/* Splintr app shell: brand tokens, navigation and shared components. */
:root {
  --paper: #f1f4f7;
  --panel: #ffffff;
  --panel-2: #f7f9fb;
  --ink: #0b0d12;
  --ink-2: #394857;
  --muted: #677585;
  --line: #d7dde4;
  --line-2: #e6eaef;
  --mark: #ffd24a;
  --mark-soft: #fff4cc;
  --mark-ink: #4d3a00;
  --signal: #1b3a6b;
  --signal-soft: #e7ecf5;
  --signal-2: #142c52;
  --signal-3: #aebfd9;
  --signal-ink: #ffffff;
  --ok: #0f7a55;
  --ok-soft: #e0f3ea;
  --warn: #9a5b00;
  --warn-soft: #fff1d9;
  --bad: #b8322a;
  --bad-soft: #fde7e5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(15, 29, 43, 0.06), 0 8px 24px rgba(15, 29, 43, 0.07);
  --shadow-lg: 0 16px 40px rgba(15, 29, 43, 0.18);
  --display: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  --body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--paper); color: var(--ink); font: 14px/1.5 var(--body); }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--signal); }
h1, h2, h3 { font-family: var(--display); letter-spacing: -0.02em; margin: 0; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

/* ---------- navigation ---------- */
.appnav {
  display: flex; align-items: center; gap: 4px; padding: 0 20px; height: 58px; background: var(--panel); color: var(--ink);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 40;
}
.wordmark {
  flex: none;
  font-family: var(--display); font-weight: 700; font-size: 23px; letter-spacing: -0.045em; color: var(--ink); text-decoration: none;
  margin-right: 22px; display: flex; align-items: center; gap: 9px; line-height: 1;
}
.wordmark img { height: 32px; width: auto; display: block; }
.wordmark span { transform: translateY(-1px); }
.appnav a.navlink {
  color: var(--ink-2); text-decoration: none; padding: 7px 12px; border-radius: 8px; font-weight: 500; font-size: 13.5px;
  display: flex; align-items: center; gap: 7px; white-space: nowrap; flex: none;
}
.appnav a.navlink:hover { color: var(--ink); background: var(--line-2); }
.appnav a.navlink.is-active { color: #fff; background: var(--signal); }
.navnum { font: 500 11px var(--mono); opacity: 0.6; }
.appnav a.navlink.is-active .navnum { opacity: 0.75; }
.nav-right { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); }

/* ---------- page layout ---------- */
.page { max-width: 1320px; margin: 0 auto; padding: 24px 20px 64px; }
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head h1 { font-size: 30px; line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--ink-2); max-width: 720px; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; flex-wrap: wrap; }
.eyebrow { font: 600 11px var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px 20px; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head h2 { font-size: 18px; }
.card-head .actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }
.grid-2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.stack { display: grid; gap: 16px; }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; border: 1px solid transparent; border-radius: 8px;
  padding: 8px 14px; cursor: pointer; font-weight: 600; font-size: 13px; line-height: 1.2; white-space: nowrap; text-decoration: none;
  background: var(--panel); color: var(--ink);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--signal); color: var(--signal-ink); }
.btn-primary:not(:disabled):hover { background: var(--signal-2); }
.btn-mark { background: var(--mark); color: var(--ink); }
.btn-mark:not(:disabled):hover { background: #ffc81a; }
.btn-secondary { border-color: var(--line); box-shadow: 0 1px 1px rgba(15, 29, 43, 0.04); }
.btn-secondary:not(:disabled):hover { border-color: #b9c2cd; }
.btn-ghost { background: transparent; color: var(--ink-2); }
.btn-ghost:not(:disabled):hover { background: var(--line-2); }
.btn-danger { background: transparent; color: var(--bad); }
.btn-danger:not(:disabled):hover { background: var(--bad-soft); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn.is-busy { position: relative; color: transparent !important; }
.btn.is-busy::after {
  content: ""; position: absolute; width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--muted);
  border-right-color: transparent; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.input, .select, .textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; background: var(--panel); min-width: 0;
}
.textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--signal); box-shadow: 0 0 0 3px rgba(27, 58, 107, 0.16); }
.field-label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-2); margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
.search { position: relative; }
.search .input { padding-left: 32px; }
.search::before {
  content: ""; position: absolute; left: 11px; top: 50%; width: 11px; height: 11px; border: 2px solid var(--muted); border-radius: 50%;
  transform: translateY(-60%);
}

