@font-face {
  font-family: 'Inter';
  src: url('/fonts/inter/inter-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 900;
  font-display: swap;
}
@font-face {
  font-family: 'JetBrains Mono';
  src: url('/fonts/mono/jetbrains-mono-latin-wght-normal.woff2') format('woff2');
  font-weight: 100 800;
  font-display: swap;
}

:root {
  color-scheme: dark;
  /* Sampled from the Fiberifi logo: #5eaafd, #2377e9, #013a86 */
  --brand-light: #5eaafd;
  --brand: #2377e9;
  --brand-deep: #013a86;

  --bg: #0a1426;
  --surface: #101c33;
  --surface-2: #162540;
  --surface-3: #1d2f50;
  --line: #24365a;
  --line-strong: #35496f;

  --ink: #eef3fb;
  --ink-2: #b4c1d6;
  --ink-3: #8a9ab5;
  --ink-locked: #76859f;

  --good: #3ecf9a;
  --warn: #f5b84a;
  --bad: #ff7b86;
  --bad-fill: #c93445;

  --radius: 8px;
  --radius-sm: 6px;
  --mono: 'JetBrains Mono', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  font-feature-settings: 'cv11', 'ss03';
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd, ul { margin: 0; padding: 0; }
ul { list-style: none; }
h1 { font-size: 22px; font-weight: 650; letter-spacing: -0.01em; line-height: 1.25; }
h2 { font-size: 15px; font-weight: 600; }
a { color: var(--brand-light); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--brand-light); outline-offset: 2px; }
.mono { font-family: var(--mono); font-size: 13px; font-variant-ligatures: none; }
.muted { color: var(--ink-3); }
.nowrap { white-space: nowrap; }
.break { overflow-wrap: anywhere; }
.right { text-align: right; }
.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}

/* ---- shell ---- */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky; top: 0; height: 100dvh;
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 12px 12px;
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.brand { display: flex; flex-direction: column; gap: 6px; padding: 0 8px; }
.brand img { width: 128px; height: auto; display: block; }
.brand span { font-size: 11px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase; color: var(--ink-3); }
.nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  color: var(--ink-2); font-weight: 500;
}
.nav a:hover { background: var(--surface-2); color: var(--ink); text-decoration: none; }
.nav a[aria-current='page'] { background: var(--surface-3); color: var(--ink); box-shadow: inset 2px 0 0 var(--brand-light); }
.nav svg { flex: none; }
.who { display: flex; align-items: center; gap: 8px; padding: 10px 8px 0; border-top: 1px solid var(--line); }
.who div { min-width: 0; flex: 1; }
.who strong, .who small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who strong { font-weight: 550; font-size: 13px; }
.who small { color: var(--ink-3); font-size: 12px; }
.topbar { display: none; }
.main { min-width: 0; padding: 24px 28px 48px; max-width: 1360px; width: 100%; }

.searchbox { position: relative; }
.searchbox svg { position: absolute; left: 9px; top: 50%; translate: 0 -50%; color: var(--ink-3); pointer-events: none; }
.searchbox input { padding-left: 30px; }

/* ---- page furniture ---- */
.page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px 24px; margin-bottom: 20px; }
.page-head > div:first-child { min-width: 0; }
.page-head p { color: var(--ink-3); margin-top: 3px; }
.page-title { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-title h1.mono { font-size: 21px; font-weight: 600; overflow-wrap: anywhere; }
.crumbs { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--ink-3); margin-bottom: 6px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--line); }
.toolbar .grow { flex: 1 1 200px; min-width: 160px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); margin-bottom: 16px; min-width: 0; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.panel-body { padding: 14px; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 2fr); gap: 16px; align-items: start; }
.grid-2 > .panel { margin-bottom: 0; }
.stack { display: flex; flex-direction: column; gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.stat b { display: block; font-size: 24px; font-weight: 600; letter-spacing: -0.01em; font-variant-numeric: tabular-nums; line-height: 1.2; }
.stat span { color: var(--ink-3); font-size: 13px; }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 12px 20px; padding: 14px; }
.facts dt { color: var(--ink-3); font-size: 12px; margin-bottom: 1px; }
.facts dd { overflow-wrap: anywhere; }

