/* Ugeskema — papir og blæk.
   Alt er stille på nær ét sted: i dag og lige nu. */

:root {
  color-scheme: light;

  --paper: #eceff3;
  --surface: #ffffff;
  --sunken: #f4f6f9;
  --line: #dce1e8;
  --line-soft: #e8ecf1;
  --line-strong: #c3ccd7;

  --ink: #16212e;
  --ink-soft: #40505f;
  --muted: #6d7b8a;
  --on-ink: #f7f9fb;

  --accent: #0b5d8a;
  --accent-soft: #e4eef5;
  --now: #e11d48;
  --danger: #b42318;
  --danger-soft: #fbeae8;
  --ok: #15803d;
  --warn-bg: #fdf4e3;
  --warn-line: #edd6a4;
  --warn-ink: #7a5314;
  --good-bg: #e9f5ee;
  --good-line: #b5ddc5;
  --good-ink: #1a5c38;

  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(22, 33, 46, 0.05), 0 8px 24px rgba(22, 33, 46, 0.06);

  /* Skala: 1.2. Bruges konsekvent, så overskrifter faktisk ser ud som overskrifter. */
  --t-xs: 0.75rem;
  --t-sm: 0.8125rem;
  --t-md: 0.9375rem;
  --t-lg: 1.125rem;
  --t-xl: 1.375rem;
  --t-2xl: 1.75rem;
  --t-3xl: 2.25rem;

  --sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial,
    sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --paper: #11161c;
    --surface: #1a212a;
    --sunken: #151b22;
    --line: #2b3540;
    --line-soft: #222b34;
    --line-strong: #3d4a58;

    --ink: #e9eef4;
    --ink-soft: #c0cbd6;
    --muted: #8c9aa8;
    --on-ink: #11161c;

    --accent: #6db2dd;
    --accent-soft: #1c2c38;
    --now: #fb7185;
    --danger: #f27272;
    --danger-soft: #2e1d1d;
    --ok: #5ec98c;
    --warn-bg: #2c2415;
    --warn-line: #4d3f1f;
    --warn-ink: #e8c98a;
    --good-bg: #16281f;
    --good-line: #27452f;
    --good-ink: #8fd6ab;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

* {
  box-sizing: border-box;
}

/* Skal staa foer alt andet: display:flex og display:inline-block slaar
   browserens egen [hidden]-regel, saa skjulte elementer blev vist alligevel. */
[hidden] {
  display: none !important;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: var(--t-md) / 1.55 var(--sans);
}

/* Tal i skema, statistik og tabeller skal flugte lodret. */
time,
.tnum,
.grid .time,
.grid .time-label,
.week-list .when,
.stat .value,
.bars .count,
.table td {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.25;
  letter-spacing: -0.011em;
}

h1 {
  font-size: var(--t-2xl);
  font-weight: 600;
}

h2 {
  font-size: var(--t-lg);
  font-weight: 600;
}

h3 {
  font-size: var(--t-md);
  font-weight: 600;
}

p {
  margin: 0;
}

main {
  max-width: 1220px;
  margin: 0 auto;
  padding: 1.5rem 1.5rem 5rem;
}

.tab-panel > section + section,
.tab-panel > form + section {
  margin-top: 2.5rem;
}

.tab-panel > section > h2,
.tab-panel > section > .section-head {
  margin-bottom: 0.75rem;
}

.muted {
  color: var(--muted);
  font-size: var(--t-sm);
}

.lede {
  color: var(--ink-soft);
  max-width: 62ch;
}

.hint {
  color: var(--muted);
  font-size: var(--t-sm);
  margin: 0.6rem 0 0;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--ink);
  color: var(--on-ink);
  padding: 0.5rem 0.9rem;
  border-radius: 0 0 var(--radius-sm) 0;
  z-index: 50;
}

.skip-link:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

.page-head {
  margin-bottom: 1.5rem;
  display: grid;
  gap: 0.4rem;
}

