/* Boka – stilar. Alla färger som variabler (RV-17). */
:root {
  --bg: #F6F7F9; --fg: #14161A; --muted: #5B6270; --card: #FFFFFF; --border: #E3E6EB; --line: #EEF1F5;
  --field: #FFFFFF; --field-border: #C9CED6; --soft: #EEF1F5;
  --accent: #2B54D9; --on-accent: #FFFFFF; --accent-soft: #E8EEFC; --accent-fg: #1E3FA8;
  --danger: #B42318; --on-danger: #FFFFFF; --danger-soft: #FDECEC;
  --ok: #0B6B3A; --ok-soft: #E3F4EC; --ok-dot: #0B8A4C;
  --wait: #9A4A06; --wait-soft: #FDF0E1; --wait-dot: #C2610C; --wait-border: #F2D3AE;
  --shadow: 0 1px 2px rgba(0,0,0,.06);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0F1115; --fg: #ECEEF2; --muted: #A2A9B6; --card: #181B21; --border: #2A2F38; --line: #23272F;
    --field: #12151A; --field-border: #3A404B; --soft: #23272F;
    --accent: #7D9BFF; --on-accent: #0B1020; --accent-soft: #1E2843; --accent-fg: #B9C8FF;
    --danger: #FF8A80; --on-danger: #2A0805; --danger-soft: #3A1714;
    --ok: #7BD8A6; --ok-soft: #143225; --ok-dot: #4CC384;
    --wait: #F5B36B; --wait-soft: #3A2510; --wait-dot: #F08A2E; --wait-border: #5A3A17;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0F1115; --fg: #ECEEF2; --muted: #A2A9B6; --card: #181B21; --border: #2A2F38; --line: #23272F;
  --field: #12151A; --field-border: #3A404B; --soft: #23272F;
  --accent: #7D9BFF; --on-accent: #0B1020; --accent-soft: #1E2843; --accent-fg: #B9C8FF;
  --danger: #FF8A80; --on-danger: #2A0805; --danger-soft: #3A1714;
  --ok: #7BD8A6; --ok-soft: #143225; --ok-dot: #4CC384;
  --wait: #F5B36B; --wait-soft: #3A2510; --wait-dot: #F08A2E; --wait-border: #5A3A17;
  color-scheme: dark;
}
:root[data-variant="test"] { --accent: #7C3AED; --accent-soft: #F1E9FE; --accent-fg: #5B21B6; }

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body { font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, Inter, sans-serif; -webkit-text-size-adjust: 100%; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.boot { display: grid; place-items: center; height: 100dvh; font-size: 28px; font-weight: 700; color: var(--muted); }

.screen { max-width: 560px; margin: 0 auto; min-height: 100dvh; display: flex; flex-direction: column; padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
.screen.plain { padding-bottom: 24px; }
.top { padding: calc(16px + env(safe-area-inset-top)) 20px 10px; display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.top .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
h1 { margin: 0; font-size: 24px; font-weight: 700; }
h2 { margin: 0; font-size: 17px; font-weight: 700; }
.sub { font-size: 13px; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 12px; padding: 0 16px; }
.row { display: flex; align-items: center; gap: 10px; }
.grow { flex: 1; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; box-shadow: var(--shadow); }
.card.flush { padding: 0; gap: 0; }
.card.warn { background: var(--wait-soft); border-color: var(--wait-border); color: var(--wait); }
.card.bad { background: var(--danger-soft); border-color: var(--danger); color: var(--danger); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 16px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 16px; text-decoration: none; cursor: pointer; }
.btn[disabled] { opacity: .45; cursor: default; }
.btn.ghost { background: var(--card); color: var(--fg); border: 1px solid var(--field-border); }
.btn.danger { background: var(--danger); color: var(--on-danger); }
.btn.danger-ghost { background: var(--card); color: var(--danger); border: 1px solid var(--danger); }
.btn.sm { min-height: 40px; padding: 0 12px; font-size: 14px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn.yes { background: var(--ok-soft); color: var(--ok); border: 2px solid var(--ok-dot); }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 600; min-height: 44px; padding: 0 6px; cursor: pointer; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 1px solid var(--border); background: var(--card); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--fg); }
.icon-btn.bare { border: 0; background: transparent; }
.icon-btn[disabled] { opacity: .35; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

.field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
.field input, .field select, .field textarea, input.in { height: 46px; padding: 0 12px; border: 1px solid var(--field-border); border-radius: 10px; background: var(--field); color: var(--fg); font-size: 16px; font-weight: 400; min-width: 0; width: 100%; }
.field textarea { height: auto; min-height: 90px; padding: 10px 12px; resize: vertical; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.err { color: var(--danger); font-size: 14px; }

.pin { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.pin input { height: 56px; text-align: center; font-size: 24px; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); color: var(--fg); -webkit-text-security: disc; }

.seg { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); gap: 4px; background: var(--soft); border-radius: 12px; padding: 4px; }
.seg button { min-height: 40px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font-size: 14px; cursor: pointer; position: relative; }
.seg button.on { background: var(--card); color: var(--fg); font-weight: 600; box-shadow: var(--shadow); }

.chip { min-height: 36px; padding: 0 12px; border-radius: 999px; border: 1px solid var(--field-border); background: var(--card); color: var(--muted); font-size: 13px; font-weight: 600; cursor: pointer; }
.chip.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent-fg); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { font-size: 12px; font-weight: 600; padding: 5px 10px; border-radius: 999px; white-space: nowrap; }
.pill.in { background: var(--ok-soft); color: var(--ok); }
.pill.wait { background: var(--wait-soft); color: var(--wait); }
.pill.dark { background: var(--fg); color: var(--bg); letter-spacing: .04em; }
.name { font-size: 14px; padding: 6px 12px; border-radius: 999px; background: var(--soft); }
.name.me { background: var(--ok-soft); color: var(--ok); font-weight: 600; }

.cal { margin: 0 16px; background: var(--card); border: 1px solid var(--border); border-radius: 16px; padding: 10px; }
.cal .wd, .cal .days { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.cal .wd { font-size: 12px; color: var(--muted); font-weight: 600; padding-bottom: 4px; }
.cal .day { height: 44px; border: 0; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; cursor: pointer; color: var(--fg); padding: 0; }
.cal .day span.n { width: 30px; height: 30px; line-height: 30px; border-radius: 999px; font-size: 15px; }
.cal .day.today span.n { box-shadow: inset 0 0 0 1.5px var(--accent); font-weight: 600; }
.cal .day.sel span.n { background: var(--accent); color: var(--on-accent); font-weight: 700; }
.cal .day.off { visibility: hidden; }
.cal .day.past span.n { color: var(--muted); }
.dots { display: flex; gap: 2px; height: 6px; }
.dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.dot.in { background: var(--ok-dot); } .dot.wait { background: var(--wait-dot); }
.legend { display: flex; gap: 14px; justify-content: center; font-size: 12px; color: var(--muted); padding: 8px 0 0; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }

.occ { display: flex; gap: 12px; align-items: center; text-align: left; width: 100%; background: var(--card); border: 1px solid var(--border); border-radius: 14px; padding: 14px; cursor: pointer; color: var(--fg); }
.occ .tm { width: 52px; text-align: center; font-weight: 700; font-size: 15px; }
.occ .tm small { display: block; font-weight: 400; font-size: 12px; color: var(--muted); }
.occ .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.occ .what b { font-size: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.bar { height: 10px; border-radius: 999px; background: var(--soft); overflow: hidden; }
.bar > div { height: 100%; background: var(--accent); }
.queue { display: flex; gap: 16px; align-items: center; }
.queue .num { width: 72px; height: 72px; border-radius: 999px; background: var(--card); border: 2px solid var(--wait-dot); display: flex; flex-direction: column; align-items: center; justify-content: center; flex-shrink: 0; color: var(--wait); }
.queue .num b { font-size: 28px; line-height: 1; }

.list .li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); min-height: 60px; }
.list .li:first-child { border-top: 0; }
.list .li .grow { display: flex; flex-direction: column; gap: 2px; }
.list .li .grow b { font-size: 15px; }
.link-row { display: flex; justify-content: space-between; align-items: center; width: 100%; padding: 14px 16px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--fg); font-size: 15px; text-align: left; cursor: pointer; min-height: 52px; }
.link-row:first-child { border-top: 0; }
.reddot { width: 9px; height: 9px; border-radius: 999px; background: var(--danger); display: inline-block; }

.switch { width: 52px; height: 32px; border-radius: 999px; border: 0; background: var(--field-border); position: relative; flex-shrink: 0; cursor: pointer; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 999px; background: #fff; transition: left .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { left: 23px; }

.tabbar { position: fixed; left: 0; right: 0; bottom: 0; background: var(--card); border-top: 1px solid var(--border); padding: 6px 8px calc(8px + env(safe-area-inset-bottom)); display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); z-index: 5; }
.tabbar button { border: 0; background: none; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 6px; font-size: 12px; color: var(--muted); cursor: pointer; position: relative; min-height: 52px; }
.tabbar button.on { color: var(--accent); font-weight: 600; }
.tabbar .reddot { position: absolute; top: 6px; left: calc(50% + 8px); }

.codebox { display: flex; align-items: center; gap: 10px; }
.codelabel { font-size: 13px; font-weight: 600; padding: 8px 12px; border-radius: 10px; background: var(--soft); flex-shrink: 0; }
.codefield { flex: 1; display: flex; align-items: center; gap: 4px; height: 46px; padding: 0 12px; border: 1px solid var(--field-border); border-radius: 12px; background: var(--field); font-size: 17px; letter-spacing: .06em; min-width: 0; }
.codefield .pre, .codefield .dash { color: var(--muted); }
.codefield input { width: 4.4em; border: 0; border-bottom: 1px solid var(--line); background: transparent; padding: 2px 0; letter-spacing: inherit; text-transform: uppercase; min-width: 0; }
.codefield input:focus { outline: none; border-bottom-color: var(--accent); }

#layer .backdrop { position: fixed; inset: 0; background: rgba(10,12,16,.55); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
#layer .sheet { background: var(--card); width: 100%; max-width: 560px; max-height: 92dvh; overflow-y: auto; border-radius: 22px 22px 0 0; padding: 10px 20px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 14px; }
#layer .grab { width: 40px; height: 5px; border-radius: 999px; background: var(--field-border); align-self: center; }
#layer .center { align-items: center; padding: 24px; }
#layer .dialog { background: var(--card); width: 100%; max-width: 380px; border-radius: 18px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.bubble { align-self: flex-start; max-width: 92%; background: var(--accent-soft); color: var(--fg); border-radius: 18px 18px 18px 4px; padding: 12px 14px; font-size: 15px; white-space: pre-wrap; }
.bigpin { font-size: 30px; font-weight: 700; letter-spacing: .18em; }

#toast { position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--bg); padding: 10px 16px; border-radius: 12px; font-size: 14px; z-index: 40; opacity: 0; pointer-events: none; transition: opacity .2s; max-width: 90vw; display: flex; gap: 12px; align-items: center; }
#toast.show { opacity: 1; pointer-events: auto; }
#toast button { background: none; border: 0; color: var(--bg); font-weight: 700; text-decoration: underline; min-height: 32px; cursor: pointer; }
.demo-band { background: var(--wait-soft); color: var(--wait); font-size: 13px; font-weight: 600; padding: 8px 16px; display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.demo-band button { min-height: 32px; }
.version { text-align: center; font-size: 12px; color: var(--muted); background: none; border: 0; min-height: 32px; cursor: default; user-select: none; }
.empty { text-align: center; color: var(--muted); font-size: 14px; padding: 18px; }
