/* -------------------------------------------------------
   The Fiscal Panic Room — Minimal stylesheet
   Left Right Minds
   Themes: void (default), night, slate, paper, sand, panel
------------------------------------------------------- */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* -------------------------------------------------------
   THEME: Void (default) — pure dark, indigo accent
------------------------------------------------------- */
:root {
    --bg:          #08090d;
    --surface:     #0f1014;
    --surface-2:   #17181e;
    --border:      rgba(255,255,255,0.16);
    --border-hover:rgba(255,255,255,0.26);
    --text:        #e8e9f0;
    --text-muted:  #6b6e7e;
    --accent:      #818cf8;
    --accent-hover:#a5b4fc;
    --accent-dim:  rgba(129,140,248,0.12);
    --success:     #4ade80;
    --success-dim: rgba(74,222,128,0.10);
    --warning:     #fbbf24;
    --warning-dim: rgba(251,191,36,0.10);
    --danger:      #f87171;
    --danger-dim:  rgba(248,113,113,0.10);
    --sidebar-w:   240px;
    --radius:      6px;
    --font:        'Roboto', system-ui, sans-serif;
    --font-mono:   'Roboto Mono', monospace;
    --card-shadow: 0 1px 2px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.24);
}

/* -------------------------------------------------------
   THEME: Night — warm dark, blue accent (original refined)
------------------------------------------------------- */
[data-theme="night"] {
    --bg:          #111318;
    --surface:     #1a1d27;
    --surface-2:   #22263a;
    --border:      rgba(255,255,255,0.16);
    --border-hover:rgba(255,255,255,0.26);
    --text:        #e2e5f0;
    --text-muted:  #6b7280;
    --accent:      #9ecaff;
    --accent-hover:#bcd9ff;
    --accent-dim:  rgba(158,202,255,0.10);
    --success:     #6dd58c;
    --success-dim: rgba(109,213,140,0.10);
    --warning:     #ffb940;
    --warning-dim: rgba(255,185,64,0.10);
    --danger:      #ff8a80;
    --danger-dim:  rgba(255,138,128,0.10);
    --card-shadow: 0 1px 2px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.24);
}

/* -------------------------------------------------------
   THEME: Slate — GitHub dark, blue accent
------------------------------------------------------- */
[data-theme="slate"] {
    --bg:          #0d1117;
    --surface:     #161b22;
    --surface-2:   #21262d;
    --border:      rgba(255,255,255,0.18);
    --border-hover:rgba(255,255,255,0.28);
    --text:        #e6edf3;
    --text-muted:  #7d8590;
    --accent:      #58a6ff;
    --accent-hover:#79c0ff;
    --accent-dim:  rgba(88,166,255,0.10);
    --success:     #3fb950;
    --success-dim: rgba(63,185,80,0.10);
    --warning:     #d29922;
    --warning-dim: rgba(210,153,34,0.10);
    --danger:      #f85149;
    --danger-dim:  rgba(248,81,73,0.10);
    --card-shadow: 0 1px 2px rgba(0,0,0,0.30), 0 2px 8px rgba(0,0,0,0.24);
}

/* -------------------------------------------------------
   THEME: Paper — white minimal, ink blue accent
------------------------------------------------------- */
[data-theme="paper"] {
    --bg:          #f7f7f8;
    --surface:     #ffffff;
    --surface-2:   #f0f0f2;
    --border:      rgba(0,0,0,0.16);
    --border-hover:rgba(0,0,0,0.28);
    --text:        #111114;
    --text-muted:  #6b7280;
    --accent:      #3b5bdb;
    --accent-hover:#2f4ac4;
    --accent-dim:  rgba(59,91,219,0.08);
    --success:     #2f9e44;
    --success-dim: rgba(47,158,68,0.08);
    --warning:     #e67700;
    --warning-dim: rgba(230,119,0,0.08);
    --danger:      #e03131;
    --danger-dim:  rgba(224,49,49,0.08);
    --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.05);
}

