/* FireDoc design system — tokens + components shared by site, portal and admin.
   Direction: engineering document. Paper + ink, steel-blue drawing lines, one signal red (the reviewer's pen). */
:root {
  --font: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SFMono-Regular", Consolas, monospace;

  --paper: #f8f7f4;      /* page */
  --surface: #ffffff;    /* cards, inputs */
  --sunken: #f1efea;     /* wells, table heads */
  --ink: #0f141a;        /* text */
  --ink-2: #39424d;      /* secondary text */
  --mute: #6a737e;       /* captions */
  --line: #e4e1da;       /* borders */
  --line-2: #d3cfc6;     /* stronger borders */

  --brand: #d4361e;      /* signal red: primary action + findings only */
  --brand-ink: #a92a16;
  --brand-soft: #fcece8;
  --blue: #1d4f7c;       /* drawing lines, links, info */
  --blue-soft: #e7eef5;
  --ok: #1b7548;  --ok-soft: #e4f3ea;
  --warn: #9a5b00; --warn-soft: #fbf0dc;
  --bad: #b8232a; --bad-soft: #fbe9ea;

  --night: #0d1319;      /* dark bands on the marketing site */
  --night-2: #16202a;
  --night-line: rgba(160, 190, 220, .14);

  --r-sm: 6px; --r: 10px; --r-lg: 14px; --r-xl: 20px;
  --sh-1: 0 1px 2px rgba(15, 20, 26, .06);
  --sh-2: 0 1px 2px rgba(15, 20, 26, .05), 0 6px 18px -6px rgba(15, 20, 26, .12);
  --sh-3: 0 2px 4px rgba(15, 20, 26, .05), 0 22px 48px -16px rgba(15, 20, 26, .28);
  --focus: 0 0 0 3px rgba(29, 79, 124, .28);
  --ease: cubic-bezier(.2, .7, .2, 1);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0e1318; --surface: #151c23; --sunken: #111820; --ink: #e9edf1; --ink-2: #c1c9d2; --mute: #8b96a2;
    --line: #243039; --line-2: #313f4a; --brand: #ef5a3f; --brand-ink: #ff7a61; --brand-soft: #34201c;
    --blue: #7fb2e0; --blue-soft: #18283a; --ok: #5cc890; --ok-soft: #14291f; --warn: #e3a748; --warn-soft: #2d2412;
    --bad: #f07379; --bad-soft: #321a1c; --sh-2: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5);
    --sh-3: 0 24px 60px -20px rgba(0,0,0,.7); --focus: 0 0 0 3px rgba(127, 178, 224, .35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #0e1318; --surface: #151c23; --sunken: #111820; --ink: #e9edf1; --ink-2: #c1c9d2; --mute: #8b96a2;
  --line: #243039; --line-2: #313f4a; --brand: #ef5a3f; --brand-ink: #ff7a61; --brand-soft: #34201c;
  --blue: #7fb2e0; --blue-soft: #18283a; --ok: #5cc890; --ok-soft: #14291f; --warn: #e3a748; --warn-soft: #2d2412;
  --bad: #f07379; --bad-soft: #321a1c; --sh-2: 0 1px 2px rgba(0,0,0,.3), 0 8px 24px -8px rgba(0,0,0,.5);
  --sh-3: 0 24px 60px -20px rgba(0,0,0,.7); --focus: 0 0 0 3px rgba(127, 178, 224, .35); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 400 15px/1.6 var(--font);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; }
img, svg { display: block; max-width: 100%; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3, h4 { margin: 0; line-height: 1.2; letter-spacing: -.015em; font-weight: 650; text-wrap: balance; }
h1 { font-size: clamp(30px, 4.4vw, 52px); letter-spacing: -.028em; font-weight: 700; }
h2 { font-size: clamp(24px, 2.8vw, 36px); letter-spacing: -.022em; }
h3 { font-size: 18px; }
h4 { font-size: 15px; }
p { margin: 0; text-wrap: pretty; }
code, kbd, .mono { font-family: var(--mono); font-size: .9em; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: var(--r-sm); }
::selection { background: var(--brand-soft); color: var(--ink); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--mute); } .ink-2 { color: var(--ink-2); }
.small { font-size: 13px; } .tiny { font-size: 12px; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.eyebrow { font: 600 12px/1 var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--brand); }
.container { width: 100%; max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.stack > * + * { margin-top: var(--gap, 12px); }
.row { display: flex; align-items: center; gap: 12px; }
.row.wrap { flex-wrap: wrap; } .row.between { justify-content: space-between; } .grow { flex: 1 1 auto; min-width: 0; }
.grid { display: grid; gap: 16px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }

/* ---------- buttons ---------- */
.btn { --bg: var(--surface); --fg: var(--ink); --bd: var(--line-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 16px;
  border-radius: var(--r-sm); border: 1px solid var(--bd); background: var(--bg); color: var(--fg);
  font: 600 14px/1 var(--font); cursor: pointer; white-space: nowrap; text-decoration: none !important;
  transition: background .15s var(--ease), border-color .15s var(--ease), transform .15s var(--ease), box-shadow .15s; }
.btn:hover { border-color: var(--ink-2); }
.btn:active { transform: translateY(1px); }
.btn svg { width: 16px; height: 16px; flex: none; }
.btn-primary { --bg: var(--brand); --fg: #fff; --bd: var(--brand); box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, var(--sh-1); }
.btn-primary:hover { --bg: var(--brand-ink); --bd: var(--brand-ink); }
.btn-dark { --bg: var(--ink); --fg: var(--paper); --bd: var(--ink); }
.btn-dark:hover { opacity: .9; border-color: var(--ink); }
.btn-ghost { --bg: transparent; --bd: transparent; }
.btn-ghost:hover { --bg: var(--sunken); border-color: transparent; }
.btn-danger { --fg: var(--bad); }
.btn-danger:hover { --bg: var(--bad-soft); border-color: var(--bad); }
.btn-sm { height: 32px; padding: 0 12px; font-size: 13px; }
.btn-lg { height: 48px; padding: 0 22px; font-size: 15px; border-radius: var(--r); }
.btn-block { width: 100%; }
.btn-icon { width: 36px; padding: 0; }
.btn[disabled], .btn.is-loading { opacity: .55; pointer-events: none; }
.btn.is-loading::after { content: ""; width: 14px; height: 14px; border-radius: 50%; border: 2px solid currentColor;
  border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- forms ---------- */
.field { display: grid; gap: 6px; }
.field > label, .label { font-size: 13px; font-weight: 600; color: var(--ink-2); }
.field .help { font-size: 12.5px; color: var(--mute); }
.field .error { font-size: 12.5px; color: var(--bad); }
.input, .select, .textarea { width: 100%; height: 42px; padding: 0 12px; border-radius: var(--r-sm);
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink); font: 400 15px/1.4 var(--font);
  transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 110px; padding: 10px 12px; resize: vertical; }
.select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none' stroke='%236a737e' stroke-width='1.6'%3E%3Cpath d='M1 1.5l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--mute); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--blue); box-shadow: var(--focus); }
.input[aria-invalid="true"] { border-color: var(--bad); }
.input-sm, .select-sm { height: 34px; font-size: 14px; }
.input-group { position: relative; }
.input-group > svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 16px; height: 16px; color: var(--mute); pointer-events: none; }
.input-group > .input { padding-left: 36px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; color: var(--ink-2); cursor: pointer; }
.check input { width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand); flex: none; }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 22px; background: var(--line-2); margin: 0;
  position: relative; cursor: pointer; transition: background .2s; flex: none; }
