/* ============================================================
   AI Metrics Console — styles.css
   Dark "console" theme. No dependencies.
   ============================================================ */

* {
  box-sizing: border-box;
}

:root {
  --bg: #0a0e16;
  --bg2: #0d1420;
  --panel: #101827;
  --panel2: #0b1220;
  --border: #1c2a42;
  --border2: #2a3c5e;
  --text: #dbe4f3;
  --muted: #8ba0bf;
  --dim: #5a6b87;
  --accent: #22d3ee;
  --accent2: #a78bfa;
  --green: #34d399;
  --amber: #fbbf24;
  --red: #f87171;
  --blue: #60a5fa;
  --mono: ui-monospace, "SF Mono", "JetBrains Mono", Menlo, Consolas, monospace;
  --sans: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(1100px 700px at 85% -10%, rgba(34, 60, 100, 0.35) 0%, rgba(10, 14, 22, 0) 60%),
    radial-gradient(900px 600px at -10% 110%, rgba(52, 80, 130, 0.22) 0%, rgba(10, 14, 22, 0) 55%),
    var(--bg);
  font: 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}
::-webkit-scrollbar-thumb {
  background: #1d2a41;
  border-radius: 6px;
  border: 2px solid var(--bg);
}
::-webkit-scrollbar-track {
  background: transparent;
}

.hidden,
[hidden] {
  display: none !important;
}

#app {
  display: grid;
  grid-template-columns: 240px 1fr;
  height: 100vh;
}

/* ---------------- Sidebar ---------------- */

#sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: rgba(10, 15, 25, 0.72);
  backdrop-filter: blur(6px);
  min-height: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 12px;
  color: inherit;
  text-decoration: none;
}
.brand:hover .brand-name {
  color: var(--accent);
}
.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  border-radius: 10px;
}

.brand-logo {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  color: #06121c;
  font-size: 15px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.35);
}

.brand-name {
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
}
.brand-sub {
  font-size: 10.5px;
  color: var(--dim);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 6px;
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
}

#src-list {
  flex: 1;
  overflow-y: auto;
  padding: 2px 8px 8px;
  min-height: 60px;
}

.src {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 9px 10px;
  margin-bottom: 4px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s;
}

.src:hover {
  background: rgba(255, 255, 255, 0.03);
}

.src.active {
  background: rgba(34, 211, 238, 0.09);
  border-color: rgba(34, 211, 238, 0.28);
}

.src-top {
  display: flex;
  align-items: center;
  gap: 8px;
}
.src-name {
  flex: 1;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.src-url {
  font: 10.5px var(--mono);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-left: 16px;
}
.src-actions {
  margin-left: auto;
  display: none;
  gap: 4px;
}
.src:hover .src-actions {
  display: inline-flex;
}

.icon-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--dim);
  border-radius: 6px;
  width: 22px;
  height: 22px;
  font-size: 11px;
  line-height: 1;
  cursor: pointer;
}
.icon-btn:hover {
  color: var(--text);
  border-color: var(--border2);
}
.icon-btn.danger {
  color: var(--red);
  border-color: rgba(248, 113, 113, 0.5);
}
.icon-btn.danger.confirm {
  background: var(--red);
  color: #1a0505;
  font-weight: 700;
}

.side-foot {
  display: flex;
  gap: 6px;
  padding: 10px 12px 14px;
  border-top: 1px solid var(--border);
}

/* ---------------- Buttons ---------------- */

.btn {
  font: 600 12.5px var(--sans);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border2);
  border-radius: 9px;
  padding: 8px 14px;
  cursor: pointer;
  transition:
    filter 0.15s,
    background 0.15s;
}
.btn:hover {
  filter: brightness(1.15);
}
.btn-accent {
  background: linear-gradient(135deg, var(--accent), #38bdf8);
  border-color: transparent;
  color: #06121c;
}
.btn-ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--muted);
}
.btn-ghost:hover {
  color: var(--text);
}
.btn-sm {
  padding: 5px 10px;
  font-size: 11.5px;
  border-radius: 7px;
}
.btn-danger {
  background: rgba(248, 113, 113, 0.12);
  border-color: rgba(248, 113, 113, 0.5);
  color: var(--red);
}

/* ---------------- Main / Topbar ---------------- */

