/* CaptrixOS polish layer. Loaded last. Quiet, ledger-like surfaces; the dashboard runway banner is the one bold element.
   User choices (Settings > Appearance) arrive as data attributes on <html>: data-density, data-radius, data-font, data-sidebar, data-card. */

:root {
  --r-s: 6px; --r-m: 10px; --r-l: 14px;
  --pad-card: 18px; --pad-cell-y: 9px; --row-h: 48px; --nav-y: 8px; --gap: 16px;
  --font-ui: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-head: var(--font-ui);
  --lift: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 14px rgba(15, 23, 42, .05);
  --ring: color-mix(in srgb, var(--brand) 45%, transparent);
  --side-bg: var(--surface); --side-ink: var(--body); --side-mute: var(--muted); --side-line: var(--line);
  --side-hover: var(--sub); --side-on-bg: var(--brand-soft); --side-on-ink: var(--brand);
}
html[data-theme="dark"] { --lift: 0 1px 0 rgba(255, 255, 255, .03); }

/* ---- Customization hooks ------------------------------------------------ */
html[data-density="compact"] { --pad-card: 12px; --pad-cell-y: 5px; --row-h: 36px; --nav-y: 5px; --gap: 10px; }
html[data-density="roomy"] { --pad-card: 24px; --pad-cell-y: 12px; --row-h: 58px; --nav-y: 10px; --gap: 22px; }
html[data-radius="sharp"] { --r-s: 3px; --r-m: 5px; --r-l: 7px; }
html[data-radius="round"] { --r-s: 10px; --r-m: 16px; --r-l: 22px; }
html[data-font="humanist"] { --font-ui: Seravek, "Gill Sans Nova", Calibri, "Trebuchet MS", ui-sans-serif, system-ui, sans-serif; }
html[data-font="rounded"] { --font-ui: ui-rounded, "SF Pro Rounded", "Hiragino Maru Gothic ProN", Quicksand, "Segoe UI", system-ui, sans-serif; }
html[data-font="serif"] { --font-head: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif; }
html[data-font="mono"] { --font-ui: ui-monospace, "SF Mono", Menlo, Consolas, monospace; }
html[data-card="flat"] { --lift: none; }
html[data-card="elevated"] .card, html[data-card="elevated"] .dcard, html[data-card="elevated"] .kcard { border-color: transparent; box-shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px rgba(15, 23, 42, .08); }
html[data-card="elevated"][data-theme="dark"] .card, html[data-card="elevated"][data-theme="dark"] .dcard, html[data-card="elevated"][data-theme="dark"] .kcard { box-shadow: 0 8px 24px rgba(0, 0, 0, .35); }

