/* Cleromant back office. Brand tokens: ink, paper and gold, with cyan on ink
   only. Every state is a dot plus a word, never colour alone. */

@font-face { font-family: "Space Grotesk"; font-weight: 600; font-display: swap; src: url("fonts/space-grotesk-latin-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-sans-latin-400.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Sans"; font-weight: 600; font-display: swap; src: url("fonts/ibm-plex-sans-latin-600.woff2") format("woff2"); }
@font-face { font-family: "IBM Plex Mono"; font-weight: 400; font-display: swap; src: url("fonts/ibm-plex-mono-latin-400.woff2") format("woff2"); }

:root {
  --ink: #0d1321; --ink-2: #141b2c; --ink-3: #1d2638; --ink-line: #263044; --ink-ctl: #3a455c;
  --on-ink: #f2eee4; --on-ink-muted: #a9adb8;
  --paper: #f4f1ea; --card: #fbfaf6; --card-line: #e3ddd0; --ctl-line: #8f8775;
  --text: #0d1321; --muted: #5b5f6a;
  --gold: #e8b045; --gold-text: #7d5509; --gold-on-ink: #f6c557;
  --cyan: #5cc8e0; --link: #0e6378;
  --danger: #a3261d; --danger-bg: #fbeeec; --ok: #2f6b3a; --ok-bg: #edf5ee; --warn: #8a5a00; --warn-bg: #fdf3df;
  --display: "Space Grotesk", system-ui, sans-serif;
  --sans: "IBM Plex Sans", system-ui, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--paper); color: var(--text); font: 400 14px/1.45 var(--sans); }
a { color: var(--link); text-underline-offset: 3px; }
a:hover { color: var(--text); }
:focus-visible { outline: 2px solid var(--link); outline-offset: 2px; }
.sidebar :focus-visible { outline-color: var(--cyan); }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---- shell ---- */
.shell { display: flex; min-height: 100%; }
.sidebar { flex: none; width: 248px; background: var(--ink); color: var(--on-ink); display: flex; flex-direction: column; gap: 22px; padding: 18px 14px;
  position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 0 8px; }
.brand-mark { display: flex; flex-direction: column; gap: 12px; }
.brand img { width: 160px; height: 52px; display: block; }
.kicker { font: 400 11px/1 var(--mono); letter-spacing: .08em; text-transform: uppercase; color: var(--on-ink-muted); }
.menu-btn { display: none; align-items: center; gap: 8px; min-height: 44px; padding: 0 12px; border: 1px solid var(--ink-ctl); border-radius: 8px;
  background: transparent; color: var(--on-ink); font: 600 13px var(--sans); cursor: pointer; }
.side-body { display: flex; flex-direction: column; gap: 22px; flex: 1; }
nav.groups { display: flex; flex-direction: column; gap: 18px; flex: 1; }
.group { display: flex; flex-direction: column; gap: 2px; }
.group > .kicker { padding: 0 10px 6px; }
.group a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 10px; border-radius: 6px; color: var(--on-ink); text-decoration: none; }
.group a::before { content: ""; width: 8px; height: 8px; transform: rotate(45deg); background: var(--ink-ctl); flex: none; }
.group a:hover { background: var(--ink-2); color: var(--gold-on-ink); }
.group a[aria-current="page"] { background: var(--ink-3); color: var(--gold-on-ink); font-weight: 600; }
.group a[aria-current="page"]::before { background: var(--gold); }
.who { display: flex; flex-direction: column; gap: 10px; padding: 14px 10px 0; border-top: 1px solid var(--ink-line); }
.who-name { font: 400 13px var(--mono); overflow-wrap: anywhere; }
.who-roles { font: 400 12px/1.3 var(--mono); color: var(--on-ink-muted); }
.who-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--on-ink-muted); }
.btn-ink-ghost { min-height: 32px; padding: 0 12px; border: 1px solid #5d6880; border-radius: 6px; background: transparent; color: var(--on-ink);
  font: 600 12px var(--sans); cursor: pointer; white-space: nowrap; }

main.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 32px; border-bottom: 1px solid var(--card-line);
  font-size: 13px; color: var(--muted); }
.topbar b { color: var(--text); font-weight: 600; }
.page { padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; max-width: 1480px; }
.page-head h1 { margin: 0 0 6px; font: 600 28px/1.15 var(--display); }
.page-head p { margin: 0; max-width: 760px; color: var(--muted); }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .sidebar { width: auto; height: auto; position: static; }
  .menu-btn { display: inline-flex; }
  .sidebar.closed .side-body { display: none; }
  .topbar, .page { padding-left: 16px; padding-right: 16px; }
}

/* ---- controls ---- */
button, input, select, textarea { font: inherit; color: inherit; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 8px;
  border: 1px solid var(--ctl-line); background: var(--card); color: var(--text); font-weight: 600; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--text); }
