/* ═══════════════════════════════════════════════════════════════════
   LoadFlow App Design System — SaaS product surfaces
   Used by: /intel/ (Grid Intelligence) and /study/ (Study Engine).
   The editorial site keeps loadflow.css; product surfaces use THIS.
   Spec: /DESIGN_SYSTEM.md
   ═══════════════════════════════════════════════════════════════════ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=IBM+Plex+Mono:wght@400;500;600&display=swap');

:root {
  /* v2 dark scale (flipped 2026-07-31 — whole-site re-skin) */
  --bg:        #080B11;
  --surface:   #111A25;
  --surface-2: #17222F;
  --border:    #213042;
  --border-2:  #2A3A4D;
  --text:      #EAF0F5;
  --text-2:    #93A3B3;
  --text-3:    #57697A;

  /* brand */
  --accent:    #00E5A0;
  --accent-h:  #00B47F;
  --accent-t:  rgba(0,229,160,.1);
  --electric:  #37E1E8;

  /* status */
  --ok:        #2ECC71;   --ok-t:     rgba(46,204,113,.13);
  --warn:      #FFC24B;   --warn-t:   rgba(255,194,75,.13);
  --bad:       #FF6B6B;   --bad-t:    rgba(255,107,107,.12);
  --info:      #4A90E2;   --info-t:   rgba(74,144,226,.14);
  --neutral-t: #17222F;

  --sans: 'Inter', -apple-system, 'Segoe UI', sans-serif;
  --mono: 'IBM Plex Mono', ui-monospace, monospace;

  --r-sm: 6px;  --r-md: 8px;  --r-lg: 12px;  --r-full: 999px;
  --sh-sm: 0 1px 2px rgba(16,22,29,.05);
  --sh-md: 0 1px 3px rgba(16,22,29,.06), 0 4px 12px rgba(16,22,29,.05);
  --sh-lg: 0 4px 10px rgba(16,22,29,.06), 0 12px 32px rgba(16,22,29,.10);
  --sidebar-w: 232px;
}

.theme-dark {
  --bg:        #0b0f14;
  --surface:   #121821;
  --surface-2: #1a212c;
  --border:    #232c38;
  --border-2:  #2f3a49;
  --text:      #e8ecf1;
  --text-2:    #a3aebc;
  --text-3:    #67717f;
  --accent:    #2ba3e0;
  --accent-h:  #4db6ea;
  --accent-t:  rgba(43,163,224,.12);
  --ok:        #34c179;   --ok-t:     rgba(52,193,121,.13);
  --warn:      #e8a33d;   --warn-t:   rgba(232,163,61,.13);
  --bad:       #f0655a;   --bad-t:    rgba(240,101,90,.13);
  --info:      #5aa2f7;   --info-t:   rgba(90,162,247,.13);
  --neutral-t: rgba(255,255,255,.07);
  --sh-sm: 0 1px 2px rgba(0,0,0,.4);
  --sh-md: 0 2px 6px rgba(0,0,0,.35);
  --sh-lg: 0 8px 32px rgba(0,0,0,.5);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-font-smoothing: antialiased; }
body.app {
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
}
.num, .mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-h); }

/* ── APP SHELL: fixed sidebar + main ─────────────────────────────── */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
  padding: 18px 12px 14px;
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 10px 16px; }
.sidebar-logo {
  width: 30px; height: 30px; border-radius: var(--r-md);
  background: rgba(0,229,160,.07) url('/loadflow-mark.svg') center/20px no-repeat;
  border: 1px solid var(--border);
  flex-shrink: 0; font-size: 0;
}
.sidebar-brand-name { font-weight: 700; font-size: 14.5px; letter-spacing: -.01em; line-height: 1.15; }
.sidebar-brand-product { font-size: 11px; color: var(--text-3); font-weight: 500; }
.side-section { margin-top: 14px; }
.side-section-label {
  font-size: 10.5px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase;
  color: var(--text-3); padding: 0 10px 6px;
}
.side-link {
  display: flex; align-items: center; gap: 9px;
  padding: 7px 10px; border-radius: var(--r-sm);
  color: var(--text-2); font-size: 13px; font-weight: 500;
  transition: background .12s, color .12s;
}
.side-link svg { width: 15px; height: 15px; flex-shrink: 0; stroke-width: 1.8; }
.side-link:hover { background: var(--surface-2); color: var(--text); }
.side-link.active { background: var(--accent-t); color: var(--accent); font-weight: 600; }
.sidebar-foot { margin-top: auto; padding: 10px 10px 0; border-top: 1px solid var(--border); }
.sidebar-user { font-size: 11.5px; color: var(--text-3); font-family: var(--mono); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-bottom: 8px; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  height: 56px; flex-shrink: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 28px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 50;
}
.topbar-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.content { padding: 24px 28px 64px; max-width: 1360px; width: 100%; }

