:root {
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #1d2733;
  --muted: #67727f;
  --line: #dde2e8;
  --accent: #2f6fb0;
  --warn: #c1543a;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font: 15px/1.5 "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.topbar {
  display: flex;
  align-items: baseline;
  gap: 2rem;
  padding: 0.9rem 1.5rem;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.topbar h1 { font-size: 1.05rem; margin: 0; letter-spacing: 0.02em; }
.topbar h1 a { color: var(--ink); text-decoration: none; }
.topbar nav { display: flex; gap: 1.1rem; }
.topbar nav a { color: var(--muted); text-decoration: none; }
.topbar nav a.active, .topbar nav a:hover { color: var(--accent); }

main { max-width: 1100px; margin: 0 auto; padding: 1.5rem; }
section { margin-bottom: 2rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.75rem; }
h3 { font-size: 1rem; margin: 0 0 0.5rem; }

footer {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1rem 1.5rem 2rem;
  color: var(--muted);
  font-size: 0.8rem;
}

.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.notice { background: #e7f2e9; border: 1px solid #bcd9c2; padding: 0.6rem 0.8rem; border-radius: 6px; }

button, .button {
  font: inherit;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button:disabled { opacity: 0.55; cursor: default; }

.import-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.9rem 1.1rem;
}

.import-bar > div { display: flex; align-items: center; gap: 0.8rem; }
.progress { color: var(--muted); font-size: 0.88rem; }
.import-errors { flex-basis: 100%; }
.import-errors ul { margin: 0.4rem 0 0; padding-left: 1.1rem; color: var(--warn); font-size: 0.82rem; }
.import-errors li { margin-bottom: 0.15rem; }

.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; }
.cards.wide { grid-template-columns: repeat(auto-fit, minmax(460px, 1fr)); }

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
}

.card-title { font-weight: 600; margin-bottom: 0.35rem; }

/*
 * Chart.js runs with maintainAspectRatio:false, so it sizes the canvas to its parent.
 * The parent therefore needs a height of its own — without one, canvas and container
 * grow each other on every resize tick and the chart creeps down the page.
 */
