/* ====================================================================
   ComplianceTrak CMS — UI matching the Financial Promotions System
   Brand navy #1e3a5f, slate neutrals, system font stack.
   Brand colours are overridable at runtime via :root vars set inline
   by the layout from Admin > Branding.
   ==================================================================== */

:root {
    --brand:        #1e3a5f;
    --brand-dark:   #172d4a;
    --accent:       #818cf8;
    --sidebar-bg:   #ffffff;
    --topbar-bg:    #ffffff;

    --bg:        #f1f5f9;
    --card:      #ffffff;
    --border:    #e2e8f0;
    --text:      #1e293b;
    --muted:     #64748b;
    --muted-2:   #94a3b8;
    --radius:    0.5rem;

    --ok:     #16a34a;  --ok-bg:    #f0fdf4;
    --warn:   #d97706;  --warn-bg:  #fffbeb;
    --danger: #dc2626;  --danger-bg:#fef2f2;
    --info:   #2563eb;  --info-bg:  #eff6ff;
}

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

html, body {
    height: 100%;
    font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
    width: 256px; flex-shrink: 0;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex; flex-direction: column;
    position: sticky; top: 0; height: 100vh;
}
.sidebar-logo {
    height: 64px; display: flex; align-items: center; gap: 10px;
    padding: 0 20px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.logo-mark {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--brand); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px; letter-spacing: -0.5px;
}
.logo-text { display: flex; flex-direction: column; line-height: 1.2; gap: 3px; }
.logo-text .name { font-weight: 700; color: var(--brand); font-size: 16px; line-height: 1.2; }
.logo-text .sub  { font-size: 10px; text-transform: uppercase; letter-spacing: 1.5px; color: var(--muted-2); line-height: 1.35; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 16px 12px; }
.nav-group { margin-bottom: 22px; }
.nav-group-label {
    padding: 0 8px; margin-bottom: 6px; font-size: 11px; font-weight: 600;
    text-transform: uppercase; letter-spacing: 1px; color: var(--muted-2);
}
.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: 6px; font-size: 14px; font-weight: 500;
    color: var(--muted); margin-bottom: 2px; transition: background .12s, color .12s;
}
.nav-item:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
.nav-item.active { background: var(--brand); color: #fff; }
.nav-item .ico { width: 18px; text-align: center; opacity: .85; flex-shrink: 0; }

.sidebar-footer {
    border-top: 1px solid var(--border); padding: 12px 16px;
    font-size: 12px; color: var(--muted-2); display: flex; align-items: center; gap: 6px;
}

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

.topbar {
    height: 64px; background: var(--topbar-bg);
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 16px; padding: 0 24px;
    position: sticky; top: 0; z-index: 30;
}
.topbar .spacer { flex: 1; }
.topbar-search { position: relative; width: 320px; max-width: 38vw; }
.topbar-search input {
    width: 100%; padding: 8px 12px 8px 34px; border: 1px solid var(--border);
    border-radius: 999px; font-size: 13px; background: #f8fafc;
}
.topbar-search .si { position: absolute; left: 12px; top: 9px; color: var(--muted-2); }

.bell {
    position: relative; width: 38px; height: 38px; border-radius: 999px;
    display: flex; align-items: center; justify-content: center; color: var(--muted);
}
.bell:hover { background: #f1f5f9; text-decoration: none; }
.bell .count {
    position: absolute; top: 4px; right: 4px; background: var(--danger);
    color: #fff; font-size: 10px; font-weight: 700; min-width: 16px; height: 16px;
    border-radius: 999px; display: flex; align-items: center; justify-content: center; padding: 0 4px;
}
.user-chip {
    display: flex; align-items: center; gap: 10px; padding: 5px 10px 5px 6px;
    border-radius: 999px; cursor: pointer;
}
.user-chip:hover { background: #f1f5f9; }
.avatar {
    width: 34px; height: 34px; border-radius: 999px; background: var(--brand);
    color: #fff; font-weight: 600; font-size: 13px;
    display: flex; align-items: center; justify-content: center;
}
.user-meta { line-height: 1.1; }
.user-meta .nm { font-size: 13px; font-weight: 600; color: var(--text); }
.user-meta .rl { font-size: 11px; color: var(--muted-2); }
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 8px); width: 220px;
    background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15,23,42,.12); padding: 6px; display: none; z-index: 50;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: 8px; width: 100%;
    padding: 8px 10px; border-radius: 6px; font-size: 13px; color: var(--text);
    background: none; border: 0; cursor: pointer; text-align: left;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: #f1f5f9; text-decoration: none; }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 6px 0; }
.dropdown-menu .danger { color: var(--danger); }

.content { padding: 24px; flex: 1; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; flex-wrap: wrap; }
.page-head h1 { font-size: 22px; font-weight: 700; color: var(--text); }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.breadcrumb { font-size: 12px; color: var(--muted-2); margin-bottom: 6px; }
.breadcrumb a { color: var(--muted); }

/* ---------- Cards / KPIs ---------- */
.card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px;
}
.card + .card { margin-top: 16px; }
/* Suppress the vertical stacking margin when cards sit side-by-side in
   a grid (.grid-2).  Without this, the second card in a horizontal
   row inherits the 16px top-margin meant for vertical stacks, breaking
   top-alignment with its row neighbour. */