.page-head p {
  color: var(--ink-soft);
  max-width: 62ch;
}

.section-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.section-head .primary {
  margin-left: auto;
}

/* Lågen ------------------------------------------------------------------- */

body.locked {
  overflow: hidden;
}

.gate {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--paper);
  display: grid;
  place-items: center;
  padding: 1.5rem;
  overflow-y: auto;
}

.gate-card {
  width: min(24rem, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.6rem 1.5rem;
  box-shadow: var(--shadow);
}

.gate-brand {
  font-size: var(--t-xl);
  margin-bottom: 0.35rem;
}

.gate-lede {
  color: var(--muted);
  font-size: var(--t-sm);
  margin-bottom: 1.25rem;
}

.gate-lede:empty {
  margin-bottom: 0.75rem;
}

.gate-form {
  display: grid;
  gap: 0.9rem;
}

.gate-form input {
  width: 100%;
}

.gate-form .primary {
  width: 100%;
  padding-block: 0.55rem;
}

.gate-links {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

button.link {
  background: none;
  border: none;
  padding: 0;
  color: var(--accent);
  font-size: var(--t-sm);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
}

button.link:hover {
  background: none;
  color: var(--ink);
}

.gate-error,
.gate-note {
  font-size: var(--t-sm);
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.7rem;
  margin-bottom: 1rem;
}

.gate-error {
  background: var(--danger-soft);
  border: 1px solid var(--danger);
  color: var(--danger);
}

.gate-note {
  background: var(--good-bg);
  border: 1px solid var(--good-line);
  color: var(--good-ink);
}

/* Topbar ------------------------------------------------------------------ */

.topbar {
  display: flex;
  align-items: center;
  gap: 1.25rem;
  flex-wrap: wrap;
  padding: 0.6rem 1.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 5;
}

.brand {
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tabs {
  display: flex;
  gap: 0.15rem;
}

.tabs button {
  white-space: nowrap;
  background: none;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font: inherit;
  color: var(--muted);
  cursor: pointer;
}

.tabs button:hover {
  color: var(--ink);
  background: var(--sunken);
}

.tabs button.active {
  background: var(--ink);
  color: var(--on-ink);
}

.topbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
}

/* Knapper ------------------------------------------------------------------ */

button,
.button {
  font: inherit;
  padding: 0.4rem 0.85rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}

button:hover,
.button:hover {
  background: var(--sunken);
}

button.primary {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--on-ink);
  font-weight: 500;
}

button.primary:hover {
  background: var(--ink-soft);
  border-color: var(--ink-soft);
}

button.ghost {
  border-color: transparent;
  color: var(--muted);
}

button.ghost:hover {
  color: var(--ink);
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:disabled:hover {
  background: var(--surface);
}

button.danger {
  color: var(--danger);
  border-color: var(--line-strong);
}

button.danger:hover {
  background: var(--danger-soft);
  border-color: var(--danger);
}

/* Beskeder ----------------------------------------------------------------- */

.toast {
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: var(--on-ink);
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
  box-shadow: var(--shadow);
  z-index: 20;
  margin: 0;
  font-size: var(--t-sm);
  animation: toast-in 0.18s ease-out;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translate(-50%, 0.5rem);
  }
}

.banner {
  display: flex;
  gap: 0.9rem;
  align-items: center;
  flex-wrap: wrap;
  background: var(--good-bg);
  border: 1px solid var(--good-line);
  color: var(--good-ink);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  margin-bottom: 1rem;
}

.banner button {
  margin-left: auto;
}

.warnings {
  background: var(--warn-bg);
  border: 1px solid var(--warn-line);
  color: var(--warn-ink);
  border-radius: var(--radius);
  padding: 0.6rem 0.9rem;
  margin-bottom: 1rem;
  font-size: var(--t-sm);
}

.warnings summary {
  cursor: pointer;
  font-weight: 500;
}

.warnings ul {
  margin: 0.5rem 0 0;
  padding-left: 1.1rem;
  display: grid;
  gap: 0.25rem;
}

/* Ugelinje ----------------------------------------------------------------- */

.weekbar {
  display: flex;
  align-items: flex-end;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.1rem;
}

.weekbar-title {
  display: grid;
  gap: 0.15rem;
}

.weekbar-range {
  color: var(--muted);
  font-size: var(--t-sm);
}

.weekbar-actions {
  margin-left: auto;
  display: flex;
  gap: 0.4rem;
  align-items: center;
}

/* I dag --------------------------------------------------------------------- */

.today-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 1rem;
  overflow: hidden;
}

