:root {
  --bg: #f6f3ee; --panel: #ffffff; --text: #1c2030; --muted: #667085; --line: #e3ded5;
  --milk: #3b6fb6; --diaper: #b9772a; --accent: #3b6fb6; --danger: #b3382c; --ok: #2f7d4f;
  --tile-text: #ffffff; --shadow: 0 1px 3px rgba(0,0,0,.12);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #12161f; --panel: #1b2230; --text: #e7e9ef; --muted: #98a0b3; --line: #2a3345;
    --milk: #2f5a96; --diaper: #8a5a22; --accent: #5b8dd6; --danger: #d66a5e; --ok: #5bbf84;
    --shadow: none; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #12161f; --panel: #1b2230; --text: #e7e9ef; --muted: #98a0b3; --line: #2a3345;
  --milk: #2f5a96; --diaper: #8a5a22; --accent: #5b8dd6; --danger: #d66a5e; --ok: #5bbf84;
  --shadow: none; color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 17px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  padding: env(safe-area-inset-top) 0 calc(24px + env(safe-area-inset-bottom));
  min-height: 100vh; overscroll-behavior-y: contain;
}
main, .top, .netz { max-width: 640px; margin: 0 auto; }
.muted { color: var(--muted); }
.pad { padding: 16px; }
h1 { font-size: 1.35rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 22px 16px 8px; color: var(--muted); font-weight: 600; text-transform: none; }
p { margin: 0; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 6px; }
.top p { font-size: .95rem; }
.icon-btn { background: none; border: 0; font-size: 1.5rem; padding: 8px; min-width: 48px; min-height: 48px; border-radius: 12px; color: var(--text); }
.netz { margin: 6px 16px; padding: 8px 12px; border-radius: 10px; background: #e8b64a33; color: var(--text); font-size: .92rem; }
.netz.err { background: #d66a5e33; }

button { font: inherit; color: inherit; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; padding: 8px 16px; }
.tile {
  border: 0; border-radius: 20px; min-height: 124px; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 6px; font-size: 1.25rem; font-weight: 600; color: var(--tile-text); box-shadow: var(--shadow); touch-action: manipulation;
}
.tile .big { font-size: 2.4rem; line-height: 1; }
.tile:active { transform: scale(.98); filter: brightness(.92); }
.tile.milk { background: var(--milk); }
.tile.diaper { background: var(--diaper); }

.card { background: var(--panel); border-radius: 16px; margin: 8px 16px; padding: 12px 14px; box-shadow: var(--shadow); }
.sum { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.sum .k { font-size: .82rem; color: var(--muted); }
.sum .v { font-size: 1.25rem; font-weight: 650; }
.sum .small { font-size: .9rem; font-weight: 500; }

.list { list-style: none; margin: 0; padding: 0 16px; }
.row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left; border: 0; background: var(--panel);
  border-radius: 14px; padding: 12px 14px; margin: 0 0 8px; min-height: 56px; box-shadow: var(--shadow);
}
.row .ico { font-size: 1.5rem; width: 34px; text-align: center; flex: none; }
.row .txt { flex: 1; min-width: 0; }
.row .t { font-weight: 600; }
.row .s { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.row .time { font-variant-numeric: tabular-nums; font-weight: 600; flex: none; }
.row.pending { opacity: .65; }
.empty { padding: 8px 16px; color: var(--muted); }

.toast {
  position: fixed; left: 12px; right: 12px; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 30; max-width: 616px; margin: 0 auto;
  background: #222a3c; color: #fff; border-radius: 14px; padding: 12px 14px; display: flex; gap: 12px; align-items: center; justify-content: space-between;
  box-shadow: 0 4px 16px rgba(0,0,0,.35);
}
.toast[hidden], .sheet-wrap[hidden], .netz[hidden], [hidden] { display: none !important; }
.toast button { background: none; border: 0; color: #9cc1ff; font-weight: 700; padding: 8px 6px; min-height: 44px; }

.sheet-wrap { position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.5); display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--panel); width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; border-radius: 22px 22px 0 0;
  padding: 16px 16px calc(18px + env(safe-area-inset-bottom));
}
.sheet h3 { margin: 0 0 12px; font-size: 1.2rem; display: flex; justify-content: space-between; align-items: center; }
.sheet .close { background: none; border: 0; font-size: 1.4rem; min-width: 44px; min-height: 44px; color: var(--muted); }
.grid4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.q {
  min-height: 64px; border-radius: 16px; border: 2px solid var(--line); background: var(--bg); font-size: 1.25rem; font-weight: 650;
  touch-action: manipulation;
}
.q small { display: block; font-size: .7rem; font-weight: 500; color: var(--muted); }
.q.sel, .q:active { border-color: var(--accent); }
.q.milkq { background: var(--milk); border-color: transparent; color: #fff; }
.q.milkq.last { outline: 3px solid var(--accent); outline-offset: 2px; }
.q.dq { background: var(--diaper); border-color: transparent; color: #fff; min-height: 76px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip { border: 2px solid var(--line); background: var(--bg); border-radius: 999px; padding: 8px 14px; min-height: 44px; }
.chip.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 22%, var(--bg)); font-weight: 600; }
.field { display: block; margin: 0 0 12px; }
.field > span { display: block; font-size: .85rem; color: var(--muted); margin-bottom: 4px; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--bg); border: 2px solid var(--line); border-radius: 12px; padding: 10px 12px;
  width: 100%; min-height: 48px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); }
.inline { display: flex; gap: 10px; align-items: stretch; margin-bottom: 12px; }
.inline > input { flex: 1; }
.btn {
  border: 0; border-radius: 14px; background: var(--accent); color: #fff; font-weight: 650; padding: 0 18px; min-height: 52px; touch-action: manipulation;
}
.btn.secondary { background: var(--bg); color: var(--text); border: 2px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.btn.full { width: 100%; }
.btns { display: flex; gap: 10px; margin-top: 6px; }
.btns .btn { flex: 1; }
.timebox { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; padding: 8px 12px; background: var(--bg); border-radius: 12px; }
.timebox button { background: none; border: 0; color: var(--accent); font-weight: 650; min-height: 44px; padding: 0 6px; }
.msg { padding: 24px 16px; text-align: center; }
.msg h2 { margin: 0 0 8px; color: var(--text); font-size: 1.2rem; }
.form { padding: 8px 16px; }
.err { color: var(--danger); font-size: .92rem; margin: 6px 0; }
.hint { font-size: .85rem; color: var(--muted); margin: -6px 0 12px; }