/* ---------- tables ---------- */
.table-wrap { overflow: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; font: 600 11px var(--mono); letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
  padding: 10px 14px; border-bottom: 1px solid var(--line); background: var(--panel-2); white-space: nowrap; position: sticky; top: 0;
}
table.data td { padding: 10px 14px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.data tr.clickable { cursor: pointer; }
table.data tr.clickable:hover td { background: var(--panel-2); }
table.data tr.is-selected td { background: var(--signal-soft); }
table.data td.num, table.data th.num { text-align: right; font-variant-numeric: tabular-nums; }

/* ---------- badges ---------- */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-bad { background: var(--bad-soft); color: var(--bad); }
.badge-info { background: var(--signal-soft); color: var(--signal); }
.badge-muted { background: var(--line-2); color: var(--muted); }
.badge-mark { background: var(--mark-soft); color: var(--mark-ink); }
.dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }
.score {
  font: 700 15px var(--mono); width: 46px; height: 32px; border-radius: 8px; display: inline-grid; place-items: center;
}
.score-ok { background: var(--ok-soft); color: var(--ok); }
.score-warn { background: var(--warn-soft); color: var(--warn); }
.score-bad { background: var(--bad-soft); color: var(--bad); }

/* ---------- stat tiles ---------- */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; }
.tile { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.tile .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.tile .value { font: 700 26px/1.2 var(--display); letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; }
.tile .sub { font-size: 12px; color: var(--ink-2); margin-top: 2px; }

/* ---------- drawer & modal ---------- */
.scrim { position: fixed; inset: 0; background: rgba(15, 29, 43, 0.35); z-index: 60; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(760px, 100vw); background: var(--paper); z-index: 61; box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
}
.drawer-head { display: flex; align-items: center; gap: 12px; padding: 16px 20px; background: var(--panel); border-bottom: 1px solid var(--line); }
.drawer-head h2 { font-size: 22px; }
.drawer-body { flex: 1; overflow: auto; padding: 18px 20px 40px; display: grid; gap: 16px; align-content: start; }
.tabs-row { display: flex; gap: 2px; border-bottom: 1px solid var(--line); background: var(--panel); padding: 0 16px; }
.tabbtn { background: none; border: 0; border-bottom: 2px solid transparent; padding: 10px 12px; cursor: pointer; font-weight: 600; font-size: 13px; color: var(--muted); }
.tabbtn.is-active { color: var(--ink); border-bottom-color: var(--signal); }

/* ---------- empty states & toasts ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--ink-2); }
.empty h3 { font-size: 20px; margin-bottom: 6px; color: var(--ink); }
.empty p { margin: 0 auto 16px; max-width: 460px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 90; }
.toast { background: var(--ink); color: #fff; padding: 10px 14px; border-radius: 9px; box-shadow: var(--shadow-lg); font-size: 13px; max-width: 420px; animation: toast-in 0.2s ease-out; }
.toast.is-error { background: var(--bad); }
@keyframes toast-in { from { transform: translateY(8px); opacity: 0; } }

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .appnav { overflow-x: auto; }
  .nav-right { display: none; }
}

/* ---------- small utilities (no inline styles: the CSP blocks them) ---------- */
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.btn-row.center { justify-content: center; }
.dot-bad { background: var(--bad); }
.dot-warn { background: var(--warn); }
.dot-ok { background: var(--ok); }
.lead-dot { margin-top: 6px; }
.eyebrow-light { color: rgba(255, 255, 255, 0.55); }
.small { font-size: 12px; }
.grow { flex: 1; }
.push { margin-left: auto; }
.dot-muted { background: var(--muted); }

/* ---------- notices ---------- */
.notice { background: var(--mark-soft); border: 1px solid #f0d98a; color: var(--mark-ink); border-radius: var(--radius); padding: 12px 16px; margin-bottom: 16px; font-size: 13px; }
.notice b { color: var(--ink); }

/* The nav scrolls sideways on narrow screens instead of widening the page. */
.appnav { overflow-x: auto; scrollbar-width: none; }
.appnav::-webkit-scrollbar { display: none; }

/* "A newer version is available" bar (js/common.js) */
.update-bar {
  position: fixed; left: 18px; bottom: 18px; z-index: 95; display: flex; align-items: center; gap: 12px;
  background: #0b0d12; color: #fff; padding: 10px 12px 10px 16px; border-radius: 9px; font: 13px/1.4 "IBM Plex Sans", system-ui, sans-serif;
  box-shadow: 0 16px 40px rgba(15, 29, 43, 0.25);
}
.update-reload { border: 0; border-radius: 6px; background: #fff; color: #1b3a6b; font: 600 12.5px "IBM Plex Sans", system-ui, sans-serif; padding: 6px 12px; cursor: pointer; }
