/* ═══════════════════════════════════════════════════════════════════════════
   SignalSifter v2.1 – Premium Dark UI
   Dr. Amobi Andrew Onovo · Quantium Insights LLC
   Aesthetic: Scientific Luxury · Deep Navy · Teal Crystalline
   ════════════════════════════════════════════════════════════════════════ */

/* ── Tokens ────────────────────────────────────────────────────────────── */
:root {
  /* Core palette */
  --ink:       #04080f;
  --navy-950:  #060d1a;
  --navy-900:  #0a1628;
  --navy-800:  #0f2040;
  --navy-700:  #162b56;
  --navy-600:  #1d3870;

  --teal-500:  #00c9b1;
  --teal-400:  #00e5cc;
  --teal-300:  #5ffaea;
  --teal-dim:  rgba(0,201,177,.12);
  --teal-glow: rgba(0,201,177,.25);

  --gold:      #f0c060;
  --gold-dim:  rgba(240,192,96,.12);

  --glass-bg:  rgba(255,255,255,.032);
  --glass-bdr: rgba(255,255,255,.07);
  --glass-hi:  rgba(255,255,255,.05);

  --txt-1: #e8f0ff;
  --txt-2: #8da4cc;
  --txt-3: #556080;

  --green:  #22c55e;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --purple: #a78bfa;

  /* Typography */
  --fs-xs:  .72rem;
  --fs-sm:  .82rem;
  --fs-base:  .92rem;
  --fs-md:  1.05rem;
  --fs-lg:  1.3rem;
  --fs-xl:  2rem;
  --fs-2xl: 3.2rem;

  --font-display: 'Syne', sans-serif;
  --font-body:    'DM Sans', sans-serif;
  --font-mono:    'JetBrains Mono', monospace;

  /* Layout */
  --sidebar-w: 220px;
  --radius-sm: 6px;
  --radius:    12px;
  --radius-lg: 18px;
  --radius-xl: 26px;

  /* Shadows */
  --shadow-teal: 0 0 40px rgba(0,201,177,.08);
  --shadow-card: 0 4px 24px rgba(0,0,0,.4), 0 1px 4px rgba(0,0,0,.3);
  --shadow-deep: 0 12px 48px rgba(0,0,0,.6);

  --t: .2s ease;
}

/* ── Reset ─────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; scroll-behavior: smooth; }
body {
  font-family: var(--font-body);
  background: var(--navy-950);
  color: var(--txt-1);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}
a { color: var(--teal-500); text-decoration: none; }
.hidden { display: none !important; }

/* ── Ambient background ────────────────────────────────────────────────── */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: .35;
  animation: drift 18s ease-in-out infinite alternate;
}
.orb-1 { width: 600px; height: 600px; background: radial-gradient(#005566, transparent 70%); top:-150px; left:50px; animation-duration:20s; }
.orb-2 { width: 500px; height: 500px; background: radial-gradient(#001833, transparent 70%); bottom:-100px; right:100px; animation-duration:25s; animation-delay:5s; }
.orb-3 { width: 400px; height: 400px; background: radial-gradient(#003322, transparent 70%); top:40%; left:40%; animation-duration:22s; animation-delay:10s; }
@keyframes drift { from { transform: translate(0,0) scale(1); } to { transform: translate(40px,30px) scale(1.06); } }

.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(0,201,177,.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,201,177,.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ── Sidebar ───────────────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  z-index: 50;
  background: rgba(6,13,26,.85);
  backdrop-filter: blur(24px);
  border-right: 1px solid var(--glass-bdr);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1rem;
  transition: transform var(--t);
}

.sidebar-brand {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--glass-bdr);
}
.brand-mark {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--teal-500), #006688);
  color: var(--navy-950);
  font-family: var(--font-display);
  font-weight: 800;
  font-size: .9rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 16px var(--teal-glow);
}
.brand-name {
  display: block;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: .95rem;
  color: var(--txt-1);
  line-height: 1.2;
}
.brand-tag {
  display: block;
  font-size: .65rem;
  color: var(--txt-3);
  letter-spacing: .05em;
  text-transform: uppercase;
}

.sidenav { display: flex; flex-direction: column; gap: .25rem; flex: 1; }
.sidenav-item {
  display: flex; align-items: center; gap: .7rem;
  padding: .65rem .85rem;
  border-radius: var(--radius-sm);
  font-size: var(--fs-sm);
  font-weight: 500;
  color: var(--txt-2);
  transition: background var(--t), color var(--t);
  position: relative;
}
.sidenav-item:hover { background: var(--glass-hi); color: var(--txt-1); }
.sidenav-item.active {
  background: var(--teal-dim);
  color: var(--teal-400);
  font-weight: 600;
}
.sidenav-item.active::before {
  content: '';
  position: absolute; left: 0; top: 20%; bottom: 20%;
  width: 3px; border-radius: 2px;
  background: var(--teal-500);
}
.sidenav-icon { font-size: 1rem; flex-shrink: 0; }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--glass-bdr); }
.api-pill {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .3rem .7rem;
  border-radius: 999px;
  background: var(--glass-bg);
  border: 1px solid var(--glass-bdr);
  font-size: var(--fs-xs);
  color: var(--txt-2);
  margin-bottom: .5rem;
}
.api-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--txt-3); transition: background var(--t); }
.api-dot.ok { background: var(--green); box-shadow: 0 0 6px var(--green); }
.api-dot.err { background: var(--red); }
.sidebar-credit { font-size: var(--fs-xs); color: var(--txt-3); }

