/* =========================================================================
   Husrenovering - designsystem
   Mobile-first. Bruges udendørs i dagslys, derfor lyst tema med høj kontrast.
   Farvestrategi: neutral flade, grøn kun på primære handlinger og valgt
   tilstand. Prioritet vises aldrig med farve alene - der er altid både
   tekst og en niveau-indikator.
   ========================================================================= */

/* ---------- 1. Tokens ---------- */

:root {
  /* Farver som hex-fallback. Nyere browsere får OKLCH-versionen nedenfor. */
  --bg: #f7fbf8;
  --surface: #ffffff;
  --surface-2: #eff5f1;
  --line: #d9e0db;
  --line-strong: #bdc7c0;
  --line-input: #7f8982;
  --ink: #111813;
  --ink-2: #4d554f;

  --brand: #217541;
  --brand-dark: #005729;
  --brand-soft: #def6e3;

  --hoej: #bc2826;
  --hoej-ink: #9b1014;
  --hoej-soft: #ffe5e0;
  --mellem: #a55e00;
  --mellem-ink: #874900;
  --mellem-soft: #ffedcf;
  --lav: #458554;
  --lav-ink: #255d34;
  --lav-soft: #dff6e2;

  /* Afstande */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 24px;
  --s6: 32px;
  --s7: 48px;

  /* Form */
  --r-sm: 8px;
  --r: 12px;
  --r-lg: 16px;
  --r-full: 999px;
  --tap: 48px;

  --shadow-1: 0 1px 2px rgb(17 24 19 / 0.06), 0 1px 3px rgb(17 24 19 / 0.04);

  /* Typografi - fast rem-skala, ratio ca. 1.2 */
  --text-xs: 0.8125rem;
  --text-sm: 0.9375rem;
  --text-base: 1rem;
  --text-lg: 1.125rem;
  --text-xl: 1.375rem;
  --text-2xl: 1.625rem;

  --font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;

  /* Bevægelse */
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --fast: 120ms;
  --normal: 180ms;

  /* Lagdeling */
  --z-sticky: 100;
}

@supports (color: oklch(0.5 0.1 150)) {
  :root {
    --bg: oklch(0.985 0.006 155);
    --surface: oklch(1 0 0);
    --surface-2: oklch(0.965 0.008 155);
    --line: oklch(0.9 0.01 155);
    --line-strong: oklch(0.82 0.014 155);
    --line-input: oklch(0.62 0.016 155);
    --ink: oklch(0.2 0.015 155);
    --ink-2: oklch(0.44 0.014 155);

    --brand: oklch(0.5 0.115 152);
    --brand-dark: oklch(0.4 0.105 152);
    --brand-soft: oklch(0.95 0.035 152);

    --hoej: oklch(0.52 0.185 27);
    --hoej-ink: oklch(0.44 0.17 27);
    --hoej-soft: oklch(0.95 0.04 27);
    --mellem: oklch(0.55 0.14 68);
    --mellem-ink: oklch(0.47 0.115 62);
    --mellem-soft: oklch(0.955 0.045 75);
    --lav: oklch(0.56 0.1 150);
    --lav-ink: oklch(0.43 0.09 150);
    --lav-soft: oklch(0.95 0.035 150);
  }
}

/* ---------- 2. Basis ---------- */

*,
*::before,
*::after { box-sizing: border-box; }

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

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.01em;
  text-wrap: balance;
}

h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }

p { margin: 0; }

a { color: var(--brand-dark); }

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 3px solid var(--brand);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* ---------- 3. Sidestruktur ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  padding: var(--s3) var(--s4);
  padding-top: calc(var(--s3) + env(safe-area-inset-top));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* Indholdet i topbaren flugter med sidens indhold. */
.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s3);
  max-width: 640px;
  margin: 0 auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2);
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

/* Lille grønt mærke i stedet for et logo. */
.brand::before {
  content: "";
  width: 10px;
  height: 20px;
  border-radius: 3px;
  background: var(--brand);
}

.wrap {
  max-width: 640px;
  margin: 0 auto;
  padding: var(--s5) var(--s4) calc(var(--s7) + env(safe-area-inset-bottom));
}

.page-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s5);
}

/* ---------- 4. Beskeder ---------- */

