/* Beschlüsse Toblach – Webinterface. Ein Designsystem für alle Seiten: Tokens -> Bausteine -> Seiten.
   Corporate Design: SVP-Ortsgruppe Toblach, Variante B (weiß, Rot als Akzent; Rot #DC0D26, Anthrazit #2C2C2C, Open Sans). */
@font-face { font-family: "Open Sans"; font-style: normal; font-weight: 400 700; font-display: swap;
  src: url("fonts/open-sans-latin.woff2") format("woff2"); }   /* lokal (SIL OFL), keine Verbindung zu Google */

/* ---------- Tokens ---------- */
:root {
  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px;
  --r: 12px; --r-sm: 8px; --r-pill: 999px;
  --bg: #f5f5f5; --surface: #ffffff; --surface-2: #f7f7f7;
  --fg: #2c2c2c; --muted: #6b6b6b; --line: #e3e3e3; --line-strong: #cccccc;
  --brand: #dc0d26;                                   /* SVP-Rot für Flächen, Linien, große Elemente */
  --accent: #c00b22; --accent-fg: #ffffff; --accent-soft: #fde6e9;   /* dunkleres Rot: auch kleine Schrift >= 5,8:1 */
  --ok: #2b7a3d; --ok-soft: #e4f3e7;
  --warn: #9a5800; --warn-soft: #fdf1df;
  --err: #b3261e; --err-soft: #fbe7e5;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 2px 8px rgba(0,0,0,.04);
  --font: "Open Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --tap: 40px;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161616; --surface: #202020; --surface-2: #262626;
    --fg: #ececec; --muted: #a0a0a0; --line: #353535; --line-strong: #474747;
    --brand: #ff4d5e; --accent: #ff6b78; --accent-fg: #1d0004; --accent-soft: #3a1519;
    --ok: #7cc68a; --ok-soft: #1a2e1e; --warn: #f0ad55; --warn-soft: #33260f; --err: #f28b82; --err-soft: #3a1b18;
    --shadow: none;
  }
}
@media (pointer: coarse) { :root { --tap: 44px; } }

/* ---------- Basis ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.55 var(--font); }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.3; margin: 0; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 1rem; }
p { margin: 0; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile ---------- */
.topbar { position: sticky; top: 0; z-index: 10; background: var(--surface); border-bottom: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  padding-top: env(safe-area-inset-top); }
.topbar-in { max-width: 1040px; margin: 0 auto; display: flex; align-items: center; gap: var(--s4);
  padding: var(--s2) max(var(--s4), env(safe-area-inset-right)) var(--s2) max(var(--s4), env(safe-area-inset-left)); }
.brand { font-weight: 700; color: var(--fg); text-decoration: none; white-space: nowrap; }
.nav { display: flex; gap: var(--s1); overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
.nav::-webkit-scrollbar { display: none; }
.nav a { display: inline-flex; align-items: center; min-height: var(--tap); padding: 0 var(--s3); border-radius: var(--r-pill);
  color: var(--fg); text-decoration: none; white-space: nowrap; }
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
@media (max-width: 640px) {
  .topbar-in { flex-direction: column; align-items: stretch; gap: 0; padding-bottom: var(--s1); }
  .brand { padding: var(--s1) 0; }
  .nav { margin: 0 calc(-1 * var(--s2)); }
}
#loadbar { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 20; background: var(--accent);
  animation: load 1.2s ease-in-out infinite; transform-origin: left; }
@keyframes load { 0% { transform: scaleX(.05); } 60% { transform: scaleX(.7); } 100% { transform: scaleX(1); opacity: .3; } }

/* ---------- Layout ---------- */
.page { max-width: 1040px; margin: 0 auto; display: flex; flex-direction: column; gap: var(--s4);
  padding: var(--s4) max(var(--s4), env(safe-area-inset-right)) calc(var(--s6) + env(safe-area-inset-bottom)) max(var(--s4), env(safe-area-inset-left)); }
