:root {
  color-scheme: light dark;
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f2f8;
  --ink: #25253a;
  --muted: #6c6f80;
  --line: #e4e6ef;
  --primary: #5547cc;
  --primary-ink: #ffffff;
  --primary-soft: #efeefe;
  --danger: #c0392b;
  --danger-soft: #fdecea;
  --warn: #9a6100;
  --warn-soft: #fff4dc;
  --ok: #1d7a4a;
  --ok-soft: #e6f5ec;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 20, 50, .06), 0 8px 24px rgba(20, 20, 50, .05);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141c;
    --surface: #1a1d28;
    --surface-2: #222634;
    --ink: #e3e4ee;
    --muted: #9a9db0;
    --line: #2c3040;
    --primary: #a79ef5;
    --primary-ink: #14121f;
    --primary-soft: #262342;
    --danger: #ff8a7a;
    --danger-soft: #3a1f1d;
    --warn: #f3c262;
    --warn-soft: #3a2f17;
    --ok: #7fd6a2;
    --ok-soft: #173225;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 26px; letter-spacing: -.5px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 17px; margin: 0 0 14px; font-weight: 650; }
p { line-height: 1.6; margin: 0 0 12px; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--primary) 45%, transparent); outline-offset: 2px; }
.skip-link { position: fixed; top: -100px; left: 10px; padding: 10px; background: var(--surface); z-index: 50; }
.skip-link:focus { top: 10px; }
.boot { display: grid; place-items: center; min-height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.nowrap { white-space: nowrap; }

/* Sign-in */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: min(420px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 32px; box-shadow: var(--shadow); }
.auth-card .brand { margin-bottom: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 17px; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand span { color: var(--muted); font-weight: 500; }
.secret { word-break: break-all; background: var(--surface-2); padding: 12px; border-radius: 10px; font-size: 16px; letter-spacing: 1px; }
.codes { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; margin: 14px 0; padding: 0; list-style: none; }
.codes li { background: var(--surface-2); padding: 8px 10px; border-radius: 8px; text-align: center; }

/* Shell */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: block; padding: 9px 12px; border-radius: 10px; color: var(--ink); font-weight: 500; }
.nav a:hover { background: var(--surface-2); text-decoration: none; }
.nav a[aria-current="page"] { background: var(--primary-soft); color: var(--primary); }
.operator { margin-top: auto; border-top: 1px solid var(--line); padding-top: 14px; font-size: 13px; }
.operator strong { display: block; overflow: hidden; text-overflow: ellipsis; }
main { padding: 28px 32px 60px; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.menu-toggle { display: none; }

/* Building blocks */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 16px; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack { display: flex; flex-direction: column; gap: 16px; }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); }
.tile .value { font-size: 28px; font-weight: 650; letter-spacing: -.5px; font-variant-numeric: tabular-nums; }
.tile .label { color: var(--muted); font-size: 13px; }
.tile.alert .value { color: var(--danger); }
.tile.warn .value { color: var(--warn); }
dl.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
dl.facts dt { color: var(--muted); }
dl.facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar input[type="search"] { flex: 1 1 260px; }
input, select, textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; min-width: 0; }
textarea { width: 100%; min-height: 90px; resize: vertical; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
label.field > input, label.field > select, label.field > textarea { color: var(--ink); font-size: 15px; }
label.check { display: flex; gap: 8px; align-items: center; }
form.form { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1 1 160px; }

.btn { border: 1px solid var(--line); background: var(--surface); padding: 9px 14px; border-radius: 10px; cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 35%, var(--line)); }
.btn.danger.solid { background: var(--danger); color: #fff; }
.btn.link { border: 0; background: none; color: var(--primary); padding: 0; }
.btn:disabled { opacity: .55; cursor: wait; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.primary { background: var(--primary-soft); color: var(--primary); }
.badges { display: inline-flex; gap: 6px; flex-wrap: wrap; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.clickable { cursor: pointer; }
tbody tr.clickable:hover { background: var(--surface-2); }
td.num { text-align: right; font-variant-numeric: tabular-nums; }
.empty { padding: 28px; text-align: center; color: var(--muted); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: flex-end; margin-top: 12px; color: var(--muted); font-size: 13px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs button { border: 0; background: none; padding: 10px 14px; border-bottom: 2px solid transparent; color: var(--muted); cursor: pointer; font-weight: 550; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.notice { padding: 12px 14px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); }
.notice.danger { background: var(--danger-soft); color: var(--danger); }
.notice.info { background: var(--primary-soft); color: var(--primary); }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }
pre.details { white-space: pre-wrap; overflow-wrap: break-word; min-width: 220px; margin: 0; font-size: 12px; color: var(--muted); max-width: 420px; }
.logline { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 12.5px; }
td .mono { overflow-wrap: break-word; }

.dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; max-height: calc(100dvh - 32px); overflow-y: auto; width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .25); }
.dialog::backdrop { background: rgba(15, 15, 30, .45); }
.dialog form { padding: 22px; }
.dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 6px; }
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 60; }
.toast { background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 12px; max-width: 360px; box-shadow: var(--shadow); }
.toast.error { background: var(--danger); color: #fff; }

@media (max-width: 1100px) {
  .grid.three { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; padding: 12px 16px; gap: 10px; }
  .sidebar .nav { display: none; }
  .sidebar.open .nav { display: flex; }
  .sidebar .operator { display: none; }
  .sidebar.open .operator { display: block; }
  .sidebar-head { display: flex; justify-content: space-between; align-items: center; }
  .menu-toggle { display: inline-block; }
  main { padding: 18px 16px 48px; }
  .grid.two, .grid.three { grid-template-columns: 1fr; }
  dl.facts { grid-template-columns: 1fr; gap: 2px; }
  dl.facts dd { margin-bottom: 8px; }
  .auth-card { padding: 24px 20px; }
}

.bulkbar { position: sticky; top: 8px; z-index: 5; display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 10px 14px; margin-bottom: 12px; border-radius: 12px; background: var(--primary-soft); border: 1px solid color-mix(in srgb, var(--primary) 30%, var(--line)); }
.bulkbar[hidden] { display: none; }
th.select, td.select { width: 36px; padding-right: 0; }
td.select input, th.select input { width: 18px; height: 18px; }
.notice { white-space: pre-line; }
a.btn { display: inline-block; color: var(--ink); text-decoration: none; }
