/* ============================================================
   DESIGN TOKENS
   Every color in the app comes from these variables, so light and dark
   mode only differ here. js/theme.js sets <html data-theme="light|dark">.
   All text/background pairs below meet WCAG AA (4.5:1) contrast.
   ============================================================ */
:root {
    /* Surfaces */
    --color-bg:            #f3f5f9;   /* page background */
    --color-surface:       #ffffff;   /* cards, tables, modals */
    --color-surface-2:     #f8fafc;   /* table headers, subtle panels */
    --color-surface-hover: #f1f5f9;   /* row / item hover */
    --color-overlay:       rgba(15, 23, 42, 0.55);  /* behind modals */

    /* Text */
    --color-text:          #0f172a;
    --color-text-muted:    #5b6577;

    /* Borders */
    --color-border:        #e2e8f0;
    --color-border-strong: #cbd5e1;   /* form inputs */

    /* Brand & status (text-safe on surface) */
    --color-primary:       #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-on-primary:    #ffffff;
    --color-primary-soft:  #dbeafe;
    --color-primary-text:  #1d4ed8;   /* text on primary-soft */
    --color-success:       #15803d;
    --color-success-soft:  #dcfce7;
    --color-warning:       #b45309;
    --color-warning-soft:  #fef3c7;
    --color-danger:        #b91c1c;
    --color-danger-soft:   #fee2e2;
    --color-danger-solid:  #dc2626;   /* danger button background (white text) */
    --color-success-solid: #15803d;   /* success button background (white text) */
    --color-neutral-soft:  #f1f5f9;

    /* Sidebar (dark in both themes) */
    --sidebar-bg:          #0f172a;
    --sidebar-hover:       #1e293b;
    --sidebar-text:        #cbd5e1;
    --sidebar-text-strong: #f8fafc;
    --sidebar-muted:       #94a3b8;
    --sidebar-accent:      #fbbf24;   /* role label */
    --sidebar-active:      #60a5fa;
    --sidebar-divider:     rgba(255, 255, 255, 0.08);

    /* Login background */
    --login-gradient: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);

    /* Focus ring */
    --focus-ring: 0 0 0 3px rgba(37, 99, 235, 0.25);

    /* Shape & depth */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
    --shadow-lg: 0 20px 50px rgba(15, 23, 42, 0.20);

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

    /* Type */
    --font-sans: 'Inter', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;

    /* Layout */
    --sidebar-width: 240px;
    --transition: 0.15s ease;
}

/* Dark theme. Wrapped in "screen" so printing (receipts, reports) always uses light colors. */
@media screen {
    :root[data-theme="dark"] {
        --color-bg:            #0b1120;
        --color-surface:       #131c2e;
        --color-surface-2:     #1a2438;
        --color-surface-hover: #1e293b;
        --color-overlay:       rgba(0, 0, 0, 0.65);

        --color-text:          #e2e8f0;
        --color-text-muted:    #94a3b8;

        --color-border:        #243049;
        --color-border-strong: #334155;

        --color-primary:       #60a5fa;
        --color-primary-hover: #93c5fd;
        --color-on-primary:    #0b1120;
        --color-primary-soft:  #1f324f;
        --color-primary-text:  #93c5fd;
        --color-success:       #4ade80;
        --color-success-soft:  #1b3739;
        --color-warning:       #fbbf24;
        --color-warning-soft:  #33332d;
        --color-danger:        #f87171;
        --color-danger-soft:   #332837;
        --color-danger-solid:  #dc2626;
        --color-success-solid: #15803d;
        --color-neutral-soft:  #1e293b;

        --sidebar-bg:          #0a0f1c;
        --sidebar-hover:       #172033;

        --login-gradient: linear-gradient(135deg, #0b1120 0%, #1e293b 100%);
        --focus-ring: 0 0 0 3px rgba(96, 165, 250, 0.35);

        --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
        --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.45);
        --shadow-lg: 0 20px 50px rgba(0, 0, 0, 0.6);
    }
}

/* ============================================================
   RESET & BASE
   ============================================================ */
* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

html, body {
    font-family: var(--font-sans);
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
    font-size: 14px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Icons (js/icons.js) sit on the text baseline and take the text color. */
.icon {
    display: inline-block;
    flex-shrink: 0;
    vertical-align: -0.2em;
}

.app { display: flex; min-height: 100vh; }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text-strong);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 200;
    transition: transform 0.25s ease;
    overflow-y: auto;
}
.sidebar-header {
    display: flex; align-items: center; gap: var(--space-3);
    padding: var(--space-5) var(--space-5) var(--space-4);
}
.brand-mark {
    width: 36px; height: 36px; border-radius: var(--radius-md);
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff;
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.sidebar-header h1 { font-size: 15px; font-weight: 700; color: var(--sidebar-text-strong); line-height: 1.2; }
.sidebar-header .tagline { font-size: 11px; color: var(--sidebar-muted); margin-top: 2px; }

.sidebar-user {
    display: flex; align-items: center; gap: var(--space-3);
    margin: 0 var(--space-3) var(--space-2);
    padding: var(--space-3);
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--sidebar-divider);
    border-radius: var(--radius-md);
}
.sidebar-user-text { min-width: 0; }
.sidebar-user .name {
    font-size: 13px; font-weight: 600; color: var(--sidebar-text-strong);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user .role {
    font-size: 10.5px; color: var(--sidebar-accent); margin-top: 1px;
    text-transform: uppercase; letter-spacing: 0.6px; font-weight: 600;
}

.sidebar-nav { flex: 1; padding: var(--space-2) var(--space-3); }
.nav-section-label {
    font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.9px;
    color: var(--sidebar-muted); padding: var(--space-4) var(--space-3) var(--space-2); font-weight: 600;
}
.nav-link {
    display: flex; align-items: center; gap: var(--space-3);
    padding: 9px var(--space-3); margin-bottom: 2px;
    color: var(--sidebar-text); text-decoration: none; font-size: 13.5px; font-weight: 500;
    border-radius: var(--radius-sm);
    transition: background var(--transition), color var(--transition);
}
.nav-link:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.nav-link:focus-visible { outline: none; box-shadow: 0 0 0 2px var(--sidebar-active); }
.nav-link.active {
    background: rgba(96, 165, 250, 0.16); color: var(--sidebar-text-strong);
    box-shadow: inset 3px 0 0 var(--sidebar-active);
}
.nav-link .nav-icon { opacity: 0.85; }
.nav-link.active .nav-icon { color: var(--sidebar-active); opacity: 1; }

.sidebar-footer {
    padding: var(--space-3);
    border-top: 1px solid var(--sidebar-divider);
}
.sidebar-footer button {
    width: 100%; justify-content: flex-start; padding: 9px var(--space-3);
    background: transparent; border: none; color: var(--sidebar-text);
    font-size: 13px; gap: var(--space-3);
}
.sidebar-footer button:hover { background: var(--sidebar-hover); color: var(--sidebar-text-strong); }
.sidebar-footer button.danger:hover { background: rgba(248, 113, 113, 0.14); color: #fca5a5; }

/* ============================================================
   MAIN AREA & TOP BAR
   ============================================================ */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
    display: flex; flex-direction: column;
}
.topbar {
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    min-height: 64px;
    padding: var(--space-3) var(--space-6);
    display: flex; align-items: center; gap: var(--space-3);
    position: sticky; top: 0; z-index: 100;
}
.topbar h2 {
    font-size: 18px; font-weight: 600; color: var(--color-text); flex: 1;
    display: flex; align-items: center; gap: var(--space-2);
    letter-spacing: -0.01em;
}
.topbar h2 .icon { color: var(--color-primary); }
.topbar .topbar-actions { display: flex; gap: var(--space-2); }
.hamburger {
    display: none; background: transparent; border: none;
    font-size: 20px; color: var(--color-text);
    padding: 7px; border-radius: var(--radius-sm); line-height: 0;
}
.hamburger:hover { background: var(--color-surface-hover); }

.page {
    padding: var(--space-6); flex: 1; max-width: 1300px; width: 100%; margin: 0 auto;
}
.page-header { margin-bottom: var(--space-5); }
.page-header h3 { font-size: 16px; font-weight: 600; color: var(--color-text); margin-bottom: 4px; }
.page-header p { font-size: 13px; color: var(--color-text-muted); }

/* Short explanation at the top of a page */
.page-intro { color: var(--color-text-muted); font-size: 14px; margin-bottom: var(--space-4); max-width: 70ch; }

/* Section heading inside a page, e.g. "Recent Orders" */
.section-heading {
    display: flex; align-items: center; gap: var(--space-2);
    font-size: 16px; font-weight: 600; color: var(--color-text);
    margin-bottom: var(--space-3);
}
.section-heading .icon { color: var(--color-primary); }

/* ============================================================
   ICON BUTTONS (theme toggle, bell, install, hamburger)
   .icon-btn is the generic version; don't reuse .theme-toggle for other
   buttons, because js/theme.js redraws every .theme-toggle's icon.
   ============================================================ */
.icon-btn,
.theme-toggle,
.notif-bell {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 38px; height: 38px; padding: 0;
    background: transparent; color: var(--color-text);
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    line-height: 0;
}
.icon-btn:hover,
.theme-toggle:hover,
.notif-bell:hover { background: var(--color-surface-hover); }
/* Floating version for pages without a top bar (login). */
.theme-toggle.floating {
    position: fixed; top: var(--space-4); right: var(--space-4); z-index: 10;
    background: var(--color-surface); box-shadow: var(--shadow-md);
}

/* ============================================================
   BUTTONS
   ============================================================ */
button {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    cursor: pointer; border: 1px solid transparent; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 13.5px; font-weight: 500; line-height: 1.2;
    padding: 9px 16px;
    transition: background var(--transition), border-color var(--transition),
                color var(--transition), box-shadow var(--transition), transform 0.1s;
    white-space: nowrap;
}
button:active:not(:disabled) { transform: translateY(1px); }
button:disabled { opacity: 0.5; cursor: not-allowed; }
button:focus-visible { outline: none; box-shadow: var(--focus-ring); }

.btn-primary   { background: var(--color-primary); color: var(--color-on-primary); box-shadow: var(--shadow-sm); }
.btn-primary:hover:not(:disabled)   { background: var(--color-primary-hover); }
.btn-danger    { background: var(--color-danger-solid); color: #fff; box-shadow: var(--shadow-sm); }
.btn-danger:hover:not(:disabled)    { background: #b91c1c; }
.btn-success   { background: var(--color-success-solid); color: #fff; box-shadow: var(--shadow-sm); }
.btn-success:hover:not(:disabled)   { background: #166534; }
.btn-secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn-secondary:hover:not(:disabled) { background: var(--color-surface-hover); }
.btn-block     { display: flex; width: 100%; padding: 11px; }
.btn-sm        { padding: 6px 12px; font-size: 12.5px; }
.btn-auto      { width: auto; }
/* Text-only button, e.g. "Mark all as read" */
.btn-link {
    background: transparent; color: var(--color-primary); padding: 4px 6px;
}
.btn-link:hover:not(:disabled) { background: var(--color-primary-soft); }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: 11px 14px; border-radius: var(--radius-md); font-size: 13px;
    margin-bottom: var(--space-4); display: none;
    border: 1px solid transparent;
}
.alert.show { display: block; }
.alert .icon { margin-right: 6px; }
.alert.error   { background: var(--color-danger-soft);  color: var(--color-danger);  border-color: color-mix(in srgb, var(--color-danger) 30%, transparent); }
.alert.success { background: var(--color-success-soft); color: var(--color-success); border-color: color-mix(in srgb, var(--color-success) 30%, transparent); }
.alert.warning { background: var(--color-warning-soft); color: var(--color-warning); border-color: color-mix(in srgb, var(--color-warning) 30%, transparent); }

/* ============================================================
   FORMS
   ============================================================ */
.form-group { margin-bottom: var(--space-4); }
.form-group label {
    display: block; font-size: 12.5px; font-weight: 600;
    margin-bottom: 6px; color: var(--color-text-muted);
}
.form-group input,
.form-group select,
.form-group textarea,
.input {
    width: 100%; padding: 9px 12px;
    border: 1px solid var(--color-border-strong); border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    background: var(--color-surface); color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-group textarea { resize: vertical; }
.input { width: auto; }
.form-group input::placeholder,
.form-group textarea::placeholder,
.toolbar input::placeholder { color: var(--color-text-muted); opacity: 0.8; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.input:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}
.label-hint { font-weight: 400; font-size: 11.5px; color: var(--color-text-muted); }
.form-hint { display: block; margin-top: 6px; font-size: 12px; color: var(--color-text-muted); }

/* ============================================================
   TOOLBAR (search and filters above tables)
   ============================================================ */
.toolbar {
    display: flex; gap: 10px; flex-wrap: wrap;
    align-items: center; margin-bottom: var(--space-4);
}
.toolbar input,
.toolbar select {
    padding: 8px 12px; border: 1px solid var(--color-border-strong);
    border-radius: var(--radius-sm); font-size: 13.5px;
    background: var(--color-surface); color: var(--color-text);
    font-family: inherit; min-width: 150px;
    transition: border-color var(--transition), box-shadow var(--transition);
}
.toolbar input { min-width: 240px; }
.toolbar input[type="date"] { min-width: 150px; }
.toolbar-label { font-size: 13px; font-weight: 500; color: var(--color-text-muted); }
.toolbar input:focus,
.toolbar select:focus {
    outline: none; border-color: var(--color-primary);
    box-shadow: var(--focus-ring);
}
/* Search box with a magnifier icon inside */
.search-field { position: relative; display: inline-flex; align-items: center; }
.search-field .icon {
    position: absolute; left: 10px; color: var(--color-text-muted); pointer-events: none;
}
.toolbar .search-field input { padding-left: 34px; }

/* ============================================================
   CARDS & STATS
   ============================================================ */
.card {
    background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-5);
    box-shadow: var(--shadow-sm); border: 1px solid var(--color-border);
}
.card-title {
    font-size: 14px; font-weight: 600; color: var(--color-text);
    margin-bottom: 14px; display: flex; align-items: center; gap: var(--space-2);
}
.card-title .icon { color: var(--color-primary); }
/* Divider + right-aligned actions at the bottom of a card */
.card-footer {
    margin-top: var(--space-4); padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
    display: flex; justify-content: flex-end; gap: var(--space-2); flex-wrap: wrap;
}
/* Avatar + name + contact details */
.profile-summary { display: flex; align-items: center; gap: var(--space-5); }
.profile-name { font-size: 18px; font-weight: 600; color: var(--color-text); }
.profile-name-lg { font-size: 22px; letter-spacing: -0.01em; }
.profile-header {
    flex-wrap: wrap; padding-bottom: var(--space-5); margin-bottom: var(--space-5);
    border-bottom: 1px solid var(--color-border);
}
.card-footer.start { justify-content: flex-start; }
/* Stacked label/value fields (profile details) */
.field-list { display: grid; gap: var(--space-4); }
.field-value { font-size: 15px; color: var(--color-text); }
.pre-wrap { white-space: pre-wrap; }
/* Narrower page for simple, single-column content */
.page.page-narrow { max-width: 800px; }
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-4);
}
.module-card {
    background: var(--color-surface); padding: var(--space-5); border-radius: var(--radius-lg);
    cursor: pointer;
    transition: transform var(--transition), box-shadow var(--transition), border-color var(--transition);
    border: 1px solid var(--color-border);
    display: flex; flex-direction: column; gap: 6px;
}
.module-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--color-primary); }
.module-card h3 { font-size: 14.5px; font-weight: 600; color: var(--color-text); }
.module-card p { font-size: 12.5px; color: var(--color-text-muted); line-height: 1.4; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 14px; margin-bottom: var(--space-5);
}
.stat-card {
    position: relative; overflow: hidden;
    background: var(--color-surface); padding: var(--space-4) var(--space-5);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow-sm);
}
/* Colored accent strip on the left; set the color with a tone-* class. */
.stat-card::before {
    content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px;
    background: var(--tone, var(--color-primary));
}
.stat-card .label {
    font-size: 11px; color: var(--color-text-muted);
    text-transform: uppercase; font-weight: 600; letter-spacing: 0.5px;
}
.stat-card .value {
    font-size: 22px; font-weight: 700; margin-top: 6px; color: var(--tone-text, var(--color-text));
    letter-spacing: -0.01em;
}
.tone-primary { --tone: var(--color-primary); --tone-text: var(--color-primary); }
.tone-success { --tone: var(--color-success); --tone-text: var(--color-success); }
.tone-warning { --tone: var(--color-warning); --tone-text: var(--color-warning); }
.tone-danger  { --tone: var(--color-danger);  --tone-text: var(--color-danger); }
.tone-muted   { --tone: var(--color-text-muted); --tone-text: var(--color-text-muted); }

