/* ====================================================================
   TELQORA — DESIGN TOKENS
   Palette: near-black ink on a soft warm paper, a confident indigo/violet
   for trust/action, a coral accent for the brand mark + destructive
   actions, amber for Debit, deep green for Credit (the ledger's own
   logic made visible, not decoration).
   Type: Space Grotesk (display, geometric and a little unconventional) +
   Inter (body/data — stays highly legible at small sizes for tables).
==================================================================== */
:root {
    --ink: #111218;
    --ink-soft: #505770;
    --ink-faint: #8B91A5;

    --paper: #F4F5F9;
    --surface: #FFFFFF;
    --border: #E4E5ED;
    --border-strong: #CBCDD9;

    --teal: #5B4FE9;
    --teal-dark: #3E33B8;
    --teal-tint: #EDEBFC;

    --garnet: #F04D3A;
    --garnet-dark: #CC3826;
    --garnet-tint: #FDE9E6;

    --amber: #B86E0A;
    --amber-tint: #FAF0DD;

    --credit: #0D8254;
    --credit-tint: #E0F4EA;

    --radius-sm: 10px;
    --radius-md: 12px;
    --radius-lg: 18px;

    --shadow-sm: 0 1px 3px rgba(21, 22, 28, 0.06), 0 1px 2px rgba(21, 22, 28, 0.04);
    --shadow-md: 0 4px 6px rgba(21, 22, 28, 0.04), 0 12px 32px rgba(21, 22, 28, 0.08);
    --shadow-lg: 0 8px 16px rgba(21, 22, 28, 0.06), 0 20px 48px rgba(21, 22, 28, 0.10);
    --shadow-lift: 0 8px 24px rgba(91, 79, 233, 0.18), 0 16px 40px rgba(91, 79, 233, 0.12);

    --ease: cubic-bezier(.22, .68, 0, 1);

    --sidebar-grad-1: #191A2E;
    --sidebar-grad-2: #0C0C18;
    --sidebar-border: rgba(255, 255, 255, 0.06);
    --sidebar-text: #A9ACC2;
    --sidebar-text-hover: #FFFFFF;
    --sidebar-icon: #7E82A0;
    --sidebar-active-bg: rgba(124, 114, 255, 0.14);
    --sidebar-active-text: #A09BFF;
}

/* ==================== DARK MODE ====================
   Same tokens, re-pointed. Everything else in the stylesheet just
   reads these variables, so nothing else needs to change. */
[data-theme="dark"] {
    --ink: #E4E6EE;
    --ink-soft: #9EA4BD;
    --ink-faint: #727896;

    --paper: #1A1D2E;
    --surface: #242740;
    --border: #353956;
    --border-strong: #464B6A;

    --wash: rgba(255, 255, 255, 0.035);

    --teal: #8A82F5;
    --teal-dark: #B0A9FF;
    --teal-tint: rgba(138, 130, 245, 0.16);

    --garnet: #FF7A64;
    --garnet-dark: #FF9585;
    --garnet-tint: rgba(255, 122, 100, 0.14);

    --amber: #E8AD42;
    --amber-tint: rgba(232, 173, 66, 0.15);

    --credit: #3BD998;
    --credit-tint: rgba(59, 217, 152, 0.14);

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.18);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.25), 0 12px 32px rgba(0, 0, 0, 0.35);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.25), 0 20px 48px rgba(0, 0, 0, 0.40);
    --shadow-lift: 0 8px 24px rgba(138, 130, 245, 0.22), 0 16px 40px rgba(138, 130, 245, 0.14);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 15px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--ink-faint); }

::selection { background: var(--teal-tint); color: var(--teal-dark); }

h1, h2, h3 { font-family: 'Space Grotesk', 'Inter', sans-serif; letter-spacing: -0.01em; margin: 0; }

button { font-family: inherit; }

/* ==================== TOP BAR ==================== */
.topbar {
    height: 56px;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 40;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
[data-theme="dark"] .topbar { background: rgba(26, 29, 46, 0.88); }

.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; min-width: 0; }
.brand-text-group { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.demo-account-tag {
    font-size: 0.68rem;
    font-weight: 700;
    color: var(--amber);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.brand-mark {
    width: 34px; height: 34px;
    background: linear-gradient(145deg, var(--garnet), var(--garnet-dark));
    color: white;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 800;
    font-size: 1.05rem;
    box-shadow: 0 2px 8px rgba(240, 77, 58, 0.25);
}
.lf-mark-icon { width: 60%; height: 60%; color: white; flex-shrink: 0; }
.brand-name {
    font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.15rem; color: var(--ink);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.fy-selector {
    padding: 4px 24px 4px 8px; border-radius: 6px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); font-size: 0.78rem; font-weight: 600;
    cursor: pointer; appearance: auto; max-width: 140px;
}
.fy-selector:focus { outline: 2px solid var(--ring); }

.icon-btn {
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    color: var(--ink-soft);
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease), border-color .15s var(--ease);
}
.icon-btn:hover { background: var(--paper); color: var(--ink); border-color: var(--border); }

/* ==================== SHELL / SIDEBAR ==================== */
.app-shell { display: flex; min-height: calc(100vh - 56px); }

.sidebar {
    width: 268px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--sidebar-grad-1), var(--sidebar-grad-2));
    border-right: 1px solid var(--sidebar-border);
    padding: 14px 10px 30px;
    overflow-y: auto;
    box-shadow: inset -1px 0 0 rgba(255,255,255,0.03);
}

.nav-groups { display: flex; flex-direction: column; gap: 4px; }

.nav-group-header {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 0.92rem;
    text-align: left;
}
.nav-group-link {
    flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px;
    padding: 0.65rem 0.5rem 0.65rem 0.75rem;
    color: inherit; text-decoration: none; font: inherit;
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    transition: background .15s var(--ease), color .15s var(--ease);
    cursor: pointer;
}
.nav-group-link:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text-hover); }
.nav-group-toggle {
    display: flex; align-items: center; justify-content: center;
    width: 34px; flex-shrink: 0; background: transparent; border: none;
    color: var(--sidebar-icon); cursor: pointer;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    padding: 0.65rem 0;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.nav-group-toggle:hover { background: rgba(255,255,255,0.1); color: var(--sidebar-text-hover); }
.nav-group-icon { display: flex; color: var(--sidebar-icon); flex-shrink: 0; }
.nav-group.is-active > .nav-group-header { color: var(--sidebar-active-text); }
.nav-group.is-active > .nav-group-header .nav-group-icon { color: var(--sidebar-active-text); }
.nav-group-header .chevron, .nav-group-toggle .chevron { transition: transform .2s var(--ease); color: inherit; }
.nav-group.is-open > .nav-group-header .chevron { transform: rotate(180deg); }

/* Dashboard is a direct link, not a group toggle — pin its look regardless of .nav-link's own rules */
.nav-group-header.nav-link {
    color: var(--sidebar-text);
    font-weight: 600;
    font-size: 0.92rem;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0.65rem 0.75rem;
}
.nav-group-header.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text-hover); }
.nav-group-header.nav-link.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 700; box-shadow: inset 3px 0 0 var(--sidebar-active-text); }

.nav-group-body {
    display: none;
    flex-direction: column;
    padding: 2px 0 8px 42px;
    gap: 1px;
}
.nav-group.is-open > .nav-group-body { display: flex; }

.nav-link {
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    padding: 0.55rem 0.7rem;
    border-radius: var(--radius-sm);
    transition: background .15s var(--ease), color .15s var(--ease);
    min-height: 40px;
    display: flex;
    align-items: center;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: var(--sidebar-text-hover); }
.nav-link.is-active { background: var(--sidebar-active-bg); color: var(--sidebar-active-text); font-weight: 700; box-shadow: inset 3px 0 0 var(--sidebar-active-text); }
/* Keyboard focus was invisible against the dark sidebar — these two rules
   are the only way a keyboard user can tell where they are in the nav. */
.nav-link:focus-visible, .nav-group-header:focus-visible {
    outline: none;
    background: rgba(255,255,255,0.10);
    color: var(--sidebar-text-hover);
    box-shadow: inset 0 0 0 1.5px var(--sidebar-active-text);
}

.sidebar-overlay { display: none; }

/* ==================== MAIN CONTENT / PAGES ==================== */
.main-content { flex: 1; padding: 28px 32px 60px; min-width: 0; }

.page { display: none; }
.page.is-active { display: block; animation: fadeUp .25s var(--ease); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}
.page-head h1 {
    font-size: 1.75rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.15;
}
.page-sub {
    color: var(--ink-faint);
    font-size: 0.92rem;
    margin-top: 6px;
    max-width: 60ch;
    line-height: 1.55;
}

/* ==================== BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0.7rem 1.4rem;
    border-radius: 999px;
    font-weight: 700;
    font-size: 0.92rem;
    border: none;
    cursor: pointer;
    transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
    white-space: nowrap;
    min-height: 44px;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-tint); }

.btn-primary {
    background: linear-gradient(145deg, var(--teal), var(--teal-dark));
    color: white;
    box-shadow: 0 1px 2px rgba(21,22,28,.08), 0 4px 14px rgba(91,79,233,.20);
    letter-spacing: 0.005em;
}
.btn-primary:hover { box-shadow: var(--shadow-lift); transform: translateY(-2px); }

.btn-ghost {
    background: var(--surface);
    color: var(--ink-soft);
    border: 1px solid var(--border-strong);
}
.btn-ghost:hover { background: var(--paper); color: var(--ink); border-color: var(--ink-faint); }

/* The two text buttons live inside table rows, so they stay compact and
   only reveal their tinted pill on hover. */
.btn-danger-text, .btn-outline-text {
    background: transparent;
    border: 1px solid transparent;
    padding: 0.38rem 0.72rem;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 650;
    cursor: pointer;
    transition: background .15s var(--ease), color .15s var(--ease);
}
.btn-danger-text { color: var(--garnet); }
.btn-danger-text:hover { background: var(--garnet-tint); }
.btn-danger-text:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--garnet-tint); }

.btn-outline-text { color: var(--teal-dark); }
.btn-outline-text:hover { background: var(--teal-tint); }
.btn-outline-text:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--teal-tint); }

.btn-spinner {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: inherit;
}
.btn-spinner::before {
    content: '';
    width: 18px; height: 18px;
    border: 2.5px solid rgba(255,255,255,.35);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .65s linear infinite;
    flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }
.hidden { display: none !important; }

/* ==================== TOOLBAR / SEARCH ==================== */
.toolbar-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-field {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.85rem;
    flex: 1;
    min-width: 220px;
    max-width: 420px;
    color: var(--ink-faint);
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.search-field:focus-within { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint); }
.search-field input {
    border: none; outline: none; background: transparent;
    font-size: 0.92rem; color: var(--ink); width: 100%;
}

.select-chip {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    color: var(--ink-soft);
    font-weight: 600;
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--ink-faint);
    font-weight: 600;
}
.date-filter input[type="date"] {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.55rem;
    font-size: 0.82rem;
    color: var(--ink-soft);
    font-weight: 600;
    max-width: 140px;
}
.count-pill {
    margin-left: auto;
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--teal-dark);
    background: var(--teal-tint);
    padding: 0.4rem 0.8rem;
    border-radius: 999px;
}

/* ==================== CARDS / TABLES ==================== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s var(--ease);
}

.table-card { overflow: hidden; border-radius: var(--radius-lg); }
.table-scroll { overflow-x: auto; }

.data-table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.data-table th, .data-table td { padding: 0.85rem 1rem; text-align: left; white-space: nowrap; }
.data-table th {
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--ink-faint);
    font-weight: 700;
    background: var(--paper);
    border-bottom: 2px solid var(--border-strong);
    position: sticky;
    top: 0;
    z-index: 2;
}
.data-table td { border-bottom: 1px solid var(--border); color: var(--ink); }
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background .12s var(--ease); }
.data-table tbody tr:nth-child(even) td { background: var(--wash, rgba(0,0,0,.018)); }
.data-table tbody tr:hover td { background: var(--teal-tint); }
.data-table tbody tr:hover td:first-child { box-shadow: inset 3px 0 0 var(--teal); }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; font-feature-settings: 'tnum'; }
.data-table td strong { font-weight: 650; }
.data-table tr.dblclick-row { cursor: pointer; }
.data-table tr.dblclick-row:hover td:first-child { box-shadow: inset 3px 0 0 var(--indigo, #4f46e5); }

.type-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 650;
    padding: 0.24rem 0.62rem;
    border-radius: 999px;
    background: var(--paper);
    color: var(--ink-soft);
    border: 1px solid var(--border);
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.balance-tag { font-weight: 700; font-variant-numeric: tabular-nums; }
.balance-tag.is-dr { color: var(--amber); }
.balance-tag.is-cr { color: var(--credit); }

.row-actions { display: flex; gap: 4px; justify-content: flex-end; }

.empty-row:hover td { background: transparent !important; box-shadow: none !important; }

/* Status pills carry a matching dot, so state reads at a glance without
   relying on colour alone. */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.74rem;
    font-weight: 650;
    padding: 0.26rem 0.68rem;
    border-radius: 999px;
    white-space: nowrap;
}
.status-badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.status-badge.is-active { background: var(--credit-tint); color: var(--credit); }
.status-badge.is-inactive { background: var(--garnet-tint); color: var(--garnet); }

