/* ================================================
   VALET INDONESIA — Design System v2
   Modern CSS: custom props, logical, clamp, layers
   Browser support: Chrome 105+, Safari 16+, FF 110+
   ================================================ */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&family=Sora:wght@600;700;800&display=swap');

/* ── 0. LAYER ORDER ── */
@layer reset, tokens, base, layout, components, utilities, responsive;

/* ── 1. TOKENS ── */
@layer tokens {
    :root {
        color-scheme: dark;
        --ui-font-size: 85%;

        /* Colors */
        --bg:              #000000;
        --surface:         #0a0a0a;
        --surface-2:       #131313;
        --surface-border:  rgba(255 255 255 / 0.12);
        --input-bg:        #0f1012;
        --input-border:    rgba(255 255 255 / 0.13);
        --header-bg:       #0f1114;
        --table-header-bg: rgba(0, 0, 0, 0.3);
        --dock-bg:         #101317;
        --dock-item-color: #d4d4d8;
        --dock-text-1:     #ffffff;
        --dock-text-2:     #ffc58e;
        --text:            #f6f6f7;
        --text-muted:      #a7abb2;

        /* Brand */
        --primary:       #ff8a2a;
        --primary-dark:  #dc5a00;
        --primary-light: #ffb36b;
        --primary-glow:  rgba(255 138 42 / 0.22);

        /* Semantic */
        --danger:      #e53e3e;
        --danger-bg:   rgba(229 62 62 / 0.10);
        --success:     #7aed82;
        --success-bg:  rgba(122 237 130 / 0.16);
        --wa:          #166534;
        --wa-bg:       rgba(22 101 52 / 0.16);
        --wa-border:   rgba(22 101 52 / 0.42);

        /* Radii */
        --radius-lg: 16px;
        --radius-md: 10px;
        --radius-sm:  6px;
        --radius-btn: 12px;

        /* Spacing scale */
        --space-1: 4px;
        --space-2: 8px;
        --space-3: 12px;
        --space-4: 16px;
        --space-5: 20px;
        --space-6: 24px;

        /* Typography */
        --font-sans: 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
        --font-display: 'Sora', var(--font-sans);
        --font-mono: 'JetBrains Mono', 'Courier New', Courier, monospace;

        /* Transitions */
        --ease:     cubic-bezier(0.4, 0, 0.2, 1);
        --duration: 180ms;
    }

    [data-theme='light'] {
        color-scheme: light;
        --bg:              #eef3f8;
        --surface:         #ffffff;
        --surface-2:       #e8eef5;
        --surface-border:  #d6dde7;
        --input-bg:        #fdfefe;
        --input-border:    rgba(15, 23, 42, 0.22);
        --header-bg:       #ffffff;
        --table-header-bg: rgba(15, 23, 42, 0.06);
        --dock-bg:         #ffffff;
        --dock-item-color: #1f2937;
        --dock-text-1:     #111827;
        --dock-text-2:     #374151;
        --text:            #0f172a;
        --text-muted:      #334155;
        
        --primary-glow:  rgba(255 138 42 / 0.14);
        --danger-bg:     rgba(229 62 62 / 0.08);
        --success-bg:    rgba(255 157 74 / 0.12);
        --wa:            #166534;
        --wa-bg:         rgba(22 101 52 / 0.12);
        --wa-border:     rgba(22 101 52 / 0.35);
    }
}

