/*
 * Star 101 operator console.
 *
 * Dense on purpose. This is a tool for someone reading a ledger or chasing an
 * incident, not a marketing page: rows are compact, numbers are tabular, and
 * anything that changes money or access is coloured so it cannot be clicked by
 * accident.
 */

:root {
  color-scheme: dark;
  --bg: #0d1117;
  --panel: #161b22;
  --panel-2: #1c2129;
  --line: #2a313c;
  --text: #e6edf3;
  --muted: #8b949e;
  --accent: #2dd4bf;
  --accent-dim: #14514a;
  --danger: #f85149;
  --warn: #d29922;
  --ok: #3fb950;
  --radius: 8px;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* ── login ──────────────────────────────────────────────────────────── */

.login-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login {
  width: min(380px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 28px;
}

.login h1 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: -0.01em;
}

.login p.sub {
  margin: 0 0 20px;
  color: var(--muted);
  font-size: 13px;
}

.seg {
  display: flex;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 3px;
  margin-bottom: 18px;
}

.seg button {
  flex: 1;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 7px;
  border-radius: 5px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
}

.seg button[aria-pressed="true"] {
  background: var(--panel-2);
  color: var(--text);
}

/* ── shell ──────────────────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: 216px 1fr;
  min-height: 100vh;
}

.side {
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 4px 8px 16px;
}

.brand strong { font-size: 15px; letter-spacing: -0.01em; }
.brand span { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em; }

.side nav { display: flex; flex-direction: column; gap: 1px; }

.side nav button {
  text-align: left;
  background: none;
  border: 0;
  color: var(--muted);
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}

.side nav button:hover { background: var(--panel-2); color: var(--text); }
.side nav button[aria-current="page"] { background: var(--accent-dim); color: var(--text); }

.side .spacer { flex: 1; }

.whoami {
  border-top: 1px solid var(--line);
  padding: 12px 10px 4px;
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.main { padding: 24px 28px 64px; min-width: 0; }

.head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.head h2 { margin: 0; font-size: 18px; letter-spacing: -0.01em; }
.head .grow { flex: 1; }

/* ── primitives ─────────────────────────────────────────────────────── */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

.card > h3 {
  margin: 0 0 12px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.stat { background: var(--panel-2); border-radius: 6px; padding: 12px 14px; }
.stat .k { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.05em; }
.stat .v { font-size: 22px; font-variant-numeric: tabular-nums; margin-top: 2px; }
.stat.bad .v { color: var(--danger); }
.stat.good .v { color: var(--ok); }

label { display: block; margin-bottom: 12px; }
label .lbl { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }

input, select, textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 6px;
  padding: 8px 10px;
  font: inherit;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: transparent;
}

button.btn {
  background: var(--accent);
  color: #05201d;
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

button.btn:disabled { opacity: 0.5; cursor: not-allowed; }
button.btn.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--line); font-weight: 400; }
button.btn.danger { background: var(--danger); color: #2b0705; }
button.btn.small { padding: 4px 9px; font-size: 12px; }

.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  text-align: left;
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 10px 8px;
  border-bottom: 1px solid var(--line);
}
tbody td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--panel-2); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; font-family: var(--mono); }

.scroll { overflow-x: auto; }

code, .mono { font-family: var(--mono); font-size: 12px; }

.pill {
  display: inline-block;
  padding: 1px 7px;
  border-radius: 20px;
  font-size: 11px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
}
.pill.ok { color: var(--ok); border-color: #17351f; background: #10251699; }
.pill.warn { color: var(--warn); border-color: #3a2f10; background: #2a220c99; }
.pill.bad { color: var(--danger); border-color: #46201e; background: #2d100e99; }

.empty { color: var(--muted); padding: 20px; text-align: center; font-size: 13px; }

.notice {
  border-left: 3px solid var(--warn);
  background: #2a220c55;
  padding: 10px 12px;
  border-radius: 0 6px 6px 0;
  font-size: 13px;
  margin-bottom: 12px;
}
.notice.danger { border-color: var(--danger); background: #2d100e55; }

/* Secrets shown once. Deliberately loud — if it is missed it is gone. */
.secret {
  font-family: var(--mono);
  font-size: 12px;
  background: var(--bg);
  border: 1px dashed var(--accent);
  border-radius: 6px;
  padding: 10px;
  word-break: break-all;
  margin: 8px 0;
}

/* ── modal ──────────────────────────────────────────────────────────── */

.backdrop {
  position: fixed;
  inset: 0;
  background: #010409cc;
  display: grid;
  place-items: center;
  padding: 20px;
  z-index: 40;
}

.modal {
  width: min(460px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 20px;
  max-height: 86vh;
  overflow: auto;
}

.modal h3 { margin: 0 0 14px; font-size: 15px; }

/* ── toasts ─────────────────────────────────────────────────────────── */

.toasts {
  position: fixed;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 50;
}

.toast {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  max-width: 340px;
}
.toast.bad { border-left-color: var(--danger); }

@media (max-width: 720px) {
  .shell { grid-template-columns: 1fr; }
  .side { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--line); }
  .side nav { flex-direction: row; flex-wrap: wrap; }
  .side .spacer, .whoami { display: none; }
  .main { padding: 16px; }
}
