@import url("accent.css");
/* ══════════════════════════════════════════
   PandaServe Customer Portal — Stylesheet
   ══════════════════════════════════════════ */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
    --primary: #0f172a;
    /* The accent family lives in css/accent.css — one shared file. */
    --light: #f8fafc;
    --white: #fff;
    --gray-50: #f9fafb;
    --gray-100: #f1f5f9;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e1;
    --gray-400: #94a3b8;
    --gray-500: #64748b;
    --gray-600: #475569;
    --gray-700: #334155;
    --gray-800: #1e293b;
    --success: #16a34a;
    --success-light: #dcfce7;
    --success-bg: #f0fdf4;
    --warning: #d97706;
    --warning-light: #fef3c7;
    --warning-bg: #fffbeb;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --danger-bg: #fef2f2;
    --purple: #7c3aed;
    --purple-light: #f3e8ff;
    --orange: #ea580c;
    --orange-light: #ffedd5;
    --sky: #0284c7;
    --sky-light: #e0f2fe;
    --sidebar-w: 260px;
    --header-h: 64px;
    --radius: 10px;
    --radius-lg: 14px;
    --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
    --shadow: 0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
    --shadow-lg: 0 8px 30px rgba(0,0,0,.08);

    /* ── Theme foundation: additive aliases (phase 1) ──
       Every value below is byte-identical to what the rules already use.
       Adding them changes nothing on screen; they exist so later phases have
       semantic names to theme against. */
    --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    --canvas: var(--gray-100);      /* page background  (body) */
    --surface: var(--white);        /* card / panel background */
    --text: var(--primary);         /* body text */
    --border: var(--gray-200);      /* default border */

    --nav-bg: var(--primary);       /* sidebar background */
    --nav-fg: #fff;                 /* sidebar text */
    --nav-muted: var(--gray-400);   /* sidebar muted text */

    --accent-fg: #fff;              /* text on accent / solid-colour buttons */
    --focus-ring: rgba(var(--accent-rgb), .1);
    --overlay: rgba(0,0,0,.4);      /* modal overlay */
    /* none, not an invert: this instance has a COLOURED logo, and brightness(0) invert(1)
       would flatten it to a white silhouette. Currently unused — defined so that if anything
       does wire it up later it does the right thing rather than the destructive thing. */
    --logo-filter: none;

    --success-hover: #15803d;
    --warning-hover: #b45309;
    --danger-hover: #b91c1c;

    --banner-paid-bg: #dcfce7;
    --banner-paid-fg: #15803d;
    --banner-unpaid-bg: #fef3c7;
    --banner-unpaid-fg: #92400e;
    --banner-overdue-bg: #fee2e2;
    --banner-overdue-fg: #991b1b;
    --banner-refunded-bg: #fef3c7;
    --banner-refunded-fg: #92400e;
    --banner-cancelled-bg: #f1f5f9;
    --banner-cancelled-fg: #64748b;
}

/* ── SURFACE TOKENS (light) — deliberately NOT part of the inverting palette.
   The sidebar and toast are surfaces; --primary is the body TEXT colour, and reusing it for
   them is what turned both white-on-white in dark mode. */
:root {
    --sidebar-bg: #ffffff;
    --sidebar-line: #e2e8f0;
    --sidebar-fg: #334155;      /* nav links */
    --sidebar-dim: #64748b;     /* section labels, secondary text */
    --sidebar-hover: #f1f5f9;
    --sidebar-on: #0f172a;      /* text on a hovered nav item */
    --toast-bg: #0f172a;
    --toast-fg: #ffffff;
    --input-bg: #ffffff;
    --input-line: #e2e8f0;
    /* Status colours as TEXT — the base --success/--warning are tuned as FILLS and are only
       ~3.3:1 as letters on a white card. */
    --success-tx: #15803d;
    --warning-tx: #b45309;
    --danger-tx: #b91c1c;
}

/* ── DARK THEME ───────────────────────────────────────────────────────────
   The customer chooses light or dark; this block redefines the SAME token names
   with dark values, so every page already written against the tokens follows
   without touching the page. Values match the order/shop page's dark palette,
   which is the look that was signed off.

   The accent family is deliberately NOT re-tinted here beyond its on-dark
   variants — a reseller swapping the accent to orange should get orange in both
   themes, not orange in one and blue in the other. */
