:root {
  --green: #78a08c;
  --green-dark: #1c302a;
  --green-light: #e3ebe5;
  --sun: #e6fd53;
  --magenta: #e6007e;
  --bg: #f5f1e9;
  --card: #ffffff;
  --text: #1c302a;
  --muted: #6b7568;
  --border: #ddd8cc;
  --red: #c62828;
  --amber: #e69500;
  --blue: #2563a8;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.04);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121c19; --card: #1c302a; --text: #e6ebe4; --muted: #9aa596; --border: #2f382e;
    --green-light: #2a4239; --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); }
a { color: var(--green-dark); }
h1 { font-size: 1.5rem; margin: 0 0 .25rem; }
h2 { font-size: 1.15rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 1rem 0 .5rem; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

/* Layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--green-dark); color: #fff; padding: 1rem .75rem; display: flex; flex-direction: column; gap: .25rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; padding: .25rem .5rem 1rem; }
.brand .logo { width: 38px; height: 38px; border-radius: 50%; background: var(--sun); color: var(--green-dark); display: grid; place-items: center; font-weight: 900; font-size: .8rem; }
.brand b { display: block; line-height: 1.1; }
.brand small { opacity: .75; }
.nav a { display: flex; align-items: center; gap: .6rem; font-size: .95rem; color: #fff; text-decoration: none; padding: .5rem .7rem; border-radius: 8px; opacity: .9; }
.nav a:hover { background: rgba(255,255,255,.08); }
.nav a.active { background: var(--sun); color: var(--green-dark); opacity: 1; font-weight: 600; }
.sidebar .spacer { flex: 1; }
.sidebar .user { font-size: .85rem; opacity: .85; padding: .5rem .7rem; border-top: 1px solid rgba(255,255,255,.15); }
.sidebar .user button { margin-top: .4rem; }
.main { padding: 1.5rem 2rem 3rem; min-width: 0; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.toolbar { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.menu-toggle { display: none; }

@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; z-index: 1500; inset: 0 30% 0 0; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; }
  .main { padding: 1rem; }
  .menu-toggle { display: inline-flex; position: sticky; top: .5rem; z-index: 1000; margin-bottom: .5rem; }
}

/* Komponenten */
.card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem; box-shadow: var(--shadow); }
.grid { display: grid; gap: 1rem; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.stat { font-size: 2rem; font-weight: 800; line-height: 1.1; color: var(--green-dark); }
.stat small { font-size: 1rem; color: var(--muted); font-weight: 500; }
.kpi-label { color: var(--muted); font-size: .85rem; }

button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--text); padding: .45rem .85rem; border-radius: 8px; display: inline-flex; align-items: center; gap: .35rem; text-decoration: none; white-space: nowrap; }
button:hover, .btn:hover { border-color: var(--green); }
.btn-primary { background: var(--green-dark); border-color: var(--green-dark); color: #fff; font-weight: 600; }
.btn-primary:hover { background: var(--green); border-color: var(--green); color: var(--green-dark); }
.btn-danger { color: var(--red); }
.btn-danger:hover { border-color: var(--red); }
.btn-sm { padding: .2rem .55rem; font-size: .85rem; }
.btn-ghost { background: transparent; border-color: transparent; }
button:disabled { opacity: .5; cursor: not-allowed; }

input, select, textarea { font: inherit; color: var(--text); background: var(--card); border: 1px solid var(--border); border-radius: 8px; padding: .45rem .6rem; width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--green); outline-offset: -1px; }
input[type=checkbox] { width: auto; }
textarea { resize: vertical; }
label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .2rem; }
.field { margin-bottom: .75rem; }
.field.check label { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .95rem; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); column-gap: .9rem; }
.form-grid .full { grid-column: 1 / -1; }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
tr.clickable { cursor: pointer; }
tr.clickable:hover td { background: var(--green-light); }
.table-wrap { overflow-x: auto; }