.chart-frame { position: relative; height: 240px; width: 100%; }
.chart-frame.tall { height: 360px; }
.chart-frame canvas { display: block; }
.copy-data {
  position: absolute;
  top: 0;
  right: 0;
  padding: 0.1rem 0.35rem;
  font-size: 0.85rem;
  line-height: 1.2;
  color: var(--muted);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.chart-frame:hover .copy-data, .copy-data:focus { opacity: 1; }
.copy-data.copied { color: #2e7d4f; border-color: #9ccbb0; opacity: 1; }
.chart-toggle { display: flex; align-items: center; gap: 0.4rem; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.chart-toggle input { margin: 0; }
.chart-controls { display: flex; flex-wrap: wrap; gap: 0.8rem; margin-top: 0.6rem; font-size: 0.85rem; color: var(--muted); }
.chart-controls label { display: flex; align-items: center; gap: 0.35rem; }
.chart-controls select { font: inherit; padding: 0.15rem 0.3rem; border: 1px solid var(--line); border-radius: 4px; color: var(--ink); background: var(--panel); }
.chart-message { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: 0.85rem; text-align: center; padding: 1rem; }
.chart-meta { margin-top: 0.5rem; color: var(--muted); font-size: 0.8rem; }

table { width: 100%; border-collapse: collapse; background: var(--panel); }
th, td { text-align: left; padding: 0.45rem 0.6rem; border-bottom: 1px solid var(--line); }
th { font-weight: 600; color: var(--muted); font-size: 0.82rem; text-transform: uppercase; letter-spacing: 0.03em; }
tbody tr:hover { background: #f2f6fa; }

.type {
  display: inline-block;
  padding: 0.05rem 0.45rem;
  border-radius: 999px;
  font-size: 0.78rem;
  border: 1px solid var(--line);
}

.type.easy { background: #e7f2e9; }
.type.recovery { background: #eef4f8; }
.type.tempo { background: #fdf2dc; }
.type.threshold { background: #fbe6dc; }
.type.interval { background: #f2e6f7; }
.type.test { background: #fde2e2; }

/* Starting an easy row cold is normal, so this is a neutral note, not a warning. */
.flag.cold { margin-left: 0.4rem; color: var(--muted); font-size: 0.75rem; }
.flag.junk { margin-left: 0.4rem; color: var(--warn); font-size: 0.75rem; cursor: help; }
.notice.warn { background: #fbe6dc; border-color: #e5bda9; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0.75rem; }
.metric {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.6rem 0.8rem;
}
.metric-label { color: var(--muted); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.03em; }
.metric-value { font-size: 1.25rem; font-variant-numeric: tabular-nums; }
.metric-hint { color: var(--muted); font-size: 0.75rem; }

.filters { display: flex; gap: 1rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: 1rem; }
.filters label, .settings-form label { display: flex; flex-direction: column; gap: 0.2rem; font-size: 0.85rem; color: var(--muted); }
.filters input, .filters select, .settings-form input { font: inherit; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 6px; color: var(--ink); }

.settings-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; align-items: end; }
.settings-form button { grid-column: 1 / -1; justify-self: start; }

.classification .reason { background: var(--panel); border-left: 3px solid var(--accent); padding: 0.5rem 0.8rem; margin: 0.5rem 0; }
.override { display: flex; align-items: center; gap: 0.5rem; }

.insight { background: var(--panel); border: 1px solid var(--line); border-left-width: 4px; border-radius: 6px; padding: 0.7rem 0.9rem; margin-bottom: 0.6rem; }
.insight.warning { border-left-color: var(--warn); }
.insight.suggestion { border-left-color: var(--accent); }
.insight.info { border-left-color: var(--muted); }
.insight-title { font-weight: 600; }
.insights-head { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.75rem; }
.insights-head h2 { margin: 0; }
.insight-head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.insight-detail { margin-top: 0.2rem; }
.insight-evidence { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-top: 0.5rem; }
.insight-evidence .fact {
  display: inline-flex;
  gap: 0.35rem;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
  font-size: 0.76rem;
}
.fact-key { color: var(--muted); }
.fact-value { font-variant-numeric: tabular-nums; }
.insight-sessions { margin-top: 0.45rem; font-size: 0.78rem; color: var(--muted); }
button.link { border: none; background: none; color: var(--muted); padding: 0; font-size: 0.8rem; text-decoration: underline; }
button.link:hover { color: var(--warn); }
button.small { padding: 0.2rem 0.55rem; font-size: 0.82rem; }
.rule-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.rule-group { grid-column: 1 / -1; margin-top: 0.5rem; font-weight: 600; font-size: 0.9rem; }

.compare-bar { display: flex; align-items: center; gap: 0.8rem; margin-bottom: 0.6rem; }
.compare-bar .spacer { flex: 1; }
td.pick, th.pick { width: 2rem; }
td.structure { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.axis-choice { margin-right: 0.5rem; }
.axis-choice.active { font-weight: 600; color: var(--ink); }

.pager { display: flex; gap: 1rem; align-items: center; margin-top: 1rem; }
.pager .disabled { color: var(--muted); }
.actions { display: flex; gap: 0.8rem; align-items: center; }

@media (max-width: 860px) {
  .cards { grid-template-columns: 1fr; }
  .chart-frame { height: 200px; }
  .chart-frame.tall { height: 280px; }
}

/* Signed-in chrome. Pushed to the right so the navigation keeps its place. */
.topbar .account { margin-left: auto; display: flex; align-items: baseline; gap: 0.7rem; }
.topbar .account-name { color: var(--muted); font-size: 0.9rem; }
.topbar .account form { display: inline; }

button.linklike {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}
button.linklike:hover { text-decoration: underline; }

.login { max-width: 26rem; margin: 3rem auto; }
.login .providers { display: flex; flex-direction: column; gap: 0.6rem; margin: 1.2rem 0; }
.login .provider-button {
  display: block;
  padding: 0.65rem 1rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  color: var(--ink);
  text-decoration: none;
  text-align: center;
}
.login .provider-button:hover { border-color: var(--accent); color: var(--accent); }
.login .hint { color: var(--muted); font-size: 0.85rem; }

/* Below the fold of the sign-in, and visibly a different offer rather than a third provider. */
.login .try-out {
  margin-top: 2rem;
  padding-top: 1.4rem;
  border-top: 1px solid var(--line);
}
.login .try-out h2 { font-size: 1.05rem; }
.login .try-out .provider-button { margin-top: 1rem; }

/* Erasure is not an ordinary action and should not look like one. */
.danger-zone {
  margin-top: 1.6rem;
  padding: 1rem;
  border: 1px solid #e5bda9;
  border-radius: 6px;
  background: #fdf4f0;
}
.danger-zone h4 { margin: 0 0 0.4rem; font-size: 0.95rem; }
.confirm-delete { display: flex; align-items: flex-end; gap: 0.8rem; margin-top: 0.8rem; }
button.danger { background: #a33a1c; border-color: #8d3118; color: #fff; }
button.danger:hover { background: #8d3118; }

/* The plan editor: one small form per weekday, so a row stays a row. */
.inline-form { display: flex; align-items: center; gap: 0.5rem; flex-wrap: wrap; }
.inline-form select, .inline-form input[type="text"] { margin: 0; }
.inline-form input[type="text"] { min-width: 10rem; }
.inline-form input[type="number"] { margin: 0; }
/* Two rates and a Save button have to fit in a table cell without widening the column. */
.inline-form input.spm { width: 3.5rem; padding: 0.2rem 0.3rem; }
.inline-check { display: inline-flex; align-items: center; gap: 0.3rem; margin: 0; }
.inline-check input { margin: 0; }
td.ok { color: #2c6e49; }

details > summary { cursor: pointer; margin: 0.8rem 0 0.4rem; color: var(--accent); }