/* ── 2. RESET ── */
@layer reset {
    *, *::before, *::after { box-sizing: border-box; }

    /* Remove default margin/padding from all */
    html, body, h1, h2, h3, h4, h5, h6,
    p, figure, blockquote, dl, dd,
    ul, ol, li, menu { margin: 0; padding: 0; }

    /* Prevent font size inflation on mobile Safari */
    html {
        font-size: var(--ui-font-size);
        -webkit-text-size-adjust: none;
        text-size-adjust: none;
        /* Prevent horizontal overflow */
        overflow-x: hidden;
    }

    img, picture, video, canvas, svg {
        display: block;
        max-width: 100%;
    }

    input, button, textarea, select {
        font: inherit;   /* Inherit font from parent (not browser default) */
    }

    button { cursor: pointer; }

    /* Min font-size 16px on inputs prevents iOS zoom */
    input, select, textarea {
        font-size: max(16px, 1rem);
    }

    /* Remove list styling when role=list */
    ul:where([role='list']),
    ol:where([role='list']) { list-style: none; }

    /* Smoother focus outline */
    :focus-visible {
        outline: 2px solid var(--primary);
        outline-offset: 3px;
        border-radius: var(--radius-sm);
    }

    /* Remove focus-visible on mouse click */
    :focus:not(:focus-visible) { outline: none; }
}

/* ── 3. BASE — body, type, links ── */
@layer base {
    body {
        background: var(--bg);
        color: var(--text);
        font-family: var(--font-sans);
        line-height: 1.5;
        min-block-size: 100dvh;
        padding-block-end: 90px;
        -webkit-font-smoothing: antialiased;
        -moz-osx-font-smoothing: grayscale;
        /* Better text rendering */
        text-rendering: optimizeLegibility;
    }

    /* Balanced headings */
    h1, h2, h3, h4, h5, h6 {
        text-wrap: balance;
        line-height: 1.2;
    }

    p { text-wrap: pretty; }

    a { color: inherit; }

    table {
        width: 100%;
        border-collapse: collapse;
    }

    th, td {
        padding: 10px 12px;
        text-align: left;
        border-bottom: 1px solid var(--surface-border);
        font-size: 0.88rem;
    }

    th {
        color: var(--text-muted);
        font-weight: 600;
        font-size: 0.75rem;
        text-transform: uppercase;
        letter-spacing: 0.6px;
        background: var(--table-header-bg);
    }
}

