/* <label placeholder aria-label> */
/* 
  Sistema de Rastreio Belmax
  Design System: Exaggerated Minimalism
*/

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

:root {
    /* Colors - Zinc/Slate Palette for Neutral Look */
    --bg-main: #f8fafc;
    --bg-surface: #ffffff;
    --primary: #3b82f6;
    /* Modern Blue */
    --primary-hover: #2563eb;
    --primary-light: #eff6ff;

    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-on-primary: #ffffff;

    --border: #e2e8f0;

    /* Semantic Colors */
    --success: #22c55e;
    --success-bg: #f0fdf4;
    --info: #3b82f6;
    --info-bg: #eff6ff;
    --error: #ef4444;
    --error-bg: #fef2f2;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;

    --map-stroke: #000000;
    --map-text: #1e293b;

    /* Spacing & Borders */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);

    /* Layout */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --header-height: 70px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);

    /* Utils */
    --bg-muted: #f1f5f9;
    --bg-hover: #f8fafc;
    --error-row-bg: #fff1f2;
}

[data-theme="dark"] {
    color-scheme: dark;
    --bg-main: #000000;
    --bg-surface: #111111;
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --primary-light: rgba(59, 130, 246, 0.1);

    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --text-on-primary: #ffffff;

    --border: #222222;
    --map-stroke: #000000;
    --map-text: #1e293b;

    --success-bg: rgba(34, 197, 94, 0.1);
    --info: #3b82f6;
    --info-bg: rgba(59, 130, 246, 0.1);
    --error-bg: rgba(239, 68, 68, 0.1);
    --warning-bg: rgba(245, 158, 11, 0.1);

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.5);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.8);

    /* Utils */
    --bg-muted: #111111;
    --bg-hover: #1a1a1a;
    --error-row-bg: rgba(239, 68, 68, 0.2);
}