.notice { display: flex; align-items: flex-start; gap: 10px; padding: 10px 14px; margin-bottom: 16px; border: 1px solid var(--line-strong); border-left: 3px solid var(--warn); border-radius: var(--radius-sm); background: var(--surface); }
.notice svg { flex: none; margin-top: 2px; color: var(--warn); }
.notice.info { border-left-color: var(--brand-light); }
.notice.info svg { color: var(--brand-light); }

/* ---- controls ---- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
  background: var(--surface-2); color: var(--ink);
  font-weight: 500; cursor: pointer; white-space: nowrap;
  transition: background-color 120ms, border-color 120ms;
}
.btn:hover { background: var(--surface-3); text-decoration: none; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: #3a88ee; }
.btn.danger { background: transparent; border-color: var(--bad); color: var(--bad); }
.btn.danger:hover { background: rgb(255 123 134 / 0.12); }
.btn.danger-solid { background: var(--bad-fill); border-color: var(--bad-fill); color: #fff; }
.btn.danger-solid:hover { background: #dc4254; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--surface-2); color: var(--ink); }
.btn.sm { min-height: 28px; padding: 3px 9px; font-size: 13px; }
.btn.icon { padding: 6px; min-width: 34px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

input, select, textarea {
  width: 100%; min-height: 34px; padding: 6px 10px;
  background: var(--bg); border: 1px solid var(--line-strong); border-radius: var(--radius-sm);
}
input[type='checkbox'] { width: 16px; height: 16px; min-height: 0; padding: 0; accent-color: var(--brand); flex: none; }
input::placeholder, textarea::placeholder { color: var(--ink-locked); }
input:disabled, textarea:disabled, select:disabled { color: var(--ink-locked); background: var(--surface-2); cursor: not-allowed; }
textarea { resize: vertical; min-height: 72px; }
.toolbar select { width: auto; }

.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-weight: 500; font-size: 13px; color: var(--ink-2); }
.field .hint { font-size: 12.5px; color: var(--ink-3); }
.field .err { font-size: 12.5px; color: var(--bad); }
.field.invalid input, .field.invalid select { border-color: var(--bad); }
.check { display: flex; align-items: flex-start; gap: 8px; }
.check input { margin-top: 2px; }
.form { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.form-error { padding: 8px 10px; border-radius: var(--radius-sm); background: rgb(255 123 134 / 0.1); color: var(--bad); }
.form-note { padding: 8px 10px; border-radius: var(--radius-sm); background: var(--surface-2); color: var(--ink-2); }

/* ---- tables ---- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  padding: 8px 12px; text-align: left; white-space: nowrap;
  font-size: 12px; font-weight: 550; color: var(--ink-3);
  border-bottom: 1px solid var(--line);
}
td { padding: 7px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover td { background: rgb(255 255 255 / 0.018); }
.cell-link { background: none; border: 0; padding: 0; cursor: pointer; color: var(--brand-light); text-align: left; }
.cell-link:hover { text-decoration: underline; }
.indent { display: inline-block; }
tr.locked td { background: rgb(255 255 255 / 0.02); color: var(--ink-locked); }
tr.locked:hover td { background: rgb(255 255 255 / 0.02); }
tr.free .mono:not(.cell-link) { color: var(--ink-2); }
.lock { display: inline-flex; align-items: center; gap: 6px; }
.chev {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; margin-right: 4px; padding: 0;
  background: none; border: 0; border-radius: 4px; color: var(--ink-3); cursor: pointer; vertical-align: middle;
}
.chev:hover { background: var(--surface-3); color: var(--ink); }
.chev svg { transition: rotate 120ms; }
.chev.open svg { rotate: 90deg; }
.explore-head td { padding-block: 5px; background: var(--bg); font-size: 12.5px; color: var(--ink-3); }
.explore-head select { width: auto; min-height: 26px; padding: 1px 6px; margin: 0 6px 0 2px; }
tbody tr.explore-head:hover td { background: var(--bg); }
.row-actions { justify-content: flex-end; flex-wrap: nowrap; }
.empty { padding: 32px 20px; text-align: center; color: var(--ink-3); }
.empty strong { display: block; color: var(--ink); font-weight: 600; margin-bottom: 2px; }
.empty .btn { margin-top: 12px; }
.pager { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--line); color: var(--ink-3); font-size: 13px; }

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 1px 7px; border-radius: 999px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  background: var(--surface-3); color: var(--ink-2);
}
.badge.good { background: rgb(62 207 154 / 0.14); color: var(--good); }
.badge.warn { background: rgb(245 184 74 / 0.14); color: var(--warn); }
.badge.bad { background: rgb(255 123 134 / 0.14); color: var(--bad); }
.badge.brand { background: rgb(94 170 253 / 0.14); color: var(--brand-light); }

/* ---- data marks ---- */
.meter { display: flex; align-items: center; gap: 8px; min-width: 128px; }
.meter-track { flex: 1; height: 6px; border-radius: 3px; background: var(--surface-3); overflow: hidden; }
.meter-fill { display: block; height: 100%; border-radius: 3px; background: var(--brand-light); }
.meter-fill.full { background: var(--warn); }
.meter span.value { flex: none; width: 52px; text-align: right; color: var(--ink-2); font-size: 12.5px; font-variant-numeric: tabular-nums; }

