/* Tigapo Mobil – gemensam stilmall för dashboard, Besökare och login.
   Inga externa beroenden (systemtypsnitt, inline-SVG). Ljust/mörkt via prefers-color-scheme. */

/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #f3f2ee; --surface: #ffffff; --surface-2: #f5f4f0; --surface-3: #e9e8e2;
  --border: #e6e4de; --border-strong: #d3d1c9;
  --text: #141413; --text-2: #55534e; --text-3: #85837c;
  --accent: #2a78d6; --accent-ink: #1e63b8; --accent-soft: #e4eefb; --on-accent: #ffffff;
  --s1: #2a78d6; --s2: #eb6834;
  --good: #1f9d45; --good-ink: #157a33; --good-soft: #e2f5e8;
  --warn: #e7a412; --warn-ink: #8a5a00; --warn-soft: #fcf1d6;
  --serious: #e5652e; --serious-ink: #b5461a; --serious-soft: #fde8de;
  --critical: #d63a3a; --critical-ink: #b12b2b; --critical-soft: #fbe3e3;
  --seq-0: #ecebe6; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --grid: #ebeae5;
  --shadow-1: 0 1px 2px rgba(25, 24, 20, .04), 0 2px 6px rgba(25, 24, 20, .05);
  --shadow-2: 0 10px 30px rgba(25, 24, 20, .14), 0 2px 8px rgba(25, 24, 20, .06);
  --r-sm: 8px; --r-md: 12px; --r-lg: 18px; --r-pill: 999px;
  --maxw: 720px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .7, .2, 1);
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #0e1320; --surface: #161c2b; --surface-2: #1e2536; --surface-3: #2a3245;
    --border: #283046; --border-strong: #3a445c;
    --text: #f2f4f8; --text-2: #b5bccb; --text-3: #7f8aa1;
    --accent: #4b93ea; --accent-ink: #86b8f3; --accent-soft: #1a3358; --on-accent: #ffffff;
    --s1: #4b93ea; --s2: #ef7a45;
    --good: #35c46b; --good-ink: #7fe0a3; --good-soft: #143424;
    --warn: #f2b53a; --warn-ink: #f6cf7a; --warn-soft: #3a2d10;
    --serious: #f2804e; --serious-ink: #f8a985; --serious-soft: #3d2216;
    --critical: #ea5a52; --critical-ink: #f5938d; --critical-soft: #3e1c1c;
    --seq-0: #1e2536; --seq-1: #1c3560; --seq-2: #1d4f95; --seq-3: #2563b8; --seq-4: #2f7ad8; --seq-5: #4b93ea; --seq-6: #7db3f2; --seq-7: #b3d3f8;
    --grid: #283046;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow-2: 0 12px 32px rgba(0, 0, 0, .5), 0 2px 8px rgba(0, 0, 0, .3);
  }
}

/* ---------- bas ---------- */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); font-variant-numeric: tabular-nums; }
body { padding: 0 0 max(28px, env(safe-area-inset-bottom)); }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: default; }
a { color: var(--accent-ink); text-decoration: none; }
input { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: var(--accent-soft); }
.i { width: 20px; height: 20px; flex: none; }
.muted { color: var(--text-3); font-size: 13px; }
.note, .card-note { color: var(--text-3); font-size: 12.5px; line-height: 1.45; margin-top: 10px; }
.note strong, .card-note strong { color: var(--text-2); }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--good) 45%, transparent); } 70% { box-shadow: 0 0 0 7px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- sidhuvud ---------- */
header.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--bg) 84%, transparent); backdrop-filter: blur(16px) saturate(1.4); -webkit-backdrop-filter: blur(16px) saturate(1.4); padding: max(10px, env(safe-area-inset-top)) 16px 10px; border-bottom: 1px solid var(--border); }
header.top > * { max-width: var(--maxw); margin-left: auto; margin-right: auto; }
.top-row { display: flex; align-items: center; gap: 10px; min-height: 40px; }
.brand { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; flex: none; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 40%, transparent); }
.brand-text { min-width: 0; }
.top h1 { font-size: 17px; font-weight: 700; letter-spacing: -.01em; margin: 0; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top .sub { font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--good); flex: none; animation: pulse 2.4s ease-out infinite; }
.icon-btn { width: 38px; height: 38px; border-radius: var(--r-md); display: grid; place-items: center; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-1); color: var(--text); flex: none; transition: transform .15s var(--ease), background .15s; }
.icon-btn:active { transform: scale(.94); }
.icon-btn .i { width: 19px; height: 19px; }
.icon-btn.spin .i { animation: spin 1s linear infinite; }
.back { display: inline-flex; align-items: center; gap: 2px; color: var(--accent-ink); font-weight: 600; font-size: 14px; }
.back .i { width: 18px; height: 18px; }
.top-row > .brand-text { flex: 1; min-width: 0; }
.top .seg { margin-top: 10px; }