.today-head {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding: 0.75rem 0.95rem;
  border-bottom: 1px solid var(--line-soft);
}

.today-head h2 {
  font-size: var(--t-md);
}

.today-head h2::first-letter {
  text-transform: uppercase;
}

.today-status {
  margin-left: auto;
  color: var(--ink-soft);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}

.today-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.today-item {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.5rem 0.95rem;
  border-top: 1px solid var(--line-soft);
}

.today-item:first-child {
  border-top: none;
}

.today-item .what {
  font-weight: 500;
}

.today-item .when {
  margin-left: auto;
  color: var(--muted);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}

.today-item .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.today-item input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--ok);
  flex: none;
  cursor: pointer;
}

.today-item.done .what {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

/* Det der er i gang lige nu. Samme rosa som nu-linjen i skemaet. */
.today-item .badge {
  display: none;
  font-size: var(--t-xs);
  color: var(--now);
  border: 1px solid var(--now);
  border-radius: 999px;
  padding: 0 0.4rem;
}

.today-item.current {
  background: var(--accent-soft);
}

.today-item.current .badge {
  display: inline-block;
}

.today-item.empty-row {
  padding-block: 0.7rem;
}

/* Skema — sidens hovedperson ------------------------------------------------ */

.grid-wrap {
  overflow-x: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overscroll-behavior-x: contain;
  /* Det sidste klokkeslaet staar midt paa underkanten og skal have plads. */
  padding-bottom: 10px;
}

.grid {
  display: grid;
  grid-template-columns: 60px repeat(7, minmax(122px, 1fr));
  min-width: 900px;
}

.grid .head {
  padding: 0.55rem 0.4rem;
  text-align: center;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid var(--line-soft);
  background: var(--surface);
  display: grid;
  gap: 0.1rem;
  justify-items: center;
}

.grid .head .name {
  font-size: var(--t-sm);
  font-weight: 600;
}

.grid .head .date {
  font-size: var(--t-xs);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.grid .head .short {
  display: none;
}

.grid .head.corner {
  border-left: none;
}

.grid .head.rest .name {
  color: var(--muted);
  font-weight: 500;
}

.grid .head.today {
  background: var(--accent-soft);
}

.grid .head.today .date {
  background: var(--now);
  color: #fff;
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

/* Tidskolonnen bliver staaende naar skemaet scrolles vandret paa en telefon. */
.grid .times,
.grid .head.corner {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--surface);
  border-right: 1px solid var(--line);
}

.grid .time-label {
  position: absolute;
  right: 0.6rem;
  transform: translateY(-50%);
  font-size: var(--t-xs);
  color: var(--muted);
}

.grid .day {
  position: relative;
  border-left: 1px solid var(--line-soft);
  /* Hel time = fuld streg, halv time = svagere. Giver et læsbart raster. */
  background-image: repeating-linear-gradient(
      to bottom,
      var(--line) 0 1px,
      transparent 1px var(--hour-height)
    ),
    repeating-linear-gradient(
      to bottom,
      transparent 0 calc(var(--hour-height) / 2),
      var(--line-soft) calc(var(--hour-height) / 2) calc(var(--hour-height) / 2 + 1px),
      transparent calc(var(--hour-height) / 2 + 1px) var(--hour-height)
    );
}

.grid .day.rest {
  background-color: var(--sunken);
}

.grid .day.today {
  background-color: var(--accent-soft);
}

.grid .day.clickable {
  cursor: copy;
}

.grid .block {
  position: absolute;
  left: 3px;
  right: 3px;
  border-radius: var(--radius-sm);
  padding: 4px 6px;
  background: var(--block);
  color: #fff;
  font-size: var(--t-xs);
  line-height: 1.3;
  overflow: hidden;
  cursor: pointer;
  border: none;
  text-align: left;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  font-family: inherit;
}

.grid .block .title {
  font-weight: 600;
}

.grid .block .time {
  opacity: 0.82;
  font-size: 0.6875rem;
}

.grid .block:hover {
  filter: brightness(1.08);
}

/* Traek: kun paa det interaktive skema, ikke paa forhaandsvisningen. */
.grid button.block {
  cursor: grab;
  touch-action: manipulation;
}

.grid .block.dragging {
  cursor: grabbing;
  z-index: 4;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.25);
  filter: brightness(1.05);
}

.grid .resize-handle {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7px;
  cursor: ns-resize;
}

.grid .block.warn {
  outline: 2px solid var(--warn-ink);
  outline-offset: -2px;
}

/* Fast aftale: en lys stribe i venstre kant. */
.grid .block.fixed {
  box-shadow: inset 3px 0 0 rgba(255, 255, 255, 0.6);
  padding-left: 9px;
}

/* Alt der ikke taeller som traening staar som baggrund for ugen, ikke som
   indhold. Ellers fylder otte timers arbejde mere end et pas paa en time. */
.grid .block.soft {
  background: color-mix(in srgb, var(--block) 13%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--block) 32%, var(--surface));
  color: var(--ink);
}