/* Two equal columns that stack on small screens */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-5); margin-bottom: var(--space-5); }

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
    overflow-x: auto; border-radius: var(--radius-lg);
    border: 1px solid var(--color-border); background: var(--color-surface);
    box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td {
    padding: 12px 14px; text-align: left;
    border-bottom: 1px solid var(--color-border); white-space: nowrap;
}
th {
    background: var(--color-surface-2); font-weight: 600; color: var(--color-text-muted);
    font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.5px;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { cursor: pointer; transition: background var(--transition); }
tbody tr:hover { background: var(--color-surface-hover); }
td.multiline { white-space: normal; }
/* Tables inside modals and cards: no outer frame of their own */
.card table th, .modal table th { background: transparent; }

/* Numbers and money line up on the right */
th.num, td.num, .num { text-align: right; font-variant-numeric: tabular-nums; }

/* "Loading…", "No results" and error rows that span the whole table */
td.table-state {
    text-align: center; padding: 36px 14px; color: var(--color-text-muted);
    white-space: normal; cursor: default;
}
td.table-state.error { color: var(--color-danger); }
tr:has(> td.table-state):hover { background: transparent; }

/* Rows that are not clickable, and rows shown faded (e.g. voided payments) */
tbody tr.static-row { cursor: default; }
tr.row-muted td { opacity: 0.6; }

/* "12 order(s) found." under a table */
.count-label { margin-top: var(--space-3); font-size: 13px; color: var(--color-text-muted); }

/* ============================================================
   MODALS
   ============================================================ */
.modal-overlay {
    position: fixed; inset: 0; background: var(--color-overlay);
    display: none; justify-content: center; align-items: flex-start;
    z-index: 1000; padding: 30px 20px; overflow-y: auto;
    backdrop-filter: blur(2px);
}
.modal-overlay.show { display: flex; }
.modal {
    background: var(--color-surface); color: var(--color-text);
    padding: var(--space-6); border-radius: var(--radius-lg);
    width: 480px; max-width: 100%; margin: auto;
    box-shadow: var(--shadow-lg); border: 1px solid var(--color-border);
}
.modal-overlay.show .modal { animation: modal-in 0.18s ease-out; }
@keyframes modal-in {
    from { opacity: 0; transform: translateY(8px) scale(0.98); }
    to   { opacity: 1; transform: none; }
}
.modal h2 {
    font-size: 18px; font-weight: 600; margin-bottom: 18px; color: var(--color-text);
    letter-spacing: -0.01em;
}
.modal-sm { width: 460px; }
.modal-md { width: 620px; }
.modal-lg { width: 720px; }
.modal-actions {
    display: flex; gap: 10px; justify-content: flex-end;
    margin-top: var(--space-5); flex-wrap: wrap;
}
.modal-actions.split { justify-content: space-between; }

/* ============================================================
   BADGES, CHIPS & ORDER STATUS
   ============================================================ */
.badge, .chip, .status-badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 10px; border-radius: var(--radius-pill);
    font-size: 11.5px; font-weight: 600; line-height: 1.5; white-space: nowrap;
    background: var(--color-neutral-soft); color: var(--color-text-muted);
}
.badge.active,   .chip.success { background: var(--color-success-soft); color: var(--color-success); }
.badge.inactive, .chip.danger  { background: var(--color-danger-soft);  color: var(--color-danger); }
.chip.primary { background: var(--color-primary-soft); color: var(--color-primary-text); }
.chip.warning { background: var(--color-warning-soft); color: var(--color-warning); }
/* Pill holding a code like STATUS_CHANGE */
.chip-code { font-size: 10.5px; font-weight: 700; letter-spacing: 0.3px; }

