/* ============================================================================
   DeliveryOn â€” Super Admin Panel (God Mode)
   Design System & Global Styles
   ============================================================================ */

:root {
    /* Color Palette â€” Dark Theme */
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-tertiary: #1a2236;
    --bg-card: #151d2e;
    --bg-elevated: #1e293b;
    --bg-hover: rgba(99, 102, 241, 0.08);

    /* Accent Colors */
    --accent-primary: #6366f1;
    --accent-primary-glow: rgba(99, 102, 241, 0.25);
    --accent-secondary: #818cf8;
    --accent-green: #22c55e;
    --accent-green-glow: rgba(34, 197, 94, 0.2);
    --accent-orange: #f59e0b;
    --accent-orange-glow: rgba(245, 158, 11, 0.2);
    --accent-red: #ef4444;
    --accent-red-glow: rgba(239, 68, 68, 0.2);
    --accent-blue: #3b82f6;
    --accent-blue-glow: rgba(59, 130, 246, 0.2);
    --accent-cyan: #06b6d4;

    /* Text */
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --text-inverse: #0f172a;

    /* Borders */
    --border-subtle: rgba(148, 163, 184, 0.08);
    --border-default: rgba(148, 163, 184, 0.12);
    --border-active: rgba(99, 102, 241, 0.4);

    /* Spacing & Sizing */
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
    --topbar-height: 60px;
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 8px 32px rgba(0,0,0,0.5);
    --shadow-glow: 0 0 20px var(--accent-primary-glow);

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 250ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 400ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset & Base */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

body {
    display: flex;
}

/* ============================================================================
   Scrollbar Custom
   ============================================================================ */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-secondary); }

/* ============================================================================
   Sidebar
   ============================================================================ */

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: width var(--transition-base);
}

.sidebar-brand {
    padding: 20px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.brand-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.brand-text {
    font-weight: 800;
    font-size: 16px;
    letter-spacing: -0.5px;
    background: linear-gradient(135deg, var(--text-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-badge {
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 1.5px;
    padding: 3px 6px;
    border-radius: 4px;
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 12px 10px;
}

.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: var(--text-muted);
    padding: 16px 12px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px 10px 60px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    position: relative;
    font-weight: 500;
    font-size: 13px;
}

.nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12), rgba(99, 102, 241, 0.06));
    color: var(--accent-secondary);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 20px;
    border-radius: 0 3px 3px 0;
    background: var(--accent-primary);
}

.nav-badge {
    margin-left: auto;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-primary);
    color: white;
    min-width: 24px;
    text-align: center;
}

.nav-badge.warning {
    background: var(--accent-red);
    animation: pulse-badge 2s infinite;
}

.nav-badge.pulse {
    background: var(--accent-green);
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid var(--border-subtle);
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.connected {
    background: var(--accent-green);
    box-shadow: 0 0 8px var(--accent-green-glow);
    animation: pulse-dot 2s infinite;
}

.status-dot.disconnected {
    background: var(--accent-red);
}

@keyframes pulse-dot {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.7; }
}

/* ============================================================================
   Main Content
   ============================================================================ */

.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    transition: margin-left var(--transition-base);
}

/* ============================================================================
   Topbar
   ============================================================================ */

.topbar {
    height: var(--topbar-height);
    max-height: var(--topbar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    flex-shrink: 0;
    flex-wrap: nowrap !important;
    overflow: visible;
    position: relative;
    z-index: 1000;
}

.topbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: nowrap !important;
    min-width: 0;
    flex-shrink: 1;
}

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.sidebar-toggle:hover { background: var(--bg-hover); color: var(--text-primary); }

.page-title {
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: nowrap !important;
    overflow: visible;
    height: 100%;
    flex-shrink: 0;
    position: relative;
}

.topbar-right * {
    flex-wrap: nowrap !important;
}

.period-selector-container {
    flex-wrap: nowrap !important;
    flex-shrink: 0;
}

.kpi-strip {
    display: flex;
    gap: 16px;
    flex-wrap: nowrap !important;
    flex-shrink: 0;
}

.kpi-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.kpi-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--accent-green);
    font-variant-numeric: tabular-nums;
}

.kpi-item.warning .kpi-value {
    color: var(--accent-red);
}

.kpi-label {
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.topbar-clock {
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
    padding: 6px 14px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-subtle);
}

/* ============================================================================
   Views (Sections)
   ============================================================================ */

.view {
    display: none;
    flex: 1;
    overflow: hidden;
}

.view.active {
    display: flex;
    flex-direction: column;
}

/* ============================================================================
   View: Torre de Controle (Dispatch)
   ============================================================================ */

.dispatch-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.map-container {
    flex: 1;
    position: relative;
}

.live-map {
    width: 100%;
    height: 100%;
    background: var(--bg-tertiary);
}

.map-overlay-controls {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 50;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.map-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    backdrop-filter: blur(12px);
}

.map-btn:hover {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
    box-shadow: var(--shadow-glow);
}

.dispatch-sidebar {
    width: 360px;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.dispatch-panel {
    padding: 16px;
    border-bottom: 1px solid var(--border-subtle);
}

.panel-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 32px 16px;
    color: var(--text-muted);
    text-align: center;
}

.empty-state.small { padding: 16px; }
.empty-state svg { opacity: 0.3; }

/* Stalled Delivery Card */
.stalled-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.stalled-card:hover {
    border-color: var(--accent-orange);
    background: rgba(245, 158, 11, 0.05);
}

