/* ObjektFit Erfassungs-App
   Design: Mockups app\mockups\ (dunkle Variante Standard) + Z-Task-Prototyp; Branding: branding\BRANDING.md.
   Akzentfarben setzt theme.js je Mandant (Kontrast fuer Keller-Lesbarkeit wird dort erzwungen).
   Ampel-/Statusfarben sind themingfest. */

@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 400; font-display: swap; src: url('../fonts/poppins-latin-400-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 600; font-display: swap; src: url('../fonts/poppins-latin-600-normal.woff2') format('woff2'); }
@font-face { font-family: 'Poppins'; font-style: normal; font-weight: 700; font-display: swap; src: url('../fonts/poppins-latin-700-normal.woff2') format('woff2'); }

:root, [data-theme="dark"] {
  --page: #101113;
  --app: #1a1c1f;
  --surface: #24272b;
  --surface2: #2c3035;
  --surface3: #383d43;
  --border: #3a3f45;
  --dash: #4a4f56;
  --fg: #f3f1ec;
  --muted: #a29d94;
  --faint: #7d786f;
  --chev: #5f6570;
  --ok: #58b878;   --ok-bg: #1f3226;
  --warn: #e5be6a; --warn-bg: #38301c;
  --bad: #e88a80;  --bad-bg: #392225;
  --scrim: rgba(0, 0, 0, .6);
  /* Mandanten-Akzent (Standard: ObjektFit-Petrol auf dunkel), wird von theme.js ueberschrieben */
  --accent: #2cc5b6;
  --on-accent: #06231f;
  --accent-fg: #2cc5b6;
  --accent-tint: #133a36;
  color-scheme: dark;
}
[data-theme="light"] {
  --page: #e9e5dd;
  --app: #f5f3ef;
  --surface: #ffffff;
  --surface2: #ebe7e0;
  --surface3: #dcd7ce;
  --border: #e5e1d8;
  --dash: #c9c4ba;
  --fg: #26241f;
  --muted: #6f6a60;
  --faint: #8b867c;
  --chev: #b0aba1;
  --ok: #2e7d47;   --ok-bg: #e4f2e7;
  --warn: #9c6b12; --warn-bg: #f7ecd6;
  --bad: #b3372c;  --bad-bg: #fbe4e1;
  --scrim: rgba(38, 36, 31, .45);
  --accent: #0e7a72;
  --on-accent: #ffffff;
  --accent-fg: #0e7a72;
  --accent-tint: #d7f0ec;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--page); color: var(--fg);
  font-family: 'Poppins', 'Segoe UI', Verdana, sans-serif; font-size: 16px; line-height: 1.4;
  display: flex; justify-content: center; -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%; overscroll-behavior-y: none;
}
@media (min-width: 481px) { body { padding: 24px 16px; } }
.phone {
  position: relative; width: 100%; max-width: 440px; min-height: 100%; background: var(--app);
  display: flex; flex-direction: column;
}
@media (min-width: 481px) { .phone { border-radius: 28px; border: 1px solid var(--border); min-height: 0; height: min(880px, calc(100vh - 48px)); overflow: hidden; } }
.boot { flex: 1; display: flex; align-items: center; justify-content: center; }
.boot img { border-radius: 16px; opacity: .9; }

.screen { display: flex; flex-direction: column; flex: 1; min-height: 0; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
button { font: inherit; color: inherit; background: none; border: none; padding: 0; cursor: pointer; text-align: left; touch-action: manipulation; }
button:focus-visible, a:focus-visible, input:focus-visible, textarea:focus-visible { outline: 3px solid var(--accent-fg); outline-offset: 2px; border-radius: 12px; }
a { color: var(--accent-fg); }
svg { flex-shrink: 0; }

/* ---------------------------------------------------------------- Kopf */
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: calc(20px + env(safe-area-inset-top)) 20px 0; }
.brand { font-size: 12px; font-weight: 600; letter-spacing: 1.6px; color: var(--muted); text-transform: uppercase; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head-r { display: flex; gap: 8px; align-items: center; flex-shrink: 0; }
.iconbtn { width: 44px; height: 44px; border-radius: 12px; background: var(--surface); display: inline-flex; align-items: center; justify-content: center; color: var(--muted); }
.iconbtn:active { background: var(--surface2); }
.pill { display: inline-flex; align-items: center; gap: 6px; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill .dot { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.pill.on { background: var(--ok-bg); color: var(--ok); }
.pill.off { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
h1 { margin: 12px 20px 0; font-size: 28px; font-weight: 700; letter-spacing: -.3px; line-height: 1.2; }
.date { margin: 4px 20px 0; font-size: 14px; color: var(--muted); }

/* ---------------------------------------------------------------- Liste */
.chips { display: flex; gap: 8px; padding: 14px 20px 10px; flex-wrap: wrap; }
.chip, .tag { border-radius: 999px; padding: 6px 12px; font-size: 13px; font-weight: 600; white-space: nowrap; }
.tag { padding: 4px 10px; font-size: 12px; }
.bad-c { background: var(--bad-bg); color: var(--bad); }
.warn-c { background: var(--warn-bg); color: var(--warn); }
.ok-c { background: var(--ok-bg); color: var(--ok); }
.neutral-c { background: var(--surface2); color: var(--muted); }
.cards { display: flex; flex-direction: column; gap: 12px; padding: 4px 20px 16px; }
.card { display: flex; align-items: center; gap: 14px; background: var(--surface); border-radius: 16px; padding: 16px; width: 100%; min-height: 72px; }
button.card:active { background: var(--surface2); }
.c-main { display: flex; flex-direction: column; gap: 4px; flex: 1; min-width: 0; }
.c-title { font-size: 17px; font-weight: 600; line-height: 1.25; }
.c-sub { font-size: 14px; color: var(--muted); overflow-wrap: anywhere; }
.c-meta { display: flex; align-items: center; gap: 10px; margin-top: 4px; flex-wrap: wrap; }
.due { font-size: 13px; color: var(--muted); }
.card.done { opacity: .7; }
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 40px 28px 16px; color: var(--muted); }
.empty b { color: var(--fg); font-size: 19px; }
.foot { margin-top: auto; border-top: 1px solid var(--surface2); padding: 12px 20px 18px; display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--faint); width: 100%; min-height: 48px; }
.notice { display: flex; align-items: center; gap: 10px; margin: 6px 20px 4px; padding: 12px 14px; border-radius: 14px; font-size: 14px; font-weight: 600; width: calc(100% - 40px); }

/* ---------------------------------------------------------------- Unterseiten */
.banner { display: flex; align-items: center; gap: 10px; background: var(--warn-bg); color: var(--warn); padding: calc(11px + env(safe-area-inset-top)) 20px 11px; font-size: 13px; font-weight: 600; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 20px 0; }
.row.top { padding-top: calc(20px + env(safe-area-inset-top)); }
.backbtn { width: 48px; height: 48px; border-radius: 12px; background: var(--surface); display: flex; align-items: center; justify-content: center; flex-shrink: 0; color: var(--fg); }
.backbtn:active { background: var(--surface2); }
.t2 { font-size: 20px; font-weight: 700; line-height: 1.2; overflow-wrap: anywhere; }
.t2sub { font-size: 13px; color: var(--muted); margin-top: 2px; }

/* ---------------------------------------------------------------- Erfassung */
.meter { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 14px; padding: 13px 16px; margin: 14px 20px 0; gap: 12px; }
.m-l { font-size: 11px; font-weight: 600; letter-spacing: 1px; color: var(--muted); text-transform: uppercase; }
.m-v { font-size: 15px; font-weight: 600; }
.hint { display: flex; gap: 8px; align-items: center; margin: 10px 20px 0; font-size: 13px; color: var(--muted); }
.inlabel { margin: 14px 20px 0; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; }
.display { display: flex; align-items: center; justify-content: space-between; gap: 12px; background: var(--surface); border: 2px solid var(--border); border-radius: 14px; padding: 6px 18px; margin: 8px 20px 0; width: calc(100% - 40px); min-height: 64px; }
.display.active { border-color: var(--accent-fg); }
.display .lbl { font-size: 13px; font-weight: 600; color: var(--muted); min-width: 28px; }
.display b { font-size: 34px; font-weight: 700; letter-spacing: 1.5px; flex: 1; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.display b.empty-v { color: var(--faint); font-weight: 400; font-size: 20px; letter-spacing: 0; }
.display .unit { font-size: 16px; color: var(--muted); }
.display.small b { font-size: 28px; }
.plaus { display: flex; align-items: flex-start; gap: 6px; margin: 8px 20px 0; font-size: 14px; font-weight: 500; min-height: 20px; }
.plaus.ok { color: var(--ok); } .plaus.warn { color: var(--warn); } .plaus.bad { color: var(--bad); } .plaus.info { color: var(--muted); }
.pad { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 9px; margin: 12px 20px 0; }
.key { height: 56px; border-radius: 12px; background: var(--surface2); display: flex; align-items: center; justify-content: center; font-size: 23px; font-weight: 600; text-align: center; user-select: none; -webkit-user-select: none; }
.key:active { background: var(--surface3); }
.key[disabled] { opacity: .3; cursor: default; }
.cta { margin: 14px 20px 0; min-height: 56px; border-radius: 14px; background: var(--accent); color: var(--on-accent); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 18px; font-weight: 700; width: calc(100% - 40px); text-align: center; }
.cta:active { filter: brightness(.92); }
.cta[disabled] { opacity: .4; cursor: default; filter: none; }
.ghost { margin: 12px 20px 0; min-height: 52px; border-radius: 14px; border: 1px solid var(--dash); display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 16px; font-weight: 600; width: calc(100% - 40px); text-align: center; padding: 8px 12px; }
.ghost:active { background: var(--surface); }
.link { margin: 10px auto 18px; padding: 12px 16px; min-height: 48px; display: inline-flex; align-items: center; gap: 8px; font-size: 15px; font-weight: 600; color: var(--muted); align-self: center; }
.spacer { flex: 1; min-height: 12px; }
.bottom-pad { height: 20px; flex-shrink: 0; }

/* ---------------------------------------------------------------- Gespeichert */
.center { display: flex; flex-direction: column; align-items: center; text-align: center; padding: calc(56px + env(safe-area-inset-top)) 32px 0; }
.bigok { width: 84px; height: 84px; border-radius: 50%; display: flex; align-items: center; justify-content: center; }
.center h2 { margin: 20px 0 0; font-size: 27px; font-weight: 700; }
.center p { margin: 10px 0 0; font-size: 15px; line-height: 1.55; color: var(--muted); }
.queue { display: flex; flex-direction: column; gap: 10px; margin: 24px 20px 0; }
.qrow { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 14px; padding: 14px 16px; gap: 10px; }
.q-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.q-t { font-size: 15px; font-weight: 600; } .q-s { font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.q-st { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; flex-shrink: 0; }
.q-st.wait { color: var(--warn); } .q-st.sent { color: var(--ok); } .q-st.bad { color: var(--bad); }

/* ---------------------------------------------------------------- Anlagen-Auswahl */
.search { display: flex; align-items: center; gap: 10px; background: var(--surface); border-radius: 14px; padding: 0 16px; margin: 14px 20px 0; color: var(--muted); }
.search input { flex: 1; background: none; border: none; color: var(--fg); font: inherit; font-size: 17px; padding: 15px 0; min-width: 0; }
.search input:focus { outline: none; }
.search:focus-within { box-shadow: 0 0 0 2px var(--accent-fg); }
.sec { display: flex; align-items: center; gap: 7px; padding: 18px 20px 8px; font-size: 12px; font-weight: 600; letter-spacing: 1.2px; color: var(--accent-fg); text-transform: uppercase; }
.sec.mut { color: var(--muted); }
.near { display: flex; justify-content: space-between; align-items: center; background: var(--surface); border-radius: 16px; padding: 14px 16px; margin: 0 20px 10px; gap: 10px; width: calc(100% - 40px); min-height: 64px; }
.near.hot { box-shadow: inset 0 0 0 1px var(--accent-fg); }
.dist { font-size: 14px; font-weight: 700; color: var(--accent-fg); flex-shrink: 0; }
.trust { display: flex; gap: 8px; align-items: flex-start; padding: 2px 20px 0; font-size: 12px; line-height: 1.45; color: var(--faint); }
.az { display: flex; flex-direction: column; padding: 0 20px 20px; }
.azrow { display: flex; justify-content: space-between; align-items: center; padding: 14px 4px; border-bottom: 1px solid var(--surface2); font-size: 17px; font-weight: 500; gap: 10px; width: 100%; min-height: 56px; }
.azrow:active { background: var(--surface); }
.azrow .az-r { display: flex; align-items: center; gap: 8px; }
.azsub { display: block; font-size: 13px; color: var(--muted); font-weight: 400; }

/* ---------------------------------------------------------------- Login */
.login { display: flex; flex-direction: column; flex: 1; padding: calc(48px + env(safe-area-inset-top)) 24px 24px; }
.login .tile { width: 72px; height: 72px; border-radius: 16px; background: #fff; display: flex; align-items: center; justify-content: center; box-shadow: 0 0 0 1px #d8d4cb; }
.login .tile img { width: 72px; height: 72px; border-radius: 16px; }
.login h1 { margin: 22px 0 0; }
.login p { color: var(--muted); font-size: 15px; line-height: 1.5; margin: 10px 0 0; }
.codebox { margin-top: 26px; display: flex; flex-direction: column; gap: 8px; }
.codebox label { font-size: 13px; color: var(--muted); }
.codebox input { width: 100%; background: var(--surface); border: 2px solid var(--border); border-radius: 14px; color: var(--fg); font: inherit; font-size: 26px; font-weight: 600; letter-spacing: 3px; padding: 14px 16px; text-transform: uppercase; text-align: center; }
.codebox input:focus { outline: none; border-color: var(--accent-fg); }
.login .cta, .login .ghost { margin-left: 0; margin-right: 0; width: 100%; }
.err { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--bad-bg); color: var(--bad); font-size: 14px; font-weight: 600; }
.okmsg { margin-top: 12px; padding: 12px 14px; border-radius: 12px; background: var(--ok-bg); color: var(--ok); font-size: 14px; font-weight: 600; }
.small { font-size: 13px; color: var(--faint); line-height: 1.5; }

/* ---------------------------------------------------------------- Menue, Einstellungen, Meldungen */
.menu { display: flex; flex-direction: column; padding: 8px 20px 0; }
.mrow { display: flex; align-items: center; gap: 14px; padding: 16px 4px; border-bottom: 1px solid var(--surface2); width: 100%; min-height: 60px; font-size: 17px; font-weight: 500; }
.mrow .mr-r { margin-left: auto; color: var(--muted); font-size: 14px; display: flex; align-items: center; gap: 8px; }
.mrow:active { background: var(--surface); }
.toggle { width: 52px; height: 32px; border-radius: 16px; background: var(--surface3); position: relative; flex-shrink: 0; }
.toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .15s; }
.toggle.on { background: var(--accent); }
.toggle.on::after { left: 23px; }
.info { margin: 14px 20px 0; padding: 14px 16px; border-radius: 14px; background: var(--surface); font-size: 14px; color: var(--muted); line-height: 1.5; }
.info b { color: var(--fg); }
.msgs { display: flex; flex-direction: column; gap: 10px; padding: 14px 20px 0; }
.msg { background: var(--surface); border-radius: 14px; padding: 12px 14px; max-width: 92%; }
.msg.mine { align-self: flex-end; background: var(--accent-tint); }
.msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.msg .body { font-size: 15px; white-space: pre-wrap; overflow-wrap: anywhere; }
textarea { width: calc(100% - 40px); margin: 10px 20px 0; min-height: 110px; background: var(--surface); border: 2px solid var(--border); border-radius: 14px; color: var(--fg); font: inherit; font-size: 17px; padding: 12px 14px; resize: vertical; }
textarea:focus { outline: none; border-color: var(--accent-fg); }

/* ---------------------------------------------------------------- Bottom-Sheet */
.sheet-wrap { position: fixed; inset: 0; background: var(--scrim); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { width: 100%; max-width: 440px; max-height: 92vh; overflow-y: auto; background: var(--app); border-radius: 22px 22px 0 0; padding: 10px 0 calc(16px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }
.sheet .grab { width: 44px; height: 5px; border-radius: 3px; background: var(--surface3); margin: 0 auto 8px; }
.sheet h3 { margin: 8px 20px 0; font-size: 22px; font-weight: 700; line-height: 1.25; }
.sheet p { margin: 8px 20px 0; color: var(--muted); font-size: 15px; line-height: 1.5; }
.sheet .big-q { color: var(--fg); font-size: 17px; }
.opt { display: flex; align-items: center; gap: 12px; margin: 10px 20px 0; padding: 14px 16px; min-height: 58px; border-radius: 14px; background: var(--surface); width: calc(100% - 40px); font-size: 16px; font-weight: 600; }
.opt:active { background: var(--surface2); }
.opt.sel { box-shadow: inset 0 0 0 2px var(--accent-fg); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--fg); color: var(--app); padding: 12px 18px; border-radius: 12px; font-size: 14px; font-weight: 600; z-index: 30; max-width: calc(100% - 40px); box-shadow: 0 6px 24px rgba(0, 0, 0, .3); }
.update { display: flex; align-items: center; gap: 10px; padding: calc(10px + env(safe-area-inset-top)) 20px 10px; background: var(--accent-tint); font-size: 14px; font-weight: 600; }
.update button { margin-left: auto; padding: 8px 14px; border-radius: 10px; background: var(--accent); color: var(--on-accent); font-weight: 700; min-height: 40px; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
.medium { width: 44px; height: 44px; border-radius: 12px; background: var(--surface2); color: var(--accent-fg); display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0; }