/* period-chips (dashboard) */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; height: 32px; padding: 0 14px; border-radius: var(--r-pill); background: var(--surface); border: 1px solid var(--border); font-size: 13px; font-weight: 600; color: var(--text-2); transition: background .15s, color .15s, transform .15s var(--ease); }
.chip:active { transform: scale(.96); }
.chip[aria-pressed=true] { background: var(--text); color: var(--bg); border-color: var(--text); }
.custom-range { display: none; gap: 8px; padding: 8px 0 4px; align-items: center; }
.custom-range.open { display: flex; }
.custom-range span { color: var(--text-3); font-size: 13px; }
input[type=date] { font-size: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 8px 10px; min-width: 0; width: 100%; }

/* segmenterad kontroll (topplista + flikar på Besökare) */
.seg { display: flex; gap: 3px; background: var(--surface-3); padding: 3px; border-radius: var(--r-md); }
.seg > button { flex: 1; height: 32px; border-radius: 9px; font-size: 13px; font-weight: 600; color: var(--text-2); display: inline-flex; align-items: center; justify-content: center; gap: 6px; transition: background .15s, color .15s; }
.seg > button.on, .seg > button[aria-selected=true] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); }
.tab-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: var(--r-pill); background: var(--serious); color: #fff; font-size: 11px; font-weight: 700; line-height: 1; }

/* sök + skanna (Besökare) */
.searchbar { margin-top: 10px; display: flex; gap: 8px; }
.search-wrap { flex: 1; position: relative; min-width: 0; }
.search-wrap .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 18px; height: 18px; color: var(--text-3); pointer-events: none; }
.searchbar input { width: 100%; height: 42px; font-size: 16px; padding: 0 12px 0 38px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); box-shadow: var(--shadow-1); -webkit-appearance: none; appearance: none; }
.searchbar input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- knappar ---------- */
.btn, .svc-btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 42px; padding: 0 14px; border-radius: var(--r-md); font-weight: 600; font-size: 15px; background: var(--surface-2); color: var(--text); border: 1px solid var(--border); transition: transform .15s var(--ease), filter .15s; }
.btn:active, .svc-btn:active { transform: scale(.97); }
.btn.primary, .svc-btn.primary { background: var(--accent); color: var(--on-accent); border-color: transparent; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); }
.btn.danger, .svc-btn.danger { background: var(--serious); color: #fff; border-color: transparent; box-shadow: 0 2px 8px color-mix(in srgb, var(--serious) 35%, transparent); }
.btn:disabled, .svc-btn:disabled { opacity: .5; box-shadow: none; transform: none; }
.svc-btn { display: flex; width: 100%; margin-top: 10px; }
.scan { flex: none; }
.scan .i { width: 18px; height: 18px; }
.more { display: block; width: 100%; margin-top: 10px; padding: 10px; border-radius: var(--r-md); background: var(--surface-2); font-weight: 600; font-size: 14px; color: var(--accent-ink); }
.more:disabled { opacity: .6; }
.close-btn { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); }
.close-btn .i { width: 16px; height: 16px; }

