/* ============================================================================
   FARPSEC design system
   Concept: the instrument panel of a research lab — disciplined, measured,
   one confident accent (signal amber). Severity red is semantic only.
   ============================================================================ */

:root {
  /* palette — light (warm off-white paper, not clinical white) */
  --ink:        #1b1a17;
  --ink-soft:   #625d54;
  --ink-faint:  #938c80;
  --paper:      #f4f1ea;   /* warm off-white ground */
  --surface:    #fbf8f2;   /* cards: soft off-white, never pure #fff */
  --line:       #e6e0d4;
  --line-soft:  #efeae0;
  --accent:     #cf8a24;   /* signal amber, tuned for warm paper */
  --accent-ink: #855312;
  --sev:        #c8443c;   /* severity red — semantic only */
  --ok:         #2f855f;
  --code-bg:    #efe9dd;

  --shadow: 0 1px 2px rgba(18,22,28,.04), 0 8px 30px rgba(18,22,28,.06);

  --font-display: "Space Grotesk", ui-sans-serif, system-ui, sans-serif;
  --font-body: "IBM Plex Sans", ui-sans-serif, system-ui, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", Menlo, monospace;

  --measure: 68ch;
  --rail: clamp(20px, 6vw, 96px);
}

:root[data-theme="dark"],
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink:       #e7ebf1;
    --ink-soft:  #9aa4b2;
    --ink-faint: #6b7583;
    --paper:     #0e1218;
    --surface:   #161b23;
    --line:      #262d38;
    --line-soft: #1c222b;
    --accent:    #e8b84b;
    --accent-ink:#f3d488;
    --sev:       #e5605b;
    --ok:        #58c9a3;
    --code-bg:   #1b212a;
    --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 40px rgba(0,0,0,.35);
  }
}
:root[data-theme="dark"] {
  --ink:#e7ebf1; --ink-soft:#9aa4b2; --ink-faint:#6b7583;
  --paper:#0e1218; --surface:#161b23; --line:#262d38; --line-soft:#1c222b;
  --accent:#e8b84b; --accent-ink:#f3d488; --sev:#e5605b; --ok:#58c9a3; --code-bg:#1b212a;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 12px 40px rgba(0,0,0,.35);
}

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.6;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---- typography ---------------------------------------------------------- */
h1, h2, h3, h4 { font-family: var(--font-display); font-weight: 600; line-height: 1.12; letter-spacing: -0.01em; margin: 0 0 .5em; color: var(--ink); }
h1 { font-size: clamp(2.1rem, 5vw, 3.4rem); letter-spacing: -0.025em; }
h2 { font-size: clamp(1.5rem, 3vw, 2.1rem); }
h3 { font-size: 1.2rem; }
p { margin: 0 0 1rem; max-width: var(--measure); }
a { color: var(--ink); text-decoration-color: var(--line); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--accent); }
strong { font-weight: 600; }
small { font-size: .8rem; }
code, kbd, pre { font-family: var(--font-mono); }
.mono { font-family: var(--font-mono); }
.muted { color: var(--ink-soft); }
.faint { color: var(--ink-faint); }

