:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #eef3f5;
  --ink: #172026;
  --muted: #66727c;
  --line: #dce4e8;
  --steel: #34515e;
  --steel-dark: #213943;
  --blue: #2563eb;
  --green: #16835f;
  --amber: #b7791f;
  --red: #c24138;
  --cyan: #0f7890;
  --shadow: 0 18px 50px rgba(17, 35, 45, 0.08);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 22px 18px;
  background: #12242d;
  color: #f6fbfd;
}

.brand-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: #e7f3f7;
  color: #12242d;
  font-weight: 800;
  border-radius: var(--radius);
}

.brand-title {
  font-weight: 800;
  line-height: 1.2;
}

.brand-subtitle,
.sidebar-footer p {
  color: #afc2cb;
  font-size: 12px;
}

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

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  padding: 10px 12px;
  color: #d9e7ec;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  text-align: left;
}

.nav-item:hover,
.nav-item.is-active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.16);
}

.nav-icon {
  display: grid;
  place-items: center;
  width: 22px;
  color: #8bd0df;
  font-weight: 700;
}

.sidebar-footer {
  margin-top: auto;
  display: grid;
  gap: 8px;
}

.sidebar-footer summary {
  list-style: none;
  color: #d9e7ec;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.sidebar-footer summary::-webkit-details-marker {
  display: none;
}

.sidebar-footer label {
  color: #d9e7ec;
  font-size: 13px;
  font-weight: 700;
}

.sidebar-footer input {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
}

.main {
  min-width: 0;
  padding: 28px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--cyan);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.18;
}

h2 {
  margin-bottom: 5px;
  font-size: 18px;
  line-height: 1.25;
}

.panel-head p,
.metric-card p,
.comparison-result p {
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.5;
}

.topbar-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.icon-button,
.primary-button,
.secondary-button,
.range-btn,
.catalog-btn {
  min-height: 40px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
}

.secondary-button {
  padding: 0 12px;
  font-weight: 800;
}

.icon-button {
  width: 42px;
  font-size: 20px;
}

.primary-button {
  padding: 0 16px;
  background: var(--steel);
  border-color: var(--steel);
  color: #ffffff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--steel-dark);
}

.status-box {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--cyan);
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.status-box.is-error {
  border-left-color: var(--red);
}

.view {
  display: none;
}

.view.is-active {
  display: grid;
  gap: 20px;
}

.metric-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
}

.metric-card {
  min-height: 138px;
  padding: 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.metric-label {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
}

.metric-value {
  margin-bottom: 4px;
  font-size: 28px;
  font-weight: 850;
  line-height: 1.1;
}

.metric-card.is-good .metric-value {
  color: var(--green);
}

.metric-card.is-warning .metric-value {
  color: var(--amber);
}

.metric-card.is-danger .metric-value {
  color: var(--red);
}

.band {
  display: grid;
  gap: 16px;
}

.two-column {
  grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.85fr);
}

.panel {
  min-width: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.segmented {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: var(--radius);
}

.range-btn,
.catalog-btn {
  min-height: 32px;
  padding: 0 10px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  white-space: nowrap;
}

.range-btn.is-active,
.catalog-btn.is-active {
  background: var(--surface);
  color: var(--ink);
  border-color: var(--line);
}

.chart {
  min-height: 320px;
  overflow: hidden;
}

.chart svg {
  width: 100%;
  height: 320px;
}

.chart-axis {
  stroke: #c9d4d9;
  stroke-width: 1;
}

.chart-grid {
  stroke: #edf2f4;
  stroke-width: 1;
}

.chart-line {
  fill: none;
  stroke: var(--cyan);
  stroke-width: 3;
}

.chart-area {
  fill: rgba(15, 120, 144, 0.12);
}

.chart-dot {
  fill: var(--cyan);
}

.chart-label {
  fill: var(--muted);
  font-size: 12px;
}

.alert-list {
  display: grid;
  gap: 10px;
}

.alert-item {
  display: grid;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--amber);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.alert-item.high {
  border-left-color: var(--red);
}

.alert-item.medium {
  border-left-color: var(--amber);
}

.alert-item.low {
  border-left-color: var(--blue);
}

.alert-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.alert-title-row strong {
  line-height: 1.35;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--steel-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.status-pill.active {
  color: #0d684b;
  background: #e7f7ef;
}

.status-pill.paused {
  color: #855d16;
  background: #fff4dc;
}

.status-pill.failed {
  color: #a33129;
  background: #ffe7e4;
}

.table-action {
  min-height: 32px;
  white-space: nowrap;
}

.alert-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.alert-meta {
  color: var(--muted);
  font-size: 12px;
}

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

.form-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.form-grid input,
.form-grid select {
  width: 100%;
  height: 42px;
  padding: 0 11px;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

.form-submit {
  grid-column: 1 / -1;
}

.table-wrap {
  max-width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
}

table {
  width: 100%;
  min-width: 720px;
  border-collapse: collapse;
  background: #ffffff;
}

th,
td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

th {
  background: #f8fafb;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0;
}

td {
  line-height: 1.4;
}

tbody tr:last-child td {
  border-bottom: 0;
}

.money {
  font-weight: 850;
  color: var(--steel-dark);
  white-space: nowrap;
}

.muted {
  color: var(--muted);
}

.text-link {
  color: var(--cyan);
  font-weight: 800;
  text-decoration: none;
}

.text-link:hover {
  text-decoration: underline;
}

.comparison-result {
  display: grid;
  gap: 14px;
}

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

.comparison-stat {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcfd;
}

.comparison-stat span {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.comparison-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 22px;
}

.argument-box {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid #b8d6ce;
  background: #effaf6;
}

.empty-state {
  padding: 18px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

@media (max-width: 1180px) {
  .metric-grid {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
  }

  .two-column {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    gap: 16px;
    padding: 18px;
  }

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

  .sidebar-footer {
    margin-top: 0;
  }

  .sidebar-footer:not([open]) {
    display: block;
  }

  .sidebar-footer label,
  .sidebar-footer input,
  .sidebar-footer p {
    display: none;
  }

  .sidebar-footer[open] label,
  .sidebar-footer[open] input,
  .sidebar-footer[open] p {
    display: block;
  }

  .sidebar-footer[open] .sr-only {
    position: absolute;
    display: block;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }

  .main {
    padding: 18px;
  }

  .topbar {
    display: grid;
  }

  h1 {
    font-size: 24px;
  }

  .metric-grid,
  .form-grid,
  .comparison-grid {
    grid-template-columns: 1fr;
  }

  .panel-head {
    display: grid;
  }

  .segmented {
    width: 100%;
    overflow-x: auto;
  }

  .metric-card {
    min-height: 120px;
  }
}