.flash {
  margin-bottom: var(--s4);
  padding: var(--s3) var(--s4);
  border: 1px solid var(--line-strong);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--ink);
  font-size: var(--text-sm);
}
.flash-ok    { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.flash-error { background: var(--hoej-soft);  border-color: var(--hoej);  color: var(--hoej-ink); }

/* ---------- 5. Flader ---------- */

.card > .btn { margin-top: var(--s5); }

.card {
  margin-bottom: var(--s5);
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-1);
}

/* ---------- 6. Formularer ---------- */

label {
  display: block;
  margin-bottom: var(--s2);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
}

.field + .field { margin-top: var(--s4); }

input[type="text"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s3);
  font: inherit;
  font-size: 1rem; /* 16px, ellers zoomer iOS ind ved fokus */
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r);
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
textarea { min-height: 96px; resize: vertical; }

input::placeholder, textarea::placeholder { color: var(--ink-2); }

input:hover, textarea:hover, select:hover { border-color: var(--ink-2); }

input:focus, textarea:focus, select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}

.check-row {
  display: flex;
  align-items: center;
  gap: var(--s3);
  min-height: var(--tap);
  margin: 0;
  font-weight: 400;
}
.check-row input[type="checkbox"] {
  flex: 0 0 auto;
  width: 24px;
  height: 24px;
  margin: 0;
  accent-color: var(--brand);
}

/* ---------- 7. Knapper ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s2);
  width: 100%;
  min-height: var(--tap);
  padding: var(--s3) var(--s4);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--r);
  cursor: pointer;
  transition: background-color var(--fast) var(--ease),
              border-color var(--fast) var(--ease),
              transform var(--fast) var(--ease);
}
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }

.btn-quiet {
  background: var(--surface);
  border-color: var(--line-input);
  color: var(--ink);
}
.btn-quiet:hover { background: var(--surface-2); }

/* Lille knap i en række, fx "Ret" og "Slet". */
.btn-sm {
  width: auto;
  min-height: 38px;
  padding: var(--s1) 10px;
  font-size: var(--text-xs);
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink-2);
}
.btn-sm:hover { background: var(--surface-2); color: var(--ink); }
.btn-sm.danger { color: var(--hoej-ink); }
.btn-sm.danger:hover { background: var(--hoej-soft); border-color: var(--hoej); }

/* ---------- 8. Login og setup ---------- */

.login {
  max-width: 400px;
  margin: 10vh auto 0;
  padding: 0 var(--s4);
}
.login-mark {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s5);
}
.login-mark span {
  width: 14px;
  height: 32px;
  border-radius: 4px;
  background: var(--brand);
}

/* ---------- 9. Modulliste (dashboard) ---------- */

.modules {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.module {
  display: flex;
  align-items: center;
  gap: var(--s4);
  min-height: 72px;
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--fast) var(--ease), box-shadow var(--fast) var(--ease);
}
.module:hover { border-color: var(--brand); box-shadow: var(--shadow-1); }

.module-body { flex: 1; min-width: 0; }
.module-name { font-size: var(--text-lg); font-weight: 600; }
.module-note { display: block; font-size: var(--text-sm); color: var(--ink-2); }

/* Tallet til højre - kun grønt når der faktisk er noget at se på. */
.module-count {
  flex: 0 0 auto;
  min-width: 40px;
  padding: var(--s1) var(--s2);
  border-radius: var(--r-full);
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-size: var(--text-sm);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.module-count.is-zero { background: var(--surface-2); color: var(--ink-2); }

.module.is-later {
  background: var(--surface-2);
  border-style: dashed;
  color: var(--ink-2);
  cursor: default;
}
.module.is-later:hover { border-color: var(--line); box-shadow: none; }

/* ---------- 10. Filtre ---------- */
/* Samme segmentsprog som prioritetsvælgeren, så filtrene fylder én række
   hver i stedet for at ombryde til tre rækker piller. */

.seg-nav {
  display: flex;
  overflow: hidden;
  margin-bottom: var(--s2);
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r);
}
.seg-nav:last-of-type { margin-bottom: var(--s4); }

