/* Fonts are served from this site (SIL Open Font License, see /fonts). */
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0000-00FF, U+2000-206F, U+20AC; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-arabic-arabic-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-arabic-arabic-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Sans"; src: url("/fonts/ibm-plex-sans-arabic-arabic-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; unicode-range: U+0600-06FF, U+0750-077F, U+FB50-FDFF, U+FE70-FEFF; }
@font-face { font-family: "Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex Mono"; src: url("/fonts/ibm-plex-mono-latin-500-normal.woff2") format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Bricolage"; src: url("/fonts/bricolage-grotesque-latin-wght-normal.woff2") format("woff2"); font-weight: 200 800; font-display: swap; }

:root {
  --bg: #eef0f4;
  --surface: #ffffff;
  --surface-2: #f6f7fa;
  --ink: #101828;
  --ink-2: #4a5468;
  --ink-3: #7a8497;
  --line: #dde1e9;
  --line-2: #eceff4;
  --brand: #1d2b53;
  --brand-ink: #ffffff;
  --focus: #2a78d6;
  --ai: #2a78d6;
  --cyber: #eb6834;
  --ds: #1baf7a;
  --good: #0a7a0a;
  --good-bg: #e4f4e4;
  --warn: #8a5a00;
  --warn-bg: #fdf1d6;
  --bad: #b32626;
  --bad-bg: #fbe4e4;
  --shadow: 0 1px 2px rgb(16 24 40 / 6%), 0 4px 14px rgb(16 24 40 / 5%);
  --radius: 14px;
  --display: "Bricolage", "Plex Sans", system-ui, sans-serif;
  --body: "Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Plex Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0e1116; --surface: #171b23; --surface-2: #1d222c; --ink: #eef0f4; --ink-2: #b7bfce; --ink-3: #8a93a6;
    --line: #2a303c; --line-2: #222833; --brand: #cfd8ff; --brand-ink: #10183a; --focus: #6da7ec;
    --ai: #3987e5; --cyber: #d95926; --ds: #199e70;
    --good: #5fd35f; --good-bg: #16301a; --warn: #f2c35a; --warn-bg: #33290f; --bad: #ff8a8a; --bad-bg: #3a1a1a;
    --shadow: 0 1px 2px rgb(0 0 0 / 40%);
  }
}
:root[data-theme="dark"] {
  --bg: #0e1116; --surface: #171b23; --surface-2: #1d222c; --ink: #eef0f4; --ink-2: #b7bfce; --ink-3: #8a93a6;
  --line: #2a303c; --line-2: #222833; --brand: #cfd8ff; --brand-ink: #10183a; --focus: #6da7ec;
  --ai: #3987e5; --cyber: #d95926; --ds: #199e70;
  --good: #5fd35f; --good-bg: #16301a; --warn: #f2c35a; --warn-bg: #33290f; --bad: #ff8a8a; --bad-bg: #3a1a1a;
  --shadow: 0 1px 2px rgb(0 0 0 / 40%);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 15px/1.5 var(--body); }