/* Order status: <span class="status-badge status-ready">Ready</span> */
.status-pending   { background: var(--color-warning-soft); color: var(--color-warning); }
.status-washing   { background: var(--color-primary-soft); color: var(--color-primary-text); }
.status-ready     { background: var(--color-success-soft); color: var(--color-success); }
.status-claimed   { background: var(--color-neutral-soft); color: var(--color-text-muted); }
.status-cancelled { background: var(--color-danger-soft);  color: var(--color-danger); }

/* ============================================================
   DETAIL BLOCKS (order details, profile, payment summaries)
   ============================================================ */
/* Label/value pairs in a 2-column grid */
.info-grid {
    display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3) var(--space-4);
    margin-bottom: var(--space-4); font-size: 14px;
}
.info-label {
    display: block; font-size: 11.5px; font-weight: 600; color: var(--color-text-muted);
    text-transform: uppercase; letter-spacing: 0.4px; margin-bottom: 2px;
}

/* Totals box: Total / Paid / Balance */
.summary-box {
    margin-top: var(--space-4); padding: var(--space-3) var(--space-4);
    background: var(--color-surface-2); border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
}
.summary-row { display: flex; justify-content: space-between; gap: var(--space-3); margin-bottom: 4px; }
.summary-row:last-child { margin-bottom: 0; }
.summary-row.total {
    padding-top: var(--space-2); margin-top: var(--space-2);
    border-top: 1px solid var(--color-border); font-weight: 600;
}
.summary-row.total .amount { font-size: 17px; }