.stack { display: flex; flex-direction: column; gap: var(--s4); }
.stack-sm { display: flex; flex-direction: column; gap: var(--s2); }
.page-head { display: flex; flex-direction: column; gap: var(--s1); }
.meta, .hint { font-size: .85rem; color: var(--muted); }
.muted { color: var(--muted); }
@media (max-width: 640px) { .page { padding-left: max(var(--s3), env(safe-area-inset-left)); padding-right: max(var(--s3), env(safe-area-inset-right)); } }

/* ---------- Box ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); padding: var(--s4); box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: var(--s3); min-width: 0; }
.card-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--s2); }

/* ---------- Hinweise / Toasts / Badges ---------- */
.notice { border-radius: var(--r); padding: var(--s3) var(--s4); border: 1px solid transparent; background: var(--surface-2); }
.notice.info { background: var(--accent-soft); color: var(--fg); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.notice.ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.notice.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); }
.notice.err { background: var(--err-soft); color: var(--err); border-color: color-mix(in srgb, var(--err) 25%, transparent); font-weight: 600; }
.notice.sm { padding: var(--s2) var(--s3); font-size: .9rem; }
.notice a { color: inherit; }
.toasts { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--s4) + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: var(--s2); width: min(520px, calc(100vw - 2 * var(--s4))); pointer-events: none; }
.toast { pointer-events: auto; border-radius: var(--r); padding: var(--s3) var(--s4); background: var(--fg); color: var(--bg);
  box-shadow: 0 6px 24px rgba(0,0,0,.18); opacity: 0; transform: translateY(8px); transition: opacity .2s, transform .2s; }
