/* ============================================================
   Mülitag Helfer-App – ruhig, modern, klar.
   Schrift: Inter. Eine Leitfarbe (Blau), neutrale Slate-Töne,
   feine Linien statt schwerer Flächen, klare Typo-Hierarchie.
   ============================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ink: #0f172a;
  --ink-soft: #1e293b;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e7ecf3;
  --line-strong: #d7dfea;
  --bg: #f6f8fb;
  --card: #ffffff;

  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --primary-soft: #eef4ff;
  --primary-softer: #f5f8ff;

  --ok-bg: #e8f6ed;   --ok-fg: #15803d;
  --warn-bg: #fdf3e3; --warn-fg: #b45309;
  --busy-bg: #fdeaea; --busy-fg: #b91c1c;

  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.05);
  --shadow: 0 1px 2px rgba(15, 23, 42, 0.04), 0 4px 14px rgba(15, 23, 42, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
  letter-spacing: -0.01em;
  padding-bottom: 80px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

input, textarea, select, button { font: inherit; letter-spacing: inherit; color: inherit; }
input::placeholder, textarea::placeholder { color: var(--faint); }
[hidden] { display: none !important; }

button, input { min-height: 44px; }
button { color: inherit; }
button:focus-visible, input:focus-visible, .tab:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* ---- Brandmark ---- */
.brandmark {
  width: 56px; height: 56px; margin: 0 auto;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary), var(--primary-strong));
  color: #fff;
  font-size: 26px; font-weight: 800; letter-spacing: 0;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
}

/* ---- Login ---- */
#login-gate {
  position: fixed; inset: 0; z-index: 200;
  background: var(--bg);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
#login-box {
  background: var(--card); border: 1px solid var(--line);
  border-radius: 18px; padding: 32px 26px;
  width: 100%; max-width: 360px; text-align: center;
  box-shadow: var(--shadow);
}
#login-box h2 { font-size: 24px; font-weight: 700; margin-top: 16px; }
#login-box p { font-size: 15px; color: var(--muted); margin: 4px 0 22px; }
#login-pw {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 11px;
  padding: 13px 14px; font-size: 17px; outline: none; text-align: center;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#login-pw:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
#login-error { font-size: 14px; color: var(--busy-fg); margin-top: 10px; min-height: 20px; }
#login-btn {
  width: 100%; margin-top: 14px; background: var(--primary); color: #fff;
  border: none; border-radius: 11px; padding: 14px 18px; font-size: 16px;
  font-weight: 600; cursor: pointer; transition: background 0.15s, transform 0.1s;
}
#login-btn:hover { background: var(--primary-strong); }
#login-btn:active { transform: translateY(1px); }
#login-btn:disabled { opacity: 0.55; cursor: default; }

/* ---- Header ---- */
#header {
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid var(--line);
  padding: 14px 14px 12px; position: sticky; top: 0; z-index: 10;
  backdrop-filter: saturate(180%) blur(10px);
}
#header-inner { width: 100%; max-width: 720px; margin: 0 auto; text-align: center; padding-bottom: 0; }
#header h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
#header .sub { font-size: 13.5px; color: var(--muted); margin-top: 1px; }

#statusbar { margin-top: 7px; display: inline-flex; justify-content: center; align-items: center; gap: 7px; }
#statusdot { width: 8px; height: 8px; border-radius: 50%; background: #16a34a; transition: background 0.3s; }
#statustext { font-size: 13px; color: var(--muted); font-weight: 500; }

