/* Puls & Pegel – mobile first. Farben aus dem Logo-Paket: Navy #071c38, Türkis #12c9c9, Orange #ff9828 */
:root {
  --navy: #071c38;
  --navy-2: #12305a;
  --teal: #12c9c9;
  --teal-ink: #0b7d80;
  --orange: #ff9828;
  --orange-ink: #b35c00;
  --bg: #f3f5f8;
  --card: #ffffff;
  --ink: #0d1b2e;
  --mute: #5b6676;
  --line: #dde2ea;
  --soft: #eef2f7;
  --ok: #1f8a5b;
  --ok-bg: #e5f5ed;
  --warn: #9a5b00;
  --warn-bg: #fff3df;
  --err: #b42318;
  --err-bg: #fdecea;
  --info-bg: #e3f8f8;
  --zero: #cdeff0;
  --heat-1: #ffe9cf;
  --heat-2: #ffcf94;
  --heat-3: #ffad55;
  --heat-4: #f2811b;
  --heat-5: #b85500;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(7, 28, 56, .06), 0 2px 8px rgba(7, 28, 56, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0a1424;
    --card: #12203a;
    --ink: #e8eef7;
    --mute: #9aa8bd;
    --line: #233656;
    --soft: #182a48;
    --ok: #4cc38a;
    --ok-bg: #133a2c;
    --warn: #ffbf5e;
    --warn-bg: #3a2a10;
    --err: #ff8a80;
    --err-bg: #3d1a1a;
    --info-bg: #0f3438;
    --zero: #1a4a50;
    --heat-1: #4a3418;
    --heat-2: #6d4515;
    --heat-3: #a65f12;
    --heat-4: #e07a12;
    --heat-5: #ffa040;
    --teal-ink: #52dede;
    --orange-ink: #ffb066;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 16px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
}
a { color: var(--teal-ink); }
h1, h2, h3 { line-height: 1.2; margin: 0 0 .5rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: .4rem 0; }
small, .small { font-size: .85rem; }
.mute { color: var(--mute); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: var(--navy); color: #fff;
  display: flex; align-items: center; gap: .6rem;
  padding: .55rem 1rem; padding-top: max(.55rem, env(safe-area-inset-top));
}
.topbar a.brand { display: flex; align-items: center; gap: .55rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.1rem; }
.topbar a.brand img { width: 32px; height: 32px; border-radius: 8px; }
.topbar a.brand .amp { color: var(--teal); }
.topbar .spacer { flex: 1; }
.topbar .iconbtn { color: #fff; background: transparent; border: 0; width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.topbar .iconbtn:hover { background: rgba(255,255,255,.1); }
.topbar .iconbtn svg { width: 24px; height: 24px; }

main { max-width: 860px; margin: 0 auto; padding: 1rem 1rem 5rem; }

.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 1rem; margin-bottom: 1rem; border: 1px solid var(--line); }
.card.flush { padding: 0; overflow: hidden; }
.row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
@media (max-width: 520px) { .grid3.stack { grid-template-columns: 1fr; } }

/* Startseite – Kopf */
.today-head .date { font-weight: 600; color: var(--mute); }
.kpis { display: grid; grid-template-columns: 1fr 1fr; gap: .75rem; margin: .75rem 0 1rem; }
.kpi { background: var(--soft); border-radius: 12px; padding: .7rem .8rem; }
.kpi .label { font-size: .8rem; color: var(--mute); }
.kpi .value { font-size: 1.6rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.kpi .value small { font-size: .9rem; font-weight: 600; }
.kpi .sub { font-size: .8rem; color: var(--mute); }

/* Schaltflächen */
button, .btn {
  font: inherit; cursor: pointer; border-radius: 12px; border: 1px solid var(--line);
  background: var(--card); color: var(--ink); padding: .7rem 1rem; min-height: 48px;
  display: inline-flex; align-items: center; justify-content: center; gap: .45rem; text-decoration: none; font-weight: 600;
}
button:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--navy); border-color: var(--navy); color: #fff; }
.btn-teal { background: var(--teal); border-color: var(--teal); color: var(--navy); }
.btn-orange { background: var(--orange); border-color: var(--orange); color: var(--navy); }
.btn-danger { color: var(--err); border-color: currentColor; background: transparent; }
.btn-ghost { background: transparent; border-color: transparent; color: var(--teal-ink); }
.btn-small { min-height: 36px; padding: .35rem .7rem; font-size: .9rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn svg, button svg { width: 22px; height: 22px; flex: none; }
.actions-big { display: grid; grid-template-columns: repeat(3, 1fr); gap: .6rem; }
.actions-big .btn { flex-direction: column; min-height: 84px; font-size: .92rem; text-align: center; }
.actions-big .btn svg { width: 28px; height: 28px; }
@media (min-width: 640px) { .actions-big .btn { flex-direction: row; min-height: 60px; } }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--teal); outline-offset: 2px; }