.grid-2 > .card + .card { margin-top: 0; }
/* Cards whose head contains just an <h2> are ~18px tall.  Cards whose
   head also contains a .btn.sm action (e.g. "View all") are ~28px tall.
   Force a min so the table/body inside both cards starts at the same
   Y when the cards sit side-by-side in a .grid-2 row. */
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; min-height: 28px; }
.card-head h2 { font-size: 15px; font-weight: 600; }

.kpi-grid {
    display: grid; gap: 16px; margin-bottom: 24px;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
}
.kpi {
    background: var(--card); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 18px 18px 16px;
    display: flex; flex-direction: column; gap: 6px;
}
.kpi .label { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; font-weight: 600; }
.kpi .value { font-size: 28px; font-weight: 700; color: var(--text); }
.kpi .foot { font-size: 12px; color: var(--muted-2); }
.kpi.accent { border-left: 3px solid var(--brand); }
.kpi.warn   { border-left: 3px solid var(--warn); }
.kpi.danger { border-left: 3px solid var(--danger); }
.kpi.ok     { border-left: 3px solid var(--ok); }

/* align-items: start keeps each card at its natural height with the
   TOPS aligned in a row.  Without this, the grid default (stretch)
   inflates the shorter card to match the taller one, leaving empty
   whitespace at the bottom of the lighter card. */
.grid-2 { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(340px,1fr)); align-items: start; }

/* ---------- Tables ---------- */
.table-tools { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.table-tools input, .table-tools select {
    padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; background: #fff;
}
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: #fff; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
    text-align: left; padding: 11px 14px; background: #f8fafc;
    font-size: 11px; text-transform: uppercase; letter-spacing: .5px;
    color: var(--muted); border-bottom: 1px solid var(--border); white-space: nowrap;
}
table.data td { padding: 11px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr:hover td { background: #f8fafc; }
table.data a { font-weight: 600; }
.empty { padding: 40px; text-align: center; color: var(--muted-2); }

/* Inline form controls inside a data table (line-item editors) — match .field */
table.data.line-table td input:not([type=checkbox]):not([type=radio]),
table.data.line-table td select,
table.data.line-table td textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 6px; font-size: 13px; font-family: inherit;
    background: #fff; color: var(--text); box-sizing: border-box;
}
table.data.line-table td textarea { min-height: 60px; resize: vertical; }
table.data.line-table td input:not([type=checkbox]):not([type=radio]):focus,
table.data.line-table td select:focus,
table.data.line-table td textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 600;
    text-transform: capitalize; line-height: 1.4;
}
.badge.ok     { background: var(--ok-bg);     color: var(--ok); }
.badge.warn   { background: var(--warn-bg);   color: var(--warn); }
.badge.danger { background: var(--danger-bg); color: var(--danger); }
.badge.info   { background: var(--info-bg);   color: var(--info); }
.badge.muted  { background: #f1f5f9;          color: var(--muted); }

.scope-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 999px; font-size: 12px; font-weight: 600;
    margin-right: 14px; white-space: nowrap; line-height: 1.3;
}
.scope-pill.scope-all      { background: var(--info-bg);   color: var(--info); }
.scope-pill.scope-assigned { background: var(--warn-bg);   color: var(--warn); }
.scope-note {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 12px; font-weight: 600; color: var(--warn);
    background: var(--warn-bg); padding: 4px 10px; border-radius: 8px;
}

