/* Mode.Werk – Zeiterfassung & Dienstplan. Mobile first, Farben aus dem Logo. */

:root {
  --bg: #f4f6f4;
  --surface: #ffffff;
  --surface-2: #eef2ef;
  --text: #232b26;
  --muted: #67716b;
  --border: #dfe5e1;
  --brand: #afcaba;
  --brand-soft: #e4eee8;
  --brand-strong: #4f7a63;
  --primary: #2c3a32;
  --primary-text: #ffffff;
  --danger: #b42318;
  --focus: #6f9a83;
  --green-bg: #e3f2e8; --green-fg: #1f6b3a;
  --amber-bg: #fcefd4; --amber-fg: #845500;
  --red-bg: #fbe3e0;   --red-fg: #a3261b;
  --blue-bg: #e2ebf7;  --blue-fg: #1d4f91;
  --grey-bg: #eaeeeb;  --grey-fg: #535c56;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(20 40 30 / 0.04), 0 6px 20px rgb(20 40 30 / 0.05);
  --tap: 44px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101311;
    --surface: #1a1f1c;
    --surface-2: #232a26;
    --text: #e7ece9;
    --muted: #9aa5a0;
    --border: #2f3833;
    --brand-soft: #24332b;
    --brand-strong: #afcaba;
    --primary: #afcaba;
    --primary-text: #16201a;
    --danger: #f0776b;
    --focus: #afcaba;
    --green-bg: #1c3324; --green-fg: #93d8a9;
    --amber-bg: #392d13; --amber-fg: #f0c66f;
    --red-bg: #3c1e1b;   --red-fg: #f29c92;
    --blue-bg: #1b2a3e;  --blue-fg: #9dc1f0;
    --grey-bg: #29302c;  --grey-fg: #b4bdb7;
    --shadow: none;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  -webkit-tap-highlight-color: transparent;
}
h1, h2 { margin: 0 0 12px; line-height: 1.25; }
h2 { font-size: 1.1rem; }
p { margin: 0 0 8px; }
a { color: inherit; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.spacer { flex: 1; }
.loading { padding: 40px 16px; text-align: center; color: var(--muted); }

/* ---------------------------------------------------------------- Kopfzeile */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}
.topbar-inner {
  max-width: 1120px; margin: 0 auto;
  display: flex; align-items: center; gap: 16px;
  height: 56px; padding: 0 16px;
}
.logo { display: flex; align-items: center; flex-shrink: 0; }
.logo-img { display: block; height: 30px; width: auto; border-radius: 4px; }

.nav-inline { display: none; }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: 10px;
  color: var(--muted); text-decoration: none; font: inherit; font-weight: 500;
  background: none; border: 0; cursor: pointer; text-align: left;
}
.nav-link:hover { color: var(--text); background: var(--surface-2); }
.nav-link.active { color: var(--text); background: var(--brand-soft); }
.count {
  min-width: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--danger); color: #fff; font-size: 0.75rem; line-height: 20px; text-align: center;
}

.menu { position: relative; margin-left: auto; }
.menu-btn {
  position: relative;
  width: var(--tap); height: var(--tap);
  display: grid; place-items: center;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); color: var(--text); cursor: pointer;
}
.burger, .burger::before, .burger::after {
  display: block; width: 18px; height: 2px; border-radius: 2px; background: currentColor;
}
.burger { position: relative; }
.burger::before, .burger::after { content: ""; position: absolute; left: 0; }
.burger::before { top: -6px; }
.burger::after { top: 6px; }
.menu-dot {
  position: absolute; top: 8px; right: 8px;
  width: 8px; height: 8px; border-radius: 50%; background: var(--danger);
}
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 8px);
  width: min(280px, calc(100vw - 32px));
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 12px 40px rgb(0 0 0 / 0.16);
  padding: 8px;
  display: grid; gap: 2px;
}
.menu-user { display: grid; padding: 8px 12px 10px; border-bottom: 1px solid var(--border); margin-bottom: 4px; }
.menu-nav { display: grid; gap: 2px; }
.menu-panel .nav-link { min-height: var(--tap); width: 100%; }
.menu-foot { display: grid; gap: 2px; border-top: 1px solid var(--border); margin-top: 4px; padding-top: 4px; }

@media (min-width: 900px) {
  .nav-inline { display: flex; gap: 2px; }
  .menu-nav { display: none; }
  .menu-dot { display: none; }
}

/* ------------------------------------------------------------------- Layout */
.content {
  max-width: 1120px; margin: 0 auto;
  padding: 16px 16px calc(48px + env(safe-area-inset-bottom));
  display: grid; gap: 16px; align-items: start;
}
.greeting { margin: 4px 2px 0; font-size: 1.35rem; font-weight: 700; }

