:root {
  --bg: #203330;
  --bg-accent: #4b8c73;
  --panel: rgba(48, 84, 75, 0.9);
  --panel-strong: rgba(61, 105, 93, 0.94);
  --panel-border: rgba(176, 228, 204, 0.2);
  --text: #f3fbf7;
  --muted: rgba(176, 228, 204, 0.82);
  --line: #ffd3a1;
  --line-soft: rgba(255, 211, 161, 0.16);
  --highlight: #ffbe7a;
  --grid: rgba(176, 228, 204, 0.14);
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Space Grotesk", sans-serif;
  color: var(--text);
  background: var(--bg);
}

a {
  color: inherit;
}

.page-shell {
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 28px 0 56px;
}

.layout {
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
}

.dashboard-panel,
.table-panel {
  padding: 24px;
}

.controls-grid,
.summary-grid {
  display: grid;
  gap: 14px;
}

.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;
}

.controls-shell {
  padding: 4px 0 0;
}

.controls-bar {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, auto);
  gap: 18px;
  align-items: end;
}

.controls-overview {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.controls-overview h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 1.9rem);
  line-height: 1.05;
}

.controls-date {
  margin: 0;
  color: var(--muted);
  font-size: 0.96rem;
}

.controls-actions {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1fr);
  gap: 12px;
}

.control,
.summary-card {
  display: grid;
  gap: 8px;
}

.control span,
.summary-label,
.legend,
#table-caption,
thead {
  font-family: "IBM Plex Mono", monospace;
}

.control span,
.summary-label {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
}

select,
.segment {
  min-height: 52px;
  border: 1px solid rgba(176, 228, 204, 0.12);
  border-radius: 16px;
  font: inherit;
}

select {
  width: 100%;
  padding: 0 16px;
  color: var(--text);
  background: rgba(176, 228, 204, 0.14);
  box-shadow: none;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  padding: 4px;
  border-radius: 18px;
  background: rgba(176, 228, 204, 0.1);
}

.segment {
  cursor: pointer;
  background: transparent;
  color: var(--muted);
}

.segment.is-active {
  background: #ffd3a1;
  color: #2b2017;
  border-color: rgba(255, 240, 220, 0.42);
  box-shadow: inset 0 1px 0 rgba(255, 250, 244, 0.36);
}

.segment:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

.summary-card {
  min-height: 106px;
  min-width: 0;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(176, 228, 204, 0.12);
  border: 1px solid rgba(176, 228, 204, 0.16);
}

.summary-card-primary {
  background: rgba(176, 228, 204, 0.18);
  border-color: rgba(176, 228, 204, 0.22);
}

.summary-card-merged {
  margin-top: 14px;
  gap: 14px;
  padding: 14px 16px;
}

.summary-now {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(176, 228, 204, 0.12);
}

.summary-now strong {
  font-size: clamp(1.24rem, 2.4vw, 1.6rem);
}

.summary-secondary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  text-align: center;
}

.summary-stat {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 0;
  text-align: center;
}

.summary-icon {
  font-size: 1rem;
  font-weight: 700;
  line-height: 1;
}

.summary-icon-average {
  color: var(--muted);
}

.summary-icon-min {
  color: #8be28d;
}

.summary-icon-max {
  color: #ff8f7a;
}

.summary-stat-average strong {
  color: var(--text);
}

.summary-stat-min strong {
  color: #8be28d;
}

.summary-stat-max strong {
  color: #ff8f7a;
}

.summary-card strong {
  font-size: clamp(1rem, 2vw, 1.2rem);
  line-height: 1.25;
}

.summary-meta {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.78rem;
}

.legend,
.footer {
  display: flex;
  gap: 16px;
  align-items: baseline;
  justify-content: space-between;
}

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

.chart-meta {
  display: none;
}

