:root {
  --red: #c4151c; --red-dark: #8f0f14; --bg: #f4f5f7; --card: #fff; --text: #1d2125; --muted: #6b7380;
  --line: #e2e5ea; --ok: #1f8a4c; --warn: #b26a00; --blue: #2457a6; --radius: 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.45; }
a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: .2em 0 .6em; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .6em; }
main { max-width: 1400px; margin: 0 auto; padding: 20px 16px 60px; }

/* Kopfzeile & Menü */
.top { background: var(--red); color: #fff; display: flex; align-items: center; gap: 24px; padding: 0 16px; min-height: 54px; position: sticky; top: 0; z-index: 10; box-shadow: 0 1px 4px rgba(0,0,0,.2); }
.brand { color: #fff; font-weight: 700; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; white-space: nowrap; }
.brand:hover { text-decoration: none; }
.logo { background: #fff; color: var(--red); border-radius: 6px; padding: 2px 6px; font-size: .85rem; font-weight: 800; }
nav.main { display: flex; align-items: center; gap: 4px; flex: 1; }
nav.main a { color: #fff; padding: 16px 12px; opacity: .9; border-bottom: 3px solid transparent; white-space: nowrap; }
nav.main a:hover { opacity: 1; text-decoration: none; background: rgba(255,255,255,.08); }
nav.main a.on { opacity: 1; border-bottom-color: #fff; font-weight: 600; }
nav.main .spacer { flex: 1; }
.burger { display: none; background: none; border: 0; color: #fff; font-size: 1.5rem; margin-left: auto; cursor: pointer; }

/* Bausteine */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 420px; margin: 40px auto; }
.head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.btn { display: inline-block; border: 1px solid var(--line); background: #fff; color: var(--text); padding: 7px 14px; border-radius: 6px; cursor: pointer; font: inherit; font-size: .92rem; white-space: nowrap; }
.btn:hover { background: #f0f1f3; text-decoration: none; }
.btn.primary { background: var(--red); border-color: var(--red); color: #fff; }
.btn.primary:hover { background: var(--red-dark); }
.btn.danger { color: var(--red); border-color: #f0c2c4; }
.btn.link { border-color: transparent; background: none; color: var(--blue); }
.btn.small { font-size: .82rem; padding: 4px 10px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.late { color: var(--red); font-weight: 600; }
.flash { padding: 10px 14px; border-radius: 6px; margin-bottom: 14px; background: #e7f5ec; color: #145c33; border: 1px solid #bfe3cc; }
.flash.err { background: #fdecec; color: #8f0f14; border-color: #f4c3c5; }
.flash.info { background: #eaf1fb; color: #1d4580; border-color: #c4d6f1; }
.tag { display: inline-block; background: #eef0f3; color: var(--muted); border-radius: 4px; padding: 0 6px; font-size: .78rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.pre { white-space: normal; overflow-wrap: anywhere; }
code { background: #eef0f3; padding: 1px 5px; border-radius: 4px; }

/* Formulare */
.form label { display: block; margin-bottom: 12px; font-size: .88rem; color: var(--muted); }
.form input:not([type=checkbox]):not([type=radio]), .form select, .form textarea, .filters input, .filters select, .quick select, input.copy {
  display: block; width: 100%; margin-top: 4px; padding: 8px 10px; border: 1px solid #cfd4db; border-radius: 6px; font: inherit; color: var(--text); background: #fff; }
.form textarea { resize: vertical; font-family: inherit; }
.form input:focus, .form select:focus, .form textarea:focus { outline: 2px solid rgba(196,21,28,.25); border-color: var(--red); }
.form label.check { display: flex; gap: 8px; align-items: flex-start; color: var(--text); }
.grid-form { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.grid-form .span-2 { grid-column: span 2; }
.narrow-form { max-width: 520px; }
.row { display: flex; gap: 8px; }
.row input[type=time] { max-width: 130px; }
body.allday .time { display: none !important; }
input.copy { font-family: ui-monospace, Menlo, monospace; font-size: .8rem; margin-bottom: 8px; }

/* Filter & Tabellen */
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filters input[type=search] { flex: 1 1 220px; width: auto; margin: 0; }
.filters select { width: auto; margin: 0; }
.stats { display: flex; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; align-items: center; }
.stats a { color: var(--text); }
.overdue-count { color: var(--red); font-weight: 600; }
.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 10px; border-bottom: 2px solid var(--line); background: #fafbfc; white-space: nowrap; }
table.list th a { color: var(--muted); }
table.list th a.sorted { color: var(--red); }
table.list th a.sorted::after { content: " ▾"; }
table.list td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.list tr.click { cursor: pointer; }
table.list tr.click:hover td { background: #fbf6f6; }
tr.inactive td { opacity: .5; }
.clamp { max-width: 520px; }

/* Badges */
.prio { display: inline-block; min-width: 30px; text-align: center; font-weight: 700; font-size: .8rem; border-radius: 4px; padding: 2px 6px; color: #fff; }
.prio-a1 { background: var(--red); }
.prio-a2 { background: #e07b00; }
.prio-b1 { background: #2f7fc1; }
.prio-b2 { background: #8a929c; }
.status { display: inline-block; font-size: .78rem; padding: 2px 8px; border-radius: 99px; background: #eef0f3; white-space: nowrap; }
.s-open { background: #fdecec; color: #8f0f14; }
.s-work { background: #fff3dc; color: #7a4a00; }
.s-wait { background: #efe8fb; color: #523090; }
.s-watch { background: #e5f0fb; color: #1d4580; }
.s-done { background: #e7f5ec; color: #145c33; }
.s-cont { background: #e9f3f3; color: #1f5d5d; }
.bar { display: inline-block; width: 70px; height: 7px; background: #e6e8ec; border-radius: 4px; overflow: hidden; vertical-align: middle; margin-right: 6px; }
.bar span { display: block; height: 100%; background: var(--ok); }

/* Detailansicht */
dl.facts { display: grid; grid-template-columns: 150px 1fr; gap: 6px 12px; margin: 0 0 18px; }
dl.facts dt { color: var(--muted); font-size: .88rem; }
dl.facts dd { margin: 0; }
.quick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.quick select { width: auto; margin: 0; }
ul.timeline { list-style: none; padding: 0; margin: 0; }
ul.timeline li { border-left: 3px solid var(--line); padding: 4px 0 10px 12px; margin-left: 4px; overflow-wrap: anywhere; }
ul.timeline li.comment { border-left-color: var(--blue); }
ul.timeline .meta { font-size: .78rem; color: var(--muted); }
del { color: #9a3a3a; background: #fdecec; text-decoration: line-through; }
ins { color: #145c33; background: #e7f5ec; text-decoration: none; }
.diff del, .diff ins { display: block; padding: 6px; margin: 4px 0; font-size: .85rem; }
ul.plain { list-style: none; padding: 0; margin: 0; }
ul.plain li { padding: 6px 0; border-bottom: 1px solid var(--line); }
pre.mail { white-space: pre-wrap; font-size: .85rem; background: #fafbfc; padding: 10px; border-radius: 6px; }

/* Kalender */
.cal-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.cal-nav h2 { min-width: 170px; text-align: center; }
.toggle { margin-left: auto; font-size: .88rem; color: var(--muted); }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); background: var(--line); gap: 1px; border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 16px; }
.cal-h { background: #fafbfc; padding: 6px; font-size: .78rem; font-weight: 600; color: var(--muted); text-align: center; }
.cal-d { background: #fff; min-height: 104px; padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-d.we { background: #fcfcfd; }
.cal-d.other { background: #f7f8f9; }
.cal-d.other .num { color: #b4bac3; }
.cal-d .num { font-size: .82rem; color: var(--muted); align-self: flex-end; padding: 0 5px; border-radius: 99px; }
.cal-d .num:hover { background: #eee; text-decoration: none; }
.cal-d.today .num { background: var(--red); color: #fff; font-weight: 700; }
.ev { display: block; font-size: .76rem; padding: 2px 5px; border-radius: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; color: #fff; background: var(--blue); }
.ev:hover { text-decoration: none; filter: brightness(1.1); }
.ev.cat-0 { background: #2457a6; } .ev.cat-1 { background: #c4151c; } .ev.cat-2 { background: #1f8a4c; }
.ev.cat-3 { background: #7d3cb5; } .ev.cat-4 { background: #b26a00; } .ev.cat-5 { background: #1f6f7a; }
.ev.lopdue { background: #fff3dc; color: #7a4a00; border: 1px dashed #e0a84a; }

@media (max-width: 1180px) and (min-width: 901px) {
  .top { gap: 12px; }
  nav.main a { padding: 16px 7px; font-size: .9rem; }
}

/* Handy */
@media (max-width: 900px) {
  .grid-2, .grid-form { grid-template-columns: 1fr; }
  .grid-form .span-2 { grid-column: auto; }
  .burger { display: block; }
  .top { flex-wrap: wrap; }
  nav.main { display: none; flex-basis: 100%; flex-direction: column; align-items: stretch; padding-bottom: 8px; }
  nav.main a { padding: 10px 8px; border-bottom: 0; }
  nav.main a.on { background: rgba(255,255,255,.15); }
  body.nav-open nav.main { display: flex; }
  dl.facts { grid-template-columns: 1fr; }
  dl.facts dt { margin-top: 6px; }
  .cal-d { min-height: 64px; }
  .ev { font-size: .66rem; padding: 1px 3px; }
  .ev b { display: none; }
  .toggle { margin-left: 0; }
  .lop-list td:nth-child(4), .lop-list th:nth-child(4), .lop-list td:nth-child(9), .lop-list th:nth-child(9) { display: none; }
}

/* Anhänge */
ul.files { list-style: none; padding: 0; margin: 0 0 14px; }
ul.files li { display: flex; align-items: center; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
ul.files .ficon { font-size: 1.3rem; }
ul.files .fname { flex: 1; min-width: 0; overflow-wrap: anywhere; }
ul.files .fname .small { display: block; }
ul.files form { margin: 0; }
.upload { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.drop { flex: 1 1 260px; position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  border: 2px dashed #cfd4db; border-radius: 8px; padding: 14px; text-align: center; cursor: pointer; color: var(--text); font-size: .9rem; }
.drop:hover, .drop.over { border-color: var(--red); background: #fbf6f6; }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
ul.timeline li.file { border-left-color: #8a929c; }

/* Unteraufgaben */
.tasks h3 { margin-bottom: 8px; }
ul.tasklist { list-style: none; padding: 0; margin: 0 0 10px; }
ul.tasklist li { display: flex; align-items: center; gap: 8px; padding: 5px 0; border-bottom: 1px solid var(--line); }
ul.tasklist li form { margin: 0; }
ul.tasklist .ttitle { flex: 1; min-width: 0; overflow-wrap: anywhere; }
ul.tasklist li.done .ttitle { color: var(--muted); text-decoration: line-through; }
ul.tasklist .tag { margin-left: 4px; }
button.chk { width: 22px; height: 22px; border: 2px solid #9aa1ab; border-radius: 5px; background: #fff; cursor: pointer; font-weight: 700; color: #fff; line-height: 1; padding: 0; }
li.done button.chk { background: var(--ok); border-color: var(--ok); }
button.chk:hover { border-color: var(--ok); }
button.x { border: 0; background: none; color: #b4bac3; cursor: pointer; font-size: .9rem; }
button.x:hover { color: var(--red); }
.task-add { display: flex; gap: 6px; flex-wrap: wrap; }
.task-add input { padding: 6px 8px; border: 1px solid #cfd4db; border-radius: 6px; font: inherit; font-size: .9rem; }
.task-add input[name=task_title] { flex: 1 1 180px; }
.task-add input[name=task_assignee] { flex: 0 1 140px; width: 140px; }
ul.timeline li.task { border-left-color: var(--ok); }

/* Sitzungsmodus */
.head form { margin: 0; }
.meeting-head { display: grid; gap: 4px; }
.meeting-progress { margin-top: 6px; }
nav.agenda { position: sticky; top: 54px; z-index: 5; display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 0; background: var(--bg); margin-bottom: 8px; }
nav.agenda a { min-width: 32px; text-align: center; padding: 4px 8px; border-radius: 6px; background: #fff; border: 1px solid var(--line); color: var(--text); font-weight: 600; font-size: .85rem; }
nav.agenda a.done { background: #e7f5ec; border-color: #bfe3cc; color: #145c33; }
nav.agenda a:hover { border-color: var(--red); text-decoration: none; }
section.mitem { scroll-margin-top: 110px; border-left: 4px solid var(--line); }
section.mitem.discussed { border-left-color: var(--ok); opacity: .85; }
section.mitem:target { border-left-color: var(--red); box-shadow: 0 0 0 2px rgba(196,21,28,.15); }
.mitem-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mitem-head h2 { font-size: 1.1rem; flex: 1 1 200px; }
.mitem-head .topnr { font-weight: 700; color: var(--muted); font-size: .85rem; }
.mdesc { margin: 10px 0; }
.mdesc summary { cursor: pointer; color: var(--muted); font-size: .88rem; }
.mdesc .pre { margin-top: 6px; padding: 8px 10px; background: #fafbfc; border-radius: 6px; }
.mitem-body { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 12px; }
.mquick .row { gap: 10px; align-items: flex-end; }
.mquick .row label { flex: 1; }
.mitem-foot { margin-top: 12px; display: flex; justify-content: flex-end; }
.btn.ok { background: var(--ok); border-color: var(--ok); color: #fff; }
.row-form { display: flex; gap: 8px; flex-wrap: wrap; }
.row-form select { flex: 1 1 260px; padding: 8px; border: 1px solid #cfd4db; border-radius: 6px; font: inherit; }
fieldset.checks { border: 1px solid var(--line); border-radius: 6px; margin: 0 0 12px; padding: 8px 12px; }
fieldset.checks legend { font-size: .88rem; color: var(--muted); }
fieldset.checks label.check { margin: 4px 0; }

/* Kartenansicht LoP (Handy) */
.lop-cards { display: none; }
.lop-card { display: block; background: var(--card); border: 1px solid var(--line); border-left: 4px solid var(--line); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; color: var(--text); }
.lop-card:hover { text-decoration: none; border-color: #d9a3a5; }
.lc-top { display: flex; align-items: center; gap: 6px; }
.lc-due { margin-left: auto; font-size: .85rem; }
.lc-title { font-weight: 700; margin: 6px 0 2px; line-height: 1.3; }
.lc-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 8px; }

@media (max-width: 900px) {
  .lop-list-wrap, .table-wrap:has(.lop-list) { display: none; }
  .lop-cards { display: block; }
  .mitem-body { grid-template-columns: 1fr; }
  nav.agenda { top: 54px; }
  .task-add input[name=task_assignee] { flex: 1 1 120px; }
}

/* Backup-Anleitung */
ol.steps { padding-left: 20px; margin: 0 0 16px; }
ol.steps li { margin-bottom: 8px; }
ol.steps .copy { margin-top: 4px; }

/* Tagesordnung sortieren */
details.sorter summary { cursor: pointer; }
.sortform { margin-top: 12px; }
.sortby { gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 10px; }
ol.sortlist { list-style: none; padding: 0; margin: 0 0 12px; }
ol.sortlist li { display: flex; align-items: center; gap: 8px; padding: 6px 8px; margin-bottom: 4px; background: #fff; border: 1px solid var(--line); border-radius: 6px; cursor: grab; transition: background .3s; }
ol.sortlist li.dragging { opacity: .4; }
ol.sortlist li.moved { background: #fff3dc; }
ol.sortlist .grip { color: #9aa1ab; font-size: 1.1rem; user-select: none; }
ol.sortlist .topno { font-weight: 700; color: var(--muted); font-size: .8rem; min-width: 48px; }
ol.sortlist .tp { display: flex; align-items: center; gap: 8px; }
ol.sortlist .arrows { display: flex; gap: 6px; }
ol.sortlist .stitle { flex: 1; min-width: 0; overflow-wrap: break-word; hyphens: auto; }
ol.sortlist .stitle .small { display: block; }
@media (max-width: 900px) {
  ol.sortlist li { gap: 10px; padding: 8px; }
  ol.sortlist .grip { display: none; }
  ol.sortlist .tp { flex-direction: column; align-items: center; gap: 4px; }
  ol.sortlist .topno { min-width: 0; font-size: .72rem; }
  ol.sortlist .arrows { flex-direction: column; }
  ol.sortlist .btn.small { padding: 5px 12px; }
}

/* Gremien */
.gremien-list li { cursor: default; }
.gremien-list .grip { cursor: grab; }
.gremien-list li.inactive { background: #f4f5f7; }
.gremien-list li.inactive input[name=name] { color: var(--muted); text-decoration: line-through; }
.gremien-list form { margin: 0; }
.gremien-list form.rename { flex: 1; display: flex; gap: 4px; min-width: 0; }
.gremien-list form.rename input { flex: 1; min-width: 0; padding: 5px 8px; border: 1px solid transparent; border-radius: 5px; font: inherit; background: transparent; }
.gremien-list form.rename input:hover, .gremien-list form.rename input:focus { border-color: #cfd4db; background: #fff; }
.gremien-list .x-placeholder { width: 22px; }

/* Menü: Verwaltung (Admin) */
details.navdrop { position: relative; }
details.navdrop > summary { list-style: none; color: #fff; padding: 16px 12px; cursor: pointer; opacity: .9; white-space: nowrap; border-bottom: 3px solid transparent; }
details.navdrop > summary::-webkit-details-marker { display: none; }
details.navdrop > summary:hover { opacity: 1; background: rgba(255,255,255,.08); }
details.navdrop.on > summary { opacity: 1; border-bottom-color: #fff; font-weight: 600; }
details.navdrop .dropmenu { position: absolute; top: 100%; left: 0; min-width: 190px; background: #fff; border-radius: 0 0 8px 8px; box-shadow: 0 6px 20px rgba(0,0,0,.18); padding: 6px 0; z-index: 20; }
nav.main details.navdrop .dropmenu a { display: block; color: var(--text); padding: 9px 16px; border: 0; opacity: 1; }
nav.main details.navdrop .dropmenu a:hover { background: #f4f5f7; text-decoration: none; }
nav.main details.navdrop .dropmenu a.on { color: var(--red); font-weight: 600; background: #fbf6f6; }
@media (max-width: 1180px) and (min-width: 901px) { details.navdrop > summary { padding: 16px 7px; font-size: .9rem; } }
@media (max-width: 900px) {
  details.navdrop > summary { padding: 10px 8px; border-bottom: 0; }
  details.navdrop .dropmenu { position: static; box-shadow: none; background: rgba(255,255,255,.1); border-radius: 6px; }
  nav.main details.navdrop .dropmenu a { color: #fff; padding: 9px 20px; }
  nav.main details.navdrop .dropmenu a:hover, nav.main details.navdrop .dropmenu a.on { background: rgba(255,255,255,.15); color: #fff; }
}