#main {
  overflow-y: auto;
  min-width: 0;
  padding-bottom: 40px;
}

#topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 7px 16px;
  background: rgba(10, 14, 22, 0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
}

#tb-name {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
#tb-sub {
  font: 11.5px var(--mono);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tb-right {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--dim);
  flex-shrink: 0;
}
.dot.ok {
  background: var(--green);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.7);
}
.dot.err {
  background: var(--red);
  box-shadow: 0 0 8px rgba(248, 113, 113, 0.7);
}
.dot.wait {
  background: var(--amber);
  animation: pulse 1s infinite;
}
.dot.idle {
  background: var(--dim);
}

@keyframes pulse {
  50% {
    opacity: 0.35;
  }
}

#lang-select {
  background: var(--panel2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 7px;
  padding: 4px 6px;
  font: 11.5px var(--mono);
  outline: none;
  cursor: pointer;
}
#lang-select:focus {
  border-color: var(--accent);
}
#lang-select option {
  background: var(--bg2);
  color: var(--text);
}

#banner {
  display: flex;
  align-items: center;
  gap: 14px;
  margin: 16px 20px 0;
  padding: 12px 16px;
  border: 1px solid rgba(248, 113, 113, 0.4);
  background: rgba(248, 113, 113, 0.07);
  border-radius: 12px;
  color: #fda4a4;
  font-size: 13px;
}
#banner-msg {
  flex: 1;
}
#banner code {
  font-family: var(--mono);
  font-size: 11.5px;
}

#loading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 40px 20px;
  color: var(--muted);
  font-size: 13px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------- Empty state ---------------- */

#empty-state {
  display: grid;
  place-items: center;
  min-height: 70vh;
}
.empty-hero {
  text-align: center;
  max-width: 520px;
  padding: 24px;
}
.empty-logo {
  width: 64px;
  height: 64px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-size: 26px;
  color: #06121c;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 40px rgba(34, 211, 238, 0.3);
}
.empty-hero h1 {
  margin: 0 0 8px;
  font-size: 22px;
}
.empty-hero p {
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.6;
}
.empty-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 22px;
}

/* ---------------- KPI cards ---------------- */

#kpis {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(215px, 1fr));
  gap: 12px;
  margin: 18px 20px 0;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 9px;
}

.kpi-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 45%), var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 9px 12px 8px;
  min-width: 0;
}

