:root {
  --bg: #f3f5ee;
  --ink: #33352f;
  --green: #7cb342;
  --green-dark: #4b8c35;
  --muted: #7a8070;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, "Open Sans", sans-serif;
  color: var(--ink);
  background: var(--bg);
}
/* Kinderabenteuerhof aerial photo as a subtle, fixed page background. A translucent
   light overlay keeps dense tables/text readable; opaque cards float above it.
   Served from /static -> allowed by CSP img-src 'self'. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(rgba(243, 245, 238, 0.74), rgba(243, 245, 238, 0.88)),
    url("/static/img/hof-luftbild.jpg") center center / cover no-repeat;
}

.shell { max-width: 1160px; margin: 0 auto; padding: 40px 28px; }
h1 { color: var(--green-dark); }
.muted { color: var(--muted); }

/* htmx request indicator (B29): external replacement for htmx's default injected
   inline <style>, which is disabled via the htmx-config meta so style-src can stay
   'self'. Used by elements with class="htmx-indicator" in later (P3+) UI work. */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator { opacity: 1; }
.htmx-request.htmx-indicator { opacity: 1; }

/* P2 auth UI */
.topbar { background: #fff; border-bottom: 1px solid #e4e8db; padding: 14px 28px; }
.brand { color: var(--green-dark); font-weight: 700; text-decoration: none;
  display: inline-flex; align-items: center; gap: 11px; }
.brand-logo { height: 38px; width: auto; display: block; }
.brand-text { line-height: 1.15; }
@media (max-width: 560px) { .brand-text { display: none; } }  /* logo-only on small screens */
.stack { display: flex; flex-direction: column; gap: 10px; max-width: 380px; margin: 16px 0; }
label { font-size: 13px; font-weight: 600; color: #5b6052; }
input[type="email"] { padding: 11px 13px; border: 1.5px solid #d8ddcd; border-radius: 9px; font-size: 15px; }
button, .btn { display: inline-block; padding: 12px 18px; border: none; border-radius: 9px;
  background: var(--green); color: #fff; font-size: 15px; font-weight: 700; cursor: pointer; text-decoration: none; }
button:hover, .btn:hover { background: var(--green-dark); }
.hint { font-size: 12px; color: #9aa08f; max-width: 380px; }
.error { color: #c0341f; font-weight: 600; }

/* P3 shell */
.topbar { display: flex; align-items: center; justify-content: space-between; }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 13px; color: #6f7466; }
.inline { margin: 0; }
.linkbtn { background: #fff; border: 1.5px solid #e0e5d6; color: #6f7466; padding: 7px 12px; font-size: 13px; }
.linkbtn:hover { background: #f3f6ec; color: var(--green-dark); }
.crumbs { font-size: 12px; color: #9aa08f; margin-bottom: 8px; }
.crumbs a { color: #9aa08f; }
.crumbs .sep { color: #cdd4c0; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; margin-top: 18px; }
.card { display: block; background: #fff; border: 1.5px solid #d7e3b8; border-radius: 14px; padding: 20px;
  text-decoration: none; color: var(--ink); box-shadow: 0 6px 18px rgba(80,110,40,.06); }
.card:hover { border-color: var(--green); }
.card-title { font-size: 18px; font-weight: 800; }
.card-desc { font-size: 13px; color: #7a8070; margin-top: 5px; }
.card-cta { font-size: 13px; font-weight: 700; color: var(--green-dark); margin-top: 14px; }
.card-soon { background: #f7f8f3; border-style: dashed; border-color: #dde2d3; }
.card-soon .card-title { color: #9aa08f; }
.badge { display: inline-block; font-size: 11px; font-weight: 700; color: #9aa08f; background: #e7ebde;
  padding: 4px 10px; border-radius: 999px; margin-top: 10px; }

/* P4 protocol table (design B) — compact, sharp 3-4px corners */
.table-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head-actions { display: flex; gap: 10px; align-items: center; }
.head-actions .btn, .head-actions .linkbtn { border-radius: 4px; }
.searchbar { display: flex; gap: 8px; margin: 14px 0; }
.searchbar input { flex: 1; max-width: 360px; padding: 9px 12px; border: 1px solid #d6dccb; border-radius: 4px; }
.searchbar button { border-radius: 4px; }

.table-wrap { background: #fff; border: 1px solid #e0e5d6; border-radius: 5px; overflow-x: auto;
  box-shadow: 0 1px 0 rgba(50,60,40,.03); }
.proto { width: 100%; border-collapse: collapse; min-width: 920px; table-layout: fixed; }
.proto thead th { background: #f1f4ea; text-align: left; font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .04em; color: #7a8070; padding: 8px 10px;
  border-bottom: 1px solid #e0e5d6; white-space: nowrap; }
.proto tbody td { padding: 7px 10px; border-top: 1px solid #eef1e8; vertical-align: top; font-size: 12.5px; word-wrap: break-word; }
.proto tbody tr:hover { background: #f8faf4; }
.cell-mono { font-variant-numeric: tabular-nums; white-space: nowrap; }
.cell-zeit { font-variant-numeric: tabular-nums; color: #7a8070; text-align: center; }
.cell-thema { font-weight: 600; }
.cell-termin { font-variant-numeric: tabular-nums; }
.proto .nw { white-space: nowrap; }
.c-datum { width: 82px; } .c-zeit { width: 44px; } .c-thema { width: 122px; }
.c-inhalt { width: auto; } .c-wer { width: 100px; } .c-next { width: 150px; }
.c-termin { width: 74px; } .c-status { width: 80px; } .c-act { width: 38px; }

/* segments inside the read cell — colored pill tag + text */
.segs { display: flex; flex-direction: column; gap: 3px; }
.segs .seg { display: flex; gap: 7px; align-items: baseline; line-height: 1.4; }
.segs .tag { flex: none; font-size: 9.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em;
  padding: 1px 5px; border-radius: 3px; color: #fff; margin-top: 1px; }
.tag.seg-ein { background: #1f6db0; } .tag.seg-prot { background: #2b2b2b; }
.tag.seg-besch { background: #c0341f; } .tag.seg-versch { background: #2e7d32; } .tag.seg-erg { background: #8a8a8a; }
.segs .txt { color: #33352f; }
.seg.seg-besch .txt { color: #c0341f; font-weight: 600; }
.seg.seg-erg .txt { color: #6b6b6b; font-style: italic; }

/* status badge */
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 3px; white-space: nowrap; }
.badge.offen { background: #fbe6cf; color: #b25a1a; }
.badge.erledigt { background: #e3efce; color: #4b7d1f; }

.row-edit-link { text-align: center; }
.row-edit-link a { color: #b6bda9; font-size: 15px; text-decoration: none; }
.proto tbody tr:hover .row-edit-link a { color: var(--green-dark); }

/* filter bar + search-hit highlight */
.filterbar { display: flex; gap: 8px; align-items: center; margin: 14px 0; flex-wrap: wrap; }
.filterbar input[type="search"] { flex: 1; min-width: 200px; max-width: 340px; padding: 9px 12px;
  border: 1px solid #d6dccb; border-radius: 4px; }
.filterbar input[type="text"], .filterbar input[type="date"], .filterbar select { padding: 8px 10px;
  border: 1px solid #d6dccb; border-radius: 4px; font-size: 13px; font-family: inherit; background: #fff; color: var(--ink); }
.filterbar button { border-radius: 4px; }
.filterbar .linkbtn { border-radius: 4px; }
.filterbar .bis { color: var(--muted); }
mark { background: #fcef9c; color: inherit; padding: 0 1px; border-radius: 2px; }

/* ---- edit drawer (design B) — slides in CSP-safe via @keyframes, no inline JS ---- */
.scrim { position: fixed; inset: 0; background: rgba(38,42,33,.34); z-index: 40; animation: scrimIn .18s ease; }
@keyframes scrimIn { from { opacity: 0; } to { opacity: 1; } }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: 492px; min-width: 380px; max-width: 96vw;
  background: #fbfcf8; border-left: 1px solid #e0e5d6; box-shadow: -14px 0 36px rgba(40,50,30,.16);
  z-index: 50; display: flex; flex-direction: column; animation: drawerIn .22s cubic-bezier(.4,0,.2,1); }
/* drag the left edge to widen (stays pinned right); double-click resets — see app.js */
.drawer-resize { position: absolute; top: 0; left: -3px; width: 10px; height: 100%; z-index: 3;
  cursor: ew-resize; touch-action: none; }
.drawer-resize::after { content: ""; position: absolute; left: 3px; top: 0; width: 2px; height: 100%;
  background: transparent; transition: background .12s ease; }
.drawer-resize:hover::after, .drawer.is-resizing .drawer-resize::after { background: var(--green); }
.drawer.is-resizing { user-select: none; animation: none; }
@keyframes drawerIn { from { transform: translateX(100%); } to { transform: translateX(0); } }
.drawer-form { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.drawer-head { flex: none; padding: 15px 20px 12px; border-bottom: 1px solid #e0e5d6; background: #fff;
  display: flex; align-items: flex-start; gap: 12px; }
.drawer-head .eyebrow { font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em; color: #7a8070; font-weight: 600; }
.drawer-head h2 { font-size: 16px; margin: 3px 0 0; color: var(--green-dark); font-weight: 700; }
.drawer-head .sub { font-size: 12px; color: #7a8070; margin-top: 2px; }
.x-btn { flex: none; margin-left: auto; width: 28px; height: 28px; border-radius: 4px; border: 1px solid #e0e5d6;
  background: #fff; color: #7a8070; font-size: 15px; line-height: 1; padding: 0; cursor: pointer; }
.x-btn:hover { background: #f4f6ef; color: var(--ink); }
.drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px; }
.drawer-foot { flex: none; padding: 12px 20px; border-top: 1px solid #e0e5d6; background: #fff;
  display: flex; align-items: center; gap: 10px; }
.drawer-foot .spacer { flex: 1; }
.drawer-foot .btn, .drawer-foot .linkbtn { border-radius: 4px; }
.drawer-err { margin: 0 0 12px; }

.drawer .field { margin-bottom: 14px; }
.drawer .field > label { display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .04em; color: #7a8070; margin-bottom: 5px; }
.drawer .grid-3 { display: grid; grid-template-columns: 1fr 86px 1.2fr; gap: 11px; }
.drawer .grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.drawer .grid-3 .field, .drawer .grid-2 .field { margin-bottom: 0; }
.inp, .ta, .sel { width: 100%; font: inherit; font-size: 13px; color: var(--ink); background: #fff;
  border: 1px solid #d6dccb; border-radius: 4px; padding: 7px 9px; }
.inp:focus, .ta:focus, .sel:focus, .seg-ta:focus, .seg-sel:focus { outline: none; border-color: var(--green-dark);
  box-shadow: 0 0 0 3px rgba(124,179,66,.18); }
.ta { resize: vertical; min-height: 60px; line-height: 1.5; }
.ta-center { text-align: center; }
.divider { height: 1px; background: #e4e8db; margin: 4px 0 15px; }

.rich-head { display: flex; align-items: baseline; margin-bottom: 8px; }
.rich-head label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #7a8070; }
.rich-head .count { margin-left: 8px; font-size: 11px; color: #9aa08f; }
.seg-stack { display: flex; flex-direction: column; gap: 9px; }
.seg-card { border: 1px solid #e0e5d6; border-left-width: 3px; border-radius: 4px; background: #fff; padding: 9px; }
.seg-card.k-ein { border-left-color: #1f6db0; } .seg-card.k-prot { border-left-color: #2b2b2b; }
.seg-card.k-besch { border-left-color: #c0341f; } .seg-card.k-versch { border-left-color: #2e7d32; }
.seg-card.k-erg { border-left-color: #8a8a8a; }
.seg-card-top { display: flex; align-items: center; gap: 8px; margin-bottom: 7px; }
.seg-sel { width: auto; min-width: 130px; font-size: 12px; font-weight: 600; padding: 4px 8px;
  border: 1px solid #d6dccb; border-radius: 4px; background: #fff; font-family: inherit; color: var(--ink); }
.seg-del { margin-left: auto; border: none; background: transparent; color: #b3baa6; font-size: 15px;
  line-height: 1; padding: 2px 4px; border-radius: 4px; cursor: pointer; }
.seg-del:hover { color: #c0341f; background: #faf0ee; }
.seg-ta { width: 100%; font: inherit; font-size: 13px; line-height: 1.5; color: var(--ink); background: #fcfdfa;
  border: 1px solid #e1e6d6; border-radius: 4px; padding: 7px 8px; resize: vertical; min-height: 52px; }
.add-seg { margin-top: 9px; width: 100%; text-align: center; font-size: 12.5px; font-weight: 600;
  color: var(--green-dark); background: #f4f8ec; border: 1px dashed #bcd49a; border-radius: 4px; padding: 7px; cursor: pointer; }
.add-seg:hover { background: #ecf3df; }

.seg-toggle { display: inline-flex; border: 1px solid #d6dccb; border-radius: 4px; overflow: hidden; }
.seg-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.seg-toggle label { font-size: 12.5px; padding: 6px 14px; cursor: pointer; color: #7a8070; background: #fff;
  user-select: none; margin: 0; border-left: 1px solid #d6dccb; }
.seg-toggle label:first-of-type { border-left: none; }
.seg-toggle #st-offen:checked + label { background: #fbe6cf; color: #b25a1a; font-weight: 600; }
.seg-toggle #st-erledigt:checked + label { background: #e3efce; color: #4b7d1f; font-weight: 600; }

/* P4 entry form */
.entryform .grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin: 14px 0; }
.entryform label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; font-weight: 600; color: #5b6052; }
.entryform input, .entryform select, .entryform textarea { padding: 10px 12px; border: 1.5px solid #e0e5d6;
  border-radius: 9px; font-size: 14px; font-family: inherit; }
.entryform .full { display: block; margin: 6px 0; }
.formh2 { font-size: 14px; margin: 18px 0 4px; }
.segrow { display: grid; grid-template-columns: 160px 1fr; gap: 10px; margin-bottom: 10px; }
.formactions { display: flex; gap: 12px; align-items: center; margin-top: 16px; }
.deleteform { margin-top: 16px; }
.danger { color: #c0341f; border-color: #e7c6bf; }
.danger:hover { background: #fbe6cf; color: #c0341f; }

.empty-note { margin-top: 12px; }

/* P8 — email a protocol as PDF (versenden) */
.sent-ok { color: #4b7d1f; font-weight: 600; background: #e3efce; padding: 10px 14px; border-radius: 6px; }
.radio-cards { display: flex; gap: 12px; flex-wrap: wrap; margin: 8px 0 14px; }
.radio-cards .radio-card { display: flex; flex-direction: row; align-items: flex-start; gap: 9px;
  border: 1.5px solid #e0e5d6; border-radius: 8px; padding: 12px 14px; cursor: pointer; flex: 1;
  min-width: 220px; background: #fff; font-weight: 400; color: var(--ink); }
.radio-cards .radio-card input { margin-top: 2px; }
.radio-cards .radio-card:has(input:checked) { border-color: var(--green); background: #f6faef; }
.range-inputs { max-width: 420px; }
.recipient-list { display: flex; flex-direction: column; gap: 8px; margin: 8px 0 4px; }
.recipient-list .checkrow { display: flex; flex-direction: row; align-items: center; gap: 8px; font-weight: 400; }

/* P5 admin */
.addform { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.addform input { padding: 11px 13px; border: 1.5px solid #e0e5d6; border-radius: 9px; font-size: 14px; }
.matrix td { vertical-align: middle; }
.cellbtn { width: 30px; height: 30px; border-radius: 8px; border: 1.5px solid #d2d7c9; background: #fff;
  color: #9aa08f; font-size: 14px; font-weight: 800; cursor: pointer; padding: 0; line-height: 1; }
.cellbtn.on { background: var(--green); border: none; color: #fff; }
.cellbtn.remove { color: #b0867f; border-color: #e7d6d0; }
.cellbtn.remove:hover { background: #fbe6cf; color: #c0341f; }
.basebox { font-size: 13px; color: #6f7466; }
.basebox code { background: #f1f4ea; padding: 6px 10px; border-radius: 8px; }
.checkrow { flex-direction: row; align-items: center; gap: 8px; }
