/* ────────────────────────────────────────────────────────────────
   Sentrint — shared app stylesheet (design tokens + app-wide chrome)
   Theme: EDITORIAL MINIMAL — one flat midnight surface, hairline rules,
   Spectral serif, IBM Plex Mono labels, a single rationed brass accent.

   Extracted verbatim from the old inline partials so every page shares
   ONE cached file instead of re-shipping 180 lines of CSS per document:
     - partials/_tokens.html      (design tokens + base resets + buttons)
     - partials/_app_styles.html  (page-agnostic app chrome)
   Referenced as /static/app.css?v=<release> — cached immutable, busted
   per deploy. Page-local styles stay inline in each template.
   ──────────────────────────────────────────────────────────────── */

  :root {
    /* ── Surfaces (Apple Cinematic Depth) ── */
    --bg: #030509;          /* page — flat midnight (landing --bg)        */
    --bg-warm: #010204;     /* deepest — insets / footer                  */
    --surface: #12141b;     /* cards — SOLID so the dot-grid canvas can't bleed through */
    --surface-2: #1a1e29;   /* secondary fill / hover                                   */
    --white: rgba(255, 255, 255, 0.16);       /* brightest raised surface      */

    /* ── Borders (ivory hairlines — the primary structural device) ────── */
    --border: rgba(255, 255, 255, 0.10);
    --border-2: rgba(255, 255, 255, 0.16);

    /* ── Ink (ivory + slate ramp on midnight) ───────────────────────── */
    --ink: #e8e6da;         /* headings / primary  (never pure white)     */
    --ink-2: #b9c2d2;       /* body                                       */
    --ink-3: #8a93a6;       /* muted                                      */
    --ink-4: #535d72;       /* faint (placeholder / labels)               */

    /* ── Brand ──────────────────────────────────────────────────────── */
    --accent: #c9a45b;      /* brass — actions, links, highlights          */
    --accent-deep: #04060b; /* deepest navy — tooltip / footer bg          */
    --accent-soft: rgba(201,164,91,.12); /* brass tint — fills, chips, badges */
    --accent-hover: #0f1b2e;/* dark navy — solid buttons invert to this    */
    --cream: #0b1424;       /* dark navy — text that sits on brass         */

    /* ── Severity scale (legible on midnight) ───────────────────────── */
    --crit: #e0796b;   --crit-bg: #241317;   --crit-line: #4a2a2c;
    --high: #db9450;   --high-bg: #241c12;   --high-line: #4a3a20;  /* amber  */
    --med:  #d9c062;   --med-bg:  #221f12;   --med-line:  #46401f;  /* gold   */
    --low:  #8fb38a;   --low-bg:  #10201a;                          /* sage   */
    --ok:   #8fb38a;                                                /* success */

    --crit-text: #e0796b; --high-text: #db9450; --med-text: #d9c062;

    /* ── Layout ─────────────────────────────────────────────────────────
       ONE page width for the whole product. Every top-level container reads
       this token so the frame never drifts between surfaces: the eye tracks a
       single left edge from the landing page through the dashboard to /terms.
       Standalone heads that don't load this file (index, pricing, the wiki,
       _legal_base) mirror the value in their own :root — keep them in sync. */
    --page-max: 1120px;

    /* ── Radii (Squircles / Apple style) ─────────── */
    --r-xs: 4px; --r-sm: 6px; --r-md: 8px; --r-lg: 12px; --r-xl: 16px;

    /* ── Elevation (soft cast shadows on midnight) ──────────────────── */
    --shadow-sm: 0 4px 16px -4px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255,255,255,0.02);
    --shadow-md: 0 12px 32px -8px rgba(0, 0, 0, 0.6), inset 0 1px 0 rgba(255,255,255,0.05);
    --shadow-pop: 0 24px 58px -12px rgba(0, 0, 0, 0.8), inset 0 1px 0 rgba(255,255,255,0.08);

    /* ── Type (Editorial Minimal: Spectral display, Plex Sans body) ── */
    --serif: "Spectral", Georgia, serif;                 /* headings — editorial */
    --sans: "IBM Plex Sans", -apple-system, system-ui, sans-serif; /* body / UI / tables */
    --mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace; /* labels / buttons / meta */

    /* ── Theme-swapped surfaces (these can't be literals — light mode needs them) ── */
    --btn-face: rgba(255,255,255,0.02);   /* outline-button fill                 */
    --accent-lift: #e5c47d;               /* brass, one step up — primary :hover */
    --ring-track: rgba(232,230,218,.16);  /* unfilled arc of the grade dial      */
    --popover: rgba(255,255,255,0.05);    /* menus / tooltips — blurred, floating */

    color-scheme: dark;
  }

  /* ── LIGHT THEME ────────────────────────────────────────────────────────────
     The same brand at noon, not a white default: bone paper instead of midnight,
     the midnight itself demoted to ink, and the brass deepened to #8a6a24 so a
     link still clears 4.5:1 on paper (the #c9a45b brass does not — it's a
     dark-surface colour). Set by [data-theme] on <html>; the inline script in
     partials/_theme.html stamps it before first paint, so there's no flash.
     Structure, spacing and type are untouched — only the surfaces invert. */
  html[data-theme="light"] {
    --bg: #f6f4ef;          /* page — bone paper                          */
    --bg-warm: #ebe7dd;     /* deepest — insets / footer                  */
    --surface: #ffffff;     /* cards — paper on paper, held by a hairline */
    --surface-2: rgba(16, 21, 31, 0.05);
    --white: #ffffff;

    --border: rgba(16, 21, 31, 0.12);
    --border-2: rgba(16, 21, 31, 0.20);

    --ink: #10151f;         /* headings — the old page bg, now the ink    */
    --ink-2: #38414f;
    --ink-3: #6a7382;
    --ink-4: #99a1ad;

    --accent: #8a6a24;      /* deep brass — legible on paper              */
    --accent-deep: #ffffff;
    --accent-soft: rgba(138, 106, 36, .10);
    --accent-hover: #f0ece1;
    --accent-lift: #6f5419; /* brass darkens (not lightens) on paper      */
    --cream: #fdfbf5;       /* text that sits on brass                    */

    --crit: #a9372a;   --crit-bg: #fbeeeb;   --crit-line: #eccfc9;
    --high: #8c5715;   --high-bg: #fbf2e6;   --high-line: #ebd9bf;
    --med:  #75620f;   --med-bg:  #faf5e0;   --med-line:  #e6ddb9;
    --low:  #3c6a41;   --low-bg:  #edf4ec;
    --ok:   #3c6a41;

    --crit-text: #a9372a; --high-text: #8c5715; --med-text: #75620f;

    --shadow-sm: 0 1px 2px rgba(16, 21, 31, 0.06), 0 2px 8px -4px rgba(16, 21, 31, 0.08);
    --shadow-md: 0 4px 16px -6px rgba(16, 21, 31, 0.12), 0 1px 2px rgba(16, 21, 31, 0.05);
    --shadow-pop: 0 18px 44px -14px rgba(16, 21, 31, 0.22), 0 2px 6px rgba(16, 21, 31, 0.06);

    --btn-face: #ffffff;
    --ring-track: rgba(16, 21, 31, .12);
    /* A translucent white popover disappears on paper — this one is opaque. */
    --popover: #ffffff;

    color-scheme: light;
  }

  /* Currency: the .money / .cur-switch rules live in partials/_currency.html, next
     to the script that stamps html[data-currency] — the marketing pages don't load
     this stylesheet, and one copy of that logic is the whole point. */

  /* ── Base resets (shared) ─────────────────────────────────── */
  *, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
  html { -webkit-text-size-adjust: 100%; }
  body {
    font-family: var(--sans);
    font-weight: 400;
    background-color: var(--bg);   /* one flat surface — no dot-grid, no grain */
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
  }
  a { color: inherit; text-decoration: none; }
  button { font-family: inherit; cursor: pointer; }
  img, svg { display: block; max-width: 100%; }
  ::selection { background: var(--accent); color: var(--cream); }
  :focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; border-radius: var(--r-xs); }

  /* ── conic grade ring (the signature score dial) ──────────────────────────
     Usage: a .grade-ring div with inline --ga (sweep angle = score/100*360deg)
     and --gc (ring colour). --gh overrides the donut-hole fill to match whatever
     surface the ring sits on (defaults to the page bg). */
  @property --ga { syntax: "<angle>"; initial-value: 0deg; inherits: false; }
  .grade-ring { position: relative; border-radius: 50%; display: grid; place-items: center;
    flex-shrink: 0; --ga: 0deg; --gc: var(--accent);
    /* The unfilled arc is a dim echo of the grade colour, never a neutral void.
       A low score then reads as a near-empty tank — grave and deliberate — not a
       broken donut with a random dark gap (Apple Activity-ring principle). */
    background: conic-gradient(var(--gc) var(--ga),
      var(--gc-track, color-mix(in srgb, var(--gc) 20%, transparent)) var(--ga));
    animation: gradeDraw 1.1s cubic-bezier(.22, 1, .36, 1) .12s backwards; }
  @keyframes gradeDraw { from { --ga: 0deg; } }
  .grade-ring::before { content: ""; position: absolute; inset: 5px; border-radius: 50%;
    background: var(--gh, var(--bg)); }
  .grade-ring > * { position: relative; line-height: 1; }
  @media (prefers-reduced-motion: reduce) { .grade-ring { animation: none; } }

  /* ── Buttons — ONE shared CTA system for every signed-in page ──────────────
     Matches the landing sign-in button: square, IBM Plex Mono, uppercase, a
     single rationed brass accent. `.btn` is the outline (secondary) default;
     add `.btn-primary` for the brass solid. Feedback is a quiet press-settle
     on :active plus colour shifts — no sheen or bounce, so the chrome stays
     calm. `.btn-sm` for compact in-table actions. Page-local button classes
     were removed in favour of this. */
  .btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px;
    height: 42px; padding: 0 22px; border: 1px solid var(--border-2); border-radius: var(--r-md);
    background: var(--btn-face); color: var(--ink); font-family: var(--mono); font-size: 12px;
    font-weight: 500; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap;
    transition: background .2s ease, color .2s ease, border-color .2s ease, transform .1s ease;
    backdrop-filter: blur(10px); }
  .btn:active { transform: scale(0.97); }
  .btn:hover { border-color: var(--accent); color: var(--accent); }
  .btn svg { width: 15px; height: 15px; flex: none; }
  
  .btn-primary { background: var(--accent); border-color: var(--accent); color: var(--cream); }
  .btn-primary:hover { background: var(--accent-lift); border-color: var(--accent-lift); color: var(--cream); }
  /* Primary CTAs get a soft brass halo on keyboard focus — same accent,
     just enough glow to say "this is the one action on the page". */
  .btn-primary:focus-visible { box-shadow: 0 0 0 4px var(--accent-soft); }
  @media (prefers-reduced-motion: reduce) {
    .btn:active { transform: none; }
  }

  /* Universal quiet press — every button-like control (not just .btn) settles
     3% on press, so the whole app shares one tactile language. Deliberately
     tiny: no bounce, no sheen. Page-local button classes and raw <button>s opt
     in here; reduced-motion drops the transform. */
  button, .sb-btn, .si-link, .si-cancel, .rec-cta, .pgbtn, .newscan, .gh-grant-btn,
  .filter-chip, .sev-cell.clickable {
    transition: transform .1s ease, background .16s ease, border-color .16s ease, color .16s ease;
  }
  button:active, .sb-btn:active, .si-link:active, .si-cancel:active, .rec-cta:active,
  .pgbtn:active, .newscan:active, .gh-grant-btn:active, .filter-chip:active,
  .sev-cell.clickable:active {
    transform: scale(0.97);
  }
  @media (prefers-reduced-motion: reduce) {
    button:active, .sb-btn:active, .si-link:active, .si-cancel:active, .rec-cta:active,
    .pgbtn:active, .newscan:active, .gh-grant-btn:active, .filter-chip:active,
    .sev-cell.clickable:active { transform: none; }
  }

  /* ── Magic Button (Animated Gradient Border & Text) ── */
  .btn-magic {
    position: relative; background: transparent !important; border: none !important; z-index: 1; overflow: visible;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    /* Apply gradient to text directly */
    background: linear-gradient(90deg, #a6c0fe, #b8d8d8, #f6d365, #a6c0fe);
    background-size: 200% auto;
    -webkit-background-clip: text !important;
    -webkit-text-fill-color: transparent !important;
    animation: shimmer-bg 3s linear infinite;
  }
  .btn-magic::before {
    content: ""; position: absolute; inset: 0; border-radius: inherit; padding: 1px;
    background: linear-gradient(90deg, #a6c0fe, #b8d8d8, #f6d365, #a6c0fe);
    background-size: 200% auto; animation: shimmer-bg 3s linear infinite;
    -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor; mask-composite: exclude; z-index: -1; pointer-events: none;
  }
  .btn-magic svg { animation: icon-shimmer 3s linear infinite; }
  .btn-magic:hover { box-shadow: 0 6px 20px rgba(166,192,254,0.15); transform: translateY(-1px); }
  @keyframes shimmer-bg { to { background-position: 200% center; } }
  @keyframes icon-shimmer {
    0%, 100% { stroke: #a6c0fe; }
    33% { stroke: #b8d8d8; }
    66% { stroke: #f6d365; }
  }

  .btn-sm { height: 34px; padding: 0 14px; font-size: 11px; gap: 7px; }
  .btn-sm svg { width: 13px; height: 13px; }
  /* destructive (e.g. Sign out): quiet by default, soft light-red on hover. */
  .btn.danger:hover { border-color: var(--crit); color: var(--crit); background: rgba(224,121,107,.10); }
  .btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; }

/* ── Shared app chrome (page-agnostic, used by 2+ app pages) ── */
  /* ── Row actions (scans list; archived list) ──────────────────────────────
     Quiet by default and only resolving on hover: a row's subject is the scan,
     not the controls, so the controls stay out of the way until aimed at. There
     is no box-shadow here on purpose — every state change is carried by surface
     colour and the hairline border, which is how the rest of this theme builds
     depth. Icon-only + tooltip rather than labels: at 100 rows, words repeated
     100 times are noise, and the shapes are learnable in one glance. */
  .actions { display: flex; align-items: center; gap: 4px; justify-content: flex-end; }
  .iconbtn {
    width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid transparent; border-radius: var(--r-sm); background: none; color: var(--ink-3);
    transition: background .12s ease, color .12s ease, border-color .12s ease;
  }
  .iconbtn:hover { background: var(--surface-2); color: var(--accent); border-color: var(--border); }
  .iconbtn.danger:hover { background: var(--crit-bg); color: var(--crit); border-color: var(--crit-line); }
  /* Also the locked state for a plan-gated action: legible, obviously inert,
     and still hoverable at the wrapper so its tooltip can explain why. */
  .iconbtn[disabled] { opacity: .35; pointer-events: none; }
  /* in-flight HTMX action: block re-clicks; the rescan button spins its own
     refresh icon as a contextual loader */
  @keyframes spin { to { transform: rotate(360deg); } }
  .iconbtn.htmx-request { pointer-events: none; color: var(--accent); }
  .iconbtn.rescan.htmx-request svg { animation: spin .8s linear infinite; }
  /* archive/delete take a moment server-side (row + findings + events cascade).
     Swap the icon for a ring spinner while in flight so the click feels alive. */
  .iconbtn .ib-spin { display: none; width: 16px; height: 16px; border-radius: 50%;
    border: 2px solid var(--border); border-top-color: var(--accent); }
  .iconbtn.ib-loader.htmx-request > svg { display: none; }
  .iconbtn.ib-loader.htmx-request .ib-spin { display: block; animation: spin .7s linear infinite; }
  .iconbtn.danger.ib-loader.htmx-request .ib-spin { border-top-color: var(--crit); }
  @media (prefers-reduced-motion: reduce) { .iconbtn.ib-loader.htmx-request .ib-spin { animation: none; } }

  /* tooltip */
  .tip { position: relative; }
  .tip::after {
    content: attr(data-tip); position: absolute; bottom: calc(100% + 7px); right: 50%; transform: translateX(50%) translateY(3px);
    background: var(--accent-deep); color: var(--ink); font-family: var(--mono); font-size: 10px; letter-spacing: 0.03em;
    padding: 4px 8px; border-radius: 5px; white-space: nowrap; opacity: 0; pointer-events: none; transition: opacity .14s ease, transform .14s ease;
    z-index: 5;
  }
  .tip:hover::after { opacity: 1; transform: translateX(50%) translateY(0); }

  /* ── background halftone texture ────────────────────────────────────────────
     The system-wide dot wave is now drawn on a <canvas> in _topbar.html (which
     every app page includes), so the dots can grow in SIZE toward the bottom —
     a true halftone gradient a uniform CSS dot-grid can't reproduce. Nothing to
     style here; see the .app-halftone canvas + renderer in _topbar.html. */

  /* ── status chips ── */
.status-chip { display: inline-flex; align-items: center; justify-content: center; height: 24px; padding: 0 10px; border-radius: var(--r-xs); font-family: var(--mono); font-size: 10.5px; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1; }
.status-chip.done { background: var(--low-bg); color: var(--ok); border: 1px solid var(--border-2); }
.status-chip.failed { background: var(--crit-bg); color: var(--crit); border: 1px solid var(--crit-line); }
.status-chip.running { background: var(--surface-2); color: var(--ink-3); border: 1px solid var(--border-2); }

/* ── filter chips ── */
.filter-chip { font-family: var(--mono); font-size: 10.5px; text-transform: uppercase; letter-spacing: 0.08em; font-weight: 500; padding: 5px 12px; border-radius: var(--r-xs); background: transparent; border: 1px solid var(--border); color: var(--ink-3); cursor: pointer; transition: all .15s ease; }
.filter-chip:hover { border-color: var(--border-2); color: var(--ink-2); }
.filter-chip.active { background: var(--surface-2); color: var(--ink); border-color: var(--border-2); }

  /* ── Page head (admin, feedback, scans, settings) ─────────────────── */
  .ph { padding: 40px 0 12px; }
  .ph .eyebrow { font-family: var(--mono); font-size: 11.5px; font-weight: 600; letter-spacing: 0.18em;
    text-transform: uppercase; color: var(--ink-3); }
  .ph h1 { font-family: var(--serif); font-weight: 300; font-size: clamp(32px, 4vw, 44px);
    letter-spacing: -0.02em; color: var(--ink); line-height: 1.1; margin-top: 10px; }
  .ph h1 em { font-style: italic; color: var(--accent); }

  /* ── Entrance reveal keyframe + stagger delays (dashboard, feedback,
       scans, settings). The `.anim` base itself stays page-local because
       its easing/duration differs per page; these delay helpers out-specify
       `.anim` so cascade order is irrelevant. ────────────────────────── */
  @keyframes rise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
  .anim.d1 { animation-delay: .04s; }
  .anim.d2 { animation-delay: .10s; }
  .anim.d3 { animation-delay: .16s; }
  .anim.d4 { animation-delay: .22s; }
  .anim.d5 { animation-delay: .28s; }