@media (min-width: 900px) {
  .content { padding-top: 24px; }
  .view-zeiten { grid-template-columns: minmax(340px, 420px) minmax(0, 1fr); }
  .view-zeiten > .greeting { grid-column: 1 / -1; }
  .view-zeiten > section:last-child { grid-column: 2; grid-row: 2 / span 3; }
  .view-uebersicht, .view-benutzer, .view-einstellungen, .view-antraege, .view-konto { max-width: 900px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card.narrow { max-width: 440px; width: 100%; }
.card-head {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 8px 12px; margin-bottom: 12px;
}
.card-head h2 { margin: 0; }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.toolbar select { width: auto; min-width: 0; }

details.collapsible > summary { cursor: pointer; font-weight: 600; list-style: none; min-height: 24px; }
details.collapsible > summary::-webkit-details-marker { display: none; }
details.collapsible > summary::before { content: "+ "; color: var(--brand-strong); font-weight: 700; }
details.collapsible[open] > summary::before { content: "− "; }
details.collapsible[open] > summary { margin-bottom: 14px; }

/* ---------------------------------------------------------------- Anmeldung */
.auth {
  min-height: 100vh; min-height: 100dvh;
  display: grid; place-content: center; justify-items: center; gap: 12px;
  padding: 24px 16px;
}
.auth-card { width: min(380px, calc(100vw - 32px)); display: grid; gap: 14px; padding: 24px; }
.auth-logo { display: flex; justify-content: center; margin-bottom: 2px; }
.auth-logo .logo-img { height: 52px; border-radius: 6px; }
.auth-sub { text-align: center; color: var(--muted); margin: -6px 0 6px; font-size: 0.9rem; }
.auth-card h2 { margin: 4px 0 0; }

/* --------------------------------------------------------------- Formulare */
label, .field-label { display: grid; gap: 6px; font-size: 0.85rem; color: var(--muted); font-weight: 600; }
.field { display: grid; gap: 6px; }

input, select, textarea {
  width: 100%; min-width: 0; min-height: var(--tap);
  font: inherit; font-size: 16px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 9px 12px;
}
textarea { resize: vertical; min-height: 0; }
input[type="time"], input[type="date"] { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
input:focus, select:focus, textarea:focus { border-color: var(--focus); outline: none; box-shadow: 0 0 0 3px color-mix(in srgb, var(--focus) 25%, transparent); }

.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.pair input[type="time"] { font-size: 1.15rem; font-weight: 600; text-align: center; }
.time-fields, .stack-form { display: grid; gap: 14px; }
.break-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.break-custom { display: flex; flex-direction: row; align-items: center; gap: 6px; font-weight: 500; }
.break-input { width: 76px; text-align: center; }

.form-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.net { margin: 0; color: var(--muted); }
.net strong { color: var(--text); font-variant-numeric: tabular-nums; }
.net strong.bad { color: var(--danger); }
.net-big { text-align: center; font-size: 1rem; padding: 4px 0; }
.net-big strong { font-size: 1.6rem; display: block; line-height: 1.2; }
.hint { color: var(--muted); font-size: 0.85rem; margin: 0; }
.warn { margin: 0; padding: 8px 12px; border-radius: 10px; background: var(--amber-bg); color: var(--amber-fg); font-size: 0.9rem; }
.form-error { color: var(--danger); font-size: 0.9rem; margin: 0; }
.form-error:empty { display: none; }

/* ----------------------------------------------------------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap);
  font: inherit; font-weight: 600; font-size: 0.95rem;
  padding: 8px 16px; border-radius: 12px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
  text-decoration: none;
}
.btn:hover:not(:disabled) { filter: brightness(0.97); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: transparent; }
.btn.danger-text { color: var(--danger); }
.btn.small { min-height: 36px; padding: 5px 12px; font-size: 0.875rem; border-radius: 10px; }
.btn.big { min-height: 52px; font-size: 1.05rem; }
.btn.block { width: 100%; }

.icon-btn {
  width: 36px; height: 36px; display: inline-grid; place-items: center;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--text); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.icon-btn:disabled { opacity: 0.35; cursor: default; }

/* ------------------------------------------------------------------- Chips */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  min-height: 38px; padding: 6px 14px; border-radius: 999px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-size: 0.9rem; font-weight: 500; cursor: pointer; white-space: nowrap;
}
.chip:hover { border-color: var(--focus); }
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-text); }

.chips.segmented { gap: 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; flex-wrap: nowrap; }
.chips.segmented .chip { border: 0; border-radius: 0; min-height: 34px; padding: 4px 14px; }