#tabs {
  display: grid; grid-template-columns: repeat(4, 1fr); gap: 3px;
  margin-top: 14px; background: #eef1f6; border-radius: 12px; padding: 4px;
}
.tab {
  min-width: 0; padding: 10px 6px; border-radius: 9px; border: none;
  background: transparent; color: var(--muted); font-size: 14px; font-weight: 600;
  cursor: pointer; transition: background 0.15s, color 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.tab:hover { color: var(--ink-soft); }
.tab.active { background: #fff; color: var(--primary-strong); box-shadow: var(--shadow-sm); }

/* ---- Content ---- */
#content { padding: 18px 14px; max-width: 720px; margin: 0 auto; }
.hint { font-size: 13.5px; color: var(--muted); margin: 0 0 14px; text-align: center; }

/* ---- Quick panel (Eintragen) ---- */
.quick-panel {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px; margin-bottom: 16px; box-shadow: var(--shadow);
}
.quick-title { font-size: 17px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.quick-copy { color: var(--muted); font-size: 14px; line-height: 1.5; }
.quick-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 16px; }
.quick-stat {
  background: var(--primary-softer); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 8px; text-align: center;
}
.quick-stat strong { display: block; font-size: 22px; font-weight: 700; line-height: 1; color: var(--primary-strong); }
.quick-stat span { display: block; font-size: 12px; font-weight: 600; color: var(--muted); margin-top: 5px; }

/* ---- Badges (Ampel: frei / fast voll / voll) ---- */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 42px; height: 26px; font-size: 12.5px; font-weight: 600;
  padding: 0 10px; border-radius: 8px;
}
.badge-green { background: var(--ok-bg); color: var(--ok-fg); }
.badge-yellow { background: var(--warn-bg); color: var(--warn-fg); }
.badge-red { background: var(--busy-bg); color: var(--busy-fg); }

/* ---- Station cards ---- */
.station-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-sm);
}
.station-header {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  width: 100%; border: none; cursor: pointer; padding: 15px 16px;
  background: var(--card); transition: background 0.15s; text-align: left;
}
.station-title { display: flex; align-items: center; gap: 13px; min-width: 0; }
.station-icon {
  width: 44px; height: 44px; border-radius: 12px; display: flex;
  align-items: center; justify-content: center; font-size: 21px; flex-shrink: 0;
}
.station-name { font-size: 16.5px; font-weight: 700; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.station-meta { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chevron { color: var(--faint); font-size: 18px; transition: transform 0.2s; }
.station-body { padding: 2px 14px 14px; }

/* ---- Slots ---- */
.slot-row {
  background: #fbfcfe; border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; margin-bottom: 9px;
}
.slot-top { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.slot-time { font-size: 15px; font-weight: 600; color: var(--ink-soft); }
.slot-actions { display: flex; gap: 8px; align-items: center; }
.full-label { font-size: 12.5px; color: var(--busy-fg); font-weight: 600; }

.slot-helpers { margin-top: 10px; display: flex; flex-direction: column; gap: 7px; }
.helper-chip {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 10px;
}
.helper-chip .name { font-size: 15px; font-weight: 600; overflow-wrap: anywhere; }

.add-row { display: flex; gap: 8px; margin-top: 11px; }
.add-input {
  flex: 1; background: #fff; border-radius: 10px; padding: 11px 13px;
  font-size: 16px; outline: none; border: 1.5px solid var(--line-strong); min-width: 0;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.add-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.btn-ok {
  border: none; border-radius: 10px; color: #fff; padding: 11px 16px;
  min-width: 104px; font-weight: 600; cursor: pointer; background: var(--primary);
  transition: background 0.15s;
}
.btn-ok:hover { background: var(--primary-strong); }

.icon-btn {
  background: transparent; border: 1px solid transparent; border-radius: 8px;
  color: var(--faint); cursor: pointer; font-size: 19px; line-height: 1;
  min-width: 38px; min-height: 38px; padding: 0 8px; transition: all 0.12s;
}
.icon-btn:hover { color: var(--busy-fg); background: var(--busy-bg); }

/* ---- Übersicht ---- */
.ov-toggle { display: flex; gap: 3px; margin-bottom: 16px; background: #eef1f6; border-radius: 12px; padding: 4px; }
.ov-toggle button {
  flex: 1; border: none; background: transparent; color: var(--muted);
  font-size: 14px; font-weight: 600; padding: 10px 0; border-radius: 9px; cursor: pointer;
}
.ov-toggle button.active { background: #fff; color: var(--primary-strong); box-shadow: var(--shadow-sm); }
.ov-group { margin-bottom: 18px; }
.ov-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; color: var(--muted); }
.ov-row {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 11px 13px; border-radius: 10px; margin-bottom: 6px; font-size: 15px;
}
.ov-name { font-weight: 600; overflow-wrap: anywhere; }
.ov-meta { font-size: 13.5px; color: var(--muted); text-align: right; flex-shrink: 0; }
.ov-empty { text-align: center; padding: 56px 20px; color: var(--muted); }
.ov-empty .big { font-size: 40px; margin-bottom: 12px; opacity: 0.8; }
.ov-total { text-align: center; margin-top: 18px; color: var(--faint); font-size: 13px; font-weight: 500; }

/* ---- Helfer-Roster ---- */
.roster-item {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 16px; margin-bottom: 9px; display: flex; align-items: center;
  gap: 12px; box-shadow: var(--shadow-sm);
}
.roster-main { flex: 1; min-width: 0; }
.roster-name { font-size: 16px; font-weight: 700; overflow-wrap: anywhere; }
.roster-sub { font-size: 13.5px; color: var(--muted); margin-top: 3px; overflow-wrap: anywhere; }
.roster-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ---- Sektionen ---- */
.section {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 20px 18px; margin-bottom: 16px; box-shadow: var(--shadow-sm);
}
.section h3 { font-size: 16px; font-weight: 700; margin-bottom: 16px; letter-spacing: -0.01em; }
.section .desc { font-size: 14px; color: var(--muted); margin-bottom: 14px; line-height: 1.5; }
.form-label {
  font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 6px;
  display: block; text-transform: uppercase; letter-spacing: 0.05em;
}
.form-input {
  width: 100%; border: 1.5px solid var(--line-strong); border-radius: 10px;
  padding: 11px 13px; font-size: 16px; outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.row { display: flex; gap: 8px; align-items: center; }

.station-config { background: #fafbfd; border: 1px solid var(--line); border-radius: 12px; padding: 14px; margin-bottom: 12px; }
.station-config-header { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.station-config-name { font-weight: 700; font-size: 15px; flex: 1; }
.slot-tag {
  display: inline-flex; align-items: center; gap: 7px; background: #fff;
  border: 1px solid var(--line-strong); border-radius: 9px; padding: 6px 8px;
  font-size: 14px; font-weight: 500; margin: 4px;
}
.slot-tag input.max {
  width: 50px; border: 1px solid var(--line-strong); border-radius: 7px;
  padding: 3px 4px; font-size: 14px; text-align: center; outline: none; min-height: 32px;
}
.slot-tag .icon-btn { font-size: 17px; min-width: 32px; min-height: 32px; }
.slots-wrap { display: flex; flex-wrap: wrap; margin-bottom: 10px; }
.add-slot-row { display: flex; gap: 7px; margin-top: 4px; }
.add-slot-row input { border: 1.5px solid var(--line-strong); border-radius: 9px; padding: 9px 11px; font-size: 15px; outline: none; }
.add-slot-row input.label { flex: 1; min-width: 0; }
.add-slot-row input.max { width: 64px; text-align: center; }
.new-station-form { background: #fafbfd; border: 1.5px dashed var(--line-strong); border-radius: 12px; padding: 14px; margin-top: 4px; }
.new-station-form .lbl { font-size: 14px; font-weight: 700; margin-bottom: 10px; color: var(--ink-soft); }
.divider { height: 1px; background: var(--line); margin: 18px 0; }

/* ---- Buttons ---- */
.btn {
  border: none; border-radius: 10px; padding: 11px 16px; font-size: 14.5px;
  font-weight: 600; cursor: pointer; transition: background 0.15s, opacity 0.15s, transform 0.1s;
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-strong); }
.btn-ghost { background: #eef1f6; color: var(--ink-soft); }
.btn-ghost:hover { background: #e3e8f0; }
.btn-add { background: var(--primary-soft); color: var(--primary-strong); border: 1px solid #c7dbff; }
.btn-danger { background: var(--busy-bg); color: var(--busy-fg); border: 1px solid #f6c9c9; padding: 9px 13px; font-size: 13.5px; }
.btn-sm { padding: 8px 13px; font-size: 13.5px; }
.btn-block { width: 100%; }
.mt { margin-top: 10px; }
.toolbar { display: flex; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }

/* ---- Modal / Toast ---- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 250; background: rgba(15, 23, 42, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 18px;
  backdrop-filter: blur(2px);
}
.modal { width: 100%; max-width: 420px; background: #fff; border-radius: 16px; box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28); padding: 24px; }
.modal h3 { font-size: 19px; font-weight: 700; margin-bottom: 6px; letter-spacing: -0.01em; }
.modal p { color: var(--muted); font-size: 15px; margin-bottom: 14px; line-height: 1.5; }
.modal-actions { display: flex; gap: 9px; justify-content: flex-end; margin-top: 18px; }
.modal-actions .btn { min-width: 112px; }

#toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(16px);
  background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none;
  transition: all 0.22s; z-index: 300; box-shadow: 0 12px 30px rgba(15, 23, 42, 0.3);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.error { background: var(--busy-fg); }

/* ---- Mobile ---- */
@media (max-width: 540px) {
  #header { padding: 12px 12px 10px; }
  #header h1 { font-size: 20px; }
  #tabs { grid-template-columns: repeat(2, 1fr); gap: 5px; margin-top: 12px; }
  .tab { padding: 11px 6px; }
  #content { padding: 16px 12px; }
  .quick-stats { gap: 8px; }
  .quick-stat strong { font-size: 20px; }
  .add-row { flex-direction: column; }
  .btn-ok { width: 100%; }
  .roster-item { align-items: stretch; flex-direction: column; }
  .roster-actions { width: 100%; }
  .roster-actions .btn { flex: 1; }
  .station-config-header { align-items: stretch; flex-direction: column; }
  .add-slot-row { flex-wrap: wrap; }
  .add-slot-row .label { flex-basis: 100%; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
}

/* ---- Einsatzmöglichkeiten (Aufgaben) ---- */
select { min-height: 44px; }
.add-row select.add-task {
  flex: 0 0 auto;
  max-width: 40%;
  border: 1.5px solid var(--line-strong);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 15px;
  background: #fff;
  color: var(--ink);
  outline: none;
}
.add-row select.add-task:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.task-tag {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  vertical-align: middle;
}
.config-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin: 14px 0 6px;
}
.config-hint { font-size: 13px; color: var(--faint); }

@media (max-width: 540px) {
  .add-row select.add-task { max-width: 100%; flex: 1 1 auto; }
}

/* ============================================================
   Plan-Ansicht (kompakt, gestapelte Namen)
   ============================================================ */
.overview {
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 14px 16px; margin-bottom: 14px; box-shadow: var(--shadow-sm);
}
.overview .orow { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 9px; }
.overview .olbl { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.overview .oval { font-size: 13.5px; color: var(--muted); }
.overview .oval b { color: var(--ink); font-weight: 700; }
.pbar { height: 8px; border-radius: 99px; background: var(--line2); overflow: hidden; }
.pbar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-strong)); border-radius: 99px; }
.pbar.mini { width: 64px; height: 6px; }

.pstn { background: var(--card); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 12px; overflow: hidden; box-shadow: var(--shadow-sm); }
.pstn-head { display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-bottom: 1px solid var(--line); }
.pstn-ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 18px; flex: 0 0 auto; }
.pstn-name { font-size: 16px; font-weight: 700; flex: 1; letter-spacing: -0.01em; overflow-wrap: anywhere; }
.pstn-prog { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.pstn-prog .cnt { font-size: 13px; font-weight: 700; color: var(--muted); min-width: 38px; text-align: right; }
.phint { font-size: 13px; color: var(--faint); padding: 12px 16px; }

.pslot { padding: 11px 16px; border-bottom: 1px solid var(--line2); }
.pslot:last-child { border-bottom: 0; }
.pslot-head { display: flex; align-items: center; gap: 10px; }
.pslot-head .t { font-size: 14px; font-weight: 600; color: var(--ink2); white-space: nowrap; }
.pslot-head .free { margin-left: auto; font-size: 13px; font-weight: 700; white-space: nowrap; }
.pslot-head .free.ok { color: var(--ok); }
.pslot-head .free.warn { color: var(--warn); }
.pslot-head .free.voll { color: var(--busy); }
.pslot-head .add {
  width: 32px; height: 32px; min-height: 32px; flex: 0 0 auto; border-radius: 9px;
  border: 1px solid var(--line-strong); background: #fff; color: var(--primary-strong);
  font-size: 18px; font-weight: 700; line-height: 1; cursor: pointer;
}
.pslot-head .add:hover { background: var(--primary-soft); }
.pslot-names { margin-top: 8px; display: flex; flex-direction: column; gap: 2px; }
.hrow { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 8px; }
.hrow:hover { background: var(--line2); }
.hname { font-size: 14.5px; font-weight: 500; color: var(--ink2); overflow-wrap: anywhere; }

/* ============================================================
   Einstellungen: Zeitslot-Editor (Von/Bis-Picker + Max)
   ============================================================ */
.cfg { display: grid; grid-template-columns: 1fr 1fr 70px 42px; gap: 8px; align-items: center; margin-bottom: 8px; }
.cfg input { font: inherit; border: 1.5px solid var(--line-strong); border-radius: 9px; padding: 9px 10px; outline: none; min-height: 42px; width: 100%; }
.cfg input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.cfg .cap { text-align: center; }
.cfg .del { width: 42px; height: 42px; min-height: 42px; border: 1px solid var(--line-strong); background: #fff; border-radius: 9px; color: var(--faint); font-size: 18px; cursor: pointer; padding: 0; }
.cfg .del:hover { color: var(--busy); background: var(--busy-bg); border-color: #f6c9c9; }
.cfg .addbtn { background: var(--primary); color: #fff; border: 0; }
.cfg .addbtn:hover { background: var(--primary-strong); }
.cfg-head { display: grid; grid-template-columns: 1fr 1fr 70px 42px; gap: 8px; font-size: 11px; font-weight: 700; color: var(--faint); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 6px; padding: 0 2px; }
@media (max-width: 540px) {
  .cfg, .cfg-head { grid-template-columns: 1fr 1fr 54px 40px; gap: 6px; }
}