/* ── Main panel ────────────────────────────────────────────────────────── */
.main-panel {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* ── Hero ──────────────────────────────────────────────────────────────── */
.hero {
  padding: 3rem 3rem 2.5rem;
  position: relative;
  border-bottom: 1px solid var(--glass-bdr);
  background: linear-gradient(180deg, rgba(0,201,177,.04) 0%, transparent 100%);
}
.menu-toggle {
  display: none;
  position: absolute; top: 1rem; left: 1rem;
  background: var(--glass-bg); border: 1px solid var(--glass-bdr);
  color: var(--txt-1); font-size: 1.2rem;
  padding: .4rem .7rem; border-radius: var(--radius-sm); cursor: pointer;
}
.hero-inner { max-width: 720px; }
.hero-eyebrow {
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .15em;
  text-transform: uppercase;
  color: var(--teal-500);
  margin-bottom: .5rem;
}
.hero-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2rem, 5vw, 3.8rem);
  line-height: 1.05;
  letter-spacing: -.03em;
  color: var(--txt-1);
  margin-bottom: .5rem;
}
.accent { color: var(--teal-400); }
.hero-sub {
  font-size: var(--fs-base);
  color: var(--txt-2);
  margin-bottom: 1.25rem;
  font-weight: 300;
}
.hero-tags { display: flex; flex-wrap: wrap; gap: .5rem; }
.htag {
  padding: .22rem .75rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: .04em;
  border: 1px solid var(--glass-bdr);
  color: var(--txt-2);
  background: var(--glass-bg);
  backdrop-filter: blur(8px);
}

/* ── Page content ──────────────────────────────────────────────────────── */
.page-content {
  flex: 1;
  padding: 2rem 2.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-width: 1000px;
  width: 100%;
}

/* ── Glass cards ───────────────────────────────────────────────────────── */
.glass-card {
  background: var(--glass-bg);
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-lg);
  padding: 1.75rem 2rem;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow-card);
  transition: border-color var(--t), box-shadow var(--t);
  position: relative;
  overflow: hidden;
}
.glass-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(0,201,177,.3), transparent);
}
.glass-card:hover {
  border-color: rgba(0,201,177,.15);
  box-shadow: var(--shadow-card), var(--shadow-teal);
}

.card-head {
  display: flex; align-items: center; gap: .75rem;
  margin-bottom: 1.5rem; flex-wrap: wrap;
}
.card-title {
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--txt-1);
  display: flex; align-items: center; gap: .55rem;
  letter-spacing: -.01em;
}
.c-icon { font-size: 1.1rem; }