/* ---------- kort ---------- */
main { padding: 14px 16px; display: grid; gap: 12px; max-width: var(--maxw); margin: 0 auto; }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-lg); padding: 16px; box-shadow: var(--shadow-1); min-width: 0; animation: rise .4s var(--ease) both; }
.card:nth-child(2) { animation-delay: .04s; } .card:nth-child(3) { animation-delay: .08s; } .card:nth-child(4) { animation-delay: .12s; } .card:nth-child(5) { animation-delay: .16s; } .card:nth-child(n+6) { animation-delay: .2s; }
.card h2 { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 20px; }
.card h2 .meta, .card h2 .muted { text-transform: none; letter-spacing: 0; font-weight: 500; font-size: 12px; color: var(--text-3); text-align: right; }
.card h2.sub-h { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); }
.error-box { background: var(--critical-soft); border-color: color-mix(in srgb, var(--critical) 35%, var(--border)); }
.error-box strong { color: var(--critical-ink); }
.error-box .muted, .error-box .err-msg { color: var(--critical-ink); font-size: 13px; margin-top: 4px; }
.skeleton { color: transparent; border-radius: 6px; background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s linear infinite; }
footer { text-align: center; color: var(--text-3); font-size: 12px; padding: 16px 16px 0; }
footer button { color: var(--text-3); text-decoration: underline; text-underline-offset: 2px; }
@media (min-width: 880px) {
  :root { --maxw: 1040px; }
  main { grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 20px; align-items: start; }
  .card.wide { grid-column: 1 / -1; }
  header.top { padding-left: 20px; padding-right: 20px; }
  /* Besökare är ett telefonverktyg: en kolumn även på bred skärm */
  body.visitors { --maxw: 760px; }
  body.visitors main { grid-template-columns: 1fr; }
}

/* ---------- dashboard: live-rutor ---------- */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.tile { background: var(--surface-2); border-radius: 14px; padding: 14px; min-width: 0; }
.tile .label { font-size: 12px; font-weight: 500; color: var(--text-2); }
.tile .value { font-size: 28px; font-weight: 700; letter-spacing: -.02em; line-height: 1.1; margin-top: 4px; }
.tile .value small { font-size: 14px; font-weight: 500; color: var(--text-3); letter-spacing: 0; }
.tile .ring { float: right; width: 40px; height: 40px; margin: -2px -2px 0 6px; }
.status-line { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; margin-top: 8px; color: var(--text-2); }
.status-line .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--good); }
.status-line.warn .dot { background: var(--warn); border-radius: 1px; transform: rotate(45deg); }
.status-line.critical .dot { background: var(--critical); border-radius: 2px; }
@media (min-width: 560px) { .tiles { grid-template-columns: repeat(4, 1fr); } }

