/* JF-Verwaltung · © ff144
   Bewusst ohne externe Schriften/CDNs (Datenschutz). */

:root {
  --bg: #f5f3f0;
  --surface: #ffffff;
  --surface-2: #faf8f6;
  --line: #e7e2dc;
  --text: #1f1b18;
  --muted: #6f665e;
  --red: #c8102e;
  --red-dark: #9e0c24;
  --red-soft: #fbe9ec;
  --blue: #1d4f91;
  --blue-soft: #e7eef8;
  --green: #1f7a46;
  --green-soft: #e4f3ea;
  --amber: #a15c00;
  --amber-soft: #fdf1dc;
  --shadow: 0 1px 2px rgba(40, 25, 15, .06), 0 4px 14px rgba(40, 25, 15, .05);
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141211; --surface: #1d1a18; --surface-2: #24201e; --line: #35302c;
    --text: #f1ece7; --muted: #a59b92; --red: #ff4d5e; --red-dark: #ff6b7a; --red-soft: #3a1a1e;
    --blue: #7fb0f0; --blue-soft: #1a2638; --green: #5fcf8c; --green-soft: #15291d;
    --amber: #f0b14a; --amber-soft: #33270f; --shadow: 0 1px 2px rgba(0,0,0,.4);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141211; --surface: #1d1a18; --surface-2: #24201e; --line: #35302c;
  --text: #f1ece7; --muted: #a59b92; --red: #ff4d5e; --red-dark: #ff6b7a; --red-soft: #3a1a1e;
  --blue: #7fb0f0; --blue-soft: #1a2638; --green: #5fcf8c; --green-soft: #15291d;
  --amber: #f0b14a; --amber-soft: #33270f; --shadow: 0 1px 2px rgba(0,0,0,.4);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 15px/1.5 var(--font);
  padding-top: 60px;
}
body.no-nav { padding-top: 0; }
a { color: var(--red); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.55rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.12rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
p { margin: 0 0 .75rem; }
code { font-family: var(--mono); font-size: .9em; background: var(--surface-2); padding: 1px 5px; border-radius: 4px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.ic { width: 20px; height: 20px; flex: none; }
.inline { display: inline; }
[hidden] { display: none !important; }

/* ---------- Kopfzeile & Navigation ---------- */
.topbar {
  position: fixed; inset: 0 0 auto 0; height: 60px; z-index: 30;
  display: flex; align-items: center; gap: 10px; padding: 0 16px;
  background: var(--surface); border-bottom: 3px solid var(--red);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); min-width: 0; }
.brand:hover { text-decoration: none; }
.brand span { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.brand strong { font-size: .98rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { color: var(--muted); font-size: .75rem; }
.topbar-right { margin-left: auto; display: flex; gap: 4px; }
.iconbtn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; color: var(--text); cursor: pointer;
}
.iconbtn:hover { background: var(--surface-2); text-decoration: none; }

.sidebar {
  position: fixed; top: 60px; bottom: 0; left: 0; width: 236px; z-index: 20;
  background: var(--surface); border-right: 1px solid var(--line);
  padding: 14px 10px; display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.sidebar a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: var(--text); font-weight: 500;
}
.sidebar a:hover { background: var(--surface-2); text-decoration: none; }
.sidebar a.active { background: var(--red-soft); color: var(--red); }
.sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); }
.sidebar-foot a { font-size: .82rem; color: var(--muted); padding: 6px 12px; font-weight: 400; }

.main { margin-left: 236px; padding: 24px 28px 40px; max-width: 1320px; }
body.no-nav .main { margin-left: auto; margin-right: auto; }
.main.narrow { max-width: 760px; }
.foot { margin-top: 40px; color: var(--muted); font-size: .8rem; text-align: center; }
.only-mobile { display: none; }

@media (max-width: 900px) {
  .only-mobile { display: inline-grid; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; box-shadow: var(--shadow); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 18px 16px 32px; }
  .brand small { display: none; }
}

