:root {
  --ink: #202124;
  --muted: #69707a;
  --paper: #fbfaf7;
  --panel: #ffffff;
  --line: #d9ddd8;
  --teal: #3f9f7b;
  --coral: #d94f3d;
  --gold: #f2c14e;
  --green: #78b86f;
  --orange: #f28c38;
  --shadow: 0 18px 50px rgba(32, 33, 36, 0.08);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(120, 184, 111, 0.12), transparent 360px),
    var(--paper);
}

button,
select {
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 24px;
  align-items: end;
  padding: 26px 0 18px;
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.2rem, 6vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0;
}

h2 {
  font-size: 1.02rem;
  letter-spacing: 0;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

select {
  min-height: 42px;
  padding: 0 34px 0 12px;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.weekdays {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin: 4px 0 18px;
}

.weekday-toggle {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  cursor: pointer;
}

.weekday-toggle.is-active {
  color: #fff;
  border-color: var(--teal);
  background: var(--teal);
}

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

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

.details-grid {
  grid-template-columns: 1fr 1fr;
  margin-top: 14px;
}

.metric,
.chart-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow);
}

.metric {
  display: grid;
  gap: 6px;
  min-height: 126px;
  padding: 18px;
}

.metric-label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
}

.metric strong {
  align-self: end;
  font-size: clamp(1.55rem, 4vw, 2.5rem);
  line-height: 1;
}

.metric a {
  color: inherit;
  text-decoration: none;
}

.metric a:hover {
  color: var(--teal);
  text-decoration: underline;
}

.metric span:last-child,
.panel-heading p,
#dataTimestamp {
  color: var(--muted);
  font-size: 0.9rem;
}

.chart-panel {
  padding: 18px;
}

.heatmap-panel {
  margin-top: 14px;
}

.solver-panel {
  margin-top: 14px;
}

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

.panel-heading a {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.chart-legend {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.chart-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend-line {
  display: inline-block;
  width: 28px;
  height: 0;
  border-top: 3px solid var(--coral);
}

.legend-line.adjusted {
  border-top-color: var(--ink);
  border-top-style: dashed;
}

.chart-frame,
.mini-chart {
  width: 100%;
  min-height: 360px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefc;
}

.mini-chart {
  min-height: 260px;
}

.heatmap-chart {
  width: 100%;
  overflow-x: auto;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefc;
}

.heatmap-months {
  display: grid;
  grid-template-columns: repeat(3, minmax(210px, 1fr));
  gap: 14px;
  min-width: 700px;
}

.heatmap-calendar {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
}

.heatmap-calendar h3 {
  margin: 0;
  color: var(--ink);
  font-size: 0.95rem;
}

.heatmap-calendar-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.heatmap-calendar-header span {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
  white-space: nowrap;
}

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

.heatmap-weekdays span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 800;
  text-align: center;
}

.heatmap-day {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(32, 33, 36, 0.08);
  border-radius: 4px;
  background: #eef0ec;
}

.heatmap-day.is-empty {
  border-color: transparent;
  background: transparent;
}

svg {
  display: block;
  width: 100%;
  height: 100%;
}

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

.grid-line {
  stroke: #e8ebe7;
  stroke-width: 1;
}

.trend-line {
  fill: none;
  stroke: var(--teal);
  stroke-width: 3;
}

.smooth-line {
  fill: none;
  stroke: var(--coral);
  stroke-width: 4;
}

.adjusted-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
  stroke-dasharray: 8 6;
}

.solver-line {
  fill: none;
  stroke: var(--ink);
  stroke-width: 3;
}

.point {
  stroke: #fff;
  stroke-width: 2;
}

.bar-label {
  fill: var(--ink);
  font-size: 12px;
  font-weight: 700;
}

.zero-line {
  stroke: #969d96;
  stroke-width: 2;
}

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

.signal {
  display: grid;
  gap: 5px;
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffefc;
}

.signal strong {
  font-size: 0.92rem;
}

.signal span {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

.table-panel {
  margin-top: 14px;
}

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

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 840px;
}

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

th {
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  padding: 0 9px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.86rem;
  font-weight: 800;
}

.empty-state {
  display: grid;
  min-height: inherit;
  place-items: center;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

@media (max-width: 860px) {
  .toolbar,
  .summary-grid,
  .details-grid {
    grid-template-columns: 1fr;
  }

  .control-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 560px) {
  .app-shell {
    width: min(100% - 20px, 1180px);
    padding-top: 14px;
  }

  .control-grid,
  .weekdays {
    grid-template-columns: 1fr;
  }

  .chart-frame {
    min-height: 300px;
  }

  .heatmap-months {
    grid-template-columns: 1fr;
    min-width: 0;
  }
}
