@import url('https://fonts.googleapis.com/css2?family=Libre+Caslon+Display&family=Public+Sans:wght@400;500;600;700&display=swap');

:root {
  /* Keystone — Establishment / Command, LIGHT INSTITUTIONAL theme.
     Content surface is bright; the sidebar stays navy (self-contained colors below).
     Data reads navy; crimson carries emphasis; gold is a sparing premium detail. */
  --bg: #F6F7F9;            /* warm off-white working surface */
  --panel: #FFFFFF;
  --panel-2: #EEF1F5;       /* subtle inset / track */
  --border: #DCE1E8;
  --text: #0A1A2F;          /* deep navy — primary text + data */
  --muted: #5B6B7E;
  --accent: #A6862F;        /* gold, darkened for legibility; used only for thin accents */
  --accent-dim: #C2A24B;    /* brighter gold — hairlines/crest on light */
  --brand: #9E1B32;         /* flag crimson — emphasis + identity */
  --ok: #1E7A46;
  --warn: #B4791A;
  --red: #C1272D;           /* alert red on light */
  --blue: #2B5C9B;          /* links / info */
  --serif: 'Libre Caslon Display', Georgia, 'Times New Roman', serif;
  --sans: 'Public Sans', 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  --radius: 12px;
  --sidebar: 244px;
  /* sidebar-scoped (dark rail) */
  --sb-bg: #0C1D33;
  --sb-border: #1B3050;
  --sb-text: #D7E0EA;
  --sb-muted: #8A98A8;
  --sb-hover: #16283F;
  font-size: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

/* ---------- App shell ---------- */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar); flex: 0 0 var(--sidebar);
  border-right: 1px solid var(--sb-border);
  background: var(--sb-bg);
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  padding: 1rem 0.75rem 2rem;
}
.sidebar .logo { padding: 0.4rem 0.6rem 0.9rem; }
.sidebar .logo h1 { margin: 0; font-size: 1.15rem; letter-spacing: 0.05em; color: var(--accent-dim); }
.sidebar .logo p { margin: 0.1rem 0 0; font-size: 0.68rem; color: var(--sb-muted); }

.nav-group { margin-top: 1rem; }
.nav-group > .gh { font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.11em; color: var(--sb-muted); padding: 0 0.6rem 0.35rem; opacity: 0.85; }
.nav-group a {
  display: flex; align-items: center; gap: 0.5rem;
  color: var(--sb-text); text-decoration: none; font-size: 0.83rem;
  padding: 0.38rem 0.6rem; border-radius: 8px; margin-bottom: 1px;
}
.nav-group a:hover { background: var(--sb-hover); }
.nav-group a.cur { background: var(--sb-hover); color: var(--accent-dim); }
.nav-group a .badge-n { margin-left: auto; font-size: 0.62rem; background: var(--red); color: #fff; border-radius: 999px; padding: 0 0.35rem; min-width: 16px; text-align: center; }

.content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.1rem 1.6rem; border-bottom: 1px solid var(--border); background: var(--panel);
}
.topbar .ttl h1 { margin: 0; font-size: 1.25rem; letter-spacing: 0.01em; font-family: var(--serif); font-weight: 400; }
.topbar .ttl p { margin: 0.15rem 0 0; font-size: 0.8rem; color: var(--muted); }
.clock { text-align: right; }
#time { font-size: 1.35rem; font-variant-numeric: tabular-nums; font-weight: 600; }
#date { font-size: 0.76rem; color: var(--muted); }

.page { padding: 1.4rem 1.6rem 2rem; }

