:root {
  --bg: #f5f6f8; --card: #ffffff; --text: #1d2330; --muted: #667085; --line: #e3e6ec;
  --accent: #2456c5; --accent-text: #ffffff; --danger: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #14171d; --card: #1d222b; --text: #e8eaf0; --muted: #98a2b3; --line: #2c333f;
          --accent: #6b97f0; --accent-text: #0e1624; --danger: #f97066; }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
main { max-width: 900px; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.5rem; margin: 0; }
h2 { font-size: 1.05rem; margin: 0 0 10px; }
a { color: var(--accent); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; margin-bottom: 14px; }
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline { display: inline; margin: 0; }
.summary { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.stat .label { display: block; color: var(--muted); font-size: .85rem; }
.stat strong { font-size: 1.4rem; }
.muted { color: var(--muted); } .small { font-size: .85rem; }
.error { color: var(--danger); }
.cats { list-style: none; padding: 0; margin: 0; }
.cats li { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.cats li:last-child { border-bottom: 0; }
.cats a { flex: 1; text-decoration: none; } .cats a.active { font-weight: 700; }
.amount, .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
th.num { text-align: right; }
td.actions { white-space: nowrap; text-align: right; } td.actions a { margin-left: 10px; }
summary { cursor: pointer; font-weight: 600; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 12px; }
.grid .wide { grid-column: 1 / -1; }
label { display: flex; flex-direction: column; gap: 4px; font-size: .9rem; color: var(--muted); }
input, select, button { font: inherit; }
input, select { padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); }
button, .btn { display: inline-block; padding: 10px 14px; border: 0; border-radius: 8px; background: var(--accent);
               color: var(--accent-text); font-weight: 600; text-decoration: none; cursor: pointer; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--line); }
.btn.danger { background: var(--danger); color: #fff; }
.tabs { display: flex; gap: 6px; margin-bottom: 14px; }
.tabs a { padding: 8px 18px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
          text-decoration: none; font-weight: 600; }
.tabs a.active { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.tag { display: inline-block; font-size: .8rem; padding: 1px 8px; border-radius: 6px; border: 1px solid var(--line);
       color: var(--muted); margin-top: 2px; }
.grid > *, label { min-width: 0; }
label select, label input { width: 100%; max-width: 100%; }
.cats li > span:first-child, .cats li > strong:first-child { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.top-actions { min-width: 0; }
.deadline { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between;
            border-left: 4px solid var(--accent); }
.deadline.overdue { border-left-color: var(--danger); }
.deadline.overdue strong { color: var(--danger); }
.tag.warn { border-color: #d29922; color: #b07d12; }
.subnav { display: flex; gap: 4px 14px; flex-wrap: wrap; margin: -4px 0 14px; font-size: .95rem; }
.subnav a { text-decoration: none; padding: 2px 0; border-bottom: 2px solid transparent; }
.subnav a.active { border-bottom-color: var(--accent); font-weight: 600; }
.notice { border-left: 4px solid #d29922; }
.pos { color: #1a7f37; } .neg { color: var(--danger); }
@media (prefers-color-scheme: dark) { .pos { color: #4ac26b; } }
.summary.three { grid-template-columns: repeat(3, 1fr); }
.summary .stat a { display: block; margin-top: 4px; }
form.row { display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 6px; }
form.row select, form.row input { padding: 6px; max-width: 100%; }
form.row button, .btn.small { padding: 6px 10px; font-size: .85rem; }
td.assign { min-width: 260px; }
.two-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
h3 { font-size: 1rem; margin: 6px 0; }
button[disabled] { opacity: .5; cursor: not-allowed; }
@media print {
  .tabs, .subnav, .top-actions, details, .notice, form, .btn { display: none !important; }
  body { background: #fff; color: #000; } .card { border: 0; padding: 0; }
}
.login { max-width: 360px; margin: 14vh auto 0; }
.login form { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
@media (max-width: 560px) {
  .grid, .two-cols, .summary.three { grid-template-columns: 1fr; }
  th:nth-child(3), td:nth-child(3) { display: none; }
}

pre.mailbody { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 240px; overflow: auto; }

/* ---------- Handy-App ---------- */
html { -webkit-text-size-adjust: 100%; }
main { padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right))
              calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
.filepick { display: flex; flex-direction: column; gap: 8px; }
.filepick .label { font-size: .9rem; color: var(--muted); }
.filepick-buttons { display: flex; gap: 8px; flex-wrap: wrap; }
.filepick img { max-width: 100%; max-height: 260px; object-fit: contain; border-radius: 8px; border: 1px solid var(--line); align-self: flex-start; }
.fab { position: fixed; right: max(18px, env(safe-area-inset-right)); bottom: calc(18px + env(safe-area-inset-bottom));
       width: 60px; height: 60px; border-radius: 50%; background: var(--accent); color: var(--accent-text);
       display: none; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(0,0,0,.25); z-index: 10; }
.tabs { overflow-x: auto; scrollbar-width: none; }
.tabs a { white-space: nowrap; }
@media (max-width: 760px) {
  .fab { display: flex; }
  input, select { font-size: 16px; }   /* verhindert das Hineinzoomen auf dem iPhone */
  button, .btn { min-height: 44px; }
  td.actions a { display: inline-block; padding: 6px 0; }
  .top h1 { font-size: 1.25rem; }
}
@media print { .fab { display: none !important; } }
@media (max-width: 560px) {
  .summary.three { grid-template-columns: repeat(3, 1fr); gap: 8px; }
  .summary.three .stat { padding: 10px; }
  .summary.three .stat strong { font-size: 1rem; }
  .summary.three .stat .label { font-size: .75rem; }
}
@media (max-width: 560px) {
  /* Belegliste als Karten statt Tabelle */
  table.list thead { display: none; }
  table.list, table.list tbody { display: block; }
  table.list tr { display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 10px 0; border-bottom: 1px solid var(--line); }
  table.list td { border: 0; padding: 0; }
  table.list td:nth-child(1) { grid-column: 1; grid-row: 1; color: var(--muted); font-size: .85rem; }
  table.list td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  table.list td.num { grid-column: 2; grid-row: 1; font-weight: 600; }
  table.list td.actions { grid-column: 1 / -1; grid-row: 3; text-align: left; }
  table.list td.actions a { display: inline-block; margin: 4px 18px 0 0; }
}

/* ---------- Neuer Aufbau: Leiste unten ---------- */
main { padding-bottom: calc(96px + env(safe-area-inset-bottom)); }
.bottombar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center;
             background: var(--card); border-top: 1px solid var(--line);
             padding: 6px max(6px, env(safe-area-inset-right)) calc(6px + env(safe-area-inset-bottom)) max(6px, env(safe-area-inset-left)); }
.bottombar a { position: relative; flex: 1; max-width: 140px; display: flex; flex-direction: column; align-items: center; gap: 2px;
               padding: 6px 2px; border-radius: 12px; text-decoration: none; color: var(--muted); font-size: .72rem; font-weight: 600; }
.bottombar svg { width: 24px; height: 24px; fill: currentColor; }
.bottombar a.active { color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }
.badge { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
         background: var(--danger); color: #fff; font-size: .7rem; line-height: 18px; text-align: center; }
.badge.dot { min-width: 10px; width: 10px; height: 10px; padding: 0; top: 4px; left: calc(50% + 8px); }
.segmented { display: inline-flex; background: var(--card); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.segmented a { padding: 7px 22px; border-radius: 999px; text-decoration: none; font-weight: 600; color: var(--muted); }
.segmented a.active { background: var(--accent); color: var(--accent-text); }
.filter { margin: 0 0 12px; }
details.card > summary { font-weight: 600; }
details.card[open] > summary { margin-bottom: 10px; }
textarea { font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); width: 100%; resize: vertical; }
.wide-btn { width: 100%; padding: 14px; font-size: 1.05rem; }

/* Erfassen */
.capture { display: flex; flex-direction: column; gap: 14px; }
.capture-buttons { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.bigbtn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 8px; border-radius: 14px; font-size: 1rem; }
.bigbtn.ghost { background: transparent; color: var(--accent); border: 1.5px dashed var(--line); }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 84px; height: 108px; border-radius: 8px; overflow: hidden; border: 1px solid var(--line); background: var(--bg); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb.file { display: flex; align-items: center; justify-content: center; padding: 6px; font-size: .7rem; overflow-wrap: anywhere; text-align: center; }
.thumb button { position: absolute; top: 3px; right: 3px; width: 24px; height: 24px; min-height: 0; padding: 0; border-radius: 50%;
                background: rgba(0,0,0,.6); color: #fff; font-size: 16px; line-height: 24px; }

/* Offen */
.offen-head { display: flex; gap: 12px; align-items: flex-start; }
.offen-head p { margin: 0 0 4px; }
.offen-thumb { width: 72px; height: 92px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); flex: none; }
a.offen-thumb.file { display: flex; align-items: center; justify-content: center; text-decoration: none; font-weight: 700; background: var(--bg); }
.offen-note { font-size: 1.05rem; }
.offen details { margin-top: 8px; }

/* Krankheit */
.shots { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.shot { position: relative; aspect-ratio: 4 / 3; border: 1.5px dashed var(--line); border-radius: 12px; overflow: hidden; cursor: pointer;
        display: flex; align-items: center; justify-content: center; color: var(--accent); font-weight: 600; }
.shot.done { border-style: solid; border-color: var(--accent); }
.shot img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.shot-text { display: flex; flex-direction: column; align-items: center; gap: 4px; position: relative;
             background: color-mix(in srgb, var(--card) 80%, transparent); padding: 6px 10px; border-radius: 8px; }
.rezept-neu { display: flex; flex-direction: column; gap: 10px; }
.rezept-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.pages { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pages figure { margin: 0; }
.pages img { width: 100%; border-radius: 6px; border: 1px solid var(--line); display: block; background: #fff; }
.pages figcaption { font-size: .78rem; color: var(--muted); margin-top: 4px; }
.nopage { aspect-ratio: 4 / 3; display: flex; align-items: center; justify-content: center; border: 1px dashed var(--line);
          border-radius: 6px; color: var(--muted); font-size: .85rem; }
.linkbtn { background: none; border: 0; padding: 0; min-height: 0; color: var(--accent); font-weight: 400; font-size: inherit; cursor: pointer; }

/* Mehr */
.menu { list-style: none; margin: 0; padding: 0; }
.menu li + li { border-top: 1px solid var(--line); }
.menu a { display: flex; flex-direction: column; padding: 11px 0; text-decoration: none; color: var(--text); }
.menu a span { color: var(--muted); font-size: .85rem; }
.menu a strong { color: var(--accent); }
@media (max-width: 560px) {
  .top { flex-wrap: nowrap; }
  .shots, .pages { gap: 8px; }
}
@media print { .bottombar { display: none !important; } }

/* Kamera oder Galerie */
.capture-buttons { grid-template-columns: repeat(3, 1fr); }
.bigbtn { padding: 18px 4px; font-size: .92rem; }
.shot { flex-direction: column; justify-content: space-between; cursor: default; padding: 8px; }
.shot-label { position: relative; font-size: .9rem; background: color-mix(in srgb, var(--card) 85%, transparent); padding: 2px 8px; border-radius: 6px; }
.shot-buttons { position: relative; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
.shot-buttons button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; min-height: 0;
                       font-size: .78rem; border-radius: 8px; }
.shot-buttons button + button { background: var(--card); color: var(--accent); border: 1px solid var(--line); }

/* Zuschnitt von Hand */
.cropper { position: relative; touch-action: none; user-select: none; margin-bottom: 14px; border-radius: 8px; overflow: visible; }
.cropper img { display: block; width: 100%; border-radius: 8px; }
.cropper svg { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.cropper polygon { fill: color-mix(in srgb, var(--accent) 10%, transparent); stroke: var(--accent); stroke-width: 2.5; }
.cropper .handle { position: absolute; width: 44px; height: 44px; min-height: 0; margin: -22px 0 0 -22px; padding: 0; border-radius: 50%;
                   background: transparent; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--accent), inset 0 0 0 2px var(--accent); touch-action: none; }
.crop-actions { display: flex; flex-direction: column; gap: 10px; }

/* ---------- Startseite, Belegliste, Beleg-Ansicht ---------- */
.bottombar a.add { flex: 0 0 58px; height: 58px; margin: -18px 6px 0; border-radius: 50%; background: var(--accent); color: var(--accent-text);
                   justify-content: center; box-shadow: 0 4px 14px rgba(0,0,0,.22); border: 4px solid var(--bg); }
.bottombar a.add svg { width: 30px; height: 30px; }
.bottombar a.add.active { background: var(--accent); color: var(--accent-text); }
.quick { display: grid; grid-template-columns: 2fr 1fr; gap: 10px; margin-bottom: 14px; }
.quick .bigbtn { text-decoration: none; font-weight: 600; text-align: center; padding: 18px 8px; }
a.bigbtn { background: var(--accent); color: var(--accent-text); }
a.bigbtn.ghost { background: var(--card); color: var(--accent); border: 1px solid var(--line); }
.todo { border-left: 4px solid #d29922; }
.tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.tile { margin: 0; padding: 10px 12px; text-decoration: none; color: var(--text); display: flex; flex-direction: column; min-width: 0; }
.tile .label { color: var(--muted); font-size: .8rem; }
.tile strong { font-size: 1.05rem; white-space: nowrap; }
.more { margin: 10px 0 0; text-align: center; }
.sumline { display: flex; gap: 18px; align-items: flex-end; padding: 12px 16px; }
.sumline .label { display: block; color: var(--muted); font-size: .78rem; }
.sumline strong { font-size: 1.25rem; white-space: nowrap; }
.sumline .right { margin-left: auto; text-align: right; }
.search { display: flex; gap: 8px; margin-bottom: 14px; }
.search input[type=search] { flex: 1; min-width: 0; background: var(--card); border-radius: 999px; padding: 10px 16px; }
.month h2 { display: flex; justify-content: space-between; align-items: baseline; color: var(--muted); font-size: .9rem;
            text-transform: uppercase; letter-spacing: .04em; margin-bottom: 2px; }
.month h2 .amount { font-size: .9rem; letter-spacing: 0; }
.rows { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--line); }
.rows a { display: flex; gap: 12px; align-items: center; padding: 10px 0; text-decoration: none; color: var(--text); }
.rows .pic { position: relative; flex: none; width: 46px; height: 58px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg);
             overflow: hidden; display: flex; align-items: center; justify-content: center; }
.rows .pic b { font-size: .62rem; color: var(--muted); text-align: center; line-height: 1.15; }
.rows .pic.none { border-style: dashed; border-color: #d29922; }
.rows .pic.none b { color: #b07d12; }
.rows .pic img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: top; background: #fff; }
.rows .what { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.rows .what strong { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rows .tags { display: flex; flex-wrap: wrap; gap: 2px 6px; align-items: center; }
.rows .tags .tag { margin: 0; font-size: .72rem; padding: 0 6px; }
.tag.ug { border-color: var(--accent); color: var(--accent); }
.rows .amt { flex: none; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.beleg-kopf { display: flex; flex-direction: column; gap: 12px; }
.beleg-bild { position: relative; display: flex; align-items: flex-start; justify-content: center; min-height: 90px; max-height: 420px; overflow: hidden;
              border: 1px solid var(--line); border-radius: 8px; background: var(--bg); text-decoration: none; }
.beleg-bild img { position: relative; width: 100%; display: block; background: #fff; }
.beleg-bild b { position: absolute; top: 34px; }
.beleg-fakten { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; }
.beleg-fakten .betrag { font-size: 1.6rem; }
.top h1 { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.del { margin-top: 14px; }
.danger-text { color: var(--danger); }
.newbox summary { color: var(--accent); list-style: none; }
.newbox summary::-webkit-details-marker { display: none; }
.newbox .plus { display: inline-block; width: 22px; height: 22px; line-height: 20px; text-align: center; border-radius: 50%;
                background: var(--accent); color: var(--accent-text); margin-right: 4px; }

/* Rezepte: Geprüft-Knopf, fertiges PDF, Ansicht des Berichts, Mitteilungen */
.check { display: flex; align-items: center; gap: .7rem; margin: .5rem 0 .7rem; }
.check .btn { flex: none; }
.card.ready { border-left: 4px solid var(--accent, #2456c5); }
.ready-buttons { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .6rem; }
table.bericht { width: 100%; border-collapse: collapse; font-size: .95rem; }
table.bericht th, table.bericht td { text-align: left; padding: .4rem .3rem; border-bottom: 1px solid rgba(0, 0, 0, .08); }
table.bericht .num { text-align: right; white-space: nowrap; }
.pushbox .btn { margin-top: .4rem; }