/* ---------- dashboard: intäkt ---------- */
.hero { font-size: 38px; font-weight: 800; letter-spacing: -.03em; line-height: 1; }
.hero small { font-size: 14px; font-weight: 600; color: var(--text-3); margin-left: 8px; letter-spacing: .04em; }
.hero-sub { color: var(--text-3); font-size: 13px; margin-top: 6px; }
.breakdown { margin-top: 14px; }
.bar { display: flex; height: 10px; border-radius: 5px; overflow: hidden; gap: 2px; background: var(--surface-2); }
.bar > span { display: block; height: 100%; min-width: 3px; border-radius: 2px; }
.legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 10px; font-size: 13px; color: var(--text-2); }
.legend .sw { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.legend b { color: var(--text); }
.legend .pct { color: var(--text-3); margin-left: 4px; }
.compare { display: grid; grid-template-columns: auto 1fr auto; column-gap: 10px; row-gap: 8px; align-items: center; margin-top: 16px; font-size: 13px; }
.compare .lbl { color: var(--text-2); white-space: nowrap; }
.compare .amt { font-weight: 600; text-align: right; white-space: nowrap; }
.compare .track { height: 8px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.compare .track i { display: block; height: 100%; border-radius: 4px; background: var(--s1); }
.compare .track i.muted-fill { background: var(--seq-2); }
.typelist { list-style: none; margin: 14px 0 0; padding: 0; }
.typelist li { display: grid; grid-template-columns: 1fr auto auto; column-gap: 10px; align-items: center; padding: 7px 0; border-top: 1px solid var(--border); font-size: 14px; }
.typelist li:first-child, .typelist li.card-note + li { border-top: 0; }
.typelist li.card-note { display: block; border: 0; padding: 0 0 6px; margin: 0; }
.typelist .name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typelist .amt { font-weight: 600; white-space: nowrap; }
.typelist .pct { color: var(--text-3); font-size: 12px; min-width: 34px; text-align: right; }
.typelist .track { grid-column: 1 / 4; height: 4px; background: var(--surface-2); border-radius: 2px; overflow: hidden; margin-top: 5px; }
.typelist .track i { display: block; height: 100%; background: var(--s1); border-radius: 2px; }

/* ---------- diagram ---------- */
.chart { position: relative; width: 100%; margin-top: 10px; touch-action: pan-y; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .axis text { fill: var(--text-3); font-size: 10.5px; font-family: var(--font); }
.chart .grid line { stroke: var(--grid); stroke-width: 1; }
.chart .line { fill: none; stroke: var(--s1); stroke-width: 2.25; stroke-linejoin: round; stroke-linecap: round; }
.chart .cross { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 3; }
.chart .marker { fill: var(--s1); stroke: var(--surface); stroke-width: 2.5; }
.chart .bars rect { fill: var(--s1); }
.tip { position: absolute; top: 0; left: 0; pointer-events: none; background: var(--text); color: var(--bg); font-size: 12px; font-weight: 500; padding: 6px 9px; border-radius: 8px; white-space: nowrap; transform: translate(-50%, -115%); opacity: 0; transition: opacity .12s; box-shadow: var(--shadow-2); }
.tip.on { opacity: 1; }

/* ---------- dashboard: topplista ---------- */
.toplist { list-style: none; margin: 0; padding: 0; }
.toplist li { display: grid; grid-template-columns: 24px 1fr auto; column-gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.toplist li:first-child, .toplist li.card-note + li { border-top: 0; }
.toplist li.card-note, .toplist li.muted { display: block; border: 0; padding: 0 0 6px; margin: 0; }
.toplist .rank { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); color: var(--text-2); font-size: 11.5px; font-weight: 700; display: grid; place-items: center; }
.toplist .rank.top { background: var(--accent-soft); color: var(--accent-ink); }
.toplist .name { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toplist .detail { grid-column: 2 / 4; font-size: 12px; color: var(--text-3); }
.toplist .amt { font-weight: 600; text-align: right; font-size: 14px; }
.toplist .track { grid-column: 2 / 4; height: 4px; background: var(--surface-2); border-radius: 2px; margin-top: 7px; overflow: hidden; }
.toplist .track i { display: block; height: 100%; background: var(--s1); border-radius: 2px; }

/* ---------- dashboard: rusningstider + status ---------- */
.heat { display: grid; grid-template-columns: 30px 1fr; grid-template-rows: 16px auto; gap: 2px 6px; margin-top: 6px; }
.heat .hours { position: relative; font-size: 11px; color: var(--text-3); }
.heat .hours span { position: absolute; top: 0; transform: translateX(-2px); }
.heat .days { display: grid; grid-template-rows: repeat(7, 1fr); font-size: 11px; color: var(--text-3); }
.heat .days span { display: flex; align-items: center; }
.heat-scale { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); margin-top: 10px; }
.heat-scale i { flex: 1; height: 8px; border-radius: 4px; background: linear-gradient(90deg, var(--seq-1), var(--seq-4), var(--seq-7)); max-width: 120px; }
.status-list { list-style: none; margin: 0; padding: 0; }
.status-list li { padding: 9px 0; border-top: 1px solid var(--border); font-size: 14px; }
.status-list li:first-child { border-top: 0; }
.status-list .k { color: var(--text-3); font-size: 12px; }
#updateBar { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 20; display: flex; align-items: center; gap: 12px; background: var(--text); color: var(--bg); padding: 8px 8px 8px 16px; border-radius: var(--r-pill); box-shadow: var(--shadow-2); font-size: 14px; font-weight: 500; white-space: nowrap; }
#updateBar button { background: var(--accent); color: #fff; border-radius: var(--r-pill); padding: 8px 14px; font-weight: 600; }

/* ---------- Besökare: avatarer, pills, listor ---------- */
.avatar { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: none; }
.avatar .i { width: 18px; height: 18px; }
.avatar.lg { width: 46px; height: 46px; border-radius: 14px; }
.avatar.lg .i { width: 22px; height: 22px; }
.avatar.sm { width: 30px; height: 30px; border-radius: 9px; }
.avatar.sm .i { width: 15px; height: 15px; }
.avatar.accent { background: var(--accent-soft); color: var(--accent-ink); }
.avatar.good { background: var(--good-soft); color: var(--good-ink); }
.avatar.warn { background: var(--warn-soft); color: var(--warn-ink); }
.avatar.bad { background: var(--serious-soft); color: var(--serious-ink); }
.pill { display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: var(--r-pill); font-size: 12px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.pill::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.on { background: var(--good-soft); color: var(--good-ink); }
.pill.off { background: var(--surface-3); color: var(--text-2); }
.pill.warn { background: var(--warn-soft); color: var(--warn-ink); }
.pill.bad { background: var(--serious-soft); color: var(--serious-ink); }
.pills { display: inline-flex; flex-wrap: wrap; gap: 4px 6px; }
.bad-ink { color: var(--serious-ink); }
.bad-ink { color: var(--serious-ink); }
.list, .hist { list-style: none; margin: 0; padding: 0; }
.list li { display: grid; grid-template-columns: 36px 1fr auto; gap: 2px 12px; align-items: center; padding: 10px 0; border-top: 1px solid var(--border); }
.list li:first-child, .hist li:first-child { border-top: 0; }
.list li[data-user], .list li[data-machine], .list li[data-kiosk-row] { cursor: pointer; }
.list li.muted, .hist li.muted { display: block; border-top: 0; padding: 4px 0; }
.who { min-width: 0; }
.who .n { font-weight: 600; font-size: 14.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who .meta { font-size: 12px; color: var(--text-3); margin-top: 1px; }
.right { text-align: right; }
.right .bal { font-weight: 700; font-size: 15px; }
.right .sub { font-size: 12px; color: var(--text-3); margin-top: 2px; display: inline-flex; align-items: center; gap: 5px; }
.right .sub .i { width: 14px; height: 14px; }
.dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
.also { margin-top: 12px; font-size: 13px; color: var(--text-3); }
.also button { color: var(--accent-ink); font-weight: 600; }

/* detaljkort (kund, maskin, kortautomat) */
.entity { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.entity-main { flex: 1; min-width: 0; }
.entity-name { font-size: 18px; font-weight: 700; letter-spacing: -.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 4px; }
.entity-side { text-align: right; }
.detail .big { font-size: 26px; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; }
.detail dl { display: grid; grid-template-columns: auto 1fr; gap: 0; margin: 0; }
.detail dt, .detail dd { padding: 7px 0; border-top: 1px solid var(--border); }
.detail dt:first-of-type, .detail dd:first-of-type { border-top: 0; }
.detail dt { color: var(--text-3); font-size: 13px; padding-right: 14px; }
.detail dd { margin: 0; font-weight: 600; font-size: 14px; text-align: right; min-width: 0; }
.detail dl.left dd { text-align: left; }
.cardid { font-family: var(--mono); font-size: 13px; font-weight: 600; letter-spacing: .02em; }
.hist li { display: grid; grid-template-columns: 30px 1fr auto; gap: 2px 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--border); }
.hist .w { min-width: 0; }
.hist .n { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hist .n .muted { font-weight: 500; }
.hist .meta { font-size: 12px; color: var(--text-3); }
.hist .amt { font-weight: 700; font-size: 14px; white-space: nowrap; text-align: right; }
.hist .amt .plus { color: var(--good-ink); }
.hact { display: inline-flex; align-items: center; gap: 4px; margin-top: 5px; padding: 4px 9px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent-ink); font-size: 12px; font-weight: 600; }
.hact .i { width: 13px; height: 13px; }

/* service-läge + kompensation */
.svc { margin-top: 2px; }
.svc-state { display: flex; align-items: center; gap: 8px; font-size: 14px; flex-wrap: wrap; }
.svc-note { margin-top: 8px; padding: 8px 10px; border-radius: var(--r-sm); background: var(--good-soft); color: var(--good-ink); font-size: 13px; font-weight: 500; }
.svc-confirm { margin-top: 10px; padding: 14px; border-radius: 14px; background: var(--surface-2); border: 1px solid var(--border); }
.svc-confirm p { margin: 0 0 10px; font-size: 14px; line-height: 1.45; }
.svc-confirm label { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin: 10px 0 4px; }
.svc-confirm label:first-of-type { margin-top: 0; }
.svc-confirm input { width: 100%; font-size: 16px; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--r-md); background: var(--surface); color: var(--text); }
.svc-confirm input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.svc-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.svc-row .svc-btn { margin-top: 0; }
.svc-err { margin-top: 8px; font-size: 13px; color: var(--critical-ink); font-weight: 500; }

/* QR-skanner */
#scanner { position: fixed; inset: 0; z-index: 40; background: #000; display: none; flex-direction: column; }
#scanner.on { display: flex; }
#scanner video { flex: 1; width: 100%; object-fit: cover; }
#scanner .frame { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
#scanner .frame div { width: 66vw; max-width: 320px; aspect-ratio: 1; border: 2px solid rgba(255, 255, 255, .92); border-radius: 24px; box-shadow: 0 0 0 100vmax rgba(0, 0, 0, .5); }
#scanner .bar { position: relative; z-index: 1; display: flex; justify-content: space-between; align-items: center; gap: 12px; height: auto; border-radius: 0; background: transparent; padding: max(14px, env(safe-area-inset-top)) 18px 14px; color: #fff; font-size: 15px; }
#scanner .bar button { color: #fff; font-size: 15px; font-weight: 600; padding: 6px 12px; border-radius: var(--r-pill); background: rgba(255, 255, 255, .16); }
#scanner .hint { position: absolute; bottom: max(40px, env(safe-area-inset-bottom)); left: 16px; right: 16px; text-align: center; color: #fff; font-size: 14px; text-shadow: 0 1px 3px rgba(0, 0, 0, .6); }

/* ---------- login ---------- */
body.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px 16px; background: radial-gradient(70% 45% at 50% 0%, var(--accent-soft), transparent 70%), var(--bg); }
.login-card { width: 100%; max-width: 360px; background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 32px 24px 24px; text-align: center; box-shadow: var(--shadow-2); animation: rise .4s var(--ease) both; }
.login-card img { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 35%, transparent); }
.login-card h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 16px 0 4px; }
.login-card p { color: var(--text-3); margin: 0 0 22px; font-size: 14px; }
.login-card input { width: 100%; font-size: 28px; letter-spacing: .45em; text-align: center; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface-2); color: var(--text); }
.login-card input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.login-card button { width: 100%; margin-top: 12px; height: 48px; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 600; font-size: 16px; box-shadow: 0 2px 8px color-mix(in srgb, var(--accent) 35%, transparent); transition: transform .15s var(--ease); }
.login-card button:active { transform: scale(.98); }
.login-card .err { color: var(--critical-ink); font-size: 14px; min-height: 20px; margin-top: 12px; }
.login-foot { margin-top: 18px; font-size: 12px; color: var(--text-3); }