.toast.show { opacity: 1; transform: none; }
.toast.ok { background: var(--ok); color: #fff; } .toast.err { background: var(--err); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
.badges { display: flex; flex-wrap: wrap; gap: var(--s1); }
.badge { display: inline-flex; align-items: center; font-size: .75rem; font-weight: 600; line-height: 1; padding: 5px 9px;
  border-radius: var(--r-pill); background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.info { background: var(--surface-2); color: var(--fg); border-color: var(--line); }
.badge.ok { background: var(--ok-soft); color: var(--ok); border-color: transparent; }
.badge.warn { background: var(--warn-soft); color: var(--warn); border-color: transparent; }

/* ---------- Knöpfe ---------- */
.btn { font: inherit; font-size: .92rem; font-weight: 600; display: inline-flex; align-items: center; justify-content: center; gap: var(--s2);
  min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-sm); border: 1px solid var(--line-strong);
  background: var(--surface); color: var(--fg); cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:focus-visible, .nav a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn-primary:hover { background: color-mix(in srgb, var(--accent) 88%, #000); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 40%, var(--line)); }
.btn-danger:hover { background: var(--err-soft); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--accent); }
.btn-ghost:hover { background: var(--accent-soft); }
.btn-sm { min-height: calc(var(--tap) - 6px); padding: 0 var(--s3); font-size: .85rem; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.toolbar form { display: contents; }
@media (max-width: 560px) { .toolbar > .btn, .toolbar form > .btn { flex: 1 1 auto; } }

/* ---------- Formulare ---------- */
input[type=text], input[type=password], input[type=number], input[type=search], input[type=email], select, textarea {
  font: inherit; font-size: 16px; /* kein Auto-Zoom auf iOS */ color: var(--fg); background: var(--surface);
  border: 1px solid var(--line-strong); border-radius: var(--r-sm); padding: 0 var(--s3); min-height: var(--tap); width: 100%; max-width: 100%; }
textarea { padding: var(--s2) var(--s3); min-height: 120px; resize: vertical; line-height: 1.5; }
textarea.code { font-family: var(--mono); font-size: 14px; min-height: 50vh; }
.check { display: flex; align-items: center; gap: var(--s2); min-height: var(--tap); cursor: pointer; }
.check input { width: 20px; height: 20px; margin: 0; accent-color: var(--accent); flex: none; }
.form-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.form-row > input[type=text], .form-row > input[type=search], .form-row > input[type=email] { flex: 1 1 220px; width: auto; }
.fields { display: grid; grid-template-columns: minmax(160px, 220px) 1fr; gap: var(--s3) var(--s4); align-items: start; }
.field { display: contents; }
.field-label { font-weight: 600; padding-top: 9px; overflow-wrap: anywhere; }
.field-body { display: flex; flex-direction: column; gap: var(--s1); min-width: 0; }
.field-body .check { min-height: 32px; }
@media (max-width: 640px) {
  .fields { grid-template-columns: 1fr; gap: var(--s1); }
  .field-label { padding-top: var(--s2); }
  .field-body { margin-bottom: var(--s2); }
}
.savebar { position: sticky; bottom: 0; z-index: 5; margin: 0 calc(-1 * var(--s4)); padding: var(--s3) var(--s4) calc(var(--s3) + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(6px); display: flex; gap: var(--s2); justify-content: flex-end; }
@media (max-width: 560px) { .savebar .btn { flex: 1; } }

/* ---------- Status (Hintergrund-Job) ---------- */
.job { gap: var(--s2); padding: var(--s3) var(--s4); position: fixed; z-index: 15; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--s3) + env(safe-area-inset-bottom)); width: min(1008px, calc(100vw - 2 * var(--s3)));
  box-shadow: 0 10px 30px rgba(0,0,0,.18); }
.job-progress { height: 8px; border-radius: var(--r-pill); background: var(--surface-2); border: 1px solid var(--line); overflow: hidden; }
.job-progress .bar { height: 100%; width: 0; background: var(--brand); border-radius: inherit; transition: width .9s linear; }
.job-progress.indet .bar { width: 28%; animation: indet 1.4s ease-in-out infinite; }
@keyframes indet { 0% { transform: translateX(-100%); } 100% { transform: translateX(380%); } }
.job-times { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 2px var(--s4); font-size: .85rem; color: var(--muted);
  font-variant-numeric: tabular-nums; }
.job-times:empty, .job-times span:empty { display: none; }
html.job-active .page { padding-bottom: calc(var(--jobh, 120px) + var(--s6) + env(safe-area-inset-bottom)); }
html.job-active .toasts { bottom: calc(var(--jobh, 120px) + 2 * var(--s3) + env(safe-area-inset-bottom)); }
html.js.job-active .selbar.active { bottom: calc(var(--jobh, 120px) + 2 * var(--s3) + env(safe-area-inset-bottom)); }
@media (prefers-reduced-motion: reduce) { .job-progress .bar { transition: none; } .job-progress.indet .bar { animation: none; width: 100%; opacity: .35; } }
.job-row { display: flex; align-items: center; flex-wrap: wrap; gap: var(--s2) var(--s3); }
.job-row .t { flex: 1 1 200px; min-width: 0; overflow-wrap: anywhere; }
.job-label { font-weight: 700; }
.job[data-busy="1"] { border-color: var(--accent); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--line-strong); flex: none; }
.job[data-busy="1"] .spinner { border-color: var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.job-log summary, .disclosure summary { cursor: pointer; color: var(--muted); font-size: .85rem; min-height: 28px; display: flex; align-items: center; }
#joblog { margin-top: var(--s2); }
.job-log ul { margin: var(--s1) 0 0; padding-left: var(--s4); font-size: .82rem; color: var(--muted); max-height: 240px; overflow: auto; }

/* ---------- Übersicht ---------- */
.tabs { display: flex; gap: var(--s2); overflow-x: auto; scrollbar-width: none; padding: 2px; margin: -2px; -webkit-overflow-scrolling: touch; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { display: inline-flex; align-items: center; gap: var(--s2); min-height: var(--tap); padding: 0 var(--s4); border-radius: var(--r-pill);
  background: var(--surface); border: 1px solid var(--line); color: var(--fg); text-decoration: none; white-space: nowrap; font-size: .92rem; }
.tabs a .n { font-size: .78rem; color: var(--muted); font-weight: 600; }
.tabs a.on { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); font-weight: 600; }
.tabs a.on .n { color: inherit; opacity: .8; }
.tabs-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.tabs-row .tabs { flex: 0 1 auto; min-width: 0; }
.selbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2) var(--s3); }
.selbar-actions { display: flex; flex-wrap: wrap; gap: var(--s2); }
.selcount { font-weight: 600; }
.js .selbar:not(.active) .selbar-actions { display: none; }
.js .selbar.active { position: sticky; bottom: calc(var(--s3) + env(safe-area-inset-bottom)); z-index: 6; background: var(--surface);
  border: 1px solid var(--accent); border-radius: var(--r); padding: var(--s2) var(--s3); box-shadow: 0 6px 24px rgba(0,0,0,.15); }
@media (max-width: 560px) { .js .selbar.active .selbar-actions { width: 100%; } .js .selbar.active .selbar-actions .btn { flex: 1; } }
.item { gap: var(--s2); scroll-margin-top: 90px; }
.item.has-warn { border-left: 4px solid var(--warn); }
.item-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--s1) var(--s3); }
.item-head .check { min-height: 32px; font-weight: 700; }
.item-title { font-size: 1rem; overflow-wrap: anywhere; }
.summary { overflow-wrap: anywhere; }
.item-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s2); }
.item-actions form { display: contents; }
.edit { width: 100%; }
.edit > summary { list-style: none; display: inline-flex; }
.edit > summary::-webkit-details-marker { display: none; }
.edit[open] > summary { margin-bottom: var(--s2); }
.edit form { display: flex; flex-direction: column; gap: var(--s2); }
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--s2); }
.empty { text-align: center; padding: var(--s6) var(--s4); color: var(--muted); }