/* -------------------------------------------------------
   THEME: Sand — warm off-white, amber accent
------------------------------------------------------- */
[data-theme="sand"] {
    --bg:          #f5f0ea;
    --surface:     #faf7f3;
    --surface-2:   #ede9e2;
    --border:      rgba(0,0,0,0.15);
    --border-hover:rgba(0,0,0,0.26);
    --text:        #1c1710;
    --text-muted:  #7a7060;
    --accent:      #c2410c;
    --accent-hover:#9a3309;
    --accent-dim:  rgba(194,65,12,0.08);
    --success:     #15803d;
    --success-dim: rgba(21,128,61,0.08);
    --warning:     #b45309;
    --warning-dim: rgba(180,83,9,0.08);
    --danger:      #be123c;
    --danger-dim:  rgba(190,18,60,0.08);
    --card-shadow: 0 1px 3px rgba(28,23,16,0.10), 0 2px 6px rgba(28,23,16,0.06);
}

/* -------------------------------------------------------
   THEME: Panel — dark sidebar + light body (Enhance-style)
------------------------------------------------------- */
[data-theme="panel"] {
    /* Main area — light */
    --bg:          #f0f1f3;
    --surface:     #ffffff;
    --surface-2:   #f5f6f8;
    --border:      rgba(0,0,0,0.13);
    --border-hover:rgba(0,0,0,0.24);
    --text:        #111114;
    --text-muted:  #6b7280;
    --accent:      #4f46e5;
    --accent-hover:#4338ca;
    --accent-dim:  rgba(79,70,229,0.08);
    --success:     #16a34a;
    --success-dim: rgba(22,163,74,0.08);
    --warning:     #d97706;
    --warning-dim: rgba(217,119,6,0.08);
    --danger:      #dc2626;
    --danger-dim:  rgba(220,38,38,0.08);

    /* Dark sidebar overrides */
    --sidebar-bg:         #1c1c1e;
    --sidebar-border:     rgba(255,255,255,0.05);
    --sidebar-nav-text:   rgba(255,255,255,0.50);
    --sidebar-nav-hover:  rgba(255,255,255,0.88);
    --sidebar-nav-active: #ffffff;
    --sidebar-active-bg:  rgba(255,255,255,0.08);
    --sidebar-logo:       #ffffff;
    --sidebar-sub:        rgba(255,255,255,0.35);
    --sidebar-footer-text:rgba(255,255,255,0.40);

    --card-shadow: 0 1px 3px rgba(0,0,0,0.09), 0 2px 6px rgba(0,0,0,0.06);
}

/* -------------------------------------------------------
   Font size scale (applied to <html> via JS)
------------------------------------------------------- */
html                { font-size: 14px; }
html.fs-sm          { font-size: 13px; }
html.fs-md          { font-size: 15px; }
html.fs-lg          { font-size: 16px; }

/* Font family overrides (applied to <html> via JS) */
html.font-system    { --font: system-ui, -apple-system, sans-serif; }
html.font-inter     { --font: 'Inter', system-ui, sans-serif; }
html.font-roboto    { --font: 'Roboto', system-ui, sans-serif; }
html.font-geist     { --font: 'Geist', system-ui, sans-serif; }

/* -------------------------------------------------------
   Base
------------------------------------------------------- */
body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    font-size: 1rem;
    line-height: 1.6;
}

body.app-layout {
    display: flex;
}

/* -------------------------------------------------------
   Sidebar
------------------------------------------------------- */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg, var(--surface));
    border-right: 1px solid var(--sidebar-border, var(--border));
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    transition: width 0.15s ease;
}

.sidebar-logo {
    padding: 24px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border, var(--border));
    margin-bottom: 6px;
    overflow: hidden;
}

/* Let the heading wrap instead of truncating — better to show the full
   company name on two lines than to cut it off with an ellipsis. */
