:root {
  --bg: #F5F4F0;
  --card: #FFFFFF;
  --ink: #1E2329;
  --muted: #5C6370;
  --line: #E3E1DA;
  --line-soft: #EEECE6;
  --accent: #B8481E;
  --accent-ink: #8A3412;
  --accent-soft: #FBE9E3;
  --accent-tint: #FBF1EC;
  --blue: #1D5FA8;
  --blue-soft: #EEF3F9;
  --green: #2F6B3F;
  --green-soft: #E3F1E6;
  --chip: #F1EFE9;
  --danger: #A33A1C;
  --radius: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171A;
    --card: #1E2125;
    --ink: #ECEDEE;
    --muted: #A2A8B1;
    --line: #30343A;
    --line-soft: #2A2E33;
    --accent: #D2623A;
    --accent-ink: #F0A07F;
    --accent-soft: #3A2219;
    --accent-tint: #2C211C;
    --blue: #7FB0E8;
    --blue-soft: #1F2A37;
    --green: #8BCB9B;
    --green-soft: #1E2E23;
    --chip: #2A2E33;
    --danger: #F08A6B;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.45 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
a { color: var(--blue); }
h1, h2, h3 { font-family: Archivo, Inter, sans-serif; margin: 0; }
h1 { font-size: 28px; font-weight: 700; }
h2 { font-size: 19px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Topbar ---------- */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 12px 16px;
  padding: 12px 24px; background: var(--card); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-family: Archivo, sans-serif; font-weight: 700; font-size: 20px; }
.brand-mark { width: 32px; height: 32px; border-radius: 8px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.mainnav { display: flex; gap: 4px; flex: 1 1 280px; flex-wrap: wrap; }
.mainnav a { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; border-radius: 9px; color: var(--ink); text-decoration: none; font-weight: 500; }
.mainnav a:hover { background: var(--chip); }
.mainnav a[aria-current="page"] { background: var(--ink); color: var(--card); font-weight: 600; }

/* ---------- Layout ---------- */
.page { max-width: 1360px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.cols { display: flex; flex-wrap: wrap; gap: 20px; align-items: flex-start; }
.col-main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.col-side { flex: 1 1 320px; min-width: 0; max-width: 460px; display: flex; flex-direction: column; gap: 20px; }
@media (max-width: 900px) { .col-side { max-width: none; } }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.grid-cats { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.cat-card { display: flex; flex-direction: column; gap: 4px; padding: 16px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; color: var(--ink); text-decoration: none; }
.cat-card:hover { border-color: var(--accent); }
.cat-card .n { font-family: Archivo, sans-serif; font-size: 26px; font-weight: 600; }

/* ---------- Elementer ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 4px 10px; border-radius: 999px; background: var(--chip); color: var(--ink); font-size: 13px; font-weight: 500; white-space: nowrap; }
.chip-accent { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.chip-blue { background: var(--blue-soft); color: var(--blue); }
.chip-green { background: var(--green-soft); color: var(--green); font-weight: 600; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 0 14px;
  border-radius: 10px; border: 1px solid var(--line); background: var(--card); color: var(--ink);
  font: inherit; font-weight: 500; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.05); border-color: var(--accent); }
.btn-dark { background: var(--ink); border-color: var(--ink); color: var(--card); font-weight: 600; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--chip); border-color: transparent; }
.btn-danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn-danger:hover { background: var(--accent-soft); border-color: transparent; }
.btn-sm { min-height: 34px; padding: 0 10px; font-size: 14px; }
.btn:focus-visible, .mainnav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, .cat-card:focus-visible {
  outline: 2px solid var(--blue); outline-offset: 2px;
}
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  min-height: 40px; padding: 0 10px; max-width: 100%;
}
textarea { padding: 10px; min-height: 90px; resize: vertical; width: 100%; }
label.field { display: flex; flex-direction: column; gap: 6px; font-size: 14px; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- Lister ---------- */
.list { display: flex; flex-direction: column; }
.list > * + * { border-top: 1px solid var(--line-soft); }
.item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.item-text { font-weight: 500; overflow-wrap: anywhere; }
.item-meta { font-size: 13px; color: var(--muted); display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.item-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.item.done .item-text { text-decoration: line-through; color: var(--muted); }
.check { width: 20px; height: 20px; margin-top: 2px; accent-color: var(--accent); flex: none; }
.group-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding-top: 4px; }
.group-label.alert { color: var(--accent-ink); }
.event { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; }
.event .t { font-weight: 600; font-variant-numeric: tabular-nums; }
.event.now { background: var(--accent-tint); margin: 0 -12px; padding: 10px 12px; border-radius: 10px; }
.event.now .t { color: var(--accent-ink); }
.event.past { color: var(--muted); }
.empty { color: var(--muted); padding: 6px 0; }
.notice { font-size: 13px; color: var(--muted); background: var(--chip); border-radius: 8px; padding: 8px 10px; }
.search { display: flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 10px; padding: 0 10px; background: var(--card); min-height: 44px; flex: 1 1 280px; max-width: 480px; }
.search input { border: 0; min-height: 40px; flex: 1; padding: 0; background: transparent; }
.search input:focus-visible { outline: none; }
.search:focus-within { outline: 2px solid var(--blue); outline-offset: 2px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs button { min-height: 42px; padding: 0 14px; border: 0; border-bottom: 3px solid transparent; background: transparent; font: inherit; color: var(--muted); cursor: pointer; }
.tabs button[aria-selected="true"] { color: var(--ink); font-weight: 600; border-bottom-color: var(--accent); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 13px; color: var(--muted); font-weight: 600; padding: 8px 6px; }
td { padding: 8px 6px; border-top: 1px solid var(--line-soft); vertical-align: middle; }

/* ---------- Dialog og besked ---------- */
.dialog { border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(560px, calc(100vw - 32px)); background: var(--card); color: var(--ink); }
.dialog::backdrop { background: rgba(20, 22, 26, .45); }
.dialog form, .dialog .dlg-body { padding: 22px; display: flex; flex-direction: column; gap: 14px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); background: var(--ink); color: var(--card); padding: 10px 16px; border-radius: 10px; font-weight: 500; z-index: 50; max-width: calc(100vw - 32px); }
.error-box { border: 1px solid var(--accent); background: var(--accent-tint); border-radius: var(--radius); padding: 18px 20px; }

@media (max-width: 600px) {
  .topbar { padding: 10px 16px; position: static; }
  .topbar #new-idea { margin-left: auto; }
  .mainnav { order: 3; flex-basis: 100%; }
  .page { padding: 16px; }
  .event { grid-template-columns: 104px minmax(0, 1fr); }
  .event .t { white-space: nowrap; }
  .event > :last-child { grid-column: 1 / -1; }
  .item { flex-wrap: wrap; }
  .item-actions { width: 100%; justify-content: flex-start; padding-left: 32px; }
}
