:root {
  --bg: #10110f;
  --surface: #171916;
  --surface-2: #20231f;
  --surface-3: #262a25;
  --line: #343a33;
  --line-soft: #272c27;
  --text: #f4f1e8;
  --muted: #aeb3a8;
  --faint: #777f73;
  --good: #86d67d;
  --good-bg: rgba(134, 214, 125, 0.11);
  --warning: #e7bc61;
  --warning-bg: rgba(231, 188, 97, 0.12);
  --bad: #ef8178;
  --bad-bg: rgba(239, 129, 120, 0.12);
  --info: #8db5ff;
  --info-bg: rgba(141, 181, 255, 0.1);
  --accent: #69ceb3;
  --shadow: rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
}

button,
input,
select,
textarea {
  font: inherit;
}

.monitor-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.topbar,
.objective-band,
.panel,
.stat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 16px 40px var(--shadow);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.95fr);
  gap: 24px;
  align-items: start;
  padding: 22px;
}

.title-block,
.panel-head > div,
.objective-band > div {
  min-width: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  color: var(--text);
  line-height: 1.08;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: 38px;
  font-weight: 800;
}

h2 {
  margin-bottom: 0;
  font-size: 20px;
  font-weight: 750;
}

h3 {
  margin: 18px 0 10px;
  font-size: 14px;
  font-weight: 750;
}

.lede,
.muted,
.panel-note,
.empty-state,
.metric-sub,
.stat-sub {
  color: var(--muted);
}

.lede {
  max-width: 760px;
  margin-bottom: 0;
  line-height: 1.55;
}

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

.status-badge,
.pill {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 10px;
}

.status-badge {
  display: grid;
  gap: 4px;
}

.status-badge span,
.pill,
.stat-label,
.metric-label,
.info-row dt,
.version-table th,
.target-item small {
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  line-height: 1.25;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-badge strong,
.pill {
  overflow-wrap: anywhere;
}

.status-badge strong {
  color: var(--text);
  font-size: 14px;
  line-height: 1.25;
}

.status-badge.good {
  border-color: rgba(134, 214, 125, 0.45);
  background: var(--good-bg);
}

.status-badge.warning {
  border-color: rgba(231, 188, 97, 0.55);
  background: var(--warning-bg);
}

.objective-band {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
  gap: 18px;
  align-items: start;
  margin-top: 16px;
  padding: 20px;
  background: var(--surface-2);
}

.objective-band p {
  margin-bottom: 0;
  line-height: 1.55;
}

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

.target-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.target-item span,
.target-item strong,
.target-item small {
  display: block;
  overflow-wrap: anywhere;
}

.target-item span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.target-item strong {
  margin: 8px 0 4px;
  font-size: 22px;
  line-height: 1;
}

.target-item.met {
  border-color: rgba(134, 214, 125, 0.38);
}

.target-item.open {
  border-color: rgba(231, 188, 97, 0.38);
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.stat-card {
  min-width: 0;
  padding: 15px;
  background: var(--surface);
}

.stat-value {
  margin-top: 9px;
  color: var(--text);
  font-size: 26px;
  font-weight: 800;
  line-height: 1;
  overflow-wrap: anywhere;
}

.stat-sub {
  min-height: 32px;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.stat-card.good,
.metric.good {
  border-color: rgba(134, 214, 125, 0.45);
}

.stat-card.warning,
.metric.warning {
  border-color: rgba(231, 188, 97, 0.45);
}

.stat-card.bad,
.metric.bad {
  border-color: rgba(239, 129, 120, 0.45);
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
}

.panel-overview {
  margin-top: 16px;
}

.panel-best {
  grid-column: span 5;
}

.panel-progress {
  grid-column: span 7;
}

.panel-search,
.panel-data {
  grid-column: span 6;
}

.panel-strategies {
  grid-column: span 12;
}

.panel-variants {
  grid-column: span 8;
}

.panel-logs {
  grid-column: span 4;
}

.panel-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
}

.pill {
  flex: 0 0 auto;
  max-width: 230px;
  color: var(--muted);
  text-align: right;
}

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

.metric {
  min-width: 0;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 12px;
}

.metric-value {
  margin-top: 7px;
  color: var(--text);
  font-size: 22px;
  font-weight: 800;
  line-height: 1;
  overflow-wrap: anywhere;
}

.metric-sub {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.objective-checklist {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.check-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) minmax(130px, auto);
  gap: 10px;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 9px;
  color: var(--muted);
  font-size: 13px;
}

.check-row strong {
  color: var(--text);
  text-align: right;
}

.check-mark {
  color: var(--warning);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  text-transform: uppercase;
}

.check-row.met .check-mark {
  color: var(--good);
}

.panel-note {
  margin: 14px 0 0;
  border-top: 1px solid var(--line-soft);
  padding-top: 12px;
  font-size: 13px;
  line-height: 1.5;
}

.history-chart {
  margin-top: 14px;
}

.chart-frame {
  position: relative;
  height: 178px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}

.zero-line {
  position: absolute;
  right: 0;
  bottom: var(--zero-line);
  left: 0;
  z-index: 2;
  border-top: 1px dashed rgba(244, 241, 232, 0.32);
}

.zero-line span {
  position: absolute;
  top: 2px;
  right: 10px;
  color: var(--faint);
  background: var(--surface-2);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.chart-bars {
  position: absolute;
  inset: 16px 14px 22px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(28px, 1fr));
  gap: 8px;
}

.bar-slot {
  position: relative;
  min-width: 0;
  border-bottom: 1px solid rgba(244, 241, 232, 0.08);
}

.bar-slot .bar {
  position: absolute;
  right: 20%;
  bottom: var(--bar-bottom);
  left: 20%;
  height: var(--bar-height);
  min-height: 4px;
  border-radius: 6px 6px 0 0;
  background: var(--info);
}

.bar-slot .bar.good {
  background: var(--good);
}

.bar-slot .bar.bad {
  background: var(--bad);
}

.bar-slot small {
  position: absolute;
  right: 0;
  bottom: -19px;
  left: 0;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
  text-align: center;
}

.history-timeline {
  display: grid;
  gap: 6px;
  margin-top: 12px;
}

.timeline-row {
  display: grid;
  grid-template-columns: minmax(92px, 1fr) 70px 70px 70px 92px;
  gap: 8px;
  align-items: center;
  border-top: 1px solid var(--line-soft);
  padding-top: 7px;
  color: var(--muted);
  font-size: 12px;
}

.timeline-row strong {
  color: var(--text);
}

.info-list {
  display: grid;
  gap: 9px;
}

.info-row {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 9px;
}

.info-row:first-child {
  border-top: 0;
  padding-top: 0;
}

.info-row dt,
.info-row dd {
  margin: 0;
}

.info-row dd {
  color: var(--text);
  font-size: 13px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.candidate-preview {
  margin-top: 12px;
}

.candidate-list {
  display: grid;
  gap: 8px;
}

.candidate-row {
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-2);
  padding: 10px;
}

.candidate-row span {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
}

.candidate-row strong {
  min-width: 0;
  color: var(--text);
  font-size: 13px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.version-table {
  overflow-x: auto;
}

.version-table table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
}

.version-table th,
.version-table td {
  border-bottom: 1px solid var(--line-soft);
  padding: 10px 8px;
  text-align: left;
  vertical-align: top;
}

.version-table td {
  color: var(--text);
  font-size: 13px;
}

.version-table td:nth-child(n+3),
.version-table th:nth-child(n+3) {
  text-align: right;
}

.version-table td strong,
.version-table td span {
  display: block;
}

.version-table td span {
  margin-top: 4px;
  color: var(--muted);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.rank-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 8px;
  background: var(--info-bg);
  color: var(--info);
  font-family: "IBM Plex Mono", monospace;
}

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

.timeframe-card {
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: var(--surface-2);
  padding: 14px;
}

.timeframe-card.good {
  border-color: rgba(134, 214, 125, 0.38);
}

.timeframe-card.warning {
  border-color: rgba(231, 188, 97, 0.38);
}

.timeframe-card.bad {
  border-color: rgba(239, 129, 120, 0.38);
}

.timeframe-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
}

.timeframe-card-head h3 {
  margin: 4px 0 0;
  font-size: 18px;
}

.timeframe-meta {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.timeframe-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.mini-stat {
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--surface-3);
  padding: 10px;
}

.mini-stat strong,
.mini-stat span {
  display: block;
}

.mini-stat strong {
  margin-top: 5px;
  font-size: 18px;
  line-height: 1.1;
}

.timeframe-spark {
  margin-top: 14px;
}

.sparkline {
  width: 100%;
  height: 58px;
  display: block;
}

.sparkline-labels {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 6px;
  color: var(--faint);
  font-family: "IBM Plex Mono", monospace;
  font-size: 10px;
}

.param-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 12px;
}

