:root {
  color-scheme: light;
  --ink: #17201d;
  --muted: #63706b;
  --line: #dfe6e1;
  --panel: #ffffff;
  --bg: #f4f7f3;
  --green: #2f6f57;
  --gold: #d49a2a;
  --rose: #b85b6b;
  --blue: #3776a9;
  --shadow: 0 14px 34px rgba(23, 32, 29, 0.08);
}

* {
  box-sizing: border-box;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 24px clamp(18px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(244, 247, 243, 0.92);
  backdrop-filter: blur(16px);
}

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

.live-status {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.live-status::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 8px;
  border-radius: 999px;
  background: var(--gold);
}

.live-status.is-live::before {
  background: var(--green);
}

.live-status.is-error::before {
  background: var(--rose);
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(26px, 4vw, 42px);
  line-height: 1.05;
}

h2 {
  font-size: 17px;
}

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

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

select {
  min-width: 132px;
  height: 38px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  font: inherit;
}

.filter-actions {
  display: flex;
  align-items: end;
  gap: 8px;
}

.filter-actions button {
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--green);
  color: white;
  font: inherit;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

.filter-actions button:last-child {
  background: white;
  color: var(--ink);
}

main {
  padding: 22px clamp(18px, 4vw, 48px) 48px;
}

.kpi-grid,
.dashboard-grid {
  display: grid;
  gap: 16px;
}

.kpi-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-bottom: 16px;
}

.kpi-grid article,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.kpi-grid article {
  display: grid;
  gap: 7px;
  min-height: 122px;
  padding: 18px;
}

.kpi-grid span,
.panel-head span,
.kpi-grid small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.kpi-grid strong {
  font-size: clamp(25px, 3.2vw, 38px);
  line-height: 1;
}

.dashboard-grid {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.panel {
  min-width: 0;
  padding: 18px;
}

.panel.wide {
  grid-column: span 2;
}

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

canvas {
  display: block;
  width: 100%;
  max-width: 100%;
}

.product-list {
  display: grid;
  gap: 11px;
}

.product-row {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) 3fr auto;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
}

.bar-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #edf1ee;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--green);
}

.table-panel {
  grid-column: span 3;
}

.table-wrap {
  overflow: auto;
  max-height: 420px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

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

th {
  position: sticky;
  top: 0;
  background: #f8faf7;
  color: var(--muted);
  font-size: 12px;
  z-index: 1;
}

td:nth-child(4) {
  min-width: 260px;
}

td:nth-child(5),
th:nth-child(5) {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 980px) {
  .topbar {
    position: static;
    display: grid;
  }

  .filters {
    justify-content: stretch;
  }

  .filters label {
    flex: 1 1 150px;
  }

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

  .panel.wide,
  .table-panel {
    grid-column: span 2;
  }
}

@media (max-width: 640px) {
  .kpi-grid,
  .dashboard-grid {
    grid-template-columns: 1fr;
  }

  .panel.wide,
  .table-panel {
    grid-column: span 1;
  }

  select {
    width: 100%;
  }

  .filter-actions {
    align-items: stretch;
  }

  .filter-actions button {
    flex: 1;
  }
}