/* ── Badges ────────────────────────────────────────────────────────────── */
.badge {
  margin-left: auto;
  padding: .18rem .65rem;
  border-radius: 999px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: .04em;
  background: var(--teal-dim);
  color: var(--teal-400);
  border: 1px solid rgba(0,201,177,.2);
}
.badge-ai   { background: rgba(34,197,94,.1);  color: #4ade80; border-color: rgba(34,197,94,.25); }
.badge-mem  { background: rgba(167,139,250,.1); color: var(--purple); border-color: rgba(167,139,250,.25); }
.req-badge  { background: rgba(239,68,68,.12); color: #f87171; padding: .1rem .45rem; border-radius: 4px; font-size: .68rem; font-weight: 700; margin-left: .4rem; }
.opt-badge  { background: var(--glass-bg); color: var(--txt-3); padding: .1rem .45rem; border-radius: 4px; font-size: .68rem; font-weight: 700; margin-left: .4rem; }

/* ── Thresholds ────────────────────────────────────────────────────────── */
.thresh-table { border-radius: var(--radius); overflow: hidden; border: 1px solid var(--glass-bdr); margin-bottom: .75rem; }
.thresh-row { display: grid; grid-template-columns: 1.1fr 1fr 2fr; }
.thresh-row > span { padding: .65rem 1rem; font-size: var(--fs-sm); border-bottom: 1px solid rgba(255,255,255,.04); }
.thresh-row:last-child > span { border-bottom: none; }
.thresh-head > span { background: rgba(0,201,177,.1); color: var(--teal-400); font-weight: 700; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; }
.thresh-row:not(.thresh-head) > span:first-child { border-left: 3px solid var(--bar, #666); }
.thresh-row:not(.thresh-head):hover > span { background: rgba(255,255,255,.025); }
.thresh-row code { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--teal-300); }
.thresh-note { font-size: var(--fs-xs); color: var(--txt-3); }

/* ── Dropzone ──────────────────────────────────────────────────────────── */
.dropzone {
  border: 1.5px dashed rgba(0,201,177,.35);
  border-radius: var(--radius-lg);
  padding: 2.75rem 1rem;
  text-align: center;
  background: rgba(0,201,177,.03);
  cursor: pointer;
  transition: border-color var(--t), background var(--t);
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--teal-400);
  background: rgba(0,201,177,.07);
}
.dz-ring {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,201,177,.3);
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .85rem;
  background: rgba(0,201,177,.06);
}
.dz-icon { font-size: 1.5rem; }
.dz-label { font-size: var(--fs-base); font-weight: 500; color: var(--txt-1); }
.dz-link { color: var(--teal-400); font-weight: 700; cursor: pointer; text-decoration: underline; }
.dz-hint  { font-size: var(--fs-xs); color: var(--txt-3); margin-top: .35rem; }

/* ── Feedback ──────────────────────────────────────────────────────────── */
.feedback {
  margin-top: 1rem; padding: .7rem 1rem;
  border-radius: var(--radius-sm); font-size: var(--fs-sm); font-weight: 500;
}
.feedback.ok    { background: rgba(34,197,94,.1);  color: #4ade80; border: 1px solid rgba(34,197,94,.25); }
.feedback.error { background: rgba(239,68,68,.1);  color: #f87171; border: 1px solid rgba(239,68,68,.25); }

/* ── Forms ─────────────────────────────────────────────────────────────── */
.form-label { display: block; font-size: var(--fs-xs); font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--txt-2); margin-bottom: .5rem; }
.select-field {
  width: 100%; padding: .6rem .9rem;
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  color: var(--txt-1);
  font-family: var(--font-body);
  font-size: var(--fs-sm);
  outline: none;
  transition: border-color var(--t);
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238da4cc' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .85rem center;
  padding-right: 2.2rem;
}
.select-field:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-dim); }
.select-field option { background: var(--navy-800); }

.slider-row { display: flex; align-items: center; gap: 1rem; }
.slider {
  flex: 1; -webkit-appearance: none; height: 4px;
  border-radius: 2px; outline: none;
  background: linear-gradient(to right, var(--teal-500) var(--pct, 37.5%), rgba(255,255,255,.1) var(--pct, 37.5%));
}
.slider::-webkit-slider-thumb {
  -webkit-appearance: none; width: 18px; height: 18px;
  border-radius: 50%; background: var(--teal-500);
  border: 2.5px solid var(--navy-900);
  box-shadow: 0 0 8px var(--teal-glow); cursor: pointer;
  transition: transform var(--t);
}
.slider::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider-val { font-family: var(--font-mono); font-size: 1rem; font-weight: 700; color: var(--teal-400); min-width: 24px; }

.section-sub { font-size: var(--fs-sm); font-weight: 600; color: var(--txt-2); margin-bottom: .6rem; text-transform: uppercase; letter-spacing: .06em; }
.dim-note    { font-size: var(--fs-xs); color: var(--txt-3); margin-top: .5rem; }

