/* ====================================================================== *
   vx-ticketboard — single stylesheet, no framework, no CDN.
   Dark by default (operators live in terminals); light mode respected.
 * ====================================================================== */

:root {
  --bg: #0b0e14;
  --bg-raise: #12161f;
  --bg-card: #171c27;
  --bg-card-hi: #1d2431;
  --line: #262d3b;
  --line-soft: #1e2431;
  --fg: #e6e9ef;
  --fg-dim: #97a0b3;
  --fg-faint: #67707f;
  --accent: #55d6a0;
  --accent-ink: #06281c;

  --sev-critical: #ff4d6a;
  --sev-high: #ff8c42;
  --sev-med: #f2c744;
  --sev-low: #5aa9e6;
  --sev-info: #8b93a6;

  --col-inbox: #e1566f;
  --col-triaged: #f2b544;
  --col-active: #55d6a0;
  --col-blocked: #c17be0;
  --col-done: #5b7490;

  /* Badge fills */
  --tint-critical: rgba(255, 77, 106, .15);
  --tint-high:     rgba(255, 140, 66, .15);
  --tint-med:      rgba(242, 199, 68, .15);
  --tint-low:      rgba(90, 169, 230, .15);
  --tint-info:     rgba(139, 147, 166, .15);

  /* Card washes — deliberately fainter than the badge fills */
  --wash-critical: rgba(255, 77, 106, .055);
  --wash-high:     rgba(255, 140, 66, .055);
  --wash-med:      rgba(242, 199, 68, .05);
  --wash-low:      rgba(90, 169, 230, .05);

  --radius: 10px;
  --radius-sm: 6px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f6fa;
    --bg-raise: #ffffff;
    --bg-card: #ffffff;
    --bg-card-hi: #f0f3f8;
    --line: #d9dee8;
    --line-soft: #e6eaf1;
    --fg: #1a1f2b;
    --fg-dim: #5a6475;
    --fg-faint: #8b94a4;
    --accent: #11895f;
    --accent-ink: #ffffff;
    --col-done: #7b8ca1;

    --wash-critical: rgba(214, 31, 64, .05);
    --wash-high:     rgba(201, 92, 14, .05);
    --wash-med:      rgba(166, 124, 0, .05);
    --wash-low:      rgba(32, 109, 173, .045);
  }
}

* { box-sizing: border-box; }

/* The `hidden` attribute must win over any layout rule below. Without this,
   `.gate { display: grid }` and `.drawer { position: fixed; inset: 0 }` keep a
   hidden overlay on top of the page, swallowing every click. */
[hidden] { display: none !important; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

button, input, select { font: inherit; color: inherit; }

.mono { font-family: var(--mono); font-size: 12px; }
.dim { color: var(--fg-faint); }

/* ------------------------------ buttons ------------------------------- */

.btn {
  background: var(--bg-card-hi);
  border: 1px solid var(--line);
  color: var(--fg);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background .12s, border-color .12s, transform .06s;
  white-space: nowrap;
}
.btn:hover { background: var(--line); border-color: var(--fg-faint); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  font-weight: 620;
}
.btn-primary:hover { filter: brightness(1.08); background: var(--accent); }

.btn-ghost { background: transparent; }
.btn-ghost:hover { background: var(--bg-card-hi); }

.btn-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.btn-row.end { justify-content: flex-end; }

/* ------------------------------ token gate ---------------------------- */

.gate {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    radial-gradient(900px 500px at 50% -10%, rgba(85, 214, 160, .10), transparent 70%),
    var(--bg);
  z-index: 50;
}
.gate-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 28px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, .35);
}
.gate-card h1 { font-size: 22px; }
.gate-sub { margin: 0; color: var(--fg-dim); font-size: 14px; }
.gate-hint { margin: 0; color: var(--fg-faint); font-size: 12px; line-height: 1.55; }
.gate-error {
  margin: 0;
  color: #ff6b85;
  font-size: 13px;
  background: rgba(255, 77, 106, .10);
  border: 1px solid rgba(255, 77, 106, .3);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
}

.field { display: grid; gap: 5px; }
.field > span { font-size: 12px; color: var(--fg-dim); font-weight: 560; }
.field input {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  width: 100%;
}
.field input:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: var(--accent); }

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

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--bg-raise);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand h1 { font-size: 17px; }
.brand-mark {
  width: 22px; height: 22px; border-radius: 6px;
  background: linear-gradient(135deg, var(--col-active), var(--col-triaged) 55%, var(--col-inbox));
  display: block;
}