/* Fix for native date & time picker icons in dark mode across all pages */
[data-theme="dark"] input[type="date"],
[data-theme="dark"] input[type="datetime-local"],
[data-theme="dark"] input[type="time"],
html[data-theme="dark"] input[type="date"],
html[data-theme="dark"] input[type="datetime-local"],
html[data-theme="dark"] input[type="time"] {
    color-scheme: dark !important;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator {
    filter: brightness(0) invert(1) !important;
    -webkit-filter: brightness(0) invert(1) !important;
    opacity: 1 !important;
    cursor: pointer !important;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator:hover,
[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator:hover,
html[data-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator:hover,
html[data-theme="dark"] input[type="datetime-local"]::-webkit-calendar-picker-indicator:hover,
html[data-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator:hover {
    opacity: 1 !important;
    transform: scale(1.15);
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-main);
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary);
    /* Primary blue */
}

/* Base Reset */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

button,
input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Typography */
h1,
h2,
h3,
h4 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Helper Classes */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.flex {
    display: flex;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-center {
    justify-content: center;
}

.gap-2 {
    gap: 0.5rem;
}

.gap-4 {
    gap: 1rem;
}

/* --- Components --- */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    border: 1px solid transparent;
    gap: 0.5rem;
}

.btn-primary {
    background-color: var(--primary);
    color: var(--text-on-primary);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

.btn-outline {
    background-color: transparent;
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background-color: var(--bg-main);
    border-color: var(--text-muted);
    color: var(--text-main);
}

/* Inputs */
.form-group {
    margin-bottom: 1.25rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-main);
    transition: var(--transition);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Badges */
.badge {
    display: inline-flex;
    padding: 0.25rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 9999px;
    text-transform: uppercase;
}

.badge-success {
    background-color: var(--success-bg);
    color: var(--success);
}

.badge-info {
    background-color: var(--info-bg);
    color: var(--info);
}

.badge-error {
    background-color: var(--error-bg);
    color: var(--error);
}

.badge-warning {
    background-color: var(--warning-bg);
    color: var(--warning);
}

/* Card */
.card {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: 2rem;
    box-shadow: var(--shadow-sm);
}

/* --- Pages --- */

/* Dashboard Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    transition: var(--transition);
    z-index: 100;
}

.sidebar:not(.collapsed) {
    overflow-x: hidden;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
    padding: 1.5rem 1rem;
    overflow: visible !important;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2.5rem;
    height: 36px;
}

.sidebar.collapsed .sidebar-header {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin-bottom: 2.5rem;
    height: 36px;
}

.sidebar.collapsed .brand-logo {
    display: none !important;
}

.brand-logo {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.brand-logo .logo-full {
    height: 32px;
    width: auto;
    object-fit: contain;
}

.brand-logo .logo-short {
    display: none;
    height: 32px;
    width: auto;
    object-fit: contain;
}



/* Logo switching based on theme AND sidebar state */
.brand-logo .light-logo,
.brand-logo .dark-logo {
    display: none !important;
}

/* Expanded Sidebar: show full logos */
.sidebar:not(.collapsed) .brand-logo .logo-full.light-logo {
    display: block !important;
}

[data-theme="dark"] .sidebar:not(.collapsed) .brand-logo .logo-full.dark-logo {
    display: block !important;
}

[data-theme="dark"] .sidebar:not(.collapsed) .brand-logo .logo-full.light-logo {
    display: none !important;
}

/* Collapsed Sidebar: hide logo to prevent hamburger overlap */
.sidebar.collapsed .brand-logo .logo-short.light-logo,
.sidebar.collapsed .brand-logo .logo-short.dark-logo {
    display: none !important;
}

/* Ensure logo-short is hidden when expanded */
.sidebar:not(.collapsed) .brand-logo .logo-short {
    display: none !important;
}

/* Invert icons in dark mode if they are not SVGs or need specific adjustment */
[data-theme="dark"] .logo-img img {
    /* Optional: if user doesn't provide white logo, we could filter: invert(1); */
}


.toggle-sidebar {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.sidebar.collapsed .toggle-sidebar {
    position: static;
    display: flex;
    padding: 0.5rem 0.75rem;
}

.toggle-sidebar:hover {
    background-color: var(--bg-main);
    color: var(--text-main);
}

.header-actions-side {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.sidebar-footer {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-top: auto;
    flex-shrink: 0;
    padding-top: 1rem;
    padding-bottom: 0.5rem;
    background-color: var(--bg-surface);
}

.theme-toggle-footer {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    transition: var(--transition);
    border-radius: var(--radius-md);
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 400;
}

.theme-toggle-footer:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.theme-toggle-footer .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle-footer .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle-footer .sun-icon {
    display: block;
}

.sidebar .nav-link span,
.sidebar .subnav-header span,
.sidebar .theme-text {
    white-space: nowrap;
    opacity: 1;
    transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1) 0.08s;
}

.sidebar.collapsed .theme-text {
    display: none !important;
    opacity: 0;
}

.sidebar.collapsed .theme-toggle-footer {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
}

.nav-menu {
    flex: 1;
    min-height: 0;
}

.sidebar:not(.collapsed) .nav-menu {
    overflow-y: auto;
    overflow-x: hidden;
    margin-right: -1.5rem;
    padding-right: 1.5rem;
}

.nav-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    padding: 0;
    margin: 0;
    list-style: none;
}

.nav-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-group-header {
    font-size: 0.725rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.25rem 0.75rem;
    opacity: 0.85;
    height: 24px;
    display: flex;
    align-items: center;
}

/* Subnav Collapsible (B2C / B2B inside Logística) */
.subnav-group {
    display: flex;
    flex-direction: column;
    margin-bottom: 0.15rem;
}

.subnav-header {
    display: flex;
    align-items: center;
    padding: 0.45rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.625rem;
    user-select: none;
    height: 36px;
}

.subnav-header:hover {
    background-color: var(--bg-hover);
}

.subnav-header svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
}

.subnav-chevron {
    margin-left: auto;
    width: 14px !important;
    height: 14px !important;
    transition: transform 0.25s ease;
    color: var(--text-muted) !important;
}

.subnav-group.open .subnav-chevron {
    transform: rotate(180deg);
}

.subnav-items {
    list-style: none;
    padding-left: 0.75rem;
    margin: 0 0 0.25rem 1.15rem;
    display: none;
    flex-direction: column;
    gap: 0.15rem;
    border-left: 2px solid var(--border);
}

.subnav-group.open .subnav-items {
    display: flex;
}

.subnav-items .nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.nav-group-items {
    list-style: none;
    padding-left: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.nav-item {
    margin-bottom: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    color: var(--text-muted);
    font-weight: 400;
    font-size: 0.875rem;
    transition: var(--transition);
    gap: 0.75rem;
    text-decoration: none;
    height: 36px;
}

.nav-link svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--text-muted);
    transition: var(--transition);
}

.nav-link:hover {
    background-color: var(--bg-hover);
    color: var(--text-main);
}

.nav-link:hover svg {
    color: var(--text-main);
}

.nav-link.active {
    background-color: var(--primary-light);
    color: var(--primary);
    font-weight: 500;
}

.nav-link.active svg {
    color: var(--primary);
}

/* Collapsed Sidebar Styles: Lines ONLY when collapsed, icons in exact same position */
.sidebar.collapsed .nav-group-header {
    font-size: 0;
    line-height: 0;
    padding: 0 0.75rem;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    margin: 0;
}

.sidebar.collapsed .nav-group-header::after {
    content: '';
    display: block;
    width: 100%;
    height: 1px;
    background-color: var(--border);
    opacity: 1;
}

[data-theme="dark"] .sidebar.collapsed .nav-group-header::after {
    background-color: rgba(255, 255, 255, 0.22);
}

[data-theme="light"] .sidebar.collapsed .nav-group-header::after,
:root:not([data-theme="dark"]) .sidebar.collapsed .nav-group-header::after {
    background-color: rgba(0, 0, 0, 0.18);
}

.sidebar.collapsed .nav-group:first-child .nav-group-header::after {
    display: none;
}

.sidebar.collapsed .nav-list {
    gap: 1.25rem;
}

.sidebar.collapsed .nav-group-items {
    gap: 0.25rem;
}

.sidebar.collapsed .subnav-group {
    position: relative;
}

.sidebar.collapsed .subnav-items {
    display: none;
}

.sidebar.collapsed .subnav-group:hover .subnav-items {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    left: 100%;
    top: 0;
    width: 220px;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    padding: 0.5rem;
    z-index: 1000;
    margin-left: 0.5rem;
    border-left: none;
}

/* Hover bridge between icon and flyout */
.sidebar.collapsed .subnav-group:hover .subnav-items::before {
    content: '';
    position: absolute;
    left: -0.75rem;
    top: 0;
    width: 1rem;
    height: 100%;
    background: transparent;
}

/* Floating flyout header in subnavs */
.floating-header {
    display: none;
}

.sidebar.collapsed .subnav-group:hover .floating-header {
    display: flex;
    align-items: center;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-main);
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 0.35rem;
    gap: 0.625rem;
}

.sidebar.collapsed .subnav-group:hover .floating-header svg {
    color: var(--primary);
    width: 18px;
    height: 18px;
}

/* Show labels inside flyout links */
.sidebar.collapsed .subnav-group:hover .nav-link span {
    display: inline !important;
}

.sidebar.collapsed .subnav-group:hover .nav-link {
    justify-content: flex-start !important;
    padding: 0.5rem 0.75rem !important;
    width: 100%;
}

.sidebar.collapsed .subnav-group:hover .nav-link svg {
    width: 18px;
    height: 18px;
}

.sidebar.collapsed .subnav-header span,
.sidebar.collapsed .subnav-header .subnav-chevron {
    display: none !important;
}

.sidebar.collapsed .subnav-header {
    justify-content: flex-start;
    padding: 0.45rem 0.75rem;
    width: 100%;
    height: 36px;
}

.sidebar.collapsed .subnav-group.active-subnav .subnav-header {
    background-color: var(--primary-light);
    color: var(--primary);
    border-radius: var(--radius-md);
}

.sidebar.collapsed .subnav-group.active-subnav .subnav-header svg {
    color: var(--primary);
}

.sidebar.collapsed .nav-link {
    justify-content: flex-start;
    padding: 0.5rem 0.75rem;
    width: 100%;
    height: 36px;
}

.sidebar.collapsed .nav-link span {
    display: none !important;
}

/* Floating tooltip popover for direct links without subfolders (e.g. Visão Geral) */
.sidebar.collapsed .nav-group-items .nav-item {
    position: relative;
}

.sidebar.collapsed .nav-group-items .nav-link[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 0.65rem;
    background-color: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 0.45rem 0.85rem;
    border-radius: var(--radius-md);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
    font-size: 0.875rem;
    font-weight: 400;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 1000;
}

.sidebar.collapsed .nav-group-items .nav-link[data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 1rem 1.5rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
    transition: var(--transition);
}

.tab-content,
#viewContainers {
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-bottom: 1rem;
}