html[data-theme="dark"] {
    --primary: #f1f5f9;              /* body TEXT in this palette, not a brand colour */

    --light: #090b0f;                /* page background — the DARKEST surface; cards lift above it */
    --white: #161a23;                /* card — LIFTED above the page, as in the reference */
    --gray-50:  #12151c;
    --gray-100: #0d0f14;             /* body background */
    --gray-200: #242a36;             /* borders */
    --gray-300: #2f3644;
    --gray-400: #8b95a5;             /* muted text — kept light enough to read */
    --gray-500: #a8b3c2;
    --gray-600: #c7d0dc;
    --gray-700: #e2e8f0;
    --gray-800: #f1f5f9;


    /* Status colours brighten slightly — the light-theme versions go muddy on black. */
    --success: #22c55e;  --success-light: #14301f;  --success-bg: #0f2318;
    --warning: #f59e0b;  --warning-light: #33270a;  --warning-bg: #241c07;
    --danger:  #ef4444;  --danger-light:  #3a1414;  --danger-bg:  #260d0d;
    --purple:  #a855f7;  --purple-light:  #241a38;
    --orange:  #fb923c;  --orange-light:  #33210f;
    --sky:     #38bdf8;  --sky-light:     #0e2637;

    /* The dark half of the sidebar palette. */
    --sidebar-bg: #0b0d12;
    --sidebar-line: #1c212b;
    --sidebar-fg: #c7d0dc;
    --sidebar-dim: #8b95a5;
    --sidebar-hover: #171b24;
    --sidebar-on: #ffffff;
    --toast-bg: #1f2937;
    --toast-fg: #f8fafc;
    /* A field sits BELOW the card, not on it — recessed, like the reference. */
    --input-bg: #101319;
    --input-line: #242a36;
    /* On a dark card the relationship inverts — status text has to get LIGHTER, not darker. */
    --success-tx: #4ade80;
    --warning-tx: #fbbf24;
    --danger-tx: #fca5a5;
}
/* NO body rule here on purpose. The base `body` rule already reads var(--primary) and
   var(--gray-100), and this block redefines both — so body follows automatically. An
   explicit `html[data-theme="dark"] body` rule is not only redundant, it outranks the
   order page's own body rule (0,1,2 vs 0,0,1) and repainted it: that page defines
   --primary as the ACCENT, so its text turned blue and its background lightened. */
/* The sidebar is already dark in the light theme; in dark it needs separating from the page. */
/* logo.png is dark artwork. It reads as-is on the light sidebar and must be inverted on the
   dark one. The inline filter that used to do this was unconditional, so on a light sidebar it
   rendered the logo white-on-white. */
.sidebar-header img { filter: none; }
/* No invert here. brightness(0) invert(1) flattens the logo to a WHITE silhouette, which
   destroys a coloured mark. It only makes sense for logos that are solid DARK artwork
   (prod's is). A coloured logo reads fine as-is on the dark sidebar. */

html { scroll-behavior: smooth; font-size: 16px; }
@media (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi) {
    html { font-size: 17px; }
}
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    html { font-size: 18px; }
}

body {
    font-family: var(--font-sans);
    color: var(--text, var(--primary)); background: var(--canvas);
    line-height: 1.6; min-height: 100vh;
}

