:root {
  /* HyperBiscuit brand: navy for structure and primary actions, cyan as the highlight on navy.
     Cyan is too light for text on white (1.5:1), so --accent-ink is a darkened teal for links. */
  --brand: #0d2658;
  --brand-hover: #173b7e;
  --highlight: #48e6e8;
  --highlight-soft: #e0fafa;
  --accent-ink: #0a6f75;
  --bg: #f3f6fa;
  --panel: #ffffff;
  --panel-alt: #f6f8fb;
  --ink: #16213a;
  --muted: #5a6781;
  --line: #dde3ec;
  --input-line: #cbd4e1;
  --ok: #2f7a4a;
  --ok-soft: #e3f2e8;
  --warn: #9a6a00;
  --warn-soft: #fbf1d6;
  --bad: #b3261e;
  --bad-soft: #fbe5e3;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Menlo, Consolas, monospace;
  --radius: 8px;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font: 14px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
pre { background: #0a1d45; color: #e3eaf6; padding: 12px 14px; border-radius: var(--radius); overflow-x: auto;
      white-space: pre-wrap; word-break: break-word; margin: 8px 0 12px; }
pre.light { background: var(--panel-alt); color: var(--ink); border: 1px solid var(--line); }
h1 { font-size: 22px; margin: 0 0 4px; color: var(--brand); }
h2 { font-size: 16px; margin: 28px 0 10px; color: var(--brand); }
h3 { font-size: 14px; margin: 18px 0 8px; }
p.lead { color: var(--muted); margin: 0 0 20px; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
nav.side { background: var(--brand); color: #c9d3e6; padding: 18px 12px; position: sticky; top: 0; height: 100vh; }
nav.side .brand { display: flex; gap: 10px; align-items: center; color: #fff; font-weight: 650; padding: 0 8px 18px; }
nav.side .brand img { height: 30px; width: auto; }
nav.side .brand small { display: block; font-weight: 400; color: #8a9bbd; font-size: 11.5px; }
nav.side .section { text-transform: uppercase; font-size: 10.5px; letter-spacing: .08em; color: #8a9bbd;
  margin: 18px 8px 6px; }
nav.side a { display: flex; justify-content: space-between; color: #dbe3f1; padding: 6px 8px; border-radius: 6px; }
nav.side a:hover { background: rgba(255, 255, 255, .07); text-decoration: none; }
nav.side a.active { background: rgba(72, 230, 232, .14); color: #fff; box-shadow: inset 3px 0 0 var(--highlight); }
nav.side .badge { background: var(--highlight); color: var(--brand); }
nav.side .who { position: absolute; bottom: 16px; left: 12px; right: 12px; font-size: 12px; color: #8a9bbd;
  border-top: 1px solid rgba(255, 255, 255, .12); padding-top: 12px; overflow-wrap: anywhere; }
nav.side .who a { display: inline; padding: 0; color: var(--highlight); }
main { padding: 28px 36px 60px; max-width: 1280px; }

body.anon { background: var(--brand); }
main.anon { max-width: 640px; margin: 10vh auto; padding: 0 20px; }
.anon-brand { display: flex; gap: 14px; align-items: center; color: #fff; font-size: 20px; font-weight: 650;
  margin-bottom: 22px; }
.anon-brand:hover { text-decoration: none; }
.anon-brand img { height: 52px; width: auto; }
.anon-brand small { display: block; font-size: 13px; font-weight: 400; color: #8a9bbd; }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px;
  margin-bottom: 16px; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); }
.grid.three { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.stat { font-size: 26px; font-weight: 650; color: var(--brand); }
.stat-label { color: var(--muted); font-size: 12.5px; }

table.data { width: 100%; border-collapse: collapse; background: var(--panel); border: 1px solid var(--line);
  border-radius: var(--radius); overflow: hidden; }
table.data th, table.data td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
  vertical-align: top; }
table.data th { background: var(--panel-alt); font-weight: 600; font-size: 12.5px; color: var(--muted); white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.sql { font-family: var(--mono); font-size: 12px; max-width: 520px; overflow-wrap: anywhere; }
table.data td.num, table.data th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11.5px; font-weight: 600;
  background: #e8edf4; color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn, .badge.timeout, .badge.cancelled, .badge.started { background: var(--warn-soft); color: var(--warn); }
.badge.bad, .badge.error, .badge.denied, .badge.rejected { background: var(--bad-soft); color: var(--bad); }
.badge.accent { background: var(--highlight-soft); color: var(--brand); }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; background: var(--ok-soft);
  color: var(--ok); border: 1px solid #cfe7d7; }
.flash.error { background: var(--bad-soft); color: var(--bad); border-color: #f2c9c5; }
.notice { padding: 10px 14px; border-radius: var(--radius); background: var(--warn-soft); color: #6d4c00;
  border: 1px solid #efdca6; margin-bottom: 14px; }

form.inline { display: inline; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
input[type=text], input[type=email], input[type=number], input[type=date], input[type=search], select, textarea {
  font: inherit; padding: 7px 9px; border: 1px solid var(--input-line); border-radius: 6px; background: #fff; min-width: 0; }
textarea { width: 100%; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: 3px solid rgba(72, 230, 232, .45); border-color: var(--brand); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); }
button, .button { font: inherit; font-weight: 600; padding: 7px 14px; border-radius: 6px; border: 1px solid var(--brand);
  background: var(--brand); color: #fff; cursor: pointer; display: inline-block; }
button:hover, .button:hover { background: var(--brand-hover); border-color: var(--brand-hover); text-decoration: none; }
button:focus-visible, .button:focus-visible { outline: 3px solid var(--highlight); outline-offset: 1px; }
button.secondary, .button.secondary { background: #fff; color: var(--brand); border-color: var(--input-line); }
button.secondary:hover, .button.secondary:hover { background: var(--panel-alt); border-color: var(--brand); }
button.danger { background: #fff; color: var(--bad); border-color: #e5b4af; }
button.danger:hover { background: var(--bad-soft); border-color: var(--bad); }
button.small, .button.small { padding: 3px 10px; font-size: 12.5px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; }
.checks label { display: inline-flex; gap: 6px; align-items: center; color: var(--ink); font-size: 13px; margin: 0; }

.token { font-family: var(--mono); font-size: 13px; padding: 10px 12px; background: var(--highlight-soft);
  border: 1px dashed var(--accent-ink); border-radius: var(--radius); word-break: break-all; }

/* grant editor */
.grant-toolbar { display: flex; gap: 10px; align-items: center; position: sticky; top: 0; background: var(--bg);
  padding: 10px 0; z-index: 2; border-bottom: 1px solid var(--line); margin-bottom: 12px; }
.grant-table { border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); margin-bottom: 10px; }
.grant-table > summary { display: grid; grid-template-columns: minmax(240px, 1.4fr) 210px 1fr auto; gap: 12px;
  align-items: center; padding: 10px 14px; cursor: pointer; list-style: none; }
.grant-table > summary::-webkit-details-marker { display: none; }
.grant-table:not([data-mode=none]) { border-left: 3px solid var(--highlight); }
.grant-table[data-mode=none] > summary .tname { color: var(--muted); }
.grant-table .body { padding: 4px 14px 14px; border-top: 1px solid var(--line); }
.grant-table .cols { columns: 3 220px; column-gap: 20px; }
.grant-table .cols label { display: flex; gap: 6px; align-items: baseline; color: var(--ink); font-size: 13px;
  break-inside: avoid; margin: 2px 0; }
.grant-table .cols .type { color: var(--muted); font-family: var(--mono); font-size: 11px; }
.grant-table .cols .inh { color: var(--ok); font-size: 11px; }
.grant-table.hidden { display: none; }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  nav.side { position: static; height: auto; }
  nav.side .who { position: static; margin-top: 16px; }
  main { padding: 20px; }
  .grant-table > summary { grid-template-columns: 1fr; }
}