.alloc { padding: 14px; border-bottom: 1px solid var(--line); }
.alloc-track { position: relative; height: 22px; border-radius: 4px; background: var(--surface-3); overflow: hidden; }
.alloc-seg { position: absolute; top: 0; bottom: 0; background: var(--brand); border-right: 2px solid var(--surface); min-width: 3px; }
.alloc-seg.assigned { background: var(--brand-light); }
.alloc-seg:hover { filter: brightness(1.2); }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; font-size: 12.5px; color: var(--ink-3); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 5px; vertical-align: -1px; }

.tabs { display: flex; gap: 2px; padding: 0 8px; border-bottom: 1px solid var(--line); overflow-x: auto; }
.tabs button {
  padding: 10px 10px; background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--ink-3); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.tabs button:hover { color: var(--ink); }
.tabs button[aria-selected='true'] { color: var(--ink); border-bottom-color: var(--brand-light); }

.activity li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.activity li:last-child { border-bottom: 0; }
.activity time { flex: none; color: var(--ink-3); font-size: 12.5px; }
.activity div { min-width: 0; overflow-wrap: anywhere; }

.skeleton { height: 220px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); }

/* ---- dialogs ---- */
dialog {
  width: min(520px, calc(100vw - 24px)); max-height: calc(100dvh - 24px);
  padding: 0; color: var(--ink);
  background: var(--surface); border: 1px solid var(--line-strong); border-radius: 10px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.5);
}
dialog::backdrop { background: rgb(4 9 18 / 0.68); }
.dialog-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.dialog-head h2 { font-size: 16px; overflow-wrap: anywhere; }
.dialog-body { padding: 12px 16px 16px; }
.dialog-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.dialog-actions .spacer { margin-right: auto; }
.section-title { margin: 16px 0 8px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 13.5px; font-weight: 600; }
.secret { display: flex; gap: 8px; align-items: center; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--bg); border: 1px solid var(--line-strong); }
.secret code { flex: 1; font-family: var(--mono); overflow-wrap: anywhere; }

.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 50; display: flex; flex-direction: column; gap: 8px; width: min(380px, calc(100vw - 32px)); }
.toast { padding: 10px 14px; border-radius: var(--radius-sm); border: 1px solid var(--line-strong); border-left: 3px solid var(--good); background: var(--surface-3); box-shadow: 0 10px 30px rgb(0 0 0 / 0.4); }
.toast.warn { border-left-color: var(--warn); }
.toast.error { border-left-color: var(--bad); }

/* ---- sign in ---- */
.auth { display: grid; place-items: center; min-height: 100dvh; padding: 16px; }
.auth-card { width: min(380px, 100%); }
.auth-card img { display: block; width: 168px; height: auto; margin: 0 auto 8px; }
.auth-card > p { text-align: center; color: var(--ink-3); margin-bottom: 20px; }
.auth-card .panel { padding: 20px; }
.auth-card .btn { width: 100%; }

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 760px) {
  .layout { display: block; }
  .topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between;
    padding: 8px 16px; background: var(--surface); border-bottom: 1px solid var(--line);
  }
  .topbar img { width: 96px; height: auto; display: block; }
  .sidebar { display: none; position: fixed; inset: 53px 0 0; z-index: 19; height: auto; border-right: 0; overflow-y: auto; }
  .sidebar.open { display: flex; }
  .sidebar .brand { display: none; }
  .main { padding: 16px 16px 40px; }
  .actions .btn { flex: 1 1 auto; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}
@media (forced-colors: active) {
  .meter-fill, .alloc-seg { background: Highlight; }
}
