/* Attestindera: phone-first (375 px), Autobok's green, dark by default and light when the phone asks for it.
   Every dynamic style comes from app.js through the CSSOM (custom properties and classes): the CSP allows no
   style attributes. The Deck turns the page into a fixed stage (html.deck) so nothing scrolls or pulls to refresh. */

:root {
  color-scheme: dark;
  --bg: #0e1311;
  --panel: #151b18;
  --panel-2: #1a2320;
  --panel-3: #202b26;
  --line: #253029;
  --line-2: #33403a;
  --text: #e4ebe6;
  --muted: #8e9b94;
  --accent: #3fbf84;
  --accent-ink: #06140d;
  --accent-soft: #163024;
  --ok: #5fd39a;
  --ok-soft: #163326;
  --warn: #f0b955;
  --warn-soft: #362b14;
  --bad: #ff8a80;
  --bad-soft: #3a1c1a;
  --info: #8fb8ee;
  --info-soft: #1a2a3d;
  --shadow: 0 12px 32px rgba(0, 0, 0, .45);
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
}
@media (prefers-color-scheme: light) {
  :root {
    color-scheme: light;
    --bg: #f3f5f1;
    --panel: #ffffff;
    --panel-2: #f6f8f4;
    --panel-3: #eef1ec;
    --line: #e1e5de;
    --line-2: #cdd3ca;
    --text: #1b2420;
    --muted: #66716b;
    --accent: #0f6b45;
    --accent-ink: #ffffff;
    --accent-soft: #e3f1ea;
    --ok: #1d7a4b;
    --ok-soft: #e1f3e8;
    --warn: #9a6200;
    --warn-soft: #fbf0d9;
    --bad: #b3261e;
    --bad-soft: #fbe6e4;
    --info: #285e9b;
    --info-soft: #e5eef9;
    --shadow: 0 10px 28px rgba(20, 30, 25, .18);
  }
}

* { box-sizing: border-box; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 16px/1.4 var(--font); color: var(--text); background: var(--bg); min-height: 100dvh; -webkit-tap-highlight-color: transparent; }
html.deck, html.deck body { height: 100dvh; overflow: hidden; overscroll-behavior: none; }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; }
h2 { font-size: 20px; }
p { margin: 0; }
a { color: var(--accent); }
button { font: inherit; color: inherit; }
img { max-width: 100%; }
.noscript { padding: 40px 20px; text-align: center; }

/* ---------------------------------------------------------------- screens (scrolling, centred) */
.app { min-height: 100dvh; display: flex; flex-direction: column; }
.screen { flex: 1; width: 100%; max-width: 480px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px;
  padding: calc(20px + var(--sat)) calc(20px + var(--sar)) calc(28px + var(--sab)) calc(20px + var(--sal)); }
