/* Zeiterfassung – staff app. Phone first, no inline styles.
   Look of the MONA admin console: its --cp-* palette (light in :root, dark in html[data-theme="dark"]),
   Playfair Display titles and the Segoe UI/system sans. /assets/theme.js sets data-theme before the first
   paint (the choice stored on this device, else the OS setting); the Hell/Dunkel switch sits in the app bar. */

@font-face {
  font-family: "Playfair Display";
  font-style: normal;
  font-weight: 600 800;
  font-display: swap;
  src: url("/assets/fonts/playfair-display-latin.woff2") format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308,
    U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

:root {
  color-scheme: light;
  /* Admin console palette (wix-restaurants-mcp/admin-server.mjs), same names and values. Where a value
     differs ("admin …"), only its lightness moved (same hue) so every pair this app uses reaches WCAG AA. */
  --cp-bg: #f7f4ef;
  --cp-bg-elevated: #fcfbf8;
  --cp-surface: #ffffff;
  --cp-surface-soft: #f5f5f5;
  --cp-border: #dedede;
  --cp-border-strong: #878787; /* admin #919191: 2.87:1 on --cp-bg, control outlines need 3:1 */
  --cp-text: #242424;
  --cp-text-muted: #5c5c5c;
  --cp-text-soft: #6f6f6f;
  --cp-accent: #b11f4b;
  --cp-accent-hover: #9a1a41;
  --cp-accent-soft: rgba(177, 31, 75, 0.08);
  --cp-accent-fg: #ffffff;
  --cp-success: #16a34a;
  --cp-danger: #dc2626;
  --cp-warning: #f59e0b;
  --cp-link: #0078d4;
  --cp-shadow: 0 18px 48px rgba(0, 0, 0, 0.12);
  --cp-overlay: rgba(255, 255, 255, 0.8);
  --cp-panel: rgba(255, 255, 255, 0.86);
  --cp-panel-strong: rgba(255, 255, 255, 0.96);
  --cp-sheen: rgba(255, 255, 255, 0.55);
  --cp-highlight: rgba(177, 31, 75, 0.12);

  /* Staff additions in the admin hues: text colours for status hues, soft fills, fixed extras. */
  --cp-accent-soft-solid: #f9edf1; /* --cp-accent-soft composited over --cp-surface */
  --cp-success-text: #117c38; /* admin success #16a34a is 3.30:1 on white */
  --cp-danger-text: #c42020; /* admin danger #dc2626 is 4.40:1 on --cp-bg */
  --cp-danger-fg: #ffffff;
  --cp-warning-text: #845506; /* admin warning #f59e0b is 2.15:1 on white */
  --cp-info-text: #006ec2; /* admin link #0078d4 is below 4.5:1 on the info fill */
  --cp-success-soft: #e5f5eb;
  --cp-danger-soft: #fcebeb;
  --cp-warning-soft: #fef1dd;
  --cp-warning-line: #e9b04f;
  --cp-info-soft: #e8f3fb;
  --cp-neutral-soft: #ededed;
  --cp-statusbar: #7a2036; /* iOS status-bar strip in both themes: white status text 10:1 */
  --cp-backdrop: rgba(58, 30, 36, 0.42); /* admin modal backdrop */
  --cp-card-shadow: 0 4px 16px rgba(122, 32, 54, 0.08); /* admin --shadow-sm */
  --cp-float-shadow: 0 12px 34px rgba(122, 32, 54, 0.1); /* admin --shadow */
  --cp-sheet-shadow: 0 -12px 34px rgba(122, 32, 54, 0.1);
  --appbar-bg: #ffffff; /* = --cp-surface; theme.js copies it into <meta name="theme-color"> */

  /* Semantic tokens used by the components (resolved per theme through the --cp-* values). */
  --bg: var(--cp-bg);
  --surface: var(--cp-surface);
  --surface-2: var(--cp-surface-soft);
  --text: var(--cp-text);
  --muted: var(--cp-text-muted);
  --border: var(--cp-border);
  --border-strong: var(--cp-border-strong);
  --link: var(--cp-accent);
  --brand-strong: var(--cp-accent);
  --brand-hover: var(--cp-accent-hover);
  --on-brand: var(--cp-accent-fg);
  --accent-soft: var(--cp-accent-soft-solid);
  --positive: var(--cp-success-text);
  --negative: var(--cp-danger-text);
  --danger-strong: var(--cp-danger);
  --on-danger: var(--cp-danger-fg);
  --warning-bg: var(--cp-warning-soft);
  --warning-border: var(--cp-warning-line);
  --warning-text: var(--cp-warning-text);
  --error-bg: var(--cp-danger-soft);
  --info-bg: var(--cp-info-soft);
  --info-text: var(--cp-info-text);
  --success-bg: var(--cp-success-soft);
  --success-text: var(--cp-success-text);
  --neutral-bg: var(--cp-neutral-soft);
  --neutral-text: var(--cp-text-muted);
  --focus: var(--cp-accent);
  --track: var(--cp-border);
  --toast-bg: var(--cp-surface);
  --shadow: var(--cp-card-shadow);
  --shadow-float: var(--cp-float-shadow);
  --shadow-sheet: var(--cp-sheet-shadow);
  --tabbar-shadow: 0 -8px 24px rgba(0, 0, 0, 0.06); /* admin phone tab bar */
  --backdrop: var(--cp-backdrop);
  --statusbar: var(--cp-statusbar);
  --radius: 16px;
  --radius-sm: 10px;
  --serif: "Playfair Display", Georgia, "Times New Roman", serif;
  --sans: "Segoe UI", Aptos, Calibri, -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  --font: var(--sans);
}

html[data-theme="dark"] {
  color-scheme: dark;
  --cp-bg: #3d3b3a;
  --cp-bg-elevated: #343231;
  --cp-surface: #292929;
  --cp-surface-soft: #2e2e2e;
  --cp-border: #474747;
  --cp-border-strong: #8f8f8f; /* admin #5f5f5f: 1.74:1 on --cp-bg */
  --cp-text: #dedede;
  --cp-text-muted: #adadad; /* admin #919191: 3.53:1 on --cp-bg (screen subtitles sit on it) */
  --cp-text-soft: #b0b0b0;
  --cp-accent: #fd8ea1;
  --cp-accent-hover: #fb7b91;
  --cp-accent-soft: rgba(253, 142, 161, 0.14);
  --cp-accent-fg: #1a1a1a;
  --cp-success: #4ade80;
  --cp-danger: #f87171;
  --cp-warning: #fbbf24;
  --cp-link: #4da6ff;
  --cp-shadow: 0 18px 48px rgba(0, 0, 0, 0.32);
  --cp-overlay: rgba(41, 41, 41, 0.88);
  --cp-panel: rgba(41, 41, 41, 0.72);
  --cp-panel-strong: rgba(41, 41, 41, 0.96);
  --cp-sheen: rgba(255, 255, 255, 0.04);
  --cp-highlight: rgba(253, 142, 161, 0.12);

  --cp-accent-soft-solid: #47373a; /* over the page background muted/accent text would be 3.9:1 */
  --cp-success-text: #4ade80;
  --cp-danger-text: #fa9393; /* admin danger #f87171 is 4.03:1 on --cp-bg */
  --cp-danger-fg: #1a1a1a; /* white on admin danger #f87171 is 2.77:1 */
  --cp-warning-text: #fbbf24;
  --cp-info-text: #58acff; /* admin link #4da6ff is below 4.5:1 on the info fill */
  --cp-success-soft: #2e4235;
  --cp-danger-soft: #4a3535;
  --cp-warning-soft: #4b4128;
  --cp-warning-line: #886d27;
  --cp-info-soft: #2f3d4b;
  --cp-neutral-soft: #3a3a3a;
  --cp-card-shadow: none;
  --cp-float-shadow: var(--cp-shadow);
  --cp-sheet-shadow: 0 -18px 48px rgba(0, 0, 0, 0.32);
  --appbar-bg: #292929; /* = dark --cp-surface */
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
html:has(dialog[open]) { overflow: hidden; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.45;
}

[hidden] { display: none !important; }

p { margin: 0.25rem 0; }
h1, h2, h3 { line-height: 1.25; }

/* Titles in the admin serif; numbers (timer, durations, week list) stay in the sans with tabular figures. */
.appbar__title, .screen__title, .section__title, .card__title, .sheet__title, .blocked__title {
  font-family: var(--serif);
  font-weight: 700;
}

a { color: var(--link); }
.link { color: var(--link); font-weight: 600; text-underline-offset: 0.15em; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
[tabindex="-1"]:focus { outline: none; }

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.icon { width: 1.25rem; height: 1.25rem; fill: currentColor; flex: none; }
.inline-icon { width: 1rem; height: 1rem; vertical-align: -0.15rem; margin-right: 0.25rem; }
.muted { color: var(--muted); }
.small { font-size: 0.875rem; }
.is-positive { color: var(--positive); }
.is-negative { color: var(--negative); }

.big, .hero, .summary__value, .fact__value, .day__worked, .day__times, .row__side,
.progress-block__value, .stepper__value, .input--number, .input--time, .weeknav__label {
  font-variant-numeric: tabular-nums;
}

/* ---------- App shell ---------- */

.appbar {
  position: relative;
  background: var(--appbar-bg);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  padding-top: env(safe-area-inset-top);
}

/* iOS home-screen mode (black-translucent) draws white status-bar text over the top of the page:
   that strip stays dark in both themes, also while the page scrolls. 0 px high everywhere else. */
.appbar::before {
  content: "";
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: env(safe-area-inset-top, 0px);
  background: var(--statusbar);
  pointer-events: none;
}

.appbar__inner {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  max-width: 40rem;
  min-height: 3.25rem;
  margin: 0 auto;
  padding: 0 max(1rem, env(safe-area-inset-left));
}

.appbar__logo { flex: none; border-radius: 0.5rem; }
.appbar__text {
  display: flex;
  flex-direction: column;
  flex: 0 1 auto;
  min-width: 0;
  line-height: 1.15;
}
.appbar__title {
  font-size: 1.125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.appbar__place {
  color: var(--muted);
  font-size: 0.8125rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hell/Dunkel switch (same look and semantics as the admin console's .theme-switch). The state is keyed
   on html[data-theme] so it is right from the first paint; theme.js keeps aria-checked in step. */
.theme-switch {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  flex: none;
  min-width: 2.75rem;
  min-height: 2.75rem;
  margin-left: auto;
  padding: 0 0.625rem;
  border: 0;
  border-radius: 11px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.theme-switch:active { background: var(--accent-soft); color: var(--link); }
@media (hover: hover) {
  .theme-switch:hover { background: var(--accent-soft); color: var(--link); }
}
.theme-switch__glyph { display: inline-flex; }
.theme-switch__icon { width: 1.25rem; height: 1.25rem; }
.theme-switch__icon--moon,
.theme-switch__name--dark { display: none; }
html[data-theme="dark"] .theme-switch__icon--sun,
html[data-theme="dark"] .theme-switch__name--light { display: none; }
html[data-theme="dark"] .theme-switch__icon--moon { display: block; }
html[data-theme="dark"] .theme-switch__name--dark { display: inline; }
.theme-track {
  display: flex;
  align-items: center;
  flex: none;
  width: 34px;
  height: 19px;
  padding: 2px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: var(--surface-2);
  transition: background-color 0.15s ease, border-color 0.15s ease;
}
.theme-thumb {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--muted);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
html[data-theme="dark"] .theme-track { background: var(--accent-soft); border-color: var(--link); }
html[data-theme="dark"] .theme-thumb { transform: translateX(15px); background: var(--link); }

@media (max-width: 22.5rem) {
  :root .theme-switch .theme-switch__name { display: none; }
}

.main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 0 1rem calc(6rem + env(safe-area-inset-bottom));
}
.main:focus { outline: none; }
body.is-blocked .main { padding-bottom: 2rem; }

.tabbar {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 20;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--surface);
  border-top: 1px solid var(--border);
  box-shadow: var(--tabbar-shadow);
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar__link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.125rem;
  min-height: 3.75rem;
  padding: 0 0.125rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.15;
  text-decoration: none;
  font-size: 0.8125rem;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
}
.tabbar__link:focus-visible { outline-offset: -3px; }
.tabbar__icon { width: 1.5rem; height: 1.5rem; }
.tabbar__link[aria-current="page"] { color: var(--link); }
.tabbar__link[aria-current="page"] .tabbar__icon {
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 0.125rem 1rem;
  width: 3.5rem;
  height: 1.75rem;
}

@media (min-width: 48rem) {
  .tabbar {
    position: sticky;
    top: 0;
    inset: auto;
    max-width: none;
    grid-template-columns: none;
    grid-auto-flow: column;
    justify-content: center;
    gap: 0.5rem;
    padding: 0 1rem;
    border-top: 0;
    border-bottom: 1px solid var(--border);
    box-shadow: none;
  }
  .tabbar__link {
    flex-direction: row;
    gap: 0.5rem;
    min-height: 3.25rem;
    padding: 0 1rem;
    font-size: 0.9375rem;
    border-bottom: 3px solid transparent;
  }
  .tabbar__link[aria-current="page"] { border-bottom-color: var(--link); }
  .tabbar__link[aria-current="page"] .tabbar__icon { background: none; padding: 0; width: 1.5rem; height: 1.5rem; }
  .main { padding-bottom: 3rem; }
}

/* ---------- Screens ---------- */

.screen__head { margin: 1.25rem 0 0.25rem; }
.screen__title { font-size: 1.5rem; margin: 0; }
.screen__sub { color: var(--muted); margin: 0.125rem 0 0; }

.section { margin-top: 1.5rem; }
.section__title { font-size: 1.0625rem; margin: 0 0 0.5rem; }

/* ---------- States ---------- */

.state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 1.5rem 1rem;
  text-align: center;
  color: var(--muted);
}
.state--loading { flex-direction: row; min-height: 6rem; }
.state--error {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  color: var(--text);
}
.state--empty {
  background: var(--surface);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 1rem;
}
.state__icon { width: 2rem; height: 2rem; color: var(--negative); }
.state__title { font-weight: 600; color: var(--text); margin: 0; }
.state__text { margin: 0; }
.state .btn { margin-top: 0.5rem; }

.spinner {
  width: 1.25rem;
  height: 1.25rem;
  border: 3px solid var(--track);
  border-top-color: var(--brand-strong);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  flex: none;
}

/* ---------- Cards ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem;
  margin-top: 1rem;
}
.section > .card:first-of-type { margin-top: 0; }
.card--accent { background: var(--accent-soft); border-color: transparent; }
.card--row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card--hero { text-align: left; }
.card__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 0.75rem; }
.card__title { font-size: 1.0625rem; margin: 0 0 0.5rem; }
.card__head .card__title { margin: 0; }
.card__actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.5rem; margin-top: 1rem; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.25rem;
  color: var(--muted);
  font-size: 0.8125rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.big { font-size: 1.75rem; font-weight: 700; margin: 0.125rem 0; }
.hero { font-size: 2.5rem; font-weight: 800; letter-spacing: -0.01em; margin: 0.25rem 0; }
.stack { display: grid; gap: 0.75rem; margin-top: 1rem; }

.pulse {
  width: 0.625rem;
  height: 0.625rem;
  border-radius: 50%;
  background: var(--positive);
  animation: pulse 1.6s ease-in-out infinite;
}

/* ---------- Buttons ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  min-height: 3rem;
  padding: 0.5rem 1.125rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: inherit;
  font: inherit;
  font-weight: 600;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn--primary { background: var(--brand-strong); color: var(--on-brand); }
.btn--primary:hover:not(:disabled) { background: var(--brand-hover); }
.btn--secondary { background: var(--surface); color: var(--text); border-color: var(--border-strong); }
.btn--secondary:hover:not(:disabled) { background: var(--accent-soft); }
.btn--ghost { color: var(--link); padding-inline: 0.75rem; }
.btn--ghost:hover:not(:disabled) { background: var(--accent-soft); }
.btn--danger { background: var(--danger-strong); color: var(--on-danger); }
.btn--danger-ghost { color: var(--negative); border-color: var(--border-strong); background: var(--surface); }
.btn--danger-ghost:hover:not(:disabled) { background: var(--error-bg); }
.btn--large { width: 100%; min-height: 3.5rem; font-size: 1.0625rem; }
.btn--small { min-height: 2.75rem; padding: 0.375rem 0.75rem; font-size: 0.9375rem; border-radius: var(--radius-sm); }
.btn--icon {
  width: 3rem;
  min-width: 3rem;
  padding: 0;
  background: var(--surface);
  border-color: var(--border-strong);
  color: var(--text);
}
.btn--icon .icon { width: 1.5rem; height: 1.5rem; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn[aria-busy="true"] { cursor: progress; }
.btn[aria-busy="true"]::after {
  content: "";
  width: 1rem;
  height: 1rem;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ---------- Banner, alerts, tags ---------- */

.banner {
  display: flex;
  gap: 0.75rem;
  margin-top: 1rem;
  padding: 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--warning-border);
  background: var(--warning-bg);
  color: var(--text);
}
.banner__icon { width: 1.75rem; height: 1.75rem; color: var(--warning-text); }
.banner__body { flex: 1; min-width: 0; }
.banner__title { font-size: 1.0625rem; margin: 0 0 0.25rem; color: var(--warning-text); }
.banner__note { font-weight: 600; margin-top: 0.5rem; }
.banner .btn { margin-top: 0.75rem; }

.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  font-weight: 600;
}
.alert--error { background: var(--error-bg); color: var(--negative); }
.alert--warning { background: var(--warning-bg); color: var(--warning-text); }
.alert__icon { margin-top: 0.0625rem; }

.tags { display: flex; flex-wrap: wrap; gap: 0.25rem; margin-top: 0.375rem; }
.tag {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.5rem;
  border-radius: 999px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
}
.tag--info { background: var(--info-bg); color: var(--info-text); }
.tag--warning { background: var(--warning-bg); color: var(--warning-text); }
.tag--success { background: var(--success-bg); color: var(--success-text); }
.tag--neutral { background: var(--neutral-bg); color: var(--neutral-text); white-space: normal; }
.tag--accent { background: var(--accent-soft); color: var(--link); }

/* ---------- Toasts (admin toast: surface, border, 4px status border on the left) ---------- */

.toasts {
  position: fixed;
  left: 50%;
  bottom: calc(4.75rem + env(safe-area-inset-bottom));
  z-index: 30;
  display: grid;
  gap: 0.5rem;
  width: min(28rem, calc(100% - 2rem));
  transform: translateX(-50%);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-left-width: 4px;
  border-radius: var(--radius-sm);
  background: var(--toast-bg);
  color: var(--text);
  box-shadow: var(--shadow-float);
  animation: toast-in 0.2s ease-out;
}
.toast--info { border-left-color: var(--cp-success); }
.toast--error { border-left-color: var(--cp-danger); }
.toast--info .toast__icon { color: var(--positive); }
.toast--error .toast__icon { color: var(--negative); }
@media (min-width: 48rem) {
  .toasts { bottom: 1.5rem; }
}

/* ---------- Week progress and facts ---------- */

.progress-block__head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; }
.progress-block__label { font-weight: 600; }
.progress-block__value { font-size: 1.125rem; }

.progress {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 100%;
  height: 0.625rem;
  margin: 0.5rem 0 0.25rem;
  border: 0;
  border-radius: 999px;
  background: var(--track);
  overflow: hidden;
  color: var(--brand-strong);
}
.progress::-webkit-progress-bar { background: var(--track); border-radius: 999px; }
.progress::-webkit-progress-value { background: var(--brand-strong); border-radius: 999px; }
.progress::-moz-progress-bar { background: var(--brand-strong); border-radius: 999px; }

.facts { display: grid; }
.fact {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.4375rem 0;
  border-bottom: 1px solid var(--border);
}
.fact:last-child { border-bottom: 0; }
.fact__label { color: var(--muted); }
.fact__value { text-align: right; }
.fact--negative .fact__value { color: var(--negative); }
.fact--positive .fact__value { color: var(--positive); }

/* ---------- Week navigation and day list ---------- */

.weeknav {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.75rem;
}
.weeknav__label { display: flex; flex-direction: column; align-items: center; text-align: center; }
.weeknav__label span { color: var(--muted); font-size: 0.875rem; }
.weeknav__back { text-align: center; margin-top: 0.5rem; }

.days {
  list-style: none;
  margin: 1rem 0 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.day {
  display: grid;
  grid-template-columns: 1fr auto;
  grid-template-areas:
    "head actions"
    "body body";
  align-items: center;
  column-gap: 0.75rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  border-left: 4px solid transparent;
}
.day:last-child { border-bottom: 0; }
.day--today { border-left-color: var(--link); background: var(--accent-soft); }
.day--today .day__date { color: var(--link); }
.day--future .day__date { color: var(--muted); }
.day__head { grid-area: head; display: flex; align-items: center; gap: 0.5rem; min-height: 2.75rem; }
.day__date { font-weight: 700; }
.day__body { grid-area: body; min-width: 0; }
.day__shift { display: flex; align-items: baseline; justify-content: space-between; gap: 0.75rem; margin: 0; }
.day__times { font-size: 1.0625rem; }
.day__worked { font-size: 1.0625rem; }
.day__meta, .day__note, .day__empty { color: var(--muted); font-size: 0.875rem; margin: 0.125rem 0 0; }
.day__note { overflow-wrap: anywhere; }
.day__actions { grid-area: actions; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.375rem; }

.lock {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.75rem;
  min-height: 2.75rem;
  color: var(--muted);
}
.legend { display: flex; align-items: center; gap: 0.25rem; margin-top: 0.75rem; }

@media (max-width: 22rem) {
  .day { grid-template-areas: "head head" "body body" "actions actions"; }
  .day__actions { justify-content: flex-start; margin-top: 0.5rem; }
}

/* ---------- Konto lists ---------- */

.rows {
  list-style: none;
  margin: 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
}
.row:last-child { border-bottom: 0; }
.row__main { min-width: 0; overflow-wrap: anywhere; }
.row__side { display: grid; justify-items: end; text-align: right; white-space: nowrap; }
.signout { margin-top: 2rem; text-align: center; }

/* ---------- Closure card ---------- */

.closure__lost { margin-top: 0.5rem; }
.closure__split { margin-top: 0.5rem; }
.closure__preview {
  margin-top: 0.5rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 700;
}

/* ---------- Start time and Urlaub (v1.3) ---------- */

.running__start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem 0.75rem;
}
.card__head + .facts { margin-top: 0.25rem; }
.fact__sub { display: block; margin-top: 0.125rem; font-size: 0.8125rem; overflow-wrap: anywhere; }
.row--entry { flex-wrap: wrap; }
.row__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.375rem; margin-left: auto; }
.date-range { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
.date-range .field { margin-top: 0; }
.input--date { min-width: 0; font-size: 1.0625rem; }
.vacation-preview {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-top: 1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.vacation-preview--idle,
.vacation-preview--loading { color: var(--muted); font-weight: 400; }
.vacation-preview--short,
.vacation-preview--error { background: var(--warning-bg); color: var(--warning-text); }

@media (max-width: 22rem) {
  .date-range { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- Forms ---------- */

.form { display: block; }
.field { margin-top: 1rem; }
.field:first-child { margin-top: 0; }
.field__label { display: block; font-weight: 600; margin-bottom: 0.375rem; }
.field__hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0.375rem 0 0;
  color: var(--muted);
  font-size: 0.875rem;
}
.field__error { margin: 0.375rem 0 0; color: var(--negative); font-size: 0.875rem; font-weight: 600; }

.input {
  width: 100%;
  min-height: 3rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.input:focus-visible { border-color: var(--focus); }
.input--time { max-width: 10rem; font-size: 1.25rem; }
.input--number { width: 4.5rem; text-align: center; font-size: 1.25rem; }
.input--area { min-height: 4.5rem; resize: vertical; }
.input[aria-invalid="true"] { border-color: var(--negative); box-shadow: 0 0 0 1px var(--negative); }

.stepper { display: flex; align-items: center; gap: 0.5rem; }
.stepper__unit { color: var(--muted); }
.stepper__value { min-width: 6.5rem; text-align: center; font-size: 1.25rem; font-weight: 700; }
.stepper--days { margin: 0.75rem 0 0.25rem; }

.summary {
  display: grid;
  gap: 0.375rem;
  margin-top: 1.25rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.summary__row { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
.summary__label { color: var(--muted); }
.summary__value { font-size: 1.125rem; }

.reason {
  margin: 1rem 0 0;
  padding: 0.75rem;
  border: 1px solid var(--warning-border);
  border-radius: var(--radius-sm);
  background: var(--warning-bg);
  color: var(--warning-text);
}
.reason__legend { padding: 0 0.25rem; font-weight: 700; }
.reason .field__hint { color: inherit; }
.reason .field { margin-top: 0.75rem; }
.choices { display: grid; gap: 0.5rem; margin-top: 0.75rem; }
.choice {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.choice__input { width: 1.25rem; height: 1.25rem; margin: 0; accent-color: var(--brand-strong); }
.choice:has(.choice__input:checked) { border-color: var(--brand-strong); box-shadow: 0 0 0 1px var(--brand-strong); }

.more { margin-top: 1rem; }
.more > summary {
  display: flex;
  align-items: center;
  min-height: 2.75rem;
  color: var(--link);
  font-weight: 600;
  cursor: pointer;
}
.more > .field { margin-top: 0.25rem; }

/* ---------- Sheets (native <dialog>) ---------- */

dialog.sheet {
  width: 100%;
  max-width: 100%;
  max-height: 92vh;
  max-height: 92dvh;
  margin: auto 0 0;
  padding: 0;
  border: 1px solid var(--border);
  border-bottom: 0;
  border-radius: 1.25rem 1.25rem 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sheet);
  overflow: auto;
  overscroll-behavior: contain;
}
dialog.sheet[open] { animation: sheet-in 0.22s ease-out; }
/* ::backdrop inherits the custom properties only in current engines, hence the literal fallback. */
dialog.sheet::backdrop {
  background: var(--backdrop, rgba(58, 30, 36, 0.42));
  -webkit-backdrop-filter: blur(3px);
  backdrop-filter: blur(3px);
}
.sheet__inner { padding: 1.25rem 1rem calc(1rem + env(safe-area-inset-bottom)); }
.sheet__header { margin-bottom: 1rem; }
.sheet__title { font-size: 1.25rem; margin: 0; }
.sheet__subtitle { color: var(--muted); margin: 0.125rem 0 0; }
.sheet__text { margin: 0 0 0.5rem; }
.sheet__list { margin: 0 0 0.75rem; padding-left: 1.25rem; }
.sheet__actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 0.5rem; margin-top: 1.25rem; }
.sheet__actions .btn--danger-ghost { margin-right: auto; }
.sheet .fact { border-bottom: 0; padding: 0; }
.sheet .fact .fact__label { color: var(--text); font-weight: 600; }
.sheet .fact .fact__value { font-size: 1.25rem; }
/* Swipe down to close (ui.js swipeToClose): the sheet follows the finger, then springs back or slides out; the backdrop
   fades along where ::backdrop inherits custom properties (elsewhere it stays until the sheet is gone). */
dialog.sheet.is-dragging,
dialog.sheet.is-settling { transform: translateY(var(--sheet-drag, 0px)); }
dialog.sheet.is-settling { transition: transform 0.22s ease-out; }
dialog.sheet.is-dragging::backdrop,
dialog.sheet.is-settling::backdrop { opacity: var(--sheet-fade, 1); }
dialog.sheet.is-settling::backdrop { transition: opacity 0.22s ease-out; }

@media (min-width: 40rem) {
  dialog.sheet {
    width: min(32rem, calc(100% - 2rem));
    margin: auto;
    border-bottom: 1px solid var(--border);
    border-radius: 1.25rem;
    box-shadow: var(--shadow-float);
  }
  dialog.sheet[open] { animation: fade-in 0.15s ease-out; }
  .sheet__inner { padding: 1.5rem; }
}

/* ---------- Blocked (not linked / inactive) ---------- */

.blocked {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  min-height: calc(100vh - 6rem);
  min-height: calc(100dvh - 6rem);
  padding: 2rem 0.5rem;
  text-align: center;
}
.blocked__icon {
  width: 4.5rem;
  height: 4.5rem;
  padding: 1rem;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--link);
}
.blocked__title { font-size: 1.375rem; margin: 0.5rem 0 0; }
.blocked__text { color: var(--muted); max-width: 26rem; }
.blocked__actions { display: grid; gap: 0.75rem; width: min(20rem, 100%); margin-top: 1rem; }

/* ---------- Motion ---------- */

@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.35; } }
@keyframes sheet-in { from { transform: translateY(2rem); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes toast-in { from { transform: translateY(0.5rem); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