/* ---- layout shell -------------------------------------------------------- */
.wrap { max-width: 1120px; margin: 0 auto; padding-inline: var(--rail); }
.site-main { padding-block: clamp(40px, 7vw, 88px); min-height: 60vh; }
.stack > * + * { margin-top: var(--sp, 1rem); }
.row { display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
section + section { margin-top: clamp(48px, 8vw, 104px); }

/* ---- top bar ------------------------------------------------------------- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar__inner { display: flex; align-items: center; gap: 28px; height: 62px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-family: var(--font-display); font-weight: 700; font-size: 1.05rem; letter-spacing: .02em; text-decoration: none; color: var(--ink); }
.brand__mark { width: 13px; height: 13px; background: var(--accent); border-radius: 2px; box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent); }
.nav { display: flex; gap: 22px; margin-left: auto; align-items: center; }
.nav a { font-size: .92rem; color: var(--ink-soft); text-decoration: none; }
.nav a:hover, .nav a.is-active { color: var(--ink); }
.nav a.is-active { box-shadow: inset 0 -2px 0 var(--accent); padding-bottom: 3px; }

/* ---- buttons ------------------------------------------------------------- */
.btn { display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-body); font-weight: 500; font-size: .92rem; padding: 9px 16px; border-radius: 8px; border: 1px solid var(--ink); background: var(--ink); color: var(--paper); cursor: pointer; text-decoration: none; transition: transform .06s ease, opacity .15s ease; }
.btn:hover { opacity: .9; }
.btn:active { transform: translateY(1px); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn--ghost:hover { border-color: var(--ink-soft); opacity: 1; }
.btn--accent { background: var(--accent); border-color: var(--accent); color: #17140b; }
.btn--danger { background: transparent; color: var(--sev); border-color: color-mix(in srgb, var(--sev) 40%, var(--line)); }
.btn--sm { padding: 6px 12px; font-size: .85rem; }

/* ---- forms --------------------------------------------------------------- */
label { display: block; font-size: .82rem; font-weight: 500; color: var(--ink-soft); margin-bottom: 6px; }
input[type=text], input[type=email], input[type=password], select, textarea {
  width: 100%; font-family: inherit; font-size: .95rem; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
}
textarea { line-height: 1.55; resize: vertical; }
input:focus, select:focus, textarea:focus, [contenteditable]:focus, .btn:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; border-color: transparent;
}
.field { margin-bottom: 16px; }
.hint { font-size: .8rem; color: var(--ink-faint); margin: 6px 0 0; }

/* ---- panels & rules ------------------------------------------------------ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(18px, 3vw, 28px); }
.rule { height: 1px; background: var(--line); border: 0; margin: 0; }
.eyebrow { font-size: .8rem; font-weight: 600; color: var(--accent-ink); margin: 0 0 8px; }
.lede { font-size: 1.15rem; color: var(--ink-soft); max-width: var(--measure); }

/* ---- tags / badges ------------------------------------------------------- */
.tag { display: inline-flex; align-items: center; gap: 6px; font-size: .78rem; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--line-soft); color: var(--ink-soft); border: 1px solid var(--line); }
.tag--sev { color: var(--sev); border-color: color-mix(in srgb, var(--sev) 35%, var(--line)); background: color-mix(in srgb, var(--sev) 8%, transparent); }
.tag--ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); }
.tag--warn { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 35%, var(--line)); }
.cve { font-family: var(--font-mono); font-size: .82rem; color: var(--sev); }

/* ---- intelligence feed --------------------------------------------------- */
.feed { border-top: 1px solid var(--line); }
.feed__item { display: block; padding: 22px 0; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.feed__item:hover { background: linear-gradient(90deg, color-mix(in srgb, var(--accent) 6%, transparent), transparent 40%); }
.feed__meta { display: flex; gap: 12px; align-items: baseline; font-size: .8rem; color: var(--ink-faint); font-family: var(--font-mono); margin-bottom: 6px; }
.feed__title { font-family: var(--font-display); font-weight: 600; font-size: 1.35rem; line-height: 1.2; margin: 0 0 6px; }
.feed__item:hover .feed__title { color: var(--accent-ink); }
.feed__sum { color: var(--ink-soft); max-width: var(--measure); margin: 0; }

/* ---- prose (rendered markdown) ------------------------------------------- */
.prose { max-width: var(--measure); }
.prose > * + * { margin-top: 1.1rem; }
.prose h2 { margin-top: 2.2rem; }
.prose h3 { margin-top: 1.6rem; }
.prose a { color: var(--accent-ink); text-decoration-color: color-mix(in srgb, var(--accent) 50%, transparent); }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li + li { margin-top: .3rem; }
.prose blockquote { margin: 1.4rem 0; padding: 4px 0 4px 20px; border-left: 3px solid var(--accent); color: var(--ink-soft); }
.prose code { background: var(--code-bg); padding: 2px 6px; border-radius: 5px; font-size: .88em; }
.prose pre.code { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: 16px 18px; overflow-x: auto; }
.prose pre.code code { background: none; padding: 0; font-size: .86rem; line-height: 1.55; }
.prose img { max-width: 100%; border-radius: 10px; border: 1px solid var(--line); }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 2rem 0; }
.prose table { width: 100%; border-collapse: collapse; font-size: .88rem; margin: 1.2rem 0; overflow-x: auto; display: block; max-width: 100%; }
.prose thead { border-bottom: 2px solid var(--line); }
.prose th { text-align: left; font-weight: 600; font-size: .8rem; letter-spacing: .03em; color: var(--ink); padding: 10px 14px; white-space: nowrap; background: color-mix(in srgb, var(--surface) 80%, var(--line)); }
.prose td { padding: 9px 14px; border-bottom: 1px solid var(--line-soft); color: var(--ink-soft); vertical-align: top; }
.prose tbody tr:hover td { background: color-mix(in srgb, var(--accent) 4%, var(--surface)); }
.prose td code, .prose th code { font-size: .82em; }
.prose td strong, .prose th strong { color: var(--ink); }

