:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #17201c;
  background: #f5f7f4;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
  --surface: #ffffff;
  --surface-muted: #f9fbf8;
  --border: #d9dfd7;
  --text-muted: #637067;
  --text-soft: #8a948c;
  --green: #147d64;
  --green-bg: #e7f5ef;
  --red: #cf2f38;
  --red-bg: #fdebed;
  --yellow: #a05d00;
  --yellow-bg: #fff2d2;
  --blue: #2f6fdd;
  --shadow: 0 16px 46px rgba(31, 42, 34, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: #f5f7f4;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 16px 22px;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
}

.brand-block,
.header-actions,
.controls-band,
.date-control,
.metric-card,
.panel-header span,
.secondary-button,
.primary-button,
.export-control {
  display: flex;
  align-items: center;
}

.brand-block {
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  background: #17201c;
  color: #f8fff9;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
}

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

h1 {
  color: #17201c;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.brand-block p,
.panel-header p,
.metric-card p,
.gauge-card p,
.state-view p {
  color: var(--text-muted);
}

.brand-block p {
  margin-top: 4px;
  font-size: 13px;
}

.header-actions {
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.secondary-button,
.primary-button {
  height: 36px;
  gap: 8px;
  border-radius: 8px;
  padding: 0 12px;
  border: 1px solid var(--border);
  background: #ffffff;
  color: #17201c;
}

.primary-button {
  border-color: #17201c;
  background: #17201c;
  color: #ffffff;
}

.export-control {
  gap: 7px;
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 8px 0 10px;
  background: #ffffff;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.export-control select {
  border: 0;
  color: #17201c;
  background: transparent;
  outline: none;
  font-weight: 700;
}

.controls-band {
  justify-content: space-between;
  gap: 14px;
  padding: 14px 22px 0;
  flex-wrap: wrap;
}

.date-control {
  gap: 10px;
  flex-wrap: wrap;
  color: var(--text-muted);
}

.date-control label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
}

.date-control input {
  height: 36px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 10px;
  color: #17201c;
  background: #ffffff;
}

.segmented-control {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  background: #ffffff;
}

.segmented-control button {
  height: 30px;
  border: 0;
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text-muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  text-transform: capitalize;
}

.segmented-control button.active {
  color: #ffffff;
  background: #17201c;
}

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

.metric-card,
.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.metric-card {
  grid-column: span 4;
  gap: 12px;
  min-height: 104px;
  padding: 15px;
}

.metric-card.warning .metric-icon {
  color: var(--red);
  background: var(--red-bg);
}

.metric-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 8px;
  color: var(--green);
  background: var(--green-bg);
}

.metric-card span {
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.metric-card strong {
  display: block;
  margin-top: 4px;
  color: #17201c;
  font-size: 24px;
  line-height: 1.1;
}

.metric-card p {
  margin-top: 5px;
  font-size: 12px;
}

.panel {
  min-width: 0;
  overflow: hidden;
}

.timeline-panel,
.calls-panel {
  grid-column: span 12;
}

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

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

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

.panel-header {
  padding: 15px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-muted);
}

.panel-header span {
  gap: 7px;
  color: #17201c;
  font-size: 14px;
  font-weight: 900;
}

.panel-header p {
  margin-top: 4px;
  font-size: 12px;
}

.chart-frame {
  padding: 10px 12px 14px;
}

.chart-frame.large {
  height: 390px;
}

.chart-frame.medium {
  height: 330px;
}

.gauge-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(178px, 1fr));
  gap: 12px;
  padding: 14px;
}

.gauge-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  background: #ffffff;
}

.gauge-ring {
  --ring-color: var(--green);
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  background:
    radial-gradient(circle at center, #ffffff 55%, transparent 56%),
    conic-gradient(var(--ring-color) var(--progress), #e8eee6 0);
}

.gauge-card.warning .gauge-ring {
  --ring-color: var(--yellow);
}

.gauge-card.danger .gauge-ring {
  --ring-color: var(--red);
}

.gauge-ring span {
  color: #17201c;
  font-size: 14px;
  font-weight: 900;
}

.gauge-card h3 {
  overflow: hidden;
  color: #17201c;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gauge-card p {
  margin-top: 4px;
  font-size: 12px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
}

th,
td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}

th {
  color: var(--text-muted);
  background: #fbfcfa;
  font-size: 11px;
  font-weight: 900;
  text-transform: uppercase;
}

td {
  color: #26312b;
  font-size: 13px;
  font-weight: 700;
}

.numeric {
  text-align: right;
}

.chart-tooltip {
  display: grid;
  gap: 6px;
  min-width: 160px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: #ffffff;
  box-shadow: var(--shadow);
  color: #17201c;
  font-size: 12px;
}

.chart-tooltip span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--text-muted);
}

.chart-tooltip i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.state-view {
  display: grid;
  place-items: center;
  align-content: center;
  min-height: 540px;
  margin: 16px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #ffffff;
  color: #17201c;
  box-shadow: var(--shadow);
  text-align: center;
}

.state-view h2 {
  margin-top: 12px;
  font-size: 20px;
}

.state-view p {
  margin-top: 5px;
  font-size: 13px;
}

.spinning {
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1120px) {
  .metric-card {
    grid-column: span 12;
  }

  .gauges-panel,
  .provider-panel,
  .tool-panel {
    grid-column: span 12;
  }
}

@media (max-width: 760px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .controls-band,
  .dashboard-grid {
    padding-left: 12px;
    padding-right: 12px;
  }

  .date-control,
  .date-control label,
  .segmented-control,
  .secondary-button,
  .primary-button,
  .export-control {
    width: 100%;
  }

  .date-control input,
  .export-control select {
    flex: 1;
  }

  .segmented-control button {
    flex: 1;
  }

  .chart-frame.large,
  .chart-frame.medium {
    height: 310px;
  }

  th,
  td {
    padding: 10px 12px;
  }
}