/* Formulare */
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: .25rem; }
.field { margin-bottom: .8rem; }
.field .hint { font-size: .8rem; color: var(--mute); margin-top: .2rem; }
input, select, textarea {
  font: inherit; width: 100%; padding: .65rem .75rem; min-height: 48px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--card); color: var(--ink);
}
textarea { min-height: 110px; resize: vertical; }
input[type=checkbox], input[type=radio] { width: 22px; height: 22px; min-height: 0; accent-color: var(--navy); }
.check { display: flex; gap: .6rem; align-items: flex-start; font-weight: 500; }
.check input { flex: none; margin-top: .1rem; }
input.big { font-size: 1.6rem; font-weight: 700; text-align: center; min-height: 64px; font-variant-numeric: tabular-nums; }
.inline-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: .6rem; }
.invalid { border-color: var(--err) !important; background: var(--err-bg) !important; }

/* Segment-Umschalter */
.segmented { display: flex; background: var(--soft); border-radius: 12px; padding: 4px; gap: 4px; margin-bottom: 1rem; }
.segmented button { flex: 1; border: 0; background: transparent; min-height: 42px; border-radius: 9px; font-weight: 600; color: var(--mute); }
.segmented button[aria-pressed=true] { background: var(--card); color: var(--ink); box-shadow: var(--shadow); }

