/* HYBEAM console.
 *
 * An operations tool: scanned and operated, not read. State is encoded in shape as well as
 * colour so nothing depends on hue alone, and the brand palette carries the identity while
 * the neutrals stay quiet enough to work behind dense tables.
 *
 * Montserrat is self-hosted rather than pulled from Google Fonts: the console runs in an EU
 * region by decision, and a font CDN would send every visitor's IP to a third party and stop
 * working offline. One variable file covers every weight used here.
 */

@font-face {
  font-family: "Montserrat";
  src: url("fonts/montserrat-variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  /* Brand */
  --brand: #8541ce;
  --brand-strong: #6c2fb0;      /* text and hover on light grounds */
  --brand-soft: #f2e9fc;
  --lilac: #9d98cd;
  --lilac-ink: #5d5788;         /* readable lilac for text */
  --lilac-soft: #eeedf8;
  --pink: #fe4e7c;
  --pink-ink: #c3123f;
  --pink-soft: #ffe8ee;
  --peach: #feb171;
  --peach-ink: #94540b;
  --peach-soft: #fff1e2;

  --gradient-brand: linear-gradient(135deg, #8541ce 0%, #fe4e7c 100%);
  --gradient-warm: linear-gradient(135deg, #fe4e7c 0%, #feb171 100%);
  --gradient-cool: linear-gradient(135deg, #8541ce 0%, #9d98cd 100%);

  /* Neutrals, biased toward the brand violet so greys read as chosen rather than default */
  --ground: #faf9fd;
  --surface: #ffffff;
  --surface-2: #f4f1fa;
  --line: #e4dff0;
  --line-strong: #b8b0cf;
  --ink: #1c1628;
  --ink-2: #4f4664;
  /* Dark enough that uppercase 11px table headers and hints clear 4.5:1 on white;
     the obvious violet-grey sits at 4.43:1 and fails for exactly the smallest text. */
  --ink-3: #6d6486;

  /* Semantic roles, drawn from the brand rather than a second palette */
  --live: var(--brand-strong);
  --live-soft: var(--brand-soft);
  --live-line: var(--brand);
  --warn: var(--peach-ink);
  --warn-soft: var(--peach-soft);
  --warn-line: var(--peach);
  --stop: var(--pink-ink);
  --stop-soft: var(--pink-soft);
  --stop-line: var(--pink);

  --sans: "Montserrat", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
  --r: 8px;
  --shadow: 0 1px 2px rgba(28, 22, 40, 0.06), 0 8px 24px rgba(28, 22, 40, 0.07);
}

@media (prefers-color-scheme: dark) {
  :root {
    --brand: #b57bea;
    --brand-strong: #c79bf0;
    --brand-soft: #2b1e47;
    --lilac: #b6b1de;
    --lilac-ink: #b6b1de;
    --lilac-soft: #262040;
    --pink: #ff7a9c;
    --pink-ink: #ff92ad;
    --pink-soft: #3b1b28;
    --peach: #ffc79a;
    --peach-ink: #ffc79a;
    --peach-soft: #3a2818;

    --ground: #141020;
    --surface: #1c1729;
    --surface-2: #251e37;
    --line: #342b4a;
    --line-strong: #4e4370;
    --ink: #efeaf8;
    --ink-2: #b4abc9;
    --ink-3: #877e9e;

    --live: var(--brand-strong);
    --live-soft: var(--brand-soft);
    --live-line: var(--brand);
    --warn: var(--peach-ink);
    --warn-soft: var(--peach-soft);
    --warn-line: var(--peach);
    --stop: var(--pink-ink);
    --stop-soft: var(--pink-soft);
    --stop-line: var(--pink);

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.45), 0 8px 24px rgba(0, 0, 0, 0.4);
  }
}

* { box-sizing: border-box; }

/* The [hidden] attribute is only display:none in the UA stylesheet, so any author rule
   that sets display — .signin and .modal-backdrop both do — silently overrides it. That
   left the modal backdrop (position:fixed, inset:0, z-index:50) laid over the whole page,
   swallowing every click and keystroke on the sign-in form. */
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.55 var(--sans);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; letter-spacing: -0.015em; font-weight: 700; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }
a { color: var(--brand-strong); }
.muted { color: var(--ink-3); }
.mono { font-family: var(--mono); font-size: 0.78rem; }
.nowrap { white-space: nowrap; }

/* ---------------- sign-in ---------------- */
.signin { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.signin-card {
  position: relative; width: min(380px, 100%); background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px; padding: 30px 28px 28px;
  box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px;
  overflow: hidden;
}
/* The one flourish on this screen: a brand bar rather than a coloured panel. */
.signin-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--gradient-brand);
}
.signin-card h1 { background: var(--gradient-brand); -webkit-background-clip: text;
  background-clip: text; color: transparent; letter-spacing: 0.02em; }
.signin-card p { margin: -6px 0 6px; }
.signin-card label { display: flex; flex-direction: column; gap: 5px; font-size: 0.78rem;
  color: var(--ink-2); font-weight: 600; }

/* ---------------- app shell ---------------- */
.appbar {
  position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 16px;
  padding: 10px 18px; background: var(--surface); border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.appbar::after {
  content: ""; position: absolute; inset: auto 0 -1px 0; height: 2px; background: var(--gradient-brand);
}
.brand {
  font-weight: 800; letter-spacing: 0.08em; font-size: 0.85rem;
  background: var(--gradient-brand); -webkit-background-clip: text; background-clip: text;
  color: transparent;
}
.org { color: var(--ink-2); font-size: 0.85rem; padding-right: 8px; border-right: 1px solid var(--line); }
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tabs a {
  padding: 6px 12px; border-radius: var(--r); color: var(--ink-2);
  text-decoration: none; font-size: 0.87rem; font-weight: 500;
}
.tabs a:hover { background: var(--brand-soft); color: var(--brand-strong); }
.tabs a.on { background: var(--brand-soft); color: var(--brand-strong); font-weight: 700; }
.spacer { flex: 1; }
.who { font-size: 0.8rem; color: var(--ink-3); }

.view { padding: 22px; max-width: 1100px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

/* ---------------- blocks ---------------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.card > header {
  padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex;
  align-items: center; gap: 12px; flex-wrap: wrap; background: var(--surface);
}
.card > header h2, .card > header h3 { flex: 1; }
.card .body { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 14px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------------- controls ---------------- */
.btn {
  font: inherit; font-size: 0.86rem; font-weight: 600; padding: 7px 13px; border-radius: var(--r);
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--ink-2); cursor: pointer;
}
.btn:hover { background: var(--surface-2); color: var(--ink); border-color: var(--brand); }
.btn:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--brand); outline-offset: 2px;
}
/* Boldness spent on the primary action only; every other button stays quiet. */
.btn.primary { background: var(--gradient-brand); border-color: transparent; color: #fff; font-weight: 700; }
.btn.primary:hover { filter: brightness(1.07); color: #fff; border-color: transparent; }
.btn.danger { color: var(--stop); border-color: var(--stop-line); background: var(--stop-soft); }
.btn.danger:hover { background: var(--stop-soft); color: var(--stop); border-color: var(--stop); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 3px 9px; font-size: 0.78rem; }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

input, select {
  font: inherit; font-size: 0.88rem; padding: 8px 10px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); min-width: 0;
}
input:hover, select:hover { border-color: var(--line-strong); }
input::placeholder { color: var(--ink-3); }
label.field { display: flex; flex-direction: column; gap: 5px; font-size: 0.72rem;
  font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3); }