.page-title {
    font-size: 1.75rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.page-subtitle {
    color: var(--text-muted);
}

/* Data Table */
.table-container {
    background-color: var(--bg-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    table-layout: fixed;
    /* Layout fixo para evitar saltos */
}

thead {
    background-color: var(--bg-main);
    border-bottom: 1px solid var(--border);
}

th {
    padding: 1rem 1.5rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    cursor: pointer;
    transition: var(--transition);
    user-select: none;
}


td {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background-color: var(--bg-main);
}

/* Row Clickable Hover */
tr[style*="cursor: pointer"]:hover td {
    background-color: var(--primary-light) !important;
}

/* Action Buttons in Table */
.btn-action {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-action:hover {
    background-color: var(--error-bg);
    color: var(--error);
}

.btn-action svg {
    width: 18px;
    height: 18px;
}

/* Action Buttons Container */
.action-buttons {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.btn-action.btn-delivery:hover {
    background-color: #ecfdf5;
    color: #10b981;
}

.btn-action.btn-delivery.has-delivery {
    color: #10b981;
}

.btn-action.btn-obs:hover {
    background-color: var(--primary-light);
    color: var(--primary);
}

.btn-action.btn-obs.has-obs {
    color: var(--primary);
}

.btn-action.btn-del:hover {
    background-color: var(--error-bg);
    color: var(--error);
}

/* Header Filters */
.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    position: relative;
    width: 100%;
    pointer-events: none;
}

.header-sort-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 2px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    pointer-events: auto; /* Required to allow clicking the sort button */
}

.header-sort-btn svg {
    width: 12px;
    height: 12px;
}

.header-sort-btn:hover {
    background-color: var(--bg-main);
    color: var(--primary);
}

.header-sort-btn.active {
    color: var(--primary);
    background-color: var(--primary-light);
}

/* Toast Notification */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 999999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

.toast {
    pointer-events: auto;
    cursor: pointer;
    background-color: #141414;
    color: #ededed;
    padding: 8px 12px;
    border-radius: 6px;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.55), 0 1px 3px rgba(0, 0, 0, 0.35);
    border: 1px solid #242424;
    border-left: 3px solid var(--primary);
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: auto;
    min-width: auto;
    max-width: 360px;
    animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    transition: all 0.25s ease;
    box-sizing: border-box;
}

.toast.toast-success,
.toast.success {
    border-left-color: var(--success) !important;
}

.toast.toast-error,
.toast.error {
    border-left-color: var(--error) !important;
}

.toast.toast-warning,
.toast.warning {
    border-left-color: var(--warning) !important;
}

.toast.toast-info,
.toast.info {
    border-left-color: var(--info) !important;
}

.toast-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.toast-icon i,
.toast-icon svg {
    width: 15px !important;
    height: 15px !important;
}

.toast.toast-success .toast-icon i,
.toast.toast-success .toast-icon svg,
.toast.success .toast-icon i,
.toast.success .toast-icon svg {
    color: var(--success) !important;
}

.toast-content {
    display: flex;
    flex-direction: column;
    gap: 1px;
    line-height: 1.25;
    flex: 1;
}

.toast-title {
    font-size: 0.8125rem;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.2;
}

.toast-message {
    font-size: 0.8125rem;
    color: #ededed;
    line-height: 1.25;
    word-break: break-word;
}

.toast-close {
    display: none !important;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.toast.fade-out {
    opacity: 0;
    transform: translateX(100%);
}

/* --- RESPONSIVE MOBILE ADJUSTMENTS --- */
/* Hide mobile-only elements on desktop */
.btn-mobile-menu {
    display: none !important;
}

.header-actions-mobile {
    display: none !important;
}

.btn-icon-square {
    display: none !important;
}

.select-wrapper-mobile {
    display: none !important;
}

.form-select-mobile {
    display: none !important;
}

.last-update {
    display: none;
}

/* === BRAZIL MAP SVG LABELS === */
.svg-state-label {
    font-family: 'Inter', sans-serif;
    pointer-events: none;
    user-select: none;
}

#brazilMapSvg polygon,
#brazilMapSvg path,
#miniBrazilMapSvg polygon,
#miniBrazilMapSvg path {
    stroke: var(--map-stroke) !important;
    transition: fill 0.3s ease, stroke 0.3s ease;
}

.svg-state-label .state-name-text {
    font-size: 8px;
    font-weight: 700;
    fill: var(--map-text);
    text-anchor: middle;
    dominant-baseline: central;
}

.svg-state-label .state-count-text {
    font-size: 7px;
    font-weight: 600;
    fill: var(--map-text);
    opacity: 0.85;
    text-anchor: middle;
    dominant-baseline: central;
}

/* Contrast for dark states in light mode */
.state-label-contrast .state-name-text,
.state-label-contrast .state-count-text {
    fill: #ffffff !important;
}

/* ================================================
   SHARED COMPONENTS - Used across multiple pages
   ================================================ */

/* --- Custom Modal --- */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease-out;
}