.sidebar-logo .nav-label {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    line-height: 1.25;
}

/* Collapsed-sidebar stand-in for the heading text — first letter of
   whichever name is showing, so there's still some hint of which company
   even with the label hidden. */
.logo-initial {
    display: none;
    width: 32px;
    height: 32px;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
    background: var(--accent-dim);
    color: var(--accent);
    font-size: 15px;
    font-weight: 700;
    margin: 0 auto;
}

html.sidebar-collapsed .logo-initial { display: flex; }

.logo-text {
    display: block;
    /* Fixed px, not rem — the Small/Medium/Large font-size preference is for
       content readability; the sidebar heading shouldn't grow with it and
       start overflowing a fixed-width sidebar. */
    font-size: 16px;
    font-weight: 700;
    color: var(--sidebar-logo, var(--text));
    letter-spacing: -0.2px;
}

.logo-sub {
    display: block;
    font-size: 11px;
    color: var(--sidebar-sub, var(--text-muted));
    margin-top: 1px;
    font-weight: 400;
}

.nav-links {
    list-style: none;
    flex: 1;
    padding: 6px 10px;
}

.nav-links li { margin-bottom: 1px; }

.nav-links li a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-nav-text, var(--text-muted));
    text-decoration: none;
    font-size: 0.93rem;
    font-weight: 500;
    transition: background 0.1s, color 0.1s;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-label {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.nav-links li a:hover {
    background: var(--sidebar-active-bg, var(--surface-2));
    color: var(--sidebar-nav-hover, var(--text));
}

.nav-links li a.active {
    background: var(--sidebar-active-bg, var(--accent-dim));
    color: var(--sidebar-nav-active, var(--accent));
}

.sidebar-footer {
    padding: 14px 20px 18px;
    border-top: 1px solid var(--sidebar-border, var(--border));
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: none;
    border: 1px solid var(--sidebar-border, var(--border));
    border-radius: var(--radius);
    color: var(--sidebar-footer-text, var(--text-muted));
    cursor: pointer;
    padding: 0;
    transition: color 0.1s, border-color 0.1s;
}
.sidebar-toggle:hover {
    color: var(--sidebar-nav-hover, var(--text));
    border-color: var(--border-hover);
}
.sidebar-toggle .nav-icon {
    width: 15px;
    height: 15px;
    transition: transform 0.15s ease;
}

.sidebar-company {
    display: block;
    font-size: 0.79rem;
    color: var(--sidebar-footer-text, var(--text-muted));
}

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--sidebar-footer-text, var(--text-muted));
    text-decoration: none;
    font-size: 0.86rem;
}
.sidebar-footer a:hover { color: var(--sidebar-nav-hover, var(--text)); }

/* -------------------------------------------------------
   Sidebar collapse
------------------------------------------------------- */
html.sidebar-collapsed .sidebar { width: 64px; }
html.sidebar-collapsed .main-content { margin-left: 64px; }
html.sidebar-collapsed .nav-label { display: none; }
html.sidebar-collapsed .nav-links li a { justify-content: center; padding: 7px; }
html.sidebar-collapsed .sidebar-logo { text-align: center; padding-left: 10px; padding-right: 10px; }
html.sidebar-collapsed .sidebar-footer { align-items: center; }
html.sidebar-collapsed .sidebar-footer a { justify-content: center; }
html.sidebar-collapsed .sidebar-toggle .nav-icon { transform: rotate(180deg); }

/* Theme swatches */
.theme-swatches {
    display: flex;
    gap: 6px;
    align-items: center;
    margin-bottom: 8px;
}

.theme-swatch {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 2px solid transparent;
    cursor: pointer;
    transition: transform 0.1s, border-color 0.1s;
    padding: 0;
    outline: none;
}

.theme-swatch:hover { transform: scale(1.2); }

.theme-swatch.active {
    border-color: var(--sidebar-nav-text, var(--text-muted));
}