.chart-wrap {
  position: relative;
  width: 100%;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid rgba(255, 211, 161, 0.24);
  background:
    linear-gradient(180deg, rgba(205, 177, 148, 0.12), rgba(116, 96, 80, 0.88)),
    linear-gradient(180deg, rgba(255, 244, 230, 0.04), rgba(255, 244, 230, 0));
  box-shadow:
    inset 0 1px 0 rgba(255, 236, 214, 0.06),
    inset 0 -24px 60px rgba(0, 0, 0, 0.08);
  cursor: crosshair;
  touch-action: none;
}

.chart {
  width: 100%;
  height: auto;
  display: block;
}

.chart-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: var(--muted);
  background: rgba(58, 48, 40, 0.72);
}

.chart-empty[hidden] {
  display: none;
}

.chart-line {
  fill: none;
  stroke: var(--line);
  stroke-width: 4;
  stroke-linejoin: round;
  stroke-linecap: round;
}

.chart-area {
  fill: var(--line-soft);
}

#chart-grid .chart-grid-line {
  stroke: rgba(255, 225, 190, 0.16);
  stroke-width: 1;
}

#chart-grid .chart-grid-line-quarter {
  opacity: 0.22;
}

#chart-grid .chart-grid-line-hour {
  opacity: 0.65;
}

#chart-labels text {
  fill: rgba(255, 225, 190, 0.68);
  font-size: 11px;
  font-family: "IBM Plex Mono", monospace;
}

#chart-points circle {
  fill: #54453a;
  stroke: var(--line);
  stroke-width: 2;
}

#chart-points .chart-point-active-line {
  stroke: rgba(255, 220, 182, 0.42);
  stroke-width: 1;
  stroke-dasharray: 4 6;
}

#chart-points .chart-point-active-ring {
  fill: #54453a;
  stroke: var(--line);
  stroke-width: 2;
}

#chart-points .chart-point-active-dot {
  fill: var(--line);
  stroke: none;
}

.chart-tooltip {
  position: absolute;
  z-index: 2;
  min-width: 148px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 211, 161, 0.22);
  border-radius: 12px;
  background: rgba(27, 21, 17, 0.96);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.24);
  pointer-events: none;
  backdrop-filter: blur(8px);
}

.chart-tooltip strong,
.chart-tooltip span {
  display: block;
}

.chart-tooltip strong {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.76rem;
  color: rgba(255, 225, 190, 0.74);
}

.chart-tooltip span {
  margin-top: 4px;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.chart-tooltip[hidden] {
  display: none;
}

.legend {
  margin-top: 12px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#table-caption {
  margin: 0;
  color: var(--muted);
  font-size: 0.86rem;
}

.table-expander {
  display: grid;
  gap: 12px;
}

.table-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
}

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

.table-summary-copy {
  display: grid;
  gap: 4px;
}

.table-summary-copy strong {
  font-size: clamp(1.4rem, 3vw, 2rem);
}

.table-summary-indicator {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.table-expander[open] .table-summary-indicator {
  transform: rotate(225deg);
}

.table-wrap {
  overflow: auto;
}

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

th,
td {
  padding: 14px 10px;
  border-bottom: 1px solid rgba(31, 26, 19, 0.08);
  text-align: left;
}

tbody tr:hover {
  background: rgba(64, 138, 113, 0.12);
}

td:last-child,
th:last-child {
  text-align: right;
}

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

th,
td {
  border-bottom-color: rgba(176, 228, 204, 0.1);
}

.footer {
  margin-top: 18px;
  padding: 0 6px;
  color: var(--muted);
}

@media (max-width: 720px) {
  .page-shell {
    width: min(100vw - 20px, 1180px);
    padding-top: 18px;
    padding-bottom: 28px;
  }

  .dashboard-panel,
  .table-panel {
    padding: 16px;
    border-radius: 22px;
  }

  .controls-bar,
  .controls-actions,
  .summary-secondary {
    grid-template-columns: 1fr;
  }

  .summary-card {
    min-height: 88px;
    padding: 10px 12px;
  }

  .summary-card-merged {
    gap: 12px;
    padding: 12px;
  }

  .footer {
    flex-direction: column;
    align-items: flex-start;
  }

  .table-summary {
    align-items: flex-start;
  }
}
