:root {
  --bg: #0a0d10;
  --bg2: #0e1217;
  --bg3: #151b22;
  --ink: #cdd6df;
  --muted: #7e8a96;
  --faint: #4f5a65;
  --line: #1e262e;
  --line2: #2a343e;
  --green: #5fe08c;
  --amber: #e3b64d;
  --red: #f0615b;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo,
    Consolas, "Liberation Mono", monospace;
  --sans: ui-monospace, "SF Mono", "JetBrains Mono", "Fira Code", Menlo,
    Consolas, "Liberation Mono", monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
}

button, select, input { font: inherit; color: inherit; }
::selection { background: rgba(95, 224, 140, 0.22); }
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--line2); border-radius: 5px; }

.term {
  min-height: 100dvh;
  max-width: 1480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.term-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--bg2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  user-select: none;
}
.term-dots { display: flex; gap: 6px; flex: none; }
.term-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line2); }
.term-dots i:nth-child(1) { background: var(--red); opacity: 0.8; }
.term-dots i:nth-child(2) { background: var(--amber); opacity: 0.8; }
.term-dots i:nth-child(3) { background: var(--green); opacity: 0.8; }
.term-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-title b { color: var(--green); font-weight: 500; }
.term-right { flex: none; font-size: 10px; color: var(--faint); white-space: nowrap; }

.term-status {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 30px;
  padding: 5px 18px;
  border-top: 1px solid var(--line);
  background: var(--bg2);
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  overflow: hidden;
  white-space: nowrap;
}
.term-status::before { content: "❯"; flex: none; color: var(--green); }
.status { font-family: var(--mono); font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status.is-loading { color: var(--amber); }
.status.is-err { color: var(--red); }

.app {
  flex: 1;
  min-height: 0;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
}
.eyebrow {
  margin: 0 0 4px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--faint);
}
.eyebrow::before { content: "# "; color: var(--green); }
h1 {
  margin: 0;
  font-family: var(--mono);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
h1::before { content: "❯ "; color: var(--green); }
.head-right { display: flex; align-items: center; gap: 14px; }
.home-link {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 5px 12px;
  text-decoration: none;
  white-space: nowrap;
}
.home-link:hover { color: var(--green); border-color: var(--green); }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 10px 20px;
  padding: 0 2px 10px;
  border-bottom: 1px solid var(--line);
}
.control-group { display: flex; flex-direction: column; gap: 5px; }
.control-group.grow { flex: 1; min-width: 220px; }
.control-group label {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--faint);
}
.control-group label::before { content: "$ "; color: var(--green); }

.interval-select {
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 7px 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.interval-select:focus { border-color: var(--green); box-shadow: 0 0 0 1px rgba(95, 224, 140, 0.18); }

.seg { display: flex; gap: 2px; }
.seg button {
  background: transparent;
  border: 0;
  border-bottom: 1px solid transparent;
  padding: 8px 11px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
}
.seg button:hover { color: var(--ink); }
.seg button.active { color: var(--green); border-bottom-color: var(--green); }
.seg button:focus-visible { outline: 1px solid var(--green); outline-offset: 2px; }

.toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 8px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
}
.toggle:hover { color: var(--ink); }
.toggle input { width: 14px; height: 14px; margin: 0; accent-color: var(--green); }

.status-btn {
  font-family: var(--mono);
  font-size: 12px;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: var(--bg2);
  cursor: pointer;
  color: var(--muted);
  white-space: nowrap;
}
.status-btn:hover { color: var(--green); border-color: var(--green); }
.status-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* mode tabs */
.tabs {
  display: flex;
  gap: 2px;
  padding: 0 2px 2px;
}
.tab {
  background: transparent;
  border: 1px solid transparent;
  border-bottom: none;
  padding: 7px 14px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--muted);
  cursor: pointer;
  border-radius: 3px 3px 0 0;
}
.tab:hover { color: var(--ink); background: var(--bg2); }
.tab.is-active {
  color: var(--green);
  background: var(--bg2);
  border-color: var(--line);
}
.tab:focus-visible { outline: 1px solid var(--green); outline-offset: 1px; }