a { color:var(--accent-ink, var(--accent)); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── LAYOUT SHELL ─────────────────────── */
.portal-layout { display: flex; min-height: 100vh; }

/* ── SIDEBAR ──────────────────────────── */
.sidebar {
    width: var(--sidebar-w); background: var(--sidebar-bg);
    color: var(--sidebar-fg); display: flex; flex-direction: column;
    position: fixed; top: 0; left: 0; bottom: 0; z-index: 50;
    transition: transform .3s;
}
.sidebar-header {
    padding: 20px 24px; display: flex; align-items: center; gap: 10px;
    border-bottom: 1px solid var(--sidebar-line);
}
.sidebar-logo {
    width: 32px; height: 32px; background: var(--accent); border-radius: 8px;
    display: grid; place-items: center; font-size: .8rem; font-weight: 800; flex-shrink: 0;
}
.sidebar-brand { font-size: 1.1rem; font-weight: 700; }
.sidebar-brand small { display: block; font-size: .7rem; font-weight: 400; color: var(--gray-400); }

.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.sidebar-nav .nav-section { font-size: .68rem; font-weight: 600; text-transform: uppercase; letter-spacing: .8px; color: var(--gray-400); padding: 16px 12px 8px; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    border-radius: 8px; color: var(--sidebar-fg); font-size: .88rem; font-weight: 500;
    transition: all .15s; text-decoration: none; margin-bottom: 2px;
}
.sidebar-nav a:hover { background: var(--sidebar-line); color: var(--nav-fg); }
.sidebar-nav a.active { background: var(--accent); color: var(--accent-fg); }
.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-badge {
    margin-left: auto; background: var(--danger); color: var(--accent-fg);
    font-size: .65rem; font-weight: 700; padding: 2px 7px;
    border-radius: 999px; line-height: 1.4;
}

.sidebar-footer {
    padding: 16px 20px; border-top: 1px solid var(--sidebar-line);
    display: flex; align-items: center; gap: 12px;
}
.sidebar-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--accent);
    display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0;
}
.sidebar-user { flex: 1; min-width: 0; }
.sidebar-user .name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-user .email { font-size: .72rem; color: var(--gray-400); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-logout {
    background: none; border: none; color: var(--gray-400); cursor: pointer;
    padding: 6px; border-radius: 6px; transition: all .15s;
}
.sidebar-logout:hover { color: var(--nav-fg); background: var(--sidebar-line); }

/* ── MAIN CONTENT ─────────────────────── */
.portal-main {
    flex: 1; margin-left: var(--sidebar-w); min-width: 0;
}

/* ── TOP HEADER ───────────────────────── */
.portal-header {
    height: var(--header-h); background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex; align-items: center; justify-content: space-between;
    padding: 0 32px; position: sticky; top: 0; z-index: 40;
}
.portal-header h1 { font-size: 1.2rem; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 12px; }
.header-btn {
    padding: 8px 12px; border-radius: 8px; border: 1px solid var(--gray-200);
    background: var(--white); font-size: .82rem; font-weight: 500;
    cursor: pointer; transition: all .15s; color: var(--gray-600);
    display: flex; align-items: center; gap: 6px;
}
.header-btn:hover { border-color:var(--accent); color:var(--accent-ink, var(--accent)); }
.mobile-menu-btn { display: none; background: none; border: none; font-size: 1.4rem; cursor: pointer; color: var(--primary); }

/* ── PAGE CONTENT ─────────────────────── */
.portal-content { padding: 28px 32px 60px; max-width: 1200px; }

/* ── BUTTONS ──────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border-radius: 8px; font-size: .85rem;
    font-weight: 600; text-decoration: none; transition: all .15s;
    border: none; cursor: pointer; line-height: 1;
}
.btn svg { width: 16px; height: 16px; }
.btn-sm { padding: 7px 14px; font-size: .8rem; }
.btn-xs { padding: 5px 10px; font-size: .75rem; border-radius: 6px; }
.btn-primary { background: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: var(--accent-hover); }
.btn-success { background: var(--success); color: var(--accent-fg); }
.btn-success:hover { background: var(--success-hover); }
.btn-warning { background: var(--warning); color: var(--accent-fg); }
.btn-warning:hover { background: var(--warning-hover); }
.btn-danger { background: var(--danger); color: var(--accent-fg); }
.btn-danger:hover { background: var(--danger-hover); }
.btn-outline { background: var(--white); color: var(--gray-600); border: 1.5px solid var(--gray-200); }
.btn-outline:hover { border-color:var(--accent); color:var(--accent-ink, var(--accent)); }
.btn-ghost { background: transparent; color: var(--gray-500); border: none; }
.btn-ghost:hover { color:var(--accent-ink, var(--accent)); background: var(--accent-bg); }

/* ── STAT CARDS ───────────────────────── */
.stats-row {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px; margin-bottom: 28px;
}
.stat-card {
    background: var(--white); border-radius: var(--radius-lg); padding: 22px 24px;
    border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
}
.stat-card .stat-label { font-size: .78rem; font-weight: 500; color: var(--gray-500); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--primary); line-height: 1.2; }
.stat-card .stat-sub { font-size: .75rem; color: var(--gray-400); margin-top: 4px; }
.stat-card .stat-icon {
    float: right; width: 40px; height: 40px; border-radius: 10px;
    display: grid; place-items: center;
}
.stat-card .stat-icon svg { width: 20px; height: 20px; }

/* ── PANELS / CARDS ───────────────────── */
.panel {
    background: var(--white); border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
    margin-bottom: 24px; overflow: hidden;
}
.panel-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 24px; border-bottom: 1px solid var(--gray-200);
}
.panel-header h2 { font-size: 1rem; font-weight: 600; }
.panel-body { padding: 20px 24px; }
.panel-body.flush { padding: 0; }