.switch input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: #fff; box-shadow: var(--sh-1); transition: transform .2s var(--ease); }
.switch input:checked { background: var(--ok); }
.switch input:checked::after { transform: translateX(16px); }
.form-grid { display: grid; gap: 16px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .span-2 { grid-column: 1 / -1; }
@media (max-width: 640px) { .form-grid { grid-template-columns: 1fr; } }

/* ---------- surfaces ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--sh-1); }
.card-pad { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px;
  border-bottom: 1px solid var(--line); }
.card-head h3 { font-size: 15px; }
.card-body { padding: 20px; }
.card-foot { padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunken);
  border-radius: 0 0 var(--r-lg) var(--r-lg); }
.well { background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); padding: 14px 16px; }
.divider { height: 1px; background: var(--line); }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px; border-radius: 999px;
  font: 600 12px/1 var(--font); background: var(--sunken); color: var(--ink-2); white-space: nowrap; border: 1px solid transparent; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .85; }
.badge.plain::before { display: none; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--blue-soft); color: var(--blue); }
.badge-brand { background: var(--brand-soft); color: var(--brand); }
.badge-live::before { animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .25; } }
.tag { display: inline-block; padding: 2px 8px; border-radius: var(--r-sm); border: 1px solid var(--line-2);
  font: 500 12px/1.5 var(--mono); color: var(--ink-2); background: var(--surface); }

/* ---------- alerts ---------- */
.alert { display: flex; gap: 12px; padding: 12px 14px; border-radius: var(--r); border: 1px solid var(--line);
  background: var(--sunken); font-size: 14px; color: var(--ink-2); }
.alert svg { width: 18px; height: 18px; flex: none; margin-top: 2px; }
.alert-info { background: var(--blue-soft); border-color: transparent; color: var(--ink); }
.alert-info svg { color: var(--blue); }
.alert-ok { background: var(--ok-soft); border-color: transparent; } .alert-ok svg { color: var(--ok); }
.alert-warn { background: var(--warn-soft); border-color: transparent; } .alert-warn svg { color: var(--warn); }
.alert-bad { background: var(--bad-soft); border-color: transparent; } .alert-bad svg { color: var(--bad); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 14px; }
.table th { text-align: left; font: 600 12px/1.3 var(--font); color: var(--mute); text-transform: uppercase;
  letter-spacing: .04em; padding: 10px 14px; background: var(--sunken); border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: 12px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: color-mix(in srgb, var(--sunken) 60%, transparent); }
.table tr.is-link { cursor: pointer; }
.table .t-right { text-align: right; }
.table .t-strong { font-weight: 600; color: var(--ink); }
.card > .table-wrap .table th:first-child { border-top-left-radius: var(--r-lg); }
.card > .table-wrap .table th:last-child { border-top-right-radius: var(--r-lg); }

/* ---------- progress ---------- */
.progress { height: 6px; background: var(--sunken); border-radius: 6px; overflow: hidden; border: 1px solid var(--line); }
.progress > i { display: block; height: 100%; background: var(--blue); border-radius: 6px; transition: width .4s var(--ease); }
.progress.ok > i { background: var(--ok); } .progress.brand > i { background: var(--brand); }

/* ---------- tabs ---------- */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); overflow-x: auto; scrollbar-width: none; }
.tabs button, .tabs a { appearance: none; border: 0; background: none; padding: 10px 14px; font: 600 14px/1 var(--font);
  color: var(--mute); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; white-space: nowrap; text-decoration: none; }
