/* Arb Scanner admin panel. Ported from the splashes panel's stylesheet.
   One admin, one screen, mostly tables and forms. No framework, and no inline
   styles anywhere: the CSP is style-src 'self'. */

:root {
  --bg: #f7f8fa;
  --panel: #ffffff;
  --border: #dfe3e8;
  --text: #1c2024;
  --muted: #6b7280;
  --accent: #2563eb;
  --accent-text: #ffffff;
  --ok: #15803d;
  --warn: #b45309;
  --err: #b91c1c;
  --ok-bg: #dcfce7;
  --warn-bg: #fef3c7;
  --err-bg: #fee2e2;
  --pos: #15803d;
  --neg: #b91c1c;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115;
    --panel: #171a21;
    --border: #2a2f3a;
    --text: #e5e7eb;
    --muted: #9aa3b2;
    --accent: #3b82f6;
    --accent-text: #ffffff;
    --ok: #4ade80;
    --warn: #fbbf24;
    --err: #f87171;
    --ok-bg: #14321f;
    --warn-bg: #3a2c0c;
    --err-bg: #3b1414;
    --pos: #4ade80;
    --neg: #f87171;
  }
}

* { box-sizing: border-box; }

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

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

[hidden] { display: none !important; }

/* ------------------------------------------------------------- app chrome */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  padding: 0.65rem 1.25rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.topbar .brand {
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text);
}

.topbar nav { display: flex; gap: 0.9rem; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); font-size: 0.88rem; }
.topbar nav a.active { color: var(--text); font-weight: 550; }
.topbar .logout { margin: 0 0 0 auto; }

main { max-width: 1480px; margin: 0 auto; padding: 1.25rem 1.25rem 4rem; }
/* The wide grids (Live spreads, Health) use the whole window: on a wide
   monitor every column fits, and the horizontal scroll only appears when the
   window really is too narrow for the table. */
main.wide { max-width: none; }

h1 { font-size: 1.35rem; margin: 0 0 1rem; letter-spacing: -0.015em; }
h2 { font-size: 1.05rem; margin: 1.6rem 0 0.6rem; letter-spacing: -0.01em; }

.page-head { display: flex; align-items: baseline; gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.page-head h1 { margin: 0; }

.muted { color: var(--muted); }
.mono { font-family: var(--mono); font-size: 0.88em; }
.small { font-size: 0.83rem; }
.nomargin { margin: 0; }
.pos { color: var(--pos); }
.neg { color: var(--neg); }
.warn { color: var(--warn); }
.err { color: var(--err); }

/* A page's standing explanation: what it shows, what applies when. */
.note { color: var(--muted); font-size: 0.85rem; margin: 0 0 0.9rem; max-width: 60rem; }

/* ----------------------------------------------------------------- panels */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
}

.panel > :first-child { margin-top: 0; }
.panel > :last-child { margin-bottom: 0; }

/* Wide tables scroll inside their panel instead of widening the page. */
.scroll { overflow-x: auto; }

.cols2 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 0 1rem;
}

/* ------------------------------------------------------------------ forms */

.auth-wrap {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 1.5rem;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1.75rem;
}

.auth-card h1 { font-size: 1.15rem; margin-bottom: 0.35rem; }
.auth-card .sub { color: var(--muted); font-size: 0.9rem; margin: 0 0 1.35rem; }
.auth-card p.small { margin: 0 0 0.5rem; }
form.stacked { margin-top: 0.75rem; }

label {
  display: block;
  font-size: 0.83rem;
  font-weight: 550;
  color: var(--muted);
  margin-bottom: 0.3rem;
}

input[type=text], input[type=password], input[type=number], input[type=search], select, textarea {
  width: 100%;
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
}

textarea { font-family: var(--mono); font-size: 0.85rem; min-height: 8rem; }

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

.field { margin-bottom: 0.9rem; }
.hint { color: var(--muted); font-size: 0.8rem; margin-top: 0.2rem; font-weight: 400; }

.otp-input {
  font-family: var(--mono);
  font-size: 1.4rem;
  letter-spacing: 0.35em;
  text-align: center;
}

button, .btn {
  display: inline-block;
  padding: 0.5rem 0.95rem;
  border: 1px solid transparent;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 550;
  cursor: pointer;
}

button:hover, .btn:hover { filter: brightness(1.08); text-decoration: none; }
button.wide { width: 100%; }
button.small, .btn.small { padding: 0.2rem 0.55rem; font-size: 0.8rem; }

button.secondary, .btn.secondary {
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

button.danger { background: transparent; color: var(--err); border-color: var(--border); }
button.danger:hover { background: var(--err-bg); }

/* A button that reads as a link, for in-table actions. */
button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-weight: inherit;
}

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

