/* ============================================================================
   DetectiveCheck — App Design System (centralized)
   Single source of truth for every authenticated app surface: onboarding,
   dashboard, results, history, settings, profile, plans, help, error states.
   Tokens are carried 1:1 from the landing (index.html) so the app and the
   marketing site read as one product. Nothing here is page-specific.
   ============================================================================ */

@font-face {
    font-family: 'Space Grotesk';
    src: url('/assets/fonts/space-grotesk-latin.woff2') format('woff2');
    font-weight: 300 700;
    font-display: swap;
    unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
    font-family: 'Inter';
    src: url('/assets/fonts/inter-latin.woff2') format('woff2');
    font-weight: 400 700;
    font-display: swap;
}

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

:root {
    /* Surfaces */
    --bg: #FFFFFF;
    --bg-soft: #F5F7FB;
    --bg-sunken: #ECF0F6;
    --ink: #070C16;

    /* Text. Ratios below are the WORST case across the three surfaces text
       actually sits on (#FFFFFF, --bg-soft, --bg-sunken), not the flattering
       white-only figure: muted text on a grey card is the case that fails. */
    --text-primary: #0B1220;   /* 15.0:1 */
    --text-secondary: #44536A; /*  7.5:1 */
    --text-muted: #5C6880;     /*  4.9:1 */
    --text-onink: #F2F5FA;

    /* Borders */
    --border: #E2E7EF;
    --border-strong: #C9D2E0;

    /* Accent. Cobalt. One accent for the whole product. */
    --accent: #1F4BF0;
    --accent-deep: #1130A8;
    --accent-hover: #1539C4;
    --accent-soft: #EDF1FF;
    --accent-border: #C2D0FF;

    /* Module accents. Each lookup module owns one hue, used only for its
       icon chip and its result column — never as a second page accent. */
    --mod-email: #1F4BF0;
    --mod-email-soft: #EDF1FF;
    --mod-phone: #05908A;
    --mod-phone-soft: #E1F5F3;
    --mod-name: #7A3BD6;
    --mod-name-soft: #F1E9FC;
    --mod-username: #B8560F;
    --mod-username-soft: #FBEEE0;
    --mod-photo: #C0186B;
    --mod-photo-soft: #FCE7F1;
    --mod-password: #0B1220;
    --mod-password-soft: #ECF0F6;

    /* Status */
    --danger: #C0231A;
    --danger-soft: #FCECEA;
    --success: #05663F;
    --success-soft: #E2F3EC;
    --warn: #9A6207;
    --warn-soft: #FBF0DC;

    /* Radius rule: controls 12, cards 18, panels 26, hero 30, pills */
    --r-control: 12px;
    --r-card: 18px;
    --r-panel: 26px;
    --r-hero: 30px;
    --r-pill: 999px;

    /* Soft tinted shadows */
    --sh-1: 0 1px 2px rgba(11,18,32,.05), 0 2px 6px -2px rgba(11,18,32,.06);
    --sh-2: 0 1px 2px rgba(11,18,32,.05), 0 6px 14px -6px rgba(11,18,32,.10), 0 18px 36px -22px rgba(11,18,32,.14);
    --sh-3: 0 2px 4px rgba(11,18,32,.05), 0 12px 24px -10px rgba(11,18,32,.13), 0 34px 60px -32px rgba(11,18,32,.22);
    --sh-accent: 0 2px 6px -1px rgba(17,48,168,.30), 0 10px 24px -8px rgba(31,75,240,.45);

    /* Hard offset (neomorphism). Raised surfaces sit on a solid black edge. */
    --line: #070C16;
    --neo-1: 3px 3px 0 var(--line);
    --neo-2: 5px 5px 0 var(--line);
    --neo-3: 8px 8px 0 var(--line);
    --neo-press: 1px 1px 0 var(--line);

    --font-display: 'Space Grotesk', system-ui, sans-serif;
    --font-sans: 'Inter', system-ui, -apple-system, sans-serif;

    --page-gutter: clamp(1rem, 2.25vw, 2.5rem);
    --content-max: 80rem;

    --ease: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);

    --sidebar-w: 264px;
    --topbar-h: 68px;
}

