/* Kassensturz — Layout: one narrow phone column, set like a Kassenbon.
   Amounts live in a right-aligned mono rail; a solid rule means a total
   follows; a dotted rule is a tear-line between sections. The shopping
   list is the deliberate opposite: airy, big targets, one thumb. */
:root {
  --paper:   #EEF0EA;   /* cool receipt stock, not cream */
  --card:    #F8F9F5;
  --ink:     #22302C;   /* faded thermal print */
  --dim:     #6A7A70;
  --rule:    #CBD2C6;
  --plus:    #1E6B4B;   /* money comes back */
  --minus:   #A6372B;   /* money owed */
  --mark:    #E6C34A;   /* price-label yellow, used sparingly */

  --ui:   "Familjen Grotesk", "Segoe UI", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, monospace;

  --col: 33rem;
  --tap: 3.25rem;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #141A17; --card: #1D2521; --ink: #E5EADF; --dim: #8C9B91;
    --rule: #303D37; --plus: #63C492; --minus: #E5836F; --mark: #D4B243;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #141A17; --card: #1D2521; --ink: #E5EADF; --dim: #8C9B91;
  --rule: #303D37; --plus: #63C492; --minus: #E5836F; --mark: #D4B243;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink);
  font-family: var(--ui); font-size: 1rem; line-height: 1.45;
  -webkit-text-size-adjust: 100%; overflow-wrap: break-word;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* ---------- frame ---------- */
#app { min-height: 100%; display: flex; flex-direction: column; }
.screen {
  flex: 1; width: 100%; max-width: var(--col); margin: 0 auto;
  padding: 1rem 1.1rem calc(5.5rem + env(safe-area-inset-bottom, 0px));
}
.bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20;
  background: var(--card); border-top: 1px solid var(--rule);
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: grid; grid-template-columns: repeat(4, 1fr);
}
.bar button {
  padding: .55rem .25rem .7rem; color: var(--dim);
  font-size: .78rem; font-weight: 500; letter-spacing: .01em;
  display: flex; flex-direction: column; align-items: center; gap: .18rem;
}
.bar button[aria-current="page"] { color: var(--ink); }
.bar svg { width: 1.3rem; height: 1.3rem; fill: none; stroke: currentColor; stroke-width: 1.6; }

/* ---------- headings ---------- */
.head { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; margin-bottom: 1.1rem; }
h1 { font-size: 1.6rem; font-weight: 600; letter-spacing: -.02em; margin: 0; text-wrap: balance; }
h2 { font-size: 1rem; font-weight: 600; margin: 0; }
.count { font-family: var(--mono); font-size: .85rem; color: var(--dim); white-space: nowrap; }
.back { display: inline-flex; align-items: center; gap: .35rem; color: var(--dim); font-weight: 500; padding: .4rem .5rem .4rem 0; margin-bottom: .4rem; }
.back svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; }