.seg {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 var(--s2);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.seg + .seg { border-left: 1px solid var(--line); }
.seg:hover { background: var(--surface-2); color: var(--ink); }

.seg[aria-current="true"] {
  background: var(--brand);
  color: #fff;
  font-weight: 700;
}
.seg.is-hoej[aria-current="true"]   { background: var(--hoej-soft);   color: var(--hoej-ink);   box-shadow: inset 0 0 0 2px var(--hoej); }
.seg.is-mellem[aria-current="true"] { background: var(--mellem-soft); color: var(--mellem-ink); box-shadow: inset 0 0 0 2px var(--mellem); }
.seg.is-lav[aria-current="true"]    { background: var(--lav-soft);    color: var(--lav-ink);    box-shadow: inset 0 0 0 2px var(--lav); }

.seg-count { font-variant-numeric: tabular-nums; opacity: 0.75; }
.seg[aria-current="true"] .seg-count { opacity: 0.9; }

/* ---------- 11. Niveau-indikator ---------- */
/* Tre streger i stigende højde. Antal udfyldte = prioritet, så niveauet
   kan aflæses uden at kunne skelne farverne. */

.level {
  display: inline-flex;
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  flex: 0 0 auto;
}
.level i {
  width: 3px;
  border-radius: 1px;
  background: currentColor;
  opacity: 0.25;
}
.level i:nth-child(1) { height: 5px; }
.level i:nth-child(2) { height: 8px; }
.level i:nth-child(3) { height: 12px; }

.is-lav    .level i:nth-child(-n + 1),
.is-mellem .level i:nth-child(-n + 2),
.is-hoej   .level i:nth-child(-n + 3) { opacity: 1; }

/* Selve mærkaten */
.tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px var(--s2);
  border-radius: var(--r-sm);
  font-size: var(--text-xs);
  font-weight: 700;
}
.tag.is-lav    { color: var(--lav-ink);    background: var(--lav-soft); }
.tag.is-mellem { color: var(--mellem-ink); background: var(--mellem-soft); }
.tag.is-hoej   { color: var(--hoej-ink);   background: var(--hoej-soft); }

/* ---------- 12. Prioritetsvælger ---------- */
/* Én sammenhængende segmentvælger frem for tre løse knapper. Etiketten er
   trykfladen; radioknappen ligger usynligt ovenpå. */

.prio-picker {
  margin: 0;
  padding: 0;
  border: 0;
}
.prio-picker legend {
  padding: 0;
  margin-bottom: var(--s2);
  font-size: var(--text-sm);
  font-weight: 600;
}

.segments {
  display: flex;
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r);
}

.prio { position: relative; flex: 1; margin: 0; }
.prio input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

/* Bruger + frem for :has(), så det også virker i ældre mobilbrowsere. */
.prio > span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  color: var(--ink-2);
  font-size: var(--text-sm);
  font-weight: 600;
  transition: background-color var(--fast) var(--ease), color var(--fast) var(--ease);
}
.prio + .prio > span { border-left: 1px solid var(--line); }
.prio > span:hover { background: var(--surface-2); }

.prio.is-hoej   input:checked + span { background: var(--hoej-soft);   color: var(--hoej-ink);   box-shadow: inset 0 0 0 2px var(--hoej); }
.prio.is-mellem input:checked + span { background: var(--mellem-soft); color: var(--mellem-ink); box-shadow: inset 0 0 0 2px var(--mellem); }
.prio.is-lav    input:checked + span { background: var(--lav-soft);    color: var(--lav-ink);    box-shadow: inset 0 0 0 2px var(--lav); }
.prio input:checked + span { font-weight: 700; }

.prio input:focus-visible + span { outline: 3px solid var(--brand); outline-offset: -3px; }

/* ---------- 13. Opgaveliste ---------- */

.todo-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.todo {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  transition: background-color var(--normal) var(--ease);
}
.todo form { margin: 0; }

/* Afkrydsning */
.check {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  background: var(--surface);
  border: 2px solid var(--line-input);
  border-radius: var(--r-sm);
  color: transparent;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}
.check:hover { border-color: var(--brand); background: var(--brand-soft); }

.todo.is-done { background: var(--surface-2); }
.todo.is-done .check {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.todo.is-done .todo-text {
  text-decoration: line-through;
  color: var(--ink-2);
}

.todo-body {
  flex: 1;
  min-width: 0;
  padding-top: 2px;
}
.todo-text {
  display: block;
  overflow-wrap: anywhere;
  text-wrap: pretty;
}
.todo-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s2);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.todo-date { font-variant-numeric: tabular-nums; }

