/* ===== DRAMDASH frontend v4 · 设计 token ===== */
:root {
  --bg: #0a0e1a;
  --card: #131826;
  --border: #1f2937;
  --green: #10b981;
  --red: #ef4444;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  font-size: 14px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

.app { max-width: 1200px; margin: 0 auto; padding: 16px 20px 48px; }

/* ===== Top bar ===== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }

.brand-title { font-weight: 700; font-size: 16px; }
.brand-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.status { display: flex; align-items: center; gap: 14px; font-size: 13px; }
.ws-live { display: inline-flex; align-items: center; gap: 6px; color: var(--green); }
.dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green);
  display: inline-block;
  box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5);
}
.dot.stale { background: var(--red); }
.lag { color: var(--muted); }
.clock { color: var(--text); font-variant-numeric: tabular-nums; }

/* ===== Tabs ===== */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 18px;
}
.tab {
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 600;
  padding: 10px 14px;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--green); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Intro row ===== */
.intro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}
.intro-left { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.intro-right { color: var(--muted); font-size: 12px; }

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

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}
.card-label { color: var(--muted); font-size: 12px; margin-bottom: 8px; }
.card-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}
.card-value.neg { color: var(--red); }
.card-value.neutral { color: var(--text); }
.card-sub { color: var(--muted); font-size: 12px; margin-top: 8px; }
.card-sub > div { margin-top: 2px; }
.card-sub span { color: var(--text); }
.card-spark { margin-top: 10px; height: 40px; }
.card-spark svg { display: block; width: 100%; height: 40px; }