.stalled-card.selected {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px var(--accent-primary-glow);
}

.stalled-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.stalled-os {
    font-weight: 700;
    font-size: 14px;
    color: var(--accent-orange);
}

.stalled-time {
    font-size: 11px;
    color: var(--accent-red);
    font-weight: 600;
}

.stalled-address {
    font-size: 12px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stalled-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Nearby Driver Card */
.driver-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    padding: 10px 12px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.driver-card:hover { border-color: var(--accent-primary); }
.driver-card.selected {
    border-color: var(--accent-green);
    background: rgba(34, 197, 94, 0.05);
}

.driver-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-cyan));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 12px;
    color: white;
    flex-shrink: 0;
}

.driver-info { flex: 1; min-width: 0; }
.driver-name { font-size: 13px; font-weight: 600; }
.driver-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 8px;
}

.driver-dist {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-green);
    white-space: nowrap;
}

/* ============================================================================
   View: War Room (DataGrid)
   ============================================================================ */

.warroom-layout {
    display: flex;
    flex-direction: column;
    flex: 1;
    overflow: hidden;
    padding: 20px;
    gap: 16px;
}

.warroom-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.filter-group {
    display: flex;
    gap: 6px;
}

.filter-btn {
    padding: 7px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.filter-btn:hover { border-color: var(--accent-primary); color: var(--text-primary); }

.filter-btn.active {
    background: var(--accent-primary);
    color: white;
    border-color: var(--accent-primary);
}

.filter-btn.warning { border-color: rgba(239, 68, 68, 0.3); color: var(--accent-red); }
.filter-btn.warning.active { background: var(--accent-red); color: white; }

.filter-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.search-input {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 13px;
    width: 280px;
    transition: border-color var(--transition-fast);
}

.search-input:focus { outline: none; border-color: var(--accent-primary); }
.search-input::placeholder { color: var(--text-muted); }

.data-grid-wrapper {
    flex: 1;
    overflow-y: auto;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-subtle);
}

.data-grid {
    width: 100%;
    border-collapse: collapse;
}

.data-grid thead {
    position: sticky;
    top: 0;
    z-index: 10;
}

.data-grid th {
    background: var(--bg-tertiary);
    padding: 10px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border-subtle);
}

.data-grid td {
    padding: 12px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.data-grid tbody tr:hover td {
    background: var(--bg-hover);
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.status-badge.pending { background: rgba(245, 158, 11, 0.12); color: var(--accent-orange); border: 1px solid rgba(245, 158, 11, 0.25); }
.status-badge.pending_next { background: rgba(245, 158, 11, 0.12); color: var(--accent-orange); border: 1px solid rgba(245, 158, 11, 0.25); }
.status-badge.accepted { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.25); }
.status-badge.picked_up { background: rgba(99, 102, 241, 0.12); color: var(--accent-primary); border: 1px solid rgba(99, 102, 241, 0.25); }
.status-badge.in_progress { background: rgba(99, 102, 241, 0.12); color: var(--accent-primary); border: 1px solid rgba(99, 102, 241, 0.25); }
.status-badge.returning { background: rgba(245, 158, 11, 0.18); color: #f59e0b; border: 1px solid rgba(245, 158, 11, 0.35); }
.status-badge.delivered_to_customer { background: rgba(59, 130, 246, 0.12); color: var(--accent-blue); border: 1px solid rgba(59, 130, 246, 0.25); }
.status-badge.delivered { background: rgba(34, 197, 94, 0.12); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.25); }
.status-badge.completed { background: rgba(34, 197, 94, 0.12); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.25); }
.status-badge.finished { background: rgba(34, 197, 94, 0.12); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.25); }
.status-badge.finished_return { background: rgba(34, 197, 94, 0.12); color: var(--accent-green); border: 1px solid rgba(34, 197, 94, 0.25); }
.status-badge.canceled { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.25); }
.status-badge.cancelled { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.25); }
.status-badge.canceled_returned { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.25); }
.status-badge.scheduled { background: rgba(148, 163, 184, 0.12); color: var(--text-secondary); border: 1px solid rgba(148, 163, 184, 0.25); }
.status-badge.blocked_by_balance { background: rgba(239, 68, 68, 0.12); color: var(--accent-red); border: 1px solid rgba(239, 68, 68, 0.25); }

/* ============================================================================
   View: Ecosystem (Stores & Drivers)
   ============================================================================ */

.ecosystem-layout {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.ecosystem-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.ecosystem-header h2 {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -0.3px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.eco-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: all var(--transition-base);
}

.eco-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.eco-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 16px;
}

.eco-card-name {
    font-size: 16px;
    font-weight: 700;
}

.eco-card-status {
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 700;
}

.eco-card-status.active { background: var(--accent-green-glow); color: var(--accent-green); }
.eco-card-status.paused { background: var(--accent-orange-glow); color: var(--accent-orange); }
.eco-card-status.blocked { background: var(--accent-red-glow); color: var(--accent-red); }

.eco-card-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.eco-stat {
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    padding: 10px;
}