h1, h2, h3, p { margin: 0; }
button, input, select { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.boot { padding: 40px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.mono { font-family: var(--mono); font-feature-settings: "zero" 1; }
.muted { color: var(--ink-3); }
.name { unicode-bidi: isolate; }
.toolbar .field.date { flex: 0 1 150px; }

/* --------------------------------- shell -------------------------------- */
.shell { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: 100vh; }
.rail { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 22px; padding: 22px 16px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 8px; }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; background: var(--brand); color: var(--brand-ink); display: grid; place-items: center; font: 700 17px var(--display); }
.brand b { display: block; font: 700 18px/1.1 var(--display); letter-spacing: -0.01em; }
.brand small { color: var(--ink-3); font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 9px 10px; border-radius: 10px; text-decoration: none; color: var(--ink-2); font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a[aria-current="page"] { background: var(--brand); color: var(--brand-ink); }
.nav .count { font: 500 12px var(--mono); background: var(--warn-bg); color: var(--warn); padding: 1px 7px; border-radius: 99px; }
.nav .tag { font-size: 10px; letter-spacing: .06em; text-transform: uppercase; opacity: .7; }
.nav-sep { margin: 10px 10px 4px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.me { margin-top: auto; display: flex; flex-direction: column; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.me-row { display: flex; gap: 10px; align-items: center; min-width: 0; }
.me-row div { min-width: 0; }
.me-row b, .me-row small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.me-row small { color: var(--ink-3); font-size: 12px; }
.me-actions { display: flex; gap: 6px; }
.main { padding: 28px clamp(16px, 3vw, 40px) 64px; max-width: 1240px; width: 100%; }
.page-head { display: flex; flex-wrap: wrap; align-items: end; justify-content: space-between; gap: 12px 20px; margin-bottom: 22px; }
.page-head h1 { font: 700 30px/1.1 var(--display); letter-spacing: -0.02em; }
.page-head p { color: var(--ink-3); margin-top: 4px; }
.head-actions { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .rail { position: static; height: auto; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 12px 14px; gap: 10px; border-right: 0; border-bottom: 1px solid var(--line); }
  .nav { flex-direction: row; overflow-x: auto; order: 3; width: 100%; padding-bottom: 2px; }
  .nav a { white-space: nowrap; }
  .nav-sep { display: none; }
  .me { margin: 0 0 0 auto; padding: 6px 8px; flex-direction: row; align-items: center; }
  .me-row div { display: none; }
  .main { padding-top: 20px; }
}

/* -------------------------------- controls ------------------------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; padding: 7px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); font-weight: 500; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--brand-ink); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.12); }
.btn.good { background: var(--good); color: #fff; border-color: var(--good); }
.btn.danger { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 40%, var(--line)); }
.btn.danger.solid { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.small { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label, .field > .label { font-size: 13px; font-weight: 500; color: var(--ink-2); }
.input, select.input { min-height: 40px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); width: 100%; }
.input::placeholder { color: var(--ink-3); }
.hint { font-size: 12.5px; color: var(--ink-3); }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; align-items: end; }
.toolbar .field { flex: 1 1 160px; }
.toolbar .field.grow { flex: 2 1 240px; }
.seg { display: inline-flex; padding: 3px; gap: 2px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line); }
.seg button { border: 0; background: transparent; padding: 6px 13px; border-radius: 9px; font-weight: 500; color: var(--ink-2); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.card h2 { font: 600 17px/1.2 var(--display); letter-spacing: -0.01em; }
.card-head { display: flex; justify-content: space-between; align-items: start; gap: 10px; margin-bottom: 14px; }
.card-head p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }
.grid { display: grid; gap: 18px; }
.grid.two { grid-template-columns: repeat(auto-fit, minmax(min(100%, 420px), 1fr)); }
.avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--line); object-fit: cover; flex: none; }
.avatar.sm { width: 28px; height: 28px; }
.avatar.lg { width: 56px; height: 56px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 2px 10px; border-radius: 99px; font-size: 12.5px; font-weight: 500; background: var(--surface-2); border: 1px solid var(--line); white-space: nowrap; }
.chip i { width: 8px; height: 8px; border-radius: 50%; background: var(--ink-3); }
.chip.ai i { background: var(--ai); } .chip.cyber i { background: var(--cyber); } .chip.ds i { background: var(--ds); }
.chip.good { background: var(--good-bg); color: var(--good); border-color: transparent; }
.chip.warn { background: var(--warn-bg); color: var(--warn); border-color: transparent; }
.chip.bad { background: var(--bad-bg); color: var(--bad); border-color: transparent; }
.empty { padding: 34px 18px; text-align: center; color: var(--ink-3); border: 1px dashed var(--line); border-radius: var(--radius); }
.empty b { display: block; color: var(--ink-2); font: 600 16px var(--display); margin-bottom: 4px; }
.more { display: flex; justify-content: center; margin-top: 16px; }

/* ---------------------------- ID cards (applications) -------------------- */
.ids { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.idcard { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 30px 18px 16px 22px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; gap: 14px; }
.idcard::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 6px; background: var(--ink-3); }
.idcard.ai::before { background: var(--ai); } .idcard.cyber::before { background: var(--cyber); } .idcard.ds::before { background: var(--ds); }
.idcard::after { content: ""; position: absolute; top: 9px; left: 50%; width: 46px; height: 8px; margin-left: -23px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); }
.id-top { display: flex; gap: 12px; align-items: center; min-width: 0; }
.id-top div { min-width: 0; }
.id-name { font: 600 18px/1.25 var(--display); }
.id-sub { color: var(--ink-3); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.id-code { font: 500 22px/1 var(--mono); letter-spacing: .04em; }
.id-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.id-actions { display: flex; gap: 8px; }
.id-actions .btn { flex: 1; }
.id-foot { font-size: 12.5px; color: var(--ink-3); }

/* ------------------------------ data bars ------------------------------- */
.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 150px 1fr auto; gap: 12px; align-items: center; }
.bar-row .lab { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 12px; background: var(--surface-2); border-radius: 0 4px 4px 0; position: relative; }
.bar-fill { height: 100%; border-radius: 0 4px 4px 0; background: var(--ink-3); min-width: 2px; }
.bar-fill.ai { background: var(--ai); } .bar-fill.cyber { background: var(--cyber); } .bar-fill.ds { background: var(--ds); } .bar-fill.brand { background: var(--brand); }
.bar-val { font: 500 14px var(--mono); min-width: 3.2ch; text-align: right; }
@media (max-width: 520px) { .bar-row { grid-template-columns: 1fr auto; } .bar-track { grid-column: 1 / -1; order: 3; } }
.cols { display: flex; align-items: end; gap: 10px; height: 160px; padding-top: 8px; border-bottom: 1px solid var(--line); }
.col { flex: 1; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: end; align-items: center; gap: 4px; position: relative; }
.col .fill { width: min(100%, 44px); border-radius: 4px 4px 0 0; background: var(--brand); min-height: 2px; }
.col .v { font: 500 12px var(--mono); }
.col-labels { display: flex; gap: 10px; margin-top: 6px; }
.col-labels span { flex: 1; min-width: 0; text-align: center; font-size: 11.5px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 12px; font-size: 13px; color: var(--ink-2); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; }
.big { font: 700 44px/1 var(--display); letter-spacing: -0.03em; }

/* --------------------------------- tables -------------------------------- */
.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 11px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
th { font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); font-weight: 600; background: var(--surface-2); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: var(--surface-2); }
td.num { font-family: var(--mono); }
.cell-person { display: flex; align-items: center; gap: 10px; min-width: 0; }
.rate { display: inline-flex; align-items: center; gap: 8px; font: 500 13px var(--mono); }
.rate .bar-track { width: 70px; height: 8px; }
.row-actions { display: flex; gap: 6px; justify-content: flex-end; }

/* ------------------------------- audit log ------------------------------- */
.log { display: flex; flex-direction: column; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.log-day { padding: 8px 16px; font-size: 12px; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); background: var(--surface-2); border-bottom: 1px solid var(--line-2); font-weight: 600; }
.entry { display: grid; grid-template-columns: 72px 1fr; gap: 6px 14px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.entry:last-child { border-bottom: 0; }
.entry time { font: 400 13px var(--mono); color: var(--ink-3); padding-top: 2px; }
.entry-main { min-width: 0; }
.entry-title { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; }
.entry-title b { font-weight: 600; }
.entry-line { color: var(--ink-2); font-size: 14px; margin-top: 2px; overflow-wrap: anywhere; }
.entry details { margin-top: 6px; }
.entry summary { cursor: pointer; font-size: 13px; color: var(--ink-3); width: fit-content; }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: 3px 14px; margin-top: 6px; padding: 10px 12px; background: var(--surface-2); border-radius: 10px; font-size: 13px; }
.kv dt { color: var(--ink-3); } .kv dd { margin: 0; overflow-wrap: anywhere; font-family: var(--mono); font-size: 12.5px; }
.src { font-size: 11.5px; padding: 1px 8px; border-radius: 6px; font-weight: 600; letter-spacing: .03em; text-transform: uppercase; background: var(--surface-2); border: 1px solid var(--line); color: var(--ink-2); }
.src.discord { background: color-mix(in srgb, var(--ai) 14%, var(--surface)); color: var(--ai); border-color: transparent; }
.src.dashboard { background: color-mix(in srgb, var(--brand) 12%, var(--surface)); border-color: transparent; }
.src.bot { background: color-mix(in srgb, var(--ds) 16%, var(--surface)); color: var(--good); border-color: transparent; }
.cat { font-size: 12.5px; color: var(--ink-3); }
@media (max-width: 520px) { .entry { grid-template-columns: 1fr; } }

/* --------------------------------- dialogs ------------------------------- */
dialog { border: 1px solid var(--line); border-radius: 18px; padding: 0; background: var(--surface); color: var(--ink); width: min(560px, calc(100vw - 24px)); max-height: calc(100vh - 32px); box-shadow: 0 24px 70px rgb(0 0 0 / 30%); }
dialog.wide { width: min(860px, calc(100vw - 24px)); }
dialog::backdrop { background: rgb(10 14 24 / 55%); }
.dlg { display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.dlg-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; padding: 20px 22px 8px; }
.dlg-head h2 { font: 700 21px/1.2 var(--display); }
.dlg-body { padding: 8px 22px 6px; overflow: auto; display: flex; flex-direction: column; gap: 14px; }
.dlg-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 16px 22px 20px; flex-wrap: wrap; }
.err { color: var(--bad); background: var(--bad-bg); padding: 9px 12px; border-radius: 10px; font-size: 14px; }
.picks { display: flex; flex-direction: column; gap: 6px; }
.pick { display: flex; gap: 10px; align-items: center; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; text-align: left; width: 100%; }
.pick:hover { background: var(--surface-2); }
.pick[aria-pressed="true"] { border-color: var(--brand); box-shadow: 0 0 0 2px color-mix(in srgb, var(--brand) 25%, transparent); }
.pick small { color: var(--ink-3); margin-left: auto; }

/* ---------------------------------- misc --------------------------------- */
.toasts { position: fixed; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 50; }
.toast { background: var(--brand); color: var(--brand-ink); padding: 11px 16px; border-radius: 12px; box-shadow: 0 10px 30px rgb(0 0 0 / 25%); max-width: 360px; }
.toast.bad { background: var(--bad); color: #fff; }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: grid; grid-template-columns: 22px 1fr; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.check b { font-weight: 600; display: block; }
.check span { color: var(--ink-3); font-size: 13.5px; }
.check .ico { font-weight: 700; }
.check.ok .ico { color: var(--good); } .check.no { background: var(--bad-bg); } .check.no .ico { color: var(--bad); }
.progress { height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; }
.progress div { height: 100%; background: var(--brand); transition: width .3s; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; }
.row .field { flex: 1 1 180px; }
.tablist { overflow-x: auto; }

/* sign-in and error pages */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: var(--bg); }
.gate-card { width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 34px 30px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 14px; align-items: flex-start; }
.gate-card h1 { font: 700 28px/1.15 var(--display); letter-spacing: -0.02em; }
.gate-card p { color: var(--ink-2); }
.gate-card .btn { min-height: 44px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
