/* Mobile first: one column, large tap targets, 16px inputs (no iOS zoom). */
:root {
  /* Light theme after gronsakshallen.se: greens on warm neutrals. */
  --bg: #f6f5ee;
  --surface: #ffffff;
  --text: #1b1a19;
  --muted: #686764;
  --line: #d7d4c6;
  --accent: #30693c;
  --accent-text: #ffffff;
  --accent-soft: #e2ebe0;
  --bar-bg: #30693c;
  --bar-text: #ffffff;
  --danger: #a22f2f;
  --danger-bg: #a22f2f;
  --warn-bg: #fcefcf;
  --warn-text: #85620a;
  --ok-bg: #d7ead9;
  --ok-text: #1c3b25;
  --radius: 6px;
  --radius-control: 4px;
  color-scheme: light;
}

/* Dark colours apply when the device is dark, unless the user chose
   light, and whenever the user chose dark (data-theme on <html>). The two
   blocks must stay identical. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #1b1a19;
    --surface: #262521;
    --text: #eceadf;
    --muted: #a6a396;
    --line: #3d3b36;
    --accent: #76bc84;
    --accent-text: #152d1a;
    --accent-soft: #1c3b25;
    --bar-bg: #152d1a;
    --bar-text: #eceadf;
    --danger: #ef8f8f;
    --danger-bg: #8f2a2a;
    --warn-bg: #3d3210;
    --warn-text: #f2dca6;
    --ok-bg: #1c3b25;
    --ok-text: #c1d7c4;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #1b1a19;
  --surface: #262521;
  --text: #eceadf;
  --muted: #a6a396;
  --line: #3d3b36;
  --accent: #76bc84;
  --accent-text: #152d1a;
  --accent-soft: #1c3b25;
  --bar-bg: #152d1a;
  --bar-text: #eceadf;
  --danger: #ef8f8f;
  --danger-bg: #8f2a2a;
  --warn-bg: #3d3210;
  --warn-text: #f2dca6;
  --ok-bg: #1c3b25;
  --ok-text: #c1d7c4;
  color-scheme: dark;
}

/* Figtree, by The Figtree Project Authors, under the SIL Open Font License
   (figtree-OFL.txt). Latin subset, variable weight. */
@font-face {
  font-family: "Figtree";
  font-style: normal;
  font-weight: 400 700;
  font-display: swap;
  src: url("figtree-latin.woff2") format("woff2");
}

* { box-sizing: border-box; }

/* Elements styled with display (e.g. buttons) must still honour hidden. */
[hidden] { display: none !important; }

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

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

main {
  max-width: 46rem;
  margin: 0 auto;
  padding: 1rem 1rem calc(2rem + env(safe-area-inset-bottom));
}

h1 { font-size: 1.5rem; line-height: 1.25; margin: .5rem 0 1rem; }
h2 { font-size: 1.15rem; margin: 1.5rem 0 .5rem; }
h3 { font-size: 1rem; margin: 1rem 0 .25rem; }
.card h2:first-child, .card h1:first-child { margin-top: 0; }

a { color: var(--accent); }

.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .5rem 1rem;
  padding-top: calc(.5rem + env(safe-area-inset-top));
  background: var(--bar-bg);
  color: var(--bar-text);
}
.bar .brand { color: inherit; font-weight: 700; text-decoration: none; font-size: 1.1rem; }
.bar .link { color: inherit; }

.tabs, .subnav {
  display: flex;
  gap: .25rem;
  overflow-x: auto;
  padding: 0 .5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  scrollbar-width: none;
}
.tabs a, .subnav a {
  flex: none;
  padding: .75rem .75rem;
  color: var(--muted);
  text-decoration: none;
  border-bottom: 3px solid transparent;
}
.tabs a[aria-current="page"], .subnav a[aria-current="page"] {
  color: var(--text);
  border-bottom-color: var(--accent);
  font-weight: 600;
}
.subnav { margin: -1rem -1rem 1rem; background: transparent; }

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  margin: 1rem 0;
}
.narrow { max-width: 26rem; margin: 2rem auto; }
.center { text-align: center; }

.stack { display: flex; flex-direction: column; gap: .9rem; }
.row { display: flex; flex-wrap: wrap; gap: .75rem; align-items: flex-end; }
.row > label { flex: 1 1 9rem; }
.actions, .quick { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }

label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .95rem; }
label.check { flex-direction: row; align-items: center; font-weight: normal; }

input, select, textarea {
  font: inherit;
  font-size: 16px;
  width: 100%;
  padding: .65rem .75rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
}
input[type="checkbox"] { width: 1.25rem; height: 1.25rem; accent-color: var(--accent); }
textarea { resize: vertical; field-sizing: content; min-height: 7rem; }
input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible, button:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