/* ---------- gästsidan "Ditt spelkort" (laddakort) – Pitcher's-tema ----------
   Färger/typografi från pitchers.se (2026-09-13): rött #a6192e, crème #efdbb2 / #fff5df, brun text #5e3d38, orange
   accent #f39200, slab-rubriker i versaler, Manrope som brödtext, handskriven accent. Ett enda ljust utseende oavsett
   systemtema (webbplatsen har inget mörkt läge). Typsnitten laddas från Google Fonts i ladda.html med systemreserv. */
body.guest {
  color-scheme: light;
  --p-red: #a6192e; --p-red-dark: #570811; --p-magenta: #cd0046; --p-creme: #efdbb2; --p-creme-light: #fff5df;
  --p-old-lace: #fdf8ea; --p-brown: #5e3d38; --p-orange: #f39200; --p-khaki: #ffea6e;
  --p-body: Manrope, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  --p-head: "Alfa Slab One", "Nexa Slab", Rockwell, "Roboto Slab", Georgia, serif;
  --p-accent: "Just Another Hand", "Bradley Hand", "Segoe Print", cursive;
  --bg: var(--p-old-lace); --text: var(--p-brown); --text-2: var(--p-brown); --text-3: #8a6a63; --accent: var(--p-red); --accent-soft: #f6e3d6;
  background: var(--p-old-lace); color: var(--p-brown); font-family: var(--p-body); font-size: 16px;
  min-height: 100vh; min-height: 100dvh; padding: 0 0 max(28px, env(safe-area-inset-bottom));
}
.guest-hero { background: var(--p-red); color: var(--p-creme); text-align: center; padding: max(22px, env(safe-area-inset-top)) 20px 30px;
  background-image: radial-gradient(90% 70% at 50% 110%, rgba(87, 8, 17, .55), transparent 70%); }
