:root {
  --night: #121a27;
  --night-2: #1b2638;
  --night-3: #26344b;
  --ice: #5aa9e6;
  --ice-2: #9fd0f5;
  --ice-soft: #e6f2fc;
  --snow: #f4f7fb;
  --card: #ffffff;
  --ink: #172033;
  --muted: #63708a;
  --line: #e1e7f0;
  --warn: #c2620c;
  --warn-soft: #fff3e6;
  --ok: #1f8a5b;
  --danger: #c23b3b;
  --radius: 18px;
  --shadow: 0 1px 2px rgba(18, 26, 39, .06), 0 8px 24px rgba(18, 26, 39, .08);
  --safe-b: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--snow);
  color: var(--ink);
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
.app { max-width: 560px; margin: 0 auto; min-height: 100dvh; padding-bottom: calc(96px + var(--safe-b)); }
.boot { padding: 48px 20px; color: var(--muted); text-align: center; }

/* Dunkler Kopf */
.top {
  background: radial-gradient(120% 140% at 100% 0%, #2c4a72 0%, var(--night-2) 45%, var(--night) 100%);
  color: #fff;
  padding: calc(14px + env(safe-area-inset-top, 0px)) 18px 26px;
  border-radius: 0 0 28px 28px;
  position: relative;
  overflow: hidden;
}
.top::after {
  content: ""; position: absolute; inset: auto -40px -60px auto; width: 180px; height: 180px; border-radius: 50%;
  background: radial-gradient(circle, rgba(159, 208, 245, .18), transparent 70%);
}
.top-bar { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.top-bar .grow { flex: 1; }
.icon-btn {
  width: 44px; height: 44px; border-radius: 14px; border: 0; display: grid; place-items: center;
  background: rgba(255, 255, 255, .1); color: #fff;
}
.icon-btn svg { width: 22px; height: 22px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--ice-2); font-weight: 700; }
.top h1 { font-size: 28px; line-height: 1.15; margin: 10px 0 4px; font-weight: 750; letter-spacing: -.01em; }
.top .sub { color: #c9d6e8; font-size: 15px; margin: 0; }
.top .big-num { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 6px 0 2px; }

/* Hauptbereich */
main { padding: 18px 16px 0; display: grid; gap: 14px; }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.dark { background: var(--night-2); color: #fff; }
.card h2 { font-size: 17px; margin: 0 0 10px; }
.section-title { font-size: 13px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin: 8px 4px -4px; }
.muted { color: var(--muted); }
.small { font-size: 14px; }
.row { display: flex; align-items: center; gap: 10px; }
.row .grow { flex: 1; min-width: 0; }
.between { justify-content: space-between; }

/* Start-Kacheln */
.tiles { display: grid; gap: 12px; margin-top: -8px; }
.tile {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left; border: 0;
  background: var(--card); border-radius: 20px; padding: 16px; box-shadow: var(--shadow); min-height: 80px;
}
.tile .ico { width: 52px; height: 52px; border-radius: 16px; display: grid; place-items: center; flex: none; background: var(--ice-soft); color: #1f6fb2; }
.tile .ico svg { width: 26px; height: 26px; }
.tile strong { display: block; font-size: 18px; }
.tile span { color: var(--muted); font-size: 14px; }
.tile.primary { background: var(--night-2); color: #fff; }
.tile.primary .ico { background: var(--ice); color: var(--night); }
.tile.primary span { color: #b9c8dc; }
.tile .chev { margin-left: auto; color: #9aa6ba; }
.tiles-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.tiles-2 .tile { flex-direction: column; align-items: flex-start; min-height: 120px; }

/* Listen */
.list { display: grid; gap: 10px; }
.item {
  display: flex; gap: 12px; align-items: center; width: 100%; text-align: left;
  background: var(--card); border: 0; border-radius: 16px; padding: 14px; box-shadow: var(--shadow);
}
.avatar { width: 46px; height: 46px; border-radius: 14px; background: var(--night-2); color: var(--ice-2); display: grid; place-items: center; font-weight: 800; flex: none; }
.item strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .muted { font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.amount { font-weight: 750; white-space: nowrap; }

/* Positionen */
.day-head { display: flex; justify-content: space-between; align-items: baseline; margin: 6px 4px -2px; font-weight: 700; }
.day-head span { color: var(--muted); font-weight: 600; font-size: 14px; }
.pos { background: var(--card); border-radius: 16px; box-shadow: var(--shadow); padding: 14px; border: 0; width: 100%; text-align: left; display: grid; gap: 8px; }
.pos .time { font-size: 18px; font-weight: 750; }
.pos.running { outline: 2px solid var(--ice); }
.thumbs { display: flex; gap: 6px; overflow-x: auto; }
.thumbs img { width: 58px; height: 58px; object-fit: cover; border-radius: 10px; flex: none; background: var(--line); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 13px; padding: 4px 10px; border-radius: 999px; background: var(--ice-soft); color: #1c5d93; font-weight: 600; }
.chip.warn { background: var(--warn-soft); color: var(--warn); }

/* Formulare */
.field { display: grid; gap: 6px; }
.field > span { font-size: 14px; font-weight: 650; color: var(--muted); }
input[type=text], input[type=date], input[type=time], input[type=number], input[type=email], input[type=tel], input[type=password], textarea, select {
  width: 100%; min-height: 50px; border: 1.5px solid var(--line); border-radius: 14px; padding: 12px 14px; background: #fff; font-size: 17px;
}
textarea { min-height: 84px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--ice); box-shadow: 0 0 0 4px rgba(90, 169, 230, .2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.time-field { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.btn-now { border: 0; border-radius: 12px; padding: 0 12px; background: var(--ice-soft); color: #1c5d93; font-weight: 700; font-size: 14px; min-height: 50px; }
.toggle-grid { display: flex; flex-wrap: wrap; gap: 8px; }
.toggle {
  border: 1.5px solid var(--line); background: #fff; border-radius: 999px; padding: 10px 14px; font-weight: 650; font-size: 15px; min-height: 44px;
}
.toggle[aria-pressed=true] { background: var(--night-2); border-color: var(--night-2); color: #fff; }
.price-box { display: flex; justify-content: space-between; align-items: center; background: var(--night-2); color: #fff; border-radius: 16px; padding: 14px 16px; }
.price-box strong { font-size: 22px; }
.price-box .small { color: #b9c8dc; }

.btn {
  display: inline-flex; justify-content: center; align-items: center; gap: 8px; min-height: 54px; padding: 0 18px;
  border-radius: 16px; border: 0; font-weight: 750; font-size: 17px; width: 100%; text-decoration: none;
}
.btn svg { width: 20px; height: 20px; }
.btn-primary { background: var(--ice); color: var(--night); }
.btn-dark { background: var(--night-2); color: #fff; }
.btn-light { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }
.btn-ghost { background: transparent; color: var(--muted); min-height: 44px; }
.btn-danger { background: #fdeeee; color: var(--danger); }
.btn[disabled] { opacity: .55; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: var(--line); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo .x { position: absolute; top: 6px; right: 6px; width: 30px; height: 30px; border-radius: 50%; border: 0; background: rgba(18, 26, 39, .75); color: #fff; font-size: 18px; line-height: 1; }
.photo.loading::after { content: "lädt …"; position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 13px; }
.file-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
details summary { cursor: pointer; font-weight: 650; color: var(--muted); padding: 4px 0; }
details[open] summary { margin-bottom: 10px; }

/* Monatswähler */
.month-switch { display: flex; align-items: center; gap: 8px; background: rgba(255, 255, 255, .1); border-radius: 16px; padding: 6px; margin-top: 14px; }
.month-switch strong { flex: 1; text-align: center; font-size: 17px; }
.month-switch button { width: 44px; height: 44px; border-radius: 12px; border: 0; background: rgba(255, 255, 255, .12); color: #fff; font-size: 22px; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 16px; }
.stat { background: rgba(255, 255, 255, .08); border-radius: 14px; padding: 10px; }
.stat b { display: block; font-size: 18px; }
.stat span { font-size: 12px; color: #b9c8dc; }

.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 82px 1fr 78px; gap: 8px; align-items: center; font-size: 14px; }
.bar { height: 12px; border-radius: 6px; background: var(--ice-soft); overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--ice), #2f7fc1); border-radius: 6px; }
.bar-row .amount { text-align: right; }
.compare { display: flex; gap: 10px; }
.compare > div { flex: 1; border-radius: 14px; padding: 12px; background: var(--snow); }
.compare b { display: block; font-size: 20px; }
.trend-up { color: var(--ok); font-weight: 700; }
.trend-down { color: var(--warn); font-weight: 700; }
.sum-line { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sum-line:last-child { border-bottom: 0; }
.sum-total { font-weight: 800; font-size: 18px; }

.empty { text-align: center; padding: 28px 16px; color: var(--muted); }
.empty svg { width: 44px; height: 44px; color: var(--ice); margin-bottom: 8px; }
.hint { background: var(--warn-soft); color: var(--warn); border-radius: 14px; padding: 10px 14px; font-size: 14px; font-weight: 600; }

/* Untere Leiste */
.bottom-nav {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: 100%; max-width: 560px;
  display: grid; grid-template-columns: repeat(4, 1fr); background: var(--night); padding: 8px 8px calc(8px + var(--safe-b));
  border-radius: 22px 22px 0 0; z-index: 10;
}
.bottom-nav a { display: grid; justify-items: center; gap: 2px; color: #8ea0b8; text-decoration: none; font-size: 11.5px; font-weight: 650; padding: 6px 0; border-radius: 12px; }
.bottom-nav a svg { width: 24px; height: 24px; }
.bottom-nav a.on { color: #fff; background: rgba(90, 169, 230, .16); }

.fab-wrap { position: sticky; bottom: calc(86px + var(--safe-b)); padding: 0 16px; margin-top: 16px; z-index: 5; }

.toast {
  position: fixed; left: 50%; bottom: calc(100px + var(--safe-b)); transform: translateX(-50%) translateY(20px); opacity: 0;
  background: var(--night); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 650; pointer-events: none;
  transition: opacity .2s, transform .2s; max-width: calc(100% - 32px); z-index: 50; box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { background: var(--danger); }

/* Anmeldung */
.login { min-height: 100dvh; display: grid; align-content: center; gap: 18px; padding: 24px 20px; background: radial-gradient(120% 80% at 100% 0%, #2c4a72, var(--night) 60%); color: #fff; }
.login h1 { font-size: 30px; margin: 0; }
.login p { color: #c9d6e8; margin: 0; }
.login input { text-align: center; letter-spacing: .12em; font-size: 20px; }
.snowflake { width: 64px; height: 64px; color: var(--ice-2); }

.viewer { position: fixed; inset: 0; background: rgba(10, 14, 22, .94); z-index: 60; display: grid; place-items: center; padding: 16px; }
.viewer img { max-width: 100%; max-height: 86dvh; border-radius: 12px; }
.viewer button { position: absolute; top: calc(12px + env(safe-area-inset-top, 0px)); right: 12px; }

@media (min-width: 600px) { .app { padding-top: 12px; } .top { border-radius: 28px; } }
@media (prefers-reduced-motion: reduce) { .toast { transition: none; } }
.item .icon-btn { background: var(--ice-soft); color: #1c5d93; flex: none; }
a.pos, a.sum-line, a.tile, a.item { color: inherit; text-decoration: none; }
a.pos .btn { margin-top: 2px; }
/* Eingabefelder immer dunkle Schrift auf hellem Grund, auch auf dunklen Flächen (Anmeldung) */
input[type=text], input[type=date], input[type=time], input[type=number], input[type=email], input[type=tel], input[type=password], textarea, select { color: var(--ink); background: #fff; }
input::placeholder, textarea::placeholder { color: #8a95a8; }
.item .icon-btn.icon-del { background: #fdeeee; color: var(--danger); }
.item .icon-btn { width: 40px; height: 40px; }
.item .grow { flex: 1; min-width: 0; }
.item strong { overflow: hidden; text-overflow: ellipsis; }
.list > *, main > * { min-width: 0; }
