/* Sitzplan — minimales, modernes Design-System */

:root {
  color-scheme: light dark;

  --bg: #fbfbfc;
  --surface: #ffffff;
  --surface-2: #f4f4f6;
  --border: #e4e4e9;
  --border-strong: #d2d2da;
  --text: #17171c;
  --text-muted: #6c6c78;
  --text-faint: #9a9aa6;

  --accent: #4f46e5;
  --accent-hover: #4338ca;
  --accent-soft: #eef2ff;
  --accent-text: #ffffff;

  --ok: #067a56;
  --ok-soft: #e6f6f0;
  --warn: #9a6200;
  --warn-soft: #fdf3e2;
  --danger: #b3261e;
  --danger-soft: #fdecea;

  --radius: 10px;
  --radius-sm: 7px;
  --radius-lg: 16px;
  --shadow: 0 1px 2px rgba(16, 16, 24, 0.05);
  --shadow-lg: 0 10px 30px rgba(16, 16, 24, 0.09);
  --shell: 960px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0e0e12;
    --surface: #17171d;
    --surface-2: #1e1e26;
    --border: #2a2a34;
    --border-strong: #3a3a46;
    --text: #ededf2;
    --text-muted: #a0a0ae;
    --text-faint: #71717f;

    --accent: #7c74ff;
    --accent-hover: #918bff;
    --accent-soft: #211f3d;

    --ok: #4ade9f;
    --ok-soft: #10281f;
    --warn: #f0b45e;
    --warn-soft: #2b2113;
    --danger: #ff8a80;
    --danger-soft: #2e1512;

    --shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.55);
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -0.015em; }
h1 { font-size: 1.55rem; }
h2 { font-size: 1.1rem; }
h3 { font-size: 0.95rem; }

p { margin: 0 0 1rem; }
p:last-child { margin-bottom: 0; }