.conn {
  font: 600 10.5px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 4px 7px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.conn-on  { color: var(--accent);    background: rgba(85,214,160,.12);  border-color: rgba(85,214,160,.35); }
.conn-off { color: var(--fg-faint);  background: var(--bg-card-hi);     border-color: var(--line); }

.filters { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; margin-left: auto; }
.topbar-actions { display: flex; gap: 8px; }

.sel { display: grid; gap: 4px; }
.sel > span { font-size: 11px; color: var(--fg-dim); font-weight: 560; }
.sel select, .sel input {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 6px 9px;
  min-width: 110px;
}
.sel select:focus, .sel input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ------------------------------- layout ------------------------------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  padding: 16px 18px 28px;
  align-items: start;
}
@media (max-width: 1100px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .feed-pane { order: -1; }
}

.columns {
  display: grid;
  grid-template-columns: repeat(5, minmax(210px, 1fr));
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 6px;
}
@media (max-width: 1500px) {
  .columns { grid-template-columns: repeat(5, minmax(200px, 1fr)); }
}

.column {
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  min-height: 160px;
}
.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.column-head h2 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .07em;
  color: var(--fg-dim);
}
.column-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
.column-body { padding: 10px; display: grid; gap: 9px; align-content: start; }
.column-empty {
  color: var(--fg-faint);
  font-size: 12.5px;
  padding: 14px 4px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: var(--radius-sm);
}

.pill {
  font: 600 11px/1 var(--mono);
  background: var(--bg-card-hi);
  border: 1px solid var(--line);
  color: var(--fg-dim);
  padding: 3px 7px;
  border-radius: 999px;
  margin-left: auto;
}

/* ------------------------------- cards -------------------------------- */

.card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sev-info);
  border-radius: var(--radius-sm);
  padding: 10px 11px;
  cursor: pointer;
  display: grid;
  gap: 7px;
  text-align: left;
  width: 100%;
  transition: border-color .12s, background .12s, transform .06s;
}
.card:hover { background: var(--bg-card-hi); border-color: var(--fg-faint); }
.card:active { transform: translateY(1px); }
.card:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Severity reads as a left rail plus a very light wash. Text colour is never
   touched here, so titles stay on --fg at full contrast in both themes. */
.card.sev-critical { border-left-color: var(--sev-critical); background: var(--wash-critical); }
.card.sev-high     { border-left-color: var(--sev-high);     background: var(--wash-high); }
.card.sev-med      { border-left-color: var(--sev-med);      background: var(--wash-med); }
.card.sev-low      { border-left-color: var(--sev-low);      background: var(--wash-low); }
.card.sev-info     { border-left-color: var(--sev-info);     background: var(--bg-card); }
.card:hover { background: var(--bg-card-hi); }

.card-top { display: flex; align-items: center; gap: 6px; }
.card-title { font-size: 13.5px; font-weight: 600; line-height: 1.35; }
.card-meta { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.sev {
  font: 650 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 6px;
  border-radius: 4px;
  flex: none;
}

/* Scoped to the badge on purpose. An unscoped `.sev-critical` would also match
   the card and the feed row (they carry the same severity class) and repaint
   their title text in the severity colour, which wrecks contrast. */
.sev.sev-critical { background: var(--tint-critical); color: var(--sev-critical); }
.sev.sev-high     { background: var(--tint-high);     color: var(--sev-high); }
.sev.sev-med      { background: var(--tint-med);      color: var(--sev-med); }
.sev.sev-low      { background: var(--tint-low);      color: var(--sev-low); }
.sev.sev-info     { background: var(--tint-info);     color: var(--sev-info); }

.tag {
  font: 500 10.5px/1 var(--mono);
  color: var(--fg-dim);
  background: var(--bg-card-hi);
  border: 1px solid var(--line-soft);
  padding: 3px 6px;
  border-radius: 4px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tag-phase { color: var(--accent); border-color: rgba(85,214,160,.3); background: rgba(85,214,160,.08); }

.prio { font: 650 10.5px/1 var(--mono); color: var(--fg-faint); margin-left: auto; flex: none; }

.quick {
  display: flex;
  gap: 6px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
}
.quick .mini {
  font: 600 10.5px/1 var(--mono);
  background: transparent;
  border: 1px solid var(--line);
  color: var(--fg-dim);
  padding: 5px 7px;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
}
.quick .mini:hover { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.quick .mini:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.status-chip {
  font: 650 10px/1 var(--mono);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--bg-card-hi);
  border: 1px solid var(--line);
  color: var(--fg-dim);
}

/* -------------------------------- feed -------------------------------- */

.feed-pane {
  background: var(--bg-raise);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius);
  padding: 14px;
  position: sticky;
  top: 70px;
  display: grid;
  gap: 10px;
  align-content: start;
  max-height: calc(100vh - 92px);
  overflow-y: auto;
}
.feed-head { display: flex; align-items: center; gap: 8px; }
.feed-head h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--fg-dim); }
.feed-sub { margin: 0; font-size: 12px; color: var(--fg-faint); }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.feed-item {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--sev-info);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  display: grid;
  gap: 4px;
  cursor: pointer;
  width: 100%;
  text-align: left;
}
.feed-item:hover { background: var(--bg-card-hi); }
.feed-item.sev-critical { border-left-color: var(--sev-critical); background: var(--wash-critical); }
.feed-item.sev-high     { border-left-color: var(--sev-high);     background: var(--wash-high); }
.feed-item.sev-med      { border-left-color: var(--sev-med);      background: var(--wash-med); }
.feed-item.sev-low      { border-left-color: var(--sev-low);      background: var(--wash-low); }
.feed-item.sev-info     { border-left-color: var(--sev-info); }
.feed-item:hover { background: var(--bg-card-hi); }
.feed-title { font-size: 12.5px; font-weight: 600; line-height: 1.35; }
.feed-meta { font: 500 10.5px/1.4 var(--mono); color: var(--fg-faint); }