.stepper { display: inline-flex; align-items: center; gap: 6px; }
.stepper-label { min-width: 112px; text-align: center; font-weight: 600; white-space: nowrap; }
.week-nav { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- Erfassen */
.capture { display: grid; gap: 14px; }
.day-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.date-input { width: auto; flex: 1 1 150px; min-height: 38px; padding: 5px 10px; border-radius: 999px; font-size: 0.95rem; }
.day-label { margin: -4px 0 0; font-weight: 700; font-size: 1.05rem; }
.day-info { display: grid; gap: 8px; }
.day-info:empty { display: none; }
.plan-hint { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--brand-soft); }
.plan-hint-label { font-size: 0.85rem; color: var(--brand-strong); font-weight: 600; }
.plan-hint .chip { background: var(--surface); }
.already { margin: 0; font-size: 0.9rem; color: var(--amber-fg); background: var(--amber-bg); padding: 8px 12px; border-radius: 10px; }

.next-shift {
  display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px;
  text-decoration: none; padding: 12px 16px;
  background: var(--brand-soft); border-color: transparent;
}
.next-shift strong { grid-column: 1; }
.next-shift .chevron { grid-column: 2; grid-row: 1 / span 2; font-size: 1.6rem; color: var(--brand-strong); }

/* ---------------------------------------------------------------- Kennzahlen */
.stats { display: flex; gap: 10px; margin-bottom: 8px; }
.stat { flex: 1; background: var(--surface-2); border-radius: 12px; padding: 10px 12px; display: grid; }
.stat-value { font-size: 1.35rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 0.8rem; }

