:root {
  --bg: #0f1413;
  --panel: #f4f7f2;
  --ink: #17201d;
  --muted: #5b6763;
  --line: #9aa7a0;
  --green: #1d7a4d;
  --red: #b3261e;
  --blue: #1d5f95;
  --amber: #986b13;
  --gold: #d6b25e;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(90deg, rgba(214,178,94,.08) 1px, transparent 1px) 0 0 / 18px 18px,
    linear-gradient(180deg, #121b19 0%, #0f1413 42%, #202723 100%);
  font-family: ui-sans-serif, -apple-system, BlinkMacSystemFont, "PingFang SC", "Heiti SC", sans-serif;
}

.topbar {
  min-height: 136px;
  padding: 28px 36px;
  color: #f3f1e8;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(214,178,94,.42);
}

.eyebrow {
  font-size: 12px;
  color: #d6d0bd;
  letter-spacing: .08em;
}

h1, h2 { margin: 0; letter-spacing: 0; }
h1 { margin-top: 8px; font-size: 36px; font-weight: 760; }
h2 { font-size: 18px; }

button, select {
  height: 36px;
  border: 1px solid #8fa098;
  background: #fff;
  color: var(--ink);
  padding: 0 12px;
  font: inherit;
}

.primary {
  background: var(--gold);
  border-color: var(--gold);
  font-weight: 700;
}

main { padding: 24px; }

.strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}

.kpi, .panel {
  background: var(--panel);
  border: 1px solid rgba(154,167,160,.75);
  border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0,0,0,.16);
}

.kpi { padding: 14px; min-height: 92px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { margin-top: 8px; font-size: 24px; font-weight: 780; }
.kpi .note { margin-top: 4px; color: var(--muted); font-size: 12px; }

.grid {
  display: grid;
  gap: 16px;
  margin-bottom: 16px;
}
.two { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }

.panel { padding: 16px; overflow: hidden; }
.livePanel { margin-bottom: 16px; }
.panelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
}
.panelHead span { color: var(--muted); font-size: 12px; }
.controls { align-items: flex-end; }
.controlSet { display: flex; gap: 8px; flex-wrap: wrap; }
.secondary { background: #e7ece8; }
.subhead {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin: 4px 0 8px;
}
.liveGrid { margin: 0; }
.liveStatus {
  display: grid;
  grid-template-columns: minmax(190px, .8fr) minmax(260px, 1.2fr) minmax(260px, 1.5fr);
  gap: 12px;
  padding: 12px;
  margin-bottom: 12px;
  border: 1px solid #d0d9d3;
  background: #fbfcfa;
}
.liveMetric {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.liveMetric .label { color: var(--muted); font-size: 12px; }
.liveMetric strong { font-size: 20px; }
.liveMetric small { color: var(--muted); line-height: 1.45; }
.liveSources {
  display: flex;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 7px 12px;
  font-size: 12px;
  line-height: 1.4;
}
.sourceState { display: block; }
.newsLink { color: var(--blue); text-decoration: none; white-space: normal; }
.newsLink:hover { text-decoration: underline; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}
th, td {
  border-bottom: 1px solid #ccd5cf;
  padding: 8px 7px;
  text-align: left;
  vertical-align: top;
  white-space: nowrap;
}
th {
  color: #2c3834;
  background: #e7ece8;
  position: sticky;
  top: 0;
  z-index: 1;
}
.wideTable {
  overflow: auto;
  max-height: 520px;
  border: 1px solid #d0d9d3;
}
.compact { max-height: 360px; }
.liveTable { max-height: 330px; }
.modelTableWrap { overflow: auto; }

.pos { color: var(--green); font-weight: 720; }
.neg { color: var(--red); font-weight: 720; }
.act { color: var(--blue); font-weight: 720; }
.warn { color: var(--amber); font-weight: 720; }
.muted { color: var(--muted); }

canvas {
  width: 100%;
  height: 260px;
  border: 1px solid #c8d1cb;
  background: #fff;
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  max-width: 520px;
  padding: 12px 14px;
  background: #101615;
  color: #f5f0df;
  border: 1px solid var(--gold);
  border-radius: 6px;
  box-shadow: 0 18px 40px rgba(0,0,0,.3);
  white-space: pre-wrap;
}

@media (max-width: 980px) {
  .topbar { align-items: flex-start; flex-direction: column; }
  .strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two { grid-template-columns: 1fr; }
  .liveStatus { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 560px) {
  main { padding: 12px; }
  .topbar { padding: 22px 18px; }
  h1 { font-size: 28px; }
  .strip { grid-template-columns: 1fr; }
  .liveStatus { grid-template-columns: 1fr; }
}
