/* =========================================================================
 * doka-platform access console — app.css
 *
 * Engineer's Notebook system, shared with Doka Pocket CRM and TiplistToGo:
 * Fraunces display / DM Sans UI / JetBrains Mono data, warm paper with rust
 * accent. The :root block below is copied verbatim from those repos so the
 * three apps stay one family.
 *
 * Local rule for THIS app: monospace is not decoration. Every identifier,
 * URL, status code, JSON body and column value is mono, because every one of
 * them is a value someone needs to read character by character. Density over
 * whitespace — this is an instrument panel.
 *
 * The one semantic that matters most: 200-with-[] and 403 share no styling.
 * Teal spine / paper background / "EMPTY — NOT AN ERROR" versus rust spine /
 * warn background / "DENIED". Opposite colour temperature, same typographic
 * weight, so nobody has to read the status code to tell them apart.
 * ========================================================================= */

:root {
  --paper: #F6F2E9;
  --card: #FFFDF7;
  --ink: #2B2A26;
  --ink-soft: #6B675C;
  --line: #DDD5C4;
  --line-soft: #EAE3D4;
  --rust: #B3502D;
  --rust-deep: #8F3E21;
  --amber: #E0A41B;
  --teal: #1F6F9C;
  --green: #4A7A43;
  --purple: #6E4FA3;
  --warn-bg: #F6E3DC;

  --font-display: "Fraunces", Georgia, serif;
  --font-body: "DM Sans", system-ui, -apple-system, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, Menlo, monospace;

  --nav-h: 58px;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(43, 42, 38, .10), 0 4px 14px rgba(43, 42, 38, .06);
}

* { box-sizing: border-box; }

/* Author display values (flex, grid) must never override the hidden
 * attribute. View switching depends entirely on this rule. */
[hidden] { display: none !important; }

html, body { height: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.mono, .raw, .kv dt, .kv dd, code { font-family: var(--font-mono); }
.view { min-height: 100%; }
.view-center {
  display: flex; justify-content: center;
  padding: 32px 20px;
}

/* ------------------------------------------------------------- generic -- */

.btn {
  font-family: var(--font-body); font-size: 14px; font-weight: 500;
  padding: 7px 14px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); cursor: pointer;
}
.btn:hover { border-color: var(--ink-soft); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: var(--rust); border-color: var(--rust-deep); color: #fff; }
.btn-primary:hover { background: var(--rust-deep); }
.btn-tiny { font-size: 12px; padding: 3px 8px; }

.text-input {
  font-size: 13px; padding: 6px 9px; width: 100%;
  border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink);
}
.text-input:focus { outline: 2px solid var(--teal); outline-offset: -1px; border-color: var(--teal); }

.hint { font-size: 12.5px; color: var(--ink-soft); margin: 6px 0 0; }
.hint-warn { color: var(--rust-deep); }
.tight-list { margin: 6px 0; padding-left: 20px; }
.tight-list li { margin: 3px 0; }

.panel-sub {
  font-size: 11px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-soft); font-family: var(--font-body); margin: 16px 0 6px;
}

.raw {
  font-size: 12px; line-height: 1.45; margin: 0;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 10px 12px; overflow-x: auto; white-space: pre-wrap; word-break: break-word;
  color: var(--ink);
}

.spinner {
  width: 22px; height: 22px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--rust);
  animation: spin .8s linear infinite; margin: 0 auto 10px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.copy-btn {
  font-family: var(--font-body); font-size: 11px; font-weight: 600;
  padding: 2px 7px; margin-left: 6px; cursor: pointer; vertical-align: middle;
  border: 1px solid var(--line); border-radius: 5px;
  background: var(--card); color: var(--ink-soft);
}
.copy-btn:hover { border-color: var(--teal); color: var(--teal); }
.copy-btn.is-done { border-color: var(--green); color: var(--green); }

/* ------------------------------------------------------ boot / fatal ---- */

