/* =====================================================================
   SAFIRINAMI SCHOOL — design tokens & core styles
   Palette: deep academic navy + warm brass/gold accent on a soft paper bg.
   Display face: Fraunces (serif, used sparingly for headings/brand).
   Body/UI face: Inter. Data face: JetBrains Mono for codes/figures.
   ===================================================================== */

:root {
    --navy-950: #0d1730;
    --navy-900: #101d3d;
    --navy-800: #17284d;
    --navy-700: #223762;
    --brass-500: #c1963f;
    --brass-400: #d4ac5e;
    --brass-100: #f6ecd7;
    --paper: #f5f6f8;
    --surface: #ffffff;
    --ink: #17203a;
    --ink-muted: #667085;
    --border: #e3e6ec;
    --success: #1c8a54;
    --success-bg: #e7f6ee;
    --danger: #c0392b;
    --danger-bg: #fbeae8;
    --warning: #b7791f;
    --warning-bg: #fbf1de;
    --info: #2563a8;
    --info-bg: #e8f1fb;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(16, 29, 61, 0.06);
    --shadow-md: 0 6px 20px rgba(16, 29, 61, 0.08);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-size: 14.5px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, .brand, .display {
    font-family: 'Fraunces', Georgia, serif;
    letter-spacing: -0.01em;
}

a { color: inherit; text-decoration: none; }

/* ---------- Layout shell ---------- */
.shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 248px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--navy-950), var(--navy-800));
    color: #dfe6f5;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}
.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    font-size: 19px;
    color: #fff;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar .brand .mark {
    width: 34px; height: 34px;
    border-radius: 8px;
    background: var(--brass-500);
    color: var(--navy-950);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-family: 'Fraunces', serif; font-size: 16px;
}
.sidebar .brand small { display:block; font-family:'Inter',sans-serif; font-size:10.5px; color:#93a0c2; letter-spacing:.08em; text-transform:uppercase; font-weight: 600;}

.nav-section { padding: 16px 12px; }
.nav-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: #6f7fa6; padding: 8px 12px 4px; font-weight: 600;}
.nav-link {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; border-radius: 8px;
    color: #c4cde3; font-size: 13.6px; font-weight: 500;
    margin-bottom: 2px;
    transition: background-color .15s ease, color .15s ease;
}
.nav-link:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link.active { background: var(--brass-500); color: var(--navy-950); font-weight: 600; }
.nav-link .dot { width:6px; height:6px; border-radius:50%; background: currentColor; opacity:.5; flex-shrink:0;}

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }

.sidebar-toggle-btn {
    display: none;
    align-items: center; justify-content: center;
    width: 40px; height: 40px; flex-shrink: 0;
    border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
    font-size: 18px; line-height: 1; cursor: pointer; color: var(--navy-900);
}
.sidebar-toggle-btn:hover { background: var(--paper); }

.sidebar-backdrop {
    opacity: 0; visibility: hidden;
    position: fixed; inset: 0; background: rgba(13, 23, 48, 0.55);
    z-index: 35; transition: opacity .2s ease, visibility .2s ease;
}
.sidebar-backdrop.open { opacity: 1; visibility: visible; }

.topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 28px; background: var(--surface); border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10; gap: 12px; flex-wrap: wrap;
}
.topbar h1 { font-size: 20px; margin: 0; color: var(--navy-900); }
.topbar .user-chip { display:flex; align-items:center; gap:10px; font-size:13px; }
.topbar .user-chip .avatar {
    width: 32px; height:32px; border-radius:50%; background: var(--brass-100); color: var(--brass-500);
    display:flex; align-items:center; justify-content:center; font-weight:700; font-family:'Fraunces',serif;
}
.topbar .role-badge {
    font-size: 10.5px; text-transform: uppercase; letter-spacing:.06em; font-weight:700;
    padding: 2px 8px; border-radius: 20px; background: var(--brass-100); color: var(--brass-500);
}