/* ---------- Executive brief banner ---------- */
.brief {
  background: linear-gradient(135deg, #FFFFFF, #F1F4F8);
  border: 1px solid var(--border); border-left: 3px solid var(--brand);
  border-radius: var(--radius); padding: 0.95rem 1.15rem; margin-bottom: 1.3rem;
}
.brief h2 { margin: 0 0 0.4rem; font-size: 0.7rem; letter-spacing: 0.09em; text-transform: uppercase; color: var(--brand); }
.brief .bluf { margin: 0 0 0.6rem; font-size: 0.98rem; line-height: 1.55; }
.brief .bluf b { color: var(--brand); }
.brief ul { margin: 0; padding-left: 1.1rem; }
.brief li { font-size: 0.9rem; line-height: 1.5; margin-bottom: 0.28rem; }

.mk { font-size: 0.6rem; font-weight: 700; padding: 0.05rem 0.3rem; border-radius: 3px; letter-spacing: 0.03em; }
.mk.assess { background: rgba(180,121,26,0.14); color: #8A5A12; }
.mk.fact   { background: rgba(30,122,70,0.14); color: #1A6E3F; }
.mk.alert  { background: rgba(193,39,45,0.12); color: #B01E27; }

/* ---------- Cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; align-content: start; }
.grid.wide { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 1.15rem; display: flex; flex-direction: column; box-shadow: 0 1px 2px rgba(10,26,47,0.04); }
.card h2 {
  margin: 0 0 0.75rem; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.09em;
  color: var(--muted); border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
  display: flex; align-items: center; gap: 0.5rem;
}
.card h2 .vendor, .card h2 .right { margin-left: auto; font-size: 0.66rem; text-transform: none; letter-spacing: 0; color: var(--muted); font-weight: 400; }
.card h2 a.right { color: var(--brand); text-decoration: none; }

/* metric strip */
.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 0.7rem; margin-bottom: 1.3rem; }
.metric { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.7rem 0.85rem; box-shadow: 0 1px 2px rgba(10,26,47,0.04); }
.metric .v { font-size: 1.4rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.metric .l { font-size: 0.66rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); margin-top: 0.15rem; }
.metric .d { font-size: 0.72rem; margin-top: 0.2rem; }
.metric .d.up { color: var(--ok); } .metric .d.down { color: var(--red); }

.big { font-size: 1.9rem; font-weight: 700; color: var(--text); line-height: 1.1; }
.sub { color: var(--muted); font-size: 0.8rem; }
.mini { display: flex; gap: 0.55rem; margin-top: 0.6rem; }
.mini .b { flex: 1; background: var(--panel-2); border-radius: 8px; padding: 0.45rem 0.55rem; }
.mini .b .v { font-size: 1.02rem; font-weight: 600; color: var(--text); }
.mini .b .l { font-size: 0.62rem; text-transform: uppercase; color: var(--muted); letter-spacing: 0.05em; }
.mini .b.up .v { color: var(--ok); } .mini .b.down .v { color: var(--red); }

.row { display: flex; justify-content: space-between; font-size: 0.86rem; padding: 0.3rem 0; border-bottom: 1px dashed var(--border); }
.row:last-child { border-bottom: none; }
.row .k { color: var(--muted); }

/* goal progress */
.goal { margin-top: 0.7rem; }
.goal .lab { display: flex; justify-content: space-between; font-size: 0.74rem; color: var(--muted); margin-bottom: 0.25rem; }
.prog { height: 7px; background: var(--panel-2); border-radius: 4px; overflow: hidden; }
.prog > i { display: block; height: 100%; background: var(--brand); }
.prog > i.ok { background: var(--ok); }
.prog > i.warn { background: var(--warn); }

/* status pills / badges — dark text on light tint */
.pill { font-size: 0.58rem; font-weight: 700; letter-spacing: 0.04em; text-transform: uppercase; padding: 0.1rem 0.4rem; border-radius: 999px; border: 1px solid var(--border); }
.pill.live   { background: rgba(30,122,70,0.12);  color: #1A6E3F; border-color: rgba(30,122,70,0.35); }
.pill.csv    { background: rgba(43,92,155,0.12);  color: #2B5C9B; border-color: rgba(43,92,155,0.35); }
.pill.manual { background: rgba(180,121,26,0.14); color: #8A5A12; border-color: rgba(180,121,26,0.35); }
.pill.sample { background: rgba(91,107,126,0.12); color: #5B6B7E; border-color: rgba(91,107,126,0.3); }
.pill.off    { background: rgba(91,107,126,0.08); color: #7C8A9C; }

.badge { display: inline-block; font-size: 0.6rem; font-weight: 700; letter-spacing: 0.04em; padding: 0.08rem 0.4rem; border-radius: 999px; border: 1px solid var(--border); text-transform: uppercase; }
.sev-critical { background: rgba(193,39,45,0.12);  color: #B01E27; border-color: rgba(193,39,45,0.35); }
.sev-high     { background: rgba(199,109,26,0.14); color: #B4661A; border-color: rgba(199,109,26,0.35); }
.sev-medium   { background: rgba(180,121,26,0.14); color: #8A5A12; border-color: rgba(180,121,26,0.35); }
.sev-low      { background: rgba(30,122,70,0.12);  color: #1A6E3F; border-color: rgba(30,122,70,0.35); }
.conf-high { background: rgba(30,122,70,0.10);  color: #1A6E3F; }
.conf-med  { background: rgba(180,121,26,0.12); color: #8A5A12; }
.conf-low  { background: rgba(91,107,126,0.12); color: #5B6B7E; }

/* feed (watchfloor) */
.feed { display: flex; flex-direction: column; gap: 0.5rem; }
.feed .item { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 0.65rem 0.85rem; display: flex; gap: 0.7rem; align-items: flex-start; box-shadow: 0 1px 2px rgba(10,26,47,0.04); }
.feed .item .bar { width: 3px; align-self: stretch; border-radius: 3px; background: var(--border); flex: 0 0 3px; }
.feed .item.crit .bar { background: var(--red); } .feed .item.high .bar { background: #C77A1A; } .feed .item.med .bar { background: var(--warn); }
.feed .item .body { flex: 1; min-width: 0; }
.feed .item .body .h { font-size: 0.9rem; line-height: 1.4; }
.feed .item .body .h b { color: var(--text); }
.feed .item .meta { display: flex; gap: 0.5rem; flex-wrap: wrap; align-items: center; margin-top: 0.3rem; font-size: 0.72rem; color: var(--muted); }
.feed .item .when { margin-left: auto; font-size: 0.72rem; color: var(--muted); white-space: nowrap; }
.src-tag { color: var(--blue); text-decoration: none; }

/* tables */
table.tbl { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
table.tbl th { text-align: left; font-size: 0.6rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); padding: 0.4rem 0.6rem; border-bottom: 1px solid var(--border); }
table.tbl td { padding: 0.5rem 0.6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
table.tbl tr:last-child td { border-bottom: none; }

/* stub / placeholder page */
.stub { max-width: 760px; }
.stub .lead { font-size: 0.98rem; line-height: 1.6; color: var(--text); }
.stub .planned { margin-top: 1.2rem; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.15rem; box-shadow: 0 1px 2px rgba(10,26,47,0.04); }
.stub .planned h3 { margin: 0 0 0.6rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); }
.stub .planned ul { margin: 0; padding-left: 1.15rem; }
.stub .planned li { font-size: 0.9rem; line-height: 1.6; }
.stub .note { margin-top: 1rem; font-size: 0.82rem; color: var(--muted); }

.setup { color: var(--muted); font-size: 0.86rem; }
.setup a { color: var(--brand); text-decoration: none; }
.muted { color: var(--muted); }
h2.section-h { font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--brand); border-bottom: 1px solid var(--accent-dim); padding-bottom: 0.4rem; margin: 1.5rem 0 0.9rem; }

/* ============ Keystone brand layer ============ */
.sidebar .logo h1 { font-family: var(--serif); font-weight: 400; letter-spacing: 0.02em; font-size: 1.3rem; }
.sidebar .logo p { letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.6rem; }
.logo { display: flex; }
.logo .mark { display: flex; align-items: center; gap: 0.6rem; }
.logo .mark svg { flex: 0 0 auto; }
.logo .mark h1 { line-height: 1.05; }

.nav-group a .kdot { font-size: 0.6rem; line-height: 1; color: #3A5170; flex: 0 0 auto; width: 12px; text-align: center; }
.nav-group a:hover .kdot { color: var(--accent-dim); }
.nav-group a.cur .kdot { color: var(--accent-dim); }

.brand-accent { color: var(--brand); }

/* mobile: collapse sidebar to top strip */
@media (max-width: 820px) {
  .app { flex-direction: column; }
  .sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--sb-border); display: flex; flex-wrap: wrap; gap: 0.2rem; padding: 0.6rem; }
  .sidebar .logo { width: 100%; padding: 0.2rem 0.4rem 0.6rem; }
  .nav-group { margin: 0; }
  .nav-group > .gh { display: none; }
  .nav-group a { padding: 0.3rem 0.5rem; font-size: 0.78rem; }
}