html[data-sidebar="dark"] { --side-bg: #101a16; --side-ink: #c5d3cb; --side-mute: #7f948a; --side-line: #22312a; --side-hover: rgba(255, 255, 255, .06); --side-on-bg: rgba(255, 255, 255, .1); --side-on-ink: #ffffff; }
html[data-sidebar="accent"] { --side-bg: var(--brand); --side-ink: rgba(255, 255, 255, .88); --side-mute: rgba(255, 255, 255, .62); --side-line: rgba(255, 255, 255, .18); --side-hover: rgba(255, 255, 255, .12); --side-on-bg: rgba(255, 255, 255, .22); --side-on-ink: #ffffff; }
html[data-sidebar="accent"][data-theme="dark"] { --side-bg: color-mix(in srgb, var(--brand) 55%, #0b1220); }

/* ---- Type --------------------------------------------------------------- */
body { font-family: var(--font-ui); font-feature-settings: "cv11", "ss01"; }
h1, h2, h3, .hd-big, .kbig { font-family: var(--font-head); }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -.015em; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.005em; }
.dh h2, .card > h2 { font-size: 15px; }
:where(.num, .kbig, td, .hd-big) { font-variant-numeric: tabular-nums; }

/* Small caption labels: sentence case, quiet, no tracking */
.cap, .navgrp > div:first-child, .sg-h { text-transform: none !important; letter-spacing: 0 !important; font-size: 12px !important; font-weight: 500 !important; color: var(--muted); }
th { text-transform: none; letter-spacing: 0; font-size: 12px; font-weight: 600; background: transparent; color: var(--muted); border-bottom: 1px solid var(--line); }
.hero-dark .cap { color: #f7c978; }

/* ---- Surfaces ----------------------------------------------------------- */
.main { background: var(--bg); }
.topbar { background: color-mix(in srgb, var(--surface) 88%, transparent); border-bottom: 1px solid var(--line); }
.card, .dcard, .kcard, .bcard { border-radius: var(--r-l); box-shadow: var(--lift); }
.card { padding: var(--pad-card); margin-bottom: var(--gap); }
.dcard { padding: var(--pad-card); }
.kcard, .bcard, .fcol { border-top-width: 1px; }
.kcard { padding: var(--pad-card); gap: 4px; }
.kcard .kbig { font-size: 26px; font-weight: 650; }
.kcard .cap { display: flex; align-items: center; gap: 6px; }
.kcard .cap::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--k, var(--brand)); flex: none; }
.fcol { border-radius: var(--r-m); }
.fcol .fn { display: none; }
.fcol .fc { font-size: 20px; }
.fcol::before { content: ""; width: 22px; height: 3px; border-radius: 2px; background: var(--c, var(--brand)); margin-bottom: 4px; }
.qcard, .urow, .wrow { border-radius: var(--r-m); }
.hero-dark { border-radius: var(--r-l); background: linear-gradient(120deg, #1d3a6b 0%, #14284B 55%, #0c1b35 100%); }
.gres, .dlg, .modal { border-radius: var(--r-l); }
.pill { border-radius: 999px; }
.avatar { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .25); }

/* ---- Tables ------------------------------------------------------------- */
th, td { padding: var(--pad-cell-y) 12px; }
td { height: auto; border-bottom: 1px solid color-mix(in srgb, var(--line) 70%, transparent); }
tr.click td { height: var(--row-h); }
tr.click:hover, tr.click-row:hover { background: color-mix(in srgb, var(--brand) 6%, transparent); }
tbody tr:last-child td { border-bottom: 0; }

/* ---- Controls ----------------------------------------------------------- */
button, .btn { border-radius: var(--r-s); }
input, select, textarea { border-radius: var(--r-s); background: var(--surface); }
select { padding-right: 28px; }
input:focus, select:focus, textarea:focus, button:focus-visible, a:focus-visible, .btn:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
input:hover:not(:focus):not([type=checkbox]):not([type=radio]), select:hover:not(:focus) { border-color: color-mix(in srgb, var(--ink) 25%, var(--line)); }
.seg, .tabs { border-radius: var(--r-m); } .seg label, .tabs a { border-radius: var(--r-s); }
.chip { border-radius: 999px; }

/* Dashboard and other Tailwind-built panels follow the same scale */
.rounded-2xl { border-radius: var(--r-l); } .rounded-xl { border-radius: var(--r-m); } .rounded-lg { border-radius: var(--r-s); }
.font-label-caps { text-transform: none !important; letter-spacing: 0 !important; font-size: 12px; font-weight: 500 !important; }
.font-headline-md { font-size: 16px; line-height: 22px; font-weight: 600; font-family: var(--font-head); }
.p-space-lg { padding: var(--pad-card); }
.group > .absolute.top-0.h-1 { display: none; }
.shadow-sm { box-shadow: var(--lift); }
section.rounded-2xl.shadow-md { box-shadow: 0 10px 30px color-mix(in srgb, var(--brand) 25%, transparent); }

/* ---- Sidebar ------------------------------------------------------------ */
.rail { background: var(--side-bg); border-right-color: var(--side-line); }
.rail .nav { flex-wrap: nowrap; flex-direction: column; gap: 14px; }
.rail .navgrp { width: 100%; margin: 0; }
.rail .nav > * { margin-top: 0 !important; }
.rail .nv { padding-top: var(--nav-y); padding-bottom: var(--nav-y); border-radius: var(--r-s); color: var(--side-ink); }
.rail .nv .material-symbols-outlined { color: var(--side-mute); }
.rail .nv:hover { background: var(--side-hover); color: var(--side-on-ink); }
.rail .nv:hover .material-symbols-outlined { color: var(--side-on-ink); }
.nav a.on { background: var(--side-on-bg); color: var(--side-on-ink); box-shadow: none; }
.nav a.on .material-symbols-outlined { color: var(--side-on-ink); }
.nav a.on .nb { background: color-mix(in srgb, var(--side-on-ink) 16%, transparent); color: var(--side-on-ink); }
.rail .navgrp > div:first-child { color: var(--side-mute); }
.rail .text-slate-900, .rail .text-slate-500, .rail .text-slate-400 { color: inherit; }
.rail .rail-top span.font-bold { color: var(--side-on-ink) !important; }
html[data-sidebar="dark"] .rail .bg-white, html[data-sidebar="accent"] .rail .bg-white { background: var(--side-hover); border-color: var(--side-line); }
html[data-sidebar="dark"] .rail .text-slate-500, html[data-sidebar="accent"] .rail .text-slate-500,
html[data-sidebar="dark"] .rail strong, html[data-sidebar="accent"] .rail strong { color: var(--side-ink) !important; }
.rail .newfile { background: var(--brand); background-image: none; border-radius: var(--r-s); box-shadow: none; }
.rail .newfile:hover { background: var(--brand-hover); }
html[data-sidebar="accent"] .rail .newfile { background: #fff; color: var(--brand); }
.rail-top > div:first-child { background: var(--brand); background-image: none; border-radius: var(--r-m); }
html[data-sidebar="accent"] .rail-top > div:first-child { background: rgba(255, 255, 255, .2); }
.rail .rail-top span.rounded-full { background: var(--side-hover); color: var(--side-ink); border-color: var(--side-line); }

/* ---- Simple menu: hidden nav items (set by appearance.js) ---------------- */

/* ---- Appearance page ---------------------------------------------------- */
.ap-sw { display: flex; flex-wrap: wrap; gap: 10px; }
.ap-sw button { width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 2px solid transparent; background: var(--c); box-shadow: inset 0 0 0 2px var(--surface); }
.ap-sw button[aria-pressed="true"] { border-color: var(--ink); }
.ap-opt { display: flex; flex-wrap: wrap; gap: 8px; }
.ap-opt button { background: var(--surface); color: var(--ink); border: 1px solid var(--line); padding: 7px 14px; font-weight: 500; }
.ap-opt button:hover:not(:disabled) { background: var(--sub); border-color: var(--line); }
.ap-opt button[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.ap-row { display: grid; grid-template-columns: 170px minmax(0, 1fr); gap: 8px 20px; align-items: start; padding: 14px 0; border-top: 1px solid var(--line); }
.ap-row:first-of-type { border-top: 0; }
.ap-row > b { font-weight: 600; font-size: 13px; padding-top: 6px; }
.ap-menu { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 4px 16px; }
.ap-menu label { display: flex; align-items: center; gap: 8px; margin: 0; padding: 4px 0; font-weight: 500; }
.ap-menu input { width: auto; height: auto; }
@media (max-width: 700px) { .ap-row { grid-template-columns: 1fr; } .ap-row > b { padding-top: 0; } }

/* ---- Assistant ---------------------------------------------------------- */
#asstbtn { background: transparent; border: 0; color: var(--muted); padding: 6px; border-radius: var(--r-s); display: grid; place-items: center; }
#asstbtn:hover:not(:disabled) { background: var(--sub); color: var(--brand); border: 0; }
.as-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(420px, 100vw); z-index: 70; display: flex; flex-direction: column; background: var(--surface); border-left: 1px solid var(--line); box-shadow: -12px 0 32px rgba(15, 23, 42, .12); }
.as-panel[hidden] { display: none; }
.as-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.as-body { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.as-u { align-self: flex-end; max-width: 88%; background: var(--brand-soft); color: var(--ink); padding: 8px 12px; border-radius: var(--r-m); white-space: pre-wrap; }
.as-b { max-width: 100%; } .as-b p { margin: 0 0 .5em; } .as-b ul, .as-card ul { margin: .3em 0 .6em 1.1em; padding: 0; list-style: disc; } .as-b code { background: var(--sub); padding: 1px 5px; border-radius: 4px; }
.as-e { background: var(--bad-soft); color: var(--bad); padding: 8px 12px; border-radius: var(--r-m); }
.as-card { border: 1px solid var(--line); border-radius: var(--r-m); padding: 10px 12px; background: var(--surface); }
.as-card.open { border-color: var(--brand); } .as-card.no { opacity: .65; } .as-card.done { background: var(--brand-soft); border-color: transparent; }
.as-hi { padding: 8px 0; } .as-sug { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 8px; }
.as-form { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); align-items: flex-end; }
.as-form textarea { height: auto; min-height: 44px; resize: none; flex: 1; }
@media (min-width: 1100px) { html.as-open .main { margin-right: 420px; } }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; scroll-behavior: auto !important; } }

/* Rows: tw.css ships a Tailwind ".inline{display:inline}" that beat the app's own flex row. Restore it. */
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > input, .inline > select { width: auto; flex: 1 1 140px; }
.inline > select[style*="width:auto"] { flex: 0 0 auto; }

/* Pick lists: one result per row, action on the right */
.picklist { display: flex; flex-direction: column; margin: 8px 0; border: 1px solid var(--line, rgba(127,127,127,.25)); border-radius: var(--r-m, 10px); overflow: hidden; }
.picklist .pick { background: none; border-width: 0; border-radius: 0; box-shadow: none; display: flex; align-items: center; gap: 12px; padding: 10px 14px; margin: 0; }
.picklist .pick + .pick { border-top: 1px solid var(--line, rgba(127,127,127,.2)); }
.picklist .pick:hover { background: rgba(127,127,127,.06); }
.picklist .pick .main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.picklist .pick .main b { font-variant-numeric: tabular-nums; font-size: 15px; }
.picklist .pick .main .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picklist .pick button { flex: 0 0 auto; white-space: nowrap; }
@media (max-width: 520px) { .picklist .pick { flex-wrap: wrap; } .picklist .pick button { width: 100%; } }

/* Two-factor and idle sign-out */
.mfa-ov { position: fixed; inset: 0; z-index: 1000; background: rgba(15,20,18,.55); display: grid; place-items: center; padding: 16px; overflow: auto; }
.mfa-ov.solid { background: var(--bg, #f9fafb); }
.mfa-box { width: 100%; max-width: 460px; max-height: 94vh; overflow: auto; }
.mfa-qr { width: 200px; max-width: 100%; margin: 10px 0; background: #fff; padding: 6px; border-radius: 8px; border: 1px solid var(--line, #e5e7eb); }
.mfa-qr svg { width: 100%; height: auto; display: block; }
.mfa-codes { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 10px 0; }
.mfa-codes code { background: var(--soft, #f3f4f6); border-radius: 8px; padding: 10px 12px; text-align: center; letter-spacing: .08em; font-size: 15px; user-select: all; }
.idle-warn { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 1001; background: var(--card, #fff); border: 1px solid var(--line2, #d1d5db); border-radius: 12px; box-shadow: 0 8px 30px rgba(0,0,0,.18); padding: 14px 18px; display: flex; gap: 16px; align-items: center; max-width: calc(100vw - 32px); }
.idle-warn p { margin: 0; }


/* Settings: same look as the rest of the app (panels, icon menu, soft inputs) */
.setgrid { grid-template-columns: 248px minmax(0, 1fr); gap: 20px; margin-top: 16px; }
.sgpanel { background: rgb(var(--c-surface-container-lowest)); border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05); padding: 10px 8px !important; border: 0 !important; width: auto !important; }
.sgpanel .sg-h { padding: 14px 12px 4px !important; font-size: 12px !important; font-weight: 600 !important; color: rgb(var(--c-on-surface-variant)) !important; opacity: .85; }
.sgpanel .sg-h:first-child { padding-top: 6px !important; }
.sgpanel a { display: flex !important; align-items: center; gap: 10px; padding: 8px 12px !important; margin: 1px 0; border-radius: 10px !important; font-size: 14px; font-weight: 500; color: rgb(var(--c-on-surface)); text-decoration: none; }
.sgpanel a .material-symbols-outlined { font-size: 19px; color: rgb(var(--c-on-surface-variant)); }
.sgpanel a:hover { background: rgb(var(--c-surface-container-low)); }
.sgpanel a.on { background: rgb(var(--c-primary-fixed)); color: rgb(var(--c-primary)); font-weight: 600; box-shadow: none; }
.sgpanel a.on .material-symbols-outlined { color: rgb(var(--c-primary)); }
#sp > .card, #sp > div > .card { background: rgb(var(--c-surface-container-lowest)); border: 0; border-radius: 16px; box-shadow: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05); padding: 24px; margin-bottom: 16px; }
#sp .card .card { background: rgb(var(--c-surface-container-low)); border: 0; box-shadow: none; border-radius: 12px; padding: 16px; }
#sp .card > h2:first-child, #sp h2 { font-size: 18px; font-weight: 600; letter-spacing: -.01em; margin: 0 0 6px; }
#sp h3 { font-size: 15px; font-weight: 600; margin: 0 0 4px; }
#sp .card > .small.muted:first-of-type, #sp h2 + .small.muted, #sp h3 + .small.muted { max-width: 70ch; margin-bottom: 14px; }
#sp label { font-size: 13px; font-weight: 600; color: rgb(var(--c-on-surface)); margin-bottom: 4px; display: block; }
#sp label.check, #sp label.inline { font-weight: 500; display: flex; }
#sp input:not([type=checkbox]):not([type=radio]):not([type=color]):not([type=range]), #sp select, #sp textarea { height: 40px; background: rgb(var(--c-surface-container-low)); border: 1px solid transparent; border-radius: 12px; padding: 8px 12px; color: rgb(var(--c-on-surface)); }
#sp textarea { height: auto; min-height: 88px; }
#sp input:not([type=checkbox]):not([type=radio]):hover, #sp select:hover, #sp textarea:hover { border-color: rgb(var(--c-outline-variant)); }
#sp input:not([type=checkbox]):not([type=radio]):focus, #sp select:focus, #sp textarea:focus { background: rgb(var(--c-surface-container-lowest)); border-color: rgb(var(--c-primary)); outline: 3px solid rgb(var(--c-primary) / .18); outline-offset: 0; }
#sp button:not(.ghost):not(.secondary):not(.small) { border-radius: 12px; padding: 9px 18px; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
#sp button.secondary { border-radius: 12px; background: rgb(var(--c-surface-container-lowest)); border: 1px solid rgb(var(--c-outline-variant)); color: rgb(var(--c-on-surface)); }
#sp button.secondary:hover:not(:disabled) { background: rgb(var(--c-surface-container-low)); }
#sp button.small { border-radius: 10px; }
#sp .tablewrap { border: 1px solid rgb(var(--c-outline-variant)); border-radius: 12px; overflow: auto; }
#sp .tablewrap table { margin: 0; }
#sp th { background: rgb(var(--c-surface-container-low)); color: rgb(var(--c-on-surface-variant)); font-size: 12px; font-weight: 600; text-transform: none; letter-spacing: 0; padding: 10px 14px; }
#sp td { padding: 10px 14px; border-top: 1px solid rgb(var(--c-outline-variant)); }
#sp tbody tr:hover td { background: rgb(var(--c-surface-container-low) / .6); }
#sp .cv-tabs { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 4px; background: rgb(var(--c-surface-container-low)); border-radius: 12px; border: 0; margin-bottom: 16px !important; max-width: 100%; }
#sp .cv-tabs a { padding: 7px 14px; border-radius: 9px; border: 0; color: rgb(var(--c-on-surface-variant)); font-weight: 500; font-size: 14px; cursor: pointer; text-decoration: none; margin: 0; }
#sp .cv-tabs a:hover { color: rgb(var(--c-on-surface)); }
#sp .cv-tabs a.on { background: rgb(var(--c-surface-container-lowest)); color: rgb(var(--c-primary)); font-weight: 600; box-shadow: 0 1px 2px rgba(15,23,42,.12); }
#sp .notice { border-radius: 12px; }
#sp .kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 8px 16px; padding: 12px 14px; background: rgb(var(--c-surface-container-low)); border-radius: 12px; margin: 8px 0 12px; }
#sp .kv > span:nth-child(odd) { color: rgb(var(--c-on-surface-variant)); }
@media (max-width: 760px) {
  .setgrid { grid-template-columns: 1fr; gap: 12px; }
  .sgpanel { display: flex !important; flex-wrap: nowrap; overflow-x: auto; padding: 6px !important; position: static !important; max-height: none !important; }
  .sgpanel .sg-h { display: none !important; }
  .sgpanel a { white-space: nowrap; flex: 0 0 auto; }
  #sp > .card, #sp > div > .card { padding: 16px; }
}