/* ── Tables ────────────────────────────────────────────────────────────── */
.tbl-scroll { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--glass-bdr); }
table { border-collapse: collapse; width: 100%; font-size: var(--fs-sm); }
thead tr { background: rgba(0,201,177,.08); }
thead th { padding: .6rem .9rem; color: var(--teal-400); font-weight: 700; font-size: var(--fs-xs); letter-spacing: .06em; text-transform: uppercase; text-align: left; white-space: nowrap; border-bottom: 1px solid rgba(0,201,177,.12); }
tbody tr { border-bottom: 1px solid rgba(255,255,255,.04); transition: background var(--t); }
tbody tr:last-child { border-bottom: none; }
tbody tr:hover { background: rgba(255,255,255,.03); }
tbody td { padding: .55rem .9rem; color: var(--txt-1); white-space: nowrap; }
td.iv-cell { font-weight: 700; font-family: var(--font-mono); }

/* ── Column selector chips ─────────────────────────────────────────────── */
.col-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px,1fr)); gap: 1.25rem; margin-bottom: 1.5rem; }
.cols-2   { grid-template-columns: repeat(auto-fit, minmax(240px,1fr)); }
.col-group {}
.chip-wrap {
  min-height: 46px; max-height: 130px; overflow-y: auto;
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-sm);
  padding: .4rem; display: flex; flex-wrap: wrap; gap: .3rem;
  background: rgba(255,255,255,.02);
  transition: border-color var(--t);
}
.chip-wrap:focus-within { border-color: var(--teal-500); }
.col-chip {
  padding: .2rem .6rem; border-radius: 999px; font-size: var(--fs-xs); font-weight: 500;
  background: rgba(255,255,255,.06); color: var(--txt-2); border: 1px solid rgba(255,255,255,.08);
  cursor: pointer; transition: background var(--t), color var(--t); user-select: none;
}
.col-chip:hover { background: var(--teal-dim); color: var(--teal-400); border-color: rgba(0,201,177,.25); }
.col-chip.selected { background: var(--teal-500); color: var(--navy-950); border-color: var(--teal-500); font-weight: 700; }
.col-chip.excl.selected { background: var(--red); color: white; border-color: var(--red); }

/* ── Run button ────────────────────────────────────────────────────────── */
.run-btn {
  display: inline-flex; align-items: center; gap: .6rem;
  padding: .85rem 2.25rem;
  border: none; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--teal-500) 0%, #007a6e 100%);
  color: var(--navy-950);
  font-family: var(--font-display);
  font-size: var(--fs-md);
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 4px 20px var(--teal-glow);
  transition: transform var(--t), box-shadow var(--t), opacity var(--t);
  letter-spacing: -.01em;
}
.run-btn:hover  { transform: translateY(-2px); box-shadow: 0 8px 32px var(--teal-glow); }
.run-btn:active { transform: translateY(0); }
.run-btn:disabled { opacity: .35; cursor: not-allowed; transform: none; box-shadow: none; }
.run-icon { font-size: .85rem; }