.health-pill { font-weight: 700; }
.health-pill .bar {
    display: inline-block; width: 46px; height: 6px; border-radius: 999px;
    background: #e2e8f0; vertical-align: middle; margin-left: 6px; overflow: hidden;
}
.health-pill .bar i { display: block; height: 100%; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; gap: 7px; cursor: pointer;
    padding: 9px 16px; border-radius: 6px; font-size: 13px; font-weight: 600;
    border: 1px solid transparent; background: var(--brand); color: #fff; transition: filter .12s;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; color: #fff; }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--border); }
.btn.secondary:hover { background: #f8fafc; color: var(--text); }
.btn.danger { background: var(--danger); }
.btn.sm { padding: 6px 11px; font-size: 12px; }
.btn.ghost { background: none; color: var(--muted); border-color: transparent; }
.btn.ghost:hover { background: #f1f5f9; color: var(--text); }

/* ---------- Forms ---------- */
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
.field label { font-size: 12px; font-weight: 600; color: var(--text); }
.field .hint { font-size: 11px; color: var(--muted-2); }
.field input, .field select, .field textarea {
    padding: 9px 11px; border: 1px solid var(--border); border-radius: 6px;
    font-size: 13px; font-family: inherit; background: #fff; width: 100%;
}
.field textarea { min-height: 90px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(30,58,95,.12);
}
.field .err { font-size: 11px; color: var(--danger); }
.form-actions { display: flex; gap: 10px; margin-top: 20px; padding-top: 18px; border-top: 1px solid var(--border); }
fieldset { border: 0; margin-bottom: 8px; }
fieldset legend { font-size: 13px; font-weight: 700; color: var(--brand); margin-bottom: 12px; }

/* ---------- Roles edit page (permission matrix) ---------- */
.perm-modules {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}
.perm-module {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    margin: 0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .04);
    transition: box-shadow .15s, border-color .15s;
}
.perm-module:focus-within { border-color: var(--brand); box-shadow: 0 2px 8px rgba(30,58,95,.08); }
.perm-module[disabled] { opacity: .65; }
.perm-module-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid var(--border);
    background: #f8fafc; border-top-left-radius: var(--radius); border-top-right-radius: var(--radius);
}
.perm-module-title { display: flex; align-items: center; gap: 8px; }
.perm-module-title strong { font-size: 13px; color: var(--brand); letter-spacing: .2px; }
.perm-count {
    display: inline-block; font-size: 11px; font-weight: 600;
    padding: 2px 7px; border-radius: 999px;
    background: #e2e8f0; color: var(--muted); line-height: 1.4;
}
.perm-module-actions { display: flex; align-items: center; gap: 8px; }
.link-btn {
    background: none; border: 0; padding: 0; cursor: pointer;
    color: var(--brand); font-size: 12px; font-weight: 600; text-decoration: underline dotted;
}
.link-btn:hover { color: var(--brand-dark); }
.info-btn {
    background: none; border: 0; padding: 0; cursor: pointer; line-height: 1;
    color: var(--muted-2);
}
.info-btn:hover .info-icon { background: var(--brand); color: #fff; border-color: var(--brand); }
.info-icon {
    display: inline-flex; align-items: center; justify-content: center;
    width: 18px; height: 18px; border-radius: 999px;
    border: 1px solid var(--border); background: #fff;
    font-size: 11px; font-weight: 700; font-style: italic; color: var(--muted);
    font-family: Georgia, serif;
}
.perm-list { padding: 6px 6px 10px; }
.perm-row {
    display: flex; align-items: flex-start; gap: 9px;
    padding: 7px 10px; border-radius: 6px; cursor: pointer;
    transition: background .12s;
}
.perm-row:hover { background: #f1f5f9; }
.perm-row input[type="checkbox"] { margin-top: 2px; flex: none; }
.perm-row-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.perm-label { font-size: 13px; font-weight: 500; color: var(--text); }
.perm-code  { font-size: 10.5px; color: var(--muted-2); background: none; padding: 0; }
.perm-module[disabled] .perm-row { cursor: not-allowed; }
.perm-info-list dt {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px; color: var(--brand); font-weight: 600;
    margin-top: 10px;
}
.perm-info-list dt:first-child { margin-top: 0; }
.perm-info-list dd { font-size: 13px; color: var(--text); margin: 2px 0 0; padding: 0; }

/* ---------- Flash ---------- */
.flash { padding: 12px 16px; border-radius: var(--radius); font-size: 13px; margin-bottom: 18px; border: 1px solid; }
.flash.success { background: var(--ok-bg);    color: var(--ok);    border-color: #bbf7d0; }
.flash.error   { background: var(--danger-bg);color: var(--danger);border-color: #fecaca; }
.flash.info    { background: var(--info-bg);  color: var(--info);  border-color: #bfdbfe; }

/* ---------- Tabs ---------- */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; overflow-x: auto; }
.tab {
    padding: 10px 16px; font-size: 13px; font-weight: 600; color: var(--muted);
    border-bottom: 2px solid transparent; white-space: nowrap;
}
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 4px; bottom: 4px; width: 2px; background: var(--border); }
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item::before {
    content: ""; position: absolute; left: -23px; top: 3px; width: 12px; height: 12px;
    border-radius: 999px; background: #fff; border: 2px solid var(--brand);
}
.tl-item .tl-head { font-size: 13px; font-weight: 600; }
.tl-item .tl-meta { font-size: 12px; color: var(--muted-2); margin: 2px 0 6px; }
.tl-item .tl-body { font-size: 13px; color: var(--text); white-space: pre-wrap; }

/* ---------- Misc ---------- */
.pagination { display: flex; gap: 6px; margin-top: 16px; align-items: center; font-size: 13px; }
.pagination a, .pagination span {
    padding: 6px 11px; border: 1px solid var(--border); border-radius: 6px; color: var(--muted);
}
.pagination .current { background: var(--brand); color: #fff; border-color: var(--brand); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.mt { margin-top: 16px; } .mb { margin-bottom: 16px; }
.row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row-actions form { display: inline-flex; align-items: center; margin: 0; }
.dl { display: grid; grid-template-columns: 180px 1fr; gap: 10px 16px; font-size: 13px; }
.dl dt { color: var(--muted); }
.dl dd { color: var(--text); }
.score-ring { font-weight: 700; font-size: 15px; }

/* ---------- Auth ---------- */
.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%); padding: 24px;
}
.auth-card { background: #fff; border-radius: 14px; width: 100%; max-width: 420px; padding: 36px 34px; box-shadow: 0 20px 50px rgba(0,0,0,.25); }
.auth-logo { display: flex; align-items: flex-start; gap: 12px; margin-bottom: 26px; }
.auth-logo .logo-mark { margin-top: 3px; }
.auth-card h1 { font-size: 20px; margin-bottom: 4px; }
.auth-card .sub { color: var(--muted); font-size: 13px; margin-bottom: 24px; }
.auth-card .field { margin-bottom: 16px; }
.auth-card .btn { width: 100%; justify-content: center; padding: 11px; }
/* The password show/hide toggle is a .btn but must NOT inherit the
   full-width auth submit styling — otherwise it overlays the whole
   password input and steals every click/keystroke. Keep it compact. */
.auth-card [data-toggle-pw] {
    width: auto; padding: 6px 10px; justify-content: center;
}
.auth-foot { text-align: center; margin-top: 20px; font-size: 12px; color: var(--muted-2); }

@media (max-width: 900px) {
    .sidebar { display: none; }
    .topbar-search { display: none; }
    .content { padding: 16px; }
}

/* ====================================================================
   Productionisation additions — dark mode, components, toasts, modals,
   command palette, quick-access. Brand colours stay runtime-driven.
   ==================================================================== */

html[data-theme="dark"] {
    --bg:      #0b1220;
    --card:    #111a2b;
    --border:  #243049;
    --text:    #e2e8f0;
    --muted:   #94a3b8;
    --muted-2: #64748b;
    --sidebar-bg: #0e1626;
    --topbar-bg:  #0e1626;
    --ok-bg:    #07261a; --warn-bg: #2a210a;
    --danger-bg:#2a1212; --info-bg: #0f1f3a;
}
html[data-theme="dark"] table.data th { background: #0e1626; }
html[data-theme="dark"] table.data tr:hover td { background: #0e1626; }
html[data-theme="dark"] .topbar-search input,
html[data-theme="dark"] .field input,
html[data-theme="dark"] .field select,
html[data-theme="dark"] .field textarea,
html[data-theme="dark"] .table-tools input,
html[data-theme="dark"] .table-tools select,
html[data-theme="dark"] table.data.line-table td input:not([type=checkbox]):not([type=radio]),
html[data-theme="dark"] table.data.line-table td select,
html[data-theme="dark"] table.data.line-table td textarea { background: #0e1626; color: var(--text); }
html { transition: none; }
body, .card, .kpi, .sidebar, .topbar, table.data td { transition: background-color .15s, color .15s; }

/* Theme toggle */
.theme-toggle {
    width: 38px; height: 38px; border-radius: 999px; border: 0; cursor: pointer;
    background: transparent; color: var(--muted); display: flex;
    align-items: center; justify-content: center;
}
.theme-toggle:hover { background: #f1f5f9; }
html[data-theme="dark"] .theme-toggle:hover { background: #1b2740; }

/* Empty state */
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted-2); }
.empty-state-icon {
    width: 56px; height: 56px; border-radius: 14px; margin: 0 auto 14px;
    display: flex; align-items: center; justify-content: center;
    background: var(--bg); color: var(--muted-2);
}
.empty-state p { margin-bottom: 14px; }

/* Toasts */
.toast-wrap {
    position: fixed; top: 18px; right: 18px; z-index: 9999;
    display: flex; flex-direction: column; gap: 10px; max-width: 360px;
}
.toast {
    background: var(--card); border: 1px solid var(--border); border-left-width: 4px;
    border-radius: 8px; padding: 12px 36px 12px 14px; font-size: 13px;
    box-shadow: 0 10px 30px rgba(15,23,42,.16); position: relative;
    animation: toast-in .2s ease-out;
}
.toast.success { border-left-color: var(--ok); }
.toast.error   { border-left-color: var(--danger); }
.toast.info    { border-left-color: var(--info); }
.toast.warning { border-left-color: var(--warn); }
.toast-x {
    position: absolute; top: 6px; right: 8px; border: 0; background: none;
    cursor: pointer; color: var(--muted-2); font-size: 16px; line-height: 1;
}
@keyframes toast-in { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; } }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 9000; display: flex;
    align-items: center; justify-content: center; padding: 20px; }
.modal[hidden] { display: none; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,.55); }
.modal-panel {
    position: relative; background: var(--card); border: 1px solid var(--border);
    border-radius: 12px; width: 100%; max-width: 520px; box-shadow: 0 24px 60px rgba(0,0,0,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: center;
    padding: 16px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 15px; }
.modal-x { border: 0; background: none; font-size: 22px; cursor: pointer; color: var(--muted-2); }
.modal-body { padding: 18px; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--border);
    display: flex; gap: 8px; justify-content: flex-end; }

/* Large document-preview modal: near-fullscreen, iframe fills the body
   so the browser's native PDF viewer (zoom + multi-page scroll) is
   fully usable. */
.modal-panel.modal-doc {
    max-width: 1100px; width: 92vw; height: 90vh;
    display: flex; flex-direction: column;
}
.modal-panel.modal-doc .modal-body { flex: 1; min-height: 0; }
.modal-panel.modal-doc iframe { display: block; }

/* Quick access (sidebar) */
.quick-block { margin-bottom: 22px; }
.quick-block .nav-group-label { display: flex; justify-content: space-between; }
.quick-item {
    display: flex; align-items: center; gap: 8px; padding: 6px 10px;
    border-radius: 6px; font-size: 13px; color: var(--muted);
}
.quick-item:hover { background: #f1f5f9; color: var(--text); text-decoration: none; }
html[data-theme="dark"] .quick-item:hover { background: #1b2740; }
.pin-btn {
    border: 1px solid var(--border); background: var(--card); color: var(--muted);
    border-radius: 6px; padding: 8px 12px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.pin-btn.pinned { color: var(--warn); border-color: var(--warn); }

/* Command palette */
.cmdk { position: fixed; inset: 0; z-index: 9500; display: none;
    align-items: flex-start; justify-content: center; padding-top: 12vh; }
.cmdk.open { display: flex; }
.cmdk-backdrop { position: absolute; inset: 0; background: rgba(2,6,23,.5); }
.cmdk-box { position: relative; width: 100%; max-width: 560px; background: var(--card);
    border: 1px solid var(--border); border-radius: 12px; overflow: hidden;
    box-shadow: 0 24px 60px rgba(0,0,0,.35); }
.cmdk-box input { width: 100%; border: 0; padding: 16px 18px; font-size: 15px;
    background: var(--card); color: var(--text); outline: none;
    border-bottom: 1px solid var(--border); }
.cmdk-list { max-height: 320px; overflow-y: auto; }
.cmdk-list a { display: flex; align-items: center; gap: 10px; padding: 11px 18px;
    font-size: 13px; color: var(--text); border-bottom: 1px solid var(--border); }
.cmdk-list a:hover, .cmdk-list a.active { background: var(--bg); text-decoration: none; }
.cmdk-hint { padding: 10px 18px; font-size: 11px; color: var(--muted-2); }
.loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0;
    background: var(--accent); z-index: 99999; transition: width .3s ease; }

/* Bar chart component */
.chart { display: flex; flex-direction: column; gap: 10px; }
.chart-title { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.chart-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.chart-label { width: 120px; color: var(--muted); text-align: right; flex-shrink: 0; }
.chart-track { flex: 1; height: 10px; background: var(--bg); border-radius: 999px; overflow: hidden; }
.chart-bar { display: block; height: 100%; border-radius: 999px; background: var(--brand); }
.chart-bar.ok { background: var(--ok); } .chart-bar.warn { background: var(--warn); }
.chart-bar.danger { background: var(--danger); } .chart-bar.info { background: var(--info); }
.chart-value { width: 36px; text-align: right; font-weight: 700; flex-shrink: 0; }