.modal-backdrop.open {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 400px;
    padding: 2rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    border: 1px solid var(--border);
}

.modal-backdrop.open .modal-content {
    transform: translateY(0);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.modal-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 2rem;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* --- Drawer Slide-in Panel --- */
.drawer-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0);
    z-index: 2000;
    pointer-events: none;
    transition: all 0.4s ease;
}

.drawer-backdrop.active {
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: -450px;
    width: 450px;
    height: 100vh;
    background: var(--bg-surface);
    box-shadow: -10px 0 30px rgba(0, 0, 0, 0.1);
    z-index: 2001;
    display: flex;
    flex-direction: column;
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.drawer.active {
    transform: translateX(-450px);
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.drawer-header h3 {
    font-size: 1.125rem;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn-close-drawer {
    background: var(--bg-main);
    border: 1px solid var(--border);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.btn-close-drawer:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

.btn-close-drawer svg,
.btn-close-drawer i {
    width: 16px;
    height: 16px;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* --- Filter Form (inside drawers) --- */
.filter-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.filter-label {
    font-size: 0.75rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.date-inputs span {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
}

.input-date {
    flex: 1;
    padding: 0.625rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    color: var(--text-main);
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-date:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.filter-actions-sticky {
    position: sticky;
    bottom: 0;
    margin-top: auto;
    padding-top: 1.5rem;
    background: var(--bg-surface);
    display: flex;
    gap: 1rem;
    border-top: 1px solid var(--border);
}

.filter-hint {
    font-size: 0.65rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- Header Action Button (filter/export buttons in page headers) --- */
.btn-header-action {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 1.15rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.btn-header-action:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-header-action i.icon-primary {
    width: 20px;
    height: 20px;
    color: var(--primary);
    display: flex;
    align-items: center;
}

/* --- Input Group Helpers --- */
.input-group-relative {
    position: relative;
    display: flex;
    align-items: center;
}

.clear-input {
    position: absolute;
    right: 2.25rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.clear-input svg,
.clear-input i {
    width: 14px;
    height: 14px;
}

.clear-input:hover {
    background-color: var(--border);
    color: var(--text-main);
}

.clear-input.visible {
    display: flex;
}

/* --- Checkbox Items (shared across filter drawers) --- */
.checkbox-group-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

.checkbox-list-scroll {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.5rem;
    background: var(--bg-main);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.65rem 0.75rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-main);
}

.checkbox-item:hover {
    background-color: var(--bg-surface);
}

.checkbox-item input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: var(--primary);
    flex-shrink: 0;
}

/* --- Date Shortcuts --- */
.date-shortcuts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.btn-shortcut {
    background: var(--bg-main);
    border: 1px solid var(--border);
    padding: 0.5rem 0.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    text-align: center;
}

.btn-shortcut:hover,
.btn-shortcut.active {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary);
}

/* --- Spin animation for loading icons --- */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* --- FadeIn animation --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* --- CHECKBOX SELECT/CLEAR ACTIONS IN DRAWER FILTERS --- */
.checkbox-actions-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 0.5rem;
    margin-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.checkbox-actions-header .btn-link-action {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    text-align: center;
    padding: 2px 6px;
    transition: opacity 0.2s ease;
    line-height: 1.25;
}

.checkbox-actions-header .btn-link-action:hover {
    opacity: 0.78;
}

/* --- TOAST CLOSE BUTTON --- */
.toast-close {
    display: none !important;
}

/* --- SECTION HEADER INLINE & SYNC INFO TOP (SHARED) --- */
.section-header-inline {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    margin-bottom: 1rem;
    width: 100%;
}

.sync-info-top {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.72rem;
    font-weight: 500;
    opacity: 0.75;
}

.sync-info-top i {
    width: 12px;
    height: 12px;
}

.header-actions .sync-info-top {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0.85;
}

.header-actions .sync-info-top i {
    width: 14px;
    height: 14px;
    color: var(--text-muted);
}

/* --- Global Page Loader --- */
.global-page-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: var(--bg-main);
    z-index: 99999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease-out, visibility 0.4s ease-out;
}
.global-page-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}
.global-page-loader .loader-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: loader-spin 1s linear infinite;
    margin-bottom: 1rem;
}
@keyframes loader-spin {
    to { transform: rotate(360deg); }
}

.no-transition,
.no-transition * {
    transition: none !important;
}

/* --- System Selector Styles --- */
.system-dropdown {
    display: none;
    position: absolute;
    bottom: 100%;
    left: 0;
    width: 100%;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    z-index: 1000;
    flex-direction: column;
    gap: 0.25rem;
    list-style: none;
}

.system-dropdown.show {
    display: flex;
}

.sidebar.collapsed .system-dropdown {
    left: 100%;
    bottom: 0;
    width: 220px;
    margin-left: 0.5rem;
    margin-bottom: 0;
}

.sidebar.collapsed .system-chevron {
    display: none !important;
}
