/* KHATT Capital — operations platform styling.
   Brand palette (content-brand.md §3.1): Navy #071A2D, Deep Navy #0B223A, Signal Gold #C89A4A,
   Light Gold #E2BE7A, Trust Blue #4FA3D9, Action Teal #37B8A6, Warm Cream #F6F1E8, White #F8FAFC.
   Navy-gold-cream hierarchy only — no decorative gradients. */

:root {
  --navy: #071a2d;
  --navy-2: #0b223a;
  --navy-3: #102c48;
  --line: #1b3554;
  --gold: #c89a4a;
  --gold-light: #e2be7a;
  --blue: #4fa3d9;
  --teal: #37b8a6;
  --cream: #f6f1e8;
  --white: #f8fafc;
  --muted: #8ea6bf;
  --danger: #e2685f;
  --warn: #d9a441;
  --good: #37b8a6;
  --radius: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--navy);
  color: var(--white);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--gold-light); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--mono); font-size: 0.92em; }
hr { border: none; border-top: 1px solid var(--line); margin: 18px 0; }
h1, h2, h3 { line-height: 1.25; margin: 0 0 8px; font-weight: 620; letter-spacing: -0.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }
p { margin: 0 0 10px; }
ul.bullets { margin: 0 0 4px; padding-left: 20px; }
ul.bullets li { margin-bottom: 6px; }

/* ---------------------------------------------------------------- banners */

.sandbox-banner {
  background: repeating-linear-gradient(135deg, #3a2a08, #3a2a08 12px, #33260a 12px, #33260a 24px);
  color: var(--gold-light);
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 7px 12px;
  border-bottom: 1px solid #4a3a12;
  font-weight: 600;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 12px 22px;
  background: var(--navy-2);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 20;
}
.brand { display: flex; flex-direction: column; text-decoration: none; }
.brand:hover { text-decoration: none; }
.brand-mark {
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--gold);
  font-size: 17px;
}
.brand-sub { font-size: 11px; color: var(--muted); letter-spacing: 0.04em; }
.nav { display: flex; gap: 4px; flex-wrap: wrap; flex: 1; }
.nav-link {
  color: var(--white);
  padding: 6px 11px;
  border-radius: 6px;
  font-size: 13.5px;
  border: 1px solid transparent;
}
.nav-link:hover { background: var(--navy-3); text-decoration: none; }
.nav-link.active { background: var(--navy-3); border-color: var(--gold); color: var(--gold-light); }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.who { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.who-name { font-size: 13px; }
.who-role { font-size: 11px; color: var(--gold); text-transform: uppercase; letter-spacing: 0.08em; }
.inline { display: inline; }

/* ---------------------------------------------------------------- layout */

.wrap { max-width: 1080px; margin: 0 auto; padding: 22px; }
.wrap-wide { max-width: 1500px; }
.page-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.page-sub { color: var(--muted); margin: 0; max-width: 70ch; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.sub { margin-top: 16px; color: var(--gold-light); font-size: 13px; text-transform: uppercase; letter-spacing: 0.06em; }

/* ---------------------------------------------------------------- cards */

.card {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 16px;
}
.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--gold);
  margin-bottom: 12px;
}
.card-sub { color: var(--muted); font-size: 13px; margin-top: -8px; }