.todo-actions {
  display: flex;
  gap: var(--s1);
  margin-left: auto;
  flex: 0 0 auto;
}
.todo-actions form { margin: 0; }

/* ---------- 14. Tom tilstand ---------- */

.empty {
  padding: var(--s7) var(--s4);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg);
}
.empty-title { font-weight: 600; margin-bottom: var(--s1); }
.empty-note { font-size: var(--text-sm); color: var(--ink-2); }

/* ---------- 15. Diverse ---------- */

.link-row {
  margin-top: var(--s5);
  text-align: center;
}
.link-row a {
  display: inline-block;
  padding: var(--s3);
  color: var(--ink-2);
  font-size: var(--text-sm);
}

.hint {
  margin-bottom: var(--s4);
  font-size: var(--text-sm);
  color: var(--ink-2);
}

/* ---------- 16. Lidt mere luft på større skærme ---------- */

@media (min-width: 560px) {
  .wrap { padding-top: var(--s6); }
  .btn:not(.btn-sm) { width: auto; min-width: 200px; }
}

/* ---------- 17. Reduceret bevægelse ---------- */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .btn:active { transform: none; }
}

/* ---------- 18. Kvitteringer ---------- */

.btn-block { width: 100%; margin-bottom: var(--s4); }
@media (min-width: 560px) {
  .btn-block { width: 100%; }
}

.label-note { font-weight: 400; color: var(--ink-2); }

/* Totalsum - modulets vigtigste tal, så det står alene. */
.total {
  display: grid;
  gap: 2px;
  margin-bottom: var(--s4);
  padding: var(--s4);
  background: var(--brand-soft);
  border: 1px solid var(--brand);
  border-radius: var(--r-lg);
}
.total-label { font-size: var(--text-sm); color: var(--brand-dark); }
.total-sum {
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--brand-dark);
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
}
.total-count { font-size: var(--text-xs); color: var(--brand-dark); opacity: 0.8; }

/* Filterlinje */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s3);
  margin-bottom: var(--s4);
}
.filter-field { flex: 1 1 140px; }
.filter-field label {
  margin-bottom: var(--s1);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
.filter-bar .btn { flex: 0 0 auto; width: auto; min-width: 0; }

/* Listen */
.receipt-list {
  display: flex;
  flex-direction: column;
  gap: var(--s2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.receipt {
  display: flex;
  align-items: flex-start;
  gap: var(--s3);
  padding: var(--s3);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.receipt form { margin: 0; }

.receipt-thumb {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  overflow: hidden;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--ink-2);
  text-decoration: none;
}
.receipt-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.receipt-thumb.is-empty { font-size: var(--text-lg); }

.receipt-body { flex: 1; min-width: 0; }

.receipt-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
}
.receipt-store {
  font-weight: 600;
  overflow-wrap: anywhere;
}
.receipt-amount {
  flex: 0 0 auto;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.receipt-note {
  margin-top: 2px;
  font-size: var(--text-sm);
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

.receipt-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--s2);
  margin-top: var(--s2);
  font-size: var(--text-xs);
  color: var(--ink-2);
}
/* Kategorien har ingen egen farve - den er ikke et niveau. */
.receipt-meta .tag { background: var(--surface-2); color: var(--ink-2); }

/* Filvælger */
input[type="file"] {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s2);
  font: inherit;
  font-size: var(--text-sm);
  background: var(--surface);
  border: 1px dashed var(--line-input);
  border-radius: var(--r);
}
input[type="file"]::file-selector-button {
  min-height: 36px;
  margin-right: var(--s3);
  padding: var(--s1) var(--s3);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ink);
  background: var(--surface-2);
  border: 1px solid var(--line-input);
  border-radius: var(--r-sm);
  cursor: pointer;
}

.current-image {
  display: flex;
  align-items: center;
  gap: var(--s3);
  margin-bottom: var(--s2);
  padding: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.current-image img {
  width: 72px;
  height: 72px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
}
.current-image .check-row { min-height: 44px; font-size: var(--text-sm); }


/* ---------- 19. Valgte billeder i en formular ---------- */

.file-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--s2);
  margin-top: var(--s2);
  padding: var(--s2);
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r);
}
.file-preview[hidden] { display: none; }