.kpi-label {
  font-size: 10px;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-value {
  margin-top: 3px;
  font: 700 18px/1.1 var(--mono);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.kpi-sub {
  font: 9.5px var(--mono);
  color: var(--dim);
  margin-top: 2px;
  height: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi-spark {
  display: block;
  width: 100%;
  height: 28px;
  margin-top: 3px;
}

/* ---------------- Gauges ---------------- */

#gauges,
.gauges {
  display: grid;
  grid-template-columns: repeat(auto-fill, 104px);
  justify-content: start;
  gap: 10px;
}

.gauge {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 6px 6px;
  text-align: center;
}

.g-plot {
  position: relative;
  width: 100%;
  max-width: 88px;
  margin: 0 auto;
}
.g-plot svg {
  display: block;
  width: 100%;
  height: auto;
}

.g-track {
  fill: none;
  stroke: var(--border2);
  stroke-width: 8;
  stroke-linecap: round;
  opacity: 0.55;
}
.g-arc {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  transition:
    stroke-dasharray 0.5s ease,
    stroke 0.3s;
}

.g-center {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}
.g-val {
  font: 700 13px var(--mono);
}

.g-label {
  margin-top: 4px;
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.g-sub {
  font: 9px var(--mono);
  color: var(--dim);
  margin-top: 1px;
  min-height: 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- Panels ---------------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  margin: 10px 0 0;
  padding: 12px 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.panel-head h2 {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.11em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-head .dim {
  font-size: 11.5px;
}

/* Live panel */

#live-body .live-top {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
#live-body .live-phase {
  font: 12.5px var(--mono);
  color: var(--muted);
}

.bar {
  position: relative;
  height: 16px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 0;
}
.bar-fill {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  background: linear-gradient(90deg, rgba(34, 211, 238, 0.85), rgba(167, 139, 250, 0.85));
  border-radius: 8px 0 0 8px;
  transition: width 0.6s ease;
}
.bar-label {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font: 10.5px var(--mono);
  color: var(--text);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
  white-space: nowrap;
}

.live-bars {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 10px;
}
@media (max-width: 720px) {
  .live-bars {
    grid-template-columns: 1fr;
  }
}

.live-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 8px;
}
.lchip {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 4px 9px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 7px;
  font-size: 9.5px;
  color: var(--muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lchip b {
  font: 600 11.5px var(--mono);
  color: var(--text);
}

.live-slots {
  margin-top: 2px;
}
.live-slots summary {
  cursor: pointer;
  font: 10.5px var(--mono);
  color: var(--muted);
  user-select: none;
}
.live-slots[open] summary {
  margin-bottom: 6px;
}
.live-slots .table-scroll {
  max-height: 180px;
  overflow-y: auto;
}

/* Chips (chart tabs) */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.chip {
  font: 11px var(--mono);
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 3px 10px;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.chip:hover {
  color: var(--text);
  border-color: var(--accent);
}
.chip.on {
  color: var(--accent);
  border-color: var(--accent);
  background: rgba(34, 211, 238, 0.09);
}

#chart-wrap {
  position: relative;
  height: 300px;
}
#big-chart {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* Histograms */

.hist-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 12px;
}
.hist-card {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 14px;
}
.hist-title {
  font: 600 12.5px var(--mono);
  margin-bottom: 8px;
}
.hist-meta {
  font: 11px var(--mono);
  color: var(--dim);
  margin-bottom: 8px;
}
.hist-q {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.qchip {
  font: 600 11px var(--mono);
  padding: 3px 9px;
  border-radius: 7px;
  border: 1px solid var(--border2);
  background: rgba(96, 165, 250, 0.08);
  color: var(--blue);
  cursor: pointer;
}
.qchip:hover {
  border-color: var(--blue);
}

.hbucket {
  display: grid;
  grid-template-columns: 74px 1fr 64px;
  gap: 8px;
  align-items: center;
  font: 10.5px var(--mono);
  color: var(--dim);
  padding: 1.5px 0;
}
.hbucket .hbar {
  height: 7px;
  background: var(--panel);
  border-radius: 4px;
  overflow: hidden;
}
.hbucket .hbar div {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  border-radius: 4px;
}
.hbucket .hcount {
  text-align: right;
  color: var(--muted);
}

/* Tables */

.table-scroll {
  overflow-x: auto;
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.tbl th {
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 6px 10px;
  border-bottom: 1px solid var(--border2);
  white-space: nowrap;
}
.tbl td {
  padding: 7px 10px;
  border-top: 1px solid var(--border);
  white-space: nowrap;
}
.tbl tbody tr:hover {
  background: rgba(255, 255, 255, 0.025);
}
.tbl .num {
  font-family: var(--mono);
  text-align: right;
}
.tbl .mono {
  font-family: var(--mono);
  font-size: 11.5px;
}
.tbl .dim {
  color: var(--dim);
}

.badge {
  display: inline-block;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  padding: 1.5px 7px;
  border-radius: 999px;
  border: 1px solid var(--border2);
  color: var(--muted);
}
.badge.counter {
  color: var(--blue);
  border-color: rgba(96, 165, 250, 0.5);
  background: rgba(96, 165, 250, 0.07);
}
.badge.gauge {
  color: var(--green);
  border-color: rgba(52, 211, 153, 0.5);
  background: rgba(52, 211, 153, 0.07);
}
.badge.histogram {
  color: var(--amber);
  border-color: rgba(251, 191, 36, 0.5);
  background: rgba(251, 191, 36, 0.07);
}
.badge.derived {
  color: var(--accent);
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(34, 211, 238, 0.06);
  border-style: dashed;
}

.finish-stop {
  color: var(--green);
}
.finish-len {
  color: var(--amber);
}
.finish-err {
  color: var(--red);
}

#metric-search {
  background: var(--panel2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 8px;
  padding: 6px 10px;
  font: 12px var(--mono);
  width: 220px;
  outline: none;
}
#metric-search:focus {
  border-color: var(--accent);
}

/* ---------------- Modals ---------------- */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 14, 0.72);
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal {
  width: min(500px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  background: var(--bg2);
  border: 1px solid var(--border2);
  border-radius: 16px;
  padding: 22px 24px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}
.modal-wide {
  width: min(760px, 94vw);
}
.modal h3 {
  margin: 0 0 16px;
  font-size: 16px;
}
.modal h4 {
  margin: 18px 0 6px;
  font-size: 13px;
  color: var(--accent);
}

.modal label > span {
  display: block;
}
.modal label {
  display: block;
  font-size: 11px;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 12px;
}
.modal input {
  display: block;
  width: 100%;
  margin-top: 5px;
  background: var(--panel2);
  border: 1px solid var(--border2);
  color: var(--text);
  border-radius: 9px;
  padding: 10px 12px;
  font: 13px var(--mono);
  outline: none;
}
.modal input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.12);
}

.modal-err {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.4);
  color: #fda4a4;
  font-size: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 18px;
}

.field-hint {
  display: flex;
  gap: 4px 10px;
  align-items: baseline;
  flex-wrap: wrap;
  margin: -4px 0 12px;
  font-size: 12px;
  color: var(--dim);
  line-height: 1.5;
}
.field-hint code {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
}
.linklike {
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  font-size: 12px;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.linklike:hover {
  color: var(--text);
}
.linklike:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.help-body {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.65;
}
.help-body b {
  color: var(--text);
}
.help-body code {
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--accent);
  background: rgba(34, 211, 238, 0.07);
  padding: 1px 5px;
  border-radius: 5px;
}
.help-body pre {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  overflow-x: auto;
  margin: 10px 0;
}
.help-body pre code {
  background: none;
  padding: 0;
  color: #c9e3ff;
  font-size: 12px;
  line-height: 1.55;
}
.help-body ul {
  padding-left: 18px;
  margin: 6px 0;
}
.help-body li {
  margin: 4px 0;
}

/* ---------------- Toasts ---------------- */

#toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: #0e1a2c;
  border: 1px solid var(--border2);
  border-left: 3px solid var(--accent);
  color: var(--text);
  font-size: 12.5px;
  padding: 10px 14px;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  animation: slidein 0.22s ease;
  max-width: 360px;
}
.toast.err {
  border-left-color: var(--red);
}
.toast.ok {
  border-left-color: var(--green);
}

@keyframes slidein {
  from {
    transform: translateY(8px);
    opacity: 0;
  }
}

/* ---------------- Sections ---------------- */

.section {
  margin: 12px 20px 0;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
}

.sec-no {
  font: 700 11px var(--mono);
  color: var(--accent);
  background: rgba(34, 211, 238, 0.08);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-radius: 6px;
  padding: 2px 7px;
  letter-spacing: 0.08em;
}

.section-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
}

.section-head .dim {
  font-size: 11.5px;
  font-family: var(--mono);
}

/* ---------------- Rate cards (instant + effective) ---------------- */

.rate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(330px, 1fr));
  gap: 10px;
  margin-bottom: 10px;
}