/* ── TABLES ───────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; font-size: .85rem; }
.data-table th {
    text-align: left; padding: 12px 20px; font-weight: 600; font-size: .75rem;
    text-transform: uppercase; letter-spacing: .5px; color: var(--gray-500);
    background: var(--gray-50); border-bottom: 1px solid var(--gray-200);
}
.data-table td { padding: 14px 20px; border-bottom: 1px solid var(--gray-100); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }

/* ── BADGES / STATUS ──────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: 999px; font-size: .72rem;
    font-weight: 600; white-space: nowrap;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--accent-light); color:var(--accent-ink, var(--accent)); }
.badge-purple { background: var(--purple-light); color: var(--purple); }
.badge-gray { background: var(--gray-100); color: var(--gray-500); }
.badge-dot::before {
    content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor;
}

/* ── FORMS ─────────────────────────────── */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }
.form-group label { font-size: .8rem; font-weight: 600; color: var(--gray-600); }
.form-group input, .form-group select, .form-group textarea {
    padding: 10px 14px; border: 1.5px solid var(--gray-200); border-radius: 8px;
    font-size: .88rem; font-family: inherit; transition: border-color .15s;
    background: var(--white); color: var(--primary);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none; border-color:var(--accent); box-shadow: 0 0 0 3px var(--focus-ring);
}
.form-group textarea { resize: vertical; min-height: 100px; }

/* ── MODAL ─────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0; background: var(--overlay);
    display: flex; align-items: center; justify-content: center;
    z-index: 200; backdrop-filter: blur(4px);
    opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
    background: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); width: 560px; max-width: 95vw;
    max-height: 90vh; overflow-y: auto;
    transform: translateY(20px); transition: transform .2s;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 20px 24px; border-bottom: 1px solid var(--gray-200);
}
.modal-header h3 { font-size: 1.05rem; font-weight: 600; }
.modal-close {
    background: none; border: none; font-size: 1.2rem; color: var(--gray-400);
    cursor: pointer; padding: 4px; border-radius: 6px;
}
.modal-close:hover { color: var(--primary); background: var(--gray-100); }
.modal-body { padding: 24px; }
.modal-footer {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 16px 24px; border-top: 1px solid var(--gray-200);
}

/* ── TICKETS (old classes removed — styles now in tickets.html) ── */

/* ── SERVICE CARDS ────────────────────── */
.svc-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); gap: 20px;
}
.svc-card {
    background: var(--white); border-radius: var(--radius-lg); padding: 28px;
    border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm);
    display: flex; flex-direction: column; min-height: 260px;
}
.svc-card-info h3 { font-size: 1.05rem !important; font-weight: 700 !important; margin-bottom: 4px !important; }
.svc-card-top { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.svc-card-icon {
    width: 44px; height: 44px; border-radius: 10px; display: grid;
    place-items: center; flex-shrink: 0;
}
.svc-card-icon svg { width: 22px; height: 22px; }
.svc-card-info { flex: 1; }
.svc-card-info h3 { font-size: .95rem; font-weight: 600; margin-bottom: 2px; }
.svc-card-info .svc-price { font-size: .85rem; color:var(--accent-ink, var(--accent)); font-weight: 600; }
.svc-card-info .svc-price span { color: var(--gray-400); font-weight: 400; }
.svc-card-details { font-size: .82rem; color: var(--gray-500); margin-bottom: 16px; flex: 1; }
.svc-card-footer { display: flex; align-items: center; justify-content: space-between; padding-top: 14px; border-top: 1px solid var(--gray-100); }
.svc-card-meta { font-size: .75rem; color: var(--gray-400); }

/* ── INVOICE ──────────────────────────── */
.invoice-detail {
    max-width: 800px;
    background: var(--white);
    border-radius: var(--radius-lg, 12px);
    border: 1px solid var(--gray-200);
    padding: 40px;
}
.inv-letterhead {
    display: flex; justify-content: space-between; align-items: flex-start;
    padding-bottom: 24px; border-bottom: 2px solid var(--accent); margin-bottom: 28px;
}
.inv-letterhead-logo { display: flex; align-items: center; gap: 12px; }
.inv-letterhead-logo .inv-logo-icon {
    width: 40px; height: 40px; background: var(--accent); border-radius: 10px;
    display: grid; place-items: center; color: var(--accent-fg); font-size: .9rem; font-weight: 800;
}
.inv-letterhead-logo .inv-logo-text { font-size: 1.2rem; font-weight: 700; color: var(--primary); }
.inv-letterhead-right { text-align: right; font-size: .8rem; color: var(--gray-500); line-height: 1.6; }

.inv-status-banner {
    display: flex; align-items: center; gap: 10px; padding: 12px 16px;
    border-radius: 8px; margin-bottom: 24px; font-size: .85rem; font-weight: 600;
}
.inv-status-banner.paid { background: var(--banner-paid-bg); color: var(--banner-paid-fg); }
.inv-status-banner.unpaid { background: var(--banner-unpaid-bg); color: var(--banner-unpaid-fg); }
.inv-status-banner.overdue { background: var(--banner-overdue-bg); color: var(--banner-overdue-fg); }
.inv-status-banner.refunded { background: var(--banner-refunded-bg); color: var(--banner-refunded-fg); }
.inv-status-banner.cancelled { background: var(--banner-cancelled-bg); color: var(--banner-cancelled-fg); }

.inv-title-bar {
    display: flex; justify-content: space-between; align-items: flex-start;
    margin-bottom: 28px; flex-wrap: wrap; gap: 16px;
}
.inv-title-bar h2 { font-size: 1.4rem; font-weight: 800; color: var(--primary); margin: 0; }
.inv-title-bar .inv-number-label {
    font-size: .7rem; text-transform: uppercase; color: var(--gray-400);
    letter-spacing: .08em; margin-bottom: 2px;
}
.inv-dates-grid {
    display: grid; grid-template-columns: auto auto; gap: 4px 16px;
    font-size: .82rem; color: var(--gray-500); text-align: right;
}
.inv-dates-grid dt { font-weight: 400; }
.inv-dates-grid dd { font-weight: 600; color: var(--primary); margin: 0; }

.inv-parties {
    display: grid; grid-template-columns: 1fr 1fr; gap: 24px;
    margin-bottom: 28px; font-size: .85rem;
}
.inv-party-label {
    font-size: .7rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em;
    color:var(--accent-ink, var(--accent)); margin-bottom: 6px;
}
.inv-party-name { font-weight: 700; color: var(--primary); font-size: .92rem; margin-bottom: 4px; }
.inv-party-details { color: var(--gray-500); line-height: 1.6; }

.inv-table { width: 100%; border-collapse: collapse; margin: 0 0 20px; font-size: .85rem; }
.inv-table thead { background: var(--gray-50); }
.inv-table th {
    text-align: left; padding: 10px 14px; border-bottom: 2px solid var(--gray-200);
    font-size: .72rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--gray-500); font-weight: 600;
}
.inv-table td { padding: 12px 14px; border-bottom: 1px solid var(--gray-100); color: var(--gray-600); }
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table .text-right { text-align: right; }
.inv-table .item-name { font-weight: 600; color: var(--primary); }

