/* Lager der Gemeinde. Farben, Schrift und Formen folgen dem Optimaze-Dashboard:
   heller Grund, weiße Flächen mit runden Ecken, Mint als Akzent, Schiefer als Schrift. */
:root {
  color-scheme: light;
  --bg: #eef3f8;
  --surface: #ffffff;
  --surface-2: #f6f8fb;
  --ink: #252b35;
  --slate: #2d2e3c;
  --muted: #5f6b7a;
  --line: #e3e9f0;
  --line-strong: #cfd8e3;
  --accent: #20cda3;
  --accent-strong: #18b98f;
  --accent-ink: #0a7a5d;      /* Mint als Textfarbe, gut lesbar auf Weiß */
  --on-accent: #0c2b24;       /* Schrift auf Mint-Flächen */
  --accent-soft: #eafff8;
  --accent-line: #b9f2df;
  --focus: rgba(32, 205, 163, 0.35);
  --blue: #2f5fe0;
  --blue-soft: #edf2ff;
  --ok: #17794a;
  --ok-soft: #e6f7ee;
  --warn: #8a5300;
  --warn-soft: #fff3da;
  --bad: #c81e56;
  --bad-soft: #fff0f4;
  --bad-line: #ffd0de;
  --idle-soft: #eef1f5;
  --shadow: 0 12px 30px rgba(34, 48, 73, 0.06);
  --r: 14px;
  --r-btn: 12px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }
html { font-size: 17px; background: var(--bg); }
html.big { font-size: 20px; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 0 0, rgba(32, 205, 163, 0.1), transparent 34%), var(--bg);
  background-attachment: fixed;
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
[hidden] { display: none !important; }
img { max-width: 100%; height: auto; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 1.7rem; font-weight: 760; line-height: 1.1; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 1.1rem; font-weight: 720; }
h3 { font-size: 1rem; font-weight: 700; overflow-wrap: anywhere; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.wrap { max-width: 1120px; margin: 0 auto; padding-left: max(16px, env(safe-area-inset-left, 0px)); padding-right: max(16px, env(safe-area-inset-right, 0px)); }
.page { padding-block: 22px 120px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.stack.tight { gap: 10px; }
.row { display: inline-flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.lead { color: var(--muted); max-width: 62ch; }
.hint { color: var(--muted); font-weight: 400; font-size: 0.86rem; }
.eyebrow { color: var(--accent-ink); font-weight: 700; font-size: 0.9rem; }
.stand { color: var(--muted); font-size: 0.85rem; text-align: center; }

/* Kopfzeile */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20; background: rgba(255, 255, 255, 0.94); backdrop-filter: blur(14px); border-bottom: 1px solid var(--line); }
body::before { content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px); z-index: 30; background: #ffffff; }
.topbar { display: flex; align-items: center; gap: 18px; min-height: 64px; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--slate); }
.brand img { display: block; height: 34px; width: 34px; }
.product { font-weight: 780; font-size: 1.2rem; color: var(--slate); letter-spacing: -0.01em; }
.topactions { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line-strong); background: var(--surface-2); font-weight: 760; cursor: pointer; color: var(--slate); }

.tabs { display: flex; gap: 4px; margin-left: 12px; }
.tabs button { display: inline-flex; align-items: center; gap: 8px; border: 0; background: none; cursor: pointer; padding: 10px 14px; border-radius: var(--r-btn); font-weight: 700; color: var(--muted); min-height: 44px; }
.tabs button svg { display: none; }
.tabs button[aria-selected="true"] { background: var(--accent-soft); color: var(--accent-ink); }