.screen.center { justify-content: center; text-align: center; align-items: center; }
.hero { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.hero img { width: 88px; height: 88px; border-radius: 22px; }
.hero .app-name { font-size: 13px; color: var(--muted); letter-spacing: .08em; text-transform: uppercase; }
.lead { font-size: 18px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.stack { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.spacer { flex: 1; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.topbar h1 { font-size: 22px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 10px 18px; border-radius: 12px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--text); cursor: pointer; text-decoration: none; font-weight: 600; }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.big { width: 100%; min-height: 56px; font-size: 19px; border-radius: 16px; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--accent); }
.btn.link { background: none; border: 0; color: var(--accent); min-height: 0; padding: 6px 4px; font-weight: 500; text-decoration: underline; }
.btn.danger { color: var(--bad); border-color: var(--bad); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.wide { width: 100%; }

.field { display: flex; flex-direction: column; gap: 6px; text-align: left; width: 100%; }
.field > span { font-size: 13px; color: var(--muted); }
input, textarea { font: inherit; color: var(--text); background: var(--panel); border: 1px solid var(--line-2); border-radius: 12px; padding: 12px 14px;
  width: 100%; min-height: 48px; font-size: 17px; }
input:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 96px; resize: vertical; }
input.code { font-family: var(--mono); letter-spacing: .08em; text-transform: uppercase; }
.note { padding: 12px 14px; border-radius: 12px; font-size: 15px; text-align: left; width: 100%; }
.note.bad { background: var(--bad-soft); color: var(--bad); }
.note.warn { background: var(--warn-soft); color: var(--warn); }
.note.ok { background: var(--ok-soft); color: var(--ok); }
.note.info { background: var(--info-soft); color: var(--info); }
.steps { text-align: left; padding-left: 20px; margin: 0; display: flex; flex-direction: column; gap: 6px; }
.spinner { width: 34px; height: 34px; border-radius: 50%; border: 3px solid var(--line-2); border-top-color: var(--accent); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.big-emoji { font-size: 56px; line-height: 1; }

/* ---------------------------------------------------------------- deck: the fixed stage */
.deck { height: 100dvh; display: flex; flex-direction: column; width: 100%; max-width: 560px; margin: 0 auto; }
.deck-head { display: flex; align-items: center; gap: 12px; padding: calc(10px + var(--sat)) calc(16px + var(--sar)) 8px calc(16px + var(--sal)); min-height: 44px; }
.deck-head .co { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; }
.deck-head .co img { height: 32px; max-width: 150px; object-fit: contain; border-radius: 6px; }
.deck-head .co-name { font-weight: 700; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.deck-head .left { color: var(--muted); font-size: 14px; white-space: nowrap; }
.icons { display: flex; gap: 2px; }
.icon-btn { width: 44px; height: 44px; border-radius: 12px; border: 0; background: transparent; color: var(--muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn:active { background: var(--panel-2); }
.icon-btn svg { width: 24px; height: 24px; }
.icon-btn[aria-current="page"] { color: var(--accent); }

.stage { flex: 1; min-height: 0; position: relative; padding: 4px 28px 10px; }
.card { position: relative; height: 100%; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: 22px;
  overflow: hidden; box-shadow: var(--shadow); touch-action: none; user-select: none; -webkit-user-select: none; cursor: grab;
  transition: transform .22s ease, opacity .22s ease; --ja: 0; --nej: 0; --andra: 0; }
.card.drag { transition: none; cursor: grabbing; }
.card.out-right { transform: translate(130%, 0) rotate(18deg); opacity: 0; }
.card.out-left { transform: translate(-130%, 0) rotate(-18deg); opacity: 0; }
.card.out-down { transform: translate(0, 110%) scale(.9); opacity: 0; }
.card .info { padding: 16px 18px 12px; display: flex; flex-direction: column; gap: 4px; }
.card .vendor { font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.card .total { font-size: 32px; font-weight: 800; letter-spacing: -.01em; }
.card .total.neg { color: var(--bad); }
.fields { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 2px 14px; margin: 6px 0 0; font-size: 15px; }
.fields dt { color: var(--muted); }
.fields dd { margin: 0; overflow-wrap: anywhere; font-variant-numeric: tabular-nums; }
.card .page { flex: 1; min-height: 0; background: var(--panel-2); border-top: 1px solid var(--line); display: flex; align-items: center; justify-content: center; position: relative; }
.card .page img { width: 100%; height: 100%; object-fit: contain; pointer-events: none; -webkit-touch-callout: none; display: block; }
.card .page .hint { position: absolute; bottom: 10px; right: 12px; font-size: 12px; color: var(--muted); background: var(--panel); padding: 3px 8px; border-radius: 999px; opacity: .85; }
.stamp { position: absolute; top: 18px; font-size: 34px; font-weight: 900; letter-spacing: .12em; padding: 4px 14px; border: 4px solid currentColor; border-radius: 12px;
  pointer-events: none; opacity: 0; background: var(--panel); }
.stamp.ja { left: 16px; color: var(--ok); transform: rotate(-14deg); opacity: var(--ja); }
.stamp.nej { right: 16px; color: var(--bad); transform: rotate(14deg); opacity: var(--nej); }
.stamp.andra { left: 50%; top: 42%; color: var(--warn); transform: translate(-50%, -50%) rotate(-6deg); opacity: var(--andra); }

.actions { display: flex; align-items: center; justify-content: center; gap: 28px; padding: 10px 0 calc(14px + var(--sab)); }
.round { width: 64px; height: 64px; border-radius: 50%; border: 2px solid currentColor; background: var(--panel); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: var(--shadow); }
.round svg { width: 30px; height: 30px; }
.round:active { transform: scale(.94); }
.round.no { color: var(--bad); }
.round.edit { color: var(--warn); width: 52px; height: 52px; }
.round.edit svg { width: 24px; height: 24px; }
.round.yes { color: var(--ok); }
.round:disabled { opacity: .4; }

/* ---------------------------------------------------------------- the Ändra sheet */
.sheet { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet .panel { width: 100%; max-width: 560px; max-height: 94dvh; overflow: auto; -webkit-overflow-scrolling: touch; background: var(--bg); border-radius: 22px 22px 0 0;
  padding: 14px 20px calc(20px + var(--sab)); display: flex; flex-direction: column; gap: 12px; }
.sheet .grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-2); margin: 0 auto 4px; }
.sheet .row { display: flex; flex-direction: column; gap: 6px; }
.sheet .row > span { font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.sheet .row .was { font-family: var(--mono); font-size: 12px; }
.amount { display: flex; gap: 8px; }
.amount input { flex: 1; min-width: 0; font-variant-numeric: tabular-nums; }
.amount .sign { width: 52px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--panel); font-size: 20px; cursor: pointer; }
.sheet .buttons { display: flex; gap: 10px; margin-top: 4px; }
.sheet .buttons .btn { flex: 1; }
.problems { display: flex; flex-direction: column; gap: 4px; }
input[aria-invalid="true"] { border-color: var(--bad); }

/* ---------------------------------------------------------------- the viewer */
.viewer { position: fixed; inset: 0; background: #000; z-index: 30; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.viewer .strip { position: absolute; left: 0; top: 0; width: 100%; transform-origin: 0 0; will-change: transform; display: flex; flex-direction: column; gap: 6px; }
.viewer .pg { width: 100%; background: #fff; }
.viewer .pg img { width: 100%; height: 100%; display: block; pointer-events: none; -webkit-touch-callout: none; }
.viewer .close { position: absolute; top: calc(8px + var(--sat)); right: calc(8px + var(--sar)); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(20, 20, 20, .7); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; z-index: 2; }
.viewer .close svg { width: 22px; height: 22px; }
.viewer .count { position: absolute; left: 50%; transform: translateX(-50%); top: calc(16px + var(--sat)); color: #fff; background: rgba(20, 20, 20, .7); padding: 4px 12px; border-radius: 999px; font-size: 13px; pointer-events: none; z-index: 2; }

/* ---------------------------------------------------------------- nej step, done, history, account */
.summary { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-align: left; width: 100%; display: flex; flex-direction: column; gap: 2px; }
.summary .total { font-size: 24px; font-weight: 800; }
.chips { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.chip { text-align: left; border: 1px solid var(--line-2); background: var(--panel); border-radius: 14px; padding: 10px 14px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.chip b { font-weight: 600; }
.chip small { color: var(--muted); font-size: 13px; }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.list { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; text-align: left; }
.item .head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.item .amount-txt { font-weight: 700; white-space: nowrap; }
.status { display: inline-block; font-size: 12px; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.status.ok { background: var(--ok-soft); color: var(--ok); }
.status.bad { background: var(--bad-soft); color: var(--bad); }
.status.reg { background: var(--info-soft); color: var(--info); }
.status.warn { background: var(--warn-soft); color: var(--warn); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 14px; width: 100%; text-align: left; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }

/* ---------------------------------------------------------------- bars: toast, offline, update */
/* on the scrolling screens a snackbar at the bottom, above the safe area (the titles and icons at the top stay readable) */
.bars { position: fixed; left: 0; right: 0; bottom: calc(12px + var(--sab)); display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; z-index: 40; padding: 0 16px; }
.toast { pointer-events: auto; display: flex; align-items: center; justify-content: center; gap: 14px; width: 100%; max-width: 440px; min-height: 48px; background: var(--text); color: var(--bg); padding: 8px 16px; border-radius: 14px; box-shadow: var(--shadow); animation: appear .18s ease-out; }
.toast .btn { min-height: 36px; padding: 6px 12px; background: transparent; border-color: transparent; color: var(--accent); font-weight: 700; }
@media (prefers-color-scheme: light) { .toast .btn { color: #7fe3b4; } }
.banner { pointer-events: auto; display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 12px; font-size: 14px; }
.banner.offline { background: var(--warn-soft); color: var(--warn); }
.banner.update { background: var(--info-soft); color: var(--info); }
.banner .btn { min-height: 34px; padding: 4px 12px; }
/* on the deck the toast takes the header's place for its 5 s (the card stays visible and swipeable under it) instead of
   straddling the count and the icons; the banners keep their gutter */
html.deck .bars { top: var(--sat); bottom: auto; padding: 0; }
html.deck .banner { margin: 8px 16px 0; }
html.deck .toast { max-width: 560px; min-height: 56px; border-radius: 0 0 16px 16px; }
/* one animation for both places: a changed animation-name would replay it when the deck gives way to the next screen */
@keyframes appear { from { opacity: 0; } }
