/*
  Shared dark-terminal theme for all monitor dashboards.  (v2 2026-08-01)
  Copy verbatim into every project's public/ folder; link with:
    <link rel="stylesheet" href="/theme.css" />
  Do not fork per-project — edit here, then redistribute the copy.
*/

:root {
  color-scheme: dark;

  /* surfaces */
  --page:    #0d0d0d;
  --surface: #15181c;
  --surface-2: #1a1e23;
  --line:    #262b31;
  --line-strong: #383e46;

  /* ink */
  --text:    #ffffff;
  --text-2:  #c3c2b7;
  --muted:   #83898f;

  /* categorical (dark steps, fixed order — never reassign per row) */
  --c-blue:    #3987e5;
  --c-aqua:    #199e70;
  --c-yellow:  #c98500;
  --c-green:   #1f9d1f;
  --c-violet:  #9085e9;
  --c-red:     #e66767;
  --c-magenta: #d55181;
  --c-orange:  #d95926;

  /* status (fixed, reserved meaning) */
  --good:     #0ca30c;
  --warning:  #fab219;
  --serious:  #ec835a;
  --critical: #d03b3b;

  /* semantic aliases used across pages */
  --accent:  var(--c-blue);
  --positive: var(--good);
  --negative: var(--critical);

  --radius: 10px;
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  --mono: "SF Mono", ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  background: var(--page);
}

body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: var(--sans);
  font-size: 13px;
  letter-spacing: 0;
}

/* ---------- shell / header ---------- */

header {
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

.shell {
  width: min(1440px, calc(100vw - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 60px;
}

h1 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: var(--text);
}

.status {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  white-space: nowrap;
}

.nav, .status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

main {
  padding: 16px 0 28px;
}

/* ---------- toolbar / inputs ---------- */

.toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 12px;
}

input, select, button {
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 8px;
  font: inherit;
  font-family: var(--sans);
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

input { padding: 0 11px; }
select, button { padding: 0 10px; }

input:focus, select:focus, button:focus {
  outline: none;
  border-color: var(--accent);
}

button { cursor: pointer; font-weight: 600; color: var(--text-2); }
button:hover { color: var(--text); border-color: var(--line-strong); }

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #051325;
}
button.primary:hover { filter: brightness(1.08); color: #051325; }

.sort-button, .sort {
  height: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 620;
  cursor: pointer;
}
.sort-button:hover, .sort:hover { color: var(--text); border: 0; }
.sort-button.active, .sort.active { color: var(--accent); }

.chip, .link {
  border: 1px solid var(--line);
  border-radius: 8px;
  transition: border-color 0.15s ease, color 0.15s ease;
  padding: 7px 10px;
  color: var(--muted);
  background: var(--surface-2);
  font-size: 12px;
  font-family: var(--mono);
  text-decoration: none;
  white-space: nowrap;
}
.link:hover { color: var(--text); border-color: var(--line-strong); }

/* ---------- stat tiles ---------- */

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.metric {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
}

.metric span, .metric .label {
  display: block;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}

.metric strong, .metric .value {
  display: block;
  margin-top: 6px;
  font-size: 20px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

.metric .hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

/* ---------- table ---------- */

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  max-height: calc(100vh - 230px);
  scrollbar-color: var(--line-strong) transparent;
}

.table-wrap::-webkit-scrollbar { width: 10px; height: 10px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 99px; }
.table-wrap::-webkit-scrollbar-track { background: transparent; }

table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

th, td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  text-align: right;
  white-space: nowrap;
}

th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 620;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

th:first-child, td:first-child,
th:nth-child(2), td:nth-child(2),
th:nth-child(3), td:nth-child(3) {
  text-align: left;
}

tr:hover td { background: var(--surface-2); }
tr:last-child td { border-bottom: 0; }

/* ---------- semantics: value coloring ---------- */

.positive { color: var(--positive); }
.negative { color: var(--negative); }
.neutral  { color: var(--warning); }
.muted    { color: var(--muted); }
.error    { color: var(--critical); }

/* ---------- identity chips ---------- */

.ticker-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}

.cn-name {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.new-badge {
  display: inline-flex;
  align-items: center;
  border: 1px solid rgba(250, 178, 25, 0.4);
  border-radius: 4px;
  background: rgba(250, 178, 25, 0.12);
  color: var(--warning);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 3px 5px;
  font-family: var(--mono);
}

/* score / tier pills — status-scale ladder (good -> critical), not categorical */

.score-pill, .tier-pill {
  display: inline-flex;
  min-width: 46px;
  justify-content: center;
  border-radius: 4px;
  padding: 3px 7px;
  font-weight: 700;
  font-size: 11px;
  font-family: var(--mono);
  background: var(--surface-2);
  color: var(--text-2);
  border: 1px solid var(--line);
}

.score-a, .tier-core   { background: rgba(12, 163, 12, 0.14);  color: #4ade80; border-color: rgba(12, 163, 12, 0.35); }
.score-b, .tier-open   { background: rgba(57, 135, 229, 0.14); color: #7db4f0; border-color: rgba(57, 135, 229, 0.35); }
.score-c, .tier-tactical { background: rgba(250, 178, 25, 0.14); color: #f2b84b; border-color: rgba(250, 178, 25, 0.35); }
.score-d, .tier-watch  { background: rgba(131, 137, 143, 0.14); color: var(--muted); border-color: var(--line); }

.hidden { display: none; }

/* ---------- hero / premium panels (skhynix-style pages) ---------- */

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 1.15fr) minmax(260px, 0.85fr);
  gap: 10px;
  margin-bottom: 12px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}

.premium-panel {
  padding: 20px;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.venue-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.premium-value {
  font-size: 46px;
  line-height: 1;
  font-weight: 700;
  margin: 12px 0 10px;
  font-variant-numeric: tabular-nums;
}
.venue-grid .premium-value { font-size: 36px; }

.formula {
  padding: 20px;
  display: grid;
  gap: 14px;
}

.formula strong {
  display: block;
  font-size: 15px;
  margin-bottom: 4px;
  color: var(--text);
}

code {
  display: block;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text-2);
  font-family: var(--mono);
  font-size: 12px;
  white-space: normal;
  line-height: 1.5;
}

.section {
  margin-top: 10px;
  padding: 16px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.section h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 620;
  color: var(--text);
}

.section-head h2 {
  display: flex;
  align-items: center;
  gap: 9px;
}

.section-head h2::before {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent);
  flex: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 11px;
}

.manual-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  align-items: end;
}

.manual-output {
  display: grid;
  gap: 4px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  min-height: 76px;
}
.manual-output b { font-size: 18px; }

.right { text-align: right; }

/* ---------- responsive ---------- */

@media (max-width: 880px) {
  .shell { width: min(100vw - 20px, 1440px); }
  .topbar, .toolbar { grid-template-columns: 1fr; display: grid; }
  header .topbar { align-items: flex-start; flex-direction: column; gap: 8px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .manual-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero { grid-template-columns: 1fr; }
  .venue-grid { grid-template-columns: 1fr; }
  .premium-value { font-size: 36px; }
  .status { white-space: normal; }
}

@media (max-width: 560px) {
  .metrics, .manual-grid { grid-template-columns: 1fr; }
  th, td { padding: 7px 6px; }
  h1 { font-size: 15px; }
}
