/* Palettenkonto – große Flächen, klare Wörter, wenig Ablenkung */

:root {
  --bg: #ffffff;
  --soft: #f3f4f6;      /* leichte Flächen auf Weiß */
  --surface: #ffffff;
  --ink: #1c1d1f;
  --muted: #5f6368;
  --line: #d3d7dd;
  --primary: #1f3a5f;
  --primary-ink: #ffffff;
  --primary-soft: #e6ecf4;
  --plus: #17703f;      /* Spedition schuldet uns */
  --plus-soft: #e3f2e8;
  --minus: #a24a06;     /* wir schulden */
  --minus-soft: #fbeedd;
  --danger: #b3261e;
  --radius: 16px;
  --tap: 60px;
  --pad: clamp(16px, 4vw, 32px);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
  line-height: 1.4;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

* { box-sizing: border-box; }
body { margin: 0; min-height: 100dvh; background: var(--bg); }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app {
  max-width: 820px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) var(--pad) calc(env(safe-area-inset-bottom, 0px) + 140px);
}

.loading { padding: 40vh 0; text-align: center; color: var(--muted); }

/* ---------- Kopfzeile ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 56px; margin-bottom: 8px;
}
.topbar .brand { font-weight: 700; font-size: 1.05rem; }
.topbar .who { color: var(--muted); font-size: .95rem; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.link-btn {
  background: none; border: 0; padding: 10px 12px; min-height: 48px;
  color: var(--primary); font-weight: 600; border-radius: 12px;
}
.link-btn:active { background: var(--primary-soft); }
.link-btn.danger { color: var(--danger); }

.back {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 10px 4px; min-height: 48px;
  color: var(--primary); font-weight: 600; font-size: 1.05rem;
}

/* ---------- Überschriften ---------- */
.title { font-size: clamp(1.75rem, 4.5vw, 2.25rem); line-height: 1.15; font-weight: 750; letter-spacing: -.01em; }
.subtitle { color: var(--muted); margin-top: 6px; }
.section-title { font-size: 1.1rem; font-weight: 700; margin: 28px 0 10px; }

/* ---------- Knöpfe ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: var(--tap); padding: 0 24px;
  border: 0; border-radius: var(--radius);
  font-weight: 700; font-size: 1.1rem;
  background: var(--primary); color: var(--primary-ink);
  text-decoration: none;
  transition: transform .06s ease, opacity .15s ease;
}
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .35; cursor: not-allowed; transform: none; }
.btn.secondary { background: var(--surface); color: var(--primary); border: 2px solid var(--line); }
.btn.danger { background: var(--danger); }
.btn.block { width: 100%; }
.btn.big { min-height: 72px; font-size: 1.25rem; }

.bottom-bar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  padding: 14px var(--pad) calc(env(safe-area-inset-bottom, 0px) + 14px);
  background: linear-gradient(to top, var(--bg) 70%, rgba(255, 255, 255, 0));
}
.bottom-bar-inner { max-width: 820px; margin: 0 auto; display: flex; gap: 12px; }
.bottom-bar-inner .btn { flex: 1; }

.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 16px; }
.btn-row .btn { flex: 1 1 200px; }

/* ---------- Karten und Listen ---------- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
  padding: 18px;
}
.list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }

.row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; text-align: left;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; min-height: 76px;
  box-shadow: 0 1px 3px rgba(16, 24, 40, .06);
}
button.row:active { background: var(--soft); }
.row-main { min-width: 0; flex: 1; }
.row-name { font-weight: 700; font-size: 1.15rem; overflow-wrap: anywhere; }
.row-meta { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.row-side { text-align: right; flex-shrink: 0; display: flex; flex-direction: column; gap: 4px; align-items: flex-end; }
.chev { color: #b5b1a7; font-size: 1.4rem; margin-left: 4px; }

.pill {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  font-weight: 700; font-size: .92rem; white-space: nowrap;
}
.pill.plus { background: var(--plus-soft); color: var(--plus); }
.pill.minus { background: var(--minus-soft); color: var(--minus); }
.pill.zero { background: var(--soft); color: var(--muted); font-weight: 600; }
.pill.off { background: var(--soft); color: var(--muted); }

.summary {
  display: grid; gap: 10px; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-top: 18px;
}
.summary .card { padding: 14px 18px; }
.summary .label { color: var(--muted); font-size: .9rem; }
.summary .value { font-size: 1.25rem; font-weight: 750; margin-top: 2px; }
.summary .value.plus { color: var(--plus); }
.summary .value.minus { color: var(--minus); }

.search {
  width: 100%; min-height: 56px; margin-top: 18px; padding: 0 18px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
}
.search:focus { outline: none; border-color: var(--primary); }

.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty strong { display: block; color: var(--ink); font-size: 1.2rem; margin-bottom: 6px; }

/* ---------- Ablauf „Paletten erfassen“ ---------- */
.wizard-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.steps-label { color: var(--muted); font-weight: 600; font-size: .95rem; }
.progress { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin: 6px 0 22px; }
.progress span { height: 6px; border-radius: 3px; background: var(--line); }
.progress span.on { background: var(--primary); }