.boot-card { text-align: center; color: var(--ink-soft); font-size: 13px; }
.fatal-card {
  max-width: 760px; background: var(--card); border: 1px solid var(--line);
  border-left: 5px solid var(--rust-deep); border-radius: var(--radius);
  padding: 24px 28px; box-shadow: var(--shadow);
}
.fatal-title { font-family: var(--font-display); font-size: 24px; margin: 0 0 10px; color: var(--rust-deep); }
.fatal-message { margin: 0 0 14px; white-space: pre-wrap; }
.fatal-csp { margin-top: 18px; }

/* -------------------------------------------------------- signed out ---- */

/* One centred column holding one card at a time. `margin: auto` rather than
 * align-items:center on .view-center, so that when the pane is taller than the
 * viewport it still scrolls from the top instead of clipping its own head. */
.signedout { width: 100%; max-width: 430px; margin: auto; }
.so-pane { display: flex; flex-direction: column; align-items: stretch; }
.so-note { margin: 16px 0 0; font-size: 12.5px; }
.so-note p { margin: 0; }
.brand { text-align: center; margin-bottom: 22px; }
.brand-name { font-family: var(--font-mono); font-size: 26px; font-weight: 600; margin: 0; letter-spacing: -.02em; }
.brand-sub {
  font-family: var(--font-body); font-size: 11px; font-weight: 700;
  letter-spacing: .18em; text-transform: uppercase; color: var(--rust); margin: 4px 0 0;
}
.brand-rule { border: 0; border-top: 1px solid var(--line); margin: 14px auto; max-width: 90px; }
.brand-blurb { font-size: 13.5px; color: var(--ink-soft); margin: 0; }
/* Centring the Clerk card.
 *
 * This class sits on a WRAPPER, not on the node passed to mountSignIn/
 * mountWaitlist: Clerk overwrites that node's class attribute on mount, so any
 * rule targeting it silently stops matching and the card drifts left of the
 * brand above it. The wrapper is ours and stays ours. */
.clerk-mount { display: flex; justify-content: center; width: 100%; }

.callout {
  border: 1px solid var(--line); border-left: 4px solid var(--ink-soft);
  border-radius: 8px; background: var(--card); padding: 12px 15px;
  font-size: 13.5px; margin: 8px 0 14px;
}
.callout p { margin: 0 0 8px; }
.callout p:last-child { margin-bottom: 0; }
.callout-note { border-left-color: var(--teal); }
.callout-warn { border-left-color: var(--rust); background: var(--warn-bg); }

/* ------------------------------------------------------------ topbar ---- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 20px;
  height: var(--nav-h); padding: 0 18px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar-brand { display: flex; flex-direction: column; line-height: 1.15; }
.topbar-name { font-family: var(--font-mono); font-size: 14px; font-weight: 600; }
.topbar-sub {
  font-size: 9.5px; font-weight: 700; letter-spacing: .14em;
  text-transform: uppercase; color: var(--rust);
}
/* Shrinkable, scrollable nav: on narrow screens the tabs scroll inside
 * their own strip and the Account button stays on the same row. */
.topbar-nav {
  display: flex; gap: 2px; margin-left: auto;
  flex: 0 1 auto; min-width: 0; overflow-x: auto;
  scrollbar-width: thin;
}
.topbar-brand, .topbar-right { flex-shrink: 0; }
.tabnav-btn {
  font-family: var(--font-body); font-size: 13px; font-weight: 500;
  padding: 7px 13px; border: 1px solid transparent; border-radius: 7px;
  background: none; color: var(--ink-soft); cursor: pointer;
}
.tabnav-btn:hover { color: var(--ink); background: var(--paper); }
.tabnav-btn.is-active { color: var(--rust-deep); background: var(--paper); border-color: var(--line); font-weight: 700; }
.topbar-right { margin-left: 10px; display: flex; align-items: center; }