.eco-stat-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.eco-stat-value {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.eco-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ============================================================================
   View: Finance
   ============================================================================ */

.finance-layout {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.finance-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.finance-card {
    border-radius: var(--radius-lg);
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
    overflow: hidden;
}

.finance-card::before {
    content: '';
    position: absolute;
    inset: 0;
    opacity: 0.08;
    border-radius: var(--radius-lg);
}

.gradient-green { background: linear-gradient(135deg, rgba(34, 197, 94, 0.15), rgba(34, 197, 94, 0.05)); border: 1px solid rgba(34, 197, 94, 0.2); }
.gradient-blue { background: linear-gradient(135deg, rgba(59, 130, 246, 0.15), rgba(59, 130, 246, 0.05)); border: 1px solid rgba(59, 130, 246, 0.2); }
.gradient-orange { background: linear-gradient(135deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05)); border: 1px solid rgba(245, 158, 11, 0.2); }
.gradient-red { background: linear-gradient(135deg, rgba(239, 68, 68, 0.15), rgba(239, 68, 68, 0.05)); border: 1px solid rgba(239, 68, 68, 0.2); }

.finance-card-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.finance-card-value {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: -1px;
    font-variant-numeric: tabular-nums;
}

.gradient-green .finance-card-value { color: var(--accent-green); }
.gradient-blue .finance-card-value { color: var(--accent-blue); }
.gradient-orange .finance-card-value { color: var(--accent-orange); }
.gradient-red .finance-card-value { color: var(--accent-red); }

.finance-card-sub {
    font-size: 11px;
    color: var(--text-muted);
}

.finance-actions {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 24px;
}

.finance-actions h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 16px;
}

.manual-entry-form {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: flex-end;
}

/* ============================================================================
   View: Health
   ============================================================================ */

.health-layout {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

.health-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.health-card {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 24px;
    text-align: center;
}

.health-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: block;
    margin-bottom: 8px;
}

.health-value {
    font-size: 32px;
    font-weight: 900;
    color: var(--accent-cyan);
    font-variant-numeric: tabular-nums;
}

.health-charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.chart-placeholder {
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: 20px;
    min-height: 240px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chart-placeholder canvas {
    width: 100% !important;
    height: auto !important;
}

/* ============================================================================
   Buttons
   ============================================================================ */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all var(--transition-fast);
    white-space: nowrap;
}

.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #4f46e5);
    color: white;
    box-shadow: 0 2px 8px var(--accent-primary-glow);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px var(--accent-primary-glow);
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-default);
}

.btn-outline:hover { border-color: var(--accent-primary); color: var(--text-primary); }

.btn-danger {
    background: linear-gradient(135deg, var(--accent-red), #dc2626);
    color: white;
}

.btn-danger:hover { transform: translateY(-1px); }
.btn-danger:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.btn-sm {
    padding: 5px 10px;
    font-size: 11px;
}

.btn-success {
    background: var(--accent-green);
    color: white;
}

.btn-warning {
    background: var(--accent-orange);
    color: var(--text-inverse);
}

/* ============================================================================
   Form Inputs
   ============================================================================ */

.form-input, .select-input {
    padding: 9px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-default);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 13px;
    font-family: inherit;
    transition: border-color var(--transition-fast);
    color-scheme: dark;
}

select, select.select-input, #global-period-select {
    color-scheme: dark !important;
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default) !important;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

option {
    background-color: #0f172a !important;
    color: #f8fafc !important;
    padding: 10px !important;
}

input[type="date"] {
    color-scheme: dark !important;
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border: 1px solid var(--border-default) !important;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    font-family: inherit;
}

.form-input:focus, .select-input:focus, select:focus, input[type="date"]:focus {
    outline: none;
    border-color: var(--accent-primary) !important;
    box-shadow: 0 0 0 3px var(--accent-primary-glow);
}

.form-input::placeholder { color: var(--text-muted); }

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 14px;
}

.form-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
}

/* ============================================================================
   Modals
   ============================================================================ */

.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(6px);
    z-index: 2147483647 !important;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast);
}

.modal-overlay.open { display: flex !important; z-index: 2147483647 !important; }

.modal {
    background: var(--bg-secondary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-xl);
    width: 520px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp var(--transition-base);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-subtle);
}

.modal-header h3 { font-size: 16px; font-weight: 700; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    line-height: 1;
    transition: color var(--transition-fast);
}

.modal-close:hover { color: var(--text-primary); }

.modal-body { padding: 20px 24px; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-subtle);
}

/* Force Assign Modal */
.force-assign-info {
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.force-assign-drivers {
    max-height: 300px;
    overflow-y: auto;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

/* ============================================================================
   Resizable Table Columns & Custom Badges
   ============================================================================ */

.data-grid th {
    position: relative;
    user-select: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.resizer {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    cursor: col-resize;
    user-select: none;
    height: 100%;
    background: transparent;
    transition: background 0.2s;
    z-index: 5;
}

.data-grid th:hover .resizer, .resizer.resizing {
    background: var(--accent-primary);
    box-shadow: 0 0 8px var(--accent-primary-glow);
}

.block-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    background: rgba(239, 68, 68, 0.15);
    color: var(--accent-red);
    border: 1px solid rgba(239, 68, 68, 0.3);
    font-size: 11px;
    font-weight: 600;
}

.block-badge-close {
    cursor: pointer;
    font-weight: 800;
    line-height: 1;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.block-badge-close:hover {
    opacity: 1;
}

.combo-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 6px;
    border-radius: 4px;
    background: linear-gradient(135deg, rgba(168, 85, 247, 0.2), rgba(99, 102, 241, 0.2));
    color: #c084fc;
    border: 1px solid rgba(168, 85, 247, 0.4);
    font-size: 10px;
    font-weight: 700;
    margin-left: 6px;
}

/* ============================================================================
   Mobile Backdrop & Drawer Sidebar
   ============================================================================ */

.mobile-sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 99;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-base);
}