/* Font size controls */
.font-size-controls {
    display: flex;
    gap: 2px;
    margin-bottom: 6px;
}

.fs-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-footer-text, var(--text-muted));
    font-family: var(--font);
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1.4;
    transition: color 0.1s, background 0.1s;
}
.fs-btn:nth-child(1) { font-size: 11px; }
.fs-btn:nth-child(2) { font-size: 13px; }
.fs-btn:nth-child(3) { font-size: 15px; }

.fs-btn:hover,
.fs-btn.active {
    color: var(--sidebar-nav-hover, var(--text));
    background: var(--sidebar-active-bg, var(--surface-2));
}

/* Font family controls */
.font-family-controls {
    display: flex;
    gap: 3px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ff-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--sidebar-footer-text, var(--text-muted));
    font-size: 11px;
    font-weight: 600;
    padding: 2px 5px;
    border-radius: 3px;
    line-height: 1.4;
    transition: color 0.1s, background 0.1s;
}

.ff-btn:hover,
.ff-btn.active {
    color: var(--sidebar-nav-hover, var(--text));
    background: var(--sidebar-active-bg, var(--surface-2));
}

.ff-btn[data-font="system"] { font-family: system-ui, -apple-system, sans-serif; }
.ff-btn[data-font="inter"]  { font-family: 'Inter', sans-serif; }
.ff-btn[data-font="roboto"] { font-family: 'Roboto', sans-serif; }
.ff-btn[data-font="geist"]  { font-family: 'Geist', sans-serif; }

/* -------------------------------------------------------
   Main content
------------------------------------------------------- */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.15s ease;
}

.page-header {
    padding: 28px 32px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.page-header h1 {
    font-size: 1.43rem;
    font-weight: 600;
    letter-spacing: -0.3px;
    color: var(--text);
}

.page-body { padding: 20px 32px 48px; }

/* -------------------------------------------------------
   Cards
------------------------------------------------------- */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 16px;
    border: 1px solid var(--border);
    box-shadow: var(--card-shadow, none);
}

.card-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.86rem;
    font-weight: 500;
    text-transform: none;
    letter-spacing: 0;
    color: var(--text-muted);
    cursor: pointer;
    margin-bottom: 0;
}

.card-title {
    font-size: 0.79rem;
    font-weight: 600;
    letter-spacing: 0.4px;
    color: var(--text-muted);
    margin-bottom: 14px;
    text-transform: uppercase;
}

/* -------------------------------------------------------
   Stats grid
------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--card-shadow, none);
}

.stat-label {
    font-size: 0.79rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1;
    letter-spacing: -0.5px;
}

.stat-value.accent  { color: var(--accent); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }

/* -------------------------------------------------------
   Tables
------------------------------------------------------- */
.table-wrap { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; font-size: 1rem; }

thead th {
    text-align: left;
    padding: 8px 14px;
    font-size: 0.79rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
}

tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.08s;
}
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
tbody td { padding: 11px 14px; }

th.sortable-col {
    cursor: pointer;
    user-select: none;
}
th.sortable-col:hover { color: var(--text); }
th.sortable-col::after {
    content: '\2195';
    display: inline-block;
    margin-left: 5px;
    opacity: 0.4;
}
th.sortable-col[data-sort-dir="asc"]::after { content: '\2191'; opacity: 1; }
th.sortable-col[data-sort-dir="desc"]::after { content: '\2193'; opacity: 1; }

/* -------------------------------------------------------
   Badges
------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.79rem;
    font-weight: 500;
    letter-spacing: 0.2px;
}

.badge-open     { background: var(--accent-dim);   color: var(--accent); }
.badge-progress { background: var(--warning-dim);  color: var(--warning); }
.badge-resolved { background: var(--success-dim);  color: var(--success); }
.badge-closed   { background: var(--surface-2);    color: var(--text-muted); }
.badge-urgent   { background: var(--danger-dim);   color: var(--danger); }

/* -------------------------------------------------------
   Buttons
------------------------------------------------------- */
.btn {
    display: inline-block;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: 0.93rem;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    text-decoration: none;
    text-align: center;
    transition: background 0.1s, opacity 0.1s, border-color 0.1s, box-shadow 0.1s;
    font-family: var(--font);
    line-height: 1.4;
    letter-spacing: 0;
}