.content { padding: 26px 28px 60px; max-width: 1280px; width: 100%; margin: 0 auto; flex: 1 0 auto; animation: contentFadeIn .35s ease; }
@keyframes contentFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}
@media (prefers-reduced-motion: reduce) {
    * { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; }
}

/* =====================================================================
   Compact mode (Settings → User Interface): tighter density for people
   who'd rather see more rows at once than have generous whitespace.
   ===================================================================== */
html.compact-mode th { padding: 7px 10px; }
html.compact-mode td { padding: 7px 10px; }
html.compact-mode .card-body { padding: 12px 14px; }
html.compact-mode .content { padding-top: 16px; }
html.compact-mode .stat-card { padding: 12px 14px; }
html.compact-mode .form-group { margin-bottom: 10px; }

.app-footer {
    border-top: 1px solid var(--border); background: var(--surface);
    padding: 10px 28px; font-size: 12px; color: var(--ink-muted);
    display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
    position: sticky; bottom: 0; z-index: 9;
}
.app-footer a { color: var(--ink-muted); }
.app-footer a:hover { color: var(--navy-900); }

/* ---------- Cards & surfaces ---------- */
.card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 16px 20px; border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 16px; margin: 0; color: var(--navy-900); }
.card-body { padding: 20px; }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; margin-bottom: 22px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 18px 20px; box-shadow: var(--shadow-sm);
}
.stat-card .label { font-size: 11.5px; text-transform: uppercase; letter-spacing:.07em; color: var(--ink-muted); font-weight: 600; }
.stat-card .value { font-family: 'Fraunces', serif; font-size: 30px; color: var(--navy-900); margin-top: 6px; }
.stat-card .value.accent { color: var(--brass-500); }

/* ---------- Forms ---------- */
label { display:block; font-size: 12.5px; font-weight: 600; color: var(--navy-800); margin-bottom: 5px; }
.form-group { margin-bottom: 16px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 16px; }
.form-row > .form-group { min-width: 0; }
input[type=text], input[type=email], input[type=password], input[type=date], input[type=number],
input[type=tel], select, textarea {
    width: 100%; padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 13.6px; font-family: inherit; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--brass-500); box-shadow: 0 0 0 3px rgba(193,150,63,0.18);
}
textarea { resize: vertical; min-height: 90px; }
.help-text { font-size: 11.5px; color: var(--ink-muted); margin-top: 4px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 9px 16px; border-radius: 8px; border: 1px solid transparent;
    font-size: 13.4px; font-weight: 600; cursor: pointer; font-family: inherit;
    transition: background-color .15s ease, border-color .15s ease, transform .1s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--navy-900); color: #fff; }