/* ===== Short-leg leverage card ===== */
.lev-card {
  background: #0f1420;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.lev-card .lev-title { font-weight: 600; }
.lev-card .lev-mid {
  font-variant-numeric: tabular-nums;
  color: var(--text);
  font-size: 15px;
}
.lev-card .lev-status { font-size: 13px; }
.lev-status.low { color: var(--green); }
.lev-status.high { color: var(--red); }
.lev-status.ok { color: var(--muted); }

/* ===== Simple tabs ===== */
.simple-head { font-weight: 700; font-size: 16px; margin-bottom: 12px; }
.simple-body {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  color: var(--muted);
}
.simple-body pre {
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 12px;
  color: var(--text);
  white-space: pre-wrap;
  word-break: break-word;
}

/* opportunities / matrix tables */
table.dump { width: 100%; border-collapse: collapse; font-size: 13px; }
table.dump th, table.dump td {
  text-align: left;
  padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}
table.dump th { color: var(--muted); font-weight: 600; }
table.dump td { color: var(--text); font-variant-numeric: tabular-nums; }

.alert-item {
  border-bottom: 1px solid var(--border);
  padding: 10px 0;
}
.alert-item:last-child { border-bottom: none; }
.alert-lvl { font-weight: 700; margin-right: 8px; }
.alert-lvl.info { color: var(--muted); }
.alert-lvl.warn { color: #f59e0b; }
.alert-lvl.crit { color: var(--red); }
.alert-time { color: var(--muted); font-size: 12px; }
.alert-body { color: var(--muted); font-size: 13px; margin-top: 2px; }

.err { color: var(--red); }

@media (max-width: 900px) {
  .card-row-5, .card-row-4 { grid-template-columns: repeat(2, 1fr); }
}


.simple-sub {
  color: #8b93a7;
  font-size: 13px;
  margin: -8px 0 18px;
}

.matrix-block {
  margin-bottom: 18px;
}

.matrix-leg-card {
  border: 1px solid #20283a;
  background: #111827;
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 14px;
}

.matrix-leg-title {
  color: #e5e7eb;
  font-weight: 700;
  margin-bottom: 12px;
}

.matrix-leg-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.matrix-leg-grid > div {
  background: #0b1020;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 12px;
}

.matrix-leg-grid span,
.matrix-leg-grid small {
  display: block;
  color: #8b93a7;
  font-size: 12px;
}

.matrix-leg-grid b {
  display: block;
  color: #f9fafb;
  font-size: 18px;
  margin: 6px 0;
}

.matrix-leg-grid em {
  display: block;
  color: #10b981;
  font-style: normal;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 12px;
  border: 1px solid #20283a;
  background: #0f172a;
}

.data-table th,
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #20283a;
  text-align: left;
  white-space: nowrap;
}

.data-table th {
  color: #94a3b8;
  font-size: 12px;
  font-weight: 700;
  background: #111827;
}

.data-table td {
  color: #d1d5db;
  font-size: 13px;
}

.data-table .pos {
  color: #10b981;
}

.data-table .neg {
  color: #ef4444;
}

.table-note {
  color: #8b93a7;
  font-size: 12px;
  margin-top: 10px;
}

@media (max-width: 900px) {
  .matrix-leg-grid { grid-template-columns: 1fr; }
  .data-table { display: block; overflow-x: auto; }
}


.semantic-note {
  color: #8b93a7;
  font-size: 11px;
}


.brand-logo {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 9px;
  box-shadow: 0 0 0 1px rgba(16,185,129,0.28), 0 10px 24px rgba(16,185,129,0.18);
}


.section-title {
  margin: 18px 0 10px;
  color: #d1d5db;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: .04em;
}

.cost-row .card-value.neutral {
  color: #f8fafc;
}


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

.risk-card {
  background: #101827;
  border: 1px solid #1f2937;
  border-radius: 10px;
  padding: 15px 16px;
}

.risk-title {
  color: #f8fafc;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
}

.risk-main {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.risk-main span {
  display: block;
  color: #8b93a7;
  font-size: 12px;
  margin-bottom: 4px;
}

.risk-main b {
  color: #f8fafc;
  font-size: 18px;
  font-weight: 800;
}

.risk-sub {
  color: #8b93a7;
  font-size: 12px;
  margin-top: 10px;
}

.risk-card.risk-ok { border-color: rgba(16,185,129,.35); }
.risk-card.risk-mid { border-color: rgba(245,158,11,.55); }
.risk-card.risk-high { border-color: rgba(239,68,68,.7); }

@media (max-width: 900px) {
  .risk-grid { grid-template-columns: 1fr; }
  .risk-main { grid-template-columns: 1fr; }
}


/* v360 risk cards */
.risk-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 10px;
}
.risk-card {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.72);
  border-radius: 10px;
  padding: 14px 16px;
}
.risk-card.high {
  border-color: rgba(239, 68, 68, 0.45);
}
.risk-title {
  color: #e5e7eb;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 10px;
}
.risk-main {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.risk-main span {
  display: block;
  color: #8b93a7;
  font-size: 12px;
  margin-bottom: 4px;
}
.risk-main b {
  color: #f9fafb;
  font-size: 16px;
}
@media (max-width: 900px) {
  .risk-grid { grid-template-columns: 1fr; }
  .risk-main { grid-template-columns: 1fr; }
}


/* v361 short switch */
.switch-summary {
  margin: 12px 0 16px;
}
.switch-hero {
  border: 1px solid rgba(148, 163, 184, 0.16);
  background: rgba(15, 23, 42, 0.72);
  border-radius: 12px;
  padding: 16px;
  display: grid;
  grid-template-columns: 1.2fr 2fr;
  gap: 16px;
}
.switch-kicker {
  color: #8b93a7;
  font-size: 12px;
  margin-bottom: 6px;
}
.switch-action {
  color: #f9fafb;
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}
.switch-reason {
  color: #a7b0c3;
  font-size: 13px;
}
.switch-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.switch-metrics div {
  background: rgba(2, 6, 23, 0.35);
  border: 1px solid rgba(148, 163, 184, 0.12);
  border-radius: 10px;
  padding: 12px;
}
.switch-metrics span {
  display: block;
  color: #8b93a7;
  font-size: 12px;
  margin-bottom: 6px;
}
.switch-metrics b {
  color: #f9fafb;
  font-size: 18px;
}
.switch-badge {
  display: inline-block;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 12px;
  font-weight: 800;
}
.switch-badge.no_switch {
  color: #fca5a5;
  background: rgba(239, 68, 68, 0.12);
  border: 1px solid rgba(239, 68, 68, 0.3);
}
.switch-badge.observe {
  color: #fcd34d;
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
}
.switch-badge.switch {
  color: #6ee7b7;
  background: rgba(16, 185, 129, 0.12);
  border: 1px solid rgba(16, 185, 129, 0.3);
}
.switch-table th,
.switch-table td {
  white-space: nowrap;
}
@media (max-width: 900px) {
  .switch-hero { grid-template-columns: 1fr; }
  .switch-metrics { grid-template-columns: 1fr 1fr; }
}