.param-chip {
  border: 1px solid var(--line-soft);
  border-radius: 999px;
  background: var(--surface-3);
  padding: 5px 9px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
}

.log-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.log-list li {
  border-left: 3px solid var(--line);
  padding-left: 10px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.empty-state {
  margin: 0;
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 14px;
  font-size: 13px;
  line-height: 1.45;
}

.text-good {
  color: var(--good) !important;
}

.text-bad {
  color: var(--bad) !important;
}

.error-panel {
  max-width: 680px;
  margin: 60px auto;
}

@media (max-width: 1120px) {
  .topbar,
  .objective-band {
    grid-template-columns: 1fr;
  }

  .target-grid,
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-best,
  .panel-progress,
  .panel-search,
  .panel-data,
  .panel-strategies,
  .panel-variants,
  .panel-logs {
    grid-column: span 12;
  }
}

@media (max-width: 720px) {
  .monitor-shell {
    width: min(100vw - 18px, 1280px);
    padding-top: 10px;
  }

  .topbar,
  .objective-band,
  .panel,
  .stat-card {
    padding: 14px;
  }

  h1 {
    font-size: 30px;
  }

  h2 {
    font-size: 18px;
  }

  .status-strip,
  .target-grid,
  .kpi-grid,
  .metric-grid,
  .progress-summary,
  .timeframe-overview,
  .timeframe-stats {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .pill {
    max-width: none;
    text-align: left;
  }

  .check-row,
  .info-row,
  .timeline-row {
    grid-template-columns: 1fr;
  }

  .check-row strong,
  .timeline-row,
  .version-table td:nth-child(n+3),
  .version-table th:nth-child(n+3) {
    text-align: left;
  }

  .version-table {
    overflow-x: visible;
  }

  .version-table table,
  .version-table thead,
  .version-table tbody,
  .version-table tr,
  .version-table th,
  .version-table td {
    display: block;
    width: 100%;
    min-width: 0;
  }

  .version-table thead {
    display: none;
  }

  .version-table tr {
    border: 1px solid var(--line-soft);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 8px;
    background: var(--surface-2);
  }

  .version-table td {
    display: grid;
    grid-template-columns: 86px minmax(0, 1fr);
    gap: 10px;
    border-bottom: 0;
    padding: 6px 0;
  }

  .version-table td::before {
    content: attr(data-label);
    color: var(--faint);
    font-family: "IBM Plex Mono", monospace;
    font-size: 11px;
    text-transform: uppercase;
  }
}