/* ── CARDS ──────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-pad { padding: 18px 20px; }
.card-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 20px; border-bottom: 1px solid var(--border);
}
.card-title { font-size: 13.5px; font-weight: 600; }
.card-sub { font-size: 12px; color: var(--text-3); }

/* KPI tiles */
.kpi-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); box-shadow: var(--sh-sm); padding: 14px 16px; }
.kpi-label { font-size: 11px; font-weight: 500; color: var(--text-3); letter-spacing: .02em; margin-bottom: 6px; display: flex; align-items: center; gap: 5px; }
.kpi-value { font-family: var(--mono); font-size: 21px; font-weight: 600; letter-spacing: -.02em; line-height: 1.1; }
.kpi-value small { font-size: 12px; color: var(--text-3); font-weight: 500; }
.kpi-hint { font-size: 11px; color: var(--text-3); margin-top: 4px; }

/* ── BADGES ─────────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  white-space: nowrap;
}
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge.ok      { background: var(--ok-t);      color: var(--ok); }
.badge.warn    { background: var(--warn-t);    color: var(--warn); }
.badge.bad     { background: var(--bad-t);     color: var(--bad); }
.badge.info    { background: var(--info-t);    color: var(--info); }
.badge.neutral { background: var(--neutral-t); color: var(--text-2); }
.badge.accent  { background: var(--accent-t);  color: var(--accent); }

/* confidence tier chips */
.tier { display: inline-flex; align-items: center; padding: 1px 7px; border-radius: 4px; font-family: var(--mono); font-size: 10px; font-weight: 600; }
.tier.v { background: var(--ok-t);   color: var(--ok); }
.tier.s { background: var(--info-t); color: var(--info); }
.tier.i { background: var(--neutral-t); color: var(--text-3); }

/* ── BUTTONS ────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 14px; border-radius: var(--r-md);
  font-family: var(--sans); font-size: 13px; font-weight: 600;
  border: 1px solid transparent; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s, box-shadow .12s;
  white-space: nowrap;
}
.btn svg { width: 15px; height: 15px; stroke-width: 2; }
.btn-primary { background: var(--accent); color: #fff; box-shadow: var(--sh-sm); }
.btn-primary:hover { background: var(--accent-h); color: #fff; }
.btn-ghost { background: var(--surface); color: var(--text-2); border-color: var(--border-2); }
.btn-ghost:hover { border-color: var(--text-3); color: var(--text); }
.btn-sm { padding: 5px 10px; font-size: 12px; border-radius: var(--r-sm); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── INPUTS ─────────────────────────────────────────────────────── */
.input, .select {
  background: var(--surface); border: 1px solid var(--border-2);
  border-radius: var(--r-md); padding: 8px 11px;
  font-family: var(--sans); font-size: 13px; color: var(--text);
  outline: none; transition: border-color .12s, box-shadow .12s;
}
.input:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-t); }
.input::placeholder { color: var(--text-3); }
.field-label { display: block; font-size: 11.5px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.select { appearance: none; padding-right: 28px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b95a1' stroke-width='2.5'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 9px center; }

/* toggle pill filters */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: var(--r-full);
  background: var(--surface); border: 1px solid var(--border-2);
  font-size: 12px; font-weight: 600; color: var(--text-2);
  cursor: pointer; transition: all .12s;
}
.pill:hover { border-color: var(--text-3); }
.pill.active { background: var(--accent-t); border-color: var(--accent); color: var(--accent); }

/* ── TABLES ─────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left; padding: 9px 14px;
  font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--text-3); border-bottom: 1px solid var(--border);
  background: var(--surface); position: sticky; top: 0; white-space: nowrap;
}
.tbl th.sortable { cursor: pointer; user-select: none; }
.tbl th.sortable:hover { color: var(--text); }
.tbl td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl tbody tr { transition: background .1s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl tbody tr.rowlink { cursor: pointer; }
.tbl td.num, .tbl th.num { text-align: right; }
.tbl .cell-main { font-weight: 600; color: var(--text); }
.tbl .cell-sub { font-size: 11.5px; color: var(--text-3); margin-top: 1px; }

/* ── MISC ───────────────────────────────────────────────────────── */
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .01em; margin: 26px 0 10px; display: flex; align-items: center; gap: 8px; }
.section-title .badge { font-weight: 600; }
.callout { border: 1px solid var(--border); border-left: 3px solid var(--accent); border-radius: var(--r-md); background: var(--surface); padding: 12px 16px; font-size: 13px; color: var(--text-2); }
.callout.warn { border-left-color: var(--warn); background: var(--warn-t); color: var(--text); }
.callout.bad  { border-left-color: var(--bad);  background: var(--bad-t);  color: var(--text); }

.empty { text-align: center; padding: 56px 20px; color: var(--text-3); }
.empty-title { font-size: 15px; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }

.skeleton { border-radius: var(--r-md); background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: sk 1.3s infinite; }
@keyframes sk { 0% { background-position: 200% 0 } 100% { background-position: -200% 0 } }

.divider { height: 1px; background: var(--border); margin: 20px 0; }
.muted { color: var(--text-3); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }

@media (max-width: 960px) {
  .sidebar { display: none; }
  .content { padding: 18px 16px 48px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}