.panel { padding: 18px; max-width: 1400px; margin: 0 auto; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

.card {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 15px 17px; margin-bottom: 14px;
}
.card-title { font-family: var(--font-display); font-size: 17px; font-weight: 640; margin: 0 0 8px; }
.card-foot { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.card-foot .hint { margin: 0; flex: 1 1 220px; }
.check { display: flex; align-items: center; gap: 6px; font-size: 13px; }

/* -------------------------------------------------------------- kv ------ */

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 4px 14px; margin: 0; font-size: 13px; }
.kv dt { color: var(--ink-soft); font-size: 11.5px; white-space: nowrap; }
.kv dd { margin: 0; word-break: break-all; }
.kv dd.is-null { color: var(--ink-soft); font-style: italic; }

/* --------------------------------------------------------- countdown ---- */

.countdown { margin-bottom: 6px; }
.countdown-row { display: flex; align-items: baseline; gap: 10px; }
.countdown-value { font-family: var(--font-mono); font-size: 30px; font-weight: 600; color: var(--teal); }
.countdown-value.is-expired { color: var(--rust); }
.countdown-life { font-size: 12px; color: var(--ink-soft); }
.countdown-track { height: 5px; border-radius: 3px; background: var(--line-soft); overflow: hidden; margin-top: 6px; }
.countdown-bar { height: 100%; width: 0; background: var(--teal); transition: width .2s linear; }
.countdown-value.is-expired ~ .countdown-track .countdown-bar,
.countdown-bar.is-expired { background: var(--rust); }

/* ---------------------------------------------------------- tabstrip ---- */

.tabstrip { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tab-btn {
  font-family: var(--font-mono); font-size: 12.5px;
  padding: 5px 11px; border: 1px solid var(--line); border-radius: 7px;
  background: var(--card); color: var(--ink-soft); cursor: pointer;
}
.tab-btn:hover { color: var(--ink); border-color: var(--ink-soft); }
.tab-btn.is-active { background: var(--ink); border-color: var(--ink); color: var(--paper); font-weight: 600; }
.tab-btn .tab-rw {
  font-size: 9px; font-weight: 700; letter-spacing: .06em;
  margin-left: 5px; color: var(--purple);
}
.tab-btn.is-active .tab-rw { color: var(--amber); }

.tablemeta { font-size: 13px; margin-bottom: 12px; }
.tablemeta .policy {
  font-family: var(--font-mono); font-size: 11.5px; white-space: pre-wrap;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 8px 10px; margin-top: 6px; color: var(--ink-soft);
}

.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; }
.ctl { display: flex; flex-direction: column; gap: 3px; flex: 1 1 150px; }
.ctl-narrow { flex: 0 0 84px; }
.ctl-wide { flex: 2 1 320px; }
.ctl-label { font-size: 10.5px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.ctl-actions { display: flex; gap: 7px; }
.controls .hint { flex: 1 1 100%; }

/* ------------------------------------------------------------ result ---- */

.result { border-radius: var(--radius); border: 1px solid var(--line); background: var(--card); margin-bottom: 14px; overflow: hidden; }
.result-head { display: flex; align-items: flex-start; gap: 12px; padding: 12px 15px; border-bottom: 1px solid var(--line-soft); }
.result-body { padding: 12px 15px; }

/* The colour system. tone drives everything; nothing else sets these. */
.tone-ok      { border-left: 5px solid var(--green); }
.tone-empty   { border-left: 5px solid var(--teal); }
.tone-denied  { border-left: 5px solid var(--rust); }
.tone-denied .result-head { background: var(--warn-bg); }
.tone-broken  { border-left: 5px solid var(--amber); }
.tone-fatal   { border-left: 5px solid var(--rust-deep); }
.tone-fatal .result-head { background: var(--warn-bg); }

.status-chip {
  font-family: var(--font-mono); font-size: 15px; font-weight: 600;
  padding: 3px 10px; border-radius: 6px; color: #fff; white-space: nowrap;
}
.tone-ok     .status-chip { background: var(--green); }
.tone-empty  .status-chip { background: var(--teal); }
.tone-denied .status-chip { background: var(--rust-deep); }
.tone-broken .status-chip { background: var(--amber); color: var(--ink); }
.tone-fatal  .status-chip { background: var(--rust-deep); }

.result-headline { font-size: 14.5px; font-weight: 700; margin: 0 0 3px; }
.result-glyph { font-family: var(--font-mono); margin-right: 6px; }
.result-plain { font-size: 13px; margin: 0; color: var(--ink); }
.result-plain code, .result-plain .mono { font-size: 12px; }
.result-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; font-size: 11.5px; color: var(--ink-soft); font-family: var(--font-mono); margin-top: 8px; }
.result-url {
  font-family: var(--font-mono); font-size: 12px; word-break: break-all;
  background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px;
  padding: 7px 10px; margin: 0 0 10px;
}
.badge {
  font-family: var(--font-body); font-size: 10px; font-weight: 700;
  letter-spacing: .05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 4px; background: var(--amber); color: var(--ink);
}

details.raw-wrap { margin-top: 10px; }
details.raw-wrap > summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  font-family: var(--font-body); padding: 4px 0;
}
details.raw-wrap > summary:hover { color: var(--ink); }