.grid .block.soft.fixed {
  box-shadow: inset 3px 0 0 var(--block);
}

.grid .block.soft .time {
  opacity: 1;
  color: var(--muted);
}

.grid .block.soft.done::after {
  color: var(--muted);
}

/* Gennemført: tonet ned, med flueben. */
.grid .block.done {
  opacity: 0.55;
}

.grid .block.done .title {
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.grid .block.done::after {
  content: '✓';
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 0.75rem;
}

/* Nu-linjen. Den eneste rosa streg i hele appen. */
.grid .now-line {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 2px solid var(--now);
  z-index: 3;
  pointer-events: none;
}

.grid .now-line::before {
  content: '';
  position: absolute;
  left: -4px;
  top: -5px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--now);
}

/* Denne uge ---------------------------------------------------------------- */

.week {
  margin-top: 2.25rem;
}

.week-count {
  color: var(--muted);
  font-size: var(--t-sm);
  font-variant-numeric: tabular-nums;
}

.meter {
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin: 0.6rem 0 0.85rem;
}

.meter-fill {
  display: block;
  height: 100%;
  background: var(--ok);
  border-radius: 999px;
  transition: width 0.25s ease;
}

.week-list {
  list-style: none;
  padding: 0;
  margin: 0;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.week-list li {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.55rem 0.85rem;
  border-top: 1px solid var(--line-soft);
}

.week-list li:first-child {
  border-top: none;
}

.week-list li.today {
  background: var(--accent-soft);
}

.week-list li.done .what {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.week-list input[type='checkbox'] {
  width: 17px;
  height: 17px;
  accent-color: var(--ok);
  flex: none;
  cursor: pointer;
}

.week-list .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.week-list .day {
  color: var(--muted);
  font-size: var(--t-sm);
  min-width: 4.5rem;
}

.week-list .when {
  color: var(--muted);
  margin-left: auto;
  font-size: var(--t-sm);
}

/* Flader og formularer ------------------------------------------------------ */

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
}

.stack {
  display: grid;
  gap: 0.75rem;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 1rem 1.1rem;
  align-items: start;
}

.form-row {
  display: flex;
  gap: 1rem;
  align-items: end;
  flex-wrap: wrap;
}

.form-row.tight {
  gap: 0.6rem;
}

.form-row.tight input {
  width: 100%;
}

.form-row.tight label {
  flex: 1 1 6rem;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

form.panel .form-grid + .form-actions {
  margin-top: 1.1rem;
  padding-top: 1.1rem;
  border-top: 1px solid var(--line-soft);
}

.wide {
  grid-column: 1 / -1;
}

label {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--ink);
}

label small,
fieldset small {
  font-weight: 400;
  color: var(--muted);
  font-size: var(--t-xs);
  line-height: 1.45;
}

label.checkbox,
.checkbox-row label {
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
}

label.checkbox > span {
  display: grid;
  gap: 0.1rem;
}

label.checkbox input[type='checkbox'],
.checkbox-row input[type='checkbox'] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  flex: none;
}