/* Knöpfe */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 48px; padding: 10px 18px; border-radius: var(--r-btn); border: 1px solid var(--line-strong); background: #ffffff; color: #3b4654; font-weight: 720; cursor: pointer; text-align: center; }
.btn:not(:disabled):hover { box-shadow: 0 10px 26px rgba(34, 48, 73, 0.1); }
.btn.primary { border-color: var(--accent); background: var(--accent); color: var(--on-accent); box-shadow: 0 12px 30px rgba(32, 205, 163, 0.24); }
.btn.primary:not(:disabled):hover { background: var(--accent-strong); }
.btn.danger { border-color: var(--bad-line); background: var(--bad-soft); color: var(--bad); }
.btn.ghost { background: transparent; border-color: transparent; box-shadow: none; }
.btn.small { min-height: 44px; padding: 8px 14px; font-size: 0.92rem; }
.btn.big { min-height: 54px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.fab { display: none; }
.x { width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--surface-2); font-size: 1.5rem; line-height: 1; cursor: pointer; color: var(--muted); }

/* Flächen */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 18px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.panelhead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.count { min-width: 28px; height: 28px; padding: 0 9px; border-radius: 999px; background: var(--idle-soft); color: var(--muted); font-weight: 760; font-size: 0.85rem; display: inline-flex; align-items: center; justify-content: center; }
.count.hot { background: var(--accent); color: var(--on-accent); }
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.pagehead > div { display: flex; flex-direction: column; gap: 4px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.help { background: var(--accent-soft); border-color: var(--accent-line); box-shadow: none; }
.help ol { margin: 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; max-width: 65ch; }

/* Kennzahlen */
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.kpi .v { font-size: 2rem; font-weight: 780; line-height: 1.05; color: var(--slate); }
.kpi .l { color: var(--muted); font-size: 0.88rem; font-weight: 600; }
.kpi.alert { border-color: var(--bad-line); background: var(--bad-soft); }
.kpi.alert .v, .kpi.alert .l { color: var(--bad); }
.kpi.good .v { color: var(--accent-ink); }

/* Hinweise */
.note { border-radius: var(--r-btn); padding: 12px 14px; font-weight: 600; border: 1px solid transparent; }
.note.ok { background: var(--ok-soft); color: var(--ok); border-color: #c5ebd5; }
.note.bad { background: var(--bad-soft); color: var(--bad); border-color: var(--bad-line); }
.note.warn { background: var(--warn-soft); color: var(--warn); border-color: #f5dfae; }
.note.idle { background: var(--idle-soft); color: var(--muted); }
.note ul { margin: 0; padding-left: 1.1em; display: flex; flex-direction: column; gap: 4px; }
.note.confirm { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

/* Status-Schilder */
.pill { display: inline-flex; align-items: center; min-height: 28px; padding: 3px 11px; border-radius: 999px; font-size: 0.82rem; font-weight: 760; white-space: nowrap; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.info { background: var(--blue-soft); color: var(--blue); }
.pill.idle { background: var(--idle-soft); color: var(--muted); }

/* Listen mit Ausleihen */
.items { display: flex; flex-direction: column; }
.item { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; align-items: center; padding: 14px 0; border-top: 1px solid var(--line); }
.item:first-child { border-top: 0; padding-top: 2px; }
.item:last-child { padding-bottom: 2px; }
.item .main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.item .title { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.item .sub { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.item .when { font-weight: 650; font-size: 0.95rem; }
.item .when.late { color: var(--bad); }
.item .acts { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.empty { color: var(--muted); padding: 6px 0; }

/* Verlauf */
.log { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.log li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 10px 0; border-top: 1px solid var(--line); font-size: 0.94rem; }
.log li:first-child { border-top: 0; padding-top: 0; }
.log .meta { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.log .txt { overflow-wrap: anywhere; }

/* Werkzeugleiste */
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.search { flex: 1 1 240px; }
.seg { display: inline-flex; border: 1px solid var(--line-strong); border-radius: var(--r-btn); overflow: hidden; background: #ffffff; }
.seg button { border: 0; background: none; padding: 8px 14px; min-height: 48px; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--slate); color: #ffffff; }
.range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; gap: 8px; align-items: end; flex: 1 1 320px; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line-strong); background: #ffffff; border-radius: 999px; padding: 6px 14px; min-height: 40px; font-weight: 700; color: var(--muted); cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--slate); border-color: var(--slate); color: #ffffff; }
.lagerbar { align-items: center; }
.seg.wide { display: flex; width: 100%; }
.seg.wide button { flex: 1; }
.plist { display: flex; flex-direction: column; }
.prow { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 12px; align-items: center; padding: 12px 0; border: 0; border-top: 1px solid var(--line); background: none; text-align: left; cursor: pointer; width: 100%; }
.prow:first-child { border-top: 0; padding-top: 2px; }
.prow .sub { color: var(--muted); font-size: 0.92rem; }
.proj { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; min-width: 0; width: 100%; }
.proj:hover { border-color: var(--accent-line); }
.proj .head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.proj .dates { font-weight: 650; }
.proj .sub { color: var(--muted); font-size: 0.92rem; overflow-wrap: anywhere; }
.proj .pills { display: flex; gap: 6px; flex-wrap: wrap; }
.linkish { border: 0; background: none; padding: 0; color: var(--accent-ink); font-weight: 700; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; font-size: inherit; }
.lagerbar .chip { min-height: 46px; padding-inline: 18px; }
.lagerbar .chip.add { border-style: dashed; }
.lagerbar .chip:disabled { opacity: 1; cursor: default; }

/* Geräte */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.device { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; display: flex; flex-direction: column; gap: 12px; cursor: pointer; min-width: 0; width: 100%; }
.device:hover { border-color: var(--accent-line); }
.device .head { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.device .cat { color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.device .free { display: flex; align-items: baseline; gap: 8px; }
.device .free b { font-size: 1.9rem; font-weight: 780; line-height: 1; color: var(--slate); }
.device .free span { color: var(--muted); font-weight: 600; }
.bar { display: flex; height: 10px; border-radius: 999px; overflow: hidden; background: var(--idle-soft); }
.bar i { display: block; height: 100%; }
.bar .free-part { background: var(--accent); }
.bar .out-part { background: var(--blue); }
.bar .def-part { background: var(--bad); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 0.86rem; font-weight: 600; }
.legend span::before { content: ""; display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; background: var(--c); }
.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.fact { background: var(--surface-2); border-radius: var(--r-btn); padding: 10px 12px; display: flex; flex-direction: column; }
.fact b { font-size: 1.3rem; font-weight: 760; }
.fact span { color: var(--muted); font-size: 0.84rem; font-weight: 600; overflow-wrap: anywhere; }

/* Formulare */
.f { display: flex; flex-direction: column; gap: 6px; font-size: 0.94rem; font-weight: 700; min-width: 0; }
input, select { font-size: max(16px, 1rem); min-height: 50px; width: 100%; min-width: 0; padding: 10px 12px; border-radius: var(--r-btn); border: 1px solid var(--line-strong); background: #ffffff; color: var(--ink); font-weight: 500; }
input:focus, select:focus { outline: 3px solid var(--focus); border-color: var(--accent); }
/* Zahlenfelder ohne Pfeile: Zählen geht über die Knöpfe − und + */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; appearance: none; margin: 0; }
input[type="date"] { -webkit-appearance: none; appearance: none; display: block; max-width: 100%; text-align: left; }
input[type="date"]::-webkit-date-and-time-value { text-align: left; margin: 0; }
input[type="date"]::-webkit-calendar-picker-indicator { margin: 0; }
.grid2 { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; }
.grid2 .full { grid-column: 1 / -1; }
fieldset.step { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 10px; min-width: 0; }
fieldset.step legend { padding: 0; font-weight: 760; font-size: 1.02rem; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.nr { width: 28px; height: 28px; border-radius: 50%; background: var(--slate); color: #ffffff; display: inline-flex; align-items: center; justify-content: center; font-size: 0.85rem; }
.lrow { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; }
.stepper { display: flex; gap: 4px; align-items: stretch; }
.stepper input { width: 3.4em; text-align: center; font-weight: 720; padding-inline: 4px; }
.stepper .btn { min-width: 48px; padding: 0; font-size: 1.3rem; }
details.more { border: 1px solid var(--line-strong); border-radius: var(--r-btn); padding: 0 14px; }
details.more summary { cursor: pointer; font-weight: 700; padding: 13px 0; }
details.more[open] { padding-bottom: 14px; }

/* Dialoge */
dialog { border: 0; padding: 0; background: var(--surface); color: var(--ink); border-radius: 18px; width: min(580px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px rgba(20, 28, 45, 0.3); }
dialog::backdrop { background: rgba(37, 43, 53, 0.55); }
.sheet { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.sheethead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.actions .spacer { flex: 1; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu .btn { justify-content: flex-start; }

/* Anmeldung */
.login { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
.login-card { width: 100%; max-width: 430px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; box-shadow: 0 18px 48px rgba(34, 48, 73, 0.1); padding: 28px 24px; display: flex; flex-direction: column; gap: 16px; }
.login-logo { height: 52px; width: 52px; align-self: flex-start; }
.login-card h1 { margin-bottom: 4px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom, 0px)); background: var(--slate); color: #ffffff; padding: 12px 18px; border-radius: var(--r-btn); font-weight: 600; z-index: 60; max-width: calc(100vw - 32px); box-shadow: 0 14px 40px rgba(20, 28, 45, 0.3); }

/* Handy: Navigation unten, Dialoge als Blatt von unten */
@media (max-width: 760px) {
  .desk { display: none; }
  .topbar { min-height: 58px; }
  .top { position: static; backdrop-filter: none; background: #ffffff; }
  .tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; margin: 0; gap: 0; background: #ffffff; border-top: 1px solid var(--line);
    padding: 4px max(8px, env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) max(8px, env(safe-area-inset-left, 0px)); }
  .tabs button { flex: 1; flex-direction: column; gap: 2px; font-size: 0.8rem; padding: 6px 4px; min-height: 54px; }
  .tabs button svg { display: block; }
  .tabs button[aria-selected="true"] { background: none; }
  .tabs button[aria-selected="true"] svg { stroke: var(--accent-strong); }
  .page { padding-block: 18px calc(170px + env(safe-area-inset-bottom, 0px)); }
  .fab { display: inline-flex; position: fixed; z-index: 24; left: max(16px, env(safe-area-inset-left, 0px)); right: max(16px, env(safe-area-inset-right, 0px)); bottom: calc(76px + env(safe-area-inset-bottom, 0px)); min-height: 54px; font-size: 1.05rem; border-radius: 16px; }
  #toast { bottom: calc(148px + env(safe-area-inset-bottom, 0px)); }
  .kpis { grid-template-columns: 1fr 1fr; }
  .cols { grid-template-columns: 1fr; }
  .item { grid-template-columns: minmax(0, 1fr); }
  .log li { grid-template-columns: minmax(0, 1fr); }
  .log .meta { white-space: normal; }
  .lrow { grid-template-columns: minmax(0, 1fr) auto; }
  .lrow select { grid-column: 1 / -1; }
  .lagerbar { flex-wrap: nowrap; gap: 6px; }
  .lagerbar .chip { flex: 1 1 auto; padding-inline: 8px; font-size: 0.92rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .lrow .stepper input { width: 4.5em; }
  .item .acts { justify-content: flex-start; }
  .grid2:not(.keep) { grid-template-columns: minmax(0, 1fr); }
  .toolbar .seg { width: 100%; }
  .toolbar .seg button { flex: 1; padding-inline: 6px; }
  .range { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); flex-basis: 100%; }
  .range #avToday { grid-column: 1 / -1; }
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 20px 20px 0 0; max-height: calc(100dvh - 40px - env(safe-area-inset-top, 0px)); }
  .sheet { padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
  .actions .btn.primary { flex: 1 1 100%; order: -1; }
  .actions .spacer { display: none; }
  .actions .btn { flex: 1; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
