@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono:wght@400;600&family=IBM+Plex+Sans:ital,wght@0,300;0,400;0,600;0,700;1,400&display=swap');

:root {
  --blue:      #1a6faf;
  --blue-dark: #0d4f82;
  --blue-light:#e8f2fb;
  --blue-mid:  #3a8fd1;
  --accent:    #e05c2a;
  --green:     #1f7a52;
  --green-bg:  #eaf6ef;
  --amber:     #b45309;
  --amber-bg:  #fef3c7;
  --red:       #c0392b;
  --bg:        #f4f6f9;
  --surface:   #ffffff;
  --border:    #d1d9e6;
  --text:      #1a2332;
  --text-muted:#6b7a99;
  --mono:      'IBM Plex Mono', monospace;
  --sans:      'IBM Plex Sans', sans-serif;
  --nav-h:     52px;
  --sidebar-w: 280px;
  --radius:    6px;
  --shadow:    0 1px 4px rgba(0,0,0,0.08), 0 4px 16px rgba(0,0,0,0.06);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  font-family: var(--sans);
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  height: 100%;
}

/* ── NAV ──────────────────────────────────────────────────────────────────── */
.topnav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  height: var(--nav-h);
  background: var(--blue-dark);
  display: flex; align-items: center;
  padding: 0 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
  gap: 1.5rem;
}
.topnav .brand {
  color: #fff; font-weight: 700; font-size: 1.05rem;
  letter-spacing: -0.02em; white-space: nowrap;
  font-family: var(--mono);
}
.topnav .brand span { color: #7ec8f7; }
.nav-links { display: flex; gap: 2px; flex: 1; }
.nav-links a {
  color: rgba(255,255,255,0.78);
  padding: 6px 13px; border-radius: var(--radius);
  text-decoration: none; font-size: 0.88rem; font-weight: 500;
  transition: background 0.15s, color 0.15s;
  cursor: pointer; white-space: nowrap;
}
.nav-links a:hover { background: rgba(255,255,255,0.15); color: #fff; }
.nav-links a.active { background: rgba(255,255,255,0.2); color: #fff; }
.nav-right {
  color: rgba(255,255,255,0.6); font-size: 0.8rem;
  text-decoration: none; white-space: nowrap;
}
.nav-right:hover { color: rgba(255,255,255,0.9); }

/* ── LAYOUT ───────────────────────────────────────────────────────────────── */
.page-wrap {
  display: flex;
  padding-top: var(--nav-h);
  min-height: 100vh;
}
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 1.1rem 1rem 2rem;
  overflow-y: auto;
  position: fixed;
  top: var(--nav-h);
  bottom: 0;
}
.main-content {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 1.25rem 1.5rem 2rem;
  min-width: 0;
}

/* ── CARDS ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1rem;
  overflow: hidden;
}
.card-header {
  background: #f7f9fc;
  border-bottom: 1px solid var(--border);
  padding: 0.6rem 1rem;
  font-weight: 600; font-size: 0.88rem;
  letter-spacing: 0.01em;
  display: flex; align-items: center; gap: 0.5rem;
}
.card-body { padding: 1rem; }

/* ── SIDEBAR CONTROLS ────────────────────────────────────────────────────── */
.sb-section { margin-bottom: 1rem; }
.sb-title {
  font-size: 0.72rem; font-weight: 700;
  letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  padding-bottom: 0.3rem;
  border-bottom: 1px solid var(--border);
}
label {
  display: block;
  font-size: 0.82rem; font-weight: 600;
  color: #3a4a66;
  margin-bottom: 4px; margin-top: 0.65rem;
}
select, input[type=text], input[type=number] {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.84rem;
  font-family: var(--sans);
  color: var(--text);
  background: #fff;
  transition: border-color 0.15s;
  appearance: none;
}
select:focus, input:focus {
  outline: none;
  border-color: var(--blue-mid);
  box-shadow: 0 0 0 3px rgba(58,143,209,0.15);
}
select[multiple] { height: 90px; padding: 4px 6px; }
.select-wrap { position: relative; }
.select-wrap::after {
  content: '▾';
  position: absolute; right: 9px; top: 50%; transform: translateY(-50%);
  pointer-events: none; color: var(--text-muted); font-size: 0.8rem;
}
.radio-group { display: flex; flex-direction: column; gap: 4px; margin-top: 4px; }
.radio-group label {
  display: flex; align-items: center; gap: 7px;
  font-size: 0.83rem; font-weight: 400; color: var(--text);
  margin: 0; cursor: pointer;
}
.radio-group input[type=radio] { width: auto; }
.checkbox-row {
  display: flex; align-items: center; gap: 7px;
  margin-top: 0.5rem;
}
.checkbox-row label { margin: 0; font-weight: 400; font-size: 0.83rem; cursor: pointer; }
.checkbox-row input[type=checkbox] { width: auto; }

/* ── BUTTONS ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 0.86rem; font-weight: 600;
  border: none; cursor: pointer;
  transition: background 0.15s, transform 0.1s, box-shadow 0.15s;
  font-family: var(--sans);
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--blue); color: #fff;
  box-shadow: 0 2px 6px rgba(26,111,175,0.3);
  width: 100%;
  justify-content: center;
  margin-top: 0.75rem;
}
.btn-primary:hover { background: var(--blue-dark); box-shadow: 0 3px 10px rgba(26,111,175,0.4); }
.btn-sm {
  padding: 5px 11px; font-size: 0.8rem;
}

/* ── ALERTS ─────────────────────────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem; border-radius: var(--radius);
  font-size: 0.86rem; line-height: 1.6;
  border: 1px solid transparent;
}
.alert-info    { background: var(--blue-light);  border-color: #b8d9f5; color: var(--blue-dark); }
.alert-success { background: var(--green-bg);    border-color: #a7dcc0; color: var(--green); }
.alert-warning { background: var(--amber-bg);    border-color: #fcd34d; color: var(--amber); }
.alert-danger  { background: #fdf2f2; border-color: #f5c6cb; color: var(--red); }

/* ── TABLES ──────────────────────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse;
  font-size: 0.83rem; font-family: var(--mono);
}
thead th {
  background: #f2f5fb;
  padding: 7px 12px; text-align: left;
  font-family: var(--sans); font-size: 0.78rem; font-weight: 700;
  letter-spacing: 0.03em; color: #3a4a66;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
tbody td {
  padding: 6px 12px;
  border-bottom: 1px solid #eef1f7;
  white-space: nowrap;
}
tbody tr:hover td { background: #f6f9ff; }
tbody tr:last-child td { border-bottom: none; }
.sig-yes { color: var(--blue); font-weight: 600; }
.sig-no  { color: var(--text-muted); }

/* ── PAGE SECTIONS ───────────────────────────────────────────────────────── */
.page { display: none; }
.page.active { display: block; }

/* ── STATS GRID ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.5rem; margin-bottom: 1rem;
}
.stat-tile {
  background: var(--blue-light);
  border: 1px solid #b8d9f5;
  border-radius: var(--radius);
  padding: 0.6rem 0.75rem;
  text-align: center;
}
.stat-tile .val {
  font-family: var(--mono); font-size: 1.05rem;
  font-weight: 600; color: var(--blue-dark);
}
.stat-tile .lbl {
  font-size: 0.72rem; color: var(--text-muted);
  margin-top: 2px;
}

/* ── INTERPRETATION BOX ──────────────────────────────────────────────────── */
.interp-row {
  padding: 0.55rem 0;
  border-bottom: 1px solid #d8eddc;
  line-height: 1.65;
}
.interp-row:last-child { border-bottom: none; }

/* ── FILE UPLOAD ─────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 0.75rem;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.82rem;
  transition: border-color 0.15s, background 0.15s;
}
.upload-zone:hover { border-color: var(--blue-mid); background: var(--blue-light); }
.upload-zone input[type=file] { display: none; }

/* ── MISC ─────────────────────────────────────────────────────────────────── */
hr { border: none; border-top: 1px solid var(--border); margin: 0.85rem 0; }
.mono { font-family: var(--mono); }
.text-muted { color: var(--text-muted); }
.fw-600 { font-weight: 600; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mt-1 { margin-top: 0.5rem; }
.small { font-size: 0.8rem; }
.tag {
  display: inline-block;
  background: var(--blue-light); color: var(--blue-dark);
  padding: 2px 8px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
}
.tag-green {
  background: var(--green-bg); color: var(--green);
}
.hidden { display: none !important; }
.spinner {
  display: inline-block; width: 18px; height: 18px;
  border: 2px solid var(--blue-light);
  border-top-color: var(--blue);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  vertical-align: middle;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── DIAGNOSTIC GRID ─────────────────────────────────────────────────────── */
.diag-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 900px) { .diag-grid { grid-template-columns: 1fr; } }

/* ── DATA PAGE TABLE ─────────────────────────────────────────────────────── */
#data-table-wrap {
  overflow-x: auto; max-height: 480px; overflow-y: auto;
}
#data-table-wrap table { min-width: 600px; }

/* ── SCROLLBAR ───────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #c5cde0; border-radius: 3px; }

/* ── HOME PAGE ───────────────────────────────────────────────────────────── */
.hero {
  background: linear-gradient(135deg, var(--blue-dark) 0%, var(--blue) 60%, var(--blue-mid) 100%);
  color: #fff;
  padding: 2.5rem 2rem;
  border-radius: var(--radius);
  margin-bottom: 1.25rem;
}
.hero h1 { font-family: var(--mono); font-size: 1.7rem; font-weight: 700; margin-bottom: 0.5rem; }
.hero p  { opacity: 0.85; line-height: 1.6; max-width: 600px; font-size: 0.95rem; }
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 1rem;
}
.feature-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 1.1rem 1rem;
  cursor: pointer; transition: box-shadow 0.15s, border-color 0.15s, transform 0.15s;
}
.feature-card:hover {
  box-shadow: 0 4px 18px rgba(26,111,175,0.15);
  border-color: var(--blue-mid); transform: translateY(-2px);
}
.feature-card .icon { font-size: 1.6rem; margin-bottom: 0.5rem; }
.feature-card h3 { font-size: 0.95rem; font-weight: 700; margin-bottom: 0.3rem; }
.feature-card p  { font-size: 0.82rem; color: var(--text-muted); line-height: 1.5; }

/* ── PLOT TYPE TABS ──────────────────────────────────────────────────────── */
.pill-tabs {
  display: flex; gap: 4px; flex-wrap: wrap; margin-bottom: 0.75rem;
}
.pill-tab {
  padding: 5px 13px; border-radius: 20px;
  border: 1px solid var(--border); background: #fff;
  font-size: 0.8rem; font-weight: 600;
  cursor: pointer; color: var(--text-muted);
  transition: all 0.15s;
}
.pill-tab.active, .pill-tab:hover {
  background: var(--blue); color: #fff; border-color: var(--blue);
}