.btn.primary { background: var(--gold); border-color: var(--gold); color: var(--ink); }
.btn.primary:hover { background: #f0bf5c; }
.btn.ink { background: var(--ink); border-color: var(--ink); color: var(--gold-on-ink); }
.btn.danger { background: var(--card); border-color: var(--danger); color: var(--danger); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 13px; }
.btn[disabled], .btn[aria-busy="true"] { opacity: .55; cursor: not-allowed; }
.linkish { border: 0; background: none; padding: 0; color: var(--link); text-decoration: underline; text-underline-offset: 3px; cursor: pointer; font: inherit; }
.linkish.mono { font-family: var(--mono); }

label.field { display: flex; flex-direction: column; gap: 4px; font-size: 13px; font-weight: 600; min-width: 0; }
label.field .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
.input, select.input, textarea.input { min-height: 44px; padding: 8px 10px; border: 1px solid var(--ctl-line); border-radius: 8px; background: #fff;
  font-weight: 400; width: 100%; }
textarea.input { min-height: 72px; resize: vertical; }
.input.mono { font-family: var(--mono); font-size: 13px; }
.check { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; font-weight: 600; font-size: 13px; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 14px; align-items: end; }
.form-grid .wide { grid-column: 1 / -1; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
.spacer { flex: 1; }

.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border: 1px solid var(--card-line); border-radius: 10px; background: var(--card); }
.seg button { min-height: 36px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.seg button[aria-checked="true"] { background: var(--ink); color: var(--gold-on-ink); }
.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: end; }

/* ---- surfaces ---- */
.card { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; }
.card-pad { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.card h2, .panel h2 { margin: 0; font: 600 18px/1.2 var(--display); }
.card h3, .panel h3 { margin: 0; font-size: 14px; font-weight: 600; }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 20px; align-items: start; }
@media (max-width: 1200px) { .split { grid-template-columns: minmax(0, 1fr); } }
.panel { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 18px 20px; display: flex; flex-direction: column; gap: 16px;
  position: sticky; top: 16px; }
.panel-empty { color: var(--muted); }
.panel .sub { display: flex; flex-direction: column; gap: 8px; padding-top: 14px; border-top: 1px solid var(--card-line); }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--card-line); flex-wrap: wrap; }
.tabs button { min-height: 40px; padding: 0 12px; border: 0; border-bottom: 3px solid transparent; background: none; cursor: pointer; font-weight: 600; color: var(--muted); }
.tabs button[aria-selected="true"] { color: var(--text); border-bottom-color: var(--gold); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 13px; }
table.data th { text-align: left; font-weight: 600; font-size: 12px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--card-line); white-space: nowrap; }
table.data td { padding: 10px 12px; border-bottom: 1px solid var(--card-line); vertical-align: top; }
table.data tr:last-child td { border-bottom: 0; }
table.data tr.pickable { cursor: pointer; }
table.data tr.pickable:hover td { background: #f6f2e8; }
table.data tr[aria-selected="true"] td { background: #f3ead2; }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; border-top: 1px solid var(--card-line);
  font-size: 12px; color: var(--muted); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

dl.facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 13px; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; overflow-wrap: anywhere; }
pre.json { margin: 0; padding: 12px; border-radius: 8px; background: #f1ede3; font: 400 12px/1.5 var(--mono); overflow: auto; max-height: 360px; white-space: pre-wrap;
  overflow-wrap: anywhere; }

/* ---- state ---- */
.pill { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--danger); } .pill.warn { color: var(--warn); } .pill.wait { color: var(--gold-text); }
.pill.off { color: var(--muted); } .pill.info { color: var(--link); }
.notice { padding: 12px 14px; border-radius: 8px; border: 1px solid; display: flex; flex-direction: column; gap: 4px; font-size: 13px; }
.notice.bad { background: var(--danger-bg); border-color: #e6b8b3; color: var(--danger); }
.notice.ok { background: var(--ok-bg); border-color: #bcd7c0; color: var(--ok); }
.notice.warn { background: var(--warn-bg); border-color: #ecd29c; color: var(--warn); }
.notice.info { background: #eef6f8; border-color: #bcdbe3; color: var(--link); }
.notice b { font-weight: 600; }
.notice .code { font: 400 12px var(--mono); opacity: .85; }

.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.steps li { display: grid; grid-template-columns: 14px 90px minmax(0, 1fr); gap: 8px; align-items: baseline; font-size: 13px; }
.steps li::before { content: ""; width: 8px; height: 8px; transform: rotate(45deg); background: var(--card-line); }
.steps li.done::before { background: var(--gold); }
.steps .who { font-family: var(--mono); font-size: 12px; border: 0; padding: 0; overflow-wrap: anywhere; }

/* ---- sign-in ---- */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.signin-side { background: var(--ink); color: var(--on-ink); padding: 48px; display: flex; flex-direction: column; justify-content: space-between; gap: 32px; }
.signin-side img { width: 220px; height: auto; }
.signin-side p { color: var(--on-ink-muted); max-width: 420px; }
.signin-main { padding: 48px; display: flex; flex-direction: column; justify-content: center; gap: 18px; max-width: 560px; }
.signin-main h1 { margin: 0; font: 600 32px/1.1 var(--display); }
@media (max-width: 900px) { .signin { grid-template-columns: 1fr; } .signin-side, .signin-main { padding: 24px 16px; } }

.levels-edit td { padding: 6px 8px; }
.levels-edit .input { min-height: 36px; padding: 4px 8px; min-width: 90px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
details > summary { cursor: pointer; font-weight: 600; }
details.card > summary { list-style: none; }
details.card > summary h2 { display: inline; }
.nowrap { white-space: nowrap; overflow-wrap: normal; }