.tiles {
  display: grid; gap: 12px; margin-top: 22px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 220px), 1fr));
}
.tile {
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start; gap: 4px;
  min-height: 96px; padding: 16px 18px; text-align: left;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  font-weight: 700; font-size: 1.2rem; overflow-wrap: anywhere;
}
.tile small { font-weight: 500; font-size: .88rem; color: var(--muted); }
.tile:active, .tile.selected { border-color: var(--primary); background: var(--primary-soft); }
.tile.add { border-style: dashed; color: var(--primary); align-items: center; text-align: center; }

.field { display: flex; flex-direction: column; gap: 8px; margin-top: 22px; }
.field label { font-weight: 700; }
.field .hint { color: var(--muted); font-size: .9rem; }
.input {
  width: 100%; min-height: 60px; padding: 0 18px;
  border: 2px solid var(--line); border-radius: var(--radius); background: var(--surface);
  font-size: 1.15rem;
}
.input:focus { outline: none; border-color: var(--primary); }
.input.plate { font-size: 2rem; font-weight: 750; letter-spacing: .06em; text-transform: uppercase; min-height: 80px; text-align: center; }

.input.plate::placeholder { text-transform: none; font-weight: 500; letter-spacing: 0; color: #b5b1a7; font-size: 1.4rem; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chip {
  min-height: 52px; padding: 0 18px; border-radius: 999px;
  border: 2px solid var(--line); background: var(--surface);
  font-weight: 700; letter-spacing: .04em;
}
.chip:active { border-color: var(--primary); background: var(--primary-soft); }

.type-card { margin-top: 16px; }
.type-card h2 { font-size: 1.25rem; font-weight: 750; margin-bottom: 6px; }
.counter-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 0; border-top: 1px solid var(--line);
}
.counter-row:first-of-type { border-top: 0; }
.counter-label { font-weight: 600; }
.counter-label small { display: block; color: var(--muted); font-weight: 500; font-size: .88rem; }
.stepper { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }
.stepper button {
  width: 64px; height: 64px; border-radius: 50%;
  border: 2px solid var(--line); background: var(--soft);
  font-size: 2rem; font-weight: 500; line-height: 1;
  display: inline-flex; align-items: center; justify-content: center;
}
.stepper button:active { background: var(--primary-soft); border-color: var(--primary); }
.stepper button[disabled] { opacity: .3; }
.stepper input {
  width: 78px; height: 64px; text-align: center;
  font-size: 1.9rem; font-weight: 750;
  border: 2px solid transparent; border-radius: 12px; background: transparent;
}
.stepper input:focus { outline: none; border-color: var(--primary); background: var(--surface); }

.preview { margin-top: 18px; padding: 16px 18px; border-radius: var(--radius); background: var(--primary-soft); }
.preview p + p { margin-top: 4px; }
.preview .label { color: var(--muted); font-size: .9rem; margin-bottom: 4px; }