.badge { display: inline-block; padding: .1rem .5rem; border-radius: 99px; font-size: .78rem; font-weight: 600; background: var(--green-light); color: var(--green-dark); white-space: nowrap; }
@media (prefers-color-scheme: dark) { .badge { color: #bfe3b0; } }
.badge.gray { background: rgba(120,120,120,.15); color: var(--muted); }
.badge.red { background: rgba(198,40,40,.12); color: var(--red); }
.badge.amber { background: rgba(230,149,0,.15); color: #a86d00; }
.badge.blue { background: rgba(37,99,168,.12); color: var(--blue); }
.badge.magenta { background: rgba(230,0,126,.12); color: var(--magenta); }

.tabs { display: flex; gap: .25rem; border-bottom: 1px solid var(--border); margin-bottom: 1rem; flex-wrap: wrap; }
.tabs button { border: none; border-bottom: 3px solid transparent; border-radius: 0; background: none; padding: .5rem .8rem; color: var(--muted); }
.tabs button.active { border-bottom-color: var(--green); color: var(--text); font-weight: 600; }

.empty { text-align: center; padding: 2rem; color: var(--muted); }
.bar { height: 8px; background: var(--border); border-radius: 99px; overflow: hidden; }
.bar > span { display: block; height: 100%; background: var(--green); }

/* Toast & Modal */
#toast { position: fixed; bottom: 1.25rem; right: 1.25rem; z-index: 3000; display: flex; flex-direction: column; gap: .5rem; }
#toast div { background: var(--green-dark); color: #fff; padding: .6rem 1rem; border-radius: 8px; box-shadow: var(--shadow); max-width: 360px; }
#toast div.error { background: var(--red); }
.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000; display: grid; place-items: center; padding: 1rem; }
.modal { background: var(--card); border-radius: 12px; width: min(720px, 100%); max-height: 92vh; overflow: auto; padding: 1.25rem 1.4rem; }
.modal.wide { width: min(1100px, 100%); }
.modal-actions { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; background: var(--green-dark); padding: 1rem; }
.login .card { width: min(380px, 100%); }
.login .logo { width: 64px; height: 64px; border-radius: 50%; background: var(--sun); color: var(--green-dark); display: grid; place-items: center; font-weight: 900; margin: 0 auto .75rem; }

/* Cockpit */
.countdown { background: var(--green-dark); color: #fff; border: none; }
.countdown .stat { color: var(--sun); font-size: 3rem; }
.deadline { display: flex; gap: .75rem; align-items: center; padding: .45rem 0; border-bottom: 1px dashed var(--border); }
.deadline:last-child { border-bottom: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--green); }
.dot.past { background: var(--border); }
.dot.soon { background: var(--red); }
.dot.mid { background: var(--amber); }
.deadline .date { width: 6.5rem; flex: none; font-variant-numeric: tabular-nums; color: var(--muted); font-size: .9rem; }
.deadline .rel { margin-left: auto; font-size: .85rem; color: var(--muted); white-space: nowrap; }

/* Listenaufstellung */
.list-layout { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .list-layout { grid-template-columns: 1fr; } }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .45rem; }
@media (max-width: 600px) { .slots { grid-template-columns: 1fr; } }
.slot { display: flex; align-items: center; gap: .6rem; border: 2px dashed var(--border); border-radius: 10px; padding: .4rem .55rem; min-height: 52px; background: var(--card); }
.slot.filled { border-style: solid; }
.slot.over, .pool.over { border-color: var(--green); background: var(--green-light); }
.slot.bad { border-color: var(--red); }
.slot .pos { font-weight: 800; font-size: 1.15rem; width: 2rem; text-align: center; color: var(--green-dark); flex: none; }
.slot .who { flex: 1; min-width: 0; }
.slot .who b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot .hint { font-size: .75rem; color: var(--muted); }
.person { cursor: grab; }
.person:active { cursor: grabbing; }
.pool { display: flex; flex-direction: column; gap: .4rem; min-height: 120px; border: 2px dashed transparent; border-radius: 10px; padding: .25rem; }
.pool-item { display: flex; align-items: center; gap: .5rem; border: 1px solid var(--border); border-radius: 8px; padding: .4rem .6rem; background: var(--card); }
.g { display: inline-grid; place-items: center; width: 1.3rem; height: 1.3rem; border-radius: 50%; font-size: .72rem; font-weight: 700; color: #fff; vertical-align: 1px; text-transform: uppercase; }
.g-w { background: var(--magenta); }
.g-m { background: var(--blue); }
.g-d { background: var(--amber); }
.warn-list { list-style: none; padding: 0; margin: 0; font-size: .9rem; }
.warn-list li { padding: .3rem 0 .3rem 1.4rem; position: relative; }
.warn-list li::before { content: ""; position: absolute; left: .2rem; top: .75rem; width: 9px; height: 9px; border-radius: 50%; }
.warn-list li.error::before { background: var(--red); }
.warn-list li.warn::before { background: var(--amber); }
.warn-list li.info::before { background: var(--blue); }
.minibars { display: flex; gap: .5rem; align-items: flex-end; height: 70px; }
.minibars div { flex: 1; text-align: center; font-size: .72rem; color: var(--muted); display: flex; flex-direction: column; justify-content: flex-end; height: 100%; }
.minibars span { display: block; background: var(--green); border-radius: 4px 4px 0 0; min-height: 2px; }

/* Ideen */
.idea { display: flex; gap: .9rem; }
.vote { display: flex; flex-direction: column; align-items: center; min-width: 3rem; }
.vote button { padding: .25rem .5rem; }
.vote button.on { background: var(--green-dark); color: var(--sun); border-color: var(--green-dark); }
.idea .body { flex: 1; min-width: 0; }

/* Dokumente */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 1rem; }
@media (max-width: 1200px) { .editor-layout { grid-template-columns: 1fr; } }
.editor textarea { min-height: 60vh; font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .9rem; line-height: 1.55; }
.doc-preview { background: #fff; color: #111; border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem 2.2rem; min-height: 60vh; overflow: auto; }
.doc-preview table { border-collapse: collapse; margin: .75rem 0; }
.doc-preview th, .doc-preview td { border: 1px solid #bbb; padding: .3rem .5rem; color: #111; text-transform: none; letter-spacing: 0; font-size: .9rem; }
.comment { border-left: 3px solid var(--green); padding: .4rem .7rem; margin-bottom: .6rem; background: var(--green-light); border-radius: 0 8px 8px 0; }
.comment.resolved { opacity: .55; border-left-color: var(--border); }
.comment blockquote { margin: .2rem 0; font-style: italic; color: var(--muted); border-left: 2px solid var(--border); padding-left: .5rem; }
.timeline { list-style: none; padding: 0; margin: 0; font-size: .88rem; }
.timeline li { padding: .35rem 0; border-bottom: 1px dashed var(--border); }
.link-row { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; padding: .4rem 0; border-bottom: 1px dashed var(--border); }
.link-row code { font-size: .78rem; background: var(--green-light); padding: .1rem .35rem; border-radius: 4px; overflow-wrap: anywhere; }

/* Termine */
.event { display: grid; grid-template-columns: 4.5rem 1fr; gap: 1rem; }
.event .when { text-align: center; background: var(--green-light); border-radius: 8px; padding: .4rem; height: fit-content; }
.event .when b { display: block; font-size: 1.5rem; line-height: 1; color: var(--green-dark); }
.checklist label { color: var(--text); font-size: .92rem; display: flex; gap: .45rem; align-items: center; margin: .15rem 0; }
.checklist label.done span { text-decoration: line-through; color: var(--muted); }
.shift { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .3rem 0; }

/* Karten */
.map-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 1rem; }
@media (max-width: 1000px) { .map-layout { grid-template-columns: 1fr; } }
.map { height: calc(100vh - 170px); min-height: 420px; border-radius: var(--radius); border: 1px solid var(--border); z-index: 0; }
.map.crosshair { cursor: crosshair; }
.side-list { max-height: calc(100vh - 420px); overflow: auto; }
.legend { display: flex; flex-wrap: wrap; gap: .5rem .9rem; font-size: .85rem; }
.legend i { display: inline-block; width: 11px; height: 11px; border-radius: 50%; margin-right: .3rem; vertical-align: -1px; }
.leaflet-popup-content { min-width: 230px; }
.leaflet-popup-content .field { margin-bottom: .45rem; }
.leaflet-popup-content input, .leaflet-popup-content select { padding: .25rem .4rem; font-size: .85rem; }
.leaflet-popup-content, .leaflet-popup-content label { color: #333; }
.leaflet-popup-content input, .leaflet-popup-content select, .leaflet-popup-content textarea, .leaflet-popup-content button { background: #fff; color: #111; border-color: #ccc; }
.leaflet-popup-content .btn-primary { background: var(--green-dark); color: #fff; }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) a, :root:not([data-theme="light"]) .stat,
  :root:not([data-theme="light"]) .slot .pos, :root:not([data-theme="light"]) .event .when b { color: var(--green); }
}