.tabs button:hover, .tabs a:hover { color: var(--ink); }
.tabs [aria-selected="true"], .tabs .is-active { color: var(--ink); border-bottom-color: var(--brand); }
.seg { display: inline-flex; padding: 3px; background: var(--sunken); border: 1px solid var(--line); border-radius: var(--r); gap: 2px; }
.seg button { border: 0; background: none; padding: 6px 12px; border-radius: 7px; font: 600 13px/1 var(--font); color: var(--mute); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--sh-1); }

/* ---------- stat ---------- */
.stat { display: grid; gap: 4px; }
.stat .k { font-size: 13px; color: var(--mute); font-weight: 500; }
.stat .v { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; line-height: 1.15; }
.stat .d { font-size: 12.5px; color: var(--mute); }

/* ---------- empty / skeleton ---------- */
.empty { display: grid; justify-items: center; gap: 10px; text-align: center; padding: 48px 20px; color: var(--mute); }
.empty svg { width: 40px; height: 40px; color: var(--line-2); }
.empty h4 { color: var(--ink); font-size: 16px; }
.skeleton { background: linear-gradient(90deg, var(--sunken) 0%, var(--line) 50%, var(--sunken) 100%); background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite; border-radius: var(--r-sm); min-height: 14px; }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* ---------- modal / drawer ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 14, 19, .48); backdrop-filter: blur(2px); z-index: 80;
  display: grid; place-items: center; padding: 16px; animation: fade .15s var(--ease); }
.modal { width: 100%; max-width: 520px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface);
  border-radius: var(--r-lg); box-shadow: var(--sh-3); border: 1px solid var(--line); animation: rise .2s var(--ease); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 20px 0; }
.modal-head h3 { font-size: 17px; }
.modal-body { padding: 16px 20px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: var(--sunken); }
.drawer-backdrop { position: fixed; inset: 0; background: rgba(10,14,19,.4); z-index: 80; animation: fade .15s; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); background: var(--surface); z-index: 81;
  box-shadow: var(--sh-3); display: flex; flex-direction: column; animation: slide .22s var(--ease); }
.drawer-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.drawer-body { flex: 1; overflow: auto; padding: 20px; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px) scale(.99); } }
@keyframes slide { from { transform: translateX(24px); opacity: 0; } }

/* ---------- toast ---------- */
.toasts { position: fixed; z-index: 100; right: 16px; bottom: 16px; display: grid; gap: 8px; max-width: min(380px, calc(100vw - 32px)); }
.toast { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--r); background: var(--ink);
  color: var(--paper); box-shadow: var(--sh-3); font-size: 14px; animation: rise .2s var(--ease); }
.toast svg { width: 18px; height: 18px; flex: none; margin-top: 1px; }
.toast.ok svg { color: #5cc890; } .toast.bad svg { color: #ff8a8f; }

/* ---------- misc ---------- */
.kbd { font: 500 12px var(--mono); padding: 2px 6px; border: 1px solid var(--line-2); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); }
.copy-field { display: flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--line-2);
  border-radius: var(--r-sm); background: var(--sunken); font: 500 13.5px/1.4 var(--mono); }
.copy-field > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.code-block { background: var(--night); color: #d6e2ee; border-radius: var(--r); padding: 16px 18px; overflow-x: auto;
  font: 400 13px/1.65 var(--mono); border: 1px solid var(--night-line); }
.code-block .c { color: #7d8b99; } .code-block .s { color: #9fd3a8; } .code-block .k { color: #f3a27f; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: var(--blue-soft);
  color: var(--blue); font: 700 13px/1 var(--font); flex: none; text-transform: uppercase; }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; background: var(--mute); }
.dot.ok { background: var(--ok); } .dot.warn { background: var(--warn); } .dot.bad { background: var(--bad); } .dot.info { background: var(--blue); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