.mobile-sidebar-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

/* ============================================================================
   Responsive (Desktop Collapse & Full Mobile Optimization)
   ============================================================================ */

/* Collapsed Sidebar on Desktop */
.sidebar.collapsed {
    width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .brand-badge,
.sidebar.collapsed .nav-item span:not(.nav-badge),
.sidebar.collapsed .nav-section-label {
    display: none;
}
.sidebar.collapsed .nav-item {
    justify-content: center;
    padding: 12px 0;
}
.sidebar.collapsed .nav-badge {
    position: absolute;
    top: 4px;
    right: 6px;
    min-width: 18px;
    padding: 1px 5px;
    font-size: 10px;
}
.main-content.sidebar-collapsed {
    margin-left: var(--sidebar-collapsed);
}

@media (max-width: 1200px) {
    .dispatch-sidebar { width: 320px; }
    .health-charts { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
    .kpi-strip { gap: 10px; }
    .kpi-value { font-size: 16px; }
    .finance-actions .manual-entry-form { flex-direction: column; align-items: stretch; }
    .manual-entry-form .form-group, .manual-entry-form .btn { width: 100%; }
}

@media (max-width: 768px) {
    /* 1. Off-Canvas Drawer Sidebar for Mobile */
    .sidebar {
        width: 270px !important;
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        z-index: 150;
        box-shadow: var(--shadow-lg);
        transition: left var(--transition-base);
    }
    .sidebar.mobile-open {
        left: 0 !important;
    }
    .sidebar.mobile-open .brand-text,
    .sidebar.mobile-open .brand-badge,
    .sidebar.mobile-open .nav-item span:not(.nav-badge),
    .sidebar.mobile-open .nav-section-label {
        display: inline-block !important;
    }
    .sidebar.mobile-open .nav-item {
        justify-content: flex-start !important;
        padding: 12px 16px !important;
    }

    .main-content,
    .main-content.sidebar-collapsed {
        margin-left: 0 !important;
        width: 100% !important;
    }

    /* 2. Topbar Mobile Stack */
    .topbar {
        height: auto;
        min-height: 60px;
        padding: 10px 14px 10px 60px;
        flex-wrap: wrap;
        gap: 10px;
    }
    .topbar-left {
        flex: 1;
        min-width: 140px;
    }
    .page-title {
        font-size: 16px;
    }
    .topbar-right {
        gap: 10px;
        flex-wrap: wrap;
        justify-content: flex-end;
    }
    #global-period-select {
        max-width: 125px;
        font-size: 11px;
        padding: 5px 8px;
    }

    /* Compact Topbar KPIs on mobile */
    .kpi-strip {
        display: flex !important;
        width: 100%;
        justify-content: space-around;
        gap: 4px;
        border-top: 1px solid var(--border-subtle);
        padding-top: 6px;
        margin-top: 4px;
    }
    .kpi-item {
        flex: 1;
        text-align: center;
    }
    .kpi-value {
        font-size: 14px;
    }
    .kpi-label {
        font-size: 8px;
    }

    /* 3. Dispatch Layout Stack (Map + War Room Side by Side -> Vertical Stack) */
    .dispatch-layout {
        flex-direction: column !important;
        height: calc(100vh - 110px) !important;
        overflow-y: auto !important;
    }
    #map-container {
        width: 100% !important;
        height: 38vh !important;
        min-height: 220px !important;
        flex: none !important;
        border-bottom: 2px solid var(--accent-primary);
    }
    .dispatch-sidebar {
        display: flex !important;
        width: 100% !important;
        flex: none !important;
        border-left: none !important;
        min-height: 380px !important;
    }

    /* 4. Ecosystem & Finance Views */
    .ecosystem-layout, .view-section {
        padding: 16px 12px !important;
    }
    .ecosystem-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    .header-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }
    .header-actions .search-input, .header-actions select {
        flex: 1;
        min-width: 130px;
    }
    .cards-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
    }
    .eco-card, .health-card {
        padding: 16px !important;
    }

    /* Responsive Data Grids / Tables */
    .data-grid-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
        border-radius: var(--radius-md);
    }
    .data-grid {
        min-width: 580px !important;
    }
    .data-grid th, .data-grid td {
        padding: 10px 12px !important;
        font-size: 12px !important;
    }

    /* 5. Health Charts & KPIs */
    .health-kpis {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .health-charts {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .chart-placeholder {
        min-height: 180px !important;
        padding: 12px !important;
    }

    /* 6. Modals on Mobile */
    .modal {
        width: 94% !important;
        max-width: 94% !important;
        max-height: 88vh !important;
        margin: 12px !important;
        border-radius: var(--radius-lg) !important;
    }
    .modal-header, .modal-body, .modal-footer {
        padding: 14px 16px !important;
    }
    .form-group input, .form-group select {
        font-size: 14px !important;
    }
    .modal-footer {
        flex-wrap: wrap;
        gap: 8px;
    }
    .modal-footer .btn {
        flex: 1;
        justify-content: center;
    }

    /* Responsividade móvel para formulários e modais de entregadores/lojas */
    .modal-body div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }
    .modal-body .form-input,
    .modal-body .select-input {
        width: 100% !important;
        font-size: 14px !important;
        min-height: 42px !important;
        box-sizing: border-box !important;
    }
    .modal-body label {
        font-size: 12px !important;
        font-weight: 600 !important;
    }
}