/* ---------- receipt grammar ---------- */
.tear { border: 0; border-top: 1px dashed var(--rule); margin: 1.4rem 0; }
.sum  { border: 0; border-top: 1px solid var(--ink); margin: .7rem 0 .55rem; }
.row { display: grid; grid-template-columns: 1fr auto; gap: .5rem 1rem; align-items: baseline; }
.amt { font-family: var(--mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.neg { color: var(--minus); }
.plus { color: var(--plus); }

/* ---------- shopping list ---------- */
.add { display: flex; gap: .5rem; margin-bottom: 1.4rem; }
.add input {
  flex: 1; min-width: 0; background: var(--card); border: 1px solid var(--rule);
  border-radius: .55rem; padding: .8rem .9rem;
}
.add input::placeholder { color: var(--dim); }
.add button {
  background: var(--ink); color: var(--paper); border-radius: .55rem;
  padding: 0 1.1rem; font-weight: 600;
}
.group { margin-bottom: 1.5rem; }
.group h2 { color: var(--dim); font-size: .85rem; font-weight: 600; padding-bottom: .4rem; border-bottom: 1px solid var(--rule); }
.item {
  display: flex; align-items: center; gap: .85rem; width: 100%;
  min-height: var(--tap); padding: .3rem 0; text-align: left;
  border-bottom: 1px solid color-mix(in srgb, var(--rule) 45%, transparent);
}
.tick {
  flex: none; width: 1.45rem; height: 1.45rem; border: 1.5px solid var(--rule);
  border-radius: 50%; display: grid; place-items: center;
}
.tick svg { width: .85rem; height: .85rem; fill: none; stroke: var(--paper); stroke-width: 2.5; opacity: 0; }
.item[data-done="1"] .tick { background: var(--ink); border-color: var(--ink); }
.item[data-done="1"] .tick svg { opacity: 1; }
.item[data-done="1"] .label { color: var(--dim); text-decoration: line-through; }
.label { flex: 1; min-width: 0; }
.qty { font-family: var(--mono); font-size: .9rem; color: var(--dim); }
.strip { display: flex; gap: .45rem; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--rule); border-radius: 1rem; padding: .3rem .75rem;
  font-size: .85rem; font-weight: 500; color: var(--dim); background: var(--card);
}
.chip[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }

/* ---------- bon list ---------- */
.bon { display: block; width: 100%; text-align: left; padding: .85rem 0; border-bottom: 1px solid var(--rule); }
.bon .shop { font-weight: 600; }
.bon .meta { color: var(--dim); font-size: .88rem; }
.flag {
  display: inline-block; font-size: .72rem; font-weight: 600; padding: .05rem .4rem;
  border-radius: .25rem; background: var(--mark); color: #22302C; margin-left: .4rem;
}
.flag[data-kind="import"] { background: transparent; color: var(--dim); border: 1px solid var(--rule); }
.flag[data-kind="doppel"] { background: var(--minus); color: var(--paper); }

/* ---------- bon detail ---------- */
.shopname { font-size: 1.75rem; font-weight: 700; letter-spacing: -.025em; margin: 0; }
.when { color: var(--dim); margin: .1rem 0 1.2rem; }
.payer { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
select.pick {
  background: var(--card); border: 1px solid var(--rule); border-radius: .5rem;
  padding: .5rem .7rem; font-weight: 500; max-width: 60%;
}
.line { padding: .55rem 0; border-bottom: 1px solid color-mix(in srgb, var(--rule) 45%, transparent); }
.line .raw { font-family: var(--mono); font-size: .78rem; color: var(--dim); }
.who {
  font-size: .78rem; color: var(--dim); font-weight: 500; margin-top: .25rem;
  border: 1px solid var(--rule); border-radius: 1rem; padding: .15rem .6rem; background: var(--card);
}
.who[data-own="1"] { color: var(--paper); background: var(--ink); border-color: var(--ink); }
.total { font-size: 1.15rem; font-weight: 600; }
.note { background: var(--card); border-left: 2px solid var(--mark); padding: .6rem .8rem; font-size: .9rem; margin: 1rem 0; }
.warn {
  background: color-mix(in srgb, var(--minus) 10%, transparent);
  border-left: 2px solid var(--minus); padding: .7rem .85rem; font-size: .9rem; margin: 1rem 0;
}
.warn strong { display: block; margin-bottom: .15rem; }
.amt.aus { color: var(--dim); text-decoration: line-through; }
.gewaehlt { font-size: .9rem; color: var(--dim); margin: .9rem 0 1.2rem; }
.gewaehlt strong { color: var(--ink); font-weight: 500; }

/* ---------- saldo ---------- */
.verdict { padding: .5rem 0 1.6rem; }
.verdict p { margin: 0; color: var(--dim); }
.big {
  font-family: var(--mono); font-variant-numeric: tabular-nums;
  font-size: clamp(3rem, 18vw, 4.5rem); line-height: 1; font-weight: 500;
  letter-spacing: -.03em; margin: .3rem 0; display: block;
}
.btn {
  display: block; width: 100%; background: var(--ink); color: var(--paper);
  border-radius: .6rem; padding: .95rem; font-weight: 600; text-align: center;
}
.btn.ghost { background: none; border: 1px solid var(--rule); color: var(--ink); }
.btn + .btn, .btn + input[hidden] + .btn { margin-top: .6rem; }
label.btn { cursor: pointer; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.led { display: grid; grid-template-columns: 1fr auto; gap: .35rem 1rem; }
.led span:nth-child(odd) { color: var(--dim); }

/* ---------- forms, upload, misc ---------- */
.field { display: block; margin-bottom: 1rem; }
.field span { display: block; font-size: .85rem; color: var(--dim); margin-bottom: .3rem; }
.field input, .field select, .field textarea {
  width: 100%; background: var(--card); border: 1px solid var(--rule);
  border-radius: .55rem; padding: .75rem .85rem;
}
.drop {
  border: 1.5px dashed var(--rule); border-radius: .8rem; padding: 2rem 1rem;
  text-align: center; color: var(--dim); background: var(--card);
}
.drop strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .2rem; }
.empty { color: var(--dim); padding: 2.5rem 0; text-align: center; }
.empty strong { display: block; color: var(--ink); font-size: 1.05rem; margin-bottom: .25rem; }
.err { background: color-mix(in srgb, var(--minus) 12%, transparent); border-left: 2px solid var(--minus); padding: .6rem .8rem; font-size: .9rem; margin-bottom: 1rem; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 40;
  bottom: calc(5rem + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: .6rem 1rem;
  border-radius: 2rem; font-size: .9rem; font-weight: 500; max-width: 90vw;
}
.banner { background: var(--mark); color: #22302C; text-align: center; padding: .4rem; font-size: .85rem; font-weight: 600; }

/* ---------- login ---------- */
.login { max-width: 22rem; margin: 0 auto; padding: 3rem 0 2rem; }
.wordmark { font-size: 2.1rem; font-weight: 700; letter-spacing: -.035em; margin: 0 0 .15rem; }
.tagline { color: var(--dim); margin: 0 0 2rem; }
.spin { display: inline-block; width: .9rem; height: .9rem; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: s .7s linear infinite; vertical-align: -.1em; }
@keyframes s { to { transform: rotate(360deg); } }