/* ==================== MODALS ==================== */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(16, 15, 23, 0.5);
    backdrop-filter: blur(12px) saturate(1.2);
    -webkit-backdrop-filter: blur(12px) saturate(1.2);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 3vh 12px;
    z-index: 60;
    overflow-y: auto;
    animation: backdropIn .2s var(--ease);
}
.modal-backdrop.hidden { display: none; }
@keyframes backdropIn { from { opacity: 0; } to { opacity: 1; } }

.shortcut-help-panel {
    position: fixed; inset: 0; z-index: 200;
    background: rgba(16, 15, 23, 0.55);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: flex; align-items: center; justify-content: center;
    animation: backdropIn .2s var(--ease);
}
.shortcut-help-panel.hidden { display: none; }
.shortcut-help-inner {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius-lg); padding: 1.5rem 2rem; min-width: 420px; max-width: 90vw;
    box-shadow: var(--shadow-lg);
}
.shortcut-help-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 1.2rem; border-bottom: 1px solid var(--border); padding-bottom: 0.75rem;
}
.shortcut-help-head h3 { font-size: 1.1rem; font-weight: 800; margin: 0; }
.shortcut-help-body { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem 2rem; }
.shortcut-group h4 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); margin-bottom: 0.5rem; font-weight: 700; }
.shortcut-row { display: flex; justify-content: space-between; align-items: center; padding: 0.3rem 0; font-size: 0.88rem; }
.shortcut-row span { color: var(--text-secondary); }
kbd {
    display: inline-block; background: var(--bg); border: 1px solid var(--border);
    border-radius: 4px; padding: 0.15rem 0.45rem; font-size: 0.78rem;
    font-family: inherit; font-weight: 600; color: var(--text);
    box-shadow: 0 1px 0 var(--border); min-width: 1.4rem; text-align: center;
}

