:root {
  --bg: #f6f3ee;
  --surface: #ffffff;
  --ink: #2a2622;
  --muted: #7a7068;
  --line: #e6dfd5;
  --accent: #6b4f3a;
  --accent-soft: #efe6dc;
  --ok: #2f7d4f; --ok-bg: #e3f2e8;
  --wait: #8a6a12; --wait-bg: #fbf1d6;
  --bad: #a83a2c; --bad-bg: #f8e1dd;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1b1916; --surface: #24211d; --ink: #f0ebe4; --muted: #a59b90;
    --line: #36312b; --accent: #d2b392; --accent-soft: #3a3129;
    --ok: #7fd09c; --ok-bg: #1f3a2a; --wait: #e8c76a; --wait-bg: #3a3220;
    --bad: #f09484; --bad-bg: #42241f;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: 0 16px 48px; max-width: 920px; margin-inline: auto;
}
a { color: var(--accent); }
h1, h2 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.1rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
p { margin: .2rem 0 0; }

/* Login */
body.login { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.login-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 20px;
  padding: 40px 32px; text-align: center; width: 100%; max-width: 360px;
}
.login-box .logo { width: 72px; height: 72px; border-radius: 18px; margin-bottom: 12px; }
/* Plads til iPhone-notch når siden kører som webapp */
body { padding-top: env(safe-area-inset-top); }
.login-box .g_id_signin { display: flex; justify-content: center; margin-top: 24px; }
.error { color: var(--bad); margin-top: 16px; }

/* Header + toolbar */
.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 24px 0 16px; }
.who { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.notice { background: var(--wait-bg); color: var(--wait); padding: 10px 14px; border-radius: 10px; }
.toolbar {
  display: grid; gap: 12px; grid-template-columns: 1fr;
  position: sticky; top: 0; z-index: 5; background: var(--bg); padding: 8px 0 12px;
}
.stats { display: flex; gap: 10px; }
.stats div {
  flex: 1; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 10px 14px; display: flex; align-items: baseline; gap: 8px;
}
.stats strong { font-size: 1.4rem; }
.stats span { color: var(--muted); font-size: .9rem; }
.date { display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--accent-soft); border-radius: var(--radius); padding: 8px 12px; font-weight: 600; }
input[type=date], input[type=search] {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; min-height: 42px;
}
input[type=search] { width: 100%; }
.filters { display: flex; gap: 6px; }
.filters button {
  flex: 1; font: inherit; font-size: .9rem; padding: 8px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
}
.filters button.on { background: var(--accent); border-color: var(--accent); color: var(--surface); }
@media (min-width: 720px) {
  .toolbar { grid-template-columns: auto auto auto 1fr auto; align-items: center; }
}

/* Knapper */
button { font: inherit; cursor: pointer; }
button:disabled { opacity: .6; cursor: default; }
.primary {
  background: var(--accent); color: var(--surface); border: 0; border-radius: 10px;
  padding: 10px 16px; min-height: 42px; font-weight: 600;
}
.secondary {
  background: var(--surface); color: var(--ink); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 16px; min-height: 42px;
}
.link { background: none; border: 0; padding: 4px 0; color: var(--accent); font-size: .85rem; text-decoration: underline; }
.link.danger { color: var(--bad); }
button.badge { border: 0; }

.card-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.note { margin-top: 6px; color: var(--ink); background: var(--accent-soft); padding: 6px 10px; border-radius: 8px; }

/* Formular-dialog */
dialog {
  border: 0; border-radius: 18px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25);
}
dialog::backdrop { background: rgba(20, 16, 12, .45); }
#card-form { padding: 22px; display: grid; gap: 14px; }
#card-form h2 { font-size: 1.25rem; }
.field { display: grid; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; }
.field em { font-weight: 400; font-style: normal; }
.field input, .field textarea {
  font: inherit; color: var(--ink); background: var(--bg); border: 1px solid var(--line);
  border-radius: 10px; padding: 10px 12px; min-height: 44px; width: 100%;
}
.field textarea { resize: vertical; min-height: 60px; }
.klip-row { display: flex; gap: 8px; }
.klip-row input { flex: 1; }
.chip {
  min-width: 52px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--accent-soft); color: var(--ink); font-weight: 600;
}
.check { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.check input { width: 22px; height: 22px; accent-color: var(--ok); }
.dialog-buttons { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.dialog-buttons .spacer { flex: 1; }

/* Kort */
#cards { display: grid; gap: 12px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.done { opacity: .7; }
.card-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
.badge { font-size: .78rem; font-weight: 600; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.badge.ok { color: var(--ok); background: var(--ok-bg); }
.badge.wait { color: var(--wait); background: var(--wait-bg); }
.badge.bad { color: var(--bad); background: var(--bad-bg); }
.progress { display: flex; align-items: center; gap: 12px; margin: 14px 0 12px; }
.bar { flex: 1; height: 8px; border-radius: 99px; background: var(--accent-soft); overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); transition: width .3s; }
.count { font-size: .85rem; color: var(--muted); white-space: nowrap; }

.slots { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); }
.slot {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 64px; border: 1.5px dashed var(--line); border-radius: 12px; cursor: pointer;
  user-select: none; transition: background .15s, border-color .15s;
}
.slot input { position: absolute; opacity: 0; pointer-events: none; }
.slot .num { font-weight: 650; }
.slot .when { font-size: .72rem; color: var(--muted); min-height: 1em; }
.slot.checked { background: var(--ok-bg); border: 1.5px solid var(--ok); }
.slot.checked .num::before { content: "✓ "; color: var(--ok); }
.slot:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: 2px; }
.empty { text-align: center; color: var(--muted); padding: 40px 0; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  transition: all .2s; pointer-events: none; font-size: .9rem;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast.bad { background: var(--bad); color: #fff; }