/* ---------- Vorschau ---------- */
.mail-preview { background: #f0f0ee; color: #1a1a1a; border-radius: var(--r); overflow-x: auto; }
.mail-preview .preheader { display: none !important; }
@media (max-width: 640px) { .mail-preview .outer { padding: 12px 8px !important; } }
.kv { display: flex; flex-wrap: wrap; gap: var(--s2); }

.masked { -webkit-text-security: disc; }
.secret { display: flex; flex-direction: column; gap: var(--s2); align-items: flex-start; }
.secret > summary { list-style: none; }
.secret > summary::-webkit-details-marker { display: none; }
.secret[open] > summary { display: none; }

/* ---------- Anmeldung ---------- */
.topbar-in .logout { margin-left: auto; }
@media (max-width: 640px) { .topbar-in .logout { position: absolute; top: calc(env(safe-area-inset-top) + 6px); right: max(var(--s3), env(safe-area-inset-right)); } .topbar-in { position: relative; } }
.login-body { min-height: 100vh; display: grid; place-items: center; }
.login-wrap { width: 100%; max-width: 400px; padding: var(--s5) max(var(--s4), env(safe-area-inset-right)) var(--s5) max(var(--s4), env(safe-area-inset-left)); }
.login-card { gap: var(--s4); padding: var(--s5); }
.login-card .brand { color: var(--accent); font-size: .85rem; }
.login-card label:not(.check) { font-weight: 600; }
.login-card .btn-primary { width: 100%; }

/* ---------- Text ---------- */
pre.code { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font: 13.5px/1.55 var(--mono); }

/* WhatsApp */
.qr { display: inline-block; background: #fff; padding: var(--s2); border-radius: var(--r); line-height: 0; }
.qr svg { width: 264px; max-width: 100%; height: auto; }
.wa-code { font: 700 2rem/1.2 var(--mono); letter-spacing: .15em; margin: var(--s2) 0; }
pre.wa-text { margin-top: var(--s2); max-height: 60vh; overflow: auto; padding: var(--s3); background: var(--surface-2); border-radius: var(--r); }