label.field input, label.field select { text-transform: none; font-weight: 400; letter-spacing: 0; color: var(--ink); }
.hint { font-size: 0.75rem; color: var(--ink-3); font-weight: 400; text-transform: none; letter-spacing: 0; }

/* ---------------- table ---------------- */
table { width: 100%; border-collapse: collapse; }
.scroll-x { overflow-x: auto; }
th {
  text-align: left; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-3); font-weight: 700; padding: 10px 16px; border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
td { padding: 10px 16px; border-bottom: 1px solid var(--line); vertical-align: middle; font-size: 0.88rem; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover td { background: var(--brand-soft); }
td.num { font-variant-numeric: tabular-nums; font-family: var(--mono); font-size: 0.78rem; color: var(--ink-2); }
td.right, th.right { text-align: right; }

/* ---------------- state ---------------- */
.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 100px;
  font-size: 0.72rem; font-weight: 700; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.pill.live { color: var(--live); border-color: var(--live-line); background: var(--live-soft); }
.pill.warn { color: var(--warn); border-color: var(--warn-line); background: var(--warn-soft); }
.pill.stop { color: var(--stop); border-color: var(--stop-line); background: var(--stop-soft); }
.dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; flex: none; }
.dot.off { background: var(--line-strong); }

.banner { padding: 11px 14px; border-radius: var(--r); font-size: 0.86rem;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--ink-2); }
.banner.warn { border-color: var(--warn-line); background: var(--warn-soft); color: var(--warn); }
.banner.stop { border-color: var(--stop-line); background: var(--stop-soft); color: var(--stop); }
.error { color: var(--stop); font-size: 0.85rem; margin: 0; }
.empty { padding: 28px 16px; text-align: center; color: var(--ink-3); font-size: 0.88rem; }

/* ---------------- toast ---------------- */
.toast-stack { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast {
  background: var(--surface); border: 1px solid var(--line-strong); border-left-width: 4px;
  border-radius: var(--r); padding: 10px 14px; box-shadow: var(--shadow); font-size: 0.86rem;
  max-width: 380px;
}
.toast.ok { border-left-color: var(--brand); }
.toast.bad { border-left-color: var(--pink); }

/* ---------------- modal ---------------- */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(20, 16, 32, 0.55); display: grid;
  place-items: center; padding: 20px; z-index: 50;
}
.modal {
  position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--shadow); width: min(460px, 100%); padding: 22px;
  display: flex; flex-direction: column; gap: 14px; overflow: hidden;
}
.modal::before { content: ""; position: absolute; inset: 0 0 auto 0; height: 3px; background: var(--gradient-brand); }
.modal h3 { font-size: 1.05rem; }
.modal .actions { display: flex; justify-content: flex-end; gap: 8px; }
.code-display {
  font-family: var(--mono); font-size: 2.1rem; letter-spacing: 0.28em; text-align: center;
  padding: 18px 10px 18px 18px; border-radius: var(--r); font-weight: 700; color: #fff;
  background: var(--gradient-brand);
}

@media (max-width: 640px) {
  .appbar { gap: 10px; }
  .org { display: none; }
  .view { padding: 14px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
