/* Raumplanung - ruhiges, schlichtes Layout.
   Die Farbwerte hier sind nur die Voreinstellung; die Verwaltung kann sie
   unter "Darstellung" überschreiben (siehe app/theme.py). */

:root {
  --bg: #f8f8f9;
  --card: #ffffff;
  --text: #101013;
  --muted: #6b7280;
  --muted-2: #9ca3af;
  --border: #e5e7eb;
  --border-soft: #f1f2f4;
  --accent: #101013;
  --accent-hover: #000000;
  --accent-text: #ffffff;
  --accent-soft: #eeeef0;
  --ok: #047857;
  --ok-bg: #ecfdf5;
  --warn: #b45309;
  --warn-bg: #fffbeb;
  --err: #b91c1c;
  --err-bg: #fef2f2;
  --radius: 10px;
  --radius-sm: 7px;
  --shadow: 0 1px 2px rgba(16, 16, 19, .04), 0 1px 3px rgba(16, 16, 19, .06);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 28%, transparent);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: inherit; text-decoration: none; }

h1 { font-size: 20px; font-weight: 650; letter-spacing: -.015em; margin: 0; }
h2 { font-size: 15px; font-weight: 600; margin: 0 0 12px; letter-spacing: -.005em; }
h3 { font-size: 12px; font-weight: 600; margin: 0 0 8px; color: var(--muted);
     text-transform: uppercase; letter-spacing: .05em; }

.muted { color: var(--muted); }
.small { font-size: 12px; }
.mono { font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: var(--radius-sm); }

/* ------------------------------------------------------------- Kopfzeile */

.topbar {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 22px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-weight: 650;
  font-size: 14px;
  white-space: nowrap;
  letter-spacing: -.01em;
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-text);
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 700;
  flex: none;
}

.nav { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }

.nav a {
  padding: 7px 11px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  white-space: nowrap;
  transition: background .12s ease, color .12s ease;
}

.nav a:hover { background: var(--border-soft); color: var(--text); }
.nav a.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
.nav svg { width: 15px; height: 15px; flex: none; opacity: .75; }
.nav a.active svg { opacity: 1; }

.badge-count {
  background: var(--accent);
  color: var(--accent-text);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  padding: 1px 6px;
  font-variant-numeric: tabular-nums;
}

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

.who { text-align: right; line-height: 1.25; }
.who .name { font-weight: 550; font-size: 13px; }
.who .role { font-size: 11px; color: var(--muted-2); }

/* ------------------------------------------------------------- Grundraster */

.page { max-width: 1280px; margin: 0 auto; padding: 26px 20px 80px; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; max-width: 62ch; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 18px 20px; }
.card + .card { margin-top: 16px; }

.grid-2 { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.spacer { flex: 1; }

/* ------------------------------------------------------------- Bedienelemente */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-weight: 550;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  transition: background .12s ease, border-color .12s ease, transform .06s ease;
}

.btn svg { width: 15px; height: 15px; flex: none; }
.btn:hover { background: var(--border-soft); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-danger { color: var(--err); border-color: color-mix(in srgb, var(--err) 30%, var(--border)); }
.btn-danger:hover { background: var(--err-bg); }
.btn-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 30%, var(--border)); }
.btn-ok:hover { background: var(--ok-bg); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 7px 9px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }

.field { display: block; margin-bottom: 15px; }
.field > label, label.lbl {
  display: block;
  font-size: 12px;
  font-weight: 550;
  color: var(--muted);
  margin-bottom: 6px;
}

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], select, textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 13px;
  transition: border-color .12s ease, box-shadow .12s ease;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: var(--ring);
}

textarea { resize: vertical; min-height: 68px; }
.hint { font-size: 11.5px; color: var(--muted-2); margin-top: 5px; line-height: 1.45; }

.inline-fields { display: flex; gap: 12px; flex-wrap: wrap; }
.inline-fields > * { flex: 1 1 140px; min-width: 0; }