.file-item { margin: 0; }
.file-item img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface);
}
.file-name {
  display: block;
  margin-top: var(--s1);
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--ink-2);
  overflow-wrap: anywhere;
}

/* ---------- 20. Dagbog ---------- */

.card-title {
  margin-bottom: var(--s3);
  font-size: var(--text-base);
  font-weight: 700;
}

.diary-list {
  display: flex;
  flex-direction: column;
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}

.diary {
  padding: var(--s4);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
}
.diary form { margin: 0; }

.diary-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--s3);
  margin-bottom: var(--s2);
}
.diary-date {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.diary-count { font-size: var(--text-xs); color: var(--ink-2); }

.diary-text {
  overflow-wrap: anywhere;
  text-wrap: pretty;
}

/* Billedgitteret vokser med skærmen uden brudpunkter. */
.diary-images {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--s2);
  margin: var(--s3) 0 0;
  padding: 0;
  list-style: none;
}
.diary-images img,
.image-manage img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  display: block;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
}
.diary-images a:focus-visible img,
.image-manage a:focus-visible img { outline: 3px solid var(--brand); outline-offset: 2px; }

.diary-actions {
  display: flex;
  gap: var(--s2);
  justify-content: flex-end;
  margin-top: var(--s3);
}

/* Billeder på siden hvor et opslag rettes */
.image-manage {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(104px, 1fr));
  gap: var(--s3);
  margin: 0;
  padding: 0;
  list-style: none;
}
.image-manage li { display: grid; gap: var(--s1); }
.image-manage .btn-sm { width: 100%; }

/* ---------- 21. Bundnavigation ---------- */
/* Fast i bunden hvor tommelfingeren når den, så man kan skifte modul
   uden at gå via dashboardet. */

.bottom-nav {
  position: fixed;
  inset: auto 0 0 0;
  z-index: var(--z-sticky);
  display: flex;
  background: var(--surface);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}

.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: var(--s2) var(--s1);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  border-top: 3px solid transparent;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--ink); }
.nav-item[aria-current="page"] {
  color: var(--brand-dark);
  border-top-color: var(--brand);
  background: var(--brand-soft);
}

/* Indholdet må ikke gemme sig bag navigationen. */
.has-nav .wrap {
  padding-bottom: calc(56px + var(--s6) + env(safe-area-inset-bottom));
}

/* ---------- 22. Søgning ---------- */

.search-bar {
  display: flex;
  gap: var(--s2);
  margin-bottom: var(--s3);
}
.search-bar input[type="search"] { flex: 1; min-width: 0; }
.search-bar .btn { flex: 0 0 auto; width: auto; min-width: 0; }

input[type="search"] {
  width: 100%;
  min-height: var(--tap);
  padding: var(--s3);
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line-input);
  border-radius: var(--r);
  -webkit-appearance: none;
  appearance: none;
}
input[type="search"]:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-soft);
  outline: none;
}

.filter-search { flex: 1 1 160px; }
.filter-bar .btn { align-self: end; }

/* ---------- 23. Fordeling pr. kategori ---------- */
/* Viser hvor pengene er gået hen. Bjælken er dekoration - tallet står der
   altid, og hver række kan trykkes for at filtrere. */

.breakdown {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0 0 var(--s4);
  padding: 0;
  list-style: none;
  overflow: hidden;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: var(--r);
}

.breakdown-row {
  display: grid;
  grid-template-columns: minmax(72px, auto) 1fr minmax(84px, auto);
  align-items: center;
  gap: var(--s3);
  min-height: 44px;
  padding: var(--s2) var(--s3);
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-sm);
  text-decoration: none;
}
.breakdown-row:hover { background: var(--surface-2); }
.breakdown-row.is-active { background: var(--brand-soft); color: var(--brand-dark); }

.breakdown-bar {
  display: block;
  height: 6px;
  background: var(--surface-2);
  border-radius: var(--r-full);
  overflow: hidden;
}
.breakdown-bar span {
  display: block;
  height: 100%;
  background: var(--brand);
  border-radius: var(--r-full);
}
.breakdown-sum {
  text-align: right;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