.rate-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0) 40%), var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--rc, var(--accent));
  border-radius: 12px;
  padding: 9px 14px 8px;
  min-width: 0;
}

.rc-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.rc-label {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
}
.rc-badge {
  font: 9.5px var(--mono);
  color: var(--rc, var(--accent));
  border: 1px dashed var(--border2);
  padding: 1px 7px;
  border-radius: 999px;
}

.rc-rows {
  margin-top: 6px;
}
.rc-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.rc-idle {
  font: 9px var(--mono);
  color: var(--dim);
  border: 1px solid var(--border2);
  border-radius: 999px;
  padding: 0 6px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.rc-row .rc-cap {
  font-size: 9.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  width: 78px;
  flex-shrink: 0;
}
.rc-val {
  font: 700 22px/1.1 var(--mono);
  letter-spacing: -0.01em;
  color: var(--rc, var(--accent));
}
.rc-unit {
  font: 600 11px var(--mono);
  color: var(--muted);
}
.rc-row.eff .rc-val {
  font-size: 15px;
  color: var(--text);
}
.rc-sub {
  font: 10px var(--mono);
  color: var(--dim);
  margin-top: 3px;
  min-height: 12px;
}
.rc-spark {
  display: block;
  width: 100%;
  height: 24px;
  margin-top: 3px;
}

/* ---------------- GPU cards (simulated GPU) ---------------- */

/* Per-GPU cards get their own full-width row below the gauge groups, two
   cards side by side (one on narrow windows); tracks cap at 640px so an
   ultrawide window does not stretch the board into a billboard. */
.gpu-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 640px));
  gap: 10px;
  margin-top: 10px;
}
@media (max-width: 760px) {
  .gpu-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

.gpu-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px 8px;
}