input,
select,
textarea {
  font: inherit;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
  outline: 2px solid var(--accent-soft);
  outline-offset: 0;
}

textarea {
  resize: vertical;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0.7rem 0.85rem;
  margin: 0;
  display: grid;
  gap: 0.6rem;
}

legend {
  font-size: var(--t-sm);
  font-weight: 500;
  padding: 0 0.3rem;
}

.checkbox-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

/* Fremgang ----------------------------------------------------------------- */

/* Nøgletallene står som tal på siden, adskilt af hårfine streger —
   ikke som fire ens kort. */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin: 1.25rem 0 2.5rem;
  overflow: hidden;
}

.stat {
  padding: 0.9rem 1.1rem;
  border-left: 1px solid var(--line-soft);
  display: grid;
  gap: 0.1rem;
}

.stat:first-child {
  border-left: none;
}

.stat .value {
  font-size: var(--t-2xl);
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.15;
}

.stat .value.down {
  color: var(--ok);
}

.stat .value.up {
  color: var(--danger);
}

.stat .value.none {
  color: var(--muted);
  font-weight: 400;
}

.stat .label {
  color: var(--muted);
  font-size: var(--t-sm);
}

.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.85rem;
  position: relative;
}

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

/* Farverne staar i CSS, saa grafen foelger temaet i stedet for at faa
   farverne bagt ind da den blev tegnet. */
.chart-grid {
  stroke: var(--line);
}

.chart-label {
  fill: var(--muted);
  font-size: 11px;
  font-variant-numeric: tabular-nums;
}

.chart-area {
  fill: var(--accent);
  opacity: 0.1;
}

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

.chart-dot {
  fill: var(--accent);
}

.empty {
  color: var(--muted);
  font-size: var(--t-sm);
  text-align: center;
  padding: 2.25rem 1rem;
  margin: 0;
}

.bars {
  display: flex;
  gap: 0.5rem;
  align-items: end;
  height: 150px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.9rem 0.9rem 0.6rem;
}

.bars .bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: end;
  align-items: center;
  gap: 0.3rem;
  height: 100%;
  font-size: var(--t-xs);
  color: var(--muted);
}

.bars .count {
  color: var(--ink);
  font-weight: 500;
}

.bars .track {
  width: 100%;
  flex: 1;
  display: flex;
  align-items: end;
  background: var(--sunken);
  border-radius: 4px 4px 0 0;
}

.bars .fill {
  width: 100%;
  background: var(--accent);
  border-radius: 4px 4px 0 0;
  min-height: 2px;
}

.bars .bar.current .fill {
  background: var(--ok);
}

.table {
  width: 100%;
  border-collapse: collapse;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}

.table th {
  text-align: left;
  padding: 0.5rem 0.85rem;
  font-size: var(--t-sm);
  font-weight: 500;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
}

.table td {
  padding: 0.45rem 0.85rem;
  border-top: 1px solid var(--line-soft);
  font-size: var(--t-sm);
}

.table td:last-child {
  text-align: right;
}

.table tbody tr:first-child td {
  border-top: none;
}

