:root {
  --bg: #0d1117;
  --card: #161b22;
  --card2: #1f2630;
  --line: #2a323d;
  --text: #e6edf3;
  --muted: #8b98a5;
  --hot: #ff7a45;
  --hot2: #ff9f1c;
  --ok: #3fb950;
  --warn: #d29922;
  --err: #f85149;
  --cold: #58a6ff;
  --radius: 18px;
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body {
  font: 17px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  min-height: 100dvh;
}
[hidden] { display: none !important; }
h1 { font-size: 28px; margin: 0; }
h2 { font-size: 18px; color: var(--muted); margin: 22px 4px 8px; font-weight: 600; }

.screen { padding-top: env(safe-area-inset-top); min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-box { width: 100%; max-width: 360px; display: grid; gap: 14px; text-align: center; }
.logo { font-size: 56px; }

.top { flex: none; display: flex; align-items: center; justify-content: space-between; padding: calc(12px + env(safe-area-inset-top)) 16px 4px; }
/* App-Hülle: Kopf, scrollender Inhalt, Tab-Leiste als normales Element (kein position:fixed –
   das ist in iOS-Safari unzuverlässig: Taps landen in der eingeklappten Browserleiste). */
#app { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
#app main { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; width: 100%; }
main { padding: 8px 16px 24px; }
main > .view { max-width: 640px; margin: 0 auto; }
.view { display: grid; gap: 12px; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.warn { border-color: var(--warn); background: #2b2111; }
.card.accent { border-color: var(--hot); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.label { color: var(--muted); font-size: 14px; text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.big { font-size: 44px; font-weight: 700; line-height: 1.05; font-variant-numeric: tabular-nums; }
.sub { color: var(--muted); margin-top: 6px; font-variant-numeric: tabular-nums; }
.small { font-size: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.right { text-align: right; }
.wtext { font-size: 20px; font-weight: 600; }
.next { font-size: 20px; font-weight: 600; }
.on-state { color: var(--hot); }
.off-state { color: var(--muted); }
.bar { height: 10px; background: var(--card2); border-radius: 6px; overflow: hidden; margin-top: 10px; }
.bar > div { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), #7ee787); transition: width .4s; }
.bar.low > div { background: var(--err); }
.bar.mid > div { background: var(--warn); }

.btn {
  appearance: none; border: 1px solid var(--line); background: var(--card2); color: var(--text);
  border-radius: 14px; padding: 12px 16px; font: inherit; font-weight: 600; min-height: 48px; cursor: pointer;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: linear-gradient(135deg, var(--hot), var(--hot2)); border: none; color: #1b0d00; }
.btn.big { min-height: 60px; font-size: 20px; }
.btn.ghost { background: transparent; }
.btn[disabled] { opacity: .5; }
.btn-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.icon-btn { background: none; border: none; color: var(--text); font-size: 24px; position: relative; min-width: 48px; min-height: 48px; }
.badge { position: absolute; top: 6px; right: 4px; background: var(--err); color: #fff; font-size: 12px; border-radius: 10px; padding: 1px 6px; }

input[type=password], .time-input {
  width: 100%; font: inherit; font-size: 20px; padding: 14px; border-radius: 14px; border: 1px solid var(--line);
  background: var(--card2); color: var(--text); min-height: 56px;
}
.time-input { font-size: 44px; font-weight: 700; text-align: center; margin: 10px 0 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chips button {
  flex: 1 1 auto; min-height: 48px; border-radius: 12px; border: 1px solid var(--line); background: var(--card2);
  color: var(--text); font: inherit; font-weight: 600; padding: 8px 12px;
}
.chips button.on { background: var(--hot); color: #1b0d00; border-color: var(--hot); }
.weekdays { margin-top: 10px; }
.weekdays button { flex: 1 1 0; padding: 8px 0; }
.stepper { display: grid; grid-template-columns: 72px 1fr 72px; align-items: center; text-align: center; gap: 8px; margin-bottom: 12px; }
.stepper.small { grid-template-columns: 56px 1fr 56px; margin: 8px 0 0; font-size: 22px; font-weight: 700; }
.check { display: flex; gap: 10px; align-items: center; color: var(--muted); margin: 8px 0; min-height: 44px; }
.check input { width: 24px; height: 24px; accent-color: var(--hot); }
.field { display: block; color: var(--muted); margin-bottom: 14px; }
.preview { background: var(--card2); border-radius: 14px; padding: 14px; margin: 12px 0; font-size: 18px; min-height: 52px; }
.preview.warn { border: 1px solid var(--warn); }
.err { color: var(--err); min-height: 1em; margin: 6px 0 0; }

.plan { display: grid; gap: 8px; }
.plan-head { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.plan-title { font-size: 20px; font-weight: 700; }
.pill { font-size: 13px; padding: 3px 10px; border-radius: 999px; background: var(--card2); color: var(--muted); white-space: nowrap; }
.pill.planned { color: var(--ok); }
.pill.warning, .pill.failed { color: var(--warn); }
.pill.running { color: var(--hot); }
.plan-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.plan-actions .btn { flex: 1; min-height: 44px; padding: 8px; font-size: 15px; }
.fb { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.fb .btn { min-height: 60px; }
.services div { display: flex; flex-wrap: wrap; gap: 2px 12px; justify-content: space-between; padding: 8px 0; border-bottom: 1px solid var(--line); }
.dot-ok { color: var(--ok); } .dot-err { color: var(--err); }
.mono { font: 12px/1.4 ui-monospace, Menlo, monospace; white-space: pre-wrap; color: var(--muted); }
.hist { display: grid; gap: 4px; }
.hist .row { font-size: 15px; }

.tabs {
  flex: none; position: relative; z-index: 5; display: grid; grid-template-columns: repeat(4, 1fr);
  background: rgba(13, 17, 23, .94); backdrop-filter: blur(12px); border-top: 1px solid var(--line);
  padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
}
.tabs button { touch-action: manipulation; cursor: pointer; background: none; border: none; color: var(--muted); font: inherit; font-size: 12px; display: grid; gap: 2px; justify-items: center; min-height: 56px; }
.tabs button span { font-size: 22px; }
.tabs button.on { color: var(--hot); }

.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.6); display: flex; align-items: flex-end; z-index: 10; }
.sheet-inner { background: var(--card); width: 100%; max-height: 80dvh; overflow: auto; border-radius: 20px 20px 0 0; padding: 16px 16px calc(16px + env(safe-area-inset-bottom)); }
.sheet-head { display: flex; justify-content: space-between; align-items: center; }
.note { border-bottom: 1px solid var(--line); padding: 10px 0; }
.note .t { font-weight: 600; }
.note.error .t { color: var(--err); } .note.warn .t { color: var(--warn); }
.toast { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom)); background: var(--card2); border: 1px solid var(--line); border-radius: 14px; padding: 14px; text-align: center; z-index: 20; }

@media (max-width: 360px) { .big { font-size: 36px; } }
#plan-form > .btn.primary, #login-form .btn { width: 100%; }