/* ── Stat strip ────────────────────────────────────────────────────────── */
.stat-strip { display: flex; flex-wrap: wrap; gap: .75rem; margin-bottom: 1.5rem; }
.stat-tile {
  flex: 1; min-width: 85px;
  border-radius: var(--radius);
  padding: .85rem .75rem;
  text-align: center;
  border: 1px solid var(--glass-bdr);
  background: var(--glass-bg);
}
.st-val { display: block; font-family: var(--font-display); font-size: 1.6rem; font-weight: 800; }
.st-lbl { font-size: var(--fs-xs); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; color: var(--txt-3); }
.st-total { border-color: rgba(255,255,255,.1); }
.st-total .st-val { color: var(--txt-1); }
.st-vs    { border-color: rgba(34,197,94,.2);  } .st-vs  .st-val { color: #4ade80; }
.st-s     { border-color: rgba(34,197,94,.15); } .st-s   .st-val { color: #86efac; }
.st-m     { border-color: rgba(245,158,11,.2); } .st-m   .st-val { color: #fcd34d; }
.st-w     { border-color: rgba(239,68,68,.2);  } .st-w   .st-val { color: #f87171; }
.st-n     { border-color: rgba(255,255,255,.08);} .st-n  .st-val { color: var(--txt-3); }
.st-avg   { border-color: rgba(0,201,177,.2);  } .st-avg .st-val { color: var(--teal-400); }

/* ── Chart ─────────────────────────────────────────────────────────────── */
.chart-wrap {
  min-height: 380px; border-radius: var(--radius-lg);
  border: 1px solid var(--glass-bdr);
  background: rgba(255,255,255,.06); margin-bottom: 1.5rem; overflow: hidden;
}

/* ── Sub-headings inside card ──────────────────────────────────────────── */
.sub-head {
  display: flex; align-items: center; gap: .5rem;
  font-size: var(--fs-sm); font-weight: 700;
  color: var(--txt-2); text-transform: uppercase; letter-spacing: .07em;
  margin: 1.5rem 0 .75rem;
}

/* ── Recommendation cards ──────────────────────────────────────────────── */
.rec-loading {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem; color: var(--txt-2); font-size: var(--fs-sm);
}
.rec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px,1fr)); gap: 1rem; }
.rec-card {
  border-radius: var(--radius);
  border: 1px solid var(--glass-bdr);
  border-left: 3px solid var(--rc-color, #666);
  padding: 1.1rem 1.25rem;
  background: rgba(255,255,255,.025);
  backdrop-filter: blur(8px);
  transition: border-color var(--t), box-shadow var(--t);
  animation: fadeUp .4s ease both;
}
.rec-card:hover { border-color: rgba(0,201,177,.2); box-shadow: var(--shadow-teal); }
@keyframes fadeUp { from { opacity:0; transform:translateY(12px); } to { opacity:1; transform:none; } }
.rec-head { display: flex; align-items: baseline; gap: .6rem; margin-bottom: .45rem; }
.rec-feat  { font-family: var(--font-display); font-size: var(--fs-base); font-weight: 700; color: var(--txt-1); }
.rec-label { font-size: var(--fs-xs); font-weight: 700; padding: .12rem .45rem; border-radius: 4px; background: var(--rc-color, #666); color: white; flex-shrink: 0; }
.rec-meta  { font-size: var(--fs-xs); color: var(--txt-3); font-family: var(--font-mono); margin-bottom: .55rem; }
.rec-body  { font-size: var(--fs-sm); color: var(--txt-2); line-height: 1.65; }
.rec-body strong { color: var(--txt-1); }
.rec-steps { list-style: none; margin-top: .4rem; }
.rec-steps li { font-size: var(--fs-sm); color: var(--txt-2); padding: .18rem 0 .18rem 1.1rem; position: relative; }
.rec-steps li::before { content: '→'; position: absolute; left: 0; color: var(--teal-500); }

/* ── Agent chat ─────────────────────────────────────────────────────────── */
.agent-intro { font-size: var(--fs-sm); color: var(--txt-2); margin-bottom: 1rem; }
.prompt-row  { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: 1rem; }
.ppill {
  padding: .25rem .8rem; border-radius: 999px;
  border: 1px solid rgba(0,201,177,.2);
  background: var(--teal-dim); color: var(--teal-400);
  font-size: var(--fs-xs); font-weight: 600; cursor: pointer;
  transition: background var(--t), border-color var(--t);
  font-family: var(--font-body);
}
.ppill:hover { background: rgba(0,201,177,.2); border-color: var(--teal-400); }

.chat-box {
  background: rgba(0,0,0,.25); border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-lg); min-height: 180px; max-height: 360px;
  overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .75rem;
  margin-bottom: .75rem; scroll-behavior: smooth;
}
.chat-empty { color: var(--txt-3); font-size: var(--fs-sm); text-align: center; margin: auto; }
.chat-msg { display: flex; flex-direction: column; gap: .2rem; }
.chat-msg.user   .chat-bubble { background: linear-gradient(135deg, var(--teal-500), #007a6e); color: var(--navy-950); align-self: flex-end; border-bottom-right-radius: 4px; font-weight: 500; }
.chat-msg.assistant .chat-bubble { background: rgba(255,255,255,.045); border: 1px solid var(--glass-bdr); color: var(--txt-1); align-self: flex-start; border-bottom-left-radius: 4px; }
.chat-bubble { padding: .65rem 1rem; border-radius: var(--radius-lg); max-width: 88%; font-size: var(--fs-sm); line-height: 1.65; white-space: pre-wrap; }
.chat-role { font-size: var(--fs-xs); font-weight: 700; color: var(--txt-3); padding: 0 .2rem; }
.chat-msg.user .chat-role { align-self: flex-end; color: var(--teal-500); }

.chat-controls { display: flex; flex-direction: column; gap: .5rem; }
.chat-input-wrap { display: flex; gap: .6rem; align-items: flex-end; }
.chat-input {
  flex: 1; padding: .65rem .9rem;
  border: 1px solid var(--glass-bdr);
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,.04);
  color: var(--txt-1); font-family: var(--font-body); font-size: var(--fs-sm);
  resize: none; outline: none;
  transition: border-color var(--t);
}
.chat-input:focus { border-color: var(--teal-500); box-shadow: 0 0 0 3px var(--teal-dim); }
.chat-input::placeholder { color: var(--txt-3); }

.send-btn {
  padding: .65rem 1.25rem; border: none; border-radius: var(--radius-sm);
  font-family: var(--font-body); font-size: var(--fs-sm); font-weight: 700;
  cursor: pointer; white-space: nowrap; flex-shrink: 0;
  transition: transform var(--t), box-shadow var(--t);
}
.send-btn:hover { transform: translateY(-1px); }
.send-primary   { background: var(--teal-500); color: var(--navy-950); box-shadow: 0 2px 10px var(--teal-dim); }
.send-secondary { background: rgba(167,139,250,.2); color: var(--purple); border: 1px solid rgba(167,139,250,.3); }

.chat-bar { display: flex; align-items: center; justify-content: space-between; min-height: 26px; }
.btn-clear {
  font-size: var(--fs-xs); font-weight: 600; padding: .2rem .65rem;
  border-radius: 999px; border: 1px solid var(--glass-bdr);
  background: transparent; color: var(--txt-3); cursor: pointer;
  transition: background var(--t), color var(--t);
  font-family: var(--font-body);
}
.btn-clear:hover { background: rgba(239,68,68,.1); color: #f87171; border-color: rgba(239,68,68,.3); }

/* ── Code blocks ───────────────────────────────────────────────────────── */
.code-block { background: #0d1117; border-radius: var(--radius); overflow: hidden; margin: .5rem 0; border: 1px solid rgba(255,255,255,.06); }
.code-header { display: flex; align-items: center; justify-content: space-between; padding: .35rem .85rem; background: rgba(255,255,255,.04); border-bottom: 1px solid rgba(255,255,255,.06); }
.code-lang { font-size: var(--fs-xs); font-weight: 700; color: var(--teal-400); text-transform: uppercase; letter-spacing: .08em; font-family: var(--font-mono); }
.copy-btn { font-size: var(--fs-xs); font-weight: 600; padding: .12rem .5rem; border-radius: 4px; border: 1px solid rgba(255,255,255,.1); background: rgba(255,255,255,.06); color: var(--txt-2); cursor: pointer; transition: background var(--t); font-family: var(--font-body); }
.copy-btn:hover { background: var(--teal-dim); color: var(--teal-400); }
.code-block pre { margin: 0; padding: .85rem 1rem; overflow-x: auto; line-height: 1.65; }
.code-block code { font-family: var(--font-mono); color: #cdd9f0; white-space: pre; font-size: var(--fs-xs); }

/* ── Plotly output ─────────────────────────────────────────────────────── */
.plot-output { margin-top: 1rem; border-radius: var(--radius-lg); border: 1px solid rgba(255,255,255,.12); min-height: 500px; background: rgba(255,255,255,.06); }

/* ── Spinner ───────────────────────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(0,201,177,.2);
  border-top-color: var(--teal-500);
  border-radius: 50%;
  animation: spin .65s linear infinite; flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Footer ────────────────────────────────────────────────────────────── */
.page-footer {
  text-align: center; padding: 1.75rem 1rem;
  border-top: 1px solid var(--glass-bdr);
  font-size: var(--fs-xs); color: var(--txt-3); line-height: 2;
}
.footer-note { color: var(--txt-3); }

/* ── Scrollbar ─────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,201,177,.2); border-radius: 99px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,201,177,.4); }

/* ── Responsive ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-panel { margin-left: 0; }
  .menu-toggle { display: block; }
  .hero { padding: 3rem 1.25rem 2rem; }
  .page-content { padding: 1.25rem 1rem; }
  .glass-card { padding: 1.25rem 1.1rem; }
  .thresh-row { grid-template-columns: 1fr 1fr; }
  .thresh-row > span:nth-child(3) { display: none; }
  .stat-strip { gap: .4rem; }
  .stat-tile { min-width: 70px; }
  .st-val { font-size: 1.2rem; }
  .rec-grid { grid-template-columns: 1fr; }
}

/* ── 3-column grid for general agent ──────────────────────────────────── */
.cols-3 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