/* Highlighted notes */
.note-box {
    margin-top: var(--space-3); padding: 10px var(--space-3);
    background: var(--color-warning-soft); color: var(--color-text);
    border: 1px solid color-mix(in srgb, var(--color-warning) 25%, transparent);
    border-radius: var(--radius-md); font-size: 13px;
}

/* A divided section inside a modal ("Payments", "Change Status") */
.section {
    margin-top: var(--space-5); padding-top: var(--space-4);
    border-top: 1px solid var(--color-border);
}
.section-title { font-weight: 600; font-size: 13px; color: var(--color-text-muted); }
.section-header {
    display: flex; justify-content: space-between; align-items: center;
    gap: var(--space-2); margin-bottom: 10px; flex-wrap: wrap;
}
.section-header h3 { font-size: 15px; font-weight: 600; color: var(--color-text); }
.button-row { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; margin-top: 10px; }

/* Row with label left, value right (snapshot lists) */
.list-row {
    display: flex; justify-content: space-between; align-items: center; gap: var(--space-3);
    padding: 10px 0; border-bottom: 1px solid var(--color-border);
}
.list-row:last-child { border-bottom: none; }

/* A boxed item in a list (payments, history) */
.list-item {
    padding: 10px var(--space-3); margin-bottom: 6px;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
    background: var(--color-surface);
}
.list-item.voided { opacity: 0.55; text-decoration: line-through; }
.list-item-head { display: flex; justify-content: space-between; align-items: center; gap: var(--space-2); flex-wrap: wrap; }