html { scroll-behavior: smooth; overflow-x: clip; }
body {
    font-family: var(--font-sans);
    background: var(--bg-soft);
    color: var(--text-primary);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    overflow-x: clip;
}
a { color: inherit; text-decoration: none; }
ul, ol { list-style: none; }
img, svg { max-width: 100%; display: block; }
strong { font-weight: 650; }
button { font: inherit; color: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 4px; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.skip-link { position: absolute; top: -100%; left: 1rem; z-index: 1200; background: var(--ink); color: #fff; padding: .625rem 1rem; border-radius: var(--r-control); font-weight: 600; }
.skip-link:focus { top: 1rem; }

h1, h2, h3, h4 { font-family: var(--font-display); letter-spacing: -.02em; line-height: 1.2; }

/* ===== TYPE HELPERS ===== */
.t-eyebrow { font-family: var(--font-display); font-size: .72rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--accent); }
.t-muted { color: var(--text-muted); }
.t-sec { color: var(--text-secondary); }
.t-num { font-family: var(--font-display); font-weight: 700; letter-spacing: -.02em; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    font-family: var(--font-display); font-weight: 600; font-size: .9375rem;
    padding: .75rem 1.375rem; border-radius: var(--r-control);
    border: 2px solid transparent; cursor: pointer; white-space: nowrap;
    position: relative; overflow: hidden;
    transition: background-color .2s var(--ease), border-color .2s var(--ease),
                box-shadow .26s var(--ease), transform .26s var(--ease-spring), color .2s var(--ease);
}
.btn svg { flex-shrink: 0; }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--line); box-shadow: var(--neo-2); }
.btn-primary:hover { background: var(--accent-hover); transform: translate(-1px,-1px); box-shadow: var(--neo-3); }
.btn-primary:active { transform: translate(4px,4px); box-shadow: var(--neo-press); transition-duration: 90ms; }
.btn-secondary { background: #fff; color: var(--text-primary); border-color: var(--line); box-shadow: var(--neo-2); }
.btn-secondary:hover { color: var(--accent); transform: translate(-1px,-1px); box-shadow: var(--neo-3); }
.btn-secondary:active { transform: translate(4px,4px); box-shadow: var(--neo-press); transition-duration: 90ms; }
.btn-ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text-primary); }
.btn-danger { background: var(--danger); color: #fff; border-color: var(--line); box-shadow: var(--neo-2); }
.btn-danger:hover { transform: translate(-1px,-1px); box-shadow: var(--neo-3); }
.btn-danger:active { transform: translate(4px,4px); box-shadow: var(--neo-press); }
.btn-lg { font-size: 1.0625rem; padding: 1rem 2rem; }
.btn-sm { font-size: .8125rem; padding: .5rem .875rem; border-width: 2px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; box-shadow: var(--neo-1); }
.btn-icon { padding: .625rem; width: 42px; height: 42px; }
.ripple { position: absolute; border-radius: 50%; pointer-events: none; background: currentColor; opacity: .28; transform: scale(0); animation: ripple .55s var(--ease) forwards; }
@keyframes ripple { to { transform: scale(2.6); opacity: 0; } }

/* ===== CARD / PANEL ===== */
.card { background: #fff; border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--neo-2); }
.card-flat { background: #fff; border: 1px solid var(--border); border-radius: var(--r-card); box-shadow: var(--sh-1); }
.card-pad { padding: clamp(1.125rem, 2vw, 1.75rem); }
.panel { background: #fff; border: 2px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--neo-3); }
.divider { height: 1px; background: var(--border); border: 0; }

/* ===== BADGE / CHIP ===== */
.badge { display: inline-flex; align-items: center; gap: .375rem; font-family: var(--font-display); font-weight: 650; font-size: .72rem; letter-spacing: .02em; padding: .25rem .625rem; border-radius: var(--r-pill); border: 1.5px solid var(--line); background: #fff; line-height: 1.2; }
.badge-accent { background: var(--accent-soft); border-color: var(--accent-border); color: var(--accent-deep); }
.badge-success { background: var(--success-soft); border-color: var(--success); color: var(--success); }
.badge-danger { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }
.badge-warn { background: var(--warn-soft); border-color: var(--warn); color: var(--warn); }
.badge-muted { background: var(--bg-sunken); border-color: var(--border-strong); color: var(--text-secondary); }
.chip { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .8rem; border-radius: var(--r-pill); border: 2px solid var(--line); background: #fff; font-weight: 600; font-size: .8125rem; box-shadow: var(--neo-1); transition: transform .18s var(--ease), box-shadow .18s var(--ease), background .18s; }
.chip:hover { transform: translate(-1px,-1px); box-shadow: var(--neo-2); }
.chip[aria-pressed="true"], .chip.is-active { background: var(--accent); color: #fff; }

/* Instagram-style verified seal, used on every "our" claim */
.vf { width: 18px; height: 18px; flex-shrink: 0; display: block; }
.vf .seal { fill: var(--accent); }
.vf .tick { fill: none; stroke: #fff; stroke-width: 2.6; stroke-linecap: round; stroke-linejoin: round; }

/* ===== FORM CONTROLS ===== */
.field { margin-bottom: 1.125rem; }
.label { display: block; font-family: var(--font-display); font-weight: 600; font-size: .8125rem; margin-bottom: .4375rem; color: var(--text-primary); }
.hint { font-size: .78rem; color: var(--text-muted); margin-top: .375rem; }
.input, .select, .textarea {
    width: 100%; background: #fff; border: 2px solid var(--line); border-radius: var(--r-control);
    padding: .75rem .9375rem; font-size: .9375rem; box-shadow: var(--neo-1);
    transition: box-shadow .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--neo-2); }
.input::placeholder { color: var(--text-muted); }
.input-invalid { border-color: var(--danger) !important; }
.input-group { position: relative; display: flex; align-items: center; }
.input-group .input { padding-left: 2.75rem; }
.input-group .ig-icon { position: absolute; left: .9375rem; color: var(--text-muted); pointer-events: none; }
.input-group .ig-btn { position: absolute; right: .5rem; background: none; border: 0; color: var(--text-muted); padding: .4rem; border-radius: 8px; }
.input-group .ig-btn:hover { color: var(--accent); background: var(--accent-soft); }
.textarea { min-height: 110px; resize: vertical; }

/* Toggle switch */
.switch { position: relative; display: inline-flex; width: 46px; height: 27px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .track { position: absolute; inset: 0; background: #fff; border: 2px solid var(--line); border-radius: var(--r-pill); transition: background .2s var(--ease); }
.switch .thumb { position: absolute; top: 3px; left: 3px; width: 17px; height: 17px; background: var(--line); border-radius: 50%; transition: transform .22s var(--ease-spring), background .2s; }
.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track .thumb { transform: translateX(19px); background: #fff; }
.switch input:focus-visible + .track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Segmented control */
.segmented { display: inline-flex; background: var(--bg-sunken); border: 2px solid var(--line); border-radius: var(--r-pill); padding: 3px; gap: 2px; }
.segmented button { border: 0; background: none; padding: .45rem 1rem; border-radius: var(--r-pill); font-family: var(--font-display); font-weight: 600; font-size: .8125rem; color: var(--text-secondary); transition: background .2s, color .2s; }
/* aria-pressed, not aria-selected. `aria-selected` is only valid on roles that
   can be selected — tab, option, row, gridcell — and a plain <button> is none
   of them, so it was an invalid attribute the whole time (Lighthouse:
   "[aria-*] attributes do not match their roles"). These buttons toggle, and
   aria-pressed is the attribute for that. The settings tabs are genuine tabs
   and keep role="tab" with aria-selected. */
.segmented button[aria-pressed="true"] { background: #fff; color: var(--accent); box-shadow: var(--sh-1); }

/* ===== TABLE ===== */
.table-wrap { overflow-x: auto; border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--neo-2); background: #fff; }
table.tbl { width: 100%; border-collapse: collapse; min-width: 520px; }
table.tbl th { text-align: left; font-family: var(--font-display); font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); padding: .875rem 1rem; border-bottom: 2px solid var(--line); background: var(--bg-soft); }
table.tbl td { padding: .875rem 1rem; border-bottom: 1px solid var(--border); font-size: .9rem; }
table.tbl tr:last-child td { border-bottom: 0; }
table.tbl tbody tr:hover { background: var(--bg-soft); }

/* ===== TABS ===== */
.tabs { display: flex; gap: .25rem; border-bottom: 2px solid var(--border); overflow-x: auto; }
.tabs button { border: 0; background: none; padding: .75rem 1rem; font-family: var(--font-display); font-weight: 600; font-size: .875rem; color: var(--text-secondary); border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; transition: color .2s, border-color .2s; }
.tabs button[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }
.tab-panel[hidden] { display: none; }

/* ===== ACCORDION ===== */
.acc-item { border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--neo-1); background: #fff; margin-bottom: .75rem; overflow: hidden; }
.acc-head { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1.125rem 1.25rem; border: 0; background: none; text-align: left; font-family: var(--font-display); font-weight: 650; font-size: 1.0625rem; }
.acc-head .acc-ico { transition: transform .28s var(--ease); flex-shrink: 0; }
.acc-head[aria-expanded="true"] .acc-ico { transform: rotate(180deg); }
.acc-body { max-height: 0; overflow: hidden; transition: max-height .35s var(--ease); }
.acc-body-inner { padding: 0 1.25rem 1.25rem; color: var(--text-secondary); }

/* ===== TOOLTIP ===== */
.tt { position: relative; }
/* width:max-content with a cap, not white-space:nowrap. nowrap was fine while
   every tip was two words; the moment one carried a full sentence it became a
   single unbreakable line that pushed its own button 157px wider than the
   screen. Short tips still sit on one line — max-content sees to that. */
.tt::after { content: attr(data-tip); position: absolute; bottom: calc(100% + 8px); left: 50%; transform: translateX(-50%) translateY(4px); background: var(--ink); color: #fff; font-size: .75rem; font-weight: 500; line-height: 1.4; padding: .4rem .625rem; border-radius: 8px; width: max-content; max-width: min(15rem, calc(100vw - 2rem)); text-align: center; opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 60; box-shadow: var(--sh-2); }
.tt:hover::after, .tt:focus-visible::after { opacity: 1; transform: translateX(-50%) translateY(0); }
/* Two reasons to drop the tooltip, and they are different reasons.
   Touch: a hover tooltip is one nobody can open.
   Narrow: it is centred on its control, so anything near an edge pushes it off
   the viewport — the dashboard's first chip did exactly that. `overflow-x:
   clip` on the body stops the page scrolling, which means the tooltip is not a
   scrollbar but a sentence cut off by the screen edge, which is worse.
   Nothing is lost either way: the selected module's description prints in full
   under the input. Keyboard focus still shows it — that is a real way in. */
@media (hover: none), (max-width: 700px) {
    .tt::after { display: none; }
    .tt:focus-visible::after { display: block; }
}

/* ===== TOASTS ===== */
.toast-stack { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 1400; display: flex; flex-direction: column; gap: .625rem; max-width: min(92vw, 380px); }
.toast { display: flex; align-items: flex-start; gap: .75rem; background: #fff; border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--neo-3); padding: .875rem 1rem; animation: toastIn .4s var(--ease-spring) both; }
.toast .tico { flex-shrink: 0; margin-top: 1px; }
.toast.ok .tico { color: var(--success); }
.toast.err .tico { color: var(--danger); }
.toast.info .tico { color: var(--accent); }
.toast strong { font-family: var(--font-display); font-size: .9rem; display: block; }
.toast p { font-size: .82rem; color: var(--text-secondary); margin: 0; }
.toast .tclose { margin-left: auto; background: none; border: 0; color: var(--text-muted); padding: 2px; }
.toast.leaving { animation: toastOut .3s var(--ease) forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ===== MODAL / DIALOG ===== */
.modal-backdrop { position: fixed; inset: 0; z-index: 1300; background: rgba(7,12,22,.5); backdrop-filter: blur(3px); display: flex; align-items: center; justify-content: center; padding: 1.25rem; opacity: 0; pointer-events: none; transition: opacity .25s var(--ease); }
.modal-backdrop.open { opacity: 1; pointer-events: auto; }
.modal { background: #fff; border: 2px solid var(--line); border-radius: var(--r-panel); box-shadow: var(--neo-3); width: min(100%, 480px); max-height: 90vh; overflow-y: auto; transform: scale(.94) translateY(10px); transition: transform .3s var(--ease-spring); }
.modal-backdrop.open .modal { transform: none; }
.modal-head { padding: 1.375rem 1.5rem 0; }
.modal-body { padding: 1rem 1.5rem 1.5rem; }
.modal-foot { padding: 0 1.5rem 1.5rem; display: flex; gap: .625rem; justify-content: flex-end; }

/* ===== PROGRESS / METER ===== */
.progress { height: 8px; background: var(--bg-sunken); border: 1.5px solid var(--line); border-radius: var(--r-pill); overflow: hidden; }
.progress > i { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); transition: width .5s var(--ease); }
/* For work with no measurable progress. A bar parked at 35% claims a third of
   the job is done, which nothing has measured — the same small lie as a status
   dot that is green because it was typed green. This one only says "running". */
.progress.indeterminate > i { width: 40%; animation: prog-sweep 1.4s var(--ease) infinite; }
@keyframes prog-sweep { 0% { margin-left: -40%; } 100% { margin-left: 100%; } }
@media (prefers-reduced-motion: reduce) {
    .progress.indeterminate > i { animation: none; width: 100%; opacity: .45; }
}

.meter { display: flex; gap: 4px; }
.meter > i { flex: 1; height: 8px; border-radius: 3px; background: var(--bg-sunken); border: 1.5px solid var(--border-strong); }
.meter > i.on { background: var(--accent); border-color: var(--line); }
.meter.risk > i.on { background: var(--danger); }

/* "Soon" badge. Marks a control that is deliberately visible and deliberately
   inert, so nobody ships a switch that silently does nothing. Lives here rather
   than in auth.css because settings uses it too. */
.soon { display: inline-flex; align-items: center; gap: .3125rem; margin-left: .4375rem; font-family: var(--font-display); font-size: .625rem; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--warn); background: var(--warn-soft); border: 1.5px solid var(--warn); padding: .125rem .4375rem; border-radius: var(--r-pill); }

/* ===== SKELETON ===== */
.sk { background: linear-gradient(100deg, var(--bg-sunken) 30%, #f3f6fb 50%, var(--bg-sunken) 70%); background-size: 200% 100%; border-radius: 8px; animation: skly 1.3s ease-in-out infinite; }
@keyframes skly { to { background-position: -200% 0; } }
.sk-line { height: 12px; margin-bottom: .5rem; }
.sk-line.short { width: 55%; }

/* ===== APP SHELL: sidebar + topbar ===== */
.app { display: grid; grid-template-columns: var(--sidebar-w) 1fr; min-height: 100vh; }
.sidebar {
    grid-row: 1 / -1; background: #fff; border-right: 2px solid var(--line);
    display: flex; flex-direction: column; padding: 1rem .875rem;
    position: sticky; top: 0; height: 100vh; overflow-y: auto; z-index: 40;
}
.sb-brand { display: flex; align-items: center; gap: .625rem; padding: .5rem .625rem 1rem; font-family: var(--font-display); font-weight: 700; font-size: 1.125rem; letter-spacing: -.02em; }
.sb-brand .mark { width: 34px; height: 34px; flex-shrink: 0; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; margin-top: .5rem; }
.sb-section { font-family: var(--font-display); font-size: .68rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--text-muted); padding: 1rem .625rem .375rem; }
.sb-link { display: flex; align-items: center; gap: .75rem; padding: .625rem .625rem; border-radius: var(--r-control); color: var(--text-secondary); font-weight: 550; font-size: .9rem; transition: background .18s, color .18s; }
.sb-link svg { flex-shrink: 0; color: var(--text-muted); transition: color .18s; }
.sb-link:hover { background: var(--bg-soft); color: var(--text-primary); }
.sb-link:hover svg { color: var(--text-primary); }
.sb-link.active { background: var(--accent-soft); color: var(--accent-deep); font-weight: 650; }
.sb-link.active svg { color: var(--accent); }
.sb-link .sb-badge { margin-left: auto; }
.sb-foot { margin-top: auto; padding-top: 1rem; }
.sb-credits { background: var(--bg-soft); border: 2px solid var(--line); border-radius: var(--r-card); padding: .875rem; box-shadow: var(--neo-1); }

.topbar { position: sticky; top: 0; z-index: 30; height: var(--topbar-h); background: rgba(255,255,255,.9); backdrop-filter: blur(10px); border-bottom: 2px solid var(--line); display: flex; align-items: center; gap: 1rem; padding: 0 var(--page-gutter); }
.topbar .tb-title { font-family: var(--font-display); font-weight: 700; font-size: 1.0625rem; }
.topbar .tb-spacer { flex: 1; }
.tb-search { flex: 1; max-width: 420px; }
.tb-menu-btn { display: none; }
.avatar { width: 38px; height: 38px; border-radius: 50%; border: 2px solid var(--line); background: var(--accent-soft); color: var(--accent-deep); display: inline-flex; align-items: center; justify-content: center; font-family: var(--font-display); font-weight: 700; font-size: .85rem; box-shadow: var(--neo-1); overflow: hidden; }

.app-main { display: flex; flex-direction: column; min-width: 0; }
.app-body { padding: clamp(1.25rem, 3vw, 2.25rem) var(--page-gutter); max-width: 1200px; width: 100%; margin: 0 auto; }
/* The report opts out. 1200px is a reading width and it is right for the
   dashboard, settings and history — but the report is a card grid beside a
   320px rail, so that budget left the grid 776px and fitted two cards where
   the screen had room for four. A modifier rather than a second layout: one
   shell, one rule, and the pages that want a reading width keep it. */
.app-body.wide { max-width: 1560px; }
.page-head { margin-bottom: 1.5rem; }
.page-head h1 { font-size: clamp(1.5rem, 1.1rem + 1.6vw, 2.125rem); }
.page-head p { color: var(--text-secondary); margin-top: .375rem; }

/* Breadcrumb */
/* Same spacing decision as .crumb in page.css: without room above it, the
   trail reads as a second row of navigation instead of as this page's
   position. Smaller here because the app shell is denser than a marketing
   page. */
.crumbs { display: flex; align-items: center; gap: .5rem; font-size: .8125rem; color: var(--text-muted); margin-top: clamp(1rem, 3vh, 1.75rem); margin-bottom: .75rem; }
.crumbs a:hover { color: var(--accent); }
.crumbs .sep { opacity: .5; }

/* Grid helpers */
.grid { display: grid; gap: 1rem; }
/* minmax(0, 1fr), never a bare 1fr. A bare 1fr means minmax(auto, 1fr), so the
   column refuses to go below its content's minimum — one un-wrappable line
   inside a card then widens the whole grid past the screen. That is exactly
   what pushed the dashboard 56px off a 390px phone. */
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; }
.gap-sm { gap: .5rem; } .gap { gap: 1rem; } .gap-lg { gap: 1.5rem; }

/* Stat widget */
.stat { background: #fff; border: 2px solid var(--line); border-radius: var(--r-card); box-shadow: var(--neo-2); padding: 1.125rem 1.25rem; }
.stat .stat-ico { width: 40px; height: 40px; border-radius: var(--r-control); display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--line); background: var(--accent-soft); color: var(--accent); margin-bottom: .75rem; }
.stat .stat-val { font-family: var(--font-display); font-weight: 700; font-size: 1.875rem; letter-spacing: -.02em; line-height: 1; }
.stat .stat-lbl { color: var(--text-muted); font-size: .82rem; margin-top: .375rem; }
.stat .stat-delta { font-size: .78rem; font-weight: 650; margin-top: .5rem; display: inline-flex; align-items: center; gap: .25rem; }
.stat .stat-delta.up { color: var(--success); }
.stat .stat-delta.down { color: var(--danger); }

/* Empty state */
.empty { text-align: center; padding: clamp(2rem, 5vw, 4rem) 1.5rem; }
.empty .em-art { width: 84px; height: 84px; margin: 0 auto 1.25rem; border-radius: 50%; background: var(--accent-soft); border: 2px solid var(--line); display: flex; align-items: center; justify-content: center; color: var(--accent); box-shadow: var(--neo-2); }
.empty h3 { font-size: 1.25rem; margin-bottom: .5rem; }
.empty p { color: var(--text-secondary); max-width: 40ch; margin: 0 auto 1.25rem; }

/* Reveal on scroll. Marketing surfaces only — inside the app, content that is
   already loaded must never be hidden waiting for a scroll that may not come. */
.reveal { opacity: 0; transform: translateY(18px); transition: opacity .6s var(--ease), transform .7s var(--ease-spring); }
.reveal.in { opacity: 1; transform: none; }

/* App entrance. Runs once on load, staggered by source order, and leaves
   nothing hidden if the animation never fires. */
.enter { animation: enterUp .5s var(--ease) both; }
.enter:nth-child(1) { animation-delay: .02s; }
.enter:nth-child(2) { animation-delay: .07s; }
.enter:nth-child(3) { animation-delay: .12s; }
.enter:nth-child(4) { animation-delay: .17s; }
.enter:nth-child(5) { animation-delay: .22s; }
.enter:nth-child(6) { animation-delay: .27s; }
@keyframes enterUp { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .reveal { opacity: 1; transform: none; transition: none; }
    .enter { animation: none; }
    .sk { animation: none; }
}

/* Module icon chip (dashboard + results) */
.mod-chip { width: 44px; height: 44px; border-radius: var(--r-control); border: 2px solid var(--line); display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--neo-1); flex-shrink: 0; }
.mod-email  { background: var(--mod-email-soft);  color: var(--mod-email); }
.mod-phone  { background: var(--mod-phone-soft);  color: var(--mod-phone); }
.mod-name   { background: var(--mod-name-soft);   color: var(--mod-name); }
.mod-username{ background: var(--mod-username-soft); color: var(--mod-username); }
.mod-photo  { background: var(--mod-photo-soft);  color: var(--mod-photo); }
.mod-password{ background: var(--mod-password-soft); color: var(--mod-password); }

/* ===== RESPONSIVE ===== */
@media (max-width: 1024px) {
    :root { --sidebar-w: 0px; }
    .app { grid-template-columns: 1fr; }
    .sidebar { position: fixed; left: 0; top: 0; width: 280px; transform: translateX(-100%); transition: transform .3s var(--ease); box-shadow: var(--neo-3); }
    .sidebar.open { transform: none; }
    .tb-menu-btn { display: inline-flex; }
    .sidebar-scrim { position: fixed; inset: 0; background: rgba(7,12,22,.4); z-index: 39; opacity: 0; pointer-events: none; transition: opacity .3s; }
    .sidebar-scrim.show { opacity: 1; pointer-events: auto; }
}
@media (max-width: 860px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .grid-2, .grid-3, .grid-4 { grid-template-columns: minmax(0, 1fr); } .tb-search { display: none; } }

/* ============================================================================
   Dark theme
   Applied by [data-theme="dark"] on <html>, set before first paint by the
   inline snippet in each page's <head> — doing it from a deferred script would
   flash the light theme first.

   Not an inversion. A pure flip makes the black neomorphic edge invisible and
   turns every card into a floating rectangle, which is the one thing this
   design system is built around. So on dark the raised surface is LIGHTER than
   the page and the hard shadow stays black: the object still reads as sitting
   on something.
   ============================================================================ */
:root[data-theme="dark"] {
    --bg: #0E141F;
    --bg-soft: #0A0F18;
    --bg-sunken: #131B29;
    --ink: #05080E;

    /* Ratios measured against --bg-soft, the darkest surface text sits on. */
    --text-primary: #E8EDF5;   /* 14.8:1 */
    --text-secondary: #A9B6C9; /*  8.4:1 */
    --text-muted: #8494AA;     /*  5.4:1 */
    --text-onink: #E8EDF5;

    --border: #253247;
    --border-strong: #35455E;

    /* Cobalt darkens badly on a dark ground — it stops reading as the accent
       and starts reading as "disabled". Lifted, not shifted in hue. */
    --accent: #6E93FF;
    --accent-deep: #A9C0FF;
    --accent-hover: #89A7FF;
    --accent-soft: #16213A;
    --accent-border: #2F4570;

    --mod-email-soft: #16213A;
    --mod-phone: #4FD1C5;    --mod-phone-soft: #0D2725;
    --mod-name: #B98BFF;     --mod-name-soft: #1E1533;
    --mod-username: #FFAA5C; --mod-username-soft: #2A1B0C;
    --mod-photo: #FF7EB6;    --mod-photo-soft: #2E1220;
    --mod-password: #E8EDF5; --mod-password-soft: #131B29;
    --mod-email: #6E93FF;

    --danger: #FF8A80;  --danger-soft: #2B1210;
    --success: #6EE7B7; --success-soft: #08251B;
    --warn: #FFC46B;    --warn-soft: #2B1F09;

    /* The edge stays black. On a dark page it reads as depth rather than as a
       drawn line, which is exactly what it should. */
    --line: #05080E;
}

/* Cards are lighter than the page here, so the black edge has something to
   sit against. */
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .stat,
:root[data-theme="dark"] .acc-item,
:root[data-theme="dark"] .input,
:root[data-theme="dark"] .select,
:root[data-theme="dark"] .textarea,
:root[data-theme="dark"] .chip,
:root[data-theme="dark"] .badge,
:root[data-theme="dark"] .btn-secondary,
:root[data-theme="dark"] .sidebar,
:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .table-wrap,
:root[data-theme="dark"] table.tbl th,
:root[data-theme="dark"] .toast,
:root[data-theme="dark"] .modal,
:root[data-theme="dark"] .acc,
:root[data-theme="dark"] .row-item,
:root[data-theme="dark"] .mode,
:root[data-theme="dark"] .mod,
:root[data-theme="dark"] .segmented button[aria-pressed="true"],
:root[data-theme="dark"] .switch .track,
:root[data-theme="dark"] .progress,
:root[data-theme="dark"] .meter > i {
    background-color: var(--bg);
}

:root[data-theme="dark"] .topbar { background-color: rgba(14,20,31,.92); }
:root[data-theme="dark"] .card-flat { background-color: var(--bg); border-color: var(--border); }
:root[data-theme="dark"] .sk { background: linear-gradient(100deg, var(--bg-sunken) 30%, #1B2536 50%, var(--bg-sunken) 70%); background-size: 200% 100%; }

/* The dark verdict panel is the one element already dark in light mode; on a
   dark page it needs to separate from the background rather than merge. */
:root[data-theme="dark"] .verdict { background: var(--bg); }

:root[data-theme="dark"] .btn-primary { color: #0A0F18; }
:root[data-theme="dark"] .switch input:checked + .track .thumb { background: #0A0F18; }