/* ------------------------------------------------------------ Eintragsliste */
.rows, .requests, .users, .timeline, .diff, .shift-list, .totals { list-style: none; margin: 0; padding: 0; }
.rows li + li { border-top: 1px solid var(--border); }
.row {
  width: 100%; display: grid; grid-template-columns: 76px minmax(0, 1fr) auto; gap: 4px 12px; align-items: center;
  padding: 12px 4px; min-height: 56px;
  font: inherit; color: inherit; text-align: left; background: none; border: 0; cursor: pointer; border-radius: 10px;
}
.row:hover { background: var(--surface-2); }
.row-date { font-weight: 600; white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-main { display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; min-width: 0; }
.row-user { font-weight: 600; color: var(--brand-strong); }
.row-time { font-variant-numeric: tabular-nums; }
.row-note { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.row-badges { display: flex; flex-wrap: wrap; gap: 4px; }
.row-badges:empty { display: none; }
.row-value { font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.row.deleted .row-date, .row.deleted .row-time, .row.deleted .row-value { text-decoration: line-through; opacity: 0.55; }
.empty { color: var(--muted); padding: 12px 0; margin: 0; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 0.75rem; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-bg); color: var(--green-fg); }
.badge-amber { background: var(--amber-bg); color: var(--amber-fg); }
.badge-red { background: var(--red-bg); color: var(--red-fg); }
.badge-blue { background: var(--blue-bg); color: var(--blue-fg); }
.badge-grey { background: var(--grey-bg); color: var(--grey-fg); }

/* ---------------------------------------------------------- Anträge/Verlauf */
.request { padding: 14px 0; border-top: 1px solid var(--border); }
.request:first-child { border-top: 0; padding-top: 2px; }
.request-head { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin-bottom: 6px; }
.diff { margin-bottom: 8px; font-size: 0.95rem; }
.diff li { padding: 1px 0; }
del { color: var(--red-fg); background: var(--red-bg); text-decoration: line-through; padding: 0 4px; border-radius: 4px; }
ins { color: var(--green-fg); background: var(--green-bg); text-decoration: none; padding: 0 4px; border-radius: 4px; }
.quote { border-left: 3px solid var(--border); padding: 2px 0 2px 10px; margin: 6px 0; font-size: 0.92rem; overflow-wrap: anywhere; }
.quote.review { border-left-color: var(--brand); }

.timeline > li { position: relative; padding: 0 0 16px 20px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline > li:last-child { border-left-color: transparent; padding-bottom: 0; }
.timeline > li::before {
  content: ""; position: absolute; left: -7px; top: 5px;
  width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--brand-strong);
}

/* ---------------------------------------------------------------- Dienstplan */
.days { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); }
.day {
  border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  display: grid; gap: 8px; align-content: start; background: var(--surface);
}
.day.today { border-color: var(--brand-strong); box-shadow: inset 0 0 0 1px var(--brand-strong); }
.day.closed { background: var(--surface-2); }
.day.past { opacity: 0.75; }
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 8px; }
.day-name { font-weight: 700; }
.day-hours { color: var(--muted); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.shift-list { display: grid; gap: 6px; }
.shift {
  width: 100%; display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 8px;
  padding: 7px 10px; border-radius: 10px; border: 0;
  background: var(--surface-2); color: var(--text); font: inherit; text-align: left;
}
button.shift { cursor: pointer; }
button.shift:hover { filter: brightness(0.96); }
.shift.mine { background: var(--brand); color: #1d2621; }
.shift-time { font-weight: 700; font-variant-numeric: tabular-nums; }
.shift-note { font-size: 0.8rem; opacity: 0.75; }
.coverage { margin: 0; font-size: 0.8rem; font-weight: 600; }
.coverage.ok { color: var(--green-fg); }
.coverage.gap { color: var(--amber-fg); }
.day .add { justify-self: start; }

.totals li { display: flex; justify-content: space-between; padding: 8px 0; border-top: 1px solid var(--border); font-variant-numeric: tabular-nums; }
.totals li:first-child { border-top: 0; }

.matrix-wrap { overflow-x: auto; margin: 0 -4px; }
.matrix { width: 100%; border-collapse: separate; border-spacing: 4px; table-layout: fixed; }
.matrix th, .matrix td { vertical-align: top; text-align: left; }
.matrix thead th { padding: 6px 8px; border-radius: 10px; background: var(--surface-2); font-weight: 400; }
.matrix thead th.today { background: var(--brand-soft); box-shadow: inset 0 0 0 1px var(--brand-strong); }
.matrix thead th.closed { opacity: 0.6; }
.matrix th.who { width: 120px; padding: 10px 8px; font-weight: 600; background: none; }
.matrix td { padding: 4px; border-radius: 10px; background: var(--surface-2); min-height: 52px; }
.matrix td.closed { background: repeating-linear-gradient(-45deg, var(--surface-2) 0 6px, var(--surface) 6px 12px); }
.matrix td .shift { margin-bottom: 4px; padding: 5px 8px; background: var(--brand); color: #1d2621; font-size: 0.85rem; }
.matrix tfoot td { background: none; }
.matrix .num { width: 80px; text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; background: none; padding-top: 10px; }
.cell-add {
  width: 100%; min-height: 28px; border: 1px dashed var(--border); border-radius: 8px;
  background: transparent; color: var(--muted); font: inherit; cursor: pointer; opacity: 0.6;
}
.matrix td:hover .cell-add, .cell-add:focus-visible { opacity: 1; border-color: var(--focus); color: var(--text); }

/* ----------------------------------------------------------------- Tabellen */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.table th, .table td { padding: 10px 8px; text-align: left; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table thead th { color: var(--muted); font-size: 0.8rem; font-weight: 600; }
.table tfoot th { border-bottom: 0; }
.table .num { text-align: right; }
.table .neg { color: var(--danger); }
.table .pos { color: var(--green-fg); }

/* ----------------------------------------------------------------- Benutzer */
.user { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 0; border-top: 1px solid var(--border); }
.user:first-child { border-top: 0; padding-top: 2px; }
.user-main .row-badges { margin-top: 4px; }
.user-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.user.inactive .user-main { opacity: 0.6; }

/* ------------------------------------------------------------ Einstellungen */
.opening-form { display: grid; gap: 4px; }
.weekday {
  display: grid; grid-template-columns: 100px minmax(0, 1fr) auto; align-items: center; gap: 8px;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.weekday-name { font-weight: 600; }
.intervals { display: grid; gap: 6px; }
.interval { display: flex; align-items: center; gap: 6px; }
.interval input { width: auto; flex: 1; min-width: 92px; padding: 6px 8px; }
.closed-label { display: none; }
.weekday.is-closed .intervals { display: none; }
.weekday.is-closed .closed-label { display: block; }
.opening-form .form-foot { margin-top: 12px; }

/* ------------------------------------------------------------------ Dialog */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100dvh - 24px);
  padding: 0; border: 1px solid var(--border); border-radius: 18px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(10 20 15 / 0.45); }
.dialog-body { display: grid; gap: 14px; padding: 20px; }
.dialog-body h2 { margin: 0; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 8px; }
.actions.start { justify-content: flex-start; }
.actions.stack { display: grid; justify-content: stretch; }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 6px 16px; margin: 0; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

@media (max-width: 560px) {
  /* Dialoge als Bottom-Sheet am Handy */
  dialog {
    width: 100%; max-width: 100%; margin: auto 0 0;
    border-radius: 18px 18px 0 0; border-bottom: 0;
    padding-bottom: env(safe-area-inset-bottom);
  }
  .actions:not(.start) { display: grid; grid-auto-flow: row; justify-content: stretch; }
  .actions:not(.start) .spacer { display: none; }
  .actions:not(.start) .btn { width: 100%; }
}

/* ------------------------------------------------------------------- Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); z-index: 100;
  transform: translate(-50%, 20px); opacity: 0;
  max-width: calc(100vw - 32px);
  padding: 12px 18px; border-radius: 12px;
  background: var(--primary); color: var(--primary-text); font-weight: 600;
  box-shadow: 0 8px 28px rgb(0 0 0 / 0.2);
  transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-error { background: var(--danger); color: #fff; }