.scroll-y { max-height: 300px; overflow-y: auto; }
.scroll-y-lg { max-height: 400px; }
/* Content that only appears on paper (see @media print) */
.print-only { display: none; }
.print-header { margin-bottom: var(--space-4); }
.print-header h1 { font-size: 20px; color: var(--color-text); }
.print-header p { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.flex-between > .card-title { margin-bottom: 0; }
.input.input-sm { padding: 6px 10px; font-size: 13px; }
.empty-text { color: var(--color-text-muted); font-size: 13px; padding: 10px 0; }

/* Round initials, e.g. "JD" */
.avatar {
    width: 60px; height: 60px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #3b82f6, #1d4ed8); color: #fff;
    font-size: 22px; font-weight: 700; letter-spacing: 0.5px;
}
.avatar-sm { width: 34px; height: 34px; font-size: 12.5px; }
.avatar-lg { width: 72px; height: 72px; font-size: 26px; }

/* Small label above a group of fields (not inside .form-group) */
.field-label {
    display: block; margin: var(--space-4) 0 var(--space-2);
    font-size: 12.5px; font-weight: 600; color: var(--color-text-muted);
}
/* Input + button side by side, wrapping on small screens */
.input-row { display: flex; gap: var(--space-2); flex-wrap: wrap; }
.input-row > input { flex: 1; min-width: 200px; }

/* ============================================================
   NEW ORDER FORM (orders.html)
   ============================================================ */
.item-row {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr auto;
    gap: 10px; align-items: center;
    background: var(--color-surface-2);
    padding: 10px; margin-bottom: 10px;
    border: 1px solid var(--color-border); border-radius: var(--radius-md);
}
.item-row .input { width: 100%; min-width: 0; padding: 8px 10px; font-size: 13.5px; }
.item-qty-wrap { display: flex; align-items: center; gap: 6px; }
.item-unit-label { font-size: 12px; font-weight: 600; color: var(--color-text-muted); min-width: 22px; }
.item-subtotal { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.order-total-box { display: flex; justify-content: flex-end; align-items: baseline; gap: 10px; }
.order-total { font-size: 22px; font-weight: 700; color: var(--color-success); font-variant-numeric: tabular-nums; }
@media (max-width: 600px) {
    .item-row { grid-template-columns: 1fr; gap: 8px; }
    .item-row .item-subtotal { text-align: left; }
    .item-row .btn-danger { width: 100%; }
}

/* ============================================================
   LOGIN
   ============================================================ */
.login-wrapper {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; padding: 20px;
    background: var(--login-gradient);
}
.login-card {
    background: var(--color-surface); padding: 36px; border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); border: 1px solid var(--color-border);
    width: 380px; max-width: 100%;
}
.login-card .brand-mark { width: 48px; height: 48px; margin: 0 auto var(--space-3); border-radius: var(--radius-lg); }
.login-card h1 { font-size: 21px; text-align: center; margin-bottom: 4px; color: var(--color-text); letter-spacing: -0.01em; }
.login-card .subtitle { text-align: center; font-size: 13px; color: var(--color-text-muted); margin-bottom: 25px; }
/* "Install app" area under the login form (shown by js/pwa.js when it applies) */
.install-app { margin-top: var(--space-3); text-align: center; }
.install-app:not(:has(> :not([hidden]))) { display: none; }

/* ============================================================
   NOTIFICATIONS
   ============================================================ */
.notif-wrapper { position: relative; }
.notif-count {
    position: absolute; top: -6px; right: -6px;
    min-width: 18px; height: 18px; padding: 0 5px;
    background: var(--color-danger-solid); color: #fff; border-radius: 9px;
    font-size: 11px; font-weight: 700; line-height: 18px; text-align: center;
    border: 2px solid var(--color-surface); box-sizing: content-box;
}
.notif-panel {
    position: absolute; right: 0; top: calc(100% + 8px);
    width: 360px; max-width: calc(100vw - 32px);
    background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); z-index: 150; overflow: hidden;
}
.notif-header {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 14px; border-bottom: 1px solid var(--color-border); font-size: 14px;
}
.notif-mark-all { background: transparent; color: var(--color-primary); padding: 4px 6px; font-size: 12.5px; }
.notif-mark-all:hover { background: var(--color-primary-soft); }
.notif-list { max-height: 420px; overflow-y: auto; }
.notif-item {
    padding: 11px 14px; border-bottom: 1px solid var(--color-border); cursor: pointer;
    border-left: 3px solid transparent; transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-surface-hover); }