/* Hinweise */
.note { border-radius: 12px; padding: .75rem .9rem; margin-bottom: 1rem; border: 1px solid transparent; }
.note.info { background: var(--info-bg); }
.note.warn { background: var(--warn-bg); color: var(--warn); border-color: rgba(154, 91, 0, .25); }
.note.err { background: var(--err-bg); color: var(--err); }
.note.ok { background: var(--ok-bg); color: var(--ok); }
.note .row { margin-top: .5rem; }
.reminder { background: var(--navy); color: #fff; border-radius: var(--radius); padding: 1rem; margin-bottom: 1rem; }
.reminder h2 { color: #fff; }
.reminder .btn { border-color: rgba(255,255,255,.3); }

/* Tagesliste */
.daylist { list-style: none; margin: 0; padding: 0; }
.daylist li a {
  display: grid; grid-template-columns: 5.6rem 4.6rem 1fr; gap: .5rem; align-items: center;
  padding: .7rem 1rem; border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; min-height: 56px;
}
.daylist li a:hover { background: var(--soft); }
.daylist .d { font-weight: 600; font-variant-numeric: tabular-nums; }
.daylist .g { text-align: right; font-weight: 750; font-variant-numeric: tabular-nums; }
.daylist .g.zero { color: var(--mute); font-weight: 500; }
.daylist .meta { display: flex; flex-wrap: wrap; gap: .3rem .5rem; align-items: center; font-size: .85rem; min-width: 0; }
.daylist .meta .txt { color: var(--mute); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.daylist .head { display: grid; grid-template-columns: 5.6rem 4.6rem 1fr; gap: .5rem; padding: .5rem 1rem; font-size: .78rem; color: var(--mute); border-bottom: 1px solid var(--line); background: var(--soft); }
.daylist .head span:nth-child(2) { text-align: right; }
.bpval { font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }

.chip { display: inline-flex; align-items: center; gap: .25rem; font-size: .75rem; font-weight: 650; padding: .12rem .5rem; border-radius: 999px; background: var(--soft); color: var(--mute); white-space: nowrap; }
.chip.st-offen { background: transparent; border: 1px dashed var(--mute); }
.chip.st-erfasst { background: #fff0dd; color: var(--orange-ink); }
.chip.st-importiert { background: #ece9f8; color: #4c3f99; }
.chip.st-unvollstaendig { background: var(--warn-bg); color: var(--warn); }
.chip.st-alkoholfrei_bestaetigt { background: var(--ok-bg); color: var(--ok); }
.chip.st-alkoholfrei_auto { background: var(--zero); color: var(--teal-ink); }
.chip.st-konflikt { background: var(--err-bg); color: var(--err); }
.chip.est { background: transparent; border: 1px solid var(--line); }
@media (prefers-color-scheme: dark) {
  .chip.st-erfasst { background: #3a2a12; }
  .chip.st-importiert { background: #2a2650; color: #bdb4ff; }
}

/* Positionen (Bestätigung) */
.pos { border: 1px solid var(--line); border-radius: 12px; padding: .85rem; margin-bottom: .8rem; background: var(--card); }
.pos .pos-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.pos .grams { font-size: 1.25rem; font-weight: 750; font-variant-numeric: tabular-nums; }
.pos .grams.unknown { color: var(--warn); font-size: 1rem; }
.pos .assume { background: var(--warn-bg); color: var(--warn); border-radius: 10px; padding: .55rem .7rem; margin: .4rem 0; }
.pos .warnings { margin: .3rem 0 0; padding-left: 1.1rem; color: var(--warn); font-size: .85rem; }
.pos .research { background: var(--info-bg); border-radius: 10px; padding: .55rem .7rem; margin-top: .5rem; font-size: .9rem; }
.quick { display: flex; flex-wrap: wrap; gap: .35rem; margin-top: .35rem; }
.quick button { min-height: 34px; padding: .2rem .6rem; font-size: .85rem; border-radius: 999px; font-weight: 600; }

.mic { width: 64px; height: 64px; border-radius: 50%; background: var(--orange); border: 0; color: var(--navy); flex: none; }
.mic svg { width: 30px; height: 30px; }
.mic.listening { background: #e5484d; color: #fff; animation: pulse 1.2s infinite; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(229,72,77,.5); } 70% { box-shadow: 0 0 0 14px rgba(229,72,77,0); } 100% { box-shadow: 0 0 0 0 rgba(229,72,77,0); } }
.input-with-mic { display: flex; gap: .75rem; align-items: flex-start; }
.input-with-mic textarea { flex: 1; }

/* Listen im Tagesdetail */
.items { list-style: none; padding: 0; margin: 0; }
.items li { display: flex; gap: .75rem; align-items: center; justify-content: space-between; padding: .7rem 0; border-bottom: 1px solid var(--line); }
.items li:last-child { border-bottom: 0; }
.items .main { min-width: 0; }
.items .main .t { font-weight: 650; }
.items .main .s { font-size: .85rem; color: var(--mute); }
.items .val { font-weight: 750; font-variant-numeric: tabular-nums; white-space: nowrap; }

.daynav { display: flex; align-items: center; justify-content: space-between; gap: .5rem; margin-bottom: .75rem; }
.daynav h1 { margin: 0; text-align: center; flex: 1; font-size: 1.15rem; }

/* Diagramme */
.chart { width: 100%; height: auto; display: block; }
.chart text { font: 11px system-ui, sans-serif; fill: var(--mute); }
.chart .grid { stroke: var(--line); stroke-width: 1; }
.chart .axis { stroke: var(--mute); stroke-width: 1; }
.chart .bar { fill: var(--orange); }
.chart .bar.imp { fill: #b9a9ff; }
.chart .bar.prov { fill: none; stroke: var(--orange); stroke-dasharray: 3 2; stroke-width: 1.5; }
.chart .zero { fill: var(--teal); }
.chart .zero.auto { fill: none; stroke: var(--teal); stroke-width: 1.4; }
.chart .conf { fill: var(--err); font-weight: 700; }
.chart .sys { fill: var(--navy); }
.chart .dia { fill: var(--card); stroke: var(--teal-ink); stroke-width: 2; }
.chart .link { stroke: var(--mute); stroke-width: 1; opacity: .6; }
.chart .phase-gap { fill: var(--soft); stroke: var(--teal-ink); stroke-width: 1; stroke-dasharray: 4 3; }
.chart text.phase-label { fill: var(--teal-ink); font-style: italic; font-weight: 600; }
.paper .chart .phase-gap { fill: #eee; stroke: #777; }
.paper .chart text.phase-label { fill: #333; }
@media (prefers-color-scheme: dark) { .chart .sys { fill: #e8eef7; } }
.legend { display: flex; flex-wrap: wrap; gap: .4rem 1rem; font-size: .8rem; color: var(--mute); margin-top: .5rem; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -2px; margin-right: .3rem; }

/* Kalender */
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal .wd { text-align: center; font-size: .75rem; color: var(--mute); font-weight: 600; padding-bottom: .2rem; }
.cal a, .cal span.empty { aspect-ratio: 1; border-radius: 8px; display: flex; flex-direction: column; align-items: center; justify-content: center; text-decoration: none; color: var(--ink); font-size: .8rem; position: relative; }
.cal a { background: var(--soft); }
.cal a .dn { font-weight: 650; font-size: .8rem; }
.cal a .gv { font-size: .68rem; font-variant-numeric: tabular-nums; }
.cal a.h0 { background: var(--zero); }
.cal a.h1 { background: var(--heat-1); }
.cal a.h2 { background: var(--heat-2); }
.cal a.h3 { background: var(--heat-3); }
.cal a.h4 { background: var(--heat-4); color: #fff; }
.cal a.h5 { background: var(--heat-5); color: #fff; }
.cal a.nodata { background: transparent; color: var(--mute); border: 1px solid var(--line); }
.cal a.today { outline: 2px dashed var(--navy); outline-offset: -2px; }
@media (prefers-color-scheme: dark) { .cal a.today { outline-color: var(--teal); } }
.cal a.conflict::after { content: "!"; position: absolute; top: 2px; right: 5px; color: var(--err); font-weight: 800; }
.cal a.auto .dn::after { content: ""; }
.cal a.bp::before { content: ""; position: absolute; bottom: 4px; width: 5px; height: 5px; border-radius: 50%; background: var(--navy); }
@media (prefers-color-scheme: dark) { .cal a.bp::before { background: #e8eef7; } }
.cal-legend { display: flex; flex-wrap: wrap; gap: .3rem .8rem; margin-top: .75rem; font-size: .78rem; color: var(--mute); align-items: center; }
.cal-legend i { display: inline-block; width: 14px; height: 14px; border-radius: 4px; vertical-align: -3px; margin-right: .25rem; }

/* Tabellen */
table.data { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.data th, table.data td { padding: .45rem .5rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
table.data th { font-size: .78rem; color: var(--mute); font-weight: 650; background: var(--soft); }
table.data td.r, table.data th.r { text-align: right; font-variant-numeric: tabular-nums; }
.table-wrap { overflow-x: auto; }

/* Bericht-Vorschau */
.paper { background: #fff; color: #000; border-radius: 6px; padding: 1.2rem; box-shadow: var(--shadow); border: 1px solid var(--line); }
.paper h2, .paper h3 { color: #000; }
.paper .kv { display: grid; grid-template-columns: minmax(9rem, 14rem) 1fr; gap: .2rem .8rem; font-size: .9rem; }
.paper .kv dt { color: #444; }
.paper .kv dd { margin: 0; font-weight: 650; }
.paper ul { padding-left: 1.1rem; font-size: .88rem; }
.paper table.data th { background: #eee; color: #333; }
.paper table.data td, .paper table.data th { border-color: #ddd; }
.paper .chart text { fill: #444; }
.paper .chart .grid { stroke: #ccc; }
.paper .chart .bar { fill: #333; }
.paper .chart .bar.imp { fill: #8a8a8a; }
.paper .chart .bar.prov { stroke: #333; }
.paper .chart .zero { fill: #333; }
.paper .chart .zero.auto { stroke: #333; fill: none; }
.paper .chart .sys { fill: #000; }
.paper .chart .dia { fill: #fff; stroke: #000; }
.pdf-frame { width: 100%; height: 75vh; border: 1px solid var(--line); border-radius: 8px; background: #fff; }

/* Dialog / Toast */
dialog { border: 0; border-radius: var(--radius); padding: 1.2rem; max-width: min(92vw, 460px); background: var(--card); color: var(--ink); box-shadow: 0 10px 40px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(7, 28, 56, .55); }
dialog .row { justify-content: flex-end; margin-top: 1rem; }
.toast { position: fixed; left: 50%; bottom: max(1.2rem, env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--navy); color: #fff; padding: .75rem 1.1rem; border-radius: 12px; z-index: 100; box-shadow: 0 6px 24px rgba(0,0,0,.25); max-width: 92vw; }
.toast.err { background: var(--err); }

/* Anmeldung */
.login { max-width: 420px; margin: 8vh auto; }
.login .logo { width: 100%; max-width: 340px; display: block; margin: 0 auto 1rem; }
@media (prefers-color-scheme: dark) { .login .logo-light { display: none; } }
@media (prefers-color-scheme: light) { .login .logo-dark { display: none; } }

details > summary { cursor: pointer; font-weight: 600; min-height: 32px; }
.loading { padding: 2rem; text-align: center; color: var(--mute); }
hr { border: 0; border-top: 1px solid var(--line); margin: 1rem 0; }

@media print {
  .topbar, .no-print { display: none !important; }
  body { background: #fff; }
  main { padding: 0; }
}