.check { display: flex; align-items: center; gap: 8px; font-size: 13px; cursor: pointer; }
.check input { width: auto; accent-color: var(--accent); }

input[type="color"] {
  width: 100%;
  height: 42px;
  padding: 3px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--card);
  cursor: pointer;
}

/* ------------------------------------------------------------- Status */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  font-weight: 550;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--border-soft);
  color: var(--muted);
  white-space: nowrap;
}

.pill-dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; flex: none; }
.pill.pending { background: var(--warn-bg); color: var(--warn);
  border-color: color-mix(in srgb, var(--warn) 26%, transparent); }
.pill.approved { background: var(--ok-bg); color: var(--ok);
  border-color: color-mix(in srgb, var(--ok) 26%, transparent); }
.pill.rejected { background: var(--err-bg); color: var(--err);
  border-color: color-mix(in srgb, var(--err) 26%, transparent); }
.pill.cancelled { background: var(--border-soft); color: var(--muted); }
.pill.series { background: var(--accent-soft); color: var(--text);
  border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

.notice {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  font-size: 13px;
  display: flex;
  gap: 9px;
  align-items: flex-start;
  line-height: 1.5;
}

.notice.ok { background: var(--ok-bg); border-color: color-mix(in srgb, var(--ok) 26%, transparent);
  color: color-mix(in srgb, var(--ok) 80%, var(--text)); }
.notice.warn { background: var(--warn-bg); border-color: color-mix(in srgb, var(--warn) 26%, transparent);
  color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.notice.error { background: var(--err-bg); border-color: color-mix(in srgb, var(--err) 26%, transparent);
  color: color-mix(in srgb, var(--err) 80%, var(--text)); }
.flashes { display: flex; flex-direction: column; gap: 8px; margin-bottom: 18px; }

/* ------------------------------------------------------------- Wochenkalender */

.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.week-title { font-size: 15px; font-weight: 650; min-width: 200px; letter-spacing: -.01em; }
h1.week-title { font-size: 15px; }

.stepper { display: flex; }
.stepper .btn { border-radius: 0; margin-left: -1px; }
.stepper .btn:first-child { border-radius: var(--radius-sm) 0 0 var(--radius-sm); margin-left: 0; }
.stepper .btn:last-child { border-radius: 0 var(--radius-sm) var(--radius-sm) 0; }

.week {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.week-head { display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  border-bottom: 1px solid var(--border); }
.week-head > div { padding: 9px 8px; text-align: center; border-left: 1px solid var(--border-soft); }
.week-head > div:first-child { border-left: 0; }
.week-head .dow { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.week-head .dnum { font-size: 15px; font-weight: 650; font-variant-numeric: tabular-nums; margin-top: 1px; }
.week-head .weekend { background: color-mix(in srgb, var(--text) 3%, var(--card)); }
.week-head .weekend .dnum { color: var(--muted); }
/* Muss nach der Wochenend-Regel stehen: gleiche Spezifität, und die Markierung
   für heute soll auch am Samstag und Sonntag gewinnen. */
.week-head .today .dnum {
  display: inline-grid; place-items: center; width: 27px; height: 27px;
  border-radius: 999px; background: var(--accent); color: var(--accent-text);
}

.week-body { display: grid; grid-template-columns: 54px repeat(7, minmax(0, 1fr));
  position: relative; height: 720px; }

.gutter { position: relative; }
.gutter .tick { position: absolute; right: 8px; transform: translateY(-50%);
  font-size: 11px; color: var(--muted-2); font-variant-numeric: tabular-nums; }

.daycol { position: relative; border-left: 1px solid var(--border-soft); }
.daycol.weekend { background: color-mix(in srgb, var(--text) 3%, var(--card)); }
.daycol.past { background: color-mix(in srgb, var(--text) 2%, var(--card)); }

.hourline { position: absolute; left: 0; right: 0; border-top: 1px solid var(--border-soft);
  pointer-events: none; }

.nowline { position: absolute; left: 0; right: 0; border-top: 2px solid var(--err);
  z-index: 4; pointer-events: none; }
.nowline::before { content: ""; position: absolute; left: -3px; top: -5px;
  width: 8px; height: 8px; border-radius: 999px; background: var(--err); }

.slotlink { position: absolute; left: 0; right: 0; z-index: 1; transition: background .1s ease; }
.slotlink:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.chip {
  position: absolute;
  z-index: 3;
  padding: 4px 7px 5px;
  border-radius: 7px;
  border: 1px solid;
  border-left-width: 3px;
  overflow: hidden;
  font-size: 11.5px;
  line-height: 1.3;
  min-height: 22px;
  cursor: pointer;
  transition: filter .12s ease;
}

.chip:hover { filter: brightness(.96); }
.chip .chip-time { font-variant-numeric: tabular-nums; opacity: .8; font-size: 10.5px; }
.chip .chip-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip .chip-room { font-size: 10.5px; opacity: .82; white-space: nowrap;
  overflow: hidden; text-overflow: ellipsis; }
.chip.is-pending { border-style: dashed; border-left-style: solid; }

.legend { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 12px; font-size: 12px; color: var(--muted); }
.legend .dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block;
  margin-right: 6px; vertical-align: -1px; }

/* --------------------------------------------- Tagesliste (Handy-Ansicht) */

.agenda { display: none; }

.agenda-day + .agenda-day { margin-top: 10px; }

.agenda-day-head {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 4px 6px;
  font-size: 13px; font-weight: 650;
  position: sticky; top: 58px; background: var(--bg); z-index: 5;
}
.agenda-day-head .num { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }
.agenda-day-head.is-today { color: var(--accent); }
.agenda-day-head.is-today .num { color: inherit; }

.agenda-item {
  display: flex; gap: 12px; align-items: flex-start;
  background: var(--card); border: 1px solid var(--border); border-left-width: 4px;
  border-radius: var(--radius-sm); padding: 11px 13px;
  box-shadow: var(--shadow);
}
.agenda-item + .agenda-item { margin-top: 7px; }
.agenda-item .when { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 13px;
  white-space: nowrap; min-width: 46px; }
.agenda-item .what { min-width: 0; flex: 1; }
.agenda-item .title { font-weight: 600; font-size: 14px; }
.agenda-item .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }

.agenda-empty { padding: 10px 4px 4px; font-size: 12.5px; color: var(--muted-2); }

.agenda-new {
  display: block; text-align: center; margin-top: 8px; padding: 11px;
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
  color: var(--muted); font-size: 13px; font-weight: 550;
}
.agenda-new:hover { background: var(--card); color: var(--text); }

/* ------------------------------------------------------------- Tabellen */

table.list { width: 100%; border-collapse: collapse; font-size: 13px; }
table.list th { text-align: left; font-size: 11px; text-transform: uppercase;
  letter-spacing: .05em; color: var(--muted-2); font-weight: 600;
  padding: 0 12px 8px; border-bottom: 1px solid var(--border); }
table.list td { padding: 11px 12px; border-bottom: 1px solid var(--border-soft); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list tbody tr:hover { background: color-mix(in srgb, var(--text) 2%, var(--card)); }
table.list td.right, table.list th.right { text-align: right; }
table.list .strong { font-weight: 600; }

.roomdot { width: 9px; height: 9px; border-radius: 3px; display: inline-block;
  margin-right: 7px; vertical-align: -1px; }

.empty { padding: 48px 20px; text-align: center; color: var(--muted); }
.empty .big { font-size: 15px; color: var(--text); font-weight: 600; margin-bottom: 4px; }

.tabs { display: flex; gap: 3px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: var(--radius-sm); font-size: 13px;
  color: var(--muted); font-weight: 550; transition: background .12s ease; }
.tabs a:hover { background: var(--border-soft); color: var(--text); }
.tabs a.active { background: var(--accent); color: var(--accent-text); }

/* ------------------------------------------------------------- Detailseite */

.kv { display: grid; grid-template-columns: 132px 1fr; gap: 10px 16px; font-size: 13px; }
.kv dt { color: var(--muted); font-size: 12px; padding-top: 1px; }
.kv dd { margin: 0; }

.timeline { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.timeline li { display: flex; gap: 10px; padding: 8px 0; border-bottom: 1px solid var(--border-soft); }
.timeline li:last-child { border-bottom: 0; }
.timeline .when { color: var(--muted-2); font-size: 12px; white-space: nowrap;
  font-variant-numeric: tabular-nums; min-width: 104px; }

.deadline-box { border: 1px solid color-mix(in srgb, var(--warn) 26%, transparent);
  background: var(--warn-bg); border-radius: var(--radius-sm); padding: 12px 14px;
  font-size: 13px; color: color-mix(in srgb, var(--warn) 80%, var(--text)); }
.deadline-box.expired { border-color: color-mix(in srgb, var(--err) 26%, transparent);
  background: var(--err-bg); color: color-mix(in srgb, var(--err) 80%, var(--text)); }
.deadline-box .big { font-weight: 650; font-size: 15px; margin-bottom: 2px; }

/* ------------------------------------------------------------- Darstellung */

.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(148px, 1fr)); gap: 10px; }

.swatch {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 0; overflow: hidden; cursor: pointer; background: none;
  font: inherit; text-align: left; transition: transform .08s ease, border-color .12s ease;
}
.swatch:hover { transform: translateY(-1px); border-color: var(--muted-2); }
.swatch .preview { height: 54px; display: flex; align-items: center; justify-content: center; gap: 6px; }
.swatch .preview i { display: block; width: 26px; height: 26px; border-radius: 7px; }
.swatch .name { padding: 7px 10px; font-size: 12px; font-weight: 550;
  border-top: 1px solid var(--border); background: var(--card); }

/* ------------------------------------------------------------- Login */

.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px; }
.auth-card { width: 100%; max-width: 380px; }
.auth-head { text-align: center; margin-bottom: 24px; }
.auth-head .brand-mark { width: 38px; height: 38px; font-size: 15px; margin: 0 auto 14px; }
.auth-head h1 { font-size: 19px; }
.auth-head p { color: var(--muted); font-size: 13px; margin: 6px 0 0; }

/* ------------------------------------------------------------- Schmale Fenster */

@media (max-width: 900px) {
  .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .nav a span.label { display: none; }
  .nav a { padding: 7px 9px; }
}

@media (max-width: 760px) {
  /* Sieben Spalten sind auf dem Handy unlesbar - stattdessen die Tagesliste. */
  .week, .legend { display: none; }
  .agenda { display: block; }
  .page { padding: 18px 14px 90px; }
  .page-head { margin-bottom: 16px; }
  .cal-toolbar { gap: 8px; }
  .week-title { min-width: 0; flex: 1; }
  .card-pad { padding: 15px 16px; }
  .kv { grid-template-columns: 1fr; gap: 3px 0; }
  .kv dt { margin-top: 8px; }
  .topbar-inner { padding: 0 14px; gap: 12px; height: 54px; }
  .who { display: none; }
  .timeline .when { min-width: 92px; }
  table.list th:nth-child(n+4), table.list td:nth-child(n+4) { display: none; }
}

@media (max-width: 520px) {
  .topbar-right .btn span.label { display: none; }
  .page-head h1 { font-size: 18px; }
}

/* Auf Geräten, die als App laufen, den unteren Rand freihalten. */
@media (display-mode: standalone) {
  .page { padding-bottom: calc(80px + env(safe-area-inset-bottom)); }
  .topbar { padding-top: env(safe-area-inset-top); }
}

@media print {
  .topbar, .cal-toolbar, .btn, .tabs { display: none !important; }
  .page { padding: 0; }
  .card, .week { box-shadow: none; }
}