.notif-item.unread { background: var(--color-primary-soft); border-left-color: var(--color-primary); }
.notif-title { font-size: 13px; font-weight: 600; color: var(--color-text); }
.notif-message { font-size: 12.5px; color: var(--color-text-muted); margin-top: 3px; line-height: 1.4; white-space: normal; }
.notif-item.unread .notif-message { color: var(--color-text); }
.notif-time { font-size: 11px; color: var(--color-text-muted); margin-top: 4px; }
.notif-empty { padding: 24px 14px; text-align: center; color: var(--color-text-muted); font-size: 13px; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
.sidebar-overlay {
    display: none; position: fixed; inset: 0;
    background: var(--color-overlay); z-index: 199;
}
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
    .sidebar.open { transform: translateX(0); }
    .sidebar-overlay.show { display: block; }
    .main { margin-left: 0; }
    .hamburger { display: inline-flex; }
    .topbar { padding: 10px var(--space-4); min-height: 58px; }
    .topbar h2 { font-size: 16px; }
    .page { padding: var(--space-4); }
    .module-grid { grid-template-columns: 1fr; }
    .grid-2 { grid-template-columns: 1fr; }
    .stat-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
    .stat-card .value { font-size: 18px; }
    table { font-size: 12.5px; }
    th, td { padding: 10px; }
    .modal { padding: var(--space-5); }
}
@media (max-width: 500px) {
    .topbar h2 { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; display: block; }
    .topbar h2 .icon { display: none; } /* more room for the title on phones */
    .topbar .topbar-actions button { padding: 6px 10px; }
    /* Fields take a full row; short buttons share rows */
    .toolbar { gap: 8px; }
    .toolbar input, .toolbar select, .toolbar .search-field, .toolbar-label {
        flex: 1 1 100%; width: 100%; min-width: 0;
    }
    .toolbar .search-field { display: flex; }
    .toolbar .search-field input { flex: 1; }
    .toolbar button { flex: 1 1 auto; }
    .page-header { flex-direction: column; align-items: stretch; }
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat-card { padding: 12px 14px; }
    .stat-card .value { font-size: 16px; }
    .info-grid { grid-template-columns: 1fr; }
    .notif-panel { position: fixed; left: 16px; right: 16px; top: 60px; width: auto; max-width: none; }
}

