:root {
  --bg: #09090b;
  --panel: rgba(255, 255, 255, 0.02);
  --panel-border: rgba(255, 255, 255, 0.08);
  --text: #f8fafc;
  --text-dim: #94a3b8;
  --blue: #38bdf8;
  --blue-bright: #7dd3fc;
  --amber: #fbbf24;
  --red: #f87171;
  --numerical: #38bdf8;
  --fpj: #fbbf24;
  --mono: "JetBrains Mono", monospace;
  --sans: "Inter", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(circle at 50% 0%, #1e1b4b 0%, var(--bg) 60%),
                    radial-gradient(circle at 80% 80%, #082f49 0%, transparent 50%);
  background-attachment: fixed;
  color: var(--text);
  font-family: var(--sans);
  min-height: 100vh;
}

.page {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 24px 60px;
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 28px;
}

.header h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.header .accent { color: var(--blue-bright); }

.subtitle {
  margin: 6px 0 0;
  color: var(--text-dim);
  font-family: var(--mono);
  font-size: 13px;
}

.legend {
  display: flex;
  gap: 16px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.legend-item { display: flex; align-items: center; gap: 6px; }

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  display: inline-block;
}

.dot-numerical { background: var(--numerical); }
.dot-fpj { background: var(--fpj); }
.dot-bmc { background: #4caf50; }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 18px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
  border-color: rgba(255, 255, 255, 0.15);
}

.kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin-bottom: 8px;
}

.kpi-value {
  font-family: var(--mono);
  font-size: 26px;
  font-weight: 700;
  line-height: 1.1;
  background: linear-gradient(135deg, #fff, #94a3b8);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.kpi-sub {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 24px;
  margin-bottom: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

.verdict-panel {
  border-left: 4px solid var(--red);
}

.verdict-body p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.65;
}

.verdict-body p:last-child { margin-bottom: 0; }

.verdict-headline {
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 700;
  color: var(--red);
  display: block;
  margin-bottom: 12px;
}

.verdict-caveat {
  color: var(--text-dim);
  font-size: 12px;
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
  margin-top: 10px;
}

.tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.data-sources {
  margin-bottom: 22px;
}

.data-sources summary {
  cursor: pointer;
  list-style: none;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 16px 20px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  transition: all 0.2s ease;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.data-sources summary::-webkit-details-marker {
  display: none;
}

.data-sources summary:hover {
  border-color: var(--blue);
  background: rgba(255, 255, 255, 0.05);
}

.data-sources[open] summary {
  border-radius: 16px 16px 0 0;
  margin-bottom: 0;
  border-bottom-color: transparent;
}

.data-sources .panel {
  border-top: none;
  border-radius: 0;
  box-shadow: none;
}

.data-sources .panel:last-of-type {
  border-radius: 0 0 16px 16px;
  border-top: 1px solid var(--panel-border);
}

.tab {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-family: var(--sans);
  font-size: 13px;
  padding: 8px 16px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab:hover {
  border-color: var(--blue);
  color: var(--text);
  background: rgba(56, 189, 248, 0.05);
}

.tab.active {
  background: var(--blue);
  border-color: var(--blue);
  color: #04111c;
  font-weight: 600;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.3);
}

.chart-wrap { position: relative; }

.table-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 14px;
}

.table-head h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.table-count {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-dim);
}

.table-wrap {
  flex-grow: 1;
  height: 300px;
  overflow-y: auto;
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background-color: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

.main-table-wrap {
  height: 400px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13px;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  text-align: left;
  padding: 12px;
  color: var(--text-dim);
  font-weight: 500;
  border-bottom: 1px solid var(--panel-border);
  z-index: 1;
}

tbody td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}

tbody tr {
  transition: background 0.15s ease;
}

tbody tr:hover { background: rgba(255, 255, 255, 0.03); }

.src-link {
  color: var(--text-dim);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.src-link:hover { color: var(--blue-bright); }

.pct-low { color: var(--red); }
.pct-mid { color: var(--amber); }
.pct-high { color: var(--blue-bright); }

.enso-callout {
  background: rgba(251, 191, 36, 0.05);
  border: 1px solid rgba(251, 191, 36, 0.2);
  border-radius: 12px;
  padding: 16px;
  font-size: 13px;
  line-height: 1.6;
  color: var(--text);
  backdrop-filter: blur(4px);
}

.enso-callout .enso-status {
  font-family: var(--mono);
  font-weight: 700;
  color: var(--amber);
  display: block;
  margin-bottom: 6px;
}

.enso-callout a { color: var(--blue); text-decoration: none; }
.enso-callout a:hover { text-decoration: underline; }

.footer {
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.6;
  margin-top: 10px;
}

.footer a { color: var(--blue); text-decoration: none; }
.footer a:hover { text-decoration: underline; }

/* BENTO GRID CSS */
.bento-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 24px;
  align-items: start;
}

.bento-kpis { grid-column: span 12; }
.bento-verdict { grid-column: span 12; }
.bento-main-chart { grid-column: span 8; height: 650px; }
.bento-forecast { grid-column: span 4; height: 650px; }
.bento-enso { grid-column: span 6; }
.bento-rain-val { grid-column: span 6; }
.bento-cwc { grid-column: span 6; }
.bento-data-table { grid-column: span 6; }

.chart-wrap {
  flex-grow: 1;
  position: relative;
  min-height: 0;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

@media (max-width: 1024px) {
  .bento-verdict, .bento-main-chart, .bento-forecast, .bento-enso, .bento-rain-val, .bento-cwc, .bento-data-table {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .bento-main-chart { height: 350px; }
  .bento-forecast { height: auto; }
}

/* Verdict Visuals */
.verdict-visuals {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin: 20px 0;
}

.v-stat {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 12px;
  padding: 16px;
}

.v-label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 12px;
  font-weight: 500;
}

.v-bar-bg {
  position: relative;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 4px;
  margin-bottom: 8px;
}

.v-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--blue);
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.4);
}