/* ---- tables -------------------------------------------------------------- */
table.fp { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.fp th { text-align: left; font-weight: 500; color: var(--ink-faint); font-size: .78rem; padding: 8px 10px; border-bottom: 1px solid var(--line); }
table.fp td { padding: 11px 10px; border-bottom: 1px solid var(--line-soft); }
table.fp tr:hover td { background: var(--line-soft); }

/* ---- flash --------------------------------------------------------------- */
.flash { padding: 11px 16px; border-radius: 10px; margin-bottom: 16px; font-size: .92rem; border: 1px solid var(--line); }
.flash--success { background: color-mix(in srgb, var(--ok) 10%, transparent); border-color: color-mix(in srgb, var(--ok) 35%, var(--line)); color: var(--ok); }
.flash--error { background: color-mix(in srgb, var(--sev) 9%, transparent); border-color: color-mix(in srgb, var(--sev) 35%, var(--line)); color: var(--sev); }

/* ---- footer -------------------------------------------------------------- */
.site-footer { border-top: 1px solid var(--line); margin-top: 96px; padding-block: 40px; color: var(--ink-faint); font-size: .88rem; }
.site-footer a { color: var(--ink-soft); text-decoration: none; }
.site-footer a:hover { color: var(--ink); }

/* ---- page head ----------------------------------------------------------- */
.page-head { margin-bottom: clamp(28px, 5vw, 48px); }

/* ---- utilities ----------------------------------------------------------- */
.theme-toggle { background: none; border: 1px solid var(--line); border-radius: 8px; width: 34px; height: 34px; cursor: pointer; color: var(--ink-soft); display: inline-flex; align-items: center; justify-content: center; }
.theme-toggle:hover { color: var(--ink); border-color: var(--ink-soft); }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: clamp(20px, 4vw, 40px); }
@media (min-width: 760px) { .grid-2 { grid-template-columns: 1.4fr 1fr; } }

/* ============================================================================
   APP SHELL — the operator console (portal + admin). A grounded dark rail on
   the left, a dense content plane on the right. Deliberately NOT the editorial
   public layout: this is the instrument panel behind the site.
   ============================================================================ */
:root {
  --rail-bg:   #0f1319;
  --rail-line: #232b36;
  --rail-ink:  #c7ceda;
  --rail-dim:  #77808f;
}
.app { background: var(--paper); }
.app-shell { display: grid; grid-template-columns: 1fr; min-height: 100vh; }
@media (min-width: 880px) { .app-shell { grid-template-columns: 248px 1fr; } }

.rail {
  background: var(--rail-bg);
  color: var(--rail-ink);
  display: flex; flex-direction: column;
  padding: 20px 16px;
  border-right: 1px solid var(--rail-line);
}
@media (min-width: 880px) { .rail { position: sticky; top: 0; height: 100vh; } }