.btn-primary {
    background: var(--accent);
    color: var(--bg);
    box-shadow: inset 0 -1px 0 rgba(0,0,0,0.16);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
    border-color: var(--border);
}
.btn-ghost:hover {
    border-color: var(--border-hover);
    color: var(--text);
}

.btn-danger {
    background: var(--danger-dim);
    color: var(--danger);
    border-color: var(--danger-dim);
}
.btn-danger:hover { border-color: var(--danger); }

.btn-sm { padding: 5px 12px; font-size: 0.86rem; }

/* -------------------------------------------------------
   Forms
------------------------------------------------------- */
.form-group { margin-bottom: 16px; }

label {
    display: block;
    font-size: 0.79rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin-bottom: 5px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    padding: 8px 12px;
    font-size: 1rem;
    font-family: var(--font);
    outline: none;
    transition: border-color 0.1s, background 0.1s;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--accent);
    background: var(--surface);
    box-shadow: 0 0 0 3px var(--accent-dim);
}

input:hover:not(:focus),
select:hover:not(:focus),
textarea:hover:not(:focus) {
    border-color: var(--border-hover);
}

textarea { resize: vertical; min-height: 80px; }
select option { background: var(--surface); }

/* -------------------------------------------------------
   Searchable dropdowns (Tom Select) — themed to match the rest of the
   form controls above rather than the library's own default look.
------------------------------------------------------- */
.ts-wrapper {
    font-family: var(--font);
    font-size: 1rem;
    min-width: 160px;
    position: relative;
}

.ts-control {
    background: var(--surface-2) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    color: var(--text) !important;
    padding: 8px 30px 8px 12px !important;
    box-shadow: none !important;
}

/* Tom Select ships with no dropdown indicator at all (unlike a native
   <select>), so every enhanced dropdown looked like plain clickable text
   with no visual cue — draw one with a CSS-only triangle. */
.ts-wrapper::after {
    content: "";
    position: absolute;
    top: 50%;
    right: 12px;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    border-top: 5px solid var(--text-muted);
    transform: translateY(-50%);
    pointer-events: none;
}

.ts-wrapper:hover .ts-control { border-color: var(--border-hover) !important; }

.ts-wrapper.focus .ts-control {
    border-color: var(--accent) !important;
    background: var(--surface) !important;
    box-shadow: 0 0 0 3px var(--accent-dim) !important;
}

.ts-control input { color: var(--text) !important; }
.ts-control .item { color: var(--text); }

.ts-dropdown {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--card-shadow) !important;
    font-family: var(--font);
    margin-top: 4px !important;
}

.ts-dropdown .dropdown-input {
    background: var(--surface-2) !important;
    border-bottom: 1px solid var(--border) !important;
    color: var(--text) !important;
}

.ts-dropdown .option {
    color: var(--text) !important;
    padding: 8px 12px !important;
}

.ts-dropdown .option.active {
    background: var(--accent-dim) !important;
    color: var(--accent) !important;
}

.ts-dropdown .no-results,
.ts-dropdown .optgroup-header {
    color: var(--text-muted) !important;
    padding: 8px 12px !important;
}

.ts-dropdown .highlight {
    background: var(--accent-dim);
    color: var(--accent);
    border-radius: 2px;
}

/* -------------------------------------------------------
   Flash messages
------------------------------------------------------- */
.flash {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 16px;
    font-size: 0.93rem;
    border: 1px solid transparent;
}