/* SIM Operations */
.badge-blue { background: #DBEAFE; color: #1E40AF; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-amber { background: #FEF3C7; color: #92400E; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-indigo { background: #E0E7FF; color: #3730A3; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-green { background: #D1FAE5; color: #065F46; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.badge-red { background: #FEE2E2; color: #991B1B; padding: 0.15rem 0.55rem; border-radius: 999px; font-size: 0.75rem; font-weight: 600; }
.sim-summary-chip {
    display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.4rem 0.8rem;
    border-radius: var(--radius); background: var(--surface); border: 1px solid var(--border);
    font-size: 0.85rem; font-weight: 600;
}
.sim-summary-chip .chip-count { font-size: 1.05rem; font-weight: 800; }
.sim-comm-rate-input {
    width: 5rem; text-align: right; padding: 0.25rem 0.4rem; border: 1px solid var(--border);
    border-radius: var(--radius); font-size: 0.85rem; background: var(--surface); color: var(--text);
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 620px;
    box-shadow: 0 24px 70px rgba(16, 15, 23, 0.22), 0 4px 12px rgba(16, 15, 23, 0.08), 0 0 0 1px rgba(255,255,255,0.05);
    animation: modalIn .25s var(--ease);
}
.modal-lg { max-width: 740px; }
.modal-xl { max-width: 960px; }

.upload-zone {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 2.5rem 1rem; border: 2px dashed var(--border); border-radius: var(--radius-lg, 12px);
    text-align: center; cursor: pointer; transition: border-color 0.2s, background 0.2s;
}
.upload-zone:hover, .upload-zone.drag-over {
    border-color: var(--teal); background: var(--teal-tint);
}
.upload-zone svg { color: var(--ink-faint); }

.load-data-row-ok { }
.load-data-row-err { background: var(--garnet-tint) !important; }
.load-data-row-dup { background: var(--amber-tint) !important; }
.load-data-inline-select { padding:4px 6px; font-size:0.82rem; border:1px solid var(--border); border-radius:6px; background:var(--surface); color:var(--ink); cursor:pointer; }

@keyframes modalIn {
    from { opacity: 0; transform: translateY(10px) scale(0.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Full-page form layout */
.form-page-body {
    max-width: 860px;
}
.form-page-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}
.form-page-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

/* Form cards — color-coded section headers */
.form-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.form-card-header { border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
.form-card-header {
    display: flex; align-items: center; gap: 10px;
    padding: 0.85rem 1.3rem;
    font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.07em;
    border-bottom: 1px solid var(--border);
}
.form-card-header svg { flex-shrink: 0; opacity: 0.85; }
.form-card-header--indigo { background: linear-gradient(135deg, #EEF2FF, #E0E7FF); color: #3730A3; }
.form-card-header--teal { background: linear-gradient(135deg, #F0FDFA, #CCFBF1); color: #115E59; }
.form-card-header--amber { background: linear-gradient(135deg, #FFFBEB, #FEF3C7); color: #92400E; }
.form-card-header--green { background: linear-gradient(135deg, #F0FDF4, #DCFCE7); color: #166534; }
.form-card-header--rose { background: linear-gradient(135deg, #FFF1F2, #FFE4E6); color: #9F1239; }
.form-card-header--blue { background: linear-gradient(135deg, #EFF6FF, #DBEAFE); color: #1E40AF; }
.form-card-header--violet { background: linear-gradient(135deg, #F5F3FF, #EDE9FE); color: #5B21B6; }
.form-card-header--slate { background: linear-gradient(135deg, #F8FAFC, #F1F5F9); color: #334155; }
[data-theme="dark"] .form-card-header--indigo { background: linear-gradient(135deg, rgba(99,102,241,0.12), rgba(99,102,241,0.06)); color: #A5B4FC; }
[data-theme="dark"] .form-card-header--teal { background: linear-gradient(135deg, rgba(20,184,166,0.12), rgba(20,184,166,0.06)); color: #5EEAD4; }
[data-theme="dark"] .form-card-header--amber { background: linear-gradient(135deg, rgba(245,158,11,0.12), rgba(245,158,11,0.06)); color: #FCD34D; }
[data-theme="dark"] .form-card-header--green { background: linear-gradient(135deg, rgba(34,197,94,0.12), rgba(34,197,94,0.06)); color: #86EFAC; }
[data-theme="dark"] .form-card-header--rose { background: linear-gradient(135deg, rgba(244,63,94,0.12), rgba(244,63,94,0.06)); color: #FDA4AF; }
[data-theme="dark"] .form-card-header--blue { background: linear-gradient(135deg, rgba(59,130,246,0.12), rgba(59,130,246,0.06)); color: #93C5FD; }
[data-theme="dark"] .form-card-header--violet { background: linear-gradient(135deg, rgba(139,92,246,0.12), rgba(139,92,246,0.06)); color: #C4B5FD; }
[data-theme="dark"] .form-card-header--slate { background: linear-gradient(135deg, rgba(148,163,184,0.12), rgba(148,163,184,0.06)); color: #CBD5E1; }
.form-card-body {
    padding: 1.3rem 1.4rem;
    display: flex; flex-direction: column; gap: 1.1rem;
}

@media (min-width: 768px) {
    .form-page-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-page-grid > .form-card:first-child {
        grid-column: 1 / -1;
    }
}

.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 1.1rem 1.3rem;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    background: var(--surface);
    z-index: 2;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-head h2 {
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.modal-body { padding: 1.2rem 1.3rem; display: flex; flex-direction: column; gap: 1.15rem; max-height: 72vh; overflow-y: auto; }

.modal-foot {
    display: flex; justify-content: flex-end; gap: 10px;
    padding: 1rem 1.3rem;
    border-top: 1px solid var(--border);
    position: sticky;
    bottom: 0;
    background: var(--surface);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* ==================== FORM SECTIONS ==================== */
.form-section {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 1.15rem 1.2rem;
    display: flex;
    flex-direction: column;
    gap: 1.1rem;
}
.form-section-title {
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--teal);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 6px;
}
.form-section-title svg { flex-shrink: 0; color: var(--teal); opacity: 0.7; }

.form-section-title::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ==================== FORM FIELDS ==================== */
.field { display: flex; flex-direction: column; gap: 6px; }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.1rem; }
.field label {
    font-size: 0.82rem;
    font-weight: 650;
    color: var(--ink-soft);
    letter-spacing: 0.01em;
}
.req { color: var(--garnet); }
.hint { font-size: 0.78rem; color: var(--ink-faint); line-height: 1.5; }

.field input[type="text"],
.field input[type="tel"],
.field input[type="email"],
.field input[type="password"],
.field input[type="number"],
.field input[type="date"],
.field select,
.field textarea {
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0.72rem 0.85rem;
    font-size: 0.95rem;
    font-family: inherit;
    color: var(--ink);
    background: var(--surface);
    outline: none;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
    width: 100%;
    min-height: 46px;
}
.field input::placeholder, .field textarea::placeholder { color: var(--ink-faint); opacity: 0.65; }
.field input:hover, .field select:hover, .field textarea:hover { border-color: var(--ink-faint); }
.field input:focus, .field select:focus, .field textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-tint), 0 1px 3px rgba(91, 79, 233, 0.08);
}
.field input:disabled, .field input[readonly] {
    background: var(--paper);
    color: var(--ink-soft);
    cursor: not-allowed;
}
.field textarea { resize: vertical; min-height: 80px; }

/* Phone control with fixed +92 prefix */
.phone-control, .amount-control {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
}
.phone-control:focus-within, .amount-control:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-tint);
}
.phone-prefix, .amount-prefix {
    display: flex; align-items: center;
    padding: 0 0.75rem;
    background: var(--paper);
    color: var(--ink-soft);
    font-weight: 700;
    font-size: 0.9rem;
    border-right: 1px solid var(--border-strong);
}
.phone-control input, .amount-control input {
    border: none; outline: none;
    padding: 0.6rem 0.75rem;
    font-size: 0.92rem;
    width: 100%;
    color: var(--ink);
}

/* Password control */
.password-control { display: flex; gap: 8px; }
.password-control input { flex: 1; }
.password-toggle {
    border: 1px solid var(--border-strong);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 0 1rem;
    font-weight: 700;
    font-size: 0.82rem;
    color: var(--teal-dark);
    cursor: pointer;
}
.password-toggle:hover { background: var(--teal-tint); }

.email-control { display: flex; align-items: center; gap: 8px; }
.email-control input { flex: 1; }
.email-tick { font-size: 1.2rem; min-width: 1.4rem; text-align: center; line-height: 1; }
.email-tick.is-valid::after { content: '\2714'; color: #27ae60; }
.email-tick.is-invalid::after { content: '\2718'; color: var(--coral); }

/* ==================== OPENING BALANCE — signature control ==================== */
.balance-field { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1rem; }
.balance-control { display: flex; gap: 12px; align-items: stretch; }
.balance-amount {
    display: flex; flex: 1;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    background: var(--surface);
}
.balance-prefix { display: flex; align-items: center; padding: 0 0.7rem; background: var(--paper); color: var(--ink-soft); font-weight: 700; border-right: 1px solid var(--border-strong); }
.balance-amount input { border: none; outline: none; padding: 0.6rem 0.75rem; font-size: 1rem; font-weight: 700; width: 100%; font-variant-numeric: tabular-nums; }

.balance-toggle { display: flex; border-radius: var(--radius-sm); overflow: hidden; border: 1px solid var(--border-strong); }
.balance-side {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 0.4rem 1.1rem;
    background: var(--surface);
    border: none;
    cursor: pointer;
    color: var(--ink-faint);
    transition: background .15s var(--ease), color .15s var(--ease);
}
.balance-side + .balance-side { border-left: 1px solid var(--border-strong); }
.side-label { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 0.95rem; }
.side-caption { font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.05em; }

.balance-side.side-dr.is-selected { background: var(--amber-tint); color: var(--amber); }
.balance-side.side-cr.is-selected { background: var(--credit-tint); color: var(--credit); }

/* ==================== ITEM: no-opening-qty note ==================== */
.no-opening-note {
    display: flex; gap: 8px; align-items: flex-start;
    background: var(--teal-tint);
    color: var(--teal-dark);
    border-radius: var(--radius-sm);
    padding: 0.75rem 0.9rem;
    font-size: 0.82rem;
    line-height: 1.5;
}
.no-opening-note svg { flex-shrink: 0; margin-top: 2px; }

/* ==================== USER RIGHTS ==================== */
.rights-quick-card { padding: 1.4rem; margin-bottom: 20px; }
.rights-quick-top { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 14px; margin-bottom: 1rem; }

.check-row { display: flex; align-items: center; gap: 10px; font-size: 0.9rem; color: var(--ink-soft); cursor: pointer; }
.check-row input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--teal); cursor: pointer; }
.check-row-strong { font-weight: 700; color: var(--ink); }
.check-row b { color: var(--teal-dark); }

.rights-user-field { min-width: 220px; }
.rights-user-field label { font-size: 0.78rem; }

.rights-quick-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.7rem 1.5rem;
    padding: 1rem 0;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}

.rights-lockback { padding: 1rem 0; font-size: 0.9rem; color: var(--ink-soft); }
.rights-lockback p { margin: 0 0 0.5rem; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.lockback-input {
    width: 70px;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.5rem;
    text-align: center;
    font-weight: 700;
}
.lockback-notes { margin: 0; padding-left: 1.1rem; font-size: 0.82rem; color: var(--ink-faint); display: flex; flex-direction: column; gap: 4px; }

.rights-actions { display: flex; gap: 10px; padding-top: 1rem; }

.rights-detail-card { padding: 1.2rem 1.4rem 1.6rem; }
.rights-search { max-width: none; margin-bottom: 1rem; }

.rights-group { border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: 12px; overflow: hidden; }
.rights-group-head {
    display: flex; align-items: center; gap: 10px;
    background: var(--paper);
    padding: 0.7rem 1rem;
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--ink);
}
.rights-group-head .check-row { margin-left: auto; font-weight: 600; font-size: 0.82rem; }
.rights-group-body { display: flex; flex-direction: column; }
.rights-item {
    display: flex; align-items: center; gap: 12px;
    padding: 0.65rem 1.2rem;
    border-top: 1px solid var(--border);
    font-size: 0.86rem;
}
.rights-item-name { color: var(--ink); font-weight: 600; }
.rights-item-perms { display: flex; gap: 16px; margin-left: auto; }
.rights-item-perms label { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font-size: 0.82rem; }
.rights-item-perms input { accent-color: var(--teal); cursor: pointer; }

/* ==================== INVOICE FULL-PAGE FORM ==================== */

.inv-page-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.8rem 1.5rem;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(14px) saturate(1.4);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 56px; z-index: 30;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.03);
}
[data-theme="dark"] .inv-page-topbar { background: rgba(26, 29, 46, 0.90); }
.inv-page-topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.inv-page-topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.inv-page-back {
    width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
    background: var(--surface); color: var(--ink); cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: all 0.15s var(--ease);
}
.inv-page-back:hover { background: var(--paper); border-color: var(--border-strong); }
.inv-page-title { font-size: 1.2rem; font-weight: 700; letter-spacing: -0.02em; white-space: nowrap; }
.inv-page-subtitle { font-size: 0.78rem; margin-top: 2px; }
.inv-cancel-toggle {
    display: flex; align-items: center; gap: 6px; font-size: 0.82rem;
    color: var(--garnet); font-weight: 600; cursor: pointer; margin-right: 8px;
}
.inv-cancel-toggle.hidden { display: none; }
.inv-cancel-toggle input { accent-color: var(--garnet); }
.inv-save-main { background: var(--credit); }
.inv-save-main:hover { background: #0c7a54; }

.inv-page-body { padding: 1.5rem; max-width: 1280px; margin: 0 auto; }

.inv-page-columns {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 1.5rem;
    align-items: flex-start;
}

.inv-page-col-main { display: flex; flex-direction: column; gap: 1.2rem; min-width: 0; }
.inv-page-col-side { display: flex; flex-direction: column; gap: 1.2rem; position: sticky; top: 140px; }

.inv-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.inv-card-head {
    display: flex; align-items: center; gap: 8px;
    padding: 0.75rem 1rem;
    background: var(--paper);
    border-bottom: 1px solid var(--border);
    font-size: 0.72rem; font-weight: 800; text-transform: uppercase;
    letter-spacing: 0.07em; color: var(--teal);
}
.inv-card-head svg { flex-shrink: 0; }
.inv-card-head-toggle { justify-content: space-between; }
.inv-card-head-left { display: flex; align-items: center; gap: 8px; }
.inv-card-body { padding: 1rem; display: flex; flex-direction: column; gap: 0.85rem; }
.inv-card-body-flush { padding: 0; }
.inv-compact-header { padding: 0.75rem 1rem; gap: 0.6rem; }
.rso-party-grid { grid-template-columns: 1fr 1.8fr; gap: 1.2rem !important; }
.rso-customer-field select { min-width: 0; width: 100%; }

.inv-toggle { position: relative; display: inline-block; width: 38px; height: 22px; cursor: pointer; }
.inv-toggle input { opacity: 0; width: 0; height: 0; }
.inv-toggle-slider {
    position: absolute; inset: 0; border-radius: 22px;
    background: var(--border-strong); transition: background 0.2s var(--ease);
}
.inv-toggle-slider::before {
    content: ''; position: absolute; width: 16px; height: 16px;
    left: 3px; bottom: 3px; border-radius: 50%;
    background: white; transition: transform 0.2s var(--ease);
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}
.inv-toggle input:checked + .inv-toggle-slider { background: var(--teal); }
.inv-toggle input:checked + .inv-toggle-slider::before { transform: translateX(16px); }

.inv-readonly-field { background: var(--paper) !important; color: var(--ink-soft) !important; cursor: default; }

.inv-party-balance-tag {
    display: inline-block; font-size: 0.78rem; color: var(--ink-faint);
    margin-top: 4px; font-variant-numeric: tabular-nums;
}

.field-grid-3 { grid-template-columns: 1fr 1fr 1fr; }

.inv-summary-card .inv-card-body { padding: 0; }
.inv-totals { padding: 0; }
.inv-totals-row {
    display: flex; justify-content: space-between; align-items: center;
    padding: 0.65rem 1rem; font-size: 0.88rem; color: var(--ink-soft);
    border-bottom: 1px solid var(--border);
}
.inv-totals-row:last-child { border-bottom: none; }
.inv-totals-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.inv-totals-grand {
    background: linear-gradient(135deg, var(--teal-tint), transparent 80%);
    font-weight: 800; font-size: 1rem;
    border-left: 3px solid var(--teal);
}
.inv-totals-grand span:last-child { color: var(--teal-dark); font-weight: 800; font-size: 1.08rem; }

.inv-page-actions-mobile { display: none; }

/* ---- Invoice item grid (compact ERP-style) ---- */
.inv-items-grid { border-top: none; overflow: hidden; }
.inv-items-table { width: 100%; border-collapse: collapse; }
.inv-items-table thead th {
    background: var(--paper); font-size: 0.7rem; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 700;
    padding: 7px 10px; border-bottom: 1px solid var(--border); text-align: left;
}
.inv-items-table thead .iit-qty,
.inv-items-table thead .iit-rate { text-align: center; }
.inv-items-table thead .iit-amt { text-align: right; }
.inv-items-table thead .iit-del { width: 36px; }
.inv-items-table thead .iit-serial { text-align: left; }

.inv-items-table tbody tr { border-bottom: 1px solid var(--border); }
.inv-items-table tbody tr:last-child { border-bottom: none; }
.inv-items-table tbody td { padding: 6px 10px; vertical-align: middle; font-size: 0.88rem; }
.inv-items-table tbody td.iit-item { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.inv-items-table tbody td.iit-amt { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-items-table tbody td.iit-del { text-align: center; padding: 2px; }
.inv-items-table tbody td.iit-serial { width: 80px; text-align: center; }

.inv-items-table tbody input {
    border: 1px solid var(--border-strong); border-radius: 5px;
    padding: 5px 8px; font-size: 0.86rem; width: 100%;
    height: 34px; text-align: center; background: var(--surface); color: var(--ink);
}
.inv-items-table tbody input:focus { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-tint); outline: none; }
.inv-items-table td.iit-qty { width: 80px; }
.inv-items-table td.iit-rate { width: 100px; }
.inv-items-table td.iit-amt { width: 110px; }

.inv-serial-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 4px 10px; border: 1px solid var(--border-strong); border-radius: 6px;
    background: var(--paper); color: var(--teal); cursor: pointer;
    font-size: 0.72rem; font-weight: 700; letter-spacing: 0.03em;
    transition: all 0.15s var(--ease); white-space: nowrap;
}
.inv-serial-btn:hover { background: var(--teal-tint); border-color: var(--teal); }
.inv-serial-btn svg { flex-shrink: 0; }
.inv-serial-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; padding: 0 5px;
    border-radius: 9px; background: var(--teal); color: white;
    font-size: 0.68rem; font-weight: 800;
}
.inv-serial-badge.hidden { display: none; }

.inv-serial-panel.hidden, .rso-os-serial-panel.hidden { display: none; }
.rso-os-serial-panel {
    padding: 10px 12px;
    background: var(--teal-tint);
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
    margin-bottom: 4px; border-radius: 0 0 8px 8px;
}
.inv-serial-panel td { padding: 0 !important; }
.inv-serial-panel-inner {
    padding: 10px 12px 10px 12px;
    background: var(--teal-tint);
    border-bottom: 1px solid var(--border);
    display: flex; flex-direction: column; gap: 6px;
}
.inv-serial-panel-inner label {
    font-size: 0.78rem; font-weight: 600; color: var(--ink-soft);
}
.inv-serial-panel-inner label .hint { font-weight: 400; }
.inv-serial-textarea {
    width: 100%; border: 1px solid var(--border-strong); border-radius: 6px;
    padding: 8px 10px; font-size: 0.85rem; resize: vertical;
    font-family: 'SF Mono', 'Cascadia Code', 'Courier New', monospace;
    letter-spacing: 0.02em; line-height: 1.5;
    background: var(--surface); color: var(--ink);
}
.inv-serial-textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 2px var(--teal-tint); outline: none; }
.inv-serial-panel-foot {
    display: flex; align-items: center; justify-content: space-between;
}
.inv-serial-count { font-size: 0.78rem; color: var(--ink-faint); font-variant-numeric: tabular-nums; }
.btn-sm { padding: 0.3rem 0.7rem !important; font-size: 0.78rem !important; min-height: 30px !important; }

/* Barcode Scanner Overlay */
#barcode-scanner-overlay {
    position: fixed; inset: 0; z-index: 9999; background: rgba(0,0,0,0.85);
    display: flex; align-items: center; justify-content: center; padding: 16px;
}
.scanner-container {
    background: var(--surface); border-radius: var(--radius-lg); overflow: hidden;
    width: 100%; max-width: 480px; box-shadow: var(--shadow-lg);
}
.scanner-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 16px; border-bottom: 1px solid var(--border);
}
.scanner-title {
    display: flex; align-items: center; gap: 8px;
    font-weight: 700; font-size: 0.92rem; color: var(--ink);
}
.scanner-title svg { color: var(--teal); }
.scanner-close {
    width: 32px; height: 32px; border: none; background: none; cursor: pointer;
    font-size: 1.4rem; color: var(--ink-faint); border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
}
.scanner-close:hover { background: var(--wash); color: var(--ink); }
.scanner-viewport {
    position: relative; background: #000; aspect-ratio: 4/3; overflow: hidden;
}
#scanner-video { width: 100%; height: 100%; object-fit: cover; }
.scanner-guide {
    position: absolute; inset: 20%; border: 2px solid rgba(91,79,233,0.6);
    border-radius: 8px; pointer-events: none;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.3);
}
.scanner-status {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 16px; font-size: 0.82rem; color: var(--ink-soft);
    border-top: 1px solid var(--border);
}
.scanner-count-label strong { color: var(--teal); font-weight: 800; }
.scanner-last {
    font-family: 'SF Mono', 'Cascadia Code', monospace; font-size: 0.75rem;
    color: var(--ink-faint); max-width: 50%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.scanner-mode-bar {
    display: flex; gap: 0; padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.scanner-mode-btn {
    flex: 1; padding: 8px 6px; border: none; background: transparent; color: var(--ink-faint);
    font-size: 0.78rem; font-weight: 500; cursor: pointer; border-bottom: 2px solid transparent;
    transition: color .15s, border-color .15s;
}
.scanner-mode-btn:hover { color: var(--ink); }
.scanner-mode-btn.is-active { color: var(--teal); border-bottom-color: var(--teal); }
.scanner-actions {
    display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-top: 1px solid var(--border);
}
.scanner-scan-btn {
    display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px;
    border: 1px solid var(--border); border-radius: 6px; background: var(--surface);
    font-size: 0.75rem; font-weight: 600; color: var(--teal); cursor: pointer;
    transition: background .15s, border-color .15s;
}
.scanner-scan-btn:hover { background: var(--teal-tint); border-color: var(--teal); }
.scanner-scan-btn svg { width: 14px; height: 14px; }
.btn-xs { padding: 0.15rem 0.5rem; font-size: 0.72rem; min-height: 24px; border-radius: 4px; background: var(--green-600, #16a34a); color: #fff; border: none; cursor: pointer; }
.btn-xs:hover { opacity: 0.85; }

.item-row-remove {
    width: 28px; height: 28px; border: none; background: transparent;
    color: var(--garnet); cursor: pointer; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.1rem; line-height: 1; flex-shrink: 0;
}
.item-row-remove:hover { background: var(--garnet-tint); }

.inv-items-empty { padding: 1.2rem; text-align: center; color: var(--ink-faint); font-size: 0.84rem; border-bottom: 1px solid var(--border); }
.inv-items-empty.hidden { display: none; }

.inv-add-item-bar { padding: 8px 10px; background: var(--paper); }
.inv-add-item-bar select {
    border: 1px dashed var(--border-strong); border-radius: 6px;
    padding: 6px 10px; font-size: 0.86rem; width: 100%;
    background: var(--surface); color: var(--ink); cursor: pointer; height: 38px;
}
.inv-add-item-bar select:focus { border-color: var(--teal); border-style: solid; outline: none; }

/* Petty Cash lines */
.pc-line {
    display: grid;
    grid-template-columns: 1fr 120px 34px;
    gap: 8px;
    padding: 10px 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
    min-height: 52px;
}
.pc-line:last-child { border-bottom: none; }
.pc-line-head { background: var(--paper); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 700; min-height: unset; padding: 6px 10px; }
#pc-lines { min-height: 200px; }
.pc-line select, .pc-line input {
    border: 1px solid var(--border-strong); border-radius: 6px; padding: 0.65rem 0.6rem; font-size: 0.92rem; width: 100%; min-height: 44px;
}

#jv-lines { min-height: 400px; }

/* Journal Voucher lines */
.jv-line {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 34px;
    gap: 8px;
    padding: 8px 10px;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.jv-line:last-child { border-bottom: none; }
.jv-line-head { background: var(--paper); font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-faint); font-weight: 700; }
.jv-line select, .jv-line input {
    border: 1px solid var(--border-strong); border-radius: 6px; padding: 0.4rem 0.5rem; font-size: 0.86rem; width: 100%;
}

/* Line-item rows (Purchase/Sale items, Petty Cash, Journal Voucher) inside
   modals stay as a grid on phones rather than stacking — a header row sits
   above every one of these, so switching to single-column would separate
   each field from its label. Instead, narrow the columns and tighten
   spacing so everything still fits without horizontal overflow. */
@media (max-width: 480px) {
    .pc-line, .pc-line-head { grid-template-columns: 1fr 100px 34px; gap: 5px; padding: 8px 6px; }
    .jv-line, .jv-line-head { grid-template-columns: 1.5fr 0.85fr 0.85fr 34px; gap: 5px; padding: 8px 6px; }
    .pc-line select, .pc-line input,
    .jv-line select, .jv-line input {
        padding: 0.35rem 0.4rem;
        font-size: 0.8rem;
    }
    .inv-items-table tbody td { padding: 3px 6px; font-size: 0.82rem; }
    .inv-items-table tbody td.iit-item { max-width: 120px; }
    .inv-items-table td.iit-qty { width: 60px; }
    .inv-items-table td.iit-rate { width: 80px; }
    .inv-items-table td.iit-amt { width: 85px; font-size: 0.8rem; }
    .inv-items-table tbody input { height: 32px; padding: 4px 5px; font-size: 0.82rem; }
    .inv-add-item-bar select { height: 34px; font-size: 0.82rem; }
}

/* ==================== INVOICE FORM EXTRAS (cont'd) ==================== */

.totals-box {
    background: var(--paper);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 0.9rem 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.totals-row { display: flex; justify-content: space-between; font-size: 0.88rem; color: var(--ink-soft); }
.totals-row span:last-child { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.totals-grand { border-top: 1px solid var(--border-strong); margin-top: 4px; padding-top: 8px; font-weight: 800; font-size: 1rem; }
.totals-grand span:last-child { color: var(--teal-dark); font-weight: 800; }

/* ==================== SIDEBAR PRODUCT BRAND ==================== */
.sidebar-product-brand {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px 12px;
    margin-bottom: 10px;
    border-bottom: 1px solid var(--sidebar-border);
    color: var(--sidebar-icon);
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.sidebar-product-brand svg { color: var(--sidebar-active-text); flex-shrink: 0; }

/* ==================== TRIAL / STATUS BANNER ==================== */
.trial-banner {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 0.7rem 24px;
    background: linear-gradient(90deg, var(--amber-tint), transparent 90%);
    border-bottom: 1px solid var(--border);
    font-size: 0.88rem;
    color: var(--ink);
}
.trial-banner.is-urgent { background: linear-gradient(90deg, var(--garnet-tint), transparent 90%); }
.trial-banner-badge {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.06em;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: var(--amber);
    color: white;
    flex-shrink: 0;
}
.trial-banner.is-urgent .trial-banner-badge { background: var(--garnet); }
.trial-banner-btn {
    margin-left: auto;
    flex-shrink: 0;
    background: var(--ink);
    color: white;
    font-weight: 700;
    font-size: 0.82rem;
    padding: 0.4rem 0.9rem;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: transform .15s var(--ease), box-shadow .15s var(--ease);
}
.trial-banner-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); }

@media (max-width: 640px) {
    .trial-banner { flex-wrap: wrap; padding: 0.7rem 14px; }
    .trial-banner-btn { margin-left: 0; }
}

/* ==================== REPORT EXPORT TOOLBAR ==================== */
.export-toolbar {
    display: flex; gap: 6px; margin-left: auto;
    background: var(--wash, rgba(0,0,0,.025));
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 4px;
}
.export-btn {
    display: flex; align-items: center; gap: 5px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 0.4rem 0.75rem;
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--ink-soft);
    cursor: pointer;
    transition: all .18s var(--ease);
}
.export-btn:hover { background: var(--surface); color: var(--teal-dark); border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.export-btn svg { flex-shrink: 0; }

/* ==================== PRINT ====================
   Hides everything except the currently active report/page content. */
@media print {
    .topbar, .trial-banner, .sidebar, .sidebar-overlay, .toast-stack,
    .export-toolbar, .toolbar-row .search-field, #menu-toggle {
        display: none !important;
    }
    /* The report-doc-header already carries the report name, so the on-page
       heading and its descriptive blurb would just be duplication on paper.
       The filter controls aren't useful printed either — the header states
       the range that was actually used. */
    .page-head, .page-sub, .report-toolbar { display: none !important; }
    .app-shell { display: block !important; }
    .main-content { padding: 0 !important; max-width: none !important; }
    .page { display: none !important; }
    .page.is-active { display: block !important; }
    body { background: white !important; }
    .card { box-shadow: none !important; border: 1px solid #ccc !important; }

    .report-doc-header {
        border: none !important;
        border-bottom: 2px solid #333 !important;
        border-radius: 0 !important;
        padding: 0 0 10px !important;
        margin-bottom: 14px !important;
    }
    .rdh-company { font-size: 16pt !important; color: #000 !important; }
    .rdh-year { font-size: 11pt !important; color: #333 !important; }
    .rdh-address, .rdh-phone { color: #333 !important; }
    .rdh-divider { background: #333 !important; }
    .rdh-title { font-size: 14pt !important; color: #000 !important; }
    .rdh-date { font-size: 10pt !important; color: #333 !important; }
    .rdh-subject { font-size: 11pt !important; color: #000 !important; }
    .data-table td, .data-table th { white-space: nowrap !important; }
    @page { size: auto; margin: 10mm; }
    .rdh-meta { color: #333 !important; }
    .report-summary-row { display: none !important; }

    /* Keep statement-style reports (Balance Sheet, P&L) side by side on
       paper instead of collapsing to one very long column. */
    .statement-grid { display: grid !important; grid-template-columns: 1fr 1fr !important; gap: 12px !important; }
    .data-table { font-size: 9pt !important; }
    .data-table thead { display: table-header-group; }
    tr, .statement-row { page-break-inside: avoid; }
}

/* Sets the browser's own print dialog to default to portrait, matching
   the jsPDF exports (which now always render portrait too — see
   exportReportToPDF). Someone can still flip it manually in the dialog,
   but the default is no longer whatever the browser feels like. */
@page { size: portrait; margin: 14mm 10mm; }

/* ==================== ROTATE-DEVICE OVERLAY ====================
   Phone-width landscape only — a widescreen desktop monitor is always
   "landscape" and must never trigger this. */
.rotate-overlay {
    display: none;
    position: fixed; inset: 0;
    z-index: 1000;
    flex-direction: column;
    align-items: center; justify-content: center;
    gap: 14px;
    padding: 2rem;
    text-align: center;
    background: var(--paper);
    color: var(--ink);
}
.rotate-overlay svg { color: var(--teal); animation: rotateHint 1.6s ease-in-out infinite; }
@keyframes rotateHint {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-90deg); }
}
.rotate-overlay p { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 1.15rem; margin: 0; }
.rotate-overlay span { font-size: 0.88rem; color: var(--ink-faint); }

@media (max-width: 900px) and (orientation: landscape) {
    html {
        transform: rotate(-90deg);
        transform-origin: left top;
        width: 100vh;
        height: 100vw;
        overflow-x: hidden;
        position: absolute;
        top: 100%;
        left: 0;
    }
}

/* ==================== INITIAL LOADING SPLASH ==================== */
.app-loading-screen {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: var(--paper);
    z-index: 999;
}
.app-loading-mark {
    width: 60px; height: 60px;
    border-radius: 18px;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(145deg, var(--garnet), var(--garnet-dark));
    box-shadow: 0 4px 20px rgba(240, 77, 58, 0.3);
    color: white;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 800;
    font-size: 1.6rem;
    animation: appLoadingPulse 1.1s ease-in-out infinite;
}
@keyframes appLoadingPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.6; transform: scale(0.94); }
}

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
    position: fixed; inset: 0;
    display: flex; align-items: flex-start; justify-content: center;
    background: linear-gradient(160deg, var(--paper) 30%, var(--teal-tint) 100%);
    z-index: 200;
    padding: 20px;
    overflow-y: auto;
}
.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 2.4rem 2.2rem;
    width: 100%;
    max-width: 400px;
    text-align: center;
}
@media (max-width: 480px) {
    .login-screen { padding: 0; background: var(--surface); }
    .login-card {
        max-width: 100%; border: none; border-radius: 0; box-shadow: none;
        min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
        padding: 2rem 1.5rem;
    }
}
.login-brand { display: flex; flex-direction: column; align-items: center; gap: 10px; margin-bottom: 4px; }
.login-logo-img, .login-logo-fallback {
    width: 52px; height: 52px;
    border-radius: 14px;
    object-fit: cover;
}
.login-logo-fallback {
    display: flex; align-items: center; justify-content: center;
    font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.4rem;
}
.login-company-name { font-family: 'Space Grotesk', sans-serif; font-weight: 800; font-size: 1.3rem; color: var(--ink); }
.login-sub { color: var(--ink-faint); font-size: 0.88rem; margin: 0 0 1.4rem; }
.login-form { display: flex; flex-direction: column; gap: 1rem; text-align: left; }
.login-submit { width: 100%; justify-content: center; margin-top: 0.4rem; }
.login-hint { font-size: 0.78rem; color: var(--ink-faint); margin-top: 1.2rem; line-height: 1.5; }
.login-hint a { color: var(--teal-dark); font-weight: 700; text-decoration: none; }
.login-hint a:hover { text-decoration: underline; }

/* Dynamic brand logo in the topbar (falls back to the "L" mark) */
.brand-logo-img { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; box-shadow: var(--shadow-sm); }

/* Logo upload row in Settings */
.logo-upload-row { display: flex; align-items: center; gap: 12px; }
.logo-preview, .logo-preview-fallback { width: 48px; height: 48px; border-radius: 12px; object-fit: cover; }
.logo-preview-fallback { display: flex; align-items: center; justify-content: center; font-family: 'Space Grotesk', sans-serif; font-weight: 800; }

/* ==================== REPORT DOCUMENT HEADER ====================
   The letterhead shown at the top of every report — company details, the
   report's own name, what it's about, and the date range. Deliberately the
   same information the PDF/Excel exports carry, so screen, print and
   download all agree. */
.report-doc-header {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.3rem 1.6rem;
    margin-bottom: 18px;
    text-align: center;
    box-shadow: var(--shadow-sm);
}
.rdh-company {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.35rem;
    color: var(--ink);
    line-height: 1.25;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}
.rdh-year {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink-soft);
    margin-top: 0.15rem;
}
.rdh-address { font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.15rem; }
.rdh-phone { font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.1rem; }
.rdh-divider {
    width: 60px;
    height: 2px;
    background: var(--teal);
    margin: 0.6rem auto;
    border-radius: 1px;
}
.rdh-title {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 1.4rem;
    color: var(--teal-dark);
    margin-top: 0.1rem;
    line-height: 1.2;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.rdh-date { font-size: 0.85rem; color: var(--ink-soft); margin-top: 0.25rem; font-weight: 500; }
.rdh-subject {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    color: var(--ink);
    margin-top: 0.25rem;
}
.rdh-meta { font-size: 0.82rem; color: var(--ink-faint); margin-top: 0.15rem; }

@media (max-width: 600px) {
    .report-doc-header { padding: 0.9rem 1rem; }
    .rdh-company { font-size: 1.1rem; }
    .rdh-title { font-size: 1.15rem; }
}

/* ==================== REPORTS ==================== */
.report-toolbar {
    display: flex;
    gap: 14px;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 16px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px 18px;
    box-shadow: var(--shadow-sm);
}
.report-field { display: flex; flex-direction: column; gap: 4px; }
.report-field label { font-size: 0.72rem; font-weight: 700; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.06em; }
.report-field select, .report-field input[type="date"] {
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0.55rem 0.7rem;
    font-size: 0.88rem;
    color: var(--ink);
    min-width: 160px;
    background: var(--paper);
}
.report-field select:focus, .report-field input:focus {
    outline: none; border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-tint);
}

.report-summary-row { display: flex; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.report-summary-card {
    flex: 1; min-width: 160px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.1rem 1.3rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow .2s var(--ease), transform .2s var(--ease);
    border-top: 3px solid var(--teal);
}
.report-summary-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.report-summary-card.summary-indigo { border-top-color: var(--indigo); }
.report-summary-card.summary-teal { border-top-color: var(--teal); }
.report-summary-card.summary-green { border-top-color: var(--credit); }
.report-summary-card.summary-amber { border-top-color: var(--amber); }
.report-summary-card.summary-rose { border-top-color: var(--garnet); }
.report-summary-label { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--ink-faint); font-weight: 700; }
.report-summary-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--teal-dark);
    margin-top: 5px;
    display: block;
    font-variant-numeric: tabular-nums;
}
.report-summary-value.is-dr { color: var(--amber); }
.report-summary-value.is-cr { color: var(--credit); }
.report-summary-value.is-warn { color: var(--garnet); }

.account-dropdown { padding: 0; }
.account-dropdown summary {
    padding: 1.1rem 1.3rem;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.92rem;
    color: var(--ink-soft);
    list-style: none;
}
.account-dropdown summary::-webkit-details-marker { display: none; }
.account-dropdown summary::before {
    content: '▸';
    display: inline-block;
    margin-right: 8px;
    color: var(--ink-faint);
    transition: transform .15s var(--ease);
}
.account-dropdown[open] summary::before { transform: rotate(90deg); }
.account-dropdown summary strong { color: var(--ink); }
.account-dropdown-body { padding: 0 1.3rem 1.1rem; }

.statement-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-bottom: 16px; }
.statement-section { padding: 1.3rem 1.4rem; overflow: hidden; border-radius: var(--radius-lg); }
.statement-section h3 { font-size: 1.05rem; font-weight: 800; margin-bottom: 1rem; letter-spacing: -0.02em; }
.statement-section[class*="statement-section--"] { padding: 0; }
.statement-section[class*="statement-section--"] > h3:first-child {
    font-size: 0.88rem; font-weight: 800; letter-spacing: -0.01em;
    padding: 0.85rem 1.3rem;
    margin: 0;
    display: flex; align-items: center; gap: 8px;
    background: linear-gradient(135deg, var(--teal) 0%, color-mix(in srgb, var(--teal), #000 18%) 100%);
    color: #fff;
}
.statement-section[class*="statement-section--"] > h3:first-child svg { flex-shrink: 0; }
.statement-section[class*="statement-section--"] > *:last-child { margin-bottom: 1.2rem; }
.statement-section[class*="statement-section--"] > h3:first-child + * { margin-top: 1rem; }
.statement-section--indigo > h3:first-child { background: linear-gradient(135deg, var(--indigo) 0%, color-mix(in srgb, var(--indigo), #000 18%) 100%); }
.statement-section--teal > h3:first-child { background: linear-gradient(135deg, var(--teal) 0%, color-mix(in srgb, var(--teal), #000 18%) 100%); }
.statement-section--green > h3:first-child { background: linear-gradient(135deg, var(--credit) 0%, color-mix(in srgb, var(--credit), #000 18%) 100%); }
.statement-section--amber > h3:first-child { background: linear-gradient(135deg, var(--amber) 0%, color-mix(in srgb, var(--amber), #000 18%) 100%); }
.statement-section--violet > h3:first-child { background: linear-gradient(135deg, #7c3aed 0%, #5b21b6 100%); }
.statement-section--rose > h3:first-child { background: linear-gradient(135deg, var(--garnet) 0%, color-mix(in srgb, var(--garnet), #000 18%) 100%); }
.backup-day-grid { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.statement-row { display: flex; justify-content: space-between; padding: 0.5rem 0; border-top: 1px solid var(--border); font-size: 0.9rem; }
.statement-section[class*="statement-section--"] .statement-row { padding-left: 1.3rem; padding-right: 1.3rem; }
.statement-row:first-of-type { border-top: none; }
.statement-row span:last-child { font-weight: 600; font-variant-numeric: tabular-nums; }
.statement-total { border-top: 2px solid var(--border-strong); margin-top: 4px; padding-top: 10px; font-weight: 800; font-size: 0.95rem; }
.statement-section[class*="statement-section--"] .statement-total { padding-left: 1.3rem; padding-right: 1.3rem; }
.statement-total span:last-child { color: var(--teal-dark); font-weight: 800; }
tr.statement-total { background: var(--wash, #f8f8f8); }
tr.statement-total td { padding-top: 0.65rem; padding-bottom: 0.65rem; border-top: 2px solid var(--border-strong); font-weight: 700; }
tfoot tr.statement-total td { border-top: 2px solid var(--ink); }
.statement-subtitle { font-size: 0.78rem; color: var(--ink-faint); font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; margin: 14px 0 4px; }
.statement-subtitle:first-child { margin-top: 0; }
.statement-section[class*="statement-section--"] .statement-subtitle { margin-left: 1.3rem; margin-right: 1.3rem; }
.pos-item-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; margin: 0.3rem 0 0.5rem; }
.pos-item-table th { text-align: left; font-weight: 700; font-size: 0.78rem; color: var(--ink-faint); text-transform: uppercase; letter-spacing: 0.03em; padding: 0.4rem 0.5rem; border-bottom: 2px solid var(--border-strong); }
.pos-item-table td { padding: 0.45rem 0.5rem; border-top: 1px solid var(--border); }
.pos-item-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.pos-item-table .neg { color: var(--debit); }
.pos-item-table tfoot td { font-weight: 700; border-top: 2px solid var(--border-strong); }
.bs-category-header { font-size: 0.8rem; font-weight: 700; color: var(--teal-dark); text-transform: uppercase; letter-spacing: 0.04em; margin: 12px 0 2px; padding: 4px 0; border-bottom: 1px dashed var(--border); }
.bs-sub-row { padding-left: 1rem; }
.bs-sub-total { padding-left: 1rem; font-weight: 700; font-size: 0.82rem; border-top: 1px solid var(--border-strong); margin-bottom: 8px; }
.bs-sub-total span:last-child { color: var(--teal-dark); }
.bs-profit { color: var(--credit) !important; font-weight: 800; }
.bs-loss { color: var(--garnet) !important; font-weight: 800; }
.bs-retained-earnings span { font-weight: 800 !important; }

@media (max-width: 900px) {
    .statement-grid { grid-template-columns: 1fr; }
}

/* ==================== DASHBOARD ==================== */
/* ==================== ERP DASHBOARD ==================== */
.erp-fin-row {
    display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 22px;
}
.erp-fin-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 1rem 1.1rem; cursor: pointer;
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
}
.erp-fin-card:hover { border-color: var(--teal); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.erp-fin-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.erp-fin-label { font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-faint); }
.erp-fin-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.erp-fin-icon--cash { background: rgba(16,185,129,0.12); color: #10b981; }
.erp-fin-icon--bank { background: rgba(59,130,246,0.12); color: #3b82f6; }
.erp-fin-icon--recv { background: rgba(245,158,11,0.12); color: #f59e0b; }
.erp-fin-icon--pay  { background: rgba(239,68,68,0.12); color: #ef4444; }
.erp-fin-value { font-family: 'Space Grotesk', sans-serif; font-size: 1.25rem; font-weight: 800; color: var(--ink); letter-spacing: -0.01em; }

.erp-section-title {
    font-size: 0.78rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--ink-faint); margin: 0 0 12px; padding: 0;
    display: flex; align-items: center; gap: 8px;
}
.erp-section-title svg { width: 16px; height: 16px; opacity: 0.6; flex-shrink: 0; }
.erp-quick-grid-2col {
    display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 22px;
}
.erp-qa {
    display: flex; align-items: center; gap: 12px;
    padding: 0.85rem 1rem; border-radius: var(--radius-md);
    background: var(--surface); border: 1px solid var(--border);
    text-decoration: none; color: var(--ink);
    transition: border-color .2s var(--ease), box-shadow .2s var(--ease), transform .2s var(--ease);
    cursor: pointer;
}
.erp-qa:hover { border-color: var(--teal); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.erp-qa-icon {
    width: 38px; height: 38px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.erp-qa--indigo { background: rgba(99,102,241,0.1); color: #6366f1; }
.erp-qa--green  { background: rgba(16,185,129,0.1); color: #10b981; }
.erp-qa--blue   { background: rgba(59,130,246,0.1); color: #3b82f6; }
.erp-qa--red    { background: rgba(239,68,68,0.1); color: #ef4444; }
.erp-qa--amber  { background: rgba(245,158,11,0.1); color: #d97706; }
.erp-qa--violet { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.erp-qa--teal   { background: rgba(13,148,136,0.1); color: #0d9488; }
.erp-qa--slate  { background: rgba(71,85,105,0.1); color: #475569; }
.erp-qa--cyan   { background: rgba(6,182,212,0.1); color: #0891b2; }
.erp-qa--rose   { background: rgba(244,63,94,0.1); color: #f43f5e; }
.erp-qa--orange { background: rgba(234,88,12,0.1); color: #ea580c; }
.erp-qa-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.erp-qa-name { font-weight: 700; font-size: 0.88rem; color: var(--ink); line-height: 1.25; }
.erp-qa-desc { font-size: 0.7rem; color: var(--ink-faint); line-height: 1.3; }

/* Dashboard greeting */
.dash-greeting-wrap { display: flex; align-items: center; gap: 10px; }
.dash-greeting-icon {
    width: 38px; height: 38px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--teal), var(--teal-dark)); color: #fff; flex-shrink: 0;
}
.dash-greeting-icon svg { width: 20px; height: 20px; }
#dash-greeting { margin: 0; font-size: 1.35rem; }
.dash-greeting-sub {
    margin: 0; font-size: 1rem; font-weight: 500;
    color: var(--teal-dark); letter-spacing: 0.02em; display: inline;
}
.dash-greeting-line { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.typewriter-active::after {
    content: '|'; animation: blink-cursor 0.6s step-end infinite;
    color: var(--teal); font-weight: 300; margin-left: 1px;
}
@keyframes blink-cursor { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
#dash-date-line { margin-top: 0; font-size: 0.82rem; }

.erp-recent-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    overflow: hidden;
}
.erp-recent-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 0.85rem 1rem; border-bottom: 1px solid var(--border);
}
.erp-recent-header-left {
    display: flex; align-items: center; gap: 8px; font-size: 0.82rem; font-weight: 700;
    color: var(--ink); text-transform: uppercase; letter-spacing: 0.03em;
}
.erp-recent-header-left svg { width: 16px; height: 16px; color: var(--ink-faint); }
.erp-recent-count {
    font-size: 0.68rem; font-weight: 700; background: var(--teal-tint); color: var(--teal);
    padding: 2px 8px; border-radius: 10px; letter-spacing: 0.02em;
}
.erp-recent-table tbody tr { cursor: pointer; transition: background .1s; }
.erp-recent-table tbody tr:hover { background: var(--wash); }
.erp-recent-table .erp-txn-type {
    display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: 0.7rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 0.03em;
}
.erp-txn-type--purchase { background: rgba(99,102,241,0.1); color: #6366f1; }
.erp-txn-type--sale { background: rgba(16,185,129,0.1); color: #10b981; }
.erp-txn-type--receipt { background: rgba(59,130,246,0.1); color: #3b82f6; }
.erp-txn-type--payment { background: rgba(239,68,68,0.1); color: #ef4444; }
.erp-txn-type--pettycash { background: rgba(245,158,11,0.1); color: #d97706; }
.erp-txn-type--journal { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.erp-txn-type--return { background: rgba(236,72,153,0.1); color: #ec4899; }
.erp-txn-type--other { background: rgba(100,116,139,0.1); color: #64748b; }

@media (max-width: 900px) {
    .erp-fin-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .erp-fin-row { grid-template-columns: 1fr 1fr; gap: 10px; }
    .erp-fin-value { font-size: 1.05rem; }
    .erp-quick-grid-2col { gap: 8px; }
    .erp-qa { padding: 0.7rem 0.8rem; gap: 10px; }
    .erp-qa-icon { width: 34px; height: 34px; }
    .erp-qa-desc { display: none; }
}
.dash-detail-panel {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md);
    padding: 1rem; margin-top: 4px; animation: dashFadeIn 0.2s;
}
.dash-detail-panel h3 { margin: 0 0 0.7rem; font-size: 0.95rem; color: var(--ink); }
.dash-detail-table { width: 100%; border-collapse: collapse; }
.dash-detail-table th { text-align: left; font-size: 0.72rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.04em; color: var(--ink-faint); padding: 6px 8px; border-bottom: 2px solid var(--border); }
.dash-detail-table td { padding: 8px; font-size: 0.85rem; border-bottom: 1px solid rgba(0,0,0,0.06); }
.dash-detail-table tr:last-child td { border-bottom: none; }
.dash-detail-table .num { text-align: right; font-family: 'Space Grotesk', monospace; font-weight: 600; }
.dash-detail-total td { font-weight: 800; border-top: 2px solid var(--border); font-size: 0.9rem; }
@keyframes dashFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }

/* legacy .dash-section-heading removed — replaced by .erp-section-title */
.btn-whatsapp { color: #25D366 !important; border-color: #25D366 !important; gap: 4px; display: inline-flex; align-items: center; }
.btn-whatsapp:hover { background: #25D366 !important; color: #fff !important; }
.btn-whatsapp svg { flex-shrink: 0; }
.btn-wa-row { color: #25D366 !important; border-color: #25D366 !important; padding: 3px 6px !important; min-width: 0 !important; }
.btn-wa-row:hover { background: #25D366 !important; color: #fff !important; }
.export-btn-wa { background: #25D366; color: #fff; border: 1px solid transparent; border-radius: var(--radius-sm); padding: 0.4rem 0.75rem; font-size: 0.78rem; font-weight: 700; cursor: pointer; display: inline-flex; align-items: center; gap: 5px; transition: all .18s var(--ease); }
.export-btn-wa:hover { background: #1EBE57; box-shadow: var(--shadow-sm); }
.page-head-actions { display: flex; gap: 8px; align-items: center; }

.dash-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}

@media (max-width: 900px) {
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
}

/* ==================== DASHBOARD TABS ==================== */
.dash-tab-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.dash-tab[data-accent="indigo"] { --tab-bg: linear-gradient(135deg, #5B4FE9, #7B6FF2); --tab-bg-hover: linear-gradient(135deg, #4F42D9, #6C5FEB); }
.dash-tab[data-accent="teal"]   { --tab-bg: linear-gradient(135deg, #0D9488, #14B8A6); --tab-bg-hover: linear-gradient(135deg, #0B8278, #0FA89A); }
.dash-tab[data-accent="violet"] { --tab-bg: linear-gradient(135deg, #0284C7, #38BDF8); --tab-bg-hover: linear-gradient(135deg, #0273AD, #2AAFEF); }
.dash-tab[data-accent="amber"]  { --tab-bg: linear-gradient(135deg, #D97706, #F59E0B); --tab-bg-hover: linear-gradient(135deg, #C26B05, #E08E06); }
.dash-tab[data-accent="slate"]  { --tab-bg: linear-gradient(135deg, #475569, #64748B); --tab-bg-hover: linear-gradient(135deg, #3D4A5C, #5A6A7E); }
.dash-tab[data-accent="blue"]   { --tab-bg: linear-gradient(135deg, #2563EB, #3B82F6); --tab-bg-hover: linear-gradient(135deg, #1D4ED8, #2563EB); }
.dash-tab[data-accent="cyan"]   { --tab-bg: linear-gradient(135deg, #0891B2, #06B6D4); --tab-bg-hover: linear-gradient(135deg, #0E7490, #0891B2); }
.dash-tab[data-accent="green"]  { --tab-bg: linear-gradient(135deg, #16A34A, #22C55E); --tab-bg-hover: linear-gradient(135deg, #15803D, #16A34A); }
.dash-tab[data-accent="rose"]   { --tab-bg: linear-gradient(135deg, #E11D48, #F43F5E); --tab-bg-hover: linear-gradient(135deg, #BE123C, #E11D48); }
.dash-tab[data-accent="orange"]  { --tab-bg: linear-gradient(135deg, #EA580C, #F97316); --tab-bg-hover: linear-gradient(135deg, #C2410C, #EA580C); }
.dash-tab[data-accent="emerald"] { --tab-bg: linear-gradient(135deg, #059669, #10B981); --tab-bg-hover: linear-gradient(135deg, #047857, #059669); }

.dash-tab {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding: 0.75rem 1.05rem;
    background: var(--tab-bg);
    border: none;
    border-radius: var(--radius-md);
    text-decoration: none;
    color: #fff;
    box-shadow: 0 4px 14px rgba(0,0,0,0.12), 0 1px 3px rgba(0,0,0,0.08);
    transition: transform .2s var(--ease), box-shadow .2s var(--ease);
    cursor: pointer;
}
.dash-tab:hover {
    transform: translateY(-3px);
    background: var(--tab-bg-hover);
    box-shadow: 0 8px 28px rgba(0,0,0,0.18), 0 2px 6px rgba(0,0,0,0.10);
}
.dash-tab:active { transform: translateY(0); box-shadow: 0 2px 6px rgba(0,0,0,0.10); }

.dash-tab-icon {
    display: flex;
    width: 32px; height: 32px;
    align-items: center; justify-content: center;
    border-radius: 8px;
    background: rgba(255,255,255,0.2);
    color: #fff;
    flex-shrink: 0;
}
.dash-tab-icon svg { width: 17px; height: 17px; }

.dash-tab-text { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.dash-tab-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 800;
    font-size: 0.95rem;
    color: #fff;
    line-height: 1.2;
    letter-spacing: -0.01em;
}
.dash-tab-desc {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.75);
    line-height: 1.35;
}

.dash-tab-meta { display: none; }

@media (max-width: 339px) {
    .dash-tab-desc { display: none; }
}

/* ==================== HUB PAGE OPTIONS ==================== */
.page[data-accent="indigo"] { --tab-accent: #5B4FE9; --tab-wash: rgba(91, 79, 233, 0.09); --tab-wash-hover: rgba(91, 79, 233, 0.16); --tab-icon-bg: rgba(91, 79, 233, 0.14); }
.page[data-accent="teal"]   { --tab-accent: #0D9488; --tab-wash: rgba(13, 148, 136, 0.09); --tab-wash-hover: rgba(13, 148, 136, 0.16); --tab-icon-bg: rgba(13, 148, 136, 0.14); }
.page[data-accent="violet"] { --tab-accent: #0284C7; --tab-wash: rgba(2, 132, 199, 0.09); --tab-wash-hover: rgba(2, 132, 199, 0.16); --tab-icon-bg: rgba(2, 132, 199, 0.14); }
.page[data-accent="amber"]  { --tab-accent: #B45309; --tab-wash: rgba(180, 83, 9, 0.09); --tab-wash-hover: rgba(180, 83, 9, 0.16); --tab-icon-bg: rgba(180, 83, 9, 0.14); }
.page[data-accent="slate"]  { --tab-accent: #475569; --tab-wash: rgba(71, 85, 105, 0.09); --tab-wash-hover: rgba(71, 85, 105, 0.16); --tab-icon-bg: rgba(71, 85, 105, 0.14); }
.page[data-accent="cyan"]   { --tab-accent: #0891B2; --tab-wash: rgba(8, 145, 178, 0.09); --tab-wash-hover: rgba(8, 145, 178, 0.16); --tab-icon-bg: rgba(8, 145, 178, 0.14); }
.page[data-accent="blue"]   { --tab-accent: #2563EB; --tab-wash: rgba(37, 99, 235, 0.09); --tab-wash-hover: rgba(37, 99, 235, 0.16); --tab-icon-bg: rgba(37, 99, 235, 0.14); }

[data-theme="dark"] .page[data-accent="indigo"] { --tab-accent: #8A82F5; --tab-wash: rgba(138, 130, 245, 0.12); --tab-wash-hover: rgba(138, 130, 245, 0.22); --tab-icon-bg: rgba(138, 130, 245, 0.18); }
[data-theme="dark"] .page[data-accent="teal"]   { --tab-accent: #2DD4BF; --tab-wash: rgba(45, 212, 191, 0.12); --tab-wash-hover: rgba(45, 212, 191, 0.22); --tab-icon-bg: rgba(45, 212, 191, 0.18); }
[data-theme="dark"] .page[data-accent="violet"] { --tab-accent: #7DD3FC; --tab-wash: rgba(125, 211, 252, 0.12); --tab-wash-hover: rgba(125, 211, 252, 0.22); --tab-icon-bg: rgba(125, 211, 252, 0.18); }
[data-theme="dark"] .page[data-accent="amber"]  { --tab-accent: #FBBF24; --tab-wash: rgba(251, 191, 36, 0.12); --tab-wash-hover: rgba(251, 191, 36, 0.22); --tab-icon-bg: rgba(251, 191, 36, 0.18); }
[data-theme="dark"] .page[data-accent="slate"]  { --tab-accent: #94A3B8; --tab-wash: rgba(148, 163, 184, 0.12); --tab-wash-hover: rgba(148, 163, 184, 0.22); --tab-icon-bg: rgba(148, 163, 184, 0.18); }
[data-theme="dark"] .page[data-accent="cyan"]   { --tab-accent: #22D3EE; --tab-wash: rgba(34, 211, 238, 0.12); --tab-wash-hover: rgba(34, 211, 238, 0.22); --tab-icon-bg: rgba(34, 211, 238, 0.18); }
[data-theme="dark"] .page[data-accent="blue"]   { --tab-accent: #60A5FA; --tab-wash: rgba(96, 165, 250, 0.12); --tab-wash-hover: rgba(96, 165, 250, 0.22); --tab-icon-bg: rgba(96, 165, 250, 0.18); }

.dash-hub-card {
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}
.dash-hub-card .dash-directory-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}
.dash-hub-card .dash-directory-list a {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--ink);
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 700;
    text-align: left;
    box-shadow: none;
    transition: border-color .15s, box-shadow .15s, background .15s;
    overflow: hidden;
    cursor: pointer;
}
.dash-hub-card .dash-directory-list a::before { display: none; }
.dash-hub-card .dash-directory-list a:hover {
    border-color: var(--accent);
    background: var(--wash);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    transform: none;
}
.dash-hub-card .dash-directory-list a:active { transform: none; }

.hub-opt-icon {
    display: flex;
    flex-shrink: 0;
    width: 38px; height: 38px;
    align-items: center; justify-content: center;
    border-radius: 10px;
    background: rgba(99,102,241,0.1);
    color: #6366f1;
}
.dash-hub-card .dash-directory-list a .hub-opt-icon svg,
.dash-hub-card .dash-directory-list a:hover .hub-opt-icon svg {
    width: 18px; height: 18px;
    padding: 0;
    background: none;
    border-radius: 0;
    color: inherit;
}
.dash-hub-card .dash-directory-list a:hover .hub-opt-icon {
    background: rgba(99,102,241,0.1);
    color: #6366f1;
}
.hub-opt-label {
    flex: 1;
    min-width: 0;
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--ink);
    line-height: 1.25;
}
.hub-opt-arrow { display: none; }

.dash-hub-card .dash-directory-list a:nth-child(6n+1) .hub-opt-icon { background: rgba(99,102,241,0.1); color: #6366f1; }
.dash-hub-card .dash-directory-list a:nth-child(6n+2) .hub-opt-icon { background: rgba(16,185,129,0.1); color: #10b981; }
.dash-hub-card .dash-directory-list a:nth-child(6n+3) .hub-opt-icon { background: rgba(59,130,246,0.1); color: #3b82f6; }
.dash-hub-card .dash-directory-list a:nth-child(6n+4) .hub-opt-icon { background: rgba(245,158,11,0.1); color: #d97706; }
.dash-hub-card .dash-directory-list a:nth-child(6n+5) .hub-opt-icon { background: rgba(139,92,246,0.1); color: #8b5cf6; }
.dash-hub-card .dash-directory-list a:nth-child(6n+6) .hub-opt-icon { background: rgba(13,148,136,0.1); color: #0d9488; }
.dash-hub-card .dash-directory-list a:hover .hub-opt-icon { background: inherit; color: inherit; }

.page[data-accent] .page-head .btn-ghost { align-self: flex-start; }

@media (max-width: 560px) {
    .dash-hub-card .dash-directory-list { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 339px) {
    .dash-hub-card .dash-directory-list { grid-template-columns: 1fr; }
}

.dash-directory-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 14px;
    margin-top: 16px;
}
.dash-directory-card { padding: 1.1rem 1.3rem; }
.dash-directory-card h3 {
    font-size: 0.95rem;
    margin-bottom: 0.6rem;
    color: var(--teal-dark);
    font-family: 'Space Grotesk', sans-serif;
    display: flex;
    align-items: center;
    gap: 8px;
}
.dash-directory-card h3 svg { flex-shrink: 0; color: var(--teal); }
.dash-directory-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.dash-directory-list a {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 1rem 0.5rem 0.85rem;
    background: var(--surface);
    color: var(--ink-soft);
    text-decoration: none;
    font-size: 0.78rem;
    font-weight: 600;
    text-align: center;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    transition: all .15s var(--ease);
}
.dash-directory-list a svg {
    color: var(--teal-dark);
    flex-shrink: 0;
    width: 34px; height: 34px;
    padding: 8px;
    box-sizing: border-box;
    border-radius: 50%;
    background: var(--teal-tint);
    transition: all .15s var(--ease);
}
.dash-directory-list a:hover {
    border-color: var(--teal);
    box-shadow: var(--shadow-lift);
    color: var(--ink);
    transform: translateY(-2px);
}
.dash-directory-list a:hover svg { background: linear-gradient(155deg, var(--teal), var(--teal-dark)); color: white; }

@media (max-width: 900px) {
    .dash-directory-grid { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
    .dash-directory-list { grid-template-columns: 1fr; }
}

/* ==================== ACCOUNT RENEWAL ==================== */
.account-status-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 0.9rem;
}
.account-status-head h3 { margin-bottom: 0; }
.btn-sm { padding: 0.45rem 1rem; font-size: 0.85rem; }

.renew-status {
    display: flex;
    flex-wrap: wrap;
    gap: 28px;
    padding: 1.15rem 1.35rem;
    margin-bottom: 18px;
    border-left: 4px solid var(--credit);
}
.renew-status.is-urgent { border-left-color: var(--amber); }
.renew-status.is-expired { border-left-color: var(--garnet); }
.renew-status-main { display: flex; flex-direction: column; gap: 3px; }
.renew-status-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--ink-faint); font-weight: 700;
}
.renew-status-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.2rem; font-weight: 700; color: var(--ink);
    letter-spacing: -0.01em;
}

.renew-grid { display: grid; grid-template-columns: 1.15fr 1fr; gap: 18px; align-items: start; }
.renew-section-title {
    font-size: 0.95rem; font-weight: 700; color: var(--ink);
    margin: 1.4rem 0 0.8rem; letter-spacing: -0.01em;
}
.renew-plans .renew-section-title:first-child { margin-top: 0; }

.plan-list { display: flex; flex-direction: column; gap: 10px; }
.plan-card {
    position: relative;
    display: block;
    padding: 1rem 1.15rem;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease), background .15s var(--ease);
}
/* The native radio is hidden but kept in the DOM so the control stays
   keyboard-operable and screen-reader correct. */
.plan-card input { position: absolute; opacity: 0; width: 0; height: 0; }
.plan-card:hover { border-color: var(--border-strong); }
.plan-card.is-selected {
    border-color: var(--teal);
    background: linear-gradient(105deg, var(--teal-tint), transparent 65%);
    box-shadow: 0 0 0 3px var(--teal-tint), var(--shadow-sm);
}
.plan-card:focus-within { box-shadow: 0 0 0 3px var(--teal-tint); }
.plan-body { display: flex; flex-direction: column; gap: 5px; }
.plan-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.plan-name {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700; font-size: 1.05rem; color: var(--ink);
    display: inline-flex; align-items: center; gap: 8px;
}
.plan-tag {
    font-family: 'Inter', sans-serif;
    font-size: 0.66rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: 0.05em; color: var(--credit);
    background: var(--credit-tint); padding: 0.16rem 0.5rem; border-radius: 999px;
}
.plan-price {
    font-family: 'Space Grotesk', sans-serif;
    font-weight: 700; font-size: 1.1rem; color: var(--teal-dark);
    font-variant-numeric: tabular-nums;
}
.plan-per { font-size: 0.78rem; font-weight: 600; color: var(--ink-faint); margin-left: 2px; }
.plan-meta { font-size: 0.82rem; color: var(--ink-faint); line-height: 1.45; }

.renew-benefits { margin: 0; padding-left: 1.1rem; color: var(--ink-soft); font-size: 0.9rem; line-height: 1.75; }

.renew-payment { padding: 1.3rem 1.4rem; }
.renew-amount {
    display: flex; flex-direction: column; gap: 3px;
    padding: 1rem 1.15rem;
    background: var(--teal-tint);
    border-radius: var(--radius-md);
    margin-bottom: 1.1rem;
}
.renew-amount-label {
    font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
    color: var(--teal-dark); font-weight: 700;
}
.renew-amount-value {
    font-family: 'Space Grotesk', sans-serif;
    font-size: 1.85rem; font-weight: 700; color: var(--teal-dark);
    letter-spacing: -0.02em; font-variant-numeric: tabular-nums; line-height: 1.15;
}
.renew-amount-note { font-size: 0.8rem; color: var(--ink-soft); }

.pay-block {
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-bottom: 1.1rem;
}
.pay-row {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px;
    padding: 0.7rem 0.9rem;
    font-size: 0.88rem;
    border-bottom: 1px solid var(--border);
}
.pay-row:last-child { border-bottom: none; }
.pay-row > span:first-child { color: var(--ink-faint); flex-shrink: 0; }
.pay-row > span:last-child { color: var(--ink); font-weight: 650; text-align: right; word-break: break-all; }
.pay-copy { display: inline-flex; align-items: center; gap: 6px; justify-content: flex-end; }

.renew-steps { display: flex; flex-direction: column; gap: 9px; margin-bottom: 1.2rem; }
.renew-step { display: flex; align-items: flex-start; gap: 10px; font-size: 0.87rem; color: var(--ink-soft); line-height: 1.5; }
.renew-step-num {
    flex-shrink: 0;
    width: 22px; height: 22px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: var(--teal); color: #fff;
    font-size: 0.72rem; font-weight: 700;
}

@media (max-width: 860px) {
    .renew-grid { grid-template-columns: 1fr; }
}
@media (max-width: 480px) {
    .renew-status { gap: 16px; }
    .pay-row { flex-direction: column; align-items: flex-start; gap: 4px; }
    .pay-row > span:last-child { text-align: left; }
    .pay-copy { justify-content: flex-start; }
}

/* ==================== CHART / GRAPH REPORTS ====================
   A wide primary chart alongside a narrower composition chart. The canvas
   needs an explicitly-sized parent: Chart.js with maintainAspectRatio
   false measures its container, and a container that sizes to its content
   would collapse to zero height. */
.chart-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 16px;
}
.chart-card { padding: 1.15rem 1.3rem; }
.chart-card h3 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--ink);
    margin-bottom: 0.9rem;
    letter-spacing: -0.01em;
}
.chart-canvas-wrap { position: relative; height: 300px; }

@media (max-width: 900px) {
    .chart-grid { grid-template-columns: 1fr; }
    .chart-canvas-wrap { height: 260px; }
}
@media (max-width: 600px) {
    .chart-canvas-wrap { height: 230px; }
    .chart-card { padding: 1rem 1.05rem; }
}

/* Charts are the whole point of these pages, so let them print. */
@media print {
    .chart-grid { grid-template-columns: 1fr 1fr !important; page-break-inside: avoid; }
    .chart-canvas-wrap { height: 240px !important; }
}

/* ==================== EDIT HISTORY ====================
   A timeline rather than a table: each entry is one line you can scan,
   and the field-level before/after detail stays folded away until you
   actually want it. */
.history-timeline { display: flex; flex-direction: column; gap: 22px; }

.history-day-label {
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    color: var(--ink-faint);
    margin-bottom: 10px;
}
.history-day { display: block; }
.history-entry { padding: 0.95rem 1.15rem; margin-bottom: 8px; }
.history-entry:last-child { margin-bottom: 0; }

.history-entry-head { display: flex; align-items: flex-start; gap: 11px; }
.history-dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    margin-top: 6px;
    flex-shrink: 0;
    background: var(--ink-faint);
}
.history-dot.is-created { background: var(--credit); }
.history-dot.is-updated { background: var(--teal); }
.history-dot.is-deleted { background: var(--garnet); }

.history-headline { flex: 1; min-width: 0; }
.history-line {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 0.92rem;
    color: var(--ink-soft);
    line-height: 1.5;
}
.history-line strong { color: var(--ink); font-weight: 650; }
.history-label { font-variant-numeric: tabular-nums; }
.history-creator { display: block; font-size: 0.79rem; color: var(--ink-faint); margin-top: 3px; }
.history-time {
    font-size: 0.8rem;
    color: var(--ink-faint);
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

.history-changes { margin: 9px 0 0 20px; }
.history-changes summary {
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 650;
    color: var(--teal-dark);
    list-style: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.2rem 0;
}
.history-changes summary::-webkit-details-marker { display: none; }
.history-changes summary::before {
    content: '▸';
    transition: transform .15s var(--ease);
    display: inline-block;
}
.history-changes[open] summary::before { transform: rotate(90deg); }
.history-nodetail { margin: 8px 0 0 20px; font-size: 0.79rem; color: var(--ink-faint); }

.history-detail { margin-top: 9px; overflow-x: auto; }
.history-table { width: 100%; border-collapse: collapse; font-size: 0.84rem; }
.history-table th {
    text-align: left;
    font-size: 0.68rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--ink-faint);
    font-weight: 700;
    padding: 0.4rem 0.7rem;
    border-bottom: 1px solid var(--border);
}
.history-table td { padding: 0.45rem 0.7rem; border-bottom: 1px solid var(--border); vertical-align: top; }
.history-table tr:last-child td { border-bottom: none; }
.history-field { font-weight: 650; color: var(--ink); white-space: nowrap; }
/* Before struck through, after highlighted — the change reads instantly
   without having to compare two similar-looking cells. */
.history-from { color: var(--ink-faint); text-decoration: line-through; }
.history-to { color: var(--credit); font-weight: 650; }
.history-arrow { color: var(--ink-faint); width: 1.5rem; text-align: center; }

.history-empty { padding: 3rem 1.5rem; text-align: center; }
.history-empty p { margin: 0 0 6px; color: var(--ink-soft); }

@media (max-width: 600px) {
    .history-entry-head { flex-wrap: wrap; }
    .history-time { width: 100%; padding-left: 20px; }
    .history-changes, .history-nodetail { margin-left: 0; }
}

/* ==================== EMPTY / PLACEHOLDER ==================== */
.empty-panel {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    text-align: center;
    gap: 12px;
    color: var(--ink-faint);
    padding: 5rem 1.5rem;
    background: linear-gradient(180deg, var(--surface), var(--paper));
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-lg);
}
.empty-panel h2 { color: var(--ink-soft); font-size: 1.1rem; }
.empty-panel svg { color: var(--ink-faint); }

/* ==================== TOASTS ==================== */
.toast-stack {
    position: fixed; top: 76px; right: 20px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 100;
}
.toast {
    background: var(--ink);
    color: white;
    padding: 0.8rem 1.15rem;
    border-radius: var(--radius-md);
    font-size: 0.86rem;
    font-weight: 600;
    box-shadow: var(--shadow-lg);
    animation: toastIn .25s var(--ease);
    max-width: 340px;
    backdrop-filter: blur(8px);
}
.toast.is-success { background: var(--teal-dark); }
.toast.is-error { background: var(--garnet-dark); }
.toast.is-warning { background: var(--amber); }
@keyframes toastIn { from { opacity: 0; transform: translateX(12px); } to { opacity: 1; transform: translateX(0); } }

/* ==================== BOTTOM NAV ==================== */
.bottom-nav {
    display: none;
    position: fixed;
    bottom: 0; left: 0; right: 0;
    z-index: 60;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(16px) saturate(1.6);
    -webkit-backdrop-filter: blur(16px) saturate(1.6);
    border-top: 1px solid var(--border);
    padding: 6px 0 max(8px, env(safe-area-inset-bottom));
    justify-content: space-around;
    align-items: stretch;
    box-shadow: 0 -1px 3px rgba(0,0,0,0.03);
}
[data-theme="dark"] .bottom-nav { background: rgba(26, 29, 46, 0.88); }
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) .bottom-nav { background: rgba(26, 29, 46, 0.88); }
}

.bottom-nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 8px 0 4px;
    background: none;
    border: none;
    color: var(--ink-faint);
    font-size: 0.72rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    cursor: pointer;
    transition: color .15s var(--ease);
    -webkit-tap-highlight-color: transparent;
    position: relative;
}
.bottom-nav-btn svg {
    width: 26px; height: 26px;
    stroke-width: 1.7;
    transition: color .15s var(--ease), transform .15s var(--ease);
}
.bottom-nav-btn.is-active { color: var(--teal); }
.bottom-nav-btn.is-active svg { stroke-width: 2; transform: scale(1.08); }

.bottom-more-menu {
    position: absolute;
    bottom: 100%;
    right: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: 6px;
    min-width: 200px;
    margin-bottom: 8px;
}
.bottom-more-menu button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--ink);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: background .15s var(--ease);
}
.bottom-more-menu button:hover { background: var(--bg-wash); }
.bottom-more-menu button svg { width: 22px; height: 22px; flex-shrink: 0; color: var(--teal); }
.bottom-more-menu.hidden { display: none; }

@media (max-width: 900px) {
    .bottom-nav { display: flex; }
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        top: 56px; bottom: 0; left: 0;
        transform: translateX(-100%);
        z-index: 55;
        box-shadow: var(--shadow-md);
        transition: transform .22s var(--ease);
        width: 280px;
    }
    .sidebar.is-open { transform: translateX(0); }
    .sidebar-overlay {
        display: none;
        position: fixed; inset: 56px 0 0 0;
        background: rgba(22,27,34,0.45);
        z-index: 50;
    }
    .sidebar-overlay.is-open { display: block; }
    .main-content { padding: 18px 14px 100px; }
    .field-grid { grid-template-columns: 1fr; }
    .rights-quick-grid { grid-template-columns: 1fr; }
    .balance-control { flex-direction: column; }
}

/* ==================== RSO MODULE ==================== */
.rso-stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.9rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.rso-stat-label { font-size: 0.78rem; color: var(--text-muted); font-weight: 500; }
.rso-stat-value { font-size: 1.15rem; font-weight: 700; color: var(--text); }
.rso-stat-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
.rso-stat-clickable:hover { border-color: var(--primary); box-shadow: 0 2px 8px rgba(91,79,233,0.12); }
.totals-bar {
    display: flex; justify-content: flex-end; align-items: center; gap: 8px;
    padding: 0.8rem 0; font-size: 1.05rem; border-top: 1px solid var(--border);
}
.item-row-header {
    display: grid; grid-template-columns: 1fr 70px 80px 90px; gap: 8px;
    font-size: 0.75rem; color: var(--text-muted); font-weight: 600;
    text-transform: uppercase; letter-spacing: 0.03em;
    padding: 0.4rem 0; border-bottom: 1px solid var(--border);
}
.item-row {
    display: grid; grid-template-columns: 1fr 70px 80px 90px; gap: 8px;
    align-items: center; padding: 0.35rem 0; border-bottom: 1px solid rgba(0,0,0,0.04);
}
.item-row input { width: 100%; text-align: right; }
.row-amount { text-align: right; font-size: 0.82rem; font-weight: 600; color: var(--ink-soft); }
.rso-admin-col { display: table-cell; }
[data-rso-admin].hidden, [data-rso-only].hidden, [data-rso-shared].hidden { display: none !important; }

/* ==================== INTEGRITY CHECK ==================== */
.integrity-container {
    display: flex; flex-direction: column; gap: 12px;
    max-width: 680px;
}
.integrity-row {
    display: flex; align-items: flex-start; gap: 14px;
    padding: 1rem 1.2rem;
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.integrity-icon {
    flex-shrink: 0; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; font-size: 0.85rem; font-weight: 700;
}
.integrity-ok .integrity-icon { background: rgba(16,185,129,0.12); color: #10b981; }
.integrity-warn .integrity-icon { background: rgba(245,158,11,0.12); color: #f59e0b; }
.integrity-error .integrity-icon { background: rgba(239,68,68,0.12); color: #ef4444; }
.integrity-content { flex: 1; min-width: 0; }
.integrity-content strong { font-size: 0.92rem; }
.integrity-content p { color: var(--ink-soft); font-size: 0.85rem; margin: 4px 0 0; }
.integrity-content ul {
    margin: 8px 0 0; padding-left: 1.2rem;
    font-size: 0.82rem; color: var(--ink-faint); line-height: 1.6;
}

/* ==================== BETTER EMPTY STATES ==================== */
.empty-row td {
    text-align: center;
    color: var(--ink-faint);
    padding: 3.5rem 1.5rem;
    font-size: 0.92rem;
    line-height: 1.7;
}
.empty-row td::before {
    content: '';
    display: block;
    width: 48px; height: 48px; margin: 0 auto 12px;
    background: var(--border);
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5'%3E%3Cpath d='M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z'/%3E%3Cpath d='M14 2v6h6M16 13H8M16 17H8M10 9H8'/%3E%3C/svg%3E") center/contain no-repeat;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='1.5'%3E%3Cpath d='M14 2H6a2 2 0 00-2 2v16a2 2 0 002 2h12a2 2 0 002-2V8z'/%3E%3Cpath d='M14 2v6h6M16 13H8M16 17H8M10 9H8'/%3E%3C/svg%3E") center/contain no-repeat;
    opacity: 0.4;
}

/* ==================== BETTER LOADING INDICATORS ==================== */
.page-loading {
    display: flex; align-items: center; justify-content: center;
    padding: 4rem 1rem;
    color: var(--ink-faint);
    gap: 10px; font-size: 0.9rem;
}
.page-loading::before {
    content: '';
    width: 20px; height: 20px;
    border: 2.5px solid var(--border-strong);
    border-top-color: var(--teal);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}

/* ==================== CONSISTENT BUTTON ICONS ==================== */
.btn svg { flex-shrink: 0; }
.btn-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 36px; height: 36px;
    border-radius: var(--radius);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--ink-soft);
    cursor: pointer;
    transition: background .15s var(--ease), border-color .15s var(--ease);
}
.btn-icon:hover { background: var(--paper); border-color: var(--ink-faint); }
.btn-icon svg { width: 16px; height: 16px; }

/* ==================== CANCELLED BADGE + ROW ==================== */
.badge-cancelled {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 4px;
    background: var(--coral);
    color: #fff;
    vertical-align: middle;
}
.cancelled-row td { opacity: 0.55; text-decoration: line-through; }
.cancelled-row td:last-child { text-decoration: none; opacity: 1; }
.cancelled-row .badge-cancelled { text-decoration: none; opacity: 1; }
.badge-active {
    display: inline-block; font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; padding: 2px 7px; border-radius: 4px;
    background: #10b981; color: #fff; vertical-align: middle;
}

.cancel-check {
    margin-right: auto;
    color: var(--coral);
    font-size: 0.85rem;
    font-weight: 500;
}
.cancel-check input:checked + span { color: var(--coral); }

.cancel-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    margin-bottom: 8px;
    background: rgba(231, 76, 60, 0.08);
    border: 1px solid rgba(231, 76, 60, 0.25);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
}
.cancel-inline input[type="checkbox"] { accent-color: #e74c3c; }
.cancel-inline input:checked + span { color: #e74c3c; font-weight: 600; }

/* ==================== MOBILE SPACING IMPROVEMENTS ==================== */
@media (max-width: 900px) {
    .page-head { flex-direction: column; gap: 10px; align-items: flex-start; }
    .page-head > .btn { width: 100%; justify-content: center; }
    .page-head-actions { width: 100%; }
    .page-head-actions .btn { flex: 1; justify-content: center; }
    .toolbar-row { gap: 8px; }
    .search-field { min-width: 0; max-width: 100%; }
    .data-table { font-size: 0.84rem; }
    .data-table th, .data-table td { padding: 0.65rem 0.55rem; }
    .row-actions { gap: 2px; }
    .btn-danger-text, .btn-outline-text { padding: 0.35rem 0.6rem; font-size: 0.8rem; }
    .card { padding: 0; }
    .statement-grid { grid-template-columns: 1fr; }
    .report-toolbar { gap: 10px; padding: 12px 14px; }
    .export-toolbar { width: 100%; margin-left: 0; flex-wrap: wrap; }
    .report-field select, .report-field input[type="date"] { min-width: 0; }
    .dash-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .modal-body { padding: 18px 14px; gap: 1.15rem; }
    .modal-foot { padding: 12px 14px; }
    .field-grid { gap: 12px; }
    .integrity-row { padding: 0.8rem; gap: 10px; }

    .modal {
        max-width: 100%;
        border-radius: var(--radius-lg);
        margin: 0 4px;
    }
    .modal-lg { max-width: 100%; }
    .modal-backdrop { padding: 2vh 8px; }
}

@media (max-width: 480px) {
    .main-content { padding: 14px 10px 100px; }
    .page-head h1 { font-size: 1.25rem; }
    .data-table th, .data-table td { padding: 0.55rem 0.4rem; font-size: 0.8rem; }
    .dash-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
    .erp-fin-value { font-size: 1.05rem; }
    .erp-fin-card { padding: 0.8rem 0.9rem; }
    .toast-stack { right: 10px; left: 10px; }
    .toast { max-width: 100%; }
    .btn { padding: 0.65rem 1.1rem; font-size: 0.88rem; min-height: 44px; }

    .field input[type="text"],
    .field input[type="tel"],
    .field input[type="email"],
    .field input[type="password"],
    .field input[type="number"],
    .field input[type="date"],
    .field select,
    .field textarea {
        font-size: 16px;
        padding: 0.75rem 0.85rem;
        min-height: 48px;
    }

    .form-section { padding: 1rem; }
    .field label { font-size: 0.84rem; }

    .search-field { padding: 0.6rem 0.85rem; }
    .search-field input { font-size: 16px; }

    .select-chip { padding: 0.55rem 0.8rem; font-size: 0.88rem; min-height: 44px; }
    .report-field select, .report-field input[type="date"] {
        font-size: 16px;
        padding: 0.6rem 0.75rem;
        min-height: 44px;
        min-width: 0;
    }
    .report-toolbar {
        padding: 10px 12px;
        gap: 10px;
    }
    .report-field { flex: 1; min-width: 0; }
    .export-toolbar {
        width: 100%;
        margin-left: 0;
        flex-wrap: wrap;
        justify-content: center;
    }
}

/* ==================== INVOICE PAGE RESPONSIVE ==================== */
@media (max-width: 960px) {
    .inv-page-columns { grid-template-columns: 1fr; }
    .inv-page-col-side { position: static; }
    .inv-page-topbar-right { display: none; }
    .inv-page-actions-mobile {
        display: flex; gap: 8px; padding-top: 0.5rem;
    }
    .inv-page-actions-mobile .btn { flex: 1; justify-content: center; }
    .field-grid-3 { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 600px) {
    .inv-page-body { padding: 1rem 0.6rem; }
    .inv-card-body { padding: 0.8rem; }
    .inv-page-title { font-size: 1rem; }
    .field-grid-3 { grid-template-columns: 1fr; }
    .inv-page-topbar { padding: 0.6rem 0.8rem; }
}

/* ==================== SEARCHABLE SELECT DROPDOWN ==================== */
.searchable-select {
    position: relative;
    width: 100%;
}
.searchable-select select { position: absolute; opacity: 0; pointer-events: none; height: 0; }
.ss-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius-md);
    padding: 0.72rem 0.85rem;
    font-size: 0.95rem;
    color: var(--ink);
    background: var(--surface);
    cursor: pointer;
    transition: border-color .15s var(--ease), box-shadow .15s var(--ease);
    min-height: 46px;
}
.ss-display:hover { border-color: var(--ink-faint); }
.searchable-select.is-open .ss-display {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-tint);
}
.ss-display-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ss-display-text.ss-placeholder { color: var(--ink-faint); opacity: 0.75; }
.ss-arrow { font-size: 0.7rem; color: var(--ink-faint); transition: transform .15s; flex-shrink: 0; }
.searchable-select.is-open .ss-arrow { transform: rotate(180deg); }
.ss-dropdown {
    position: fixed;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    max-height: 300px;
    animation: modalIn .18s var(--ease);
}
.ss-search {
    width: 100%;
    border: none;
    border-bottom: 1px solid var(--border);
    padding: 0.7rem 0.85rem;
    font-size: 16px;
    color: var(--ink);
    background: var(--paper);
    outline: none;
}
.ss-search::placeholder { color: var(--ink-faint); }
.ss-options { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.ss-option {
    padding: 0.7rem 0.85rem;
    font-size: 0.92rem;
    cursor: pointer;
    color: var(--ink);
    transition: background .1s;
    min-height: 44px;
    display: flex;
    align-items: center;
    white-space: nowrap;
}
.ss-option:hover, .ss-option.ss-highlighted { background: var(--teal-tint); }
.ss-option.is-selected { background: var(--teal-tint); color: var(--teal-dark); font-weight: 600; }
.ss-no-match { padding: 0.8rem; text-align: center; color: var(--ink-faint); font-size: 0.85rem; }

/* ==================== TOGGLE BUTTON GROUP ==================== */
.btn-toggle-group {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-md);
    overflow: hidden;
}
.btn-toggle {
    padding: 0.5rem 1.2rem;
    font-size: 0.88rem;
    font-weight: 500;
    border: none;
    background: var(--surface);
    color: var(--ink-faint);
    cursor: pointer;
    transition: background .15s, color .15s;
}
.btn-toggle + .btn-toggle { border-left: 1px solid var(--border-strong); }
.btn-toggle.is-active { background: var(--teal); color: #fff; }
.btn-toggle:hover:not(.is-active) { background: var(--teal-tint); color: var(--ink); }