.btn-primary:hover { background: var(--navy-800); }
.btn-gold { background: var(--brass-500); color: var(--navy-950); }
.btn-gold:hover { background: var(--brass-400); }
.btn-outline { background: transparent; border-color: var(--border); color: var(--navy-900); }
.btn-outline:hover { background: var(--paper); }
.btn-danger { background: var(--danger-bg); color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.4px; }
th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-muted); padding: 10px 14px; border-bottom: 1px solid var(--border); font-weight: 700;}
td { padding: 11px 14px; border-bottom: 1px solid var(--border); color: var(--ink); }
tbody tr:hover { background: #fafbfc; }
tbody tr { transition: background-color .12s ease; }
.table-wrap { overflow-x: auto; }

/* ---------- Badges ---------- */
.badge { display:inline-block; padding: 3px 9px; border-radius: 20px; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing:.03em;}
.badge-success { background: var(--success-bg); color: var(--success); }
.badge-danger  { background: var(--danger-bg); color: var(--danger); }
.badge-warning { background: var(--warning-bg); color: var(--warning); }
.badge-info    { background: var(--info-bg); color: var(--info); }
.badge-muted   { background: #eef0f4; color: var(--ink-muted); }

/* ---------- Alerts / flash ---------- */
.alert {
    padding: 12px 16px; border-radius: 8px; font-size: 13.4px; margin-bottom: 16px; border: 1px solid transparent;
    animation: alertIn .25s ease;
    transition: opacity .25s ease, transform .25s ease, margin .25s ease, padding .25s ease, max-height .25s ease;
    overflow: hidden;
}
.alert-hiding { opacity: 0; transform: translateY(-6px); max-height: 0; margin-bottom: 0; padding-top: 0; padding-bottom: 0; border-width: 0; }
@keyframes alertIn {
    from { opacity: 0; transform: translateY(-6px); }
    to { opacity: 1; transform: translateY(0); }
}
.alert-success { background: var(--success-bg); color: var(--success); border-color: rgba(28,138,84,.2); }
.alert-error   { background: var(--danger-bg); color: var(--danger); border-color: rgba(192,57,43,.2); }
.alert-info    { background: var(--info-bg); color: var(--info); border-color: rgba(37,99,168,.2); }
.alert-warning { background: var(--warning-bg); color: var(--warning); border-color: rgba(183,121,31,.3); }

/* ---------- Misc ---------- */
.muted { color: var(--ink-muted); }
.mono { font-family: 'JetBrains Mono', monospace; }
.flex { display:flex; align-items:center; }
.flex-wrap { flex-wrap: wrap; }
.flex-between { display:flex; align-items:center; justify-content:space-between; flex-wrap: wrap; }
.gap-8 { gap: 8px; } .gap-12 { gap:12px; } .gap-16 { gap:16px; }
.mb-16 { margin-bottom:16px; } .mb-20 { margin-bottom:20px; } .mb-24 { margin-bottom:24px; }
.text-right { text-align:right; }
.empty-state { text-align:center; padding: 48px 20px; color: var(--ink-muted); }
.empty-state .icon { font-size: 32px; margin-bottom: 10px; }

.pagination { display:flex; gap:6px; margin-top: 18px; flex-wrap: wrap; }
.pagination a, .pagination span {
    padding: 6px 11px; border-radius: 6px; border: 1px solid var(--border); font-size: 12.5px;
}
.pagination a:hover { background: var(--paper); }
.pagination .current { background: var(--navy-900); color:#fff; border-color: var(--navy-900); }

/* Login screen */
.auth-wrap {
    min-height: 100vh; display:flex; align-items:center; justify-content:center;
    background: radial-gradient(circle at 20% 20%, var(--navy-800), var(--navy-950) 65%);
    padding: 20px;
}
.auth-card {
    width: 100%; max-width: 380px; background: var(--surface); border-radius: 14px;
    padding: 34px 32px; box-shadow: var(--shadow-md);
}
.auth-card .mark {
    width: 46px; height:46px; border-radius:10px; background: var(--brass-500); color: var(--navy-950);
    display:flex; align-items:center; justify-content:center; font-family:'Fraunces',serif; font-weight:700; font-size:20px;
    margin-bottom: 16px;
}
.auth-card h1 { font-size: 22px; margin: 0 0 4px; color: var(--navy-900); }
.auth-card p.sub { color: var(--ink-muted); margin: 0 0 22px; font-size: 13px; }

@media print {
    .no-print { display: none !important; }
}

/* =====================================================================
   Receipts: standard A4 vs 57mm/80mm thermal printer formats.
   Paper size itself is set via a JS-injected @page rule (see
   layouts/print.php) since @page can't be scoped by a body class in CSS -
   these rules only handle the visual reflow of the receipt content.
   ===================================================================== */
.receipt-doc { max-width: 600px; margin: 0 auto; }
.receipt-header { text-align: center; margin-bottom: 24px; }
.receipt-brand { font-family: 'Fraunces', serif; font-size: 24px; font-weight: 700; color: var(--navy-950); }
.receipt-logo { max-height: 48px; margin-bottom: 8px; }
.receipt-row {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin-bottom: 14px;
}
.receipt-row .receipt-label { color: var(--ink-muted); }
.receipt-row .receipt-value { font-weight: 700; text-align: right; }
.receipt-total {
    display: flex; align-items: baseline; justify-content: space-between;
    border-top: 1px dashed var(--border); padding-top: 14px; margin-top: 4px;
}
.receipt-total .receipt-total-label { font-size: 18px; }
.receipt-total .receipt-total-value { font-size: 22px; font-weight: 700; color: var(--brass-500); }
.receipt-footer-note { text-align: center; margin-top: 20px; color: var(--ink-muted); }

body.print-80mm .receipt-doc,
body.print-57mm .receipt-doc {
    max-width: none; width: 100%; font-size: 11px;
}
body.print-80mm .receipt-brand { font-size: 15px; }
body.print-57mm .receipt-brand { font-size: 13px; }
body.print-80mm .receipt-row .receipt-value,
body.print-57mm .receipt-row .receipt-value { font-size: 11px; }
body.print-80mm .receipt-total .receipt-total-value { font-size: 15px; }
body.print-57mm .receipt-total .receipt-total-value { font-size: 13px; }

/* At 57mm even a short label + value pair can be tight side-by-side; stack them instead. */
body.print-57mm .receipt-row {
    flex-direction: column; align-items: flex-start; gap: 2px; margin-bottom: 10px;
}
body.print-57mm .receipt-row .receipt-value { text-align: left; }
body.print-57mm .receipt-total { flex-direction: column; gap: 2px; }

@media print {
    body.print-80mm, body.print-57mm { padding: 0; }
    body.print-80mm .receipt-doc, body.print-57mm .receipt-doc { padding: 2mm; }
    body.print-80mm .card, body.print-57mm .card { border: none; box-shadow: none; }
    body.print-80mm .card-body, body.print-57mm .card-body { padding: 0; }
}

/* =====================================================================
   Responsive: tablet + mobile share an off-canvas sidebar behind a
   hamburger toggle; desktop (>1024px) keeps the sidebar always visible.
   Grid-based components (.stat-grid, .form-row, .feature-grid, .role-grid)
   already reflow automatically via `repeat(auto-fit, minmax(...))` and
   need no extra breakpoints of their own.
   ===================================================================== */
@media (max-width: 1024px) {
    .sidebar-toggle-btn { display: inline-flex; }

    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: 40;
    }
    .sidebar.open { transform: translateX(0); }

    .content { padding: 18px; }
    .topbar { padding: 12px 16px; }
    .app-footer { padding: 12px 16px; }

    /* Keep the topbar compact on narrower screens: show only the avatar + role badge. */
    .user-chip .user-name { display: none; }
}

@media (max-width: 480px) {
    .stat-card .value { font-size: 24px; }
    .hero-title { font-size: 26px; }
}

/* =====================================================================
   Landing / marketing page
   ===================================================================== */
.landing-body { background: var(--paper); }

.landing-nav {
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 32px; background: var(--navy-950); flex-wrap: wrap; gap: 12px;
}
.landing-brand {
    display: flex; align-items: center; gap: 10px; color: #fff;
    font-family: 'Fraunces', serif; font-size: 18px;
}
.landing-brand .mark {
    width: 32px; height: 32px; border-radius: 8px; background: var(--brass-500); color: var(--navy-950);
    display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 15px;
}
.landing-brand small { display: block; font-family: 'Inter', sans-serif; font-size: 10px; color: #93a0c2; letter-spacing: .08em; text-transform: uppercase; font-weight: 600; }
.landing-nav-outline { border-color: rgba(255,255,255,0.35); color: #fff; }
.landing-nav-outline:hover { background: rgba(255,255,255,0.08); }

.btn-lg { padding: 12px 22px; font-size: 14.5px; border-radius: 10px; }

.hero {
    background: radial-gradient(circle at 15% 0%, var(--navy-800), var(--navy-950) 70%);
    color: #fff; padding: 88px 32px 100px; text-align: center;
}
.hero-inner { max-width: 720px; margin: 0 auto; }
.hero-eyebrow {
    display: inline-block; font-size: 11.5px; text-transform: uppercase; letter-spacing: .1em;
    color: var(--brass-400); font-weight: 700; margin-bottom: 18px;
}
.hero-title { font-size: 42px; line-height: 1.15; margin: 0 0 18px; color: #fff; }
.hero-sub { font-size: 16px; color: #c4cde3; line-height: 1.7; margin: 0 0 34px; }
.hero-actions { display: flex; gap: 14px; justify-content: center; flex-wrap: wrap; }

.landing-section { padding: 72px 32px; }
.landing-section-inner { max-width: 1080px; margin: 0 auto; }
.landing-roles { background: #fff; border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }

.section-title { font-size: 26px; text-align: center; color: var(--navy-900); margin: 0 0 40px; }

.feature-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 20px; }
.feature-card {
    background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 22px;
    box-shadow: var(--shadow-sm); transition: transform .2s ease, box-shadow .2s ease;
}
.feature-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-md); }
.feature-icon { font-size: 26px; margin-bottom: 10px; }
.feature-card h3 { margin: 0 0 8px; font-size: 16px; color: var(--navy-900); font-family: 'Fraunces', serif; }
.feature-card p { margin: 0; font-size: 13px; color: var(--ink-muted); line-height: 1.6; }

.role-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 14px; }
.role-pill {
    background: var(--paper); border: 1px solid var(--border); border-radius: 10px;
    padding: 16px; text-align: center;
}
.role-pill strong { display: block; font-family: 'Fraunces', serif; color: var(--navy-900); font-size: 15px; margin-bottom: 4px; }
.role-pill span { font-size: 12px; color: var(--ink-muted); }

.landing-footer {
    text-align: center; padding: 26px; font-size: 12.5px; color: var(--ink-muted);
    border-top: 1px solid var(--border); background: #fff;
}

@media (max-width: 640px) {
    .hero { padding: 60px 20px 70px; }
    .hero-title { font-size: 30px; }
    .landing-nav { padding: 14px 18px; }
}

/* =====================================================================
   Dark mode (theme_mode = 'dark', or 'auto' + OS prefers dark)
   Overrides the surface/text/border tokens; brand colors (navy/brass
   variables) are already injected inline per-request and stay as-is.
   ===================================================================== */
html[data-theme="dark"] {
    --paper: #0a0f1e;
    --surface: #121a2e;
    --ink: #e7ebf5;
    --ink-muted: #8f9bc0;
    --border: #263252;
    --success-bg: rgba(28, 138, 84, 0.16);
    --danger-bg: rgba(192, 57, 43, 0.18);
    --warning-bg: rgba(183, 121, 31, 0.18);
    --info-bg: rgba(37, 99, 168, 0.2);
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --paper: #0a0f1e;
        --surface: #121a2e;
        --ink: #e7ebf5;
        --ink-muted: #8f9bc0;
        --border: #263252;
        --success-bg: rgba(28, 138, 84, 0.16);
        --danger-bg: rgba(192, 57, 43, 0.18);
        --warning-bg: rgba(183, 121, 31, 0.18);
        --info-bg: rgba(37, 99, 168, 0.2);
    }
}
html[data-theme="dark"] input[type=text], html[data-theme="dark"] input[type=email],
html[data-theme="dark"] input[type=password], html[data-theme="dark"] input[type=date],
html[data-theme="dark"] input[type=number], html[data-theme="dark"] input[type=tel],
html[data-theme="dark"] select, html[data-theme="dark"] textarea { background: #0e1526; color: var(--ink); }
html[data-theme="dark"] tbody tr:hover { background: rgba(255,255,255,0.03); }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] input[type=text], html[data-theme="auto"] input[type=email],
    html[data-theme="auto"] input[type=password], html[data-theme="auto"] input[type=date],
    html[data-theme="auto"] input[type=number], html[data-theme="auto"] input[type=tel],
    html[data-theme="auto"] select, html[data-theme="auto"] textarea { background: #0e1526; color: var(--ink); }
    html[data-theme="auto"] tbody tr:hover { background: rgba(255,255,255,0.03); }
}

/* =====================================================================
   Settings pages (Branding / User Interface)
   ===================================================================== */
.settings-tabs {
    display: flex; gap: 6px; margin-bottom: 20px; border-bottom: 1px solid var(--border);
    overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.settings-tabs::-webkit-scrollbar { display: none; }
.settings-tab {
    padding: 10px 16px; font-size: 13.4px; font-weight: 600; color: var(--ink-muted);
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    white-space: nowrap; flex-shrink: 0;
    transition: color .15s ease, border-color .15s ease;
}
.settings-tab.active { color: var(--navy-900); border-bottom-color: var(--brass-500); }
.settings-tab:hover { color: var(--navy-900); }

@media (max-width: 480px) {
    .settings-tab { padding: 9px 12px; font-size: 12.8px; }
}

.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] { width: 44px; height: 38px; padding: 2px; border-radius: 8px; cursor: pointer; }
.color-field input[type=text] { max-width: 120px; font-family: 'JetBrains Mono', monospace; }

.logo-preview {
    display: flex; align-items: center; gap: 14px; padding: 14px; border: 1px dashed var(--border);
    border-radius: 10px; margin-bottom: 12px; background: var(--paper);
}
.logo-preview img { width: 56px; height: 56px; border-radius: 10px; object-fit: cover; border: 1px solid var(--border); background: #fff; }
.logo-preview .placeholder {
    width: 56px; height: 56px; border-radius: 10px; background: var(--brass-100); color: var(--brass-500);
    display: flex; align-items: center; justify-content: center; font-family: 'Fraunces', serif; font-weight: 700;
}

.toggle-row {
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 14px 0; border-bottom: 1px solid var(--border);
}
.toggle-row:last-child { border-bottom: none; }
.toggle-row .toggle-copy { min-width: 0; }
.toggle-row .toggle-copy strong { display: block; font-size: 13.6px; color: var(--navy-900); }
.toggle-row .toggle-copy span { font-size: 12px; color: var(--ink-muted); }
.switch { position: relative; display: inline-block; width: 42px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; cursor: pointer; inset: 0; background: var(--border); border-radius: 24px; transition: .15s;
}
.switch .slider::before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; bottom: 3px;
    background: #fff; border-radius: 50%; transition: .15s;
}
.switch input:checked + .slider { background: var(--brass-500); }
.switch input:checked + .slider::before { transform: translateX(18px); }

/* ---- Branding: homepage template picker ---- */
.tpl-grid { display:grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap:12px; margin-bottom:16px; }
.tpl-card { position:relative; display:flex; flex-direction:column; gap:4px; padding:16px 16px 14px 44px; border:1.5px solid var(--border); border-radius:12px; cursor:pointer; background:var(--surface); transition:border-color .15s, box-shadow .15s; font-weight:400; }
.tpl-card:hover { border-color: var(--brass-500); }
.tpl-card.is-selected, .tpl-card:has(input:checked) { border-color: var(--brass-500); box-shadow: 0 0 0 3px color-mix(in srgb, var(--brass-500) 22%, transparent); }
.tpl-card input { position:absolute; left:16px; top:18px; width:auto; accent-color: var(--brass-500); }
.tpl-title { font-weight:700; font-size:14.5px; }
.tpl-desc { font-size:12.5px; color:var(--ink-muted); line-height:1.5; }
.tpl-preview { font-size:12.5px; font-weight:600; margin-top:6px; color:var(--brass-500); }
.tpl-content { border:1px solid var(--border); border-radius:12px; padding:14px 16px; }
.tpl-content > summary { cursor:pointer; font-weight:600; font-size:14px; }

/* ---- Accounting module ---- */
.num { text-align:right; font-variant-numeric: tabular-nums; white-space:nowrap; }
.neg { color: var(--danger); }
.pos { color: var(--success); }
.acc-grid-2 { display:grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap:20px; margin-bottom:24px; }
.filter-bar { display:flex; gap:12px; flex-wrap:wrap; align-items:end; margin-bottom:18px; }
.filter-bar .form-group { margin:0; min-width:140px; }
.acc-toolbar { display:flex; gap:8px; flex-wrap:wrap; align-items:center; justify-content:space-between; margin-bottom:16px; }
.acc-total-row td { font-weight:700; border-top:2px solid var(--border); background: var(--paper); }
.acc-section-row td { font-weight:700; text-transform:uppercase; font-size:11.5px; letter-spacing:.06em; color:var(--ink-muted); background: var(--paper); }
.progress { height:8px; background: var(--paper); border-radius:99px; overflow:hidden; min-width:90px; border:1px solid var(--border); }
.progress > span { display:block; height:100%; background: var(--success); }
.progress.warn > span { background: var(--warning); }
.progress.over > span { background: var(--danger); }
.bars { display:flex; align-items:flex-end; gap:14px; height:180px; padding-top:10px; }
.bars .col { flex:1; display:flex; flex-direction:column; align-items:center; gap:6px; height:100%; justify-content:flex-end; min-width:0; }
.bars .pair { display:flex; align-items:flex-end; gap:4px; height:100%; width:100%; justify-content:center; }
.bars .bar { width:42%; max-width:28px; border-radius:5px 5px 0 0; min-height:2px; }
.bars .bar.inc { background: var(--success); } .bars .bar.exp { background: var(--brass-500); }
.bars .lbl { font-size:11px; color: var(--ink-muted); }
.legend { display:flex; gap:16px; font-size:12px; color:var(--ink-muted); margin-top:10px; flex-wrap:wrap; }
.legend i { display:inline-block; width:10px; height:10px; border-radius:3px; margin-right:6px; vertical-align:middle; }
.donut-wrap { display:flex; gap:22px; align-items:center; flex-wrap:wrap; }
.donut { width:150px; height:150px; border-radius:50%; flex-shrink:0; position:relative; }
.donut::after { content:''; position:absolute; inset:28px; background: var(--surface); border-radius:50%; }
.jl-table input, .jl-table select { width:100%; }
.status-dot { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:6px; }
.kv { display:grid; grid-template-columns: 170px 1fr; gap:8px 16px; font-size:14px; }
.kv dt { color: var(--ink-muted); } .kv dd { margin:0; }
@media print { .settings-tabs, .no-print, .sidebar, .topbar { display:none !important; } }
.acc-stats .stat-card .value { font-size: 22px; white-space: nowrap; }

/* Inventory item-row forms: on phones each row becomes a labelled card instead of a squeezed table row. */
@media (max-width: 700px) {
    [data-lines] table, [data-lines] tbody, [data-lines] tfoot, [data-lines] tr, [data-lines] td { display: block; width: auto !important; }
    [data-lines] thead { display: none; }
    [data-lines] tbody tr { position: relative; padding: 12px 16px 14px; border-bottom: 1px solid var(--border); }
    [data-lines] tbody td { padding: 5px 0; border: 0; text-align: left; }
    [data-lines] tbody td[data-label]::before { content: attr(data-label); display: block; font-size: 11px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-muted); margin-bottom: 3px; }
    [data-lines] tbody td select, [data-lines] tbody td input { width: 100%; }
    [data-lines] tbody td:last-child { position: absolute; top: 8px; right: 10px; padding: 0; }
    [data-lines] tfoot tr { display: flex; justify-content: space-between; padding: 12px 16px; }
    [data-lines] tfoot td { padding: 0; border: 0; }
}

/* Library uploader */
.upload-drop { border: 2px dashed var(--border); border-radius: 12px; padding: 22px; text-align: center; background: var(--paper); transition: border-color .15s, background-color .15s; }
.upload-drop.over { border-color: var(--brass-500); background: var(--brass-100); }
.upload-drop input[type=file] { display: block; margin: 10px auto 0; max-width: 100%; }
.upload-row { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 8px 0; }
.upload-row .upload-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13.5px; }
.upload-row.err .progress span { background: var(--danger); } .upload-row.err small { color: var(--danger); }
.upload-row.ok .progress span { background: var(--success); }
@media (max-width: 600px) { .upload-row { grid-template-columns: 1fr; gap: 4px; } }