/* liquidation list (terminal output lines) */
.liq-panel {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--bg2);
  padding: 10px 12px 8px;
}
.liq-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.liq-row {
  font-family: var(--mono);
  font-size: 11.5px;
  padding: 6px 8px;
  border-left: 2px solid var(--line2);
  background: var(--bg);
  line-height: 1.55;
}
.liq-row.is-long { border-left-color: var(--red); }
.liq-row.is-short { border-left-color: var(--green); }
.liq-row b { font-weight: 600; }
.liq-row.is-long b { color: var(--red); }
.liq-row.is-short b { color: var(--green); }
.liq-row span { color: var(--faint); font-size: 10px; display: block; }
.liq-empty { color: var(--faint); font-size: 12px; grid-column: 1 / -1; padding: 6px 0; }

/* picker */
.picker { position: relative; }
.picker-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 13px;
  color: var(--ink);
  outline: none;
}
.picker-input::placeholder { color: var(--faint); }
.picker-input:focus { border-color: var(--green); box-shadow: 0 0 0 1px rgba(95, 224, 140, 0.18); }
.picker-list {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  max-height: 300px;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--line2);
  border-radius: 3px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  z-index: 50;
}
.picker-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 7px 12px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.picker-item:hover, .picker-item:focus-visible, .picker-item.is-selected { background: var(--bg3); outline: none; }
.picker-item-name { flex: 1; }
.picker-item-price { font-size: 11px; color: var(--muted); }
.picker-empty { padding: 14px 12px; font-family: var(--mono); font-size: 12px; color: var(--faint); }

/* stats */
.stats {
  display: grid;
  grid-template-columns: 1.4fr repeat(4, 1fr);
  border-bottom: 1px solid var(--line);
}
.stat { display: flex; flex-direction: column; gap: 3px; padding: 12px 16px 10px 0; }
.stat + .stat { border-left: 1px solid var(--line); padding-left: 16px; }
.stat-label { font-family: var(--mono); font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--faint); }
.stat-value {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 500;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
}
.stat-hero .stat-value { font-size: 36px; font-weight: 500; letter-spacing: -0.02em; }
.stat-value.is-pos { color: var(--green); }
.stat-value.is-neg { color: var(--red); }
.stat-value.is-neutral { color: var(--ink); }
.stat-desc { font-family: var(--mono); font-size: 9px; color: var(--faint); }

/* main chart */
.main-wrap { flex: 1; min-height: 340px; display: flex; flex-direction: column; }
.chart-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 4px;
}
.chart-title { font-family: var(--mono); font-size: 11px; color: var(--muted); }
.chart-title::before { content: "▸ "; color: var(--green); }
.chart-note { font-family: var(--mono); font-size: 10px; color: var(--faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chart { width: 100%; }
.main-chart { flex: 1; min-height: 320px; }
.sub-chart { height: 150px; }

.sub-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}
.sub-card {
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px 12px;
  background: var(--bg2);
}

.footnote {
  margin: 0;
  font-size: 10.5px;
  color: var(--faint);
  line-height: 1.7;
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(3, 1fr); }
  .stat:nth-child(4) { border-left: 0; padding-left: 0; }
  .sub-grid { grid-template-columns: 1fr; }
  .liq-list { grid-template-columns: 1fr; }
  .term-right { display: none; }
}

@media (max-width: 760px) {
  .app { padding: 14px; }
  .stats { grid-template-columns: 1fr 1fr; }
  .stat:nth-child(odd) { border-left: 0; padding-left: 0; }
  .stat-hero .stat-value { font-size: 30px; }
  .picker-list { position: fixed; left: 14px; right: 14px; top: 120px; }
}