/* ---------- Layout ---------- */

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 20px 72px; }
.shell--narrow { max-width: 520px; }
.page--wide { --shell: 1240px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.topbar__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 20px;
  height: 58px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.brand {
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand__mark {
  width: 22px; height: 22px;
  border-radius: 6px;
  background: var(--accent);
  display: grid; place-items: center;
  color: #fff; font-size: 12px; font-weight: 700;
}

.nav { display: flex; gap: 4px; margin-left: auto; align-items: center; }
.nav a {
  padding: 6px 11px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.9rem;
}
.nav a:hover { background: var(--surface-2); color: var(--text); text-decoration: none; }
.nav a.is-active { background: var(--surface-2); color: var(--text); }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin: 36px 0 20px;
}
.page-head p { color: var(--text-muted); margin: 4px 0 0; font-size: 0.9rem; }

/* ---------- Karten ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card + .card { margin-top: 20px; }
.card__head {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card__body { padding: 20px; }
.card__body--flush { padding: 0; }

.grid { display: grid; gap: 16px; }
.grid--2 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid--3 { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

/* ---------- Tagesliste ---------- */

.days { display: flex; flex-direction: column; }

.day {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  align-items: center;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.day:last-child { border-bottom: 0; }
.day--past { opacity: 0.5; }
.day--today { background: var(--accent-soft); }
.day--weekend .day__date { color: var(--text-faint); }

.day__date { display: flex; flex-direction: column; line-height: 1.25; }
.day__weekday { font-weight: 600; font-size: 0.9rem; }
.day__number { color: var(--text-muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }

.day__info { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.day__room { font-weight: 500; }
.day__note { color: var(--text-muted); font-size: 0.85rem; }

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

/* ---------- Pills ---------- */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  white-space: nowrap;
  background: var(--surface-2);
  color: var(--text-muted);
}
.pill--seat { background: var(--ok-soft); color: var(--ok); }
.pill--waitlist { background: var(--warn-soft); color: var(--warn); }
.pill--released { background: var(--surface-2); color: var(--text-muted); }
.pill--home { background: var(--accent-soft); color: var(--accent); }
.pill--off { background: var(--surface-2); color: var(--text-faint); }
.pill--not_employed { background: var(--surface-2); color: var(--text-faint); }
.pill--admin { background: var(--accent-soft); color: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 999px; background: currentColor; }

/* ---------- Buttons ---------- */

.btn {
  --btn-bg: var(--surface);
  --btn-fg: var(--text);
  --btn-border: var(--border-strong);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 550;
  color: var(--btn-fg);
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.13s ease, border-color 0.13s ease, transform 0.06s ease;
  white-space: nowrap;
}
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.btn--primary {
  --btn-bg: var(--accent);
  --btn-fg: var(--accent-text);
  --btn-border: var(--accent);
}
.btn--primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn--ghost { --btn-bg: transparent; --btn-border: transparent; --btn-fg: var(--text-muted); }
.btn--danger { --btn-fg: var(--danger); }
.btn--sm { padding: 5px 10px; font-size: 0.82rem; }
.btn--block { width: 100%; }

/* ---------- Formulare ---------- */

.field { margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field > label,
.label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.hint { font-size: 0.8rem; color: var(--text-faint); margin-top: 6px; }

input[type="text"],
input[type="email"],
input[type="date"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.92rem;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  transition: border-color 0.13s ease, box-shadow 0.13s ease;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.code-input {
  font-family: var(--mono);
  font-size: 1.5rem;
  letter-spacing: 0.4em;
  text-align: center;
  padding: 14px 12px;
}

.checkline { display: flex; align-items: center; gap: 9px; padding: 7px 0; }
.checkline input { width: auto; }
.checkline label { margin: 0; font-size: 0.9rem; font-weight: 500; color: var(--text); }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; align-items: flex-end; }
.form-row > * { flex: 1 1 160px; }
.form-row > .btn { flex: 0 0 auto; }

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

table { width: 100%; border-collapse: collapse; }
th {
  text-align: left;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-faint);
  font-weight: 600;
  padding: 10px 20px;
  border-bottom: 1px solid var(--border);
}
td { padding: 12px 20px; border-bottom: 1px solid var(--border); vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

/* ---------- Raum-Belegung ---------- */

.room {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 16px;
}
.room__head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.room__cap { font-size: 0.8rem; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.room__seats { display: flex; flex-direction: column; gap: 6px; }
.seat {
  display: flex; align-items: center; gap: 9px;
  padding: 6px 9px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: 0.88rem;
}
.seat--free { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-faint); }
.seat--me { background: var(--accent-soft); color: var(--accent); font-weight: 600; }

.avatar {
  width: 24px; height: 24px; flex: 0 0 24px;
  border-radius: 999px;
  background: var(--border);
  color: var(--text-muted);
  display: grid; place-items: center;
  font-size: 0.7rem; font-weight: 650;
  text-transform: uppercase;
}

/* ---------- Hinweise ---------- */

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  font-size: 0.88rem;
  background: var(--warn-soft);
  color: var(--warn);
  border-bottom: 1px solid color-mix(in srgb, var(--warn) 22%, transparent);
}
.banner .btn { margin-left: auto; }

.alert {
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  margin-bottom: 16px;
  border: 1px solid transparent;
}
.alert--error { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.alert--ok { background: var(--ok-soft); color: var(--ok); border-color: color-mix(in srgb, var(--ok) 25%, transparent); }
.alert--info { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

.empty { padding: 36px 20px; text-align: center; color: var(--text-faint); font-size: 0.9rem; }

.muted { color: var(--text-muted); }
.faint { color: var(--text-faint); }
.small { font-size: 0.85rem; }
.stack { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.spacer { flex: 1; }
.mono { font-family: var(--mono); }

/* ---------- Auth ---------- */

.auth { min-height: 82vh; display: grid; place-items: center; padding: 40px 20px; }
.auth__card { width: 100%; max-width: 400px; }
.auth__title { text-align: center; margin-bottom: 6px; }
.auth__sub { text-align: center; color: var(--text-muted); font-size: 0.9rem; margin-bottom: 24px; }

/* ---------- Wochenplan-Editor ---------- */

.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.week__day { display: flex; flex-direction: column; gap: 6px; }
.week__label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); text-align: center; }
.week select { padding: 7px 6px; font-size: 0.8rem; }

@media (max-width: 720px) {
  .week { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.htmx-request .btn { opacity: 0.6; pointer-events: none; }

/* ---------- Wochenplan-Matrix ---------- */

.plan-scroll { max-height: 72vh; overflow: auto; }
.plan { border-collapse: separate; border-spacing: 0; min-width: 1080px; }
.plan th, .plan td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.plan thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--border);
  text-align: center;
  text-transform: none;
  font-size: 0.8rem;
  letter-spacing: 0;
  color: var(--text);
}
.plan__date { display: block; font-weight: 400; font-size: 0.72rem; color: var(--text-faint); font-variant-numeric: tabular-nums; }
.plan__corner { text-align: left !important; min-width: 200px; }
.plan__name {
  font-weight: 550;
  font-size: 0.88rem;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
}
.plan__cell { padding: 6px 6px !important; }
.plan__cell--weekend { background: var(--surface-2); }
.plan__select {
  width: 100%;
  padding: 5px 6px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
  border-color: var(--border);
  background: var(--surface);
  cursor: pointer;
}
.plan__select--office { color: var(--ok); background: var(--ok-soft); border-color: transparent; }
.plan__select--home { color: var(--accent); background: var(--accent-soft); border-color: transparent; }
.plan__select--off { color: var(--text-faint); }
.plan__select--not_employed { color: var(--text-faint); background: transparent; border-style: dashed; }

.plan-row--inherited .plan__select { opacity: 0.48; }
.plan-row--inherited .plan__name > a { color: var(--text-muted); }
.plan-row--inherited:hover .plan__select { opacity: 0.85; }

/* ---------- Bottom-Navigation (mobil / PWA) ---------- */

.tabbar { display: none; }
.lbl-sm { display: none; }

@media (max-width: 760px) {
  .nav--top { display: none; }
  .topbar__inner { height: 52px; }
  .brand { font-size: 0.98rem; }

  .shell { padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }

  .tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 30;
    display: flex;
    justify-content: space-around;
    gap: 2px;
    padding: 6px 6px calc(6px + env(safe-area-inset-bottom, 0px));
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    backdrop-filter: saturate(180%) blur(14px);
    border-top: 1px solid var(--border);
  }
  .tabbar a {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3px;
    padding: 6px 2px;
    border-radius: var(--radius-sm);
    color: var(--text-faint);
    font-size: 0.66rem;
    font-weight: 550;
    letter-spacing: 0.005em;
    text-decoration: none;
  }
  .tabbar a span {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .tabbar a.is-active { color: var(--accent); }
  .tabbar svg {
    width: 21px; height: 21px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.7;
    stroke-linecap: round;
    stroke-linejoin: round;
  }

  .lbl-lg { display: none; }
  .lbl-sm { display: inline; }

  .page-head { margin: 22px 0 16px; }
  h1 { font-size: 1.35rem; }

  .day {
    grid-template-columns: 52px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 12px 14px;
  }
  .day__actions { grid-column: auto; }
  .day__info { gap: 6px; }
  .day__note { width: 100%; font-size: 0.78rem; }
  .card__body { padding: 16px; }
  .card__head { padding: 14px 16px; }
  th, td { padding: 10px 14px; }
  .banner { padding: 10px 14px; flex-wrap: wrap; }
  .banner .btn { margin-left: 0; }
  .shell { padding-left: 14px; padding-right: 14px; }
}

@media (max-width: 430px) {
  /* Fünf Tabs müssen nebeneinander passen, ohne dass Beschriftungen abschneiden. */
  .tabbar a { font-size: 0.6rem; letter-spacing: -0.01em; padding-left: 0; padding-right: 0; }
  .tabbar svg { width: 20px; height: 20px; }
}

@media (max-width: 360px) {
  .day { grid-template-columns: 46px minmax(0, 1fr); }
  .day__actions { grid-column: 1 / -1; justify-content: flex-end; }
}

/* In der installierten App gibt es keinen Browser-Zurück-Button: mehr Luft oben. */
@media (display-mode: standalone) {
  .topbar { padding-top: env(safe-area-inset-top, 0px); }
}

/* ---------- Dialoge ---------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(12, 12, 18, 0.45);
  backdrop-filter: blur(2px);
}
.modal__card {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.16s ease-out;
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(8px) scale(0.985); }
  to { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  .modal__card { animation: none; }
}

.modal__title { font-size: 1.15rem; margin-bottom: 8px; }
.modal__lead { font-size: 0.92rem; color: var(--text-muted); margin-bottom: 18px; }
.modal__lead strong { color: var(--text); font-weight: 600; }
.modal__actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

/* Auswahl aus "wie im Profil" oder tagesgenauer Liste */
.choice { border: 0; margin: 0 0 16px; padding: 0; }
.choice legend { padding: 0; }
.choice__list {
  margin: 4px 0 0 26px;
  padding: 8px 12px;
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.choice:has(input[value="profile"]:checked) .choice__list { opacity: 0.5; }

.btn--icon { padding: 6px; }
.btn--icon svg {
  width: 15px; height: 15px;
  fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

@media (max-width: 760px) {
  .modal { padding: 0; align-items: flex-end; }
  .modal__card {
    max-width: none;
    max-height: 88vh;
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding-bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  }
  @keyframes modal-in {
    from { opacity: 0; transform: translateY(24px); }
    to { opacity: 1; transform: none; }
  }
  .modal__actions { flex-direction: column-reverse; }
  .modal__actions .btn { width: 100%; }
}

/* ---------- Bestätigungen ---------- */

.confirm__details {
  margin: 0 0 16px;
  padding: 12px 16px 12px 30px;
  list-style: disc;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text);
}
.confirm__details li + li { margin-top: 4px; }

.btn--destructive {
  --btn-bg: var(--danger);
  --btn-fg: #fff;
  --btn-border: var(--danger);
}
.btn--destructive:hover {
  background: color-mix(in srgb, var(--danger) 85%, black);
  border-color: color-mix(in srgb, var(--danger) 85%, black);
}