@media (max-width: 480px) {
    .health-kpis {
        grid-template-columns: 1fr !important;
    }
    .kpi-strip {
        gap: 2px;
    }
    .kpi-value {
        font-size: 13px;
    }
    .topbar-right {
        width: 100%;
        justify-content: space-between;
    }
    #global-period-select {
        flex: 1;
        max-width: 100%;
    }
}

/* ============================================================================
   Leaflet Map Icons - CorreÃ§Ã£o de Overflow e Z-Index
   ============================================================================ */
.leaflet-div-icon {
    background: transparent !important;
    border: none !important;
    overflow: visible !important;
}

.driver-map-marker, .delivery-map-marker, .store-map-marker {
    background: transparent !important;
    border: none !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    overflow: visible !important;
}

.driver-map-marker > div, .delivery-map-marker > div, .store-map-marker > div {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
    box-sizing: border-box;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.driver-map-marker > div:hover, .delivery-map-marker > div:hover, .store-map-marker > div:hover {
    transform: scale(1.12);
    z-index: 999999 !important;
}

/* Drag & Drop Route Sequence Styling */
.route-drag-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.95);
    border: 1px solid #6366f1;
    padding: 8px 12px;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.15s ease;
    user-select: none;
}
.route-drag-item:hover {
    background: rgba(45, 55, 72, 0.95);
    border-color: #818cf8;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.route-drag-item:active {
    cursor: grabbing;
}
.route-drag-item.dragging {
    opacity: 0.45;
    border: 2px dashed #a5b4fc;
    background: rgba(99, 102, 241, 0.15);
}
.route-stop-badge {
    background: #6366f1;
    color: #ffffff;
    padding: 3px 8px;
    border-radius: 12px;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.3px;
}

/* ============================================================================
   MOBILE RESPONSIVENESS â€” Complete Mobile-First Override
   ============================================================================ */

/* Hamburger button (visible only on mobile) */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 11px;
    left: 12px;
    z-index: 1200;
    width: 38px;
    height: 38px;
    background: var(--bg-card);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    padding: 0;
    cursor: pointer;
    color: var(--text-primary);
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

.mobile-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

.mobile-menu-btn.is-open {
    background: var(--bg-tertiary);
    color: var(--accent-primary);
}

/* Mobile sidebar backdrop */
.mobile-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    z-index: 1099;
    backdrop-filter: blur(2px);
}
.mobile-sidebar-backdrop.active { display: block; }