/* Kategorier ---------------------------------------------------------------- */

.categories {
  display: grid;
  gap: 0;
  padding: 0;
}

.categories .category {
  display: flex;
  gap: 0.7rem;
  align-items: center;
  flex-wrap: wrap;
  padding: 0.6rem 0.9rem;
  border-top: 1px solid var(--line-soft);
}

.categories .category:first-child {
  border-top: none;
}

.categories input[type='color'] {
  padding: 2px;
  width: 38px;
  height: 30px;
  flex: none;
  cursor: pointer;
}

.categories .name {
  flex: 1 1 10rem;
  max-width: 18rem;
}

.categories .category label {
  white-space: nowrap;
}

.categories .category .danger {
  margin-left: auto;
}

.history {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.5rem;
}

.history li {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0.7rem 0.9rem;
  font-size: var(--t-sm);
  display: grid;
  gap: 0.15rem;
}

.history .when {
  color: var(--muted);
  font-size: var(--t-xs);
  font-variant-numeric: tabular-nums;
}

.danger-zone {
  display: flex;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
  border-color: var(--line-strong);
  margin-top: 0.75rem;
}

.danger-zone button {
  margin-left: auto;
}

/* Dialog -------------------------------------------------------------------- */

dialog {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1.25rem 1.35rem;
  width: min(440px, 92vw);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(10, 16, 22, 0.45);
}

dialog form {
  display: grid;
  gap: 0.9rem;
}

dialog h2 {
  margin-bottom: 0.1rem;
}

dialog menu {
  display: flex;
  gap: 0.5rem;
  padding: 0;
  margin: 0.35rem 0 0;
  align-items: center;
}

dialog .spacer {
  flex: 1;
}

/* Små skærme ---------------------------------------------------------------- */

@media (max-width: 720px) {
  .topbar {
    padding: 0.55rem 0.9rem;
    gap: 0.6rem;
  }

  .tabs {
    order: 3;
    width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .tabs::-webkit-scrollbar {
    display: none;
  }

  main {
    padding: 1rem 0.9rem 3.5rem;
  }

  h1 {
    font-size: var(--t-xl);
  }

  .weekbar-actions {
    width: 100%;
    margin-left: 0;
  }

  .weekbar-actions .primary {
    margin-left: auto;
  }

  .grid {
    grid-template-columns: 50px repeat(7, minmax(74px, 1fr));
    min-width: 600px;
  }

  .grid .time-label {
    right: 0.4rem;
  }

  .grid .head {
    padding: 0.4rem 0.15rem;
  }

  .grid .head .long {
    display: none;
  }

  .grid .head .short {
    display: inline;
  }

  .grid .block {
    font-size: 0.6875rem;
    padding: 2px 4px;
  }

  .grid .block.fixed {
    padding-left: 6px;
  }

  .grid .block .time {
    font-size: 0.625rem;
  }

  .stat {
    border-left: none;
    border-top: 1px solid var(--line-soft);
  }

  .stat:first-child {
    border-top: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
}

/* Udskrift: én A4 på tværs --------------------------------------------------- */

@page {
  size: A4 landscape;
  margin: 10mm;
}

@media print {
  .topbar,
  .no-print,
  .banner,
  .warnings,
  .toast,
  .skip-link {
    display: none !important;
  }

  body {
    background: #fff;
    color: #000;
  }

  main {
    padding: 0;
    max-width: none;
  }

  .grid-wrap {
    overflow: visible;
    border: none;
    zoom: var(--print-zoom, 1);
  }

  .grid {
    min-width: 0;
  }

  .grid .head.today,
  .grid .day.today {
    background-color: transparent;
  }

  /* Paa papir markeres dagen med fed skrift, ikke med en farvet plet. */
  .grid .head.today .date {
    background: none;
    color: inherit;
    font-weight: 700;
    padding: 0;
  }

  .grid .now-line {
    display: none;
  }

  .grid .block {
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
    opacity: 1;
  }
}