.flash--success { background: var(--success-dim); color: var(--success); border-color: var(--success-dim); }
.flash--error   { background: var(--danger-dim);  color: var(--danger);  border-color: var(--danger-dim); }
.flash--info    { background: var(--accent-dim);  color: var(--accent);  border-color: var(--accent-dim); }

/* -------------------------------------------------------
   Login
------------------------------------------------------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--card-shadow);
}

.login-box h1 {
    font-size: 1.43rem;
    font-weight: 600;
    margin-bottom: 4px;
    letter-spacing: -0.2px;
}

.login-box p {
    color: var(--text-muted);
    font-size: 0.93rem;
    margin-bottom: 24px;
}

/* -------------------------------------------------------
   Code
------------------------------------------------------- */
code {
    font-family: var(--font-mono);
    font-size: 0.86rem;
    background: var(--surface-2);
    padding: 2px 5px;
    border-radius: 3px;
    color: var(--accent);
}

/* -------------------------------------------------------
   Appearance selector (settings page)
------------------------------------------------------- */
.appear-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.appear-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: none;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    padding: 0 0 10px;
    cursor: pointer;
    font-family: var(--font);
    transition: border-color 0.15s;
    width: 90px;
    overflow: hidden;
}

.appear-opt:hover {
    border-color: var(--border-hover);
}

.appear-opt.active {
    border-color: var(--accent);
}

.appear-preview {
    width: 100%;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0 0;
    position: relative;
    overflow: hidden;
}

/* Accent dot for theme previews */
.appear-preview span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: block;
}

.appear-label {
    font-size: 0.79rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: center;
    padding: 0 6px;
    white-space: nowrap;
}

.appear-opt.active .appear-label {
    color: var(--accent);
}

/* -------------------------------------------------------
   Inline links (main content only — sidebar has its own look)
   Uses the theme's own accent colors, so this adapts automatically
   across all six Appearance options with no extra config.
------------------------------------------------------- */
.page-body a:not(.btn) {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.1s;
}

.page-body a:not(.btn):hover {
    color: var(--accent-hover);
    text-decoration: underline;
}

/* -------------------------------------------------------
   Utilities
------------------------------------------------------- */
.flex         { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.mt-16        { margin-top: 16px; }
.mt-24        { margin-top: 24px; }
.text-muted   { color: var(--text-muted); }
.text-right   { text-align: right; }
.text-sm      { font-size: 0.86rem; }
.w-full       { width: 100%; }

/* -------------------------------------------------------
   Responsive
   Standing rule: every page in this app must work down to phone
   width, not just desktop. This is the shared foundation (sidebar +
   page padding); individual pages add their own breakpoint rules for
   layouts that don't reflow on their own (hardcoded grid columns,
   non-wrapping flex rows, etc).
------------------------------------------------------- */
@media (max-width: 900px) {
    /* Force the icon-only collapsed sidebar treatment regardless of the
       user's manual toggle state — there's no room for the full 240px
       rail once the viewport gets this narrow. */
    .sidebar { width: 64px; }
    .main-content { margin-left: 64px; }
    .nav-label,
    .sidebar-company { display: none; }
    .nav-links li a { justify-content: center; padding: 7px; }
    .sidebar-logo { text-align: center; padding-left: 10px; padding-right: 10px; }
    .sidebar-footer { align-items: center; }
    .sidebar-footer a { justify-content: center; }
    .sidebar-toggle { display: none; } /* nothing to toggle, it's forced */
    .logo-initial { display: flex; }

    .page-header { padding: 20px 16px 0; }
    .page-body { padding: 16px 16px 32px; }
}

@media (max-width: 600px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    .stats-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); }
}

/* Add alongside any inline `style="display:grid;grid-template-columns:..."` —
   the desktop column layout stays wherever it's defined (inline, since these
   are all one-off per-page layouts), this just forces a single stacked
   column once there's no room to render multiple side by side. */
@media (max-width: 700px) {
    .grid-responsive { grid-template-columns: 1fr !important; }
}