.guest-logo { display: block; width: 150px; height: auto; margin: 0 auto 14px; }
.guest-tag { font-family: var(--p-accent); font-size: 30px; line-height: 1; color: var(--p-orange); transform: rotate(-2deg); margin-bottom: 6px; }
.guest-hero h1 { font-family: var(--p-head); font-weight: 400; font-size: 34px; line-height: 1.05; letter-spacing: .01em; text-transform: uppercase; margin: 0; color: var(--p-creme); }
.guest-venue { margin-top: 8px; font-size: 15px; font-weight: 600; color: var(--p-creme); opacity: .85; }
body.guest main.guest-wrap { max-width: 440px; margin: 0 auto; display: grid; gap: 16px; padding: 18px 16px; grid-template-columns: 1fr; }
.guest-card { background: var(--p-creme-light); color: var(--p-brown); border: 2px solid var(--p-creme); border-radius: 8px; padding: 22px 20px; box-shadow: 0 6px 20px rgba(94, 61, 56, .10); animation: rise .4s var(--ease) both; }
.guest-lead { margin: 0 0 18px; font-size: 16px; line-height: 1.5; text-align: center; }
.gbtn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; height: 56px; padding: 0 16px; border-radius: 6px; font-family: var(--p-body); font-size: 16px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; transition: transform .15s var(--ease), filter .15s; }
.gbtn:active { transform: scale(.98); }
.gbtn:disabled { opacity: .55; transform: none; }
.gbtn .i { width: 22px; height: 22px; }
.gbtn.primary { background: var(--p-red); color: var(--p-orange); box-shadow: 0 3px 10px rgba(166, 25, 46, .35); }
.gbtn.outline { background: transparent; color: var(--p-red); border: 2px solid var(--p-red); height: 52px; }
.guest-manual { margin-top: 18px; }
.guest-manual summary { cursor: pointer; text-align: center; color: var(--p-red); font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; list-style: none; }
.guest-manual summary::-webkit-details-marker { display: none; }
.guest-manual form { display: grid; gap: 10px; margin-top: 14px; }
.guest-manual input { width: 100%; font-size: 17px; padding: 13px 14px; border: 2px solid var(--p-creme); border-radius: 6px; background: #fff; color: var(--p-brown); font-family: var(--mono); letter-spacing: .04em; }
.guest-manual input::placeholder { color: #b39a90; }
.guest-manual input:focus { outline: none; border-color: var(--p-red); box-shadow: 0 0 0 3px rgba(166, 25, 46, .18); }
.guest-error { background: #fbe6e6; border-color: #e9b4b4; color: var(--p-red-dark); font-size: 15px; line-height: 1.5; font-weight: 600; }
.guest-result { text-align: center; }
.guest-label { font-size: 12.5px; font-weight: 800; text-transform: uppercase; letter-spacing: .1em; color: var(--p-red); }
.guest-label .mono { font-family: var(--mono); text-transform: none; letter-spacing: .04em; color: var(--p-brown); }
.guest-balance { display: flex; align-items: baseline; justify-content: center; gap: 10px; margin: 8px 0 2px; }
.guest-balance #balance { font-family: var(--p-head); font-weight: 400; font-size: 72px; line-height: 1; color: var(--p-red); }
.guest-unit { font-size: 18px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--p-brown); }
.guest-tickets { margin-top: 6px; font-size: 14px; font-weight: 600; color: #8a6a63; }
.guest-inactive { margin: 14px 0 0; padding: 12px 14px; border-radius: 6px; background: var(--p-khaki); color: var(--p-brown); font-size: 14px; line-height: 1.5; text-align: left; }
.guest-result h2 { font-family: var(--p-head); font-weight: 400; font-size: 20px; text-transform: uppercase; letter-spacing: .02em; color: var(--p-red); text-align: left; margin: 22px 0 6px; padding-top: 18px; border-top: 2px solid var(--p-creme); }
.guest-load { margin: 0 0 16px; font-size: 15px; line-height: 1.5; text-align: left; }
.guest-foot { text-align: center; font-size: 12.5px; color: #8a6a63; padding: 4px 8px; }
body.guest #scanner .bar { font-family: var(--p-body); }
body.guest #scanner .hint { bottom: calc(max(24px, env(safe-area-inset-bottom)) + 76px); }
body.guest #scanner .cancel { position: absolute; left: 20px; right: 20px; bottom: max(24px, env(safe-area-inset-bottom)); width: auto; z-index: 1; background: var(--p-creme-light); color: var(--p-red); border: 2px solid var(--p-creme); box-shadow: 0 4px 16px rgba(0, 0, 0, .4); }

@media (prefers-reduced-motion: reduce) {
  .card, .login-card { animation: none; }
  .live-dot, .skeleton { animation: none; }
  .chip, .icon-btn, .btn, .svc-btn { transition: none; }
}