button, .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.75rem;
  padding: .55rem 1.1rem;
  font: inherit;
  font-weight: 600;
  color: var(--accent-text);
  background: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  text-decoration: none;
  cursor: pointer;
}
button.secondary, .button.secondary { color: var(--accent); background: var(--surface); }
button.danger { color: #fff; background: var(--danger-bg); border-color: var(--danger-bg); }
button.link { min-height: auto; padding: .25rem .5rem; background: none; border: none; text-decoration: underline; }

.segmented {
  display: inline-flex;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  margin: 0 0 .75rem;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  overflow: hidden;
}
.segmented a {
  flex: none;
  white-space: nowrap;
  padding: .45rem .9rem;
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}
.segmented a[aria-current="true"] { color: var(--accent-text); background: var(--accent); }

.search { display: flex; flex-direction: column; gap: .5rem; margin-bottom: .5rem; }
.search input[type="search"] { font-size: 1.1rem; padding: .8rem 1rem; }

.list { list-style: none; margin: .5rem 0; padding: 0; }
.list li + li { border-top: 1px solid var(--line); }
.list a {
  display: block;
  padding: .75rem .25rem;
  color: var(--text);
  text-decoration: none;
}
.list .sub { display: block; color: var(--muted); font-size: .9rem; }
.overdue { color: var(--danger); }

.muted { color: var(--muted); }
.small { font-size: .875rem; }
.lead { font-size: 1.1rem; margin: -.75rem 0 .25rem; }
.hint { color: var(--muted); margin: -.5rem 0 0; font-weight: normal; }
.nowrap { white-space: nowrap; }
.count {
  display: inline-block;
  min-width: 1.6em;
  padding: 0 .45em;
  font-size: .8em;
  text-align: center;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 1em;
}
.tag {
  display: inline-block;
  padding: 0 .4em;
  font-size: .75rem;
  font-weight: 600;
  color: var(--warn-text);
  background: var(--warn-bg);
  border-radius: 4px;
}

.flash, .due, .error {
  padding: .75rem 1rem;
  border-radius: var(--radius-control);
  margin: 0 0 1rem;
}
.flash { color: var(--ok-text); background: var(--ok-bg); }
.due { color: var(--warn-text); background: var(--warn-bg); font-weight: 600; }
.error { color: #fff; background: var(--danger-bg); }
.field-error { color: var(--danger); font-weight: 600; font-size: .875rem; }
.warn { color: var(--warn-text); background: var(--warn-bg); padding: .25rem .5rem; border-radius: 4px; }

.note {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius-control);
  padding: .75rem 1rem;
  margin: .75rem 0;
}
.note header { display: flex; flex-wrap: wrap; gap: .4rem; align-items: baseline; }
.note header a { margin-left: auto; }
.note.revision { border-left-color: var(--line); }
.body { white-space: pre-wrap; overflow-wrap: anywhere; margin: .5rem 0 0; }

.kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr));
  gap: .75rem;
  margin: 0 0 1rem;
}
.kpis div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  padding: .6rem .75rem;
}
.card .kpis div { background: var(--bg); }
.kpis dt { font-size: .8rem; color: var(--muted); }
.kpis dd { margin: 0; font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: .4rem 1rem; margin: 0; }
.details dt { color: var(--muted); }
.details dd { margin: 0; overflow-wrap: anywhere; }

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

.bars { width: 100%; border-collapse: collapse; }
.bars th { text-align: left; font-weight: normal; padding: .2rem .5rem .2rem 0; white-space: nowrap; font-variant-numeric: tabular-nums; }
.bars .bar { width: 100%; padding: .2rem 0; }
.bars svg { display: block; width: 100%; height: .9rem; }
.bars rect { fill: var(--accent); }
.bars .num { text-align: right; padding-left: .5rem; font-variant-numeric: tabular-nums; }

.table-wrap { overflow-x: auto; margin: 0 -1rem; padding: 0 1rem; }
.report { width: 100%; border-collapse: collapse; font-size: .9rem; }
.report th, .report td { text-align: left; vertical-align: top; padding: .5rem .5rem .5rem 0; border-bottom: 1px solid var(--line); }
.report .body { margin: 0; min-width: 14rem; }
.report .num { text-align: right; }
.row-invalid td { color: var(--danger); }
.row-unchanged td { color: var(--muted); }
del { color: var(--muted); }
ins { text-decoration: none; font-weight: 600; }

.danger-zone { border-color: var(--danger); }
.danger-zone > * + * { margin-top: .75rem; }

.secret code {
  display: inline-block;
  font-size: 1.4rem;
  padding: .5rem .75rem;
  background: var(--bg);
  border: 1px dashed var(--line);
  border-radius: var(--radius-control);
  user-select: all;
}

img { max-width: 100%; height: auto; background: #fff; padding: .5rem; border-radius: var(--radius-control); }

@media (min-width: 40rem) {
  .search { flex-direction: row; align-items: center; }
  .search input[type="search"] { flex: 1; }
  .search label.check { flex: none; }
}

.foot { max-width: 46rem; margin: 0 auto; padding: 0 1rem calc(1.5rem + env(safe-area-inset-bottom)); font-size: .875rem; }
.foot a { color: var(--muted); }
.prose h2 { margin-top: 2rem; }
.prose li { margin: .25rem 0; }
.prose .do, .prose .dont { padding-left: 1.25rem; }

.tag.planned { color: var(--ok-text); background: var(--ok-bg); }
.tag.tier { color: var(--accent); background: var(--accent-soft); }
details > summary { cursor: pointer; padding: .25rem 0; color: var(--accent); }
details[open] > summary { margin-bottom: .75rem; }
.plan-when { font-size: 1.1rem; margin: 0 0 .75rem; }