@media (max-width: 900px) {

    /* --- Sidebar --- */
    .mobile-menu-btn { display: flex !important; }

    #sidebar {
        position: fixed !important;
        left: -280px !important;
        top: 0 !important;
        bottom: 0 !important;
        z-index: 1100 !important;
        width: 260px !important;
        min-width: 260px !important;
        max-width: 260px !important;
        transition: left 0.3s ease !important;
        overflow-y: auto;
    }

    #sidebar.mobile-open {
        left: 0 !important;
    }

    #sidebar.collapsed {
        left: -280px !important;
    }

    /* --- Main Content --- */
    .main-content {
        margin-left: 0 !important;
        padding: 12px !important;
        padding-top: 68px !important;
    }

    .topbar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        height: 56px !important;
        z-index: 1000 !important;
        padding: 0 10px 0 54px !important;
        overflow: visible !important;
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
    }

    .topbar-left {
        display: flex !important;
        align-items: center !important;
        flex: 1 1 auto !important;
        min-width: 0 !important;
        overflow: hidden !important;
    }

    .topbar-left .page-title {
        font-size: 15px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        min-width: 0 !important;
    }

    .topbar-right {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-end !important;
        gap: 6px !important;
        flex-shrink: 0 !important;
        flex-grow: 0 !important;
        max-width: none !important;
        min-width: 0 !important;
        overflow: visible !important;
    }

    .topbar-right .kpi-strip,
    .topbar-right .topbar-clock {
        display: none !important;
    }

    .period-selector-container {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        margin-right: 0 !important;
        padding: 4px 6px !important;
        min-width: fit-content !important;
        overflow: visible !important;
        flex-shrink: 0 !important;
        position: relative !important;
    }

    .period-selector-container svg {
        display: none !important;
    }

    .period-selector-container select,
    #global-period-select {
        max-width: 105px !important;
        min-width: 75px !important;
        font-size: 11px !important;
        padding: 2px 4px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        flex-shrink: 0 !important;
    }

    .sidebar-toggle {
        display: none !important;
    }

    /* --- KPI Cards --- */
    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }

    /* --- Tables & Data Grids --- */
    .data-grid-wrapper {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .data-grid {
        min-width: 600px;
    }

    /* --- Modals --- */
    .modal-overlay {
        align-items: flex-end !important;
        padding: 0 !important;
    }

    .modal {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0 !important;
        max-height: 92vh !important;
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
    }

    .modal-body {
        padding: 14px !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    .modal-header {
        padding: 14px !important;
        position: sticky;
        top: 0;
        z-index: 10;
    }

    .modal-footer {
        padding: 12px 14px !important;
        position: sticky;
        bottom: 0;
        z-index: 10;
    }

    /* Form grids inside modals â†’ single column */
    .form-group div[style*="grid-template-columns:1fr 1fr"],
    div[style*="grid-template-columns: 1fr 1fr"],
    div[style*="grid-template-columns:repeat(2"] {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* General flex rows -> stack (excluding topbar) */
    .modal-body div[style*="display:flex;gap"],
    .finance-actions div[style*="display:flex;gap"] {
        flex-wrap: wrap !important;
    }

    .topbar-right,
    .topbar-right *,
    .period-selector-container {
        flex-wrap: nowrap !important;
    }

    /* Store modal grid override & full width on mobile */
    #modal-store .modal-body > div[style*="grid"],
    #modal-store .modal-body div[style*="grid-template-columns"] {
        display: grid !important;
        grid-template-columns: 1fr !important;
    }

    #modal-store {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        border-radius: 0 !important;
        max-height: 100dvh !important;
    }

    #modal-store-overlay {
        align-items: flex-start !important;
        padding: 0 !important;
    }

    /* --- Kanban / Delivery Cards --- */
    .kanban-board {
        flex-direction: column !important;
        gap: 16px !important;
    }

    .kanban-column {
        min-width: unset !important;
        width: 100% !important;
    }

    /* --- Map Responsiveness for Mobile (iPhone 14 Pro Max etc) --- */
    .dispatch-layout {
        flex-direction: column !important;
        height: auto !important;
        overflow-y: auto !important;
    }

    .map-container {
        height: 380px !important;
        min-height: 380px !important;
        width: 100% !important;
        flex: none !important;
    }

    #live-map, #map {
        height: 380px !important;
        min-height: 380px !important;
        width: 100% !important;
    }

    #modal-map-container,
    #new-deliv-map-container,
    #edit-deliv-modal-map,
    #new-deliv-modal-map {
        height: 200px !important;
        width: 100% !important;
    }

    /* --- Combo Candidates Vertical Scroll & Uniform Card Sizing --- */
    #modal-combo-suggestions-list,
    #new-deliv-combo-suggestions-list {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
        width: 100% !important;
        max-height: 260px !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }

    .combo-suggestion-item,
    div[class*="combo-suggestion"] {
        width: 100% !important;
        box-sizing: border-box !important;
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        padding: 10px !important;
        background: rgba(30, 41, 59, 0.7) !important;
        border: 1px solid var(--border-subtle) !important;
        border-radius: 8px !important;
    }

    /* --- Finance Actions Form --- */
    .manual-entry-form {
        display: flex !important;
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* --- Buttons --- */
    .btn {
        min-height: 44px;
        font-size: 14px;
    }

    .btn-group {
        flex-direction: column !important;
        gap: 8px !important;
    }

    /* --- Driver cards / Motoboy grid --- */
    .driver-grid {
        grid-template-columns: 1fr 1fr !important;
    }

    /* --- Finance Tables --- */
    .finance-tables {
        grid-template-columns: 1fr !important;
    }

    /* --- Topbar actions --- */
    .topbar-actions {
        gap: 6px !important;
    }

    .topbar-actions .btn span {
        display: none; /* hide text, show only icon */
    }

    /* KPI health mini-charts */
    .health-charts {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    /* Extra small phones (iPhone 14 Pro Max screen size) */
    .modal-overlay {
        padding: 6px !important;
    }

    .modal {
        width: 96vw !important;
        max-width: 96vw !important;
        margin: auto !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
        border-radius: 12px !important;
    }

    .modal-body {
        padding: 10px !important;
        box-sizing: border-box !important;
        overflow-x: hidden !important;
    }

    /* Ensure checkbox labels remain horizontal row alignment */
    label[style*="display:flex"],
    label[style*="display: flex"],
    .form-group label[style*="display:flex"] {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 8px !important;
        width: auto !important;
    }

    label input[type="checkbox"],
    input[type="checkbox"] {
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        min-height: 16px !important;
        flex-shrink: 0 !important;
        margin: 0 !important;
        cursor: pointer !important;
    }

    .form-group, .form-input, .select-input, select, input, textarea {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        text-overflow: ellipsis !important;
    }

    /* Fix return fee inputs & custom km inputs on iPhone/mobile */
    .return-fee-item,
    .custom-km-item {
        display: flex !important;
        flex-direction: column !important;
        gap: 6px !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Fix store-return-fee-row layout on mobile: break into 2 lines */
    .store-return-fee-row {
        flex-wrap: wrap !important;
        gap: 6px !important;
    }

    .store-return-fee-row .return-fee-type-select {
        width: 100% !important;
        min-height: 40px !important;
        font-size: 14px !important;
        padding: 6px 8px !important;
        flex: none !important;
    }

    .store-return-fee-row .return-fee-label-input {
        width: 100% !important;
        flex: 1 1 100% !important;
        min-height: 40px !important;
        font-size: 14px !important;
        padding: 6px 8px !important;
    }

    .store-return-fee-row .return-fee-price-input {
        flex: 1 !important;
        min-width: 80px !important;
        min-height: 40px !important;
        font-size: 14px !important;
        padding: 6px 8px !important;
    }

    .return-fee-label-input,
    .return-fee-cents-input,
    .custom-km-input {
        min-height: 44px !important;
        font-size: 15px !important;
        padding: 8px 12px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        border-radius: 6px !important;
    }

    select option {
        max-width: 100% !important;
        word-break: break-word !important;
    }

    .kpi-grid {
        grid-template-columns: 1fr !important;
    }

    .kpi-card {
        padding: 12px !important;
    }

    h2.section-title {
        font-size: 16px !important;
    }

    .filter-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 8px !important;
    }

    .filter-bar .search-input {
        width: 100% !important;
    }

    .modal-title, .modal-header h3 {
        font-size: 15px !important;
    }

    /* Form inputs touch-friendly */
    .form-input, .select-input {
        min-height: 44px !important;
        font-size: 16px !important; /* prevents iOS zoom */
    }

    /* Nav items text on sidebar */
    .nav-item-label { font-size: 12px !important; }
}

/* ============================================================
   Pricing Machine (God Mode) Responsive Grid & Layout
   ============================================================ */
.pm-wrapper {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 0 4px;
    overflow-x: hidden;
}

.pm-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.pm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 18px;
    width: 100%;
    box-sizing: border-box;
}

