/* ---- reset + tokens ---- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:       #0f0f0f;
  --surface:  #1a1a1a;
  --panel:    #161616;
  --border:   #2a2a2a;
  --accent:   #7c3aed;
  --accent-fill: rgba(124,58,237,.15);
  --green:    #22c55e;
  --green-fill: rgba(34,197,94,.12);
  --yellow:   #e0a82e;
  --yellow-fill: rgba(224,168,46,.12);
  --red:      #ff4d4d;
  --red-fill: rgba(255,77,77,.12);
  --text:     #ededed;
  --dim:      #7a7a7a;
  --radius:   8px;
  --pad:      20px;
  --font:     -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --mono:     "SF Mono", "Fira Code", "Menlo", monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

.hidden { display: none !important; }
.dim { color: var(--dim); font-size: 12px; }

/* ---- overlay / modal ---- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  width: 420px;
  max-width: calc(100vw - 40px);
  display: flex; flex-direction: column; gap: 18px;
}

.modal h2 { font-size: 18px; font-weight: 700; }
.modal-sub { color: var(--dim); font-size: 12px; line-height: 1.6; }

.modal label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 12px; font-weight: 600; color: var(--dim);
  text-transform: uppercase; letter-spacing: .05em;
}

.modal input {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--mono);
  font-size: 13px;
  padding: 9px 12px;
  outline: none;
  transition: border-color .12s;
}
.modal input:focus { border-color: var(--accent); }

.modal-actions { display: flex; justify-content: flex-end; }

/* ---- buttons ---- */
.btn-primary {
  background: var(--accent-fill);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  color: var(--accent);
  cursor: pointer;
  font-family: var(--font);
  font-size: 13px; font-weight: 700;
  padding: 8px 20px;
  transition: background .12s, color .12s;
}
.btn-primary:hover { background: var(--accent); color: #fff; }

.btn-ghost {
  background: none;
  border: none;
  border-radius: var(--radius);
  color: var(--dim);
  cursor: pointer;
  font-size: 16px;
  padding: 6px 8px;
  transition: color .12s, background .12s;
}
.btn-ghost:hover { color: var(--text); background: var(--surface); }

/* ---- header ---- */
header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px var(--pad);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0;
  background: var(--bg);
  z-index: 10;
}

.header-left { display: flex; align-items: center; gap: 14px; }
.header-right { display: flex; align-items: center; gap: 6px; }
.logo { font-size: 15px; font-weight: 700; }

/* ---- main ---- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--pad);
  display: flex; flex-direction: column; gap: 16px;
}

/* ---- error banner ---- */
.error-banner {
  background: var(--red-fill);
  border: 1px solid var(--red);
  border-radius: var(--radius);
  color: var(--red);
  font-size: 13px;
  padding: 10px 14px;
}

/* ---- cards ---- */
.card-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex; flex-direction: column; gap: 8px;
}

.card.accent-green { border-color: rgba(34,197,94,.3); background: var(--green-fill); }
.card.accent-yellow { border-color: rgba(224,168,46,.3); background: var(--yellow-fill); }
.card.accent-red { border-color: rgba(255,77,77,.3); background: var(--red-fill); }

.card-label { color: var(--dim); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; }
.card-value { font-size: 26px; font-weight: 700; letter-spacing: -.02em; font-family: var(--mono); }

.card.accent-green .card-value { color: var(--green); }
.card.accent-yellow .card-value { color: var(--yellow); }
.card.accent-red .card-value { color: var(--red); }

/* ---- lower row ---- */
.lower-row {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 12px;
}

/* ---- panels ---- */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: flex; flex-direction: column;
}

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 13px; font-weight: 600;
}

/* ---- chart ---- */
.chart-wrap {
  padding: 16px;
  flex: 1;
  position: relative;
  min-height: 220px;
}

.range-btns { display: flex; gap: 4px; }
.range-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--dim);
  cursor: pointer;
  font-family: var(--font);
  font-size: 11px; font-weight: 600;
  padding: 3px 9px;
  transition: all .12s;
}
.range-btn:hover { border-color: var(--accent); color: var(--accent); }
.range-btn.active { background: var(--accent-fill); border-color: var(--accent); color: var(--accent); }

/* ---- mode table ---- */
.mode-panel { overflow: hidden; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  padding: 10px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--dim);
  text-transform: uppercase;
  letter-spacing: .05em;
}

thead th.num { text-align: right; }

tbody tr {
  border-top: 1px solid var(--border);
  transition: background .1s;
}
tbody tr:hover { background: rgba(255,255,255,.03); }

tbody td {
  padding: 10px 16px;
  color: var(--text);
}
tbody td.num { text-align: right; font-family: var(--mono); font-size: 12px; color: var(--dim); }
tbody td.mode-name { font-weight: 500; }
tbody td.empty { color: var(--dim); font-style: italic; text-align: center; padding: 24px; }

/* ---- responsive ---- */
@media (max-width: 900px) {
  .lower-row { grid-template-columns: 1fr; }
  .card-row { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 520px) {
  .card-row { grid-template-columns: 1fr 1fr; }
  .card-value { font-size: 20px; }
}