.inv-totals { display: flex; justify-content: flex-end; margin-bottom: 28px; }
.inv-totals-inner { width: 260px; font-size: .85rem; }
.inv-totals-row {
    display: flex; justify-content: space-between; padding: 7px 0;
    border-bottom: 1px solid var(--gray-100); color: var(--gray-500);
}
.inv-totals-row.grand {
    border-bottom: none; border-top: 2px solid var(--gray-200);
    padding-top: 10px; margin-top: 4px;
    font-weight: 800; font-size: 1.05rem; color: var(--primary);
}
.inv-totals-row.grand .inv-grand-amount { color:var(--accent-ink, var(--accent)); }

.inv-footer-notes {
    background: var(--gray-50); border-radius: 8px; padding: 16px 20px;
    margin-bottom: 24px; font-size: .8rem; color: var(--gray-500); line-height: 1.6;
}
.inv-footer-notes strong { color: var(--gray-600); }

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

/* ── INVOICE PRINT ───────────────────── */
@media print {
    /* Force crisp dark text — override any theme (light or midnight) */
    :root {
        --primary: #0f172a !important;
        --white: #ffffff !important;
        --gray-50: #f8fafc !important;
        --gray-100: #f1f5f9 !important;
        --gray-200: #cbd5e1 !important;
        --gray-300: #94a3b8 !important;
        --gray-400: #475569 !important;
        --gray-500: #334155 !important;
        --gray-600: #1e293b !important;
        --gray-700: #0f172a !important;
        --accent: var(--accent-hover, #1d4ed8) !important;
    }
    html, body { background: var(--white, #fff) !important; color: #000 !important; font-size: 12pt !important; -webkit-font-smoothing: antialiased; }
    * { print-color-adjust: exact !important; -webkit-print-color-adjust: exact !important; color-adjust: exact !important; }

    .sidebar, .portal-header, #invoiceListPanel, #paymentListPanel,
    .toast, .inv-actions, .mobile-menu-btn { display: none !important; }
    .portal-layout { display: block !important; }
    .portal-main { margin: 0 !important; padding: 0 !important; width: 100% !important; }
    .portal-content { padding: 0 !important; }

    .invoice-detail {
        max-width: 100% !important; width: 100% !important;
        box-shadow: none !important; border: none !important;
        border-radius: 0 !important; padding: 24px !important;
        background: var(--white, #fff) !important; color: #000 !important;
    }
    .invoice-detail * { color: #000 !important; }
    .invoice-detail h2 { color: #000 !important; font-weight: 800 !important; }
    .invoice-detail .inv-number-label,
    .invoice-detail [style*="color:var(--gray-400)"],
    .invoice-detail [style*="color:var(--gray-500)"] { color: var(--gray-800, #1e293b) !important; font-weight: 600 !important; }

    /* Status banner — preserve color for printing */
    .inv-status-banner { border: 2px solid #000 !important; padding: 10px 14px !important; font-weight: 700 !important; }
    .inv-status-banner.paid { background: var(--success-light, #dcfce7) !important; color: #14532d !important; border-color: #166534 !important; }
    .inv-status-banner.paid * { color: #14532d !important; }
    .inv-status-banner.unpaid, .inv-status-banner.overdue { background: var(--danger-light, #fee2e2) !important; color: #7f1d1d !important; border-color: var(--banner-overdue-fg, #991b1b) !important; }
    .inv-status-banner.unpaid *, .inv-status-banner.overdue * { color: #7f1d1d !important; }
    .inv-status-banner.refunded { background: var(--warning-light, #fef3c7) !important; color: #78350f !important; border-color: var(--banner-unpaid-fg, #92400e) !important; }
    .inv-status-banner.refunded * { color: #78350f !important; }
    .inv-status-banner.cancelled { background: var(--gray-100, #f1f5f9) !important; color: var(--gray-800, #1e293b) !important; border-color: var(--gray-700, #334155) !important; }
    .inv-status-banner.cancelled * { color: var(--gray-800, #1e293b) !important; }

    /* Table — solid borders, dark text */
    .inv-table { border: 1.5px solid #000 !important; border-collapse: collapse !important; }
    .inv-table thead { background: var(--gray-200, #e2e8f0) !important; }
    .inv-table thead th { background: var(--gray-200, #e2e8f0) !important; color: #000 !important; font-weight: 800 !important; border-bottom: 2px solid #000 !important; padding: 10px 12px !important; }
    .inv-table tbody td { color: #000 !important; border-bottom: 1px solid var(--gray-400, #94a3b8) !important; padding: 10px 12px !important; font-weight: 500 !important; }
    .inv-table .item-name { font-weight: 700 !important; }

    /* Totals block — dark, bold */
    .inv-totals, .inv-totals * { color: #000 !important; }
    .inv-totals-row { font-weight: 600 !important; }
    .inv-totals-row.grand { border-top: 2px solid #000 !important; padding-top: 8px !important; margin-top: 6px !important; font-size: 1.15rem !important; font-weight: 900 !important; }
    .inv-grand-amount { color: #000 !important; font-weight: 900 !important; }

    /* Footer notes — visible and bold */
    .inv-footer-notes { margin-top: 24px !important; padding: 14px 16px !important; background: var(--light, #f8fafc) !important; border: 1.5px solid var(--gray-700, #334155) !important; border-radius: 6px !important; color: #000 !important; font-size: 11pt !important; line-height: 1.55 !important; }
    .inv-footer-notes * { color: #000 !important; }
    .inv-footer-notes strong { color: #000 !important; font-weight: 800 !important; }

    /* Letterhead */
    .inv-letterhead { border-bottom: 2px solid #000 !important; padding-bottom: 12px !important; margin-bottom: 16px !important; }
    .inv-letterhead img { filter: none !important; }

    /* Dates grid + labels */
    .inv-dates-grid dt { color: var(--gray-800, #1e293b) !important; font-weight: 700 !important; }
    .inv-dates-grid dd { color: #000 !important; font-weight: 600 !important; }

    .inv-table, .inv-totals, .inv-footer-notes { page-break-inside: avoid; }
}

/* ── EMPTY STATE ──────────────────────── */
.empty-state {
    text-align: center; padding: 48px 24px; color: var(--gray-500);
}
.empty-state svg { width: 64px; height: 64px; margin: 0 auto 16px; opacity: .35; }
.empty-state h3 { font-size: 1.05rem; color: var(--primary); margin-bottom: 6px; }
.empty-state p { font-size: .88rem; margin-bottom: 20px; }

/* ── TOAST ─────────────────────────────── */
.toast {
    position: fixed; bottom: 24px; right: 24px;
    background: var(--toast-bg); color: var(--toast-fg); padding: 12px 20px;
    border-radius: 10px; font-size: .85rem; font-weight: 500;
    box-shadow: 0 8px 24px rgba(0,0,0,.2);
    transform: translateY(80px); opacity: 0;
    transition: all .25s ease; z-index: 300; max-width: 340px;
}
.toast.show { transform: translateY(0); opacity: 1; }

/* ── LOGIN PAGE ───────────────────────── */
.login-page {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%); padding: 24px;
}

/* The login and reset pages paint their OWN dark gradient, so they are dark in both themes.
   In dark mode the card inherits --white (#111111) and sat at 1.06:1 against that gradient —
   its edges vanished and the page read as a narrow strip of floating text. Lift the card off
   the background and give it an edge. This is the login card on its own dark gradient. */
html[data-theme="dark"] .login-card {
    /* #1e2a3d separates from BOTH ends of the gradient (1.24:1 vs #0f172a, 1.26:1 vs
       #1e3a5f). A surface tuned to one end blends into the other. The border and shadow
       do the definitive edge work; this just lifts the fill off the background. */
    background: #1e2a3d;
    border: 1px solid rgba(255,255,255,.10);
    box-shadow: 0 18px 50px rgba(0,0,0,.45);
}
html[data-theme="dark"] .login-card h2,
html[data-theme="dark"] .login-card .login-logo .logo-text { color: #f1f5f9; }

.login-card {
    background: var(--white); border-radius: var(--radius-lg); padding: 48px 52px;
    /* Was 420px. box-sizing is border-box, so 40px of padding each side left only ~340px of
       actual content — it read as a cramped strip on a desktop. 560px gives ~456px. */
    width: 560px; max-width: 100%; box-shadow: var(--shadow-lg);
}
.login-card h2 { font-size: 1.45rem; }
.login-card .login-sub { font-size: .95rem; }
.login-card .form-group input { padding: 12px 14px; font-size: .95rem; }
@media (max-width: 620px) {
    .login-card { padding: 32px 24px; }
}
.login-card .login-logo {
    display: flex; align-items: center; gap: 10px; justify-content: center;
    margin-bottom: 32px;
}
.login-card .login-logo .logo-icon {
    width: 40px; height: 40px; background: var(--accent); border-radius: 10px;
    display: grid; place-items: center; color: var(--accent-fg); font-size: 1rem; font-weight: 800;
}
.login-card .login-logo .logo-text { font-size: 1.4rem; font-weight: 700; }
.login-card h2 { text-align: center; font-size: 1.3rem; margin-bottom: 6px; }
.login-card .login-sub { text-align: center; color: var(--gray-500); font-size: .9rem; margin-bottom: 28px; }
.login-card .form-group { margin-bottom: 16px; }
.login-card .btn { width: 100%; justify-content: center; padding: 12px; margin-top: 8px; }
.login-card .login-footer { text-align: center; margin-top: 20px; font-size: .82rem; color: var(--gray-500); }
.login-card .login-footer a { color:var(--accent-ink, var(--accent)); font-weight: 500; }
.login-demo { background: var(--accent-bg); padding: 14px 16px; border-radius: 8px; margin-bottom: 20px; font-size: .8rem; color: var(--gray-600); border: 1px solid var(--accent-light); }
.login-demo strong { color:var(--accent-ink, var(--accent)); }

/* ── RESPONSIVE ───────────────────────── */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .portal-main { margin-left: 0; }
    .mobile-menu-btn { display: block; }
    .portal-content { padding: 20px 16px 60px; }
    .stats-row { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .svc-grid { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
    .stats-row { grid-template-columns: 1fr; }
    .portal-header { padding: 0 16px; }
    .data-table { font-size: .78rem; }
    .data-table th, .data-table td { padding: 10px 12px; }
}

/* ─── High-DPI render quality ──────────────────────────────────────────────
   The only font-smoothing rule in this file used to live in the print block, so screens got
   none. On a dark UI the default subpixel rendering looks heavy and slightly fuzzy; grayscale
   antialiasing is noticeably crisper. */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}
/* Keep raster logos sharp when scaled down on 2x/3x displays. */
img[src*="logo"] {
    image-rendering: -webkit-optimize-contrast;
}

/* The theme toggle, injected into .portal-header by THEME.mount(). */
.theme-btn { display:inline-flex; align-items:center; justify-content:center;
             width:36px; height:36px; margin-left:12px; border-radius:9px;
             border:1px solid var(--gray-200); background:transparent;
             color:var(--gray-500); cursor:pointer; padding:0; transition:all .2s; flex-shrink:0; }
.theme-btn:hover { color:var(--primary); border-color:var(--accent); background:var(--accent-bg); }
/* ══════════════════════════════════════════════════════════════════════════
   CARD LAYOUT — bring the portal pages onto the order page's visual system.

   The order page reads as a calm set of cards: 18px radius, generous interior
   padding, a heading that sits INSIDE the card rather than in a bordered bar,
   and a lot of air between sections. The portal was built on tighter panels
   with a header rule across the top, which is what made the two look unrelated.

   Written by hand and appended as one block so it reverts in a single cut.
   Nothing here touches :root or any geometry (widths, flex, margins on the
   layout containers) — only the look of the components themselves.
   ══════════════════════════════════════════════════════════════════════════ */

/* More air, matching the order page's 48px top / 46px between sections. */
.portal-content { padding: 40px 36px 72px; }

/* The panel becomes a card. The header rule goes: on the order page a heading
   simply sits inside the card with space under it. */
.panel {
    border-radius: 18px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    margin-bottom: 28px;
}
.panel-header {
    padding: 24px 28px 0;
    border-bottom: none;
}
.panel-header h2 {
    font-size: 1.05rem; font-weight: 600; letter-spacing: -.25px;
}
.panel-body { padding: 18px 28px 26px; }
/* A flush body holds a table, which supplies its own edge padding. */
.panel-body.flush { padding: 0 0 6px; }
.panel-header + .panel-body.flush { padding-top: 14px; }

/* Stat tiles get the order page's card behaviour: a lift on hover, and the
   large light numeral it uses for prices rather than a heavy bold. */
.stat-card {
    border-radius: 18px; padding: 24px 26px;
    box-shadow: 0 1px 2px rgba(0,0,0,.04);
    transition: transform .2s, box-shadow .2s, border-color .2s;
}
.stat-card:hover {
    transform: translateY(-3px);
    border-color: rgba(var(--accent-rgb), .35);
    box-shadow: 0 12px 28px rgba(var(--accent-rgb), .12);
}
.stat-card .stat-label {
    font-size: .7rem; font-weight: 600; letter-spacing: .12em;
    text-transform: uppercase; color: var(--gray-400);
}
.stat-card .stat-value {
    font-size: 2rem; font-weight: 400; letter-spacing: -.04em;
}

/* Rows get room to breathe, and a lighter separator. */
.data-table th { padding: 14px 28px; }
.data-table td { padding: 17px 28px; border-bottom: 1px solid var(--gray-100); }

/* The page title reads as a section heading, not a chrome label. */
.portal-header h1 { font-size: 1.4rem; font-weight: 500; letter-spacing: -.5px; }

@media (max-width: 820px) {
    .portal-content { padding: 24px 18px 56px; }
    .panel-header { padding: 20px 20px 0; }
    .panel-body { padding: 14px 20px 20px; }
    .data-table th, .data-table td { padding-left: 20px; padding-right: 20px; }
}
/* ── FORM CONTROLS ────────────────────────────────────────────────────────
   Only `.form-group input` was ever styled. Every control OUTSIDE a form-group
   — and every `.form-input`, which had no rule at all — fell back to the
   BROWSER default: a bright white box on a dark page. That is the "white boxes
   hurt my eyes" report.

   Low specificity on purpose: the order and shop pages style their own controls
   inline and must keep winning. Checkboxes/radios/range/color are excluded so
   they keep their native behaviour and accent-color. */
input:not([type="checkbox"]):not([type="radio"]):not([type="range"]):not([type="color"]):not([type="file"]):not([type="submit"]):not([type="button"]),
select,
textarea,
.form-input {
    background: var(--input-bg);
    color: var(--primary);
    border: 1.5px solid var(--input-line);
    border-radius: 10px;
    padding: 11px 14px;
    font-family: inherit;
    font-size: .88rem;
    transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus, .form-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb), .12);
}
::placeholder { color: var(--gray-400); opacity: .75; }

/* .form-group had its own background token; keep it in step with the rest. */
.form-group input, .form-group select, .form-group textarea {
    background: var(--input-bg); border-color: var(--input-line);
}

/* Tells the browser to render NATIVE widgets dark too — select dropdowns, date
   pickers, scrollbars, autofill. Without it those stay stubbornly light no
   matter what the CSS says, which is most of what reads as "bright boxes". */
html[data-theme="dark"] { color-scheme: dark; }
:root { color-scheme: light; }