.pm-card {
    background: var(--bg-tertiary, #16162a);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 14px;
    padding: 20px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.pm-subgrid-3 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.pm-subgrid-2 {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
    gap: 10px;
    width: 100%;
    box-sizing: border-box;
}

.pm-actions {
    margin-top: 20px;
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
    width: 100%;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    .pm-wrapper {
        padding: 0;
    }
    .pm-kpis {
        grid-template-columns: 1fr 1fr !important;
        gap: 10px !important;
    }
    .pm-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }
    .pm-subgrid-3 {
        grid-template-columns: 1fr 1fr !important;
        gap: 8px !important;
    }
    .pm-subgrid-2 {
        grid-template-columns: 1fr !important;
        gap: 8px !important;
    }
    .pm-card {
        padding: 14px !important;
    }
    .pm-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }
    .pm-actions .btn {
        width: 100% !important;
        justify-content: center !important;
        font-size: 14px !important;
        padding: 12px 16px !important;
    }
}

/* Ocultar todo o conteúdo do site até que o usuário esteja autenticado */
body:not(.authenticated) .sidebar,
body:not(.authenticated) .main-content,
body:not(.authenticated) .mobile-menu-btn,
body:not(.authenticated) .mobile-sidebar-backdrop {
    display: none !important;
}

body:not(.authenticated) {
    overflow: hidden !important;
    background: #0f172a !important;
}

/* iFood Chips & Filters */
.btn-chip {
    background: var(--bg-tertiary, #1e293b);
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.15));
    color: var(--text-muted, #94a3b8);
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all 0.15s ease;
}

.btn-chip:hover {
    background: rgba(99, 102, 241, 0.15);
    color: var(--text-primary, #f1f5f9);
    border-color: rgba(99, 102, 241, 0.4);
}

.btn-chip.active {
    background: #6366f1;
    color: #ffffff;
    border-color: #6366f1;
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.chip-count {
    background: rgba(0, 0, 0, 0.25);
    color: inherit;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 10px;
}

.chip-count.warning {
    background: rgba(245, 158, 11, 0.2);
    color: #f59e0b;
}

.chip-count.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10b981;
}

.chip-count.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
}

.btn-chip.active .chip-count {
    background: rgba(255, 255, 255, 0.25);
    color: #ffffff;
}

.badge-ifood {
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
}
.badge-ifood-cfm { background: rgba(59, 130, 246, 0.15); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.3); }
.badge-ifood-rtp { background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-ifood-dsp { background: rgba(168, 85, 247, 0.15); color: #c084fc; border: 1px solid rgba(168, 85, 247, 0.3); }
.badge-ifood-con { background: rgba(34, 197, 94, 0.15); color: #4ade80; border: 1px solid rgba(34, 197, 94, 0.3); }
.badge-ifood-can { background: rgba(239, 68, 68, 0.15); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.3); }
.badge-ifood-plc { background: rgba(148, 163, 184, 0.15); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.3); }

/* iFood Integration Panel & Credentials */
@keyframes slideInRight {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.ifood-badge {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.8); }
  to { opacity: 1; transform: scale(1); }
}

