:root {
  --bg: #f6f3ee;
  --panel: #ffffff;
  --ink: #1f1a14;
  --ink-2: #5d554b;
  --ink-3: #8f867a;
  --line: #e6e0d6;
  --line-2: #d6cec1;
  --accent: #c48a1f;
  --accent-ink: #1f1a14;
  --accent-soft: #fbf1dc;
  --side: #1f1a14;
  --side-ink: #e9e2d6;
  --ok: #2f7d4f;
  --ok-soft: #e3f3e8;
  --warn: #b7791f;
  --warn-soft: #fdf2dc;
  --bad: #b23a3a;
  --bad-soft: #fbe6e4;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(31, 26, 20, .06), 0 4px 16px rgba(31, 26, 20, .06);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  color: var(--ink);
  background: var(--bg);
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.5rem; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; margin: 0 0 .75rem; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--ink-2); }
.muted { color: var(--ink-3); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- Layout ---------- */
.layout { display: grid; grid-template-columns: 228px 1fr; min-height: 100vh; }
.sidebar { background: var(--side); color: var(--side-ink); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; font-weight: 700; font-size: 1.05rem; color: #fff; }
.brand .logo { width: 30px; height: 30px; border-radius: 8px; background: var(--accent); display: grid; place-items: center; color: var(--side); flex: none; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 8px; color: var(--side-ink); font-size: .95rem; }
.nav a:hover { background: rgba(255,255,255,.07); text-decoration: none; }
.nav a.active { background: rgba(217, 164, 65, .18); color: #fff; }
.nav a svg { width: 18px; height: 18px; opacity: .85; flex: none; }
.nav .sep { height: 1px; background: rgba(255,255,255,.1); margin: 10px 8px; }
.side-foot { margin-top: auto; padding: 10px 12px; font-size: .85rem; color: #b8ae9f; }
.side-foot b { color: #fff; font-weight: 600; display: block; }
.main { padding: 26px 32px 60px; min-width: 0; }
.topbar { display: none; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .spacer { flex: 1; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
  .layout.menu-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); }
  .topbar { display: flex; align-items: center; gap: 10px; background: var(--side); color: #fff; padding: 10px 14px; position: sticky; top: 0; z-index: 40; }
  .topbar button { background: none; border: 0; color: #fff; padding: 4px; display: grid; }
  .topbar button svg { width: 24px; height: 24px; }
  .main { padding: 16px 14px 60px; }
}

/* ---------- Komponenten ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.card + .card { margin-top: 16px; }
.grid > .card { margin-top: 0; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.grid-3 { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn { appearance: none; border: 1px solid var(--line-2); background: var(--panel); color: var(--ink); border-radius: 8px; padding: 8px 14px; font: inherit; font-size: .92rem; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; line-height: 1.2; }
.btn:hover { border-color: var(--ink-3); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.primary:hover { filter: brightness(1.05); }
.btn.danger { color: var(--bad); border-color: #e8c2be; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(0,0,0,.05); }
.btn.sm { padding: 5px 10px; font-size: .85rem; }
.btn.ok { color: var(--ok); border-color: #b9dcc6; }
.btn.ok.on { background: var(--ok); color: #fff; border-color: var(--ok); }
.btn.bad.on { background: var(--bad); color: #fff; border-color: var(--bad); }
.btn.bad { color: var(--bad); border-color: #e8c2be; }
.btn[disabled] { opacity: .5; cursor: default; }
.btn svg { width: 16px; height: 16px; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: .78rem; font-weight: 600; white-space: nowrap; }
.st-anfrage { background: var(--warn-soft); color: var(--warn); }
.st-bestaetigt { background: var(--ok-soft); color: var(--ok); }
.st-storniert { background: var(--bad-soft); color: var(--bad); }
.r-zugesagt { color: var(--ok); }
.r-abgesagt { color: var(--bad); }
.r-offen { color: var(--ink-3); }
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; background: #efe9df; color: var(--ink-2); font-size: .78rem; }

/* Formulare */
label.f { display: flex; flex-direction: column; gap: 5px; font-size: .82rem; color: var(--ink-2); font-weight: 600; min-width: 0; }
input, select, textarea { font: inherit; font-size: .95rem; color: var(--ink); background: #fff; border: 1px solid var(--line-2); border-radius: 8px; padding: 8px 10px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: 2px solid rgba(196,138,31,.35); border-color: var(--accent); }
input[type=checkbox] { width: auto; accent-color: var(--accent); }
textarea { min-height: 70px; resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px 14px; }
.form-grid .span-2 { grid-column: span 2; }
.form-grid .span-all { grid-column: 1 / -1; }
@media (max-width: 560px) { .form-grid .span-2 { grid-column: 1 / -1; } }
.inline-add { display: flex; gap: 6px; }
.inline-add select { flex: 1; }
.search { max-width: 280px; }

/* Tabellen */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.t th { text-align: left; font-size: .76rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.t th.sortable { cursor: pointer; user-select: none; }
table.t th.sortable:hover { color: var(--ink); }
table.t td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t tr.click { cursor: pointer; }
table.t tr.click:hover td { background: #faf7f2; }
table.t tfoot td { font-weight: 700; border-top: 2px solid var(--line-2); border-bottom: 0; }
table.t tr.cancelled td { color: var(--ink-3); text-decoration: line-through; }
table.t tr.cancelled td .badge { text-decoration: none; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 14px; flex-wrap: wrap; }
.tabs button { background: none; border: 0; padding: 9px 14px; font: inherit; color: var(--ink-2); cursor: pointer; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.active { color: var(--ink); border-color: var(--accent); font-weight: 600; }
.tabs .count { color: var(--ink-3); font-size: .8rem; margin-left: 4px; }

/* Sterne */
.stars { display: inline-flex; gap: 1px; }
.stars button { background: none; border: 0; padding: 0 1px; cursor: pointer; color: #ddd3c2; font-size: 1.05rem; line-height: 1; }
.stars button.on { color: var(--accent); }
.stars.readonly button { cursor: default; }

/* Definitionen */
dl.kv { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; font-size: .93rem; }
dl.kv dt { color: var(--ink-3); }
dl.kv dd { margin: 0; }

/* Event-Tage im Formular */
.day-row { display: grid; grid-template-columns: 160px repeat(3, minmax(150px, 1fr)) minmax(140px, 1.2fr) auto; gap: 10px; align-items: end; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fcfaf7; }
.day-row + .day-row { margin-top: 8px; }
.timepair { display: flex; align-items: center; gap: 4px; }
.timepair input { padding: 7px 6px; text-align: center; font-variant-numeric: tabular-nums; }
@media (max-width: 1150px) { .day-row { grid-template-columns: 1fr 1fr; } .day-row .del { justify-self: end; } }
@media (max-width: 560px) { .day-row { grid-template-columns: 1fr; } }

.musician-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 8px; }
.musician { display: grid; grid-template-columns: auto 1fr; gap: 6px 10px; align-items: center; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; }
.musician.sel { border-color: var(--accent); background: var(--accent-soft); }
.musician .extra { grid-column: 2; display: flex; gap: 6px; }
.musician .extra select, .musician .extra input { padding: 5px 8px; font-size: .88rem; }

.fin-box { display: grid; grid-template-columns: 1fr auto; gap: 4px 20px; font-variant-numeric: tabular-nums; font-size: .95rem; }
.fin-box .total { font-weight: 700; border-top: 1px solid var(--line-2); padding-top: 6px; margin-top: 4px; }
.fin-box .neg { color: var(--bad); }
.fin-box .pos { color: var(--ok); }
.section-title { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; }
.section-title .lock { font-size: .72rem; background: #2b241b; color: #f1d9a6; padding: 2px 7px; border-radius: 5px; font-weight: 600; }

.doc-list { list-style: none; margin: 0; padding: 0; }
.doc-list li { display: flex; align-items: center; gap: 10px; padding: 7px 0; border-bottom: 1px dashed var(--line); }
.doc-list li:last-child { border-bottom: 0; }
.doc-kind { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 12px; }
.doc-kind > div { border: 1px solid var(--line); border-radius: 8px; padding: 12px; }
.dropzone { display: block; border: 2px dashed var(--line-2); border-radius: 8px; padding: 10px; text-align: center; color: var(--ink-3); font-size: .85rem; cursor: pointer; margin-top: 8px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* Kalender */
#calendar { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow); }
.fc { --fc-border-color: var(--line); --fc-today-bg-color: #fbf1dc80; --fc-button-bg-color: #fff; --fc-button-text-color: var(--ink); --fc-button-border-color: var(--line-2); --fc-button-hover-bg-color: #f3eee6; --fc-button-hover-border-color: var(--ink-3); --fc-button-active-bg-color: var(--accent); --fc-button-active-border-color: var(--accent); }
.fc .fc-button-primary:not(:disabled).fc-button-active { color: #fff; }
.fc .fc-toolbar-title { font-size: 1.2rem; }
.fc .fc-button { font-size: .85rem; padding: 5px 10px; }
.fc-event { cursor: pointer; }
.fc .ev-anfrage { --fc-event-bg-color: #f0c069; --fc-event-border-color: #e0a93f; --fc-event-text-color: #3b2a07; }
.fc .ev-bestaetigt { --fc-event-bg-color: #3f8f5f; --fc-event-border-color: #2f7d4f; --fc-event-text-color: #fff; }
.fc .ev-storniert { --fc-event-bg-color: #e8d9d7; --fc-event-border-color: #d9c0bd; --fc-event-text-color: #8a4a45; text-decoration: line-through; }
.fc .fc-daygrid-dot-event.ev-anfrage .fc-daygrid-event-dot { border-color: #e0a93f; }
.fc .fc-daygrid-dot-event.ev-bestaetigt .fc-daygrid-event-dot { border-color: #2f7d4f; }
.fc .fc-daygrid-dot-event.ev-storniert .fc-daygrid-event-dot { border-color: #c98e88; }
.legend { display: flex; gap: 14px; font-size: .85rem; color: var(--ink-2); align-items: center; flex-wrap: wrap; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Setlist-Editor */
.setlist-editor { display: grid; grid-template-columns: minmax(280px, 1fr) minmax(320px, 1.2fr); gap: 16px; align-items: start; }
@media (max-width: 900px) { .setlist-editor { grid-template-columns: 1fr; } }
.song-pool, .set-items { list-style: none; margin: 0; padding: 0; min-height: 80px; }
.song-pool { max-height: 62vh; overflow-y: auto; }
.song-item { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; margin-bottom: 6px; cursor: grab; user-select: none; }
.song-item .grip { color: var(--ink-3); cursor: grab; flex: none; }
.song-item .t { flex: 1; min-width: 0; }
.song-item .t b { font-weight: 600; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song-item .t span { font-size: .8rem; color: var(--ink-3); }
.song-item .meta { font-size: .8rem; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.song-item .idx { width: 24px; text-align: right; color: var(--ink-3); font-variant-numeric: tabular-nums; flex: none; }
.song-item.break { background: #2b241b; color: #f1d9a6; border-color: #2b241b; }
.song-item.break .t span, .song-item.break .meta, .song-item.break .grip { color: #c9b896; }
.song-item.break input { background: transparent; border: 0; color: #f1d9a6; font-weight: 600; padding: 0; }
.song-item.in-set { opacity: .45; }
.sortable-ghost { opacity: .35; }
.sortable-chosen { box-shadow: var(--shadow); }
.set-items:empty::after { content: "Songs hierher ziehen"; display: block; text-align: center; color: var(--ink-3); padding: 30px; border: 2px dashed var(--line-2); border-radius: 8px; }
.set-summary { font-size: .85rem; color: var(--ink-2); }

/* Modal */
.modal-back { position: fixed; inset: 0; background: rgba(31,26,20,.45); display: grid; place-items: start center; padding: 6vh 14px; z-index: 100; overflow-y: auto; }
.modal { background: var(--panel); border-radius: 12px; width: 100%; max-width: 640px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { max-width: 860px; }
.modal header { padding: 16px 20px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal header h2 { margin: 0; flex: 1; }
.modal .body { padding: 18px 20px; }
.modal footer { padding: 14px 20px; border-top: 1px solid var(--line); display: flex; gap: 8px; justify-content: flex-end; }
.modal footer .left { margin-right: auto; }

/* Toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 8px; box-shadow: var(--shadow); font-size: .92rem; max-width: 380px; }
.toast.err { background: var(--bad); }

/* Login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; background: var(--side); padding: 20px; }
.login { width: 100%; max-width: 360px; background: var(--panel); border-radius: 14px; padding: 30px; box-shadow: 0 20px 60px rgba(0,0,0,.35); }
.login .brand { color: var(--ink); padding: 0 0 20px; font-size: 1.2rem; }
.login form { display: grid; gap: 14px; }
.err-msg { color: var(--bad); font-size: .9rem; min-height: 1.2em; }

.empty { text-align: center; padding: 36px 10px; color: var(--ink-3); }
.event-list .ev { display: grid; grid-template-columns: 68px 1fr auto; gap: 14px; align-items: center; padding: 12px 6px; border-bottom: 1px solid var(--line); cursor: pointer; }
.event-list .ev:hover { background: #faf7f2; }
.event-list .ev:last-child { border-bottom: 0; }
.datebox { text-align: center; border: 1px solid var(--line); border-radius: 8px; padding: 4px 0; background: #fff; }
.datebox .m { font-size: .7rem; text-transform: uppercase; color: var(--accent); font-weight: 700; letter-spacing: .05em; }
.datebox .d { font-size: 1.35rem; font-weight: 700; line-height: 1.1; }
.datebox .w { font-size: .7rem; color: var(--ink-3); }
.ev .title { font-weight: 600; }
.ev .sub { font-size: .85rem; color: var(--ink-3); margin-top: 2px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.kpi .l { font-size: .78rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .04em; }
.kpi .v { font-size: 1.35rem; font-weight: 700; margin-top: 4px; font-variant-numeric: tabular-nums; }
.flag { display: inline-block; min-width: 22px; text-align: center; font-size: .78rem; border-radius: 4px; padding: 1px 4px; background: #efe9df; color: var(--ink-3); }
.flag.on { background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: ui-monospace, Menlo, monospace; font-size: .82rem; }

/* Druckansicht Setliste */
#print-root { display: none; }
@media print {
  body > *:not(#print-root) { display: none !important; }
  #print-root { display: block; font-family: Arial, Helvetica, sans-serif; color: #000; }
  #print-root h1 { font-size: 22pt; margin: 0 0 4pt; }
  #print-root .sub { font-size: 11pt; margin-bottom: 12pt; color: #333; }
  #print-root ol { margin: 0; padding: 0; list-style: none; counter-reset: s; }
  #print-root li { font-size: 20pt; font-weight: 700; padding: 3pt 0; border-bottom: 1px solid #ccc; display: flex; gap: 12pt; break-inside: avoid; }
  #print-root li .n { width: 32pt; text-align: right; color: #666; }
  #print-root li .k { margin-left: auto; font-size: 13pt; font-weight: 400; color: #333; }
  #print-root li.break { font-size: 14pt; background: #eee; justify-content: center; text-transform: uppercase; letter-spacing: 2pt; border: 0; margin: 8pt 0; }
  #print-root.compact li { font-size: 13pt; }
}

.daylist .day { display: grid; grid-template-columns: 150px repeat(3, minmax(0, 1fr)); gap: 4px 14px; padding: 10px 0; border-bottom: 1px solid var(--line); align-items: baseline; }
.daylist .day:last-child { border-bottom: 0; }
.daylist .lbl { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); }
@media (max-width: 640px) { .daylist .day { grid-template-columns: 1fr 1fr 1fr; } .daylist .day > :first-child { grid-column: 1 / -1; } }
.check-line { display: flex; gap: 8px; align-items: flex-start; }
.check-line input { margin-top: 3px; }
