/* TWAS portal - institutional record system.
   Design intent: a case-file registry, not a consumer app. Hairline rules,
   uppercase register labels, monospaced references, and a persistent data-zone
   classification tag on every record surface. */

:root {
  --ink: #0b2038;
  --ink-2: #22384f;
  --muted: #5d7186;
  --paper: #f4f7fa;
  --surface: #ffffff;
  --line: #d5dee8;
  --line-soft: #e8eef4;
  --clearance: #1b5fa8;
  --clearance-dark: #14477e;
  --signal: #a0212f;
  --verified: #0f6b45;
  --caution: #8a5a00;
  --shadow: 0 1px 2px rgba(11, 32, 56, .06), 0 8px 24px rgba(11, 32, 56, .06);
  --mono: 'Consolas', 'SF Mono', 'Roboto Mono', monospace;
  --body: Calibri, 'Segoe UI', system-ui, -apple-system, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body { font-family: var(--body); font-size: 15px; line-height: 1.5; color: var(--ink); background: var(--paper); }
a { color: var(--clearance); }
:focus-visible { outline: 2px solid var(--clearance); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- register labels: the typographic signature ---------- */
.eyebrow, th, .zone, .navsec {
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .14em; font-weight: 700;
}
.eyebrow { color: var(--muted); margin: 0 0 6px; }
.mono { font-family: var(--mono); font-size: 13px; letter-spacing: .02em; }

/* ---------- shell ---------- */
.topbar {
  background: var(--ink); color: #fff; display: flex; align-items: center; justify-content: space-between;
  padding: 0 22px; height: 60px; position: sticky; top: 0; z-index: 40;
  border-bottom: 3px solid var(--clearance);
}
.brand { display: flex; align-items: baseline; gap: 12px; }
.brand strong { font-size: 20px; letter-spacing: .06em; }
.brand span { font-size: 11.5px; letter-spacing: .12em; text-transform: uppercase; color: #9fb6cd; }
.topbar-right { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.whoami { text-align: right; line-height: 1.25; }
.whoami b { display: block; font-size: 13.5px; }
.whoami small { color: #9fb6cd; font-size: 11px; text-transform: uppercase; letter-spacing: .1em; }

.layout { display: grid; grid-template-columns: 232px 1fr; min-height: calc(100vh - 60px); }
.rail { background: var(--surface); border-right: 1px solid var(--line); padding: 18px 0 40px; }
.navsec { color: var(--muted); padding: 16px 20px 6px; }
.rail button {
  display: block; width: 100%; text-align: left; background: none; border: 0; border-left: 3px solid transparent;
  padding: 9px 20px; font: inherit; color: var(--ink-2); cursor: pointer;
}
.rail button:hover { background: var(--line-soft); }
.rail button.active { border-left-color: var(--clearance); background: #eef4fb; color: var(--clearance-dark); font-weight: 700; }
.rail .badge-count { float: right; background: var(--signal); color: #fff; border-radius: 10px; padding: 0 7px; font-size: 11px; }

main { padding: 26px 30px 70px; max-width: 1180px; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 18px; }
h1 { font-size: 25px; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 13.5px; margin: 18px 0 8px; color: var(--ink-2); }
.lede { color: var(--muted); margin: 6px 0 0; max-width: 70ch; }

/* ---------- cards and the zone classification tag ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 20px; margin: 0 0 18px; box-shadow: var(--shadow); position: relative; }
.card.flush { padding: 0; overflow: hidden; }
.zone {
  position: absolute; top: 0; right: 0; background: var(--line-soft); color: var(--muted);
  padding: 4px 10px; border-bottom-left-radius: 6px; border-left: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.zone.identity { background: #eef4fb; color: var(--clearance-dark); }
.zone.vetting { background: #fdf0f1; color: var(--signal); }
.zone.registry { background: #eef7f2; color: var(--verified); }
.zone.gateway { background: #fff8ec; color: var(--caution); }

.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.full { grid-template-columns: 1fr; }

/* ---------- statistics ---------- */
.stats { display: grid; grid-template-columns: repeat(5, 1fr); gap: 12px; margin-bottom: 18px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 14px 16px; }
.stat b { display: block; font-size: 27px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat span { font-size: 10.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); }
.stat.red b { color: var(--signal); } .stat.red { border-color: #f0c7cc; background: #fdf5f6; }
.stat.amber b { color: var(--caution); } .stat.amber { border-color: #f0dcbb; background: #fffaf1; }
.stat.green b { color: var(--verified); }

/* ---------- forms ---------- */
label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: var(--ink-2); }
input, select, textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 8px 10px; border: 1px solid #b9c7d6;
  border-radius: 4px; background: #fff; color: var(--ink);
}
input:disabled, textarea:disabled { background: #f2f5f8; color: var(--muted); }
textarea { min-height: 86px; resize: vertical; }
.check { flex-direction: row; align-items: flex-start; gap: 9px; font-weight: 400; font-size: 13.5px; margin: 9px 0; }
.check input { width: auto; margin-top: 3px; }
.hint { background: #eef4fb; border-left: 3px solid var(--clearance); padding: 10px 12px; font-size: 13px; color: var(--ink-2); margin: 10px 0; border-radius: 0 4px 4px 0; }
.hint.warn { background: #fffaf1; border-left-color: var(--caution); }
.hint.danger { background: #fdf5f6; border-left-color: var(--signal); }

button.btn, .btn {
  font: inherit; font-weight: 700; font-size: 13.5px; border: 1px solid var(--clearance); background: var(--clearance);
  color: #fff; padding: 9px 16px; border-radius: 4px; cursor: pointer; letter-spacing: .01em;
}
.btn:hover { background: var(--clearance-dark); }
.btn.ghost { background: transparent; color: var(--clearance); }
.btn.ghost:hover { background: #eef4fb; }
.btn.quiet { background: #fff; color: var(--ink-2); border-color: var(--line); }
.btn.quiet:hover { background: var(--line-soft); }
.btn.danger { background: var(--signal); border-color: var(--signal); }
.btn.danger:hover { background: #85101d; }
.btn.small { padding: 5px 10px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 16px; }

/* ---------- tables ---------- */
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; color: var(--muted); padding: 9px 14px; background: #f7fafc; border-bottom: 1px solid var(--line); }
td { padding: 10px 14px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
tbody tr:hover { background: #f9fbfd; }
tr.clickable { cursor: pointer; }
.empty { padding: 18px; color: var(--muted); font-size: 13.5px; }

/* ---------- tags ---------- */
.tag { display: inline-block; padding: 2px 8px; border-radius: 3px; font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .08em; background: var(--line-soft); color: var(--ink-2); white-space: nowrap; }
.tag.critical { background: #fbe3e6; color: var(--signal); }
.tag.high { background: #fdeedd; color: var(--caution); }
.tag.medium { background: #e9f0f8; color: var(--clearance-dark); }
.tag.low { background: #eef1f5; color: var(--muted); }
.tag.ok, .tag.valid, .tag.approved, .tag.verified { background: #e4f2ea; color: var(--verified); }
.tag.breach { background: var(--signal); color: #fff; }

/* level ladder - the signature device */
.ladder { display: flex; gap: 2px; margin: 4px 0 0; }
.ladder i { font-style: normal; width: 22px; height: 20px; display: grid; place-items: center; font-size: 11px;
  font-weight: 700; background: var(--line-soft); color: var(--muted); }
.ladder i.on { background: var(--clearance); color: #fff; }
.ladder i.first { border-radius: 3px 0 0 3px; } .ladder i.last { border-radius: 0 3px 3px 0; }

/* ---------- auth screen ---------- */
.auth-wrap { display: grid; place-items: center; min-height: 100vh; padding: 24px; background:
  linear-gradient(180deg, #0b2038 0 38%, var(--paper) 38% 100%); }
.auth-card { width: 100%; max-width: 440px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 20px 50px rgba(11,32,56,.22); overflow: hidden; }
.auth-head { padding: 22px 26px 18px; border-bottom: 1px solid var(--line-soft); }
.auth-head strong { font-size: 22px; letter-spacing: .06em; display: block; }
.auth-head span { font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.auth-body { padding: 22px 26px 26px; display: grid; gap: 14px; }
.demo-list { border-top: 1px solid var(--line-soft); padding: 16px 26px 22px; background: #f8fafc; font-size: 12.5px; }
.demo-list table { font-size: 12.5px; } .demo-list td { padding: 5px 8px 5px 0; border: 0; }
.demo-list button { font: inherit; font-size: 12.5px; background: none; border: 0; color: var(--clearance);
  cursor: pointer; padding: 0; text-decoration: underline; }

/* ---------- detail drawer ---------- */
.drawer-backdrop { position: fixed; inset: 0; background: rgba(11,32,56,.42); z-index: 60; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 96vw); background: var(--paper);
  z-index: 61; overflow-y: auto; box-shadow: -12px 0 40px rgba(11,32,56,.2); }
.drawer-head { position: sticky; top: 0; background: var(--ink); color: #fff; padding: 16px 22px; display: flex;
  justify-content: space-between; align-items: center; }
.drawer-head .mono { color: #b9cde2; }
.drawer-body { padding: 20px 22px 60px; }
.close-x { background: none; border: 1px solid #46607d; color: #fff; border-radius: 4px; cursor: pointer;
  padding: 4px 10px; font: inherit; }

/* ---------- misc ---------- */
.msg { font-size: 13.5px; font-weight: 600; }
.msg.ok { color: var(--verified); } .msg.error { color: var(--signal); }
.kv { display: grid; grid-template-columns: 190px 1fr; gap: 6px 14px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 600; }
.kv dd { margin: 0; }
.timeline { border-left: 2px solid var(--line); padding-left: 16px; margin-left: 4px; }
.timeline-item { margin-bottom: 16px; position: relative; }
.timeline-item::before { content: ''; position: absolute; left: -21px; top: 5px; width: 8px; height: 8px;
  border-radius: 50%; background: var(--clearance); }
.footer-note { color: var(--muted); font-size: 12px; margin-top: 26px; border-top: 1px solid var(--line); padding-top: 14px; }
.toast { position: fixed; right: 20px; bottom: 20px; background: var(--ink); color: #fff; padding: 12px 18px;
  border-radius: 4px; z-index: 80; box-shadow: var(--shadow); font-size: 13.5px; max-width: 420px; }
.toast.error { background: var(--signal); }

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .rail { display: flex; overflow-x: auto; border-right: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .rail .navsec { display: none; }
  .rail button { white-space: nowrap; border-left: 0; border-bottom: 3px solid transparent; }
  .rail button.active { border-left: 0; border-bottom-color: var(--clearance); }
  .grid, .grid.three, .stats { grid-template-columns: 1fr; }
  main { padding: 18px 16px 60px; }
  .kv { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
