/* Tokens from docs/design/design-system.md (the only source of visual values). */
@font-face { font-family: "Cairo"; src: url("fonts/Cairo_400Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("fonts/Cairo_500Medium.ttf") format("truetype"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("fonts/Cairo_600SemiBold.ttf") format("truetype"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Cairo"; src: url("fonts/Cairo_700Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --k-navy: #0A2136; --k-rail: #08192A; --k-navy-2: #173F5F;
  --k-teal: #147D92; --k-teal-100: #E6F2F4; --k-teal-ink: #0E5E6E; --k-teal-bright: #4FD1C5;
  --k-green: #1F9D6A; --k-green-100: #E9F6F1; --k-green-ink: #14724D;
  --k-amber: #E29A2D; --k-amber-100: #FDF6EA; --k-amber-ink: #8A6014; --k-amber-line: #F0DFC0;
  --k-red: #D64545; --k-red-100: #FBEAEA; --k-red-ink: #A63A3A; --k-red-line: #F0C8C8;
  --k-purple: #5B4B8A; --k-purple-100: #EEEAF7;
  --k-ink: #10202F; --k-ink-2: #43586B; --k-muted: #7A8CA0;
  --k-line: #E2E9F0; --k-line-2: #CBD8E4; --k-canvas: #F2F5F8; --k-soft: #EDF3F7; --k-surface: #FFFFFF;
  --font: "Cairo", "Segoe UI", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--k-canvas); color: var(--k-ink); font-family: var(--font); font-size: 13px; line-height: 23px; }
.num { font-variant-numeric: tabular-nums; direction: ltr; unicode-bidi: isolate; white-space: nowrap; }
.ltr { direction: ltr; unicode-bidi: isolate; }
.muted { color: var(--k-muted); font-size: 11.5px; line-height: 19px; }
.hidden { display: none !important; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: row; min-height: 100vh; }
.rail { width: 248px; flex: 0 0 248px; background: var(--k-rail); color: #FFFFFF; padding: 20px 12px; display: flex; flex-direction: column; gap: 4px; }
.brand { padding: 4px 12px 20px; }
.brand-title { font-size: 18px; font-weight: 600; }
.brand-sub { font-size: 11.5px; color: #8FA9BE; }
.rail-group { font-size: 10px; font-weight: 600; letter-spacing: 1.2px; color: #4E6C85; padding: 12px 12px 4px; }
.nav-item { height: 40px; display: flex; align-items: center; gap: 12px; padding: 0 12px; border-radius: 8px; color: #A8BECD; text-decoration: none; font-weight: 400; position: relative; }
.nav-item:hover { color: #FFFFFF; }
.nav-item.active { background: #12314B; color: #FFFFFF; font-weight: 600; }
.nav-item.active::before { content: ""; position: absolute; inset-inline-start: 0; top: 11px; width: 4px; height: 18px; border-radius: 2px; background: var(--k-teal-bright); }
.rail-foot { margin-top: auto; padding: 12px; font-size: 11.5px; color: #6F8AA0; display: flex; flex-direction: column; gap: 8px; }
.rail-foot button { align-self: flex-start; }
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { background: var(--k-surface); border-bottom: 1px solid var(--k-line); padding: 16px 26px; display: flex; flex-direction: row; align-items: center; gap: 16px; }
.topbar .eyebrow { font-size: 10px; font-weight: 600; letter-spacing: 1.6px; color: var(--k-muted); direction: ltr; unicode-bidi: isolate; text-align: right; }
.topbar h1 { margin: 0; font-size: 21px; line-height: 32px; font-weight: 600; }
.topbar .spacer { flex: 1; }
.content { padding: 20px 26px 44px; display: flex; flex-direction: column; gap: 16px; }

/* ---------- surfaces ---------- */
.card { background: var(--k-surface); border: 1px solid var(--k-line); border-radius: 12px; }
.card-head { padding: 16px 20px; border-bottom: 1px solid var(--k-line); display: flex; flex-direction: row; align-items: center; gap: 12px; }
.card-head h2 { margin: 0; font-size: 15.5px; line-height: 24px; font-weight: 600; }
.card-head .spacer { flex: 1; }
.card-body { padding: 18px 20px; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0; }
.fact { padding: 16px 20px; border-inline-start: 1px solid var(--k-line); }
.fact:first-child { border-inline-start: 0; }
.fact .label { font-size: 11.5px; line-height: 19px; color: var(--k-muted); font-weight: 500; }
.fact .value { font-size: 17px; font-weight: 600; margin-top: 4px; }
.band { background: var(--k-navy); color: #FFFFFF; border-radius: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.band .fact { border-inline-start: 1px solid #FFFFFF1A; }
.band .fact:first-child { border-inline-start: 0; }
.band .fact .label { color: #8FA9BE; }
.band .fact .value { font-size: 26px; line-height: 36px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: right; font-size: 11.5px; font-weight: 600; color: var(--k-muted); padding: 10px 16px; border-bottom: 1px solid var(--k-line-2); white-space: nowrap; }
td { padding: 10px 16px; border-bottom: 1px solid var(--k-line); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.first { font-weight: 600; }
td.n, th.n { text-align: left; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--k-soft); }
.empty { padding: 26px 20px; text-align: center; color: var(--k-muted); }

/* ---------- badge ---------- */
.badge { display: inline-block; border-radius: 7px; padding: 5px 10px; font-size: 11px; line-height: 13px; font-weight: 600; white-space: nowrap; }
.b-green { background: var(--k-green-100); color: var(--k-green-ink); }
.b-amber { background: var(--k-amber-100); color: var(--k-amber-ink); }
.b-red { background: var(--k-red-100); color: var(--k-red-ink); }
.b-teal { background: var(--k-teal-100); color: var(--k-teal-ink); }
.b-purple { background: var(--k-purple-100); color: var(--k-purple); }
.b-soft { background: var(--k-soft); color: var(--k-ink-2); }

/* ---------- controls ---------- */
button, .btn { font-family: var(--font); font-size: 13px; font-weight: 600; height: 42px; padding: 0 16px; border-radius: 8px; cursor: pointer; border: 1px solid transparent; }
.btn-primary { background: var(--k-navy); color: #FFFFFF; }
.btn-primary:hover { background: #143650; }
.btn-primary:active { background: #06121F; }
.btn-secondary { background: var(--k-surface); color: var(--k-ink); border-color: var(--k-line-2); }
.btn-secondary:hover { border-color: var(--k-teal); color: var(--k-teal); }
.btn-secondary:active { background: var(--k-soft); }
.btn-danger { background: var(--k-surface); color: var(--k-red-ink); border-color: var(--k-red-line); }
.btn-danger:hover { background: var(--k-red-100); }
.btn-small { height: 32px; padding: 0 12px; font-size: 11.5px; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; box-shadow: 0 0 0 3px rgba(20,125,146,0.35); }
button:disabled { background: #E8EEF3; color: #9AAABB; border-color: #E8EEF3; cursor: not-allowed; }
.actions { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }

.form { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 16px; }
.form .wide { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 11.5px; line-height: 19px; font-weight: 500; color: var(--k-ink-2); }
input, select, textarea { font-family: var(--font); font-size: 13px; height: 46px; padding: 0 12px; border: 1px solid var(--k-line-2); border-radius: 10px; background: var(--k-surface); color: var(--k-ink); width: 100%; }
textarea { height: 76px; padding: 10px 12px; resize: vertical; }
input:hover, select:hover, textarea:hover { border-color: var(--k-line-2); }
input:focus, select:focus, textarea:focus { border-color: var(--k-teal); box-shadow: 0 0 0 3px rgba(20,125,146,0.16); outline: none; }
input:disabled { background: #F4F7FA; }
.checks { display: flex; flex-direction: row; flex-wrap: wrap; gap: 8px; }
.check { display: flex; flex-direction: row; align-items: center; gap: 8px; border: 1px solid var(--k-line-2); border-radius: 8px; padding: 0 12px; height: 42px; cursor: pointer; }
.check input { width: 16px; height: 16px; }
.check.on { border-color: var(--k-teal); background: var(--k-teal-100); }

/* ---------- alerts ---------- */
.alert { border-radius: 10px; padding: 12px 16px; display: flex; flex-direction: row; gap: 12px; align-items: flex-start; }
.alert-title { font-weight: 600; }
.alert-text { font-size: 11.5px; line-height: 20px; }
.alert-red { background: var(--k-red-100); color: var(--k-red-ink); border: 1px solid var(--k-red-line); }
.alert-amber { background: var(--k-amber-100); color: var(--k-amber-ink); border: 1px solid var(--k-amber-line); }
.alert-green { background: var(--k-green-100); color: var(--k-green-ink); }
.alert-teal { background: var(--k-teal-100); color: var(--k-teal-ink); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
.login { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 16px; }
.login .card-body { display: flex; flex-direction: column; gap: 12px; }
.login-brand { text-align: center; }
.login-brand .t { font-size: 21px; font-weight: 600; }
.qr { display: flex; justify-content: center; padding: 8px; }
.qr img { width: 200px; height: 200px; image-rendering: pixelated; }
.secret { font-size: 15px; font-weight: 600; letter-spacing: 2px; text-align: center; background: var(--k-soft); border-radius: 10px; padding: 10px; word-break: break-all; }
.code-box { font-size: 22px; font-weight: 700; letter-spacing: 2px; text-align: center; background: var(--k-soft); border: 1px dashed var(--k-line-2); border-radius: 10px; padding: 16px; }

/* ---------- dialog ---------- */
dialog { border: 1px solid var(--k-line); border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 32px)); box-shadow: 0 12px 28px rgba(10,33,54,0.28); color: var(--k-ink); font-family: var(--font); }
dialog::backdrop { background: rgba(10,33,54,0.45); }
dialog .card-body { display: flex; flex-direction: column; gap: 12px; }

.skeleton { height: 120px; border-radius: 12px; background: linear-gradient(90deg, #E8EEF3 25%, #F4F7FA 50%, #E8EEF3 75%); background-size: 200% 100%; animation: sk 1.4s infinite linear; }
@keyframes sk { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (max-width: 900px) {
  .shell { flex-direction: column; }
  .rail { width: auto; flex: none; flex-direction: row; flex-wrap: wrap; padding: 8px 12px; align-items: center; }
  .brand { padding: 4px 8px; }
  .rail-group, .brand-sub { display: none; }
  .nav-item { height: 48px; }
  .rail-foot { margin: 0; flex-direction: row; align-items: center; padding: 4px 8px; }
  .topbar, .content { padding-inline: 16px; }
  .grid2, .form { grid-template-columns: minmax(0, 1fr); }
  .facts, .band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact { border-inline-start: 0; border-top: 1px solid var(--k-line); }
  .band .fact { border-top: 1px solid #FFFFFF1A; }
  .toast { inset-inline: 16px; max-width: none; }
  /* Tables become row cards on phones. */
  .table-wrap thead { display: none; }
  .table-wrap table, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; width: 100%; }
  .table-wrap tr { border-bottom: 1px solid var(--k-line); padding: 8px 0; }
  .table-wrap tr:last-child { border-bottom: 0; }
  .table-wrap td { border: 0; padding: 4px 16px; display: flex; flex-direction: row; justify-content: space-between; align-items: center; gap: 12px; text-align: start; min-height: 32px; }
  .table-wrap td.n { text-align: start; }
  .table-wrap td[data-label]::before { content: attr(data-label); font-size: 11.5px; font-weight: 500; color: var(--k-muted); flex: 0 0 auto; }
  .table-wrap td:empty { display: none; }
  tr.click:hover td { background: transparent; }
}

.toast { position: fixed; inset-inline-end: 16px; bottom: 16px; z-index: 50; max-width: 420px; box-shadow: 0 12px 28px rgba(10,33,54,0.28); }
