/* ==========================================================================
   RAWAAT Design System v2 — tokens, themes, shell & component polish
   Loaded AFTER style.css. Preserves existing class names.
   ========================================================================== */

:root,
html[data-theme="light"] {
    color-scheme: light;

    --primary: #f43f5e;
    --primary-dark: #e11d48;
    --primary-light: #ffe4e6;
    --primary-soft: #fff1f2;

    --success: #059669;
    --success-light: #d1fae5;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --info: #2563eb;
    --info-light: #dbeafe;

    --app-bg: #f5f6fa;
    --content-bg: #f5f6fa;
    --card-bg: #ffffff;
    --surface-2: #f9fafb;
    --surface-3: #f3f4f6;
    --border: #e8e8ed;
    --border-strong: #d4d4d8;

    --text-primary: #18181b;
    --text-secondary: #71717a;
    --text-muted: #a1a1aa;
    --text-inverse: #fafafa;

    --sidebar-bg: #111827;
    --sidebar-deep: #080c13;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #e2e8f0;
    --sidebar-active-bg: rgba(244, 63, 94, 0.16);
    --sidebar-active-border: #f43f5e;
    --sidebar-width: 268px;
    --topbar-height: 64px;

    --wa-green: #4ade80;
    --wa-green-dark: #22c55e;

    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 12px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 16px rgba(15, 23, 42, 0.07);
    --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.1);
    --radius-sm: 8px;
    --radius: 12px;
    --radius-lg: 16px;
    --transition: 0.22s cubic-bezier(0.22, 1, 0.36, 1);
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --content-max: 1400px;
    --focus-ring: 0 0 0 3px rgba(244, 63, 94, 0.28);

    /* Table rows — must flip with theme */
    --table-row: transparent;
    --table-row-alt: #f4f4f5;
    --table-row-hover: #ececf0;
    --surface: var(--card-bg);
    --money-hero-bg: linear-gradient(135deg, #ecfdf5 0%, #f0fdf4 50%, #ffffff 100%);
    --money-hero-border: #bbf7d0;
    --money-hero-label: #15803d;
    --money-hero-value: #14532d;
    --money-hero-hint: #166534;
    --money-drawer-bg: #f0f9ff;
    --money-drawer-border: #bae6fd;
    --money-drawer-label: #0369a1;
    --money-drawer-value: #0c4a6e;

    --stat-1-bg: linear-gradient(135deg, #fff, #ffe4e6);
    --stat-2-bg: linear-gradient(135deg, #fff, #d1fae5);
    --stat-3-bg: linear-gradient(135deg, #fff, #dbeafe);
    --stat-4-bg: linear-gradient(135deg, #fff, #fef3c7);
    --stat-1-icon-bg: #fecdd3;
    --stat-1-icon-fg: #be123c;
    --stat-2-icon-bg: #a7f3d0;
    --stat-2-icon-fg: #047857;
    --stat-3-icon-bg: #bfdbfe;
    --stat-3-icon-fg: #1d4ed8;
    --stat-4-icon-bg: #fde68a;
    --stat-4-icon-fg: #b45309;

    --finance-tab-active-bg: linear-gradient(135deg, #fda4af, #fbcfe8);
    --finance-tab-active-fg: #881337;
    --workflow-step-bg: rgba(255, 255, 255, 0.6);
    --workflow-active-border: #fda4af;
    --workflow-active-bg: linear-gradient(135deg, #fff, #ffe4e6);
    --pastel-gradient: linear-gradient(180deg, #fff1f2 0%, #ecfdf5 50%, #eff6ff 100%);
    --welcome-back-bg: #ecfdf5;
    --welcome-back-border: #a7f3d0;
}

html[data-theme="dark"] {
    color-scheme: dark;

    --primary: #fb7185;
    --primary-dark: #f43f5e;
    --primary-light: rgba(244, 63, 94, 0.18);
    --primary-soft: rgba(244, 63, 94, 0.12);

    --success: #34d399;
    --success-light: rgba(5, 150, 105, 0.2);
    --danger: #f87171;
    --danger-light: rgba(220, 38, 38, 0.2);
    --warning: #fbbf24;
    --warning-light: rgba(217, 119, 6, 0.2);
    --info: #60a5fa;
    --info-light: rgba(37, 99, 235, 0.2);

    --app-bg: #0b1019;
    --content-bg: #0b1019;
    --card-bg: #121925;
    --surface-2: #17202e;
    --surface-3: #1c2738;
    --border: #283243;
    --border-strong: #3f4b5f;

    --text-primary: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --text-inverse: #18181b;

    --sidebar-bg: #080c13;
    --sidebar-deep: #05080e;
    --sidebar-text: #94a3b8;
    --sidebar-text-hover: #f1f5f9;
    --sidebar-active-bg: rgba(244, 63, 94, 0.22);
    --sidebar-active-border: #fb7185;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.35), 0 4px 14px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.45);
    --focus-ring: 0 0 0 3px rgba(251, 113, 133, 0.35);

    --table-row: transparent;
    --table-row-alt: rgba(255, 255, 255, 0.04);
    --table-row-hover: rgba(244, 63, 94, 0.1);
    --surface: var(--card-bg);
    --money-hero-bg: linear-gradient(135deg, rgba(5, 150, 105, 0.2) 0%, rgba(16, 185, 129, 0.08) 55%, rgba(18, 25, 37, 0.9) 100%);
    --money-hero-border: rgba(52, 211, 153, 0.35);
    --money-hero-label: #6ee7b7;
    --money-hero-value: #ecfdf5;
    --money-hero-hint: #a7f3d0;
    --money-drawer-bg: rgba(14, 165, 233, 0.12);
    --money-drawer-border: rgba(56, 189, 248, 0.35);
    --money-drawer-label: #7dd3fc;
    --money-drawer-value: #e0f2fe;

    --stat-1-bg: linear-gradient(145deg, #1a1520 0%, #241820 55%, #121925 100%);
    --stat-2-bg: linear-gradient(145deg, #12201c 0%, #15241f 55%, #121925 100%);
    --stat-3-bg: linear-gradient(145deg, #121a28 0%, #152033 55%, #121925 100%);
    --stat-4-bg: linear-gradient(145deg, #1f1a14 0%, #261f16 55%, #121925 100%);
    --stat-1-icon-bg: rgba(244, 63, 94, 0.22);
    --stat-1-icon-fg: #fda4af;
    --stat-2-icon-bg: rgba(16, 185, 129, 0.22);
    --stat-2-icon-fg: #6ee7b7;
    --stat-3-icon-bg: rgba(59, 130, 246, 0.22);
    --stat-3-icon-fg: #93c5fd;
    --stat-4-icon-bg: rgba(245, 158, 11, 0.22);
    --stat-4-icon-fg: #fcd34d;

    --finance-tab-active-bg: linear-gradient(135deg, rgba(251, 113, 133, 0.35), rgba(244, 63, 94, 0.22));
    --finance-tab-active-fg: #fecdd3;
    --workflow-step-bg: rgba(255, 255, 255, 0.04);
    --workflow-active-border: rgba(251, 113, 133, 0.55);
    --workflow-active-bg: linear-gradient(135deg, rgba(244, 63, 94, 0.18), rgba(18, 25, 37, 0.9));
    --welcome-back-bg: rgba(16, 185, 129, 0.12);
    --welcome-back-border: rgba(52, 211, 153, 0.35);
    --pastel-gradient: linear-gradient(180deg, #0b1019 0%, #0e1420 45%, #0b1019 100%);
}

/* Base
   ========================================================================== */

html {
    font-size: 15px;
}

body,
.app-body {
    font-family: var(--font-sans);
    color: var(--text-primary);
    background: var(--content-bg);
    transition: background-color var(--transition), color var(--transition);
}

a {
    color: var(--primary);
}

a:hover {
    color: var(--primary-dark);
}

h1, h2, h3, h4, h5, h6 {
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

/* Focus visibility
   ========================================================================== */

:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.btn:focus-visible,
.form-control:focus-visible,
.nav-top-item:focus-visible,
.nav-group-head:focus-visible,
.nav-sub-item:focus-visible,
.topbar-wa-status:focus-visible,
.theme-toggle:focus-visible {
    box-shadow: var(--focus-ring);
}

/* Sidebar pro — premium navy (both themes)
   ========================================================================== */

.sidebar.sidebar-pro {
    --sidebar-pro-bg: var(--sidebar-bg);
    --sidebar-pro-border: rgba(148, 163, 184, 0.1);
    --sidebar-pro-text: var(--sidebar-text);
    --sidebar-pro-text-hover: var(--sidebar-text-hover);
    --sidebar-pro-text-active: #ffffff;
    --sidebar-pro-hover: rgba(255, 255, 255, 0.06);
    --sidebar-pro-active: var(--sidebar-active-bg);
    --sidebar-pro-active-border: var(--sidebar-active-border);
    --sidebar-pro-accent: var(--primary);
    background: linear-gradient(180deg, var(--sidebar-bg) 0%, var(--sidebar-deep) 100%);
    box-shadow: 4px 0 28px rgba(0, 0, 0, 0.28);
    display: flex;
    flex-direction: column;
}

.sidebar.sidebar-pro .sidebar-nav {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
}

.sidebar.sidebar-pro .sidebar-ops-card {
    flex-shrink: 0;
}

.sidebar.sidebar-pro .sidebar-brand-mark {
    background: linear-gradient(135deg, #f43f5e 0%, #e11d48 100%);
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.4);
}

.sidebar.sidebar-pro .nav-top-item.active,
.sidebar.sidebar-pro .nav-group.has-active > .nav-group-head {
    background: var(--sidebar-active-bg);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--sidebar-active-border);
}

.sidebar.sidebar-pro .nav-sub-item.active {
    color: #fff;
    background: rgba(244, 63, 94, 0.14);
}

.sidebar-ops-card {
    margin: 12px 14px 16px;
    padding: 12px 14px;
    border-radius: var(--radius);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(148, 163, 184, 0.12);
    color: var(--sidebar-text);
    font-size: 0.75rem;
    line-height: 1.45;
}

.sidebar-ops-card strong {
    display: block;
    color: #f8fafc;
    font-size: 0.8125rem;
    margin-bottom: 4px;
}

.sidebar-ops-card .ops-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 6px;
}

.sidebar-ops-card .ops-row--compact {
    justify-content: flex-end;
    gap: 6px;
    margin-top: 0;
}

.sidebar-ops-card .ops-dot {
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: var(--wa-green-dark);
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.2);
}

.sidebar-ops-card .ops-dot.is-warn {
    background: var(--warning);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.25);
}

.sidebar-ops-card .ops-dot.is-bad {
    background: var(--danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

/* Main + topbar
   ========================================================================== */

.main-wrapper {
    background: var(--content-bg);
}

.topbar {
    height: var(--topbar-height);
    background: color-mix(in srgb, var(--card-bg) 92%, transparent);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 0 20px 0 18px;
}

.topbar-title {
    font-size: 1.125rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.topbar-datetime {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 6px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 4px 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.topbar-avatar {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    flex-shrink: 0;
}

.topbar-user-name {
    font-weight: 600;
    color: var(--text-primary);
}

.topbar-user-role {
    color: var(--text-secondary);
}

.topbar-logout {
    width: 34px;
    height: 34px;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    background: transparent;
}

.topbar-logout:hover {
    background: var(--danger-light);
    color: var(--danger);
}

.theme-toggle {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--text-secondary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition), transform var(--transition);
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--border-strong);
    background: var(--card-bg);
}

.theme-toggle .theme-icon-moon { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-sun { display: none; }
html[data-theme="dark"] .theme-toggle .theme-icon-moon { display: inline-block; }

.content-area {
    padding: 22px 24px 40px;
    max-width: var(--content-max);
    width: 100%;
    margin: 0 auto;
}

/* Page header
   ========================================================================== */

.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding-bottom: 4px;
}

.page-header h2 {
    font-size: 1.65rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin: 0;
}

.page-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Cards & panels
   ========================================================================== */

.card,
.panel,
.settings-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
}

.card-header,
.panel-header,
.settings-card-header {
    border-bottom: 1px solid var(--border);
    background: transparent;
}

.card-header h3,
.card-header h4,
.panel-title,
.settings-card-title {
    font-size: 0.98rem;
    font-weight: 700;
    color: var(--text-primary);
}

.panel-subtitle,
.card-subtitle {
    color: var(--text-secondary);
}

/* KPI / stat cards
   ========================================================================== */

.stat-card,
a.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px 18px;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
}

.stat-card:hover,
a.stat-card.stat-card--link:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    border-color: color-mix(in srgb, var(--primary) 35%, var(--border));
}

.stat-card-label {
    color: var(--text-secondary);
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.stat-card-value {
    font-size: 1.55rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.stat-card-change {
    color: var(--text-muted);
    font-size: 0.78rem;
}

.stat-card-icon {
    border-radius: 12px;
}

/* Buttons
   ========================================================================== */

.btn {
    height: 40px;
    border-radius: 10px;
    font-weight: 600;
    transition: background var(--transition), border-color var(--transition), color var(--transition),
        box-shadow var(--transition), transform var(--transition);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 6px 16px rgba(244, 63, 94, 0.25);
}

.btn-primary:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
    box-shadow: 0 8px 20px rgba(225, 29, 72, 0.3);
}

.btn-secondary {
    background: var(--card-bg);
    color: var(--text-secondary);
    border-color: var(--border);
}

.btn-secondary:hover {
    background: var(--surface-2);
    color: var(--text-primary);
    border-color: var(--border-strong);
}

.btn:active {
    transform: translateY(1px);
}

/* Forms
   ========================================================================== */

.form-label {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-control,
input.form-control,
select.form-control,
textarea.form-control {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    border-radius: 10px;
    min-height: 42px;
    transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
}

.form-control:focus,
input.form-control:focus,
select.form-control:focus,
textarea.form-control:focus {
    border-color: color-mix(in srgb, var(--primary) 55%, var(--border));
    box-shadow: var(--focus-ring);
    outline: none;
    background: var(--card-bg);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.form-hint {
    color: var(--text-muted);
}

.form-control:disabled {
    background: var(--surface-2);
    color: var(--text-muted);
}

/* Tables
   ========================================================================== */

.table-wrapper,
.table-scroll {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--card-bg);
    overflow: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table thead th,
table thead th,
table th,
.data-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: var(--surface-2) !important;
    color: var(--text-secondary) !important;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}

.data-table tbody td,
table tbody td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary) !important;
    vertical-align: middle;
    background: transparent !important;
}

table tbody tr:nth-child(even),
.data-table tbody tr:nth-child(even) {
    background: var(--table-row-alt) !important;
}

table tbody tr:nth-child(odd),
.data-table tbody tr:nth-child(odd) {
    background: var(--table-row) !important;
}

table tbody tr:hover,
.data-table tbody tr:hover {
    background: var(--table-row-hover) !important;
}

table tbody tr:hover td,
.data-table tbody tr:hover td {
    background: transparent !important;
    color: var(--text-primary) !important;
}

/* Jobs list — due rows must stay readable in both themes */
html[data-theme="light"] .job-row--due,
html[data-theme="light"] .job-row--due:hover {
    background: #fffbeb !important;
}
html[data-theme="dark"] .job-row--due {
    background: rgba(245, 158, 11, 0.12) !important;
}
html[data-theme="dark"] .job-row--due:hover {
    background: rgba(245, 158, 11, 0.2) !important;
}
html[data-theme="dark"] .job-mobile-card--due {
    border-color: rgba(245, 158, 11, 0.45);
    background: rgba(245, 158, 11, 0.1);
}

.jobs-type-tabs,
.tabs.jobs-type-tabs {
    background: var(--card-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary);
}

.jobs-type-tabs .tab-link {
    color: var(--text-secondary);
}

.jobs-type-tabs .tab-link.active {
    color: var(--primary);
}

.filters-card,
.filter-bar,
.card.filters,
.jobs-list-panel,
.panel.jobs-list-panel {
    background: var(--card-bg);
    border-color: var(--border);
    color: var(--text-primary);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Alerts
   ========================================================================== */

.alert {
    border-radius: var(--radius);
    border-width: 1px;
    border-style: solid;
}

.alert-success {
    background: var(--success-light);
    border-color: color-mix(in srgb, var(--success) 35%, transparent);
}

html[data-theme="light"] .alert-success { color: #166534; }
html[data-theme="dark"] .alert-success { color: #a7f3d0; }
html[data-theme="light"] .alert-danger,
html[data-theme="light"] .alert-error { color: #991b1b; }
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .alert-error { color: #fecaca; }
html[data-theme="light"] .alert-warning { color: #92400e; }
html[data-theme="dark"] .alert-warning { color: #fde68a; }
html[data-theme="light"] .alert-info { color: #1e40af; background: var(--info-light); border-color: #93c5fd; }
html[data-theme="dark"] .alert-info { color: #bfdbfe; background: var(--info-light); border-color: rgba(96, 165, 250, 0.35); }

/* Status pills — dark contrast
   ========================================================================== */

html[data-theme="dark"] .status-pending,
html[data-theme="dark"] .status-pill.status-pending { background: rgba(234, 179, 8, 0.2); color: #fde68a; }
html[data-theme="dark"] .status-working,
html[data-theme="dark"] .status-pill.status-working { background: rgba(37, 99, 235, 0.25); color: #93c5fd; }
html[data-theme="dark"] .status-completed,
html[data-theme="dark"] .status-pill.status-completed { background: rgba(5, 150, 105, 0.25); color: #6ee7b7; }
html[data-theme="dark"] .status-ready,
html[data-theme="dark"] .status-pill.status-ready { background: rgba(99, 102, 241, 0.25); color: #c7d2fe; }
html[data-theme="dark"] .status-delivered,
html[data-theme="dark"] .status-pill.status-delivered { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; }
html[data-theme="dark"] .status-cancelled,
html[data-theme="dark"] .status-pill.status-cancelled { background: rgba(220, 38, 38, 0.25); color: #fecaca; }
html[data-theme="dark"] .status-credit,
html[data-theme="dark"] .status-pill.status-credit { background: rgba(234, 88, 12, 0.25); color: #fdba74; }

/* Modals & toasts
   ========================================================================== */

.modal,
.modal-card-sm,
.modal-card-lg {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
}

.toast {
    background: var(--card-bg);
    color: var(--text-primary);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
}

.search-dropdown {
    background: var(--card-bg);
    border-color: var(--border);
    box-shadow: var(--shadow-lg);
}

.search-dropdown-item:hover,
.search-dropdown-item.highlighted {
    background: var(--surface-2);
}

/* Dashboard
   ========================================================================== */

.dashboard-page {
    max-width: var(--content-max);
    gap: 20px;
}

.dashboard-greeting {
    color: var(--primary);
    font-size: 0.78rem;
    font-weight: 700;
}

.dashboard-headline {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

.counter-shortcuts {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 10px;
}

.counter-shortcut-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.875rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
}

.counter-shortcut-btn:hover {
    transform: translateY(-1px);
    border-color: color-mix(in srgb, var(--primary) 40%, var(--border));
    box-shadow: var(--shadow-md);
    color: var(--text-primary);
}

.counter-shortcut-btn--primary {
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    border-color: transparent;
    color: #fff;
}

.counter-shortcut-btn--primary:hover {
    color: #fff;
}

.counter-kbd,
.counter-kb-hints kbd {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.counter-shortcut-btn--primary .counter-kbd {
    background: rgba(255, 255, 255, 0.18);
    border-color: transparent;
    color: #fff;
}

.dashboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

/* Login
   ========================================================================== */

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background:
        radial-gradient(900px 420px at 10% -10%, rgba(244, 63, 94, 0.18), transparent 60%),
        radial-gradient(700px 380px at 100% 0%, rgba(37, 99, 235, 0.12), transparent 55%),
        var(--app-bg);
}

.login-card {
    width: min(420px, 100%);
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    padding: 28px 26px 24px;
}

.login-logo .logo-title {
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    color: var(--text-primary);
}

.login-logo .logo-subtitle {
    color: var(--text-secondary);
}

html[data-theme="dark"] .login-title,
html[data-theme="dark"] .login-logo .logo-title {
    color: var(--primary);
}

html[data-theme="dark"] .login-page {
    background:
        radial-gradient(900px 420px at 10% -10%, rgba(244, 63, 94, 0.22), transparent 60%),
        radial-gradient(700px 380px at 100% 0%, rgba(37, 99, 235, 0.16), transparent 55%),
        var(--app-bg) !important;
}

/* Hardcoded white surfaces → theme tokens */
html[data-theme="dark"] .topbar,
html[data-theme="dark"] .card,
html[data-theme="dark"] .panel,
html[data-theme="dark"] .settings-card,
html[data-theme="dark"] .modal,
html[data-theme="dark"] .search-dropdown,
html[data-theme="dark"] .toast {
    background: var(--card-bg);
    color: var(--text-primary);
    border-color: var(--border);
}

html[data-theme="dark"] input:not([type="checkbox"]):not([type="radio"]):not([type="range"]),
html[data-theme="dark"] select,
html[data-theme="dark"] textarea,
html[data-theme="dark"] .form-control {
    background: var(--surface-2) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] input::placeholder,
html[data-theme="dark"] textarea::placeholder {
    color: var(--text-muted) !important;
}

/* Empty states
   ========================================================================== */

.empty-state {
    color: var(--text-muted);
}

/* Utilities that depend on theme
   ========================================================================== */

.text-muted { color: var(--text-muted) !important; }
.text-secondary { color: var(--text-secondary); }

html[data-theme="dark"] .badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

/* Responsive
   ========================================================================== */

@media (max-width: 991px) {
    .content-area {
        padding: 16px 14px 32px;
    }

    .page-header h2 {
        font-size: 1.4rem;
    }

    .topbar-user-info {
        display: none;
    }
}

@media (max-width: 767px) {
    .topbar {
        padding: 0 12px;
    }

    .topbar-datetime {
        display: none;
    }

    .dashboard-headline {
        font-size: 1.35rem;
    }

    .stat-card-value {
        font-size: 1.35rem;
    }

    .btn {
        min-height: 42px;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print
   ========================================================================== */

@media print {
    .sidebar,
    .topbar,
    .theme-toggle,
    .toast-container,
    .sidebar-ops-card,
    .counter-shortcuts,
    .counter-kb-hints {
        display: none !important;
    }

    .main-wrapper {
        margin: 0 !important;
        width: 100% !important;
    }

    .card,
    .panel {
        box-shadow: none !important;
        border-color: #ddd !important;
    }
}

/* Login / site-gate extras
   ========================================================================== */

.login-theme-toggle {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 20;
}

.login-logo--mark {
    width: 56px;
    height: 56px;
    margin: 0 auto 12px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 800;
    color: #fff;
    background: linear-gradient(135deg, #f43f5e, #e11d48);
    box-shadow: 0 10px 24px rgba(244, 63, 94, 0.35);
}

.login-title {
    font-size: 1.45rem;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--text-primary);
    text-align: center;
}

.login-subtitle {
    text-align: center;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.login-footer-note {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.8125rem;
    margin-top: 16px;
}

.login-form .input-with-icon {
    position: relative;
}

.login-form .input-with-icon > i:first-child {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    pointer-events: none;
}

.login-form .input-with-icon input {
    width: 100%;
    min-height: 44px;
    padding: 10px 42px 10px 40px;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--card-bg);
    color: var(--text-primary);
    font-family: inherit;
}

.login-form .password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    border: none;
    background: transparent;
    color: var(--text-muted);
    cursor: pointer;
    width: 34px;
    height: 34px;
}

.site-gate-page {
    background: var(--app-bg);
    min-height: 100vh;
}

.pin-verify-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text-primary);
}

/* Dark mode — kill remaining light “islands” (dashboard Money, KPIs, panels)
   ========================================================================== */

html[data-theme="dark"] .shop-money,
html[data-theme="dark"] .finance-summary .shop-money,
html[data-theme="dark"] .shop-money--compact {
    background: var(--card-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] .shop-money-title,
html[data-theme="dark"] .shop-money-metric-value,
html[data-theme="dark"] .shop-money-block-title,
html[data-theme="dark"] .shop-money-sub {
    color: var(--text-primary);
}

html[data-theme="dark"] .shop-money-hero {
    background: var(--money-hero-bg) !important;
    border-color: var(--money-hero-border) !important;
}

html[data-theme="dark"] .shop-money-hero-label { color: var(--money-hero-label) !important; }
html[data-theme="dark"] .shop-money-hero-value { color: var(--money-hero-value) !important; }
html[data-theme="dark"] .shop-money-hero-hint { color: var(--money-hero-hint) !important; }

html[data-theme="dark"] .shop-money-metric {
    background: var(--surface-2) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .shop-money-drawer-now {
    background: var(--money-drawer-bg) !important;
    border-color: var(--money-drawer-border) !important;
}

html[data-theme="dark"] .shop-money-drawer-now-label { color: var(--money-drawer-label) !important; }
html[data-theme="dark"] .shop-money-drawer-now-value { color: var(--money-drawer-value) !important; }
html[data-theme="dark"] .shop-money-drawer-now-formula { color: var(--text-secondary) !important; }

html[data-theme="dark"] .finance-tabs {
    background: rgba(255, 255, 255, 0.06) !important;
}

html[data-theme="dark"] .finance-tab.active {
    background: var(--finance-tab-active-bg) !important;
    color: var(--finance-tab-active-fg) !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .dashboard-stats .stat-card,
html[data-theme="dark"] .stat-cards .stat-card,
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(1),
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(2),
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(3),
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(4),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(1),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(2),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(3),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(4) {
    border: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
    box-shadow: var(--shadow-sm) !important;
}

html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(1),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(1) {
    background: var(--stat-1-bg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(2),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(2) {
    background: var(--stat-2-bg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(3),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(3) {
    background: var(--stat-3-bg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(4),
html[data-theme="dark"] .stat-cards .stat-card:nth-child(4) {
    background: var(--stat-4-bg) !important;
}

html[data-theme="dark"] .dashboard-stats .stat-card .stat-card-label,
html[data-theme="dark"] .stat-cards .stat-card .stat-card-label {
    color: var(--text-secondary) !important;
}

html[data-theme="dark"] .dashboard-stats .stat-card .stat-card-value,
html[data-theme="dark"] .stat-cards .stat-card .stat-card-value {
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(1) .stat-card-icon,
html[data-theme="dark"] .stat-cards .stat-card:nth-child(1) .stat-card-icon {
    background: var(--stat-1-icon-bg) !important;
    color: var(--stat-1-icon-fg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(2) .stat-card-icon,
html[data-theme="dark"] .stat-cards .stat-card:nth-child(2) .stat-card-icon {
    background: var(--stat-2-icon-bg) !important;
    color: var(--stat-2-icon-fg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(3) .stat-card-icon,
html[data-theme="dark"] .stat-cards .stat-card:nth-child(3) .stat-card-icon {
    background: var(--stat-3-icon-bg) !important;
    color: var(--stat-3-icon-fg) !important;
}
html[data-theme="dark"] .dashboard-stats .stat-card:nth-child(4) .stat-card-icon,
html[data-theme="dark"] .stat-cards .stat-card:nth-child(4) .stat-card-icon {
    background: var(--stat-4-icon-bg) !important;
    color: var(--stat-4-icon-fg) !important;
}

html[data-theme="dark"] .alert-success,
html[data-theme="dark"] .alert-warning,
html[data-theme="dark"] .alert-danger,
html[data-theme="dark"] .alert-info,
html[data-theme="dark"] .alert-error {
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    box-shadow: none !important;
}

html[data-theme="dark"] .welcome-back-panel {
    background: var(--welcome-back-bg) !important;
    border-color: var(--welcome-back-border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .greeting-recipient-count {
    background: rgba(59, 130, 246, 0.15) !important;
    color: var(--text-primary);
}

html[data-theme="dark"] .job-workflow-step {
    background: var(--workflow-step-bg) !important;
}

html[data-theme="dark"] .job-workflow-step.is-active {
    border-color: var(--workflow-active-border) !important;
    background: var(--workflow-active-bg) !important;
}

html[data-theme="dark"] .quick-action,
html[data-theme="dark"] .dash-action,
html[data-theme="dark"] .action-card,
html[data-theme="dark"] .kpi-card,
html[data-theme="dark"] .metric-card,
html[data-theme="dark"] .awaiting-pickup-panel,
html[data-theme="dark"] .awaiting-pickup-details .panel {
    background: var(--card-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .data-table,
html[data-theme="dark"] .data-table thead th,
html[data-theme="dark"] table.data-table {
    background: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .data-table tbody tr {
    background: transparent !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .data-table tbody tr:nth-child(even) {
    background: var(--table-row-alt) !important;
}

html[data-theme="dark"] .data-table tbody tr:hover {
    background: var(--table-row-hover) !important;
}

html[data-theme="dark"] .data-table td,
html[data-theme="dark"] .data-table th {
    color: inherit !important;
    border-color: var(--border) !important;
}

html[data-theme="dark"] .filter-bar,
html[data-theme="dark"] .filters-bar,
html[data-theme="dark"] .table-toolbar,
html[data-theme="dark"] .page-toolbar,
html[data-theme="dark"] .content-card,
html[data-theme="dark"] .list-card,
html[data-theme="dark"] .section-card {
    background: var(--card-bg) !important;
    border-color: var(--border) !important;
    color: var(--text-primary) !important;
}

/* Pastel Counter theme hardcodes (end of style.css) → dark-safe */
html[data-theme="dark"] body,
html[data-theme="dark"] .app-body,
html[data-theme="dark"] .login-page {
    background: var(--pastel-gradient) !important;
    background-attachment: fixed !important;
}

html[data-theme="dark"] .topbar {
    background: rgba(18, 25, 37, 0.82) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .sidebar {
    border-right-color: var(--border) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.35) !important;
}

html[data-theme="dark"] .sidebar-logo .logo-title,
html[data-theme="dark"] .sidebar-brand-title {
    color: #fecdd3 !important;
}

html[data-theme="dark"] .nav-link.active,
html[data-theme="dark"] .nav-item.active {
    background: var(--sidebar-active-bg) !important;
    color: var(--sidebar-text-hover) !important;
    border-left: 3px solid var(--sidebar-active-border);
    box-shadow: none !important;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .panel {
    background: var(--card-bg) !important;
    box-shadow: var(--shadow-sm) !important;
    color: var(--text-primary) !important;
}

html[data-theme="dark"] .stat-card {
    border: 1px solid var(--border) !important;
}

html[data-theme="dark"] .login-title,
html[data-theme="dark"] .login-logo .logo-title {
    color: var(--primary) !important;
}