.checks {
  display: flex;
  gap: 1.4rem;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.check {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  font-size: 0.9rem;
  font-weight: 400;
  color: var(--text);
  margin: 0;
}

input[type=checkbox] { width: auto; accent-color: var(--accent); }

form.inline { display: inline-flex; gap: 0.4rem; align-items: flex-end; margin: 0; }

/* A row of compact filters above a table. */
.toolbar {
  display: flex;
  gap: 0.9rem;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 0.8rem;
}

.toolbar label { margin: 0; }
.toolbar input[type=text], .toolbar input[type=search], .toolbar input[type=number], .toolbar select {
  width: auto;
  padding: 0.3rem 0.5rem;
  font-size: 0.88rem;
}

.row-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  flex-wrap: wrap;
  margin-bottom: 0.9rem;
}

.row-head form { margin: 0; }
.grow { flex: 1; margin-left: auto; }

/* ------------------------------------------------------------------- tabs */

.tabs { display: flex; gap: 0.35rem; margin-bottom: 0.8rem; flex-wrap: wrap; }

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  padding: 0.3rem 0.8rem;
  font-size: 0.88rem;
}

.tab.active { color: var(--accent); border-color: var(--accent); }
.tab .count { color: var(--muted); font-weight: 400; }

/* ----------------------------------------------------------------- alerts */

.flash {
  padding: 0.6rem 0.8rem;
  border-radius: 7px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.flash.error { background: var(--err-bg); color: var(--err); }
.flash.warn  { background: var(--warn-bg); color: var(--warn); }
.flash.ok    { background: var(--ok-bg); color: var(--ok); }

/* ----------------------------------------------------------------- tables */

table { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 550; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.04em; white-space: nowrap; }
tbody tr:last-child td { border-bottom: none; }
td.num, th.num { text-align: right; font-family: var(--mono); font-size: 0.85rem; }
th.num { font-family: inherit; font-size: 0.78rem; }
th[data-sort] { cursor: pointer; user-select: none; }
th[data-sort]:hover { color: var(--text); }
th.sorted { color: var(--accent); }

/* Dense tables: the live and health grids. */
table.compact { font-size: 0.83rem; }
table.compact th, table.compact td { padding: 0.3rem 0.5rem; white-space: nowrap; }
table.compact td.wrap { white-space: normal; min-width: 14rem; }

/* Two-column key/value tables. */
table.kv td:first-child { color: var(--muted); width: 45%; }
table.kv td:last-child { font-family: var(--mono); font-size: 0.85rem; }

table.spaced { margin-bottom: 1.1rem; }
th.tick, td.tick { width: 2rem; }

/* ------------------------------------------------------------------ pills */

.pill {
  display: inline-block;
  padding: 0.05rem 0.5rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: nowrap;
}

.pill.ok       { background: var(--ok-bg); color: var(--ok); }
.pill.degraded { background: var(--warn-bg); color: var(--warn); }
.pill.down     { background: var(--err-bg); color: var(--err); }
.pill.off      { background: var(--border); color: var(--muted); }

/* A small bordered label: instrument class, scope level. */
.tag {
  display: inline-block;
  font-size: 0.72rem;
  padding: 0 0.3rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--muted);
  margin-left: 0.25rem;
  font-weight: 400;
}

/* ------------------------------------------------------------ live table */

table.live td.verdict { white-space: normal; min-width: 16rem; max-width: 30rem; }
table.live .reason { display: block; }
table.live .source { display: block; color: var(--muted); font-size: 0.78rem; }
table.live .leg-market { color: var(--muted); margin-left: 0.25rem; }
table.live td.stale { color: var(--warn); }

/* The per-row action menu (mute). */
details.menu { position: relative; display: inline-block; }
details.menu > summary {
  list-style: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 0.83rem;
}
details.menu > summary::-webkit-details-marker { display: none; }
details.menu[open] > summary { font-weight: 600; }

.menu-body {
  position: absolute;
  right: 0;
  z-index: 10;
  margin-top: 0.3rem;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem 0.7rem;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}

details.menu.up .menu-body { bottom: 100%; margin: 0 0 0.3rem; }

.menu-body form { margin: 0 0 0.5rem; }
.menu-body form:last-child { margin-bottom: 0; }
.menu-title { font-size: 0.78rem; color: var(--muted); margin-bottom: 0.25rem; }
.menu-body button { margin-right: 0.25rem; }

.actions { display: flex; gap: 0.7rem; align-items: baseline; }

/* ------------------------------------------------------------- empty state */

.empty {
  padding: 2.5rem 1rem;
  text-align: center;
  color: var(--muted);
}

.empty code, code {
  font-family: var(--mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 0.1rem 0.35rem;
  font-size: 0.85em;
}

.qr { display: block; margin: 0 auto 1rem; border-radius: 8px; background: #fff; padding: 8px; }

.secret-box {
  font-family: var(--mono);
  font-size: 0.85rem;
  word-break: break-all;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 0.6rem;
  margin-bottom: 1rem;
}

.pager {
  margin-top: 0.85rem;
  display: flex;
  gap: 0.7rem;
  align-items: center;
}