@keyframes flash {
  from { box-shadow: 0 0 0 2px var(--accent); background: rgba(85,214,160,.10); }
  to   { box-shadow: 0 0 0 0 transparent; }
}
.flash { animation: flash 1.4s ease-out; }

.phase-pane { border-top: 1px solid var(--line-soft); padding-top: 12px; display: grid; gap: 8px; }
.phase-pane h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--fg-dim); }
.phase-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.phase-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 12.5px;
}
.phase-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.phase-status {
  font: 650 9.5px/1 var(--mono); text-transform: uppercase; letter-spacing: .06em;
  padding: 3px 6px; border-radius: 4px; margin-left: auto; flex: none;
}
.ps-active  { color: var(--col-active);  background: rgba(85,214,160,.12); }
.ps-queued  { color: var(--col-triaged); background: rgba(242,181,68,.12); }
.ps-waiting { color: var(--col-blocked); background: rgba(193,123,224,.12); }
.ps-done    { color: var(--col-done);    background: rgba(91,116,144,.15); }

/* ------------------------------- drawer ------------------------------- */

.drawer { position: fixed; inset: 0; z-index: 40; }
.drawer-backdrop { position: absolute; inset: 0; background: rgba(4, 6, 11, .6); }
.drawer-panel {
  position: absolute;
  top: 0; right: 0; bottom: 0;
  width: min(560px, 100%);
  background: var(--bg-raise);
  border-left: 1px solid var(--line);
  padding: 18px 20px 40px;
  overflow-y: auto;
  display: grid;
  gap: 14px;
  align-content: start;
  box-shadow: -24px 0 60px rgba(0,0,0,.4);
}
.drawer-head { display: flex; align-items: center; gap: 8px; }
.drawer-head > div { display: flex; gap: 8px; align-items: center; }
.drawer-head .btn { margin-left: auto; }
.drawer-panel h2 { font-size: 18px; line-height: 1.35; }
.drawer-sec { display: grid; gap: 8px; border-top: 1px solid var(--line-soft); padding-top: 12px; }
.drawer-sec h3 {
  font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--fg-dim);
}

.kv { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 5px 10px; margin: 0; }
.kv dt { font: 500 11.5px/1.5 var(--mono); color: var(--fg-faint); }
.kv dd { margin: 0; font: 500 11.5px/1.5 var(--mono); overflow-wrap: anywhere; }

.body-text {
  margin: 0;
  font: 12.5px/1.6 var(--mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg);
  border: 1px solid var(--line-soft);
  border-radius: var(--radius-sm);
  padding: 10px;
  max-height: 320px;
  overflow-y: auto;
}

.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.links a { color: var(--sev-low); font: 12px/1.5 var(--mono); overflow-wrap: anywhere; }

.triage-row { display: flex; gap: 10px; flex-wrap: wrap; }

.lineage { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.lineage li {
  display: grid;
  grid-template-columns: 148px minmax(0, 1fr);
  gap: 10px;
  font: 500 11.5px/1.6 var(--mono);
  padding: 6px 0 6px 12px;
  border-left: 2px solid var(--line);
  position: relative;
}
.lineage li::before {
  content: '';
  position: absolute; left: -4px; top: 12px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--fg-faint);
}
.lineage li:last-child::before { background: var(--accent); }
.lineage time { color: var(--fg-faint); }
.lineage .ln-event { color: var(--fg); }
.lineage .ln-actor { color: var(--fg-dim); }

.modal-card {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: min(420px, calc(100% - 32px));
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 24px;
  display: grid;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,.4);
}

/* -------------------------------- toast ------------------------------- */

.toast {
  position: fixed;
  bottom: 18px; left: 50%;
  transform: translateX(-50%);
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 13px;
  box-shadow: 0 12px 30px rgba(0,0,0,.35);
  z-index: 60;
  max-width: min(520px, calc(100% - 32px));
}
.toast.err { border-left-color: var(--sev-critical); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