/* ---------- Bausteine ---------- */
.pagehead { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.pagehead p { margin: 4px 0 0; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px;
}
.card > :last-child { margin-bottom: 0; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 12px; }
.card-head h2 { margin: 0; }
.grid { display: grid; gap: 18px; }
.grid > .card { margin-bottom: 0; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g12 { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.span2 { grid-column: span 2; }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 700px) {
  .g2, .g3, .g4, .g12, .grid2, .grid3 { grid-template-columns: minmax(0, 1fr); }
  .span2 { grid-column: auto; }
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* KPI-Kacheln */
.kpi { padding: 16px 18px; }
.kpi .label { color: var(--muted); font-size: .82rem; font-weight: 500; }
.kpi .value { font-size: 1.9rem; font-weight: 700; line-height: 1.15; margin-top: 2px; font-variant-numeric: tabular-nums; }
.kpi .sub { color: var(--muted); font-size: .82rem; }
.kpi.accent { border-top: 3px solid var(--red); }
.kpi.blue { border-top: 3px solid var(--blue); }

/* Countdown */
.countdown { display: flex; gap: 10px; margin: 8px 0 4px; }
.countdown div { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; min-width: 64px; text-align: center; }
.countdown b { display: block; font-size: 1.5rem; font-variant-numeric: tabular-nums; }
.countdown span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }

/* Orts-Karten */
.ort-card h3 { display: flex; justify-content: space-between; align-items: baseline; }
.ort-split { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 10px 0; }
.ort-split > div { border-radius: 10px; padding: 10px 12px; }
.ort-split .kf { background: var(--amber-soft); }
.ort-split .jf { background: var(--blue-soft); }
.ort-split b { display: block; font-size: 1.45rem; font-variant-numeric: tabular-nums; }
.ort-split small { color: var(--muted); }
.contact { font-size: .88rem; padding: 4px 0; border-top: 1px dashed var(--line); }
.contact:first-of-type { border-top: 0; }
.contact .fn { color: var(--muted); font-size: .78rem; }
.contact a { color: var(--text); }

/* Listen */
.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--line); }
.list li:first-child { border-top: 0; padding-top: 2px; }
.datebox { flex: none; width: 50px; text-align: center; border-radius: 9px; background: var(--surface-2); border: 1px solid var(--line); padding: 4px 0; line-height: 1.1; }
.datebox b { display: block; font-size: 1.15rem; }
.datebox small { font-size: .7rem; color: var(--muted); text-transform: uppercase; }
.datebox.deadline { background: var(--red-soft); border-color: transparent; color: var(--red); }
.datebox.deadline small { color: var(--red); }
.list .body { flex: 1; min-width: 0; }
.list .meta { font-size: .82rem; color: var(--muted); }

/* Tabellen */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 600; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.done td { color: var(--muted); text-decoration: line-through; }
tbody tr:hover { background: var(--surface-2); }

/* Badges */
.badge { display: inline-block; font-size: .74rem; font-weight: 600; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); white-space: nowrap; }
.badge.red { background: var(--red-soft); color: var(--red); border-color: transparent; }
.badge.green { background: var(--green-soft); color: var(--green); border-color: transparent; }
.badge.amber { background: var(--amber-soft); color: var(--amber); border-color: transparent; }
.badge.blue { background: var(--blue-soft); color: var(--blue); border-color: transparent; }

/* Hinweise */
.flash { padding: 11px 14px; border-radius: 10px; margin-bottom: 14px; font-weight: 500; }
.flash-ok { background: var(--green-soft); color: var(--green); }
.flash-err { background: var(--red-soft); color: var(--red); }
.flash-warn { background: var(--amber-soft); color: var(--amber); }
.alert-list li { align-items: center; }
.alert-list .ic { color: var(--amber); }
.empty { color: var(--muted); padding: 14px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }

/* ---------- Formulare ---------- */
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-weight: 500; font-size: .95rem; }
input, select, textarea {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%;
  min-height: 42px;
}
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; min-height: 0; accent-color: var(--red); }
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--red); outline-offset: -1px; border-color: transparent; }
fieldset { border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; font-size: .9rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: inherit; font-weight: 600; font-size: .92rem;
  padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--surface); color: var(--text); cursor: pointer; min-height: 42px; white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn .ic { width: 18px; height: 18px; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.danger { color: var(--red); }
.btn.small { padding: 5px 10px; min-height: 34px; font-size: .84rem; }
.btn.big { padding: 12px 20px; font-size: 1rem; width: 100%; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn[disabled] { opacity: .5; cursor: default; }

/* Filterleiste */
.filters { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.filters input, .filters select { width: auto; min-width: 160px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); font-weight: 600; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--red); border-color: var(--red); }
.tabs a:hover { text-decoration: none; color: var(--text); }

/* Ausklappbereiche (Formulare zum Anlegen) */
details.adder { margin-bottom: 18px; }
details.adder > summary { list-style: none; cursor: pointer; }
details.adder > summary::-webkit-details-marker { display: none; }
details.adder[open] > summary { margin-bottom: 12px; }

/* ---------- Protokoll-Editor (Tablet) ---------- */
.prot-meta summary { cursor: pointer; font-weight: 600; }
.savestate { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.savestate::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.savestate.dirty::before { background: var(--amber); }
.savestate.error::before { background: var(--red); }
.top-card { padding: 0; overflow: hidden; }
.top-card .top-head {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px 10px 16px;
  background: var(--surface-2); border-bottom: 1px solid var(--line);
}
.top-card .top-nr { font-weight: 800; color: var(--red); white-space: nowrap; font-size: 1.05rem; }
.top-card .top-title { font-weight: 700; font-size: 1.05rem; border-color: transparent; background: transparent; padding-left: 4px; }
.top-card .top-title:focus { background: var(--surface); }
.top-card textarea.top-text {
  border: 0; border-radius: 0; min-height: 170px; padding: 14px 16px; font-size: 1.05rem; background: var(--surface);
}
.top-card textarea.top-text:focus { outline: 0; box-shadow: inset 3px 0 0 var(--red); }
.top-tools { display: flex; gap: 2px; }
.sticky-bar {
  position: sticky; bottom: 0; z-index: 10; margin: 0 -4px; padding: 12px 4px;
  background: linear-gradient(to top, var(--bg) 70%, transparent);
  display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}
.top-index { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.top-index a { font-size: .82rem; padding: 4px 10px; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--text); }

/* Zeitplan-Tabelle */
.zp-table td { padding: 5px 4px; }
.zp-table input[type="time"] { min-width: 96px; }
.zp-table input[type="date"] { min-width: 140px; }
.zp-table input[name="zp_punkt[]"] { min-width: 180px; }
.zp-table input[name="zp_wer[]"], .zp-table input[name="zp_bem[]"] { min-width: 110px; }

/* Login */
.login-wrap { min-height: 82vh; display: grid; place-items: center; }
.login-card { width: 100%; max-width: 400px; padding: 28px; }
.login-card h1 { text-align: center; font-size: 1.3rem; margin-top: 8px; }
.login-logo { text-align: center; }

/* Installer */
.checklist { list-style: none; padding: 0; margin: 0 0 10px; }
.checklist li { padding: 4px 0; font-weight: 500; }
.checklist .ok { color: var(--green); }
.checklist .bad { color: var(--red); }
.checklist .pending { color: var(--muted); }

/* Rechte-Matrix */
.perm-table td, .perm-table th { padding: 7px 8px; }
.perm-table select { min-width: 130px; }

/* Changelog */
.changelog h2 .badge { margin-left: 6px; }
.changelog ul { margin: 0; padding-left: 20px; }

/* ---------- Druck ---------- */
@media print {
  body { padding: 0; background: #fff; color: #000; font-size: 11pt; }
  .topbar, .sidebar, .actions, .noprint, .foot, .sticky-bar, details.adder, .filters, .tabs, form button { display: none !important; }
  .main { margin: 0; padding: 0; max-width: none; }
  .card { box-shadow: none; border: 0; padding: 0; margin-bottom: 14px; }
  a { color: #000; }
  input, textarea, select { border: 0; padding: 0; min-height: 0; }
}