.recap { margin-top: 18px; }
.recap-line { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; }
.recap-line span:first-child { color: var(--muted); }
.recap-line span:last-child { font-weight: 700; text-align: right; }

.handover {
  display: flex; gap: 12px; align-items: center; margin-top: 22px;
  padding: 14px 16px; border-radius: var(--radius); background: #fff6d6; color: #5c4a00; font-weight: 600;
}

.sig-wrap { position: relative; margin-top: 10px; }
.sig-pad {
  display: block; width: 100%; height: clamp(200px, 34vh, 320px);
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius);
  touch-action: none;
}
.sig-pad.signed { border-color: var(--primary); }
.sig-line {
  position: absolute; left: 24px; right: 24px; bottom: 54px;
  border-bottom: 2px dashed #cfcbc1; pointer-events: none;
}
.sig-x { position: absolute; left: 24px; bottom: 60px; color: #b5b1a7; font-size: 1.6rem; pointer-events: none; }
.sig-hint { position: absolute; left: 0; right: 0; bottom: 18px; text-align: center; color: var(--muted); pointer-events: none; font-size: .95rem; }
.sig-tools { display: flex; justify-content: flex-end; }

.done { text-align: center; padding-top: 8vh; }
.done-check {
  width: 112px; height: 112px; margin: 0 auto 22px; border-radius: 50%;
  background: var(--plus-soft); color: var(--plus);
  display: flex; align-items: center; justify-content: center;
}
.done .card { text-align: left; margin-top: 24px; }

/* ---------- Spedition ---------- */
.balance-grid { display: grid; gap: 12px; margin-top: 18px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.balance-card { border-radius: var(--radius); padding: 18px; background: var(--surface); border: 1px solid var(--line); }
.balance-card.plus { background: var(--plus-soft); border-color: transparent; }
.balance-card.minus { background: var(--minus-soft); border-color: transparent; }
.balance-card .type { font-weight: 700; }
.balance-card .num { font-size: 2.6rem; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.balance-card.plus .num, .balance-card.plus .what { color: var(--plus); }
.balance-card.minus .num, .balance-card.minus .what { color: var(--minus); }
.balance-card .what { font-weight: 600; }

.mv { display: flex; gap: 14px; align-items: center; }
.mv-sig { width: 96px; height: 48px; object-fit: contain; background: #fff; border: 1px solid var(--line); border-radius: 8px; flex-shrink: 0; }
.mv-body { flex: 1; min-width: 0; }
.mv-title { font-weight: 700; }
.mv-lines { margin-top: 2px; }
.mv.cancelled .mv-title, .mv.cancelled .mv-lines { text-decoration: line-through; color: var(--muted); }
.tag { display: inline-block; font-size: .8rem; font-weight: 700; padding: 2px 8px; border-radius: 6px; background: var(--soft); color: var(--muted); margin-left: 6px; vertical-align: 2px; }
.tag.red { background: #fbe4e2; color: var(--danger); }

/* ---------- Anmeldung ---------- */
.login-head { text-align: center; padding-top: 6vh; }
.avatar {
  width: 56px; height: 56px; border-radius: 50%; flex-shrink: 0;
  background: var(--primary-soft); color: var(--primary);
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 1.3rem;
}
.tile .avatar { margin-bottom: 6px; }
.pin-dots { display: flex; justify-content: center; gap: 18px; margin: 28px 0 10px; }
.pin-dots span { width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--primary); }
.pin-dots span.on { background: var(--primary); }
.pin-dots.shake { animation: shake .35s; }
@keyframes shake { 25% { transform: translateX(-10px); } 75% { transform: translateX(10px); } }
.pin-error { text-align: center; color: var(--danger); min-height: 1.5em; font-weight: 600; }
.keypad { display: grid; grid-template-columns: repeat(3, 84px); gap: 16px; justify-content: center; margin-top: 16px; }
.keypad button {
  width: 84px; height: 84px; border-radius: 50%;
  border: 0; background: var(--surface); box-shadow: 0 1px 0 var(--line), 0 0 0 1px var(--line);
  font-size: 2rem; font-weight: 600;
}
.keypad button:active { background: var(--primary-soft); }
.keypad button.ghost { background: none; box-shadow: none; font-size: 1rem; color: var(--primary); }

/* ---------- Einstellungen ---------- */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-top: 1px solid var(--line); }
.set-row:first-child { border-top: 0; }
.set-row .name { font-weight: 650; overflow-wrap: anywhere; }
.set-row .actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- Dialog ---------- */
dialog {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  border: 0; border-radius: 20px; padding: 0; background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .25);
}
dialog::backdrop { background: rgba(20, 20, 20, .45); }
.dlg { padding: 24px; display: flex; flex-direction: column; gap: 4px; }
.dlg h2 { font-size: 1.4rem; font-weight: 750; }
.dlg .field { margin-top: 16px; }
.dlg .btn-row { margin-top: 24px; }
.dlg .error { color: var(--danger); font-weight: 600; margin-top: 12px; min-height: 1.4em; }
.dlg .sig-full { width: 100%; background: #fff; border: 1px solid var(--line); border-radius: 12px; margin-top: 12px; }
.check { display: flex; align-items: center; gap: 12px; min-height: 52px; font-weight: 600; }
.check input { width: 26px; height: 26px; }

/* ---------- Hinweis unten ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom, 0px) + 110px); transform: translateX(-50%);
  z-index: 50; max-width: calc(100vw - 32px);
  background: var(--ink); color: #fff; padding: 14px 20px; border-radius: 14px; font-weight: 600;
  box-shadow: 0 8px 30px rgba(0, 0, 0, .25);
}
#toast.error { background: var(--danger); }

/* ---------- Handy ---------- */
@media (max-width: 520px) {
  :root { font-size: 17px; --tap: 58px; }
  .stepper button { width: 54px; height: 54px; }
  .stepper input { width: 60px; }
  .counter-row { flex-wrap: wrap; }
  .keypad { grid-template-columns: repeat(3, 76px); }
  .keypad button { width: 76px; height: 76px; }
  .row { padding: 14px; }
  .mv-sig { width: 72px; height: 40px; }
}

/* ---------- Drucken (Kontoauszug je Spedition) ---------- */
@media print {
  :root { font-size: 12pt; background: #fff; }
  body { background: #fff; }
  #app { max-width: none; padding: 0; }
  .no-print, .bottom-bar, .topbar-actions, #toast, .chev { display: none !important; }
  .row, .card, .balance-card { border: 1px solid #999 !important; break-inside: avoid; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
.muted { color: var(--muted); }
.btn { white-space: nowrap; }
.small-btns .btn { flex: 1 1 180px; font-size: 1rem; min-height: 54px; padding: 0 16px; }
.done .card p { font-size: 1.15rem; }

/* Handy: Saldo unter den Namen, Kopfzeile kompakter */
@media (max-width: 520px) {
  .row:not(.mv) { flex-wrap: wrap; row-gap: 10px; }
  .row:not(.mv) .row-main { flex: 1 1 calc(100% - 40px); order: 1; }
  .row:not(.mv) .chev { order: 2; }
  .row:not(.mv) .row-side { order: 3; width: 100%; flex-direction: row; flex-wrap: wrap; justify-content: flex-start; text-align: left; }
  .pill { white-space: normal; }
  .topbar .brand { font-size: .95rem; }
  .topbar-actions { gap: 0; }
  .topbar .link-btn { padding: 8px; font-size: .9rem; min-height: 44px; }
}
@media (max-width: 520px) {
  .counter-row { flex-wrap: nowrap; }
  .stepper { gap: 4px; }
  .stepper button { width: 50px; height: 50px; font-size: 1.7rem; }
  .stepper input { width: 52px; font-size: 1.6rem; }
  .type-card { padding: 14px 16px; }
}
