/* Julemarkedets kasse. Lyst og mørkt tema efter systemet. Ingen inline-
   styles (CSP), så alt, der varierer, er klasser. */

:root {
  --bg: #f5f1ea;
  --surface: #ffffff;
  --surface-2: #f0ebe2;
  --ink: #1c231f;
  --ink-2: #48524c;
  --muted: #69736d;
  --line: #e2dcd1;
  --brand: #1f5c3f;
  --brand-ink: #ffffff;
  --brand-wash: #e3efe7;
  --red: #b3261e;
  --red-wash: #fbe9e7;
  --gold: #a87a14;
  --ok: #1f6b3a;
  --ok-wash: #e2f2e7;
  --warn: #8a5a00;
  --warn-wash: #fdf0d5;
  --bad: #a51d16;
  --bad-wash: #fbe5e3;
  --grid: #ebe6dd;
  --axis: #b9b2a6;
  --bar: #1f5c3f;
  --shadow: 0 1px 2px rgba(30, 25, 15, .06), 0 4px 14px rgba(30, 25, 15, .06);
  --c0: #c0392b; --c1: #2e7d4f; --c2: #c9962b; --c3: #2f6db5;
  --c4: #7b4fb0; --c5: #d9772b; --c6: #1f8f8a; --c7: #8a5a3c;
  --q1: #dcebe1; --q2: #b2d3bd; --q3: #6fae86; --q4: #2f7a4f;
  --q-ink-dark: #ffffff;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111513;
    --surface: #1a201d;
    --surface-2: #222a26;
    --ink: #edf2ee;
    --ink-2: #c3ccc6;
    --muted: #9aa59e;
    --line: #2f3833;
    --brand: #3f9a6c;
    --brand-ink: #08130d;
    --brand-wash: #1d3328;
    --red: #ef6f64;
    --red-wash: #3a1d1a;
    --gold: #e0b14a;
    --ok: #6fd39a;
    --ok-wash: #173324;
    --warn: #f0c062;
    --warn-wash: #3a2e12;
    --bad: #ff8a80;
    --bad-wash: #3d1b18;
    --grid: #27302b;
    --axis: #4a554f;
    --bar: #4fb07e;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4);
    --c0: #e5675a; --c1: #4fb07e; --c2: #e0b14a; --c3: #5b9be0;
    --c4: #a780d8; --c5: #ec9350; --c6: #3fbdb6; --c7: #c08a68;
    --q1: #1f3329; --q2: #285a40; --q3: #3a8a60; --q4: #5cc08a;
    --q-ink-dark: #08130d;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
main { max-width: 960px; margin: 0 auto; padding: 16px 16px 40px; }
h1, h2 { line-height: 1.2; margin: 0 0 12px; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.15rem; }
a { color: var(--brand); }
p { margin: 0 0 12px; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* --- Top og menu (administrationen) --- */
.top {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px 16px; background: var(--brand); color: var(--brand-ink);
}
.brand { display: inline-flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.tree { width: 22px; height: 22px; fill: currentColor; flex: none; }
.tree.big { width: 56px; height: 56px; fill: var(--brand); margin-bottom: 8px; }
.top nav { display: flex; gap: 4px; }
.top nav a { color: inherit; text-decoration: none; padding: 6px 12px; border-radius: 8px; opacity: .85; }
.top nav a[aria-current] { background: rgba(255, 255, 255, .18); opacity: 1; font-weight: 600; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .top nav a[aria-current] { background: rgba(0, 0, 0, .18); }
}

/* --- Kort, knapper, felter --- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  padding: 18px; margin: 0 0 16px; box-shadow: var(--shadow);
}
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 44px; padding: 8px 16px; border-radius: 10px; border: 1px solid transparent;
  background: var(--brand); color: var(--brand-ink); font: inherit; font-weight: 600;
  text-decoration: none; cursor: pointer;
}
.btn.small { min-height: 36px; padding: 6px 12px; font-size: .925rem; }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.ghost.danger { background: transparent; color: var(--bad); border-color: var(--line); }
.btn:disabled { opacity: .45; cursor: default; }
.btn:focus-visible, .icon-btn:focus-visible, button.add:focus-visible, button.minus:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.ico { width: 18px; height: 18px; fill: currentColor; flex: none; }
.icon-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); font: inherit; cursor: pointer;
}
.icon-btn:disabled { opacity: .35; cursor: default; }
input, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-height: 44px; min-width: 0;
}
input:focus, select:focus { outline: 2px solid var(--brand); outline-offset: 0; border-color: var(--brand); }
label { font-weight: 600; }
.flash { padding: 10px 14px; border-radius: 10px; background: var(--ok-wash); color: var(--ok); font-weight: 500; }
.flash.warn { background: var(--warn-wash); color: var(--warn); }
.back { margin: 0 0 10px; }
.back a { text-decoration: none; }

.dot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; margin-right: .45em; vertical-align: .05em; background: var(--muted); flex: none; }
.dot.c0 { background: var(--c0); } .dot.c1 { background: var(--c1); } .dot.c2 { background: var(--c2); } .dot.c3 { background: var(--c3); }
.dot.c4 { background: var(--c4); } .dot.c5 { background: var(--c5); } .dot.c6 { background: var(--c6); } .dot.c7 { background: var(--c7); }

/* --- Forsiden uden bod --- */
.welcome main { max-width: 520px; padding-top: 12vh; }
.hello { text-align: center; padding: 28px 22px; }

/* --- Bodens kasse --- */
body.booth main { max-width: 1100px; padding-bottom: 120px; }
body.booth { --booth: var(--brand); --booth-ink: #fff; }
body.booth.c2, body.booth.c5 { --booth-ink: #1c231f; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) body.booth { --booth-ink: #0d1210; } }
body.booth.c0 { --booth: var(--c0); } body.booth.c1 { --booth: var(--c1); } body.booth.c2 { --booth: var(--c2); } body.booth.c3 { --booth: var(--c3); }
body.booth.c4 { --booth: var(--c4); } body.booth.c5 { --booth: var(--c5); } body.booth.c6 { --booth: var(--c6); } body.booth.c7 { --booth: var(--c7); }
.booth-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 0 10px; padding: 0 0 10px; border-bottom: 4px solid var(--booth);
}
.booth-head h1 { margin: 0; font-size: 1.4rem; }
.today { margin: 2px 0 0; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.sync { margin: 0 0 12px; font-size: .9rem; padding: 6px 12px; border-radius: 999px; display: inline-block; }
.sync:empty { display: none; }
.sync.ok { background: var(--ok-wash); color: var(--ok); }
.sync.busy { background: var(--warn-wash); color: var(--warn); }
.sync.bad { background: var(--bad-wash); color: var(--bad); border-radius: 12px; }

.items {
  display: grid; gap: 10px; margin: 0 0 16px;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}
@media (max-width: 420px) { .items { grid-template-columns: 1fr 1fr; } }
.tile { position: relative; }
button.add {
  width: 100%; min-height: 104px; padding: 14px 12px 12px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 8px;
  background: var(--surface); color: var(--ink); text-align: left;
  border: 2px solid var(--line); border-radius: 14px; box-shadow: var(--shadow);
  font: inherit; cursor: pointer; touch-action: manipulation; -webkit-tap-highlight-color: transparent;
}
button.add:active { transform: scale(.98); }
button.add .name { font-weight: 650; font-size: 1.05rem; line-height: 1.25; padding-right: 30px; overflow-wrap: break-word; hyphens: auto; }
button.add .price { color: var(--ink-2); font-variant-numeric: tabular-nums; }
.tile.picked button.add { border-color: var(--booth); background: var(--brand-wash); }
button.add .count {
  position: absolute; top: 8px; right: 8px; min-width: 30px; height: 30px; padding: 0 8px; border-radius: 15px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--booth); color: var(--booth-ink); font-weight: 700; font-variant-numeric: tabular-nums;
}
button.add.bump .count { animation: bump .18s ease-out; }
@keyframes bump { from { transform: scale(1.25); } to { transform: scale(1); } }
@media (prefers-reduced-motion: reduce) { button.add.bump .count { animation: none; } button.add:active { transform: none; } }
button.minus {
  position: absolute; right: 8px; bottom: 8px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  font-size: 1.5rem; line-height: 1; cursor: pointer; touch-action: manipulation;
}

.paybar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: 12px max(16px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line); box-shadow: 0 -4px 16px rgba(0, 0, 0, .08);
}
.paybar .sum { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.sum-label { color: var(--ink-2); font-size: .9rem; }
.sum-total { font-size: 1.75rem; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1.1; }
.btn.pay { min-width: 120px; min-height: 56px; font-size: 1.15rem; background: var(--ok); color: #fff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .btn.pay { color: #08130d; } }
.toast {
  position: fixed; left: 50%; bottom: 100px; transform: translateX(-50%); z-index: 11;
  padding: 10px 18px; border-radius: 999px; background: var(--ink); color: var(--surface);
  font-weight: 600; box-shadow: var(--shadow); white-space: nowrap;
}

.recent { list-style: none; margin: 0; padding: 0; }
.recent li { padding: 10px 0; border-top: 1px solid var(--line); }
.recent li:first-child { border-top: 0; }
.recent li.sale { display: flex; align-items: center; gap: 10px; }
.sale-main { flex: 1; min-width: 0; }
.sale-top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; font-variant-numeric: tabular-nums; }
.sale-top .when { color: var(--muted); }
.what { color: var(--ink-2); font-size: .9rem; overflow-wrap: anywhere; }
.state { font-size: .8rem; padding: 1px 8px; border-radius: 999px; }
.state.saved { background: var(--ok-wash); color: var(--ok); }
.state.pending { background: var(--warn-wash); color: var(--warn); }
.state.cancelled, .state.rejected { background: var(--bad-wash); color: var(--bad); }
.recent li.cancelled .sale-top strong, .recent li.rejected .sale-top strong { text-decoration: line-through; color: var(--muted); }

dialog.handover {
  border: 0; border-radius: 18px; padding: 22px; max-width: min(420px, calc(100vw - 32px));
  background: var(--surface); color: var(--ink); text-align: center;
}
dialog.handover::backdrop { background: rgba(10, 15, 12, .55); }
.qr { display: flex; justify-content: center; margin: 8px auto 12px; }
.qr svg { width: min(280px, 70vw); height: auto; border-radius: 8px; }
.qr-bg { fill: #ffffff; }
.qr-fg { fill: #000000; }

/* --- Administration --- */
.booth-list { list-style: none; margin: 0 0 16px; padding: 0; }
.booth-list li { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.booth-list li:first-child { border-top: 0; }
.booth-link { flex: 1; min-width: 0; display: flex; flex-direction: column; color: var(--ink); text-decoration: none; padding: 4px 0; }
.booth-name { font-weight: 650; font-size: 1.05rem; }
.booth-link:hover .booth-name { text-decoration: underline; }
.move { display: flex; gap: 6px; }
.inline-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }
.inline-form label { width: 100%; }
.inline-form input { flex: 1 1 220px; }
.help ol { margin: 0 0 12px; padding-left: 1.3em; }
.help li { margin-bottom: 6px; }

.product-list { list-style: none; margin: 0 0 12px; padding: 0; }
.product-list li { padding: 10px 0; border-top: 1px solid var(--line); }
.product-list li:first-child { border-top: 0; }
.product-form { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
/* Telefon: navn og pris på første linje, knapperne på næste */
.product-form .pname { flex: 1 1 calc(100% - 126px); }
.product-form .price-field { flex: 0 0 118px; }
.product-form .row-tools { display: contents; }
@media (min-width: 760px) { .product-form .pname { flex-basis: 220px; } }
.product-form.new { padding-top: 12px; border-top: 1px solid var(--line); }
.price-field { position: relative; display: block; }
.price-field input { width: 100%; padding-right: 38px; text-align: right; font-variant-numeric: tabular-nums; }
.price-field span { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.hidden-item .pname, .hidden-item .pprice { color: var(--muted); background: var(--surface-2); }
.hidden-note { flex-basis: 100%; }

.access-grid { display: grid; gap: 18px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .access-grid { grid-template-columns: 300px 1fr; align-items: start; } }
.qr-card { text-align: center; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); }
.qr-title { font-weight: 700; font-size: 1.15rem; margin: 0; }
.qr-hint { color: var(--ink-2); font-size: .875rem; margin: 0; }
.copy-row { display: flex; gap: 8px; margin: 4px 0 12px; }
.copy-row input { flex: 1; font-size: .875rem; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.danger-zone { margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--line); }
.danger-zone summary { cursor: pointer; color: var(--bad); font-weight: 600; }
.danger-zone p { margin-top: 8px; }

.booth-form { display: grid; gap: 10px; max-width: 520px; }
.colors { border: 0; padding: 0; margin: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.colors legend { font-weight: 600; margin-bottom: 6px; padding: 0; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch .dot { width: 34px; height: 34px; margin: 0; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); }
.swatch input:checked + .dot { box-shadow: 0 0 0 3px var(--ink); }
.swatch input:focus-visible + .dot { outline: 3px solid var(--gold); outline-offset: 3px; }

/* --- Statistik --- */
.filters { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 0 0 16px; }
.filters label { display: flex; flex-direction: column; gap: 4px; font-size: .875rem; color: var(--ink-2); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 0 0 12px; }
@media (max-width: 560px) { .stats { grid-template-columns: 1fr 1fr; } }
.stats div { background: var(--surface-2); border-radius: 12px; padding: 12px; }
.stats dt { color: var(--ink-2); font-size: .875rem; }
.stats dd { margin: 2px 0 0; font-size: 1.5rem; font-weight: 700; font-variant-numeric: tabular-nums; }

.chart-wrap { position: relative; }
.chart { display: block; width: 100%; height: auto; overflow: visible; }
.chart.narrow { display: none; }
@media (max-width: 560px) { .chart.wide { display: none; } .chart.narrow { display: block; } }
.chart .grid { stroke: var(--grid); stroke-width: 1; }
.chart .axis { stroke: var(--axis); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.chart .bar { fill: var(--bar); }
.chart .hit { fill: transparent; cursor: pointer; outline: none; }
.chart .hit:hover { fill: var(--ink); fill-opacity: .05; }
.chart .hit:focus-visible { stroke: var(--gold); stroke-width: 2; }
.chart-tip {
  position: absolute; top: -6px; transform: translate(-50%, -100%); margin: 0;
  padding: 6px 10px; border-radius: 8px; background: var(--ink); color: var(--surface);
  font-size: .85rem; white-space: nowrap; pointer-events: none; z-index: 2;
}
.table-view { margin-top: 10px; }
.table-view summary { cursor: pointer; color: var(--ink-2); font-size: .9rem; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { padding: 8px 6px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
thead th { color: var(--ink-2); font-weight: 600; font-size: .875rem; }
.num { text-align: right; }
.share-table td a { color: var(--ink); text-decoration: none; }
.share-table td a:hover { text-decoration: underline; }
.share-col { width: 34%; white-space: nowrap; }
.share { display: inline-block; width: calc(100% - 48px); height: 10px; border-radius: 5px; background: var(--surface-2); vertical-align: middle; overflow: hidden; }
.share span { display: block; height: 100%; background: var(--bar); border-radius: 5px; }
.pct { display: inline-block; width: 44px; text-align: right; color: var(--ink-2); font-size: .85rem; }
.w0 span { width: 0; } .w5 span { width: 5%; } .w10 span { width: 10%; } .w15 span { width: 15%; } .w20 span { width: 20%; }
.w25 span { width: 25%; } .w30 span { width: 30%; } .w35 span { width: 35%; } .w40 span { width: 40%; } .w45 span { width: 45%; }
.w50 span { width: 50%; } .w55 span { width: 55%; } .w60 span { width: 60%; } .w65 span { width: 65%; } .w70 span { width: 70%; }
.w75 span { width: 75%; } .w80 span { width: 80%; } .w85 span { width: 85%; } .w90 span { width: 90%; } .w95 span { width: 95%; }
.w100 span { width: 100%; }
@media (max-width: 560px) { .share-col { width: auto; } .share { display: none; } }

.heat-wrap { overflow-x: auto; }
.heat th[scope="row"] { font-weight: 500; white-space: nowrap; }
.heat td { min-width: 48px; border: 2px solid var(--surface); border-radius: 6px; text-align: center; }
.heat .q1 { background: var(--q1); } .heat .q2 { background: var(--q2); }
.heat .q3 { background: var(--q3); color: var(--q-ink-dark); } .heat .q4 { background: var(--q4); color: var(--q-ink-dark); font-weight: 600; }

/* --- Print af QR-koden --- */
@media print {
  body.print-qr { background: #fff; }
  body.print-qr .top, body.print-qr .back, body.print-qr .flash, body.print-qr main > .card:not(.access),
  body.print-qr .access h2, body.print-qr .access-grid > div:not(.qr-card) { display: none !important; }
  body.print-qr .card { border: 0; box-shadow: none; padding: 0; }
  body.print-qr .access-grid { display: block; }
  body.print-qr .qr-card { border: 0; background: #fff; color: #000; padding-top: 15mm; }
  body.print-qr .qr-title { font-size: 28pt; }
  body.print-qr .qr svg { width: 120mm; }
  body.print-qr .qr-hint { font-size: 14pt; color: #000; }
}