/* -------------------------------------------------------- data table ---- */

.tablewrap { overflow-x: auto; border: 1px solid var(--line-soft); border-radius: 7px; margin-top: 10px; }
table.data { border-collapse: collapse; width: 100%; font-family: var(--font-mono); font-size: 12px; }
table.data th, table.data td { padding: 5px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; white-space: nowrap; }
table.data th {
  position: sticky; top: 0; background: var(--paper); cursor: pointer;
  font-size: 10.5px; letter-spacing: .04em; text-transform: uppercase;
  color: var(--ink-soft); border-bottom: 1px solid var(--line); user-select: none;
}
table.data th:hover { color: var(--rust); }
table.data th.is-sorted { color: var(--rust-deep); }
table.data tbody tr:nth-child(even) { background: #FBF7EE; }
table.data td.is-null { color: var(--ink-soft); font-style: italic; }
table.data td.is-num { text-align: right; }
.cell-clip { display: inline-block; max-width: 340px; overflow: hidden; text-overflow: ellipsis; vertical-align: bottom; }

/* -------------------------------------------------------------- grid ---- */

table.grid { border-collapse: collapse; width: 100%; font-size: 12.5px; margin-top: 10px; }
table.grid th, table.grid td { padding: 6px 9px; border-bottom: 1px solid var(--line-soft); text-align: left; vertical-align: top; }
table.grid th { font-size: 10.5px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-soft); }
table.grid td.mono, table.grid td .mono { font-family: var(--font-mono); font-size: 11.5px; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; vertical-align: middle; }
.dot-ok { background: var(--green); }
.dot-empty { background: var(--teal); }
.dot-denied { background: var(--rust); }
.dot-broken { background: var(--amber); }
.dot-fatal { background: var(--rust-deep); }
tr.is-unexpected { background: var(--warn-bg); }

.probe-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.cmd {
  font-family: var(--font-mono); font-size: 12px; line-height: 1.5;
  background: var(--ink); color: #F1EADC; border-radius: 7px;
  padding: 10px 12px; margin: 8px 0 4px; overflow-x: auto; white-space: pre-wrap; word-break: break-all;
}

/* ------------------------------------------------------------ mobile ---- */

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: 1fr; }
  .topbar { padding: 0 10px; gap: 8px; }
  .panel { padding: 12px; }
  .cell-clip { max-width: 180px; }
}

/* ------------------------------------------------- light-mode details ---- */

details.result-why { margin-top: 2px; }
details.result-why > summary {
  cursor: pointer; font-size: 12px; font-weight: 600; color: var(--ink-soft);
  font-family: var(--font-body); user-select: none;
}
details.result-why > summary:hover { color: var(--ink); }
details.result-why[open] > summary { color: var(--ink); }

.rb-checks { display: flex; flex-wrap: wrap; gap: 8px 14px; padding: 7px 0; }

/* ---------------------------------------------------------- hub pivot ---- */

.card-head-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.card-head-row .card-title { margin-bottom: 0; }