.v-warn-bar { background: var(--red); box-shadow: 0 0 8px rgba(248, 113, 113, 0.4); }
.v-safe-bar { background: #4caf50; }

.v-marker {
  position: absolute;
  top: -4px;
  width: 2px;
  height: 16px;
  background: var(--red);
  z-index: 2;
}

.v-marker-safe { background: #4caf50; }

.v-vals {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  font-family: var(--mono);
}

.v-dim { color: var(--text-dim); }
.v-warn-text { color: var(--red); }

.v-trend {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.v-trend-box {
  display: flex;
  flex-direction: column;
  background: rgba(255, 255, 255, 0.05);
  padding: 8px 12px;
  border-radius: 8px;
  font-family: var(--mono);
  font-size: 13px;
}

.v-warn-box {
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: var(--red);
  background: rgba(248, 113, 113, 0.05);
}

.v-arrow {
  color: var(--text-dim);
}

.v-proj {
  font-size: 16px;
  color: var(--blue-bright);
}

@media (max-width: 600px) {
  .page { padding: 12px 8px 32px; }
  .header { flex-direction: column; align-items: flex-start; gap: 8px; margin-bottom: 20px; }
  .header h1 { font-size: 20px; }
  .legend { flex-wrap: wrap; gap: 8px; font-size: 11px; }
  .panel { padding: 14px; border-radius: 12px; }
  .bento-grid { gap: 12px; }
  .kpis { gap: 8px; margin-bottom: 16px; }
  .kpi-card { padding: 12px 14px; }
  .kpi-value { font-size: 20px; }
  .verdict-visuals { grid-template-columns: 1fr; gap: 10px; margin: 12px 0; }
  .verdict-headline { font-size: 15px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { white-space: nowrap; font-size: 12px; padding: 6px 12px; }
}