.gpu-card svg {
  display: block;
  width: 100%;
  height: auto;
}

.gpu-pcb {
  fill: url(#gpcb-grad);
  stroke: var(--border2);
  stroke-width: 1;
}
.gpu-led {
  transition: fill 0.4s;
}
.gpu-bracket {
  fill: #22304a;
  stroke: var(--border2);
  stroke-width: 0.6;
}
.gpu-finger {
  fill: #c9a54c;
  opacity: 0.85;
}
.gpu-fan-ring {
  fill: #0a101c;
  stroke: var(--border2);
  stroke-width: 2;
}
.gpu-fan-blade {
  fill: none;
  stroke: #3d5578;
  stroke-width: 6;
  stroke-linecap: round;
}
.gpu-fan-hub {
  fill: #16233a;
  stroke: var(--accent);
  stroke-width: 1.5;
}
.gpu-fan-dot {
  fill: var(--accent);
}
.gpu-fan-spin {
  animation: gpu-fan-rot var(--fanspin, 2.5s) linear infinite;
  animation-play-state: var(--fanplay, running);
  transform-origin: 0 0;
}
@keyframes gpu-fan-rot {
  to {
    transform: rotate(360deg);
  }
}

.gpu-die {
  fill: #0a101c;
  stroke: var(--border2);
  stroke-width: 1;
}
.gpu-die-label {
  font: 600 8.5px var(--mono);
  fill: var(--dim);
  letter-spacing: 0.14em;
}
.gpu-util {
  font: 700 26px var(--mono);
  fill: var(--green);
  transition: fill 0.3s;
}
.gpu-chip-box {
  fill: #0d1524;
  stroke: var(--border2);
  stroke-width: 0.8;
  rx: 5;
}
.gpu-chip-label {
  font: 600 7.5px var(--mono);
  fill: var(--dim);
  letter-spacing: 0.12em;
}
.gpu-chip-val {
  font: 700 12px var(--mono);
}
.gpu-vram-label {
  font: 600 8px var(--mono);
  fill: var(--dim);
  letter-spacing: 0.1em;
}
.gpu-vram-bg {
  fill: #0a101c;
  stroke: var(--border2);
  stroke-width: 0.8;
}
.gpu-vram-fill {
  fill: var(--accent);
  transition: width 0.5s;
}
.gpu-vram-text {
  font: 600 9px var(--mono);
  fill: var(--muted);
}

.gpu-name {
  margin-top: 5px;
  font: 10px var(--mono);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* mini stat: same width as a gauge (104px), shares the GPU gauge band */
.mini-stat {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 7px 8px 6px;
  min-width: 0;
}
.ms-val {
  font: 700 13px var(--mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-label {
  margin-top: 2px;
  font-size: 9.5px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-spark {
  display: block;
  width: 100%;
  height: 26px;
  margin-top: 2px;
}

/* Host and GPU groups share one row when it fits (1080p and wider), and
   wrap onto stacked bands on narrow windows; the GPU band sits directly
   above the per-GPU cards it describes. */
.gauge-row {
  display: flex;
  gap: 12px 28px;
  align-items: flex-start;
  flex-wrap: wrap;
}
.gauge-group {
  flex: 0 0 auto;
  min-width: 0;
}
.gauge-group > .gauges {
  grid-auto-flow: column;
  grid-auto-columns: 104px;
  grid-template-columns: none;
}
@media (max-width: 960px) {
  .gauge-group > .gauges {
    grid-auto-flow: row;
    grid-template-columns: repeat(auto-fill, 104px);
  }
}
.gg-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 5px;
}
.gg-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.gg-sub {
  font: 9.5px var(--mono);
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- Responsive ---------------- */

@media (max-width: 960px) {
  #app {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
    height: auto;
    min-height: 100vh;
  }
  #sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
  #src-list {
    display: flex;
    overflow-x: auto;
    padding: 4px 8px;
  }
  .src {
    min-width: 200px;
    border: 1px solid var(--border);
  }
  #topbar {
    position: static;
    flex-wrap: wrap;
  }
}
