/* lokaln Cockpit — Farben aus docs/DESIGN_GUIDELINES.md (Palette "Stadtgrün").
   Keine externen Schriften (DSGVO): Nunito Sans, falls installiert, sonst Systemschrift. */
:root {
  --bg: #F7F3E8;        /* Leinen */
  --surface: #FFFDF7;
  --fg: #12251F;
  --muted: #4E6159;
  --line: #DDD6C3;
  --brand: #0E4D3C;     /* Tannengrün */
  --brand-2: #1F6E56;   /* Moos */
  --leaf: #7BC67E;      /* Blatt */
  --tint: #CDE8C8;      /* Salbei */
  --on-brand: #F7F3E8;
  --ok: #2E7D4F; --ok-bg: #DDF0DC;
  --warn: #A3540F; --warn-bg: #FBE7D3;
  --bad: #B3261E; --bad-bg: #F9DEDC;
  --logs-bg: #0B2C23; --logs-fg: #E3EFE0; --logs-err: #FF9C85;
  --font: "Nunito Sans", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #082A21; --surface: #0D3529; --fg: #ECF3EC; --muted: #A9C2B6; --line: #1F4A3C;
    --brand: #7BC67E; --brand-2: #9BD79D; --leaf: #7BC67E; --tint: #14453A; --on-brand: #082A21;
    --ok: #8BD99A; --ok-bg: #16402F; --warn: #FFB27A; --warn-bg: #47301D; --bad: #FF9C85; --bad-bg: #4A1F1A;
    --logs-bg: #05201A;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--fg); font-family: var(--font); font-size: 16px; line-height: 1.5; }
[hidden] { display: none !important; }
h1, h2 { margin: 0; line-height: 1.25; text-wrap: balance; }
h1 { font-size: 1.4rem; font-weight: 800; }
h2 { font-size: 1.1rem; font-weight: 800; }
p { margin: 0; }
.muted { color: var(--muted); }
.small-text { font-size: .88rem; }

.brand { display: flex; align-items: center; gap: 10px; font-size: 1.15rem; color: var(--brand); font-weight: 600; }
.brand b { font-weight: 800; }
.brand-mark { width: 22px; height: 22px; border-radius: 50%; border: 4px solid var(--leaf); background: var(--brand); flex: none; }

/* Knöpfe */
.btn { font: inherit; font-weight: 700; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--fg); padding: 9px 16px; cursor: pointer; }
.btn:hover { border-color: var(--brand-2); }
.btn:focus-visible, input:focus-visible, select:focus-visible, .logs-body:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.ghost { background: transparent; }
.btn.small { padding: 6px 12px; font-size: .9rem; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

/* Anmeldung */
.login { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 10px; }
.login-card .brand { margin-bottom: 4px; }
.login-card label { font-weight: 700; font-size: .92rem; margin-top: 6px; }
input, select { font: inherit; color: var(--fg); background: var(--bg); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.login-card .btn { margin-top: 12px; }
.form-error { color: var(--bad); font-weight: 600; font-size: .92rem; }

/* Kopfzeile */
.topbar { position: sticky; top: 0; z-index: 5; background: var(--bg); border-bottom: 1px solid var(--line); }
.topbar-inner { max-width: 1100px; margin: 0 auto; padding: 12px 16px; display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.wrap { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: 28px; }
section { display: flex; flex-direction: column; gap: 12px; }

/* Gesamtstatus */
.summary { flex-direction: row; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 16px; background: var(--ok-bg); }
.summary > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.summary-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--ok); flex: none; }
.summary.warn { background: var(--warn-bg); } .summary.warn .summary-dot { background: var(--warn); }
.summary.bad { background: var(--bad-bg); } .summary.bad .summary-dot { background: var(--bad); }

/* Dienste */
.services { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.service { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; display: flex; flex-direction: column; gap: 10px; }
.service-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.service .meta { font-size: .86rem; color: var(--muted); }
.service .actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: auto; }
.pill { display: inline-block; font-size: .78rem; font-weight: 800; padding: 2px 10px; border-radius: 999px; white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }

/* Felder */
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; min-width: 0; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-top: 1px solid var(--line); font-size: .93rem; }
.list li:first-child { border-top: none; }
.list .when { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.list .what { min-width: 0; overflow-wrap: anywhere; }
.list .empty { color: var(--muted); justify-content: flex-start; }
.db { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.db .num { font-size: 1.7rem; font-weight: 800; color: var(--brand); font-variant-numeric: tabular-nums; line-height: 1.1; }
.db .lbl { font-size: .86rem; color: var(--muted); }
.db .full { grid-column: 1 / -1; font-size: .86rem; color: var(--muted); }

.footnote { font-size: .85rem; text-align: center; }

/* Dialoge */
.dialog { border: none; border-radius: 16px; padding: 24px; max-width: 460px; width: calc(100% - 32px); background: var(--surface); color: var(--fg); }
.dialog::backdrop { background: rgba(8, 42, 33, .55); }
.dialog form { display: flex; flex-direction: column; gap: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }
.dialog.wide { max-width: 1000px; display: none; flex-direction: column; gap: 10px; }
.dialog.wide[open] { display: flex; }
.logs-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.logs-controls { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.logs-controls select { padding: 6px 8px; }
.logs-body { margin: 0; background: var(--logs-bg); color: var(--logs-fg); border-radius: 10px; padding: 14px; font-family: var(--mono); font-size: .8rem; line-height: 1.5; height: 60vh; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; }
.logs-body .t { opacity: .55; }
.logs-body .err { color: var(--logs-err); }

.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--brand); color: var(--on-brand); padding: 12px 18px; border-radius: 12px; font-weight: 700; max-width: calc(100% - 32px); z-index: 20; }
.toast.error { background: var(--bad); color: #fff; }

@media (max-width: 520px) {
  .summary { flex-wrap: wrap; }
  #whoami { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .btn { transition: border-color .15s; }
}

/* ---------- Bearbeiten (Rolle admin) ---------- */
.nav { display: flex; gap: 4px; }
.nav-btn { font: inherit; font-weight: 700; background: none; border: none; color: var(--muted); padding: 6px 12px; border-radius: 8px; cursor: pointer; }
.nav-btn.active { background: var(--tint); color: var(--brand); }
.nav-btn:focus-visible, .tab:focus-visible { outline: 3px solid var(--leaf); outline-offset: 2px; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tab { font: inherit; font-weight: 700; background: none; border: none; border-bottom: 3px solid transparent; color: var(--muted); padding: 8px 12px; cursor: pointer; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; }
.toolbar input { flex: 1; min-width: 200px; }
.rows { list-style: none; margin: 0; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.rows li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--line); }
.rows li:first-child { border-top: none; }
.rows .row-main { min-width: 0; display: flex; flex-direction: column; }
.rows .row-main b { overflow-wrap: anywhere; }
.rows .row-sub { font-size: .88rem; color: var(--muted); overflow-wrap: anywhere; }
.rows .row-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.rows .empty { color: var(--muted); }
.editor { max-width: 640px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; max-height: 60vh; overflow: auto; padding: 2px; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.full { grid-column: 1 / -1; }
.field label { font-weight: 700; font-size: .9rem; }
.field .hint { font-size: .8rem; color: var(--muted); }
.field input, .field select { width: 100%; }
.dialog-actions.spread { justify-content: space-between; }
.danger-text { color: var(--bad); }
.inline-form { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { flex: 1; min-width: 200px; }
#link-value { width: 100%; font-family: var(--mono); font-size: .85rem; }
.login-card h1 { color: var(--brand); }
@media (max-width: 640px) {
  .fields { grid-template-columns: 1fr; }
  .topbar-inner { flex-wrap: wrap; }
  #change-pass { display: none; }
}

/* Anfragen */
.badge { display: inline-block; min-width: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; background: var(--bad); color: #fff; font-size: .75rem; line-height: 20px; text-align: center; }
.lead .row-main { gap: 4px; }
.lead-msg { white-space: pre-wrap; font-size: .92rem; background: var(--bg); border-radius: 8px; padding: 8px 10px; margin: 4px 0; }
.lead.done { opacity: .6; }
.lead a, .rows a { color: var(--brand); }