.stats { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.stat {
  background: var(--navy-2);
  border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: var(--radius);
  padding: 12px 16px;
  min-width: 150px;
  display: flex;
  flex-direction: column;
}
.stat-value { font-size: 22px; font-weight: 650; color: var(--white); }
.stat-label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.stat-sub { font-size: 11px; color: var(--muted); }

/* ---------------------------------------------------------------- notices */

.notice {
  border-radius: 8px;
  padding: 10px 14px;
  margin-bottom: 14px;
  font-size: 13.5px;
  border: 1px solid var(--line);
  background: var(--navy-3);
}
.notice-info { border-color: #2a4c72; background: #10283f; }
.notice-good { border-color: #1f6b60; background: #0d2a28; color: #b6f0e6; }
.notice-warn { border-color: #7a5c1c; background: #2e2410; color: var(--gold-light); }
.notice-bad { border-color: #7d3630; background: #2f1513; color: #f6c6c1; }
.notice-strong { font-weight: 600; letter-spacing: 0.01em; }

/* ---------------------------------------------------------------- tables */

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; }
table.data { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data th {
  text-align: left;
  padding: 9px 12px;
  background: var(--navy-3);
  color: var(--gold-light);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  font-weight: 600;
  white-space: nowrap;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 9px 12px; border-bottom: 1px solid #14304d; vertical-align: top; }
table.data tr:last-child td { border-bottom: none; }
table.data tr:hover td { background: #0e2740; }
.detail {
  max-width: 460px;
  max-height: 74px;
  overflow: auto;
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  word-break: break-word;
}

.empty {
  text-align: center;
  padding: 28px 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #0a2036;
}
.empty-title { color: var(--muted); margin: 0; }
.empty-hint { color: #6d84a0; font-size: 12.5px; margin: 4px 0 0; }

/* ---------------------------------------------------------------- badges */

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  white-space: nowrap;
  border: 1px solid;
}
.badge-neutral { color: var(--white); border-color: #34506e; background: #12304c; }
.badge-muted { color: var(--muted); border-color: #2a4361; background: #0e2540; }
.badge-info { color: #bfe0f7; border-color: #2f6289; background: #0e2c44; }
.badge-accent { color: var(--gold-light); border-color: #7a5c1c; background: #2c2210; }
.badge-good { color: #a8ece0; border-color: #1f6b60; background: #0c2b28; }
.badge-warn { color: #f2d49b; border-color: #7d6122; background: #2d2310; }
.badge-bad { color: #f6c6c1; border-color: #7d3630; background: #2f1513; }
.score { font-family: var(--mono); font-size: 12px; color: var(--muted); }

.gate {
  display: inline-block;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  border: 1px solid #34506e;
  color: var(--muted);
  white-space: nowrap;
}
.gate-ok { border-color: #1f6b60; color: #a8ece0; background: #0c2b28; }

/* ---------------------------------------------------------------- gates panel */

.gates { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 12px; }
.gate-card {
  border: 1px solid var(--line);
  border-top: 3px solid #34506e;
  border-radius: 8px;
  padding: 12px 14px;
  background: #0a2136;
}
.gate-card.ok { border-top-color: var(--teal); }
.gate-card.no { border-top-color: var(--danger); }
.gate-card h3 { font-size: 13px; color: var(--gold-light); margin-bottom: 6px; }
.gate-card p { font-size: 12.5px; margin-bottom: 6px; }
.gate-rule { color: var(--muted); font-style: italic; font-size: 12px; }

/* ---------------------------------------------------------------- forms */

.input, select.input, textarea.input {
  background: #0a2036;
  border: 1px solid #24446a;
  color: var(--white);
  border-radius: 7px;
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
  width: 100%;
  max-width: 100%;
}
.input:focus { outline: 2px solid var(--gold); outline-offset: 0; border-color: var(--gold); }
textarea.input { resize: vertical; }
select.input { cursor: pointer; }

.field { margin-bottom: 12px; display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); }
.field .req { color: var(--gold); }
.field .hint, .hint { font-size: 12px; color: var(--muted); }
.field .err, .err { font-size: 12px; color: #f6c6c1; }
.field-error .input { border-color: var(--danger); }
.field-actions { justify-content: flex-end; }
.stack { display: flex; flex-direction: column; gap: 4px; }
.grid-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 6px 14px; align-items: end; }
.check { display: flex; align-items: flex-start; gap: 8px; font-size: 13px; margin: 6px 0; color: var(--cream); }
.check input { margin-top: 3px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filters .input { width: auto; min-width: 150px; }
.row-form { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row-form .input { width: auto; min-width: 120px; font-size: 12.5px; padding: 5px 8px; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }

.btn {
  display: inline-block;
  background: var(--navy-3);
  border: 1px solid #2b4d74;
  color: var(--white);
  padding: 7px 14px;
  border-radius: 7px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}
.btn:hover { background: #16385a; text-decoration: none; }
.btn-primary { background: var(--gold); border-color: var(--gold); color: #1a1204; font-weight: 620; }
.btn-primary:hover { background: var(--gold-light); }
.btn-ghost { background: transparent; }
.btn-danger { background: #40201d; border-color: #7d3630; color: #f6c6c1; }
.btn-danger:hover { background: #552924; }
.btn-small { padding: 4px 9px; font-size: 12px; }
.btn-block { width: 100%; text-align: center; margin-top: 6px; }

/* ---------------------------------------------------------------- key/value */

.kv { display: grid; grid-template-columns: minmax(120px, 200px) 1fr; gap: 6px 14px; margin: 0; font-size: 13.5px; }
.kv dt { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.kv dd { margin: 0; word-break: break-word; }

.prewrap { white-space: pre-wrap; word-break: break-word; background: #0a2036; border: 1px solid var(--line); border-radius: 7px; padding: 10px 12px; font-size: 13.5px; }
.mail-body { font-family: var(--mono); font-size: 12.5px; max-height: 560px; overflow: auto; }

/* ---------------------------------------------------------------- timeline */

.timeline { list-style: none; margin: 0; padding: 0 0 0 6px; }
.tl { position: relative; padding: 0 0 16px 22px; border-left: 2px solid #24446a; }
.tl:last-child { border-left-color: transparent; padding-bottom: 0; }
.tl-dot {
  position: absolute; left: -7px; top: 3px; width: 12px; height: 12px;
  border-radius: 50%; background: var(--navy); border: 2px solid #24446a;
}
.tl-done > .tl-dot { background: var(--teal); border-color: var(--teal); }
.tl-current > .tl-dot { background: var(--gold); border-color: var(--gold); box-shadow: 0 0 0 4px rgba(200,154,74,0.18); }
.tl-label { display: block; font-size: 13.5px; }
.tl-current .tl-label { color: var(--gold-light); font-weight: 600; }
.tl-meta { display: block; font-size: 11.5px; color: var(--muted); }

/* ---------------------------------------------------------------- comments */

.comments { list-style: none; margin: 0 0 14px; padding: 0; }
.comment { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; margin-bottom: 8px; background: #0a2036; }
.comment-internal { border-left: 3px solid var(--warn); }
.comment-head { display: flex; gap: 10px; align-items: center; margin-bottom: 6px; flex-wrap: wrap; font-size: 13px; }
.comment-meta { color: var(--muted); font-size: 11.5px; }
.comment .prewrap { background: transparent; border: none; padding: 0; }

/* ---------------------------------------------------------------- auth pages */

.auth-page { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 26px; align-items: start; }
.auth-card { background: var(--navy-2); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.auth-title { font-size: 21px; margin-bottom: 4px; }
.auth-sub { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.auth-links { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.auth-aside { padding: 10px 4px; }
.auth-aside h2 { color: var(--gold); font-size: 15px; }
.auth-aside p { color: var(--cream); max-width: 52ch; font-size: 13.5px; }
.auth-points { list-style: none; padding: 0; margin: 14px 0; }
.auth-points li { padding: 5px 0 5px 20px; position: relative; color: var(--cream); font-size: 13.5px; }
.auth-points li::before { content: "—"; position: absolute; left: 0; color: var(--gold); }
.auth-note { font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); padding-top: 10px; }

/* ---------------------------------------------------------------- exports & pager */

.export-list { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.export-item {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  border: 1px solid var(--line); border-radius: 8px; padding: 12px 14px; background: #0a2036;
}
.export-item .hint { margin: 0; }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }

/* ---------------------------------------------------------------- footer */

.site-footer {
  border-top: 1px solid var(--line);
  background: var(--navy-2);
  margin-top: 30px;
  padding: 18px 0 26px;
  font-size: 12px;
  color: var(--muted);
}
.site-footer p { max-width: 100ch; margin-bottom: 6px; }
.site-footer strong { color: var(--cream); }
.foot-meta { color: #6d84a0; }

@media (max-width: 820px) {
  .auth-page { grid-template-columns: 1fr; }
  .topbar { gap: 10px; }
  .kv { grid-template-columns: 1fr; }
  .kv dd { margin-bottom: 6px; }
}

/* ---------------------------------------------------------------- live operations console
   /admin/live. Charts are inline SVG only — no chart library, no dependency. Colour is always
   redundant here: every bar sits beside its own label and figure, so nothing is carried by hue. */

.live-strip {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--navy-2);
  padding: 10px 14px;
  margin-bottom: 16px;
  font-size: 13px;
}
.live-state { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.live-dot {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--muted); flex: none;
  box-shadow: 0 0 0 3px rgba(142, 166, 191, 0.15);
}
.live-state-live { color: var(--teal); }
.live-state-live .live-dot { background: var(--teal); box-shadow: 0 0 0 3px rgba(55, 184, 166, 0.18); animation: live-pulse 3s ease-in-out infinite; }
.live-state-connecting { color: var(--gold-light); }
.live-state-connecting .live-dot { background: var(--gold); box-shadow: 0 0 0 3px rgba(200, 154, 74, 0.18); }
.live-state-retry { color: var(--warn); }
.live-state-retry .live-dot { background: var(--warn); box-shadow: 0 0 0 3px rgba(217, 164, 65, 0.2); animation: live-pulse 1.1s ease-in-out infinite; }
.live-state-down { color: var(--danger); }
.live-state-down .live-dot { background: var(--danger); box-shadow: 0 0 0 3px rgba(226, 104, 95, 0.2); }
@keyframes live-pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }

.live-meta { color: var(--muted); }
.live-meta span { color: var(--cream); font-variant-numeric: tabular-nums; }
.live-flags { display: inline-flex; gap: 12px; flex-wrap: wrap; margin-left: auto; }

.flag { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; }
.flag-dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.flag-on { color: var(--teal); }
.flag-on .flag-dot { background: var(--teal); }
.flag-off { color: var(--warn); }
.flag-off .flag-dot { background: var(--warn); }

/* ---- counter bars: link + hairline bar + figure, one row each */

.cbars { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.cbar {
  display: grid;
  grid-template-columns: minmax(96px, 34%) 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 4px 6px;
  border-radius: 6px;
  color: var(--white);
  text-decoration: none;
}
.cbar:hover { background: var(--navy-3); text-decoration: none; }
.cbar:hover .cbar-label { color: var(--gold-light); }
.cbar-label { font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbar-track { display: block; line-height: 0; }
.cbar-svg { display: block; width: 100%; height: 8px; }
.cbar-value { font-variant-numeric: tabular-nums; font-size: 13px; min-width: 3ch; text-align: right; color: var(--cream); }

/* ---- sparkline */

.chart { padding-top: 4px; }
.spark { display: block; width: 100%; height: auto; overflow: visible; }
.chart-note { color: var(--muted); font-size: 12px; margin: 6px 0 0; }
.chart-note span { color: var(--cream); font-variant-numeric: tabular-nums; }
.stats-tight { margin-bottom: 10px; }

/* ---- activity feed */

.live-feed td { font-size: 13px; }
.nowrap { white-space: nowrap; }
tr.feed-new td { animation: feed-in 2.4s ease-out; }
@keyframes feed-in {
  0% { background: rgba(200, 154, 74, 0.28); }
  100% { background: transparent; }
}

/* ---- control actions */

.controls { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; margin-top: 12px; }
.control-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0a2036;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.control-card h3 { color: var(--gold-light); margin: 0; }
.control-card p { margin: 0; font-size: 13px; }
.control-card .hint { font-size: 12px; }
.control-card form { margin-top: auto; }
.control-card .check { font-size: 12.5px; }

@media (prefers-reduced-motion: reduce) {
  .live-state-live .live-dot,
  .live-state-retry .live-dot,
  tr.feed-new td { animation: none; }
}

/* Public intake pages (/apply/*, /sandbox) — added with routes/apply.js. */
.list { margin: .25rem 0 0; padding-left: 1.15rem; }
.list li { margin: .3rem 0; line-height: 1.55; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; align-items: center; margin-top: .35rem; }
.check { display: flex; gap: .55rem; align-items: flex-start; font-weight: 400; cursor: pointer; }
.check input { margin-top: .22rem; flex: 0 0 auto; }