/* Respect users who turn off animations */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
    body { background: #fff; }
    .sidebar, .topbar, .hamburger, .sidebar-overlay,
    .toolbar, .modal-actions, button { display: none !important; }
    .main { margin-left: 0; }
    .page { max-width: 100%; padding: 10px; }
    .card, .stat-card, .module-card, .table-wrapper { box-shadow: none !important; border: 1px solid #ccc; }
    .no-print { display: none !important; }
    .print-only { display: block !important; }
    /* Print every row, not just what fits in the on-screen scroll box */
    .scroll-y { max-height: none !important; overflow: visible !important; }
    .card { break-inside: avoid; }
    table { page-break-inside: auto; }
    tr { page-break-inside: avoid; }
    @page { margin: 1cm; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.text-muted   { color: var(--color-text-muted); }
.text-danger  { color: var(--color-danger); }
.text-success { color: var(--color-success); }
.text-warning { color: var(--color-warning); }
.text-primary { color: var(--color-primary); }
.link { color: var(--color-primary); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.link:focus-visible { outline: none; box-shadow: var(--focus-ring); border-radius: 3px; }
.strike { text-decoration: line-through; }
.mono { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: 12.5px; }
.text-sm  { font-size: 13px; }
.text-xs  { font-size: 12px; }
.fw-600   { font-weight: 600; }
.mt-10 { margin-top: 10px; } .mt-20 { margin-top: 20px; }
.mb-10 { margin-bottom: 10px; } .mb-20 { margin-bottom: 20px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.flex-row { display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap; }