/* ── 4. LAYOUT ── */
@layer layout {
    .auth-wrapper {
        display: grid;
        place-items: center;
        min-block-size: 100dvh;
        padding: var(--space-5);
        background: radial-gradient(ellipse at top, #2a1a12 0%, var(--bg) 60%);
    }
    [data-theme='light'] .auth-wrapper {
        background: radial-gradient(ellipse at top, #ffe8d2 0%, #eef3f8 62%);
    }

    .dash-header {
        background: var(--header-bg);
        border-bottom: 1px solid #1f2329;
        padding: 14px 20px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        position: sticky;
        inset-block-start: 0;
        z-index: 100;
        /* Improve compositing */
        will-change: transform;
    }

    .dash-container {
        padding: var(--space-5);
        max-width: 1100px;
        margin-inline: auto;
    }

    .grid                { display: grid; gap: 16px; }
    .grid-cols-2         { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
    .grid-cols-3         { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
    .grid-cols-4         { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
    .justify-between     { display: flex; justify-content: space-between; align-items: center; }

    .table-wrapper {
        overflow-x: auto;
        overscroll-behavior-x: contain;
        -webkit-overflow-scrolling: touch;
    }
}

/* ── 5. COMPONENTS ── */
@layer components {

    /* —— PANEL (AUTH) —— */
    .panel-glass {
        background: var(--surface);
        border: 1px solid var(--surface-border);
        border-radius: var(--radius-lg);
        padding: 36px 32px;
        width: 100%;
        max-width: 410px;
        box-shadow: 0 18px 38px rgba(0 0 0 / 0.48);
    }

    /* —— BRAND TITLE —— */
    h1.brand-title {
        font-family: var(--font-display);
        font-size: clamp(1.4rem, 5vw, 2rem);
        background: linear-gradient(90deg, #ffd7b0, #ff9f4d, #ffd7b0);
        background-size: 200% auto;
        -webkit-background-clip: text;
        background-clip: text;
        color: transparent;
        animation: shimmer 3s linear infinite;
        margin-block-end: 8px;
    }

    .dash-brand {
        font-family: var(--font-display);
        font-size: 1.1rem;
        font-weight: 800;
        color: var(--primary);
        text-decoration: none;
        letter-spacing: 0.5px;
    }

    /* —— FORM —— */
    .form-group {
        margin-block-end: 1.1rem;
    }

    .form-group label {
        display: block;
        margin-block-end: 5px;
        font-size: 0.8rem;
        color: var(--text-muted);
        font-weight: 500;
        letter-spacing: 0.3px;
    }

    .form-control {
        width: 100%;
        background: var(--input-bg);
        border: 1px solid var(--input-border);
        color: var(--text);
        padding: 12px 14px;
        border-radius: var(--radius-sm);
        font-size: 1rem;          /* ≥ 16px on real devices — prevents iOS zoom */
        transition:
            border-color var(--duration) var(--ease),
            box-shadow   var(--duration) var(--ease);
        -webkit-appearance: none;
        appearance: none;
        accent-color: var(--primary);
    }

    .form-control:focus {
        outline: none;
        border-color: var(--primary);
        box-shadow: 0 0 0 3px var(--primary-glow);
    }

    .form-control option { background: var(--surface); color: var(--text); }

    /* —— BUTTONS —— */
    .btn-primary {
        width: 100%;
        background: linear-gradient(180deg, #ffb36b, #ff8a2a);
        color: #111111;
        border: 1px solid rgba(255 170 102 / 0.42);
        padding: 14px;
        border-radius: var(--radius-btn);
        font-weight: 700;
        font-size: 0.95rem;
        transition: filter var(--duration) var(--ease), transform 80ms, box-shadow var(--duration) var(--ease);
        box-shadow: 0 8px 18px rgba(220 90 0 / 0.24), inset 0 1px 0 rgba(255 255 255 / 0.16);
        letter-spacing: 0.5px;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
    }

    .btn-primary:active  { transform: translateY(1px); }
    .btn-primary:hover   { filter: brightness(1.03); box-shadow: 0 0 0 1px rgba(255 138 42 / 0.34), 0 10px 20px rgba(220 90 0 / 0.28), inset 0 1px 0 rgba(255 255 255 / 0.2); }

    .btn-sm {
        padding: 7px 12px;
        font-size: 0.8rem;
        border-radius: var(--radius-btn);
        font-weight: 600;
        text-decoration: none;
        border: 1px solid var(--surface-border);
        background: var(--surface-2);
        transition: all var(--duration) var(--ease);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 7px;
    }
    .btn-sm:hover { border-color: var(--primary); box-shadow: 0 6px 14px rgba(0 0 0 / 0.24); transform: translateY(-1px); }
    .btn-sm.btn-primary {
        width: auto;
        padding: 7px 12px;
        font-size: 0.8rem;
        background: linear-gradient(180deg, #ffb36b, #ff8a2a);
        color: #111111 !important;
        border: 1px solid rgba(255 170 102 / 0.42);
        box-shadow: 0 8px 18px rgba(220 90 0 / 0.24), inset 0 1px 0 rgba(255 255 255 / 0.16);
    }
    .btn-primary svg, .btn-sm svg, .action-btn svg {
        width: 15px;
        height: 15px;
        stroke-width: 2.1;
        flex-shrink: 0;
    }

    .btn-danger {
        background: var(--danger-bg);
        color: var(--danger);
        border: 1px solid rgba(229 62 62 / 0.2);
        border-radius: var(--radius-btn);
    }
    .btn-danger:hover  { filter: brightness(1.2); }
    .btn-success       { background: linear-gradient(180deg, #7aed82, #56895e); color: #0b0b0b; border: 1px solid rgba(122 237 130 / 0.58); box-shadow: 0 8px 18px rgba(86 137 94 / 0.24), inset 0 1px 0 rgba(255 255 255 / 0.15); border-radius: var(--radius-btn); }
    .btn-success:hover { filter: brightness(1.04); box-shadow: 0 0 0 1px rgba(122 237 130 / 0.34), 0 10px 20px rgba(86 137 94 / 0.28); }

    /* —— CARDS —— */
    .card {
        background: var(--surface);
        border: 1px solid var(--surface-border);
        border-radius: 16px;
        padding: 18px;
        box-shadow: 0 12px 24px rgba(0 0 0 / 0.3);
    }
    .card h3 {
        margin-block-end: 14px;
        font-size: 0.98rem;
        color: var(--text);
        font-weight: 700;
        letter-spacing: 0.3px;
    }

    /* —— ALERTS —— */
    .alert {
        padding: 11px 14px;
        border-radius: var(--radius-sm);
        margin-block-end: 16px;
        font-size: 0.875rem;
        text-align: center;
    }
    .alert-error {
        background: var(--danger-bg);
        color: var(--danger);
        border: 1px solid rgba(229 62 62 / 0.2);
    }

    /* —— BADGE —— */
    .badge {
        display: inline-block;
        padding: 2px 8px;
        border-radius: 20px;
        font-size: 0.7rem;
        font-weight: 700;
        letter-spacing: 0.5px;
    }

    /* —— PLATE NUMBER —— */
    .plate {
        display: inline-block;
        background: linear-gradient(180deg, #ffffff, #efefef);
        color: #141414;
        font-family: var(--font-display);
        font-weight: 700;
        font-size: clamp(0.72rem, 2.2vw, 1rem);
        letter-spacing: 1.8px;
        padding: 4px 12px;
        border-radius: 8px;
        border: 2px solid #1a1a1a;
        box-shadow: inset 0 0 0 1px #d6d6d6, 0 2px 6px rgba(0 0 0 / 0.4);
        white-space: nowrap;
        line-height: 1.5;
        vertical-align: middle;
        text-transform: uppercase;
        flex-shrink: 0;
        /* contain repaints */
        contain: layout style;
    }

    .plate-sm {
        font-size: clamp(0.62rem, 1.8vw, 0.78rem);
        padding: 2px 8px;
        letter-spacing: 2px;
        border-radius: 6px;
    }

    /* —— SPINNER / LOADER —— */
    .global-loader {
        position: fixed;
        inset: 0;
        background: rgba(5 5 5 / 0.92);
        z-index: 999999;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: #fff;
        text-align: center;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }

    .spinner {
        inline-size: 60px;
        block-size: 60px;
        border: 4px solid rgba(255 106 0 / 0.15);
        border-top-color: var(--primary);
        border-radius: 50%;
        animation: spin 0.9s infinite cubic-bezier(0.4, 0, 0.2, 1);
        margin-block-end: 22px;
    }

    /* —— NAV (OWNER/SUPERVISOR) —— */
    .top-nav-owner {
        background: var(--surface);
        border: 1px solid rgba(255 255 255 / 0.06);
        padding: 6px;
        border-radius: var(--radius-md);
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
        margin-block-end: 20px;
    }

    .top-nav-owner a {
        padding: 8px 16px;
        border-radius: var(--radius-sm);
        color: var(--text-muted);
        text-decoration: none;
        font-size: 0.85rem;
        font-weight: 500;
        transition: all var(--duration) var(--ease);
        white-space: nowrap;
    }
    .top-nav-owner a:hover { color: var(--text); background: var(--surface-border); }
    .top-nav-owner a.active {
        background: var(--primary);
        color: #fff;
        font-weight: 700;
        box-shadow: 0 2px 12px rgba(255 106 0 / 0.35);
    }

    /* —— HAMBURGER BUTTON —— */
    .hamburger-btn {
        display: none;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        gap: 5px;
        width: 40px;
        height: 40px;
        background: var(--surface-2);
        border: 1px solid var(--surface-border);
        border-radius: var(--radius-sm);
        cursor: pointer;
        flex-shrink: 0;
        transition: background var(--duration) var(--ease);
    }
    .hamburger-btn:hover { background: var(--surface-border); }
    .hamburger-btn .bar {
        display: block;
        width: 20px;
        height: 2px;
        background: var(--text);
        border-radius: 2px;
        transition: transform var(--duration) var(--ease), opacity var(--duration) var(--ease);
        transform-origin: center;
    }
    .hamburger-btn.open .bar:nth-child(1) { transform: translateY(7px) rotate(45deg); }
    .hamburger-btn.open .bar:nth-child(2) { opacity: 0; }
    .hamburger-btn.open .bar:nth-child(3) { transform: translateY(-7px) rotate(-45deg); }

    /* —— MOBILE NAV DRAWER —— */
    .mobile-nav-drawer {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 9998;
        background: rgba(0 0 0 / 0.6);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        opacity: 0;
        transition: opacity 240ms var(--ease);
    }
    .mobile-nav-drawer.open {
        display: block;
        opacity: 1;
    }
    .mobile-nav-panel {
        position: absolute;
        inset-block: 0;
        inset-inline-end: 0;
        width: min(300px, 85vw);
        background: var(--surface);
        border-inline-start: 1px solid rgba(249 115 22 / 0.18);
        padding: 24px 20px;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
        gap: 6px;
        transform: translateX(100%);
        transition: transform 260ms var(--ease);
    }
    .mobile-nav-drawer.open .mobile-nav-panel {
        transform: translateX(0);
    }
    .mobile-nav-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-block-end: 20px;
        padding-block-end: 16px;
        border-block-end: 1px solid var(--surface-border);
    }
    .mobile-nav-header h3 {
        font-family: var(--font-display);
        font-size: 0.9rem;
        color: var(--primary);
        letter-spacing: 1px;
        margin: 0;
    }
    .mobile-nav-close {
        background: none;
        border: none;
        color: var(--text-muted);
        font-size: 1.4rem;
        cursor: pointer;
        line-height: 1;
    }
    .mobile-nav-link {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 13px 14px;
        border-radius: var(--radius-sm);
        color: var(--text);
        text-decoration: none;
        font-size: 0.9rem;
        font-weight: 500;
        transition: background var(--duration) var(--ease), color var(--duration) var(--ease);
        border: 1px solid transparent;
    }
    .mobile-nav-link:hover {
        background: rgba(249 115 22 / 0.08);
        color: var(--primary);
        border-color: rgba(249 115 22 / 0.15);
    }
    .mobile-nav-link.danger { color: var(--danger); }
    .mobile-nav-link.danger:hover { background: var(--danger-bg); color: var(--danger); border-color: rgba(229 62 62 / 0.2); }
    .mobile-nav-divider {
        height: 1px;
        background: var(--surface-border);
        margin-block: 8px;
    }
    .mobile-nav-section-label {
        font-size: 0.65rem;
        font-weight: 700;
        letter-spacing: 1px;
        color: var(--text-muted);
        text-transform: uppercase;
        padding: 8px 14px 4px;
    }

    /* —— BOTTOM DOCK —— */
    .bottom-dock-container {
        position: fixed;
        inset-block-end: 16px;
        inset-inline: 0;
        display: flex;
        justify-content: center;
        z-index: 9999;
        pointer-events: none;
    }

    .bottom-dock {
        background: var(--dock-bg);
        border: 1px solid var(--surface-border);
        border-radius: 26px;
        padding: 7px 12px;
        display: flex;
        gap: 4px;
        box-shadow: 0 10px 24px rgba(0 0 0 / 0.35);
        pointer-events: auto;
    }

    .dock-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--dock-item-color);
        text-decoration: none;
        font-size: 1.3rem;
        padding: 8px 20px;
        border-radius: 20px;
        transition: all var(--duration) var(--ease);
        /* Silver-white gradient on the entire item */
        filter: drop-shadow(0 1px 2px rgba(0 0 0 / 0.4));
    }
    .dock-item svg {
        filter: none;
        background: none;
        border: none;
        border-radius: 0;
        padding: 0;
    }
    .dock-item span {
        font-size: 0.6rem;
        margin-block-start: 3px;
        font-weight: 700;
        letter-spacing: 0.3px;
        /* Adaptive gradient text */
        background: linear-gradient(180deg, var(--dock-text-1) 0%, var(--dock-text-2) 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }
    .dock-item:is(:hover, :active) {
        background: #1a1f25;
        color: var(--primary);
        translate: 0 -3px;
        filter: drop-shadow(0 0 8px rgba(255 138 42 / 0.35));
    }
    .dock-item:is(:hover, :active) svg { filter: none; }
    .dock-item:is(:hover, :active) span {
        background: linear-gradient(180deg, #fdba74 0%, #f97316 100%);
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
        background-clip: text;
    }

    /* —— MODAL —— */
    .modal { transition: opacity var(--duration) var(--ease); }

    /* —— FLOATING UI CONTROLLER —— */
    .ui-float-controller {
        position: fixed;
        right: 16px;
        bottom: 110px;
        z-index: 10001;
        display: grid;
        gap: 8px;
    }
    .ui-float-btn {
        width: 44px;
        height: 44px;
        border-radius: 999px;
        border: 1px solid var(--surface-border);
        background: linear-gradient(180deg, var(--surface), var(--surface-2));
        color: var(--text);
        display: inline-flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 10px 20px rgba(0 0 0 / 0.28);
        transition: transform var(--duration) var(--ease), box-shadow var(--duration) var(--ease), filter var(--duration) var(--ease);
    }
    .ui-float-btn:hover {
        transform: translateY(-1px);
        box-shadow: 0 12px 24px rgba(0 0 0 / 0.35);
        filter: brightness(1.05);
    }
    .ui-float-btn svg {
        width: 18px;
        height: 18px;
        stroke: currentColor;
    }
    .ui-scale-pill {
        min-width: 44px;
        height: 30px;
        border-radius: 999px;
        background: var(--surface);
        border: 1px solid var(--surface-border);
        color: var(--text-muted);
        font-size: 0.62rem;
        font-weight: 800;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        letter-spacing: 0.4px;
    }
    [data-theme='light'] .ui-float-btn {
        background: linear-gradient(180deg, #ffffff, #edf2f8);
        box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
    }

    /* Keep card-like blocks consistent across pages */
    .summary-card,
    .stat-card,
    .valet-card,
    .dash-card,
    .filter-box,
    .format-group {
        border-style: solid !important;
        border-color: var(--surface-border) !important;
        box-shadow: 0 10px 24px rgba(0 0 0 / 0.24), inset 0 1px 0 rgba(255 255 255 / 0.04);
    }
}

/* Light readability refinement */
[data-theme='light'] body { background: var(--bg); }
[data-theme='light'] .dash-header {
    border-bottom: 1px solid rgba(15, 23, 42, 0.14);
}
[data-theme='light'] .card,
[data-theme='light'] .panel-glass,
[data-theme='light'] .bottom-dock {
    box-shadow: 0 8px 18px rgba(15, 23, 42, 0.08);
}
[data-theme='light'] .btn-sm {
    background: linear-gradient(180deg, #ffffff, #f8fbff);
    color: #0f172a;
    border-color: rgba(15, 23, 42, 0.18);
}
[data-theme='light'] .btn-primary {
    color: #ffffff;
    border-color: rgba(194, 65, 12, 0.35);
}
[data-theme='light'] .btn-success {
    color: #ffffff;
    border-color: rgba(22, 101, 52, 0.45);
}
[data-theme='light'] .btn-danger {
    background: #fee2e2;
    color: #991b1b;
    border-color: #fca5a5;
}
[data-theme='light'] .form-group label,
[data-theme='light'] th,
[data-theme='light'] .mobile-nav-section-label,
[data-theme='light'] .top-nav-owner a {
    color: #334155;
}
[data-theme='light'] .top-nav-owner a.active {
    color: #ffffff;
}
[data-theme='light'] .dock-item svg {
    background: transparent !important;
    border: 0 !important;
    border-radius: 0 !important;
    padding: 0 !important;
    box-shadow: none !important;
    filter: none;
}
[data-theme='light'] .btn-sm.btn-primary {
    color: #111111 !important;
    border-color: rgba(194, 65, 12, 0.35);
    background: linear-gradient(180deg, #ffb36b, #ff8a2a);
}
[data-theme='light'] .dock-item span {
    background: none;
    -webkit-background-clip: initial;
    -webkit-text-fill-color: initial;
    background-clip: border-box;
    color: #1f2937;
}

/* ── 6. UTILITIES ── */
@layer utilities {
    .hidden  { display: none !important; }
    .w-100   { width: 100%; }
    .text-center { text-align: center; }
    .mb-2    { margin-block-end: 0.5rem; }
    .mb-4    { margin-block-end: 1.5rem; }
    .mt-4    { margin-block-start: 1.5rem; }
    .w-48    { inline-size: 12rem; }
    .card-full { grid-column: 1 / -1; }
    .pager {
        display:flex;
        justify-content:center;
        align-items:center;
        gap:10px;
        padding:12px;
        flex-wrap:wrap;
        margin-block: 14px calc(110px + env(safe-area-inset-bottom));
    }
    .pager a {
        display:inline-flex;
        align-items:center;
        justify-content:center;
        min-width:38px;
        height:38px;
        padding:0 10px;
        border-radius:10px;
        border:1px solid rgba(255 138 42 / 0.32);
        background: rgba(255 138 42 / 0.10);
        color: var(--text);
        text-decoration:none;
        font-weight: 800;
        font-size: 0.85rem;
        transition: transform var(--duration) var(--ease), filter var(--duration) var(--ease), background var(--duration) var(--ease), border-color var(--duration) var(--ease);
    }
    .pager a:hover {
        background: linear-gradient(135deg, #ff7f32, #ef4f12);
        border-color: rgba(255,255,255,0.18);
        color:#fff;
        transform: translateY(-1px);
    }
    .pager a.active {
        background: linear-gradient(135deg, #ff7f32, #ef4f12);
        border-color: rgba(255,255,255,0.18);
        color:#fff;
    }
}

/* ── 7. RESPONSIVE ── */
@layer responsive {
    @media (max-width: 768px) {
        .dash-container { padding: 12px; }
        .card           { padding: 14px; }
        .panel-glass    { padding: 24px 18px; }
        .ui-float-controller {
            right: 10px;
            bottom: 96px;
        }

        /* ── Grid collapse ── */
        .grid-cols-2,
        .grid-cols-3,
        .grid-cols-4 { grid-template-columns: 1fr !important; }

        /* Nested grids inside cards also collapse */
        .card .grid { grid-template-columns: 1fr !important; }

        /* Span-2 / span-3 cards keep single column */
        [style*="grid-column: span"],
        [style*="grid-column:span"] {
            grid-column: span 1 !important;
        }

        /* ── Header ── */
        .dash-header {
            flex-direction: column !important;
            align-items: stretch !important;
            gap: 15px;
            padding: 15px 18px;
        }

        /* Brand: hide badge label on tiny screens */
        .dash-brand { font-size: 1.1rem !important; letter-spacing: 0.5px !important; text-align: center; }
        .dash-brand small, .dash-brand > small { display: none !important; }

        .dash-header > div {
            display: flex;
            justify-content: space-between !important;
            width: 100%;
            margin-top: 5px;
        }

        /* ── Nav ── */
        .dash-header .desktop-nav { display: none !important; }
        .hamburger-btn { display: flex !important; flex-shrink: 0; padding: 0; margin-right: 0; align-self: center; }

        /* ── RESPONSIVE TABLE (CARD MODEL) ── */
        .table-wrap, [style*="overflow-x:auto"], [style*="overflow-x: auto"] { 
            overflow: visible !important;
            box-shadow: none !important;
            margin: 0 !important;
            padding: 0 !important;
        }
        table { display: block; width: 100%; border-collapse: collapse; }
        thead { display: none; } /* Hide normal header */
        tbody { display: block; width: 100%; }
        tr {
            display: block;
            background: var(--surface-2);
            border: 1px solid var(--surface-border);
            border-radius: 12px;
            margin-bottom: 15px;
            padding: 4px;
            box-shadow: 0 4px 15px rgba(0,0,0,0.05);
            overflow: hidden;
            width: 100%;
        }
        td, th {
            display: flex;
            justify-content: space-between;
            align-items: center;
            text-align: right;
            border-bottom: 1px solid rgba(255,255,255,0.03);
            border-bottom-color: var(--surface-border);
            padding: 12px 10px !important;
            font-size: 0.85rem !important;
            white-space: normal !important;
            word-break: break-word;
        }
        tr td:last-child { border-bottom: none; }
        td::before {
            content: attr(data-label);
            font-weight: 800;
            color: var(--text-muted);
            text-align: left;
            margin-right: 15px;
            flex-shrink: 0;
            text-transform: uppercase;
            font-size: 0.72rem;
            letter-spacing: 0.5px;
        }

        /* ── Flex groups: wrap on mobile ── */
        [style*="display:flex"],
        [style*="display: flex"] {
            flex-wrap: wrap;
        }
        /* EXCEPT: header nav wrapper stays row */
        .dash-header > div { flex-wrap: nowrap !important; }
        /* EXCEPT: dock stays row */
        .bottom-dock { flex-wrap: nowrap !important; gap: 4px; padding: 6px 10px; }
        .dock-item { flex: 1 1 0; padding: 6px 4px; min-width: 0; }
        .dock-item span { font-size: 0.65rem; }

        /* ── Action button groups ── */
        td > div[style*="flex"], td form, td > div {
            gap: 6px !important;
            flex-wrap: wrap !important;
            justify-content: flex-end;
            display: flex;
        }
        td > div > .btn-sm, td form .btn-sm { flex: 0 0 auto; font-size: 0.72rem !important; padding: 6px 10px !important; }

        /* ── Tab buttons scroll horizontally ── */
        [style*="overflow-x:auto"] > .tab-btn { white-space: nowrap !important; flex-shrink:0; }
        .tab-btn { font-size: 0.82rem !important; padding: 10px 14px !important; }
        
        /* Form Inputs larger tap area */
        .form-control, select, input { font-size: 1rem !important; padding: 12px 14px; }

        /* ── Stats cards ── */
        .stat-card { grid-column: span 1 !important; }

        /* ── Owner nav tabs ── */
        .top-nav-owner {
            overflow-x: auto;
            flex-wrap: nowrap !important;
            padding: 5px;
            gap: 3px;
            overscroll-behavior-x: contain;
            scrollbar-width: none;
        }
        .top-nav-owner::-webkit-scrollbar { display: none; }
        .top-nav-owner a { padding: 7px 13px; font-size: 0.8rem; }

        /* ── Superadmin specific: ensure config card inside grid-cols-2 is full ── */
        .card-full { grid-column: 1 / -1 !important; }
    }

    /* Touch devices — slightly larger tap targets */
    @media (pointer: coarse) {
        .btn-primary { padding-block: 15px; }
        .btn-sm      { padding: 9px 14px; }
        .dock-item   { padding: 10px 14px; }
        .form-control { padding: 13px 14px; }
    }

    /* Reduce motion for accessibility */
    @media (prefers-reduced-motion: reduce) {
        *, *::before, *::after {
            animation-duration: 0.01ms !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ── ANIMATIONS (outside layers — global) ── */
@keyframes spin    { to { rotate: 1turn; } }
@keyframes shimmer { to { background-position: 200% center; } }
@keyframes fadeUp  {
    from { opacity: 0; translate: 0 16px; }
    to   { opacity: 1; translate: 0 0; }
}
