:root {
  --bg: #e7e5e4;
  --panel: #ffffff;
  --panel-2: #f0efed;
  --border: #d1cfcb;
  --text: #1c1917;
  --muted: #57534e;
  --muted-2: #78716c;
  --amber: #d97706;
  --amber-2: #b45309;
  --green: #059669;
  --red: #dc2626;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 980px; margin: 0 auto; padding: 32px 24px 64px; }

header h1 { font-size: 24px; font-weight: 700; margin: 0 0 4px; }
header .sub { color: var(--muted-2); font-size: 14px; margin: 0 0 24px; }

#tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  background: none; border: none; color: var(--muted);
  padding: 10px 16px; font-size: 14px; font-weight: 500; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.tab.active { color: var(--amber); border-bottom-color: var(--amber); }
.tab:hover:not(.active) { color: var(--text); }

button { font-family: inherit; }
input, textarea {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 12px; font-size: 14px; font-family: inherit;
}
input:focus, textarea:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 2px rgba(251,191,36,.25); }

.btn-primary {
  background: var(--amber); color: #1c1917; border: none; border-radius: 6px;
  padding: 8px 14px; font-weight: 600; font-size: 14px; cursor: pointer;
}
.btn-primary:hover { background: var(--amber-2); }
.btn-secondary {
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border); border-radius: 6px;
  padding: 8px 14px; font-size: 14px; cursor: pointer;
}
.btn-secondary:hover { border-color: var(--muted); }
.icon-btn {
  background: none; border: none; color: var(--muted-2); cursor: pointer;
  width: 30px; height: 30px; border-radius: 6px; display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { color: var(--amber); background: var(--panel-2); }
.icon-btn.danger:hover { color: var(--red); background: #2a1414; }

.row { display: flex; gap: 8px; align-items: center; }

.card-list { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.card-list .item {
  display: flex; align-items: center; gap: 12px; padding: 10px 14px;
  border-top: 1px solid var(--border); background: var(--panel);
}
.card-list .item:first-child { border-top: none; }
.item-thumb {
  width: 40px; height: 40px; border-radius: 6px; object-fit: cover; background: var(--panel-2); flex-shrink: 0;
}
.item-thumb.placeholder { display: flex; align-items: center; justify-content: center; color: var(--muted-2); font-size: 11px; }
.item-body { flex: 1; min-width: 0; }
.item-name { font-weight: 500; }
.item-note { color: var(--muted-2); font-size: 13px; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.empty { color: var(--muted-2); font-size: 14px; }

.edit-form {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px; background: var(--panel);
  display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px;
}
.edit-form label { font-size: 13px; color: var(--muted); }
.edit-form textarea { resize: vertical; min-height: 60px; }
.edit-form .actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.preview-img { max-width: 160px; max-height: 120px; border-radius: 6px; display: block; margin-top: 6px; }

.days-layout { display: flex; gap: 24px; }
.days-side { width: 220px; flex-shrink: 0; }
.day-item {
  width: 100%; text-align: left; background: none; border: none; color: var(--muted);
  padding: 8px 10px; border-radius: 6px; cursor: pointer; margin-bottom: 2px;
}
.day-item .d-label { font-weight: 500; color: var(--text); font-size: 14px; }
.day-item .d-date { font-size: 12px; color: var(--muted-2); }
.day-item.active { background: var(--panel-2); }
.day-item.active .d-label { color: var(--amber-2); }

.day-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.day-date-line { color: var(--muted-2); font-size: 13px; margin-bottom: 2px; }
.day-title-btn { background: none; border: none; color: var(--text); font-size: 20px; font-weight: 700; cursor: pointer; padding: 0; }
.day-title-btn:hover { color: var(--amber-2); }

.toggle-matrix { background: none; border: none; color: var(--muted); font-size: 13px; cursor: pointer; padding: 6px 0; margin: 8px 0 14px; }
.toggle-matrix:hover { color: var(--amber-2); }

table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td { padding: 8px 10px; text-align: center; white-space: nowrap; }
th { color: var(--muted-2); font-weight: 500; text-align: center; }
th:first-child, td:first-child { text-align: left; }
tbody tr { border-top: 1px solid var(--border); }
.matrix-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; margin-bottom: 20px; background: var(--panel); }
.matrix-wrap .mx-head { display: flex; justify-content: space-between; align-items: center; padding: 8px 14px; border-bottom: 1px solid var(--border); background: var(--panel-2); font-size: 13px; }
.results-wrap { border: 1px solid var(--border); border-radius: 10px; overflow: auto; }

.chk {
  width: 24px; height: 24px; border-radius: 5px; border: 1px solid var(--border);
  background: none; cursor: pointer; color: transparent; display: inline-flex; align-items: center; justify-content: center;
}
.chk.on { background: var(--amber); border-color: var(--amber); color: #1c1917; }
.chk.result.on { background: var(--green); border-color: var(--green); }
.chk:hover:not(.on) { border-color: var(--muted); }

.num-input {
  width: 60px; text-align: center; padding: 5px 6px; border-radius: 5px;
}

.cell-pair { display: inline-flex; align-items: center; gap: 6px; }
.dash { color: #a8a29e; }

.kategorie-gruppe { margin-bottom: 18px; }
.kategorie-titel { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--muted-2); margin: 0 0 6px 2px; }

.vorgabe-label { font-size: 11px; color: var(--muted-2); margin-bottom: 3px; white-space: nowrap; }

.kat-head { background: var(--panel-2); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
.kategorie-row td { background: var(--panel-2); font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); text-align: left; padding: 6px 10px; }
.th-sub { font-weight: 400; color: var(--muted-2); font-size: 11px; }

.mx-foot { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-top: 1px solid var(--border); background: var(--panel-2); }

/* Sticky Tabellenkopf + erste Spalte */
.sticky-table-wrap { max-height: 62vh; overflow: auto; }
.sticky-table-wrap table thead tr:first-child th {
  position: sticky; top: 0; z-index: 3; background: var(--panel-2);
}
.sticky-table-wrap table thead tr:nth-child(2) th {
  position: sticky; top: 35px; z-index: 3; background: var(--panel-2);
}
.sticky-table-wrap table thead tr:first-child th[rowspan] { z-index: 4; }
.sticky-table-wrap table tbody td:first-child {
  position: sticky; left: 0; z-index: 2; background: var(--panel);
}
.sticky-table-wrap table thead th:first-child {
  position: sticky; left: 0; z-index: 5; background: var(--panel-2);
}
.sticky-table-wrap table tbody tr.kategorie-row td:first-child { position: static; }

/* Fokus-Modus: Kopfzeile/Navigation aus, kompakte Terminauswahl, mehr Platz für Tabelle */
body.focus-mode header,
body.focus-mode #tabs {
  display: none;
}
body.focus-mode .sticky-table-wrap { max-height: 82vh; }

.focus-bar {
  display: flex; align-items: center; gap: 8px; margin-bottom: 12px;
  padding: 8px 10px; background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
}
.focus-bar select { flex: 1; min-width: 0; }
.days-layout.focus { flex-direction: column; }

select {
  background: var(--panel); border: 1px solid var(--border); border-radius: 6px;
  color: var(--text); padding: 8px 10px; font-size: 14px; font-family: inherit;
}
select:focus { outline: none; border-color: var(--amber); box-shadow: 0 0 0 2px rgba(217,119,6,.25); }