.rail__brand { display: inline-flex; align-items: center; gap: 10px; color: #fff; text-decoration: none;
  font-family: var(--font-display); font-weight: 700; letter-spacing: .02em; font-size: 1.05rem; padding: 6px 10px 16px; }
.rail__brand .brand__mark { width: 12px; height: 12px; background: var(--accent); border-radius: 2px; }
.rail__tag { font-size: .62rem; font-weight: 600; letter-spacing: .12em; color: var(--rail-bg); background: var(--accent); padding: 2px 6px; border-radius: 4px; margin-left: 2px; }

.rail__section { font-family: var(--font-mono); font-size: .68rem; letter-spacing: .12em; color: var(--rail-dim); padding: 12px 10px 8px; text-transform: uppercase; }

.rail-nav { display: flex; flex-direction: column; gap: 1px; }
.rail-nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 9px 10px; border-radius: 8px; text-decoration: none; color: var(--rail-ink);
  font-size: .93rem; font-weight: 500; border-left: 2px solid transparent; }
.rail-nav a:hover { background: rgba(255,255,255,.05); color: #fff; }
.rail-nav a.is-active { background: rgba(232,184,75,.12); color: #fff; border-left-color: var(--accent); border-radius: 0 8px 8px 0; }
.side-badge { background: var(--accent); color: #17140b; border-radius: 999px; font-size: .7rem; font-weight: 700; padding: 0 7px; line-height: 1.55; }

.rail__foot { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--rail-line); display: flex; flex-direction: column; gap: 2px; }
.rail__foot a, .rail__foot .linkish { color: var(--rail-dim); text-decoration: none; font-size: .86rem; padding: 6px 10px; border: 0; background: none; text-align: left; cursor: pointer; font-family: inherit; border-radius: 7px; }
.rail__foot a:hover, .rail__foot .linkish:hover { color: #fff; background: rgba(255,255,255,.05); }

/* content plane */
.app-main { min-width: 0; display: flex; flex-direction: column; }
.app-topline { display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 0 clamp(20px, 4vw, 44px); height: 56px; border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--paper) 85%, transparent); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20; }
.app-topline .crumb { font-family: var(--font-mono); font-size: .8rem; color: var(--ink-faint); }
.app-topline .crumb b { color: var(--ink); font-weight: 500; }
.app-content { padding: clamp(22px, 4vw, 40px) clamp(20px, 4vw, 44px); max-width: 1080px; width: 100%; }

/* console page header */
.console-head { margin-bottom: 24px; }
.console-head h1 { font-size: clamp(1.5rem, 3vw, 1.9rem); margin: 4px 0 0; }
.console-head .sub { color: var(--ink-soft); margin: 6px 0 0; font-size: .95rem; }

/* dense data table */
.dtable { width: 100%; border-collapse: collapse; }
.dtable thead th { text-align: left; font-family: var(--font-body); font-weight: 500; font-size: .78rem;
  color: var(--ink-faint); padding: 0 14px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
.dtable tbody td { padding: 13px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.dtable tbody tr:hover td { background: var(--line-soft); }
.dtable .u-name { font-weight: 500; }
.dtable .u-mail { font-family: var(--font-mono); font-size: .78rem; color: var(--ink-faint); margin-top: 2px; }
.dtable select, .dtable input[type=text] { padding: 6px 9px; font-size: .88rem; }
.dtable .cell-actions { text-align: right; white-space: nowrap; }
.rowform { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* stat tiles */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(148px, 1fr)); gap: 12px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 16px 18px; text-decoration: none; color: inherit; display: block; }
a.stat:hover { border-color: var(--accent); }
.stat__num { font-family: var(--font-display); font-size: 1.9rem; font-weight: 600; line-height: 1; }
.stat__label { color: var(--ink-soft); font-size: .82rem; margin-top: 6px; }

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