.ifood-section {
  background: linear-gradient(135deg, #1a0a0b, #1e1e2e);
  border: 1px solid rgba(234, 29, 44, 0.3);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 24px;
}

.ifood-section h3 {
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.ifood-input {
  width: 100%;
  padding: 10px 14px;
  border-radius: 8px;
  background: #0f172a;
  border: 1px solid #334155;
  color: #fff;
  font-size: 13px;
  margin-bottom: 12px;
  box-sizing: border-box;
}

.ifood-input:focus {
  border-color: #ea1d2c;
  outline: none;
}

.btn-ifood-save {
  background: linear-gradient(135deg, #ea1d2c, #c41525);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  margin-right: 8px;
  transition: opacity 0.2s;
}

.btn-ifood-save:hover {
  opacity: 0.85;
}

.btn-ifood-test {
  background: linear-gradient(135deg, #1d4ed8, #1e40af);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn-ifood-test:hover {
  opacity: 0.85;
}

/* ── Toast Notifications ──────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

.toast {
    background: var(--bg-elevated, #1e293b);
    border: 1px solid var(--border, rgba(148, 163, 184, 0.15));
    border-radius: 10px;
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 500;
    min-width: 240px;
    max-width: 380px;
    color: var(--text-primary, #f8fafc);
    box-shadow: 0 4px 20px rgba(0, 0, 0, .5);
    animation: slideIn .25s ease;
    pointer-events: auto;
}

.toast.success {
    border-color: #22c55e;
    color: #22c55e;
    background: rgba(34, 197, 94, 0.1);
}

.toast.error,
.toast.danger {
    border-color: #ef4444;
    color: #ef4444;
    background: rgba(239, 68, 68, 0.1);
}

.toast.warning {
    border-color: #f59e0b;
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.toast.info {
    border-color: #3b82f6;
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.1);
}

.modal-raw-logs-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(6px);
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

.ifood-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #ea1d2c, #c41525);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
    letter-spacing: 0.5px;
    box-shadow: 0 2px 6px rgba(234, 29, 44, 0.4);
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
    animation: fadeIn 0.3s ease;
}

.ifood-blocked-alert {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999;
    background: linear-gradient(135deg, #1e1e2e, #2d1b1b);
    border: 2px solid #ea1d2c;
    border-radius: 16px;
    padding: 20px 24px;
    max-width: 360px;
    box-shadow: 0 8px 32px rgba(234, 29, 44, 0.4);
    animation: slideInRight 0.3s ease;
}

.ifood-blocked-alert-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.ifood-blocked-alert-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.ifood-blocked-alert-title {
    font-weight: 800;
    color: #fff;
    font-size: 15px;
    margin-bottom: 4px;
}

.ifood-blocked-alert-display-id {
    font-weight: 700;
    color: #ea1d2c;
    font-size: 18px;
    margin-bottom: 8px;
}

.ifood-blocked-alert-reason {
    color: #94a3b8;
    font-size: 13px;
    line-height: 1.4;
}

.ifood-blocked-alert-btn {
    margin-top: 12px;
    background: #ea1d2c;
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 6px 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s ease;
}

.ifood-blocked-alert-btn:hover {
    opacity: 0.85;
}

.modal-readonly-banner {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #ef4444;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 12px;
    font-weight: bold;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.loja-km-rate-row,
.store-km-rate-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary, #1e293b);
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 12px;
}

.store-return-fee-row {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-secondary, #0f172a);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: 12px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.15));
}

.integration-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.integration-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.35);
    border-color: rgba(99, 102, 241, 0.4);
}

/* ============================================================================
   Tables & Integration Views (iFood, Anota AI) - Prevents Overflow
   ============================================================================ */

.view#view-ifood,
.view#view-anotaai,
.view#view-integracoes,
.view#view-pedidos-integrados {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

.table-container {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: var(--bg-secondary, #131324);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.08));
    border-radius: 12px;
    margin-bottom: 20px;
    box-sizing: border-box;
}

.data-table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    text-align: left;
    font-size: 12.5px;
}

.data-table th,
.data-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.05));
    vertical-align: middle;
}

.data-table th {
    background: var(--bg-tertiary, #1e1e34);
    color: var(--text-secondary, #94a3b8);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
    position: sticky;
    top: 0;
    z-index: 2;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.035);
}

.ifood-filter-chips,
.anotaai-filter-chips,
.integration-filter-chips {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.1));
    background: var(--bg-tertiary, #1e1e34);
    color: var(--text-secondary, #94a3b8);
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    white-space: nowrap;
}

.btn-chip:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.2);
}

.btn-chip.active {
    background: var(--accent-primary, #6366f1);
    color: #fff;
    border-color: var(--accent-primary, #6366f1);
    box-shadow: 0 2px 8px rgba(99, 102, 241, 0.35);
}

.chip-count {
    background: rgba(0, 0, 0, 0.25);
    padding: 1px 6px;
    border-radius: 10px;
    font-size: 10.5px;
    font-weight: 700;
}

.chip-count.warning {
    background: rgba(245, 158, 11, 0.25);
    color: #fbbf24;
}

.chip-count.success {
    background: rgba(16, 185, 129, 0.25);
    color: #34d399;
}

.chip-count.danger {
    background: rgba(239, 68, 68, 0.25);
    color: #f87171;
}

.chip-count.info {
    background: rgba(59, 130, 246, 0.25);
    color: #93c5fd;
}

@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }

    /* Modal Mobile Adjustments */
    .modal-dialog {
        width: 96% !important;
        max-width: 96% !important;
        margin: 10px auto !important;
        max-height: 94vh !important;
    }

    .modal-body {
        padding: 12px !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
    }

    /* Convert all multi-column inline grids inside modals to clean single column or 2 column flow on mobile */
    .modal-dialog div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Keep small 2-column items nicely split if desired or unstack */
    .modal-dialog .form-input,
    .modal-dialog .select-input {
        font-size: 14px !important;
        min-height: 42px !important;
        height: auto !important;
        padding: 8px 12px !important;
        box-sizing: border-box !important;
        width: 100% !important;
    }

    .modal-dialog label {
        font-size: 12px !important;
        margin-bottom: 6px !important;
        font-weight: 600 !important;
    }

    .modal-dialog input[type="file"] {
        font-size: 12px !important;
    }

    /* Ecosystem header wrapping on mobile */
    .ecosystem-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .header-actions {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    .header-actions .search-input,
    .header-actions .select-input,
    .header-actions .btn {
        width: 100% !important;
    }
}

/* ── Field Error Highlight & Pulse ────────────────────────── */
.field-error-highlight {
    border: 2px solid #ef4444 !important;
    background-color: rgba(239, 68, 68, 0.08) !important;
    box-shadow: 0 0 0 4px rgba(239, 68, 68, 0.25), 0 0 16px rgba(239, 68, 68, 0.35) !important;
    animation: fieldErrorPulse 1.8s infinite ease-in-out !important;
    outline: none !important;
}

@keyframes fieldErrorPulse {
    0% {
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 0 8px rgba(239, 68, 68, 0.3);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.4), 0 0 20px rgba(239, 68, 68, 0.55);
    }
    100% {
        box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.2), 0 0 8px rgba(239, 68, 68, 0.3);
    }
}