.ov-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 10px; margin-top: 12px; }
.ov-card {
  border: 1px solid var(--line); border-radius: 8px; background: var(--card);
  padding: 11px 13px; cursor: pointer;
}
.ov-card:hover { border-color: var(--rust); }
.ov-head { display: flex; align-items: baseline; gap: 8px; }
.ov-name { font-weight: 600; font-size: 13px; }
.ov-count { margin-left: auto; font-family: var(--font-mono); font-size: 12px; color: var(--teal); white-space: nowrap; }
.ov-blurb { font-size: 12.5px; color: var(--ink-soft); margin: 4px 0 0; }
.ov-card .hint { font-size: 11px; }

.export-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 10px; }
.export-bar .hint { margin: 0; }

.gate-foot { text-align: center; margin-top: 18px; }
tr.is-hit td { font-weight: 700; }
textarea.text-input { resize: vertical; font-size: 12.5px; line-height: 1.5; }

/* ------------------------------------------------ accessibility pass ---- */

/* Keyboard focus must be visible everywhere, not only on text inputs. */
:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
  border-radius: 4px;
}
.tabnav-btn:focus-visible, .tab-btn:focus-visible, .btn:focus-visible { outline-offset: 1px; }
table.data th:focus-visible { outline-offset: -2px; }

/* Motion is a preference, not a given. The spinner falls back to a static
 * ring; the countdown bar simply jumps. */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--line); }
  .countdown-bar { transition: none; }
  * { scroll-behavior: auto !important; }
}

/* The topbar name is the page's h1 — same visual, correct semantics. */
h1.topbar-name { margin: 0; font-size: 14px; }

/* .ov-card became a real <button>; undo the UA button styling. */
button.ov-card {
  font: inherit; color: inherit; text-align: left; width: 100%;
  display: block; appearance: none;
}
.ov-head { width: 100%; }

/* Small screens: tighter chrome, full-width tap targets, no crowding. */
@media (max-width: 600px) {
  body { font-size: 15px; }
  .panel { padding: 10px; }
  .card { padding: 12px 12px; }
  .controls { gap: 8px; }
  .ctl, .ctl-narrow, .ctl-wide { flex: 1 1 100%; }
  .ctl-actions { width: 100%; }
  .ctl-actions .btn { flex: 1 1 auto; }
  .card-foot .btn { flex: 1 1 auto; }
  .result-head { flex-direction: column; gap: 8px; }
  .status-chip { align-self: flex-start; }
  .kv { grid-template-columns: 1fr; gap: 1px 0; }
  .kv dt { margin-top: 8px; }
  .export-bar .btn { flex: 1 1 auto; }
}

/* --------------------------------------------------------- users tab ---- */

tr.is-inactive td { opacity: .55; }
tr.is-inactive td .btn { opacity: 1; }
.ud-actions { white-space: nowrap; }
.ud-actions .btn { margin: 2px 4px 2px 0; }
.ud-editor { background: #FBF7EE; border: 1px solid var(--line-soft); border-radius: 7px; padding: 10px 12px; }
tr.ud-edit-row > td { padding: 8px 0 14px; }

/* ---------------------------------------------------- account button ---- */

.account { position: relative; }
.account-menu {
  position: absolute; top: calc(100% + 6px); right: 0; z-index: 40;
  min-width: 220px; display: flex; flex-direction: column; gap: 6px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  box-shadow: var(--shadow); padding: 10px;
}
.account-menu .btn { width: 100%; text-align: left; }
.account-who { padding: 2px 4px 6px; border-bottom: 1px solid var(--line-soft); font-size: 13.5px; }
.account-who .hint { margin: 2px 0 0; word-break: break-all; }

/* ------------------------------------------------------------ env chip --- */

.env-chip {
  font-family: var(--font-mono); font-size: 10.5px; font-weight: 600;
  letter-spacing: .08em; padding: 4px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--paper); color: var(--ink-soft);
  cursor: pointer; flex-shrink: 0;
}
.env-chip:hover { border-color: var(--ink-soft); }
.env-chip.is-dev {
  background: var(--amber); border-color: var(--amber); color: var(--ink);
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
