/* Kulturbeutel Zeiterfassung: components from the approved draft (design/entwurf/quellen/components.css).
   Order: base, shell, page, lists, buttons, inputs, status, calendar, overlays, utilities. */

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--c-text);
  background: var(--c-bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
h1, h2, h3, h4, p, ul, ol, dl, figure { margin: 0; }
ul, ol { padding: 0; }
h1, h2, h3 { text-wrap: balance; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--c-accent-text); }
svg { flex: none; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: var(--focus-w) solid var(--c-focus);
  outline-offset: 2px;
}
[tabindex="-1"]:focus:not(:focus-visible) { outline: none; }
:is(h1, h2, h3, main)[tabindex="-1"]:focus { outline: none; }
.icon { width: 20px; height: 20px; display: inline-block; vertical-align: middle; }
.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* Hit area of at least 44 px without changing the layout */
.hit, .btn--sm, .toast-action, .link, .page-back {
  position: relative;
}
.hit::after, .btn--sm::after, .toast-action::after, .link::after, .page-back::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: max(100%, var(--hit));
  height: max(100%, var(--hit));
  transform: translate(-50%, -50%);
}

.skip-link {
  position: fixed; left: 12px; top: 8px; z-index: 300;
  display: inline-flex; align-items: center;
  min-height: var(--hit); padding: 0 16px; border-radius: var(--r-md);
  background: var(--c-accent); color: var(--c-on-accent); font-weight: 600; text-decoration: none;
  transform: translateY(-160%); transition: transform var(--dur-1);
}
.skip-link:focus-visible { transform: none; outline: var(--focus-w) solid var(--c-focus); outline-offset: 2px; }

/* ---------- Shell: sidebar, list and detail from 1024 px, tab bar below (container queries) ---------- */
.kb-app { container: kb-app / inline-size; height: 100vh; height: 100dvh; }
.shell {
  position: relative; isolation: isolate;
  height: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-areas: "main" "tabs";
  background: var(--c-bg); color: var(--c-text);
  --fs-body: 1.0625rem;
}
.sidebar { display: none; }
.app-main { grid-area: main; position: relative; min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; display: flex; flex-direction: column; }
.app-main:focus { outline: none; }
.app-main:has(> .split) { overflow: hidden; }

.tabbar {
  grid-area: tabs; position: relative; z-index: var(--z-chrome);
  display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr);
  padding: 0 max(4px, env(safe-area-inset-right, 0px)) env(safe-area-inset-bottom, 0px) max(4px, env(safe-area-inset-left, 0px));
  background: color-mix(in srgb, var(--c-elev) 90%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border-top: 1px solid var(--c-sep);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  min-height: 52px; padding-top: 5px;
  color: var(--c-text-2); text-decoration: none;
  font-size: var(--fs-caption2); font-weight: 500; letter-spacing: .01em;
  border-radius: var(--r-md);
}
.tab svg { width: 27px; height: 27px; }
.tab[aria-current="page"] { color: var(--c-accent-text); font-weight: 600; }
.tab[aria-current="page"] svg { stroke-width: 2; }
.tab .badge--count { position: absolute; top: 2px; left: calc(50% + 5px); }
.tab:focus-visible { outline-offset: -2px; }

@container kb-app (min-width: 1024px) {
  .shell {
    grid-template-columns: 248px minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "side main";
    --fs-body: 0.9375rem;
  }
  .sidebar {
    grid-area: side;
    display: flex; flex-direction: column; gap: var(--sp-5);
    min-height: 0; overflow-y: auto;
    padding: var(--sp-4) var(--sp-3) var(--sp-3);
    background: var(--c-sidebar);
    border-right: 1px solid var(--c-sep);
  }
  .tabbar { display: none; }
}
.sb-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 2px; }
.sb-logo { width: 34px; height: 34px; }
.sb-logo-bg { fill: var(--c-accent); }
.sb-logo-fg { fill: none; stroke: var(--c-on-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sb-name { display: block; font-size: 14px; font-weight: 650; line-height: 18px; letter-spacing: -.005em; }
.sb-sub { display: block; font-size: var(--fs-caption); color: var(--c-text-2); line-height: 16px; }
.sb-nav { display: flex; flex-direction: column; gap: 2px; }
.sb-nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.sb-item {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--hit); padding: 0 10px;
  border-radius: var(--r-md);
  color: var(--c-text); text-decoration: none;
  font-size: 15px; font-weight: 500;
  transition: background var(--dur-1);
}
.sb-item svg { width: 21px; height: 21px; color: var(--c-accent-text); }
.sb-item:hover { background: var(--c-hover); }
.sb-item[aria-current="page"] { background: var(--c-accent-tint); font-weight: 600; }
.sb-item .badge { margin-left: auto; }
.sb-foot { margin-top: auto; display: flex; flex-direction: column; gap: var(--sp-2); }
.sb-item--disabled { color: var(--c-text-3); cursor: not-allowed; align-items: flex-start; padding-block: 8px; }
.sb-item--disabled:hover { background: transparent; }
.sb-item--disabled svg { color: var(--c-text-3); margin-top: 1px; }
.sb-item--disabled small { display: block; font-size: var(--fs-caption); font-weight: 400; line-height: 16px; }
.sb-user {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--hit); padding: 10px; border-radius: var(--r-lg);
  background: var(--c-elev); box-shadow: var(--sh-1);
  color: var(--c-text); text-decoration: none;
  transition: background var(--dur-1);
}
a.sb-user:hover { background: var(--c-elev-2); }
.sb-user[aria-current="page"] { box-shadow: 0 0 0 2px var(--c-accent-text); }
.sb-user-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.sb-user-name { font-weight: 600; font-size: 14px; line-height: 18px; }
.sb-user-role { font-size: var(--fs-caption); color: var(--c-text-2); line-height: 16px; }
.sb-user-chev { width: 16px; height: 16px; color: var(--c-text-3); }
/* Below 1200 px the sidebar shows icons only, so list and detail keep their room */
@container kb-app (min-width: 1024px) and (max-width: 1199.98px) {
  .shell { grid-template-columns: 72px minmax(0, 1fr); }
  .sidebar { padding-inline: 10px; }
  .sb-brand { justify-content: center; padding-inline: 0; }
  .sb-brand > span, .sb-item > span, .sb-user-text, .sb-user-chev {
    position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
  }
  .sb-item { position: relative; justify-content: center; padding: 0; }
  .sb-item .badge { position: absolute; top: 3px; right: 3px; margin: 0; }
  .sb-item--disabled { padding-block: 0; align-items: center; }
  .sb-user { justify-content: center; padding: 8px 0; }
}

/* ---------- Split: list and detail ---------- */
.split { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; min-height: 0; }
.split-list, .split-detail { min-width: 0; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.split[data-mobile-pane="list"] > .split-detail, .split[data-mobile-pane="detail"] > .split-list { display: none; }
@container kb-app (min-width: 1024px) {
  .split { grid-template-columns: var(--split-list, 320px) minmax(0, 1fr); }
  .split[data-mobile-pane] > .split-list, .split[data-mobile-pane] > .split-detail { display: block; }
  .split-list { overflow: hidden; background: var(--c-elev); border-right: 1px solid var(--c-sep); }
  .split-detail { overflow: hidden; }
}

/* ---------- Page and pane: large title with navigation bar on phones, sticky header on desktop ---------- */
.page {
  --page-pad-left: max(16px, env(safe-area-inset-left, 0px));
  --page-pad-right: max(16px, env(safe-area-inset-right, 0px));
  display: grid;
  grid-template-columns: minmax(max-content, 1fr) minmax(0, auto) minmax(max-content, 1fr);
  column-gap: 4px;
  align-content: start;
  min-height: 100%;
  padding: 0 var(--page-pad-right) 28px var(--page-pad-left);
}
.page-top, .page-bar { display: contents; }
.page::before {
  content: ""; grid-area: 1 / 1 / 2 / -1;
  position: sticky; top: 0; z-index: 2;
  height: 44px; margin: 0 calc(-1 * var(--page-pad-right)) 0 calc(-1 * var(--page-pad-left));
  background: var(--c-bg);
  border-bottom: 1px solid transparent;
  transition: background var(--dur-2), border-color var(--dur-2);
}
.page.is-scrolled::before {
  background: color-mix(in srgb, var(--c-elev) 82%, transparent);
  -webkit-backdrop-filter: blur(20px) saturate(1.8);
  backdrop-filter: blur(20px) saturate(1.8);
  border-bottom-color: var(--c-sep);
}
.page-back {
  grid-area: 1 / 1; position: sticky; top: 0; z-index: 3; align-self: center; justify-self: start;
  display: inline-flex; align-items: center;
  min-height: 44px; padding-right: 8px; margin-left: -10px;
  color: var(--c-accent-text); text-decoration: none;
  font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.page-back svg { width: 24px; height: 24px; margin-right: -1px; }
.page-bartitle {
  grid-area: 1 / 2; position: sticky; top: 0; z-index: 3; align-self: center;
  min-width: 0; max-width: 230px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; font-weight: 600; line-height: 44px; text-align: center; letter-spacing: -.01em;
  opacity: 0; transition: opacity var(--dur-2);
}
.page.is-scrolled .page-bartitle { opacity: 1; }
.page-actions {
  grid-area: 1 / 3; justify-self: end; position: sticky; top: 0; z-index: 3;
  display: flex; align-items: center; gap: 2px; min-height: 44px; margin-right: -8px;
}
.page-title {
  grid-area: 2 / 1 / 3 / -1;
  padding: 2px 4px 0;
  font-size: var(--fs-large); line-height: var(--lh-large); font-weight: 700; letter-spacing: var(--tracking-large);
  overflow-wrap: anywhere;
}
.page--detail .page-title {
  grid-area: 1 / 2; position: sticky; top: 0; z-index: 3; align-self: center;
  min-width: 0; max-width: 230px; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 17px; line-height: 44px; font-weight: 600; text-align: center; letter-spacing: -.01em;
}
.page-sub { grid-column: 1 / -1; padding: 2px 4px 0; color: var(--c-text-2); font-size: 15px; }
.page-toolbar { grid-column: 1 / -1; display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; padding: var(--sp-3) 0 0; }
.page-body { grid-column: 1 / -1; display: flex; flex-direction: column; gap: var(--sp-6); min-width: 0; padding-top: var(--sp-4); }
.page-body > * { flex-shrink: 0; }
/* Full-width rows must not widen the max-content columns of the phone bar */
.page-title, .page-sub, .page-toolbar, .page-body { contain: inline-size; }
.page--detail .page-title { contain: none; }
/* Phone navigation bar: page actions are small buttons with a 44 px hit area, as in the draft */
@container kb-app (max-width: 1023.98px) {
  .page-actions .btn { min-height: var(--control-h-sm); min-width: var(--control-h-sm); padding: 0 12px; border-radius: var(--r-sm); font-size: var(--fs-subhead); }
  .page-actions .btn svg { width: 17px; height: 17px; }
  .page-actions .btn--icon { width: var(--control-h-sm); padding: 0; }
  .page-actions .btn::after {
    content: ""; position: absolute; left: 50%; top: 50%;
    width: max(100%, var(--hit)); height: max(100%, var(--hit));
    transform: translate(-50%, -50%);
  }
}

@container kb-app (min-width: 1024px) {
  .page { display: flex; flex-direction: column; padding: 0; }
  .page-title, .page-sub, .page-toolbar, .page-body { contain: none; }
  .page::before { content: none; }
  .page-top {
    position: sticky; top: 0; z-index: var(--z-sticky);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas: "back actions" "title actions" "sub actions";
    column-gap: var(--sp-4); row-gap: 2px;
    padding: 22px 32px 14px;
    background: color-mix(in srgb, var(--c-bg) 86%, transparent);
    -webkit-backdrop-filter: saturate(1.6) blur(16px);
    backdrop-filter: saturate(1.6) blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color var(--dur-2);
  }
  .page.is-scrolled .page-top { border-bottom-color: var(--c-sep); }
  .page--detail .page-title, .page-actions { position: static; }
  .page-back {
    grid-area: back; align-self: end; position: relative;
    gap: 2px; min-height: 28px; margin: 0; padding: 0;
    font-size: var(--fs-subhead); font-weight: 500;
  }
  .page-back svg { width: 16px; height: 16px; margin: 0; }
  .page-back--mobile { display: none; }
  .page-bartitle { display: none; }
  .page-title, .page--detail .page-title {
    grid-area: title; align-self: end; max-width: none; padding: 0;
    overflow: visible; white-space: normal; text-align: left;
    font-size: var(--fs-title1); line-height: var(--lh-title1); font-weight: 700; letter-spacing: var(--tracking-large);
  }
  .page-sub { grid-area: sub; padding: 0; font-size: var(--fs-subhead); }
  .page-actions { grid-area: actions; align-self: end; gap: var(--sp-2); flex-wrap: wrap; min-height: 0; margin: 0; }
  .page-toolbar { gap: var(--sp-3); padding: 0 32px 12px; }
  .page-body { gap: var(--sp-8); padding: 8px 32px 48px; }
  .page--narrow .page-body { max-width: 920px; }

  .page--pane { height: 100%; min-height: 0; }
  .page--pane .page-top { position: static; padding: 22px 24px 12px; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; border: 0; }
  .page--pane .page-title, .page--pane.page--detail .page-title { font-size: var(--fs-title2); line-height: var(--lh-title2); letter-spacing: var(--tracking-tight); }
  .page--pane .page-toolbar { padding: 0 24px 12px; }
  .page--pane .page-body { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 4px 24px 40px; gap: var(--sp-6); }
  .split-list .page--pane .page-top { padding-inline: 16px; }
  .split-list .page--pane .page-title { font-size: var(--fs-title1); line-height: var(--lh-title1); letter-spacing: var(--tracking-large); }
  .split-list .page--pane .page-toolbar { padding-inline: 16px; }
  .split-list .page--pane .page-body { padding: 0 8px 16px; gap: var(--sp-4); }
}

/* ---------- Sections and grouped lists ---------- */
.section { display: flex; flex-direction: column; gap: var(--sp-3); min-width: 0; }
.section-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--sp-1) var(--sp-3); min-height: 32px; }
.section-title { font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 700; letter-spacing: var(--tracking-tight); }
.group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.group-title {
  padding: 0 16px;
  font-size: var(--fs-footnote); font-weight: 500;
  letter-spacing: var(--tracking-caps); text-transform: uppercase;
  color: var(--c-text-2);
}
.group-foot { padding: 0 16px; font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text-2); }

.list { list-style: none; margin: 0; padding: 0; background: var(--c-elev); border-radius: var(--r-lg); overflow: hidden; box-shadow: var(--sh-1); }
.list > li { position: relative; }
.list > li + li::before {
  content: ""; position: absolute; z-index: 1; top: 0; right: 0;
  left: 16px; height: 1px; background: var(--c-sep); pointer-events: none;
}
.list > li:has(> .cell > .cell-lead)::before { left: calc(16px + var(--lead-w, 32px) + 12px); }
.cell {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  width: 100%; min-height: var(--hit);
  padding: 10px 16px;
  background: none; border: 0; border-radius: 0;
  color: inherit; text-align: left; text-decoration: none;
  font: inherit; font-size: var(--fs-body);
}
a.cell, button.cell, label.cell { cursor: pointer; transition: background var(--dur-1); -webkit-tap-highlight-color: transparent; }
a.cell:hover, button.cell:hover, label.cell:hover { background: var(--c-hover); }
a.cell:active, button.cell:active, label.cell:active { background: var(--c-pressed); }
.cell[aria-current="true"], .cell[aria-current="page"] { background: var(--c-accent-tint); }
.cell[aria-current="true"]:hover, .cell[aria-current="page"]:hover { background: var(--c-accent-tint-2); }
.cell:focus-visible { outline-offset: -2px; border-radius: inherit; z-index: 2; }
.cell-lead { flex: none; display: flex; align-items: center; justify-content: center; width: var(--lead-w, 32px); color: var(--c-accent-text); }
.cell-lead svg { width: 22px; height: 22px; }
.cell-tile { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; background: var(--c-accent-tint); color: var(--c-accent-text); }
.cell-tile svg { width: 18px; height: 18px; }
.cell-tile--warn { background: var(--c-warn-tint); color: var(--c-warn-text); }
.cell-tile--err { background: var(--c-err-tint); color: var(--c-err-text); }
.cell-tile--ok { background: var(--c-ok-tint); color: var(--c-ok-text); }
.cell-tile--info { background: var(--c-info-tint); color: var(--c-info-text); }
.cell-tile--neutral { background: var(--c-fill); color: var(--c-text-2); }
.cell-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cell-title { color: var(--c-text); line-height: 1.3; overflow-wrap: anywhere; }
.cell-sub { font-size: var(--fs-footnote); line-height: 1.35; color: var(--c-text-2); overflow-wrap: anywhere; }
.cell-trail { flex: none; display: flex; align-items: center; gap: 8px; max-width: 55%; color: var(--c-text-2); text-align: right; font-variant-numeric: tabular-nums; }
.cell-value { color: var(--c-text-2); }
.cell-chevron { width: 16px; height: 16px; flex: none; margin-right: -4px; color: var(--c-text-3); }
.cell--multiline { align-items: flex-start; }
.cell--multiline .cell-lead, .cell--multiline .cell-trail { padding-top: 1px; }
.cell--action .cell-title { color: var(--c-accent-text); font-weight: 500; }
.cell--destructive .cell-title { color: var(--c-err-text); font-weight: 500; }
.cell--disabled, .cell[aria-disabled="true"] { opacity: .55; cursor: not-allowed; }
.cell--disabled:hover, .cell[aria-disabled="true"]:hover { background: none; }
.list--source { background: transparent; border-radius: 0; box-shadow: none; overflow: visible; display: flex; flex-direction: column; gap: 2px; }
.list--source > li::before { display: none; }
.list--source .cell { border-radius: var(--r-md); padding: 8px 10px; min-height: 52px; }
.list--plain { background: transparent; border-radius: 0; box-shadow: none; }

/* ---------- Buttons ---------- */
.btn {
  --btn-bg: var(--c-fill);
  --btn-fg: var(--c-accent-text);
  position: relative;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: var(--control-h); min-width: var(--hit); padding: 0 16px;
  border: 0; border-radius: var(--r-md);
  background: var(--btn-bg); color: var(--btn-fg);
  font-size: var(--fs-body); font-weight: 600; line-height: 1.2;
  text-decoration: none; white-space: nowrap;
  transition: background var(--dur-1), transform var(--dur-1), opacity var(--dur-1);
  -webkit-tap-highlight-color: transparent;
}
.btn svg { width: 19px; height: 19px; }
.btn:hover { background: color-mix(in srgb, var(--btn-bg) 90%, var(--c-text)); }
.btn:active { transform: scale(.97); }
.btn--primary { --btn-bg: var(--c-accent); --btn-fg: var(--c-on-accent); }
.btn--primary:hover { background: var(--c-accent-hover); }
.btn--primary:active { background: var(--c-accent-press); }
.btn--secondary { --btn-bg: var(--c-accent-tint); --btn-fg: var(--c-accent-text); }
.btn--secondary:hover { background: var(--c-accent-tint-2); }
.btn--neutral { --btn-bg: var(--c-fill); --btn-fg: var(--c-text); }
.btn--plain { --btn-bg: transparent; padding: 0 10px; }
.btn--plain:hover { background: var(--c-hover); }
.btn--destructive { --btn-bg: var(--c-err-fill); --btn-fg: var(--c-on-err); }
.btn--destructive:hover { background: color-mix(in srgb, var(--c-err-fill) 88%, #000); }
.btn--destructive-secondary { --btn-bg: var(--c-err-tint); --btn-fg: var(--c-err-text); }
.btn--destructive-plain { --btn-bg: transparent; --btn-fg: var(--c-err-text); padding: 0 10px; }
.btn--destructive-plain:hover { background: var(--c-err-tint); }
.btn--sm { min-height: var(--control-h-sm); min-width: var(--control-h-sm); padding: 0 12px; border-radius: var(--r-sm); font-size: var(--fs-subhead); }
.btn--sm svg { width: 17px; height: 17px; }
.btn--lg { min-height: var(--control-h-lg); padding: 0 22px; border-radius: var(--r-lg); font-size: 17px; }
.btn--block { display: flex; width: 100%; }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: var(--control-h-sm); }
.btn--round { border-radius: var(--r-pill); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .45; cursor: not-allowed; transform: none; }
.btn[aria-busy="true"] { cursor: progress; }
.btn:disabled:hover, .btn[aria-disabled="true"]:hover { background: var(--btn-bg); }
.btn--hit { min-height: var(--hit); }
.btn--hit.btn--icon { width: var(--hit); }
.btn-row { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }
.btn-row--end { justify-content: flex-end; }
.btn-stack { display: flex; flex-direction: column; gap: var(--sp-2); }
.link {
  display: inline; padding: 0; border: 0; background: none;
  color: var(--c-accent-text); font: inherit; font-weight: 500;
  text-decoration: none; cursor: pointer;
}
.link:hover { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- Segmented control ---------- */
.seg {
  display: inline-flex; max-width: 100%; align-self: flex-start;
  padding: 2px; border-radius: 9px;
  background: var(--c-fill);
}
.seg-opt { position: relative; display: flex; flex: 1 1 auto; min-width: 0; }
.seg-opt input {
  position: absolute; left: 0; right: 0; top: 50%; z-index: 1;
  width: 100%; height: max(100%, var(--hit)); margin: 0;
  opacity: 0; cursor: pointer; transform: translateY(-50%);
}
.seg-opt span {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 32px; padding: 0 14px;
  border-radius: 7px;
  color: var(--c-text);
  font-size: var(--fs-subhead); font-weight: 500; white-space: nowrap;
  transition: background var(--dur-1), box-shadow var(--dur-1);
}
.seg-opt span svg { width: 17px; height: 17px; }
.seg-opt:hover input:not(:checked):not(:disabled) + span { background: var(--c-hover); }
.seg-opt input:checked + span { background: var(--c-seg-on); font-weight: 600; box-shadow: 0 1px 3px rgba(0, 0, 0, .14), inset 0 0 0 1px var(--c-control-border); }
.seg-opt input:focus-visible { outline: none; }
.seg-opt input:focus-visible + span { outline: var(--focus-w) solid var(--c-focus); outline-offset: 1px; }
.seg-opt input:disabled { cursor: not-allowed; }
.seg-opt input:disabled + span { opacity: .45; }
.seg--block { display: flex; width: 100%; align-self: stretch; }
.seg--block .seg-opt { flex: 1 1 0; }
.seg--lg .seg-opt span { min-height: 40px; font-size: var(--fs-body); }

/* ---------- Toggle (switch) ---------- */
.toggle { position: relative; display: inline-flex; flex: none; width: 51px; height: 31px; }
.toggle input {
  position: absolute; left: 0; top: 50%; z-index: 1;
  width: 100%; height: max(100%, var(--hit)); margin: 0;
  opacity: 0; cursor: pointer; transform: translateY(-50%);
}
.toggle-track {
  position: relative; width: 100%; height: 100%;
  border-radius: var(--r-pill);
  background: var(--c-fill-2);
  box-shadow: inset 0 0 0 1.5px var(--c-text-3);
  transition: background var(--dur-2), box-shadow var(--dur-2);
}
.toggle-track::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 27px; height: 27px; border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, .22), 0 0 0 .5px rgba(0, 0, 0, .1);
  transition: transform var(--dur-2) var(--ease);
}
.toggle input:checked + .toggle-track { background: var(--c-accent); box-shadow: none; }
.toggle input:checked + .toggle-track::after { transform: translateX(20px); }
.toggle input:focus-visible { outline: none; }
.toggle input:focus-visible + .toggle-track { outline: var(--focus-w) solid var(--c-focus); outline-offset: 2px; }
.toggle input:disabled + .toggle-track { opacity: .45; }
.toggle input:disabled { cursor: not-allowed; }
.toggle-row { display: inline-flex; align-items: center; gap: var(--sp-3); }

/* ---------- Form fields (native time and date inputs) ---------- */
.form { display: flex; flex-direction: column; gap: var(--sp-4); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { font-size: var(--fs-footnote); font-weight: 600; color: var(--c-text-2); }
.field-label .req { color: var(--c-err-text); font-weight: 600; }
.input {
  width: 100%; min-height: var(--control-h);
  padding: 10px 12px;
  border: 1px solid var(--c-control-border); border-radius: var(--r-md);
  background: var(--c-elev); color: var(--c-text);
  font-size: var(--fs-body); line-height: 1.3;
  transition: border-color var(--dur-1), box-shadow var(--dur-1);
}
.input::placeholder { color: var(--c-text-3); }
.input:focus-visible { outline: var(--focus-w) solid var(--c-focus); outline-offset: 2px; border-color: var(--c-accent-text); }
.input[aria-invalid="true"] { border-color: var(--c-err); border-width: 1.5px; }
.input[aria-invalid="true"]:focus-visible { border-color: var(--c-err); }
.input:disabled { background: var(--c-fill); color: var(--c-text-2); }
.input--time, .input--num { font-variant-numeric: tabular-nums; }
.input--time { max-width: 140px; }
.input--date { max-width: 160px; font-variant-numeric: tabular-nums; }
.input::-webkit-calendar-picker-indicator { cursor: pointer; }
.field-hint { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text-2); }
.field-error { display: flex; align-items: flex-start; gap: 5px; font-size: var(--fs-footnote); line-height: var(--lh-footnote); font-weight: 500; color: var(--c-err-text); }
.field-error svg { width: 16px; height: 16px; margin-top: 1px; }
.fields-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: var(--sp-3); }

/* ---------- Badges, avatars (shell chrome) ---------- */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  height: 22px; padding: 0 8px;
  border-radius: var(--r-pill);
  background: var(--c-fill); color: var(--c-text-2);
  font-size: var(--fs-caption); font-weight: 600; line-height: 1; white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.badge--count { min-width: 20px; height: 20px; padding: 0 6px; justify-content: center; background: var(--c-warn-fill); color: var(--c-on-warn); font-size: 12px; }
.avatar {
  --av: 36px;
  display: inline-grid; place-items: center; flex: none;
  width: var(--av); height: var(--av); border-radius: 50%;
  background: var(--av-1-bg); color: var(--av-1-fg);
  font-size: max(0.75rem, calc(var(--av) * .38)); font-weight: 650; letter-spacing: .02em; line-height: 1;
}
.avatar--sm { --av: 28px; }
.avatar--lg { --av: 56px; }
.avatar[data-hue="2"] { background: var(--av-2-bg); color: var(--av-2-fg); }
.avatar[data-hue="3"] { background: var(--av-3-bg); color: var(--av-3-fg); }
.avatar[data-hue="4"] { background: var(--av-4-bg); color: var(--av-4-fg); }
.avatar[data-hue="5"] { background: var(--av-5-bg); color: var(--av-5-fg); }
.avatar[data-hue="6"] { background: var(--av-6-bg); color: var(--av-6-fg); }

/* ---------- Badges and status ---------- */
.badge svg { width: 13px; height: 13px; }
.badge--ok { background: var(--c-ok-tint); color: var(--c-ok-text); }
.badge--warn { background: var(--c-warn-tint); color: var(--c-warn-text); }
.badge--err { background: var(--c-err-tint); color: var(--c-err-text); }
.badge--info { background: var(--c-info-tint); color: var(--c-info-text); }
.badge--indigo { background: var(--c-indigo-tint); color: var(--c-indigo-text); }
.badge--accent { background: var(--c-accent-tint); color: var(--c-accent-text); }
.badge--neutral { background: var(--c-fill); color: var(--c-text-2); }
.badge--outline { background: transparent; box-shadow: inset 0 0 0 1px var(--c-border); color: var(--c-text-2); }
.marks { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.status { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; color: var(--c-text); }
.dot { width: 9px; height: 9px; flex: none; border-radius: 50%; background: var(--dot, var(--c-neutral)); }
.dot--da, .dot--ok { --dot: var(--c-ok); }
.dot--pause { --dot: var(--c-info); }
.dot--feierabend { --dot: var(--c-indigo); }
.dot--abwesend { --dot: var(--c-neutral); }
.dot--frei, .dot--erwartet { background: transparent; box-shadow: inset 0 0 0 1.75px var(--c-neutral); }
.dot--warn { --dot: var(--c-warn); }
.dot--err { --dot: var(--c-err); }
.dot--lg { width: 12px; height: 12px; }

/* ---------- Key figures ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: var(--sp-3); }
.stats--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@container kb-app (max-width: 1023.98px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  position: relative; min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
  padding: 14px 16px 15px;
  border: 0; border-radius: var(--r-xl);
  background: var(--c-elev); color: inherit; box-shadow: var(--sh-1);
  font: inherit; text-align: left; text-decoration: none;
}
a.stat, button.stat { cursor: pointer; transition: background var(--dur-1); -webkit-tap-highlight-color: transparent; }
a.stat:hover, button.stat:hover { background: color-mix(in srgb, var(--c-elev) 94%, var(--c-text)); }
.stat-head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-2); min-height: 32px; margin: -6px -4px -4px 0; }
.stat-label { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: var(--fs-footnote); font-weight: 600; color: var(--c-text-2); }
.stat-label svg { width: 16px; height: 16px; }
.stat-value { font-size: 34px; line-height: 40px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; color: var(--c-text); overflow-wrap: anywhere; }
.stat-value small { font-size: 17px; font-weight: 600; letter-spacing: 0; color: var(--c-text-2); }
.stat-meta { font-size: var(--fs-footnote); color: var(--c-text-2); }
.stat--ok .stat-label svg { color: var(--c-ok); }
.stat--info .stat-label svg { color: var(--c-info); }
.stat--warn .stat-label svg { color: var(--c-warn); }
.stat--warn .stat-value { color: var(--c-warn-text); }
.stat--err .stat-label svg { color: var(--c-err); }
.stat--err .stat-value { color: var(--c-err-text); }
.stat--accent .stat-label svg { color: var(--c-accent-text); }
.stat--positive .stat-value { color: var(--c-ok-text); }
.stat--compact .stat-value { font-size: 24px; line-height: 30px; }
.stat--large .stat-value { font-size: 52px; line-height: 58px; letter-spacing: -.03em; }
.stat--large .stat-value small { margin-left: 2px; font-size: 22px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 1px; margin: 0; border-radius: var(--r-lg); overflow: hidden; background: var(--c-sep); box-shadow: var(--sh-1); }
.kpi { display: flex; flex-direction: column; gap: 2px; padding: 12px 16px; background: var(--c-elev); min-width: 0; }
.kpi > dd { margin: 0; }
.kpi-label { font-size: var(--fs-footnote); color: var(--c-text-2); font-weight: 500; }
.kpi-value { font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 700; font-variant-numeric: tabular-nums; }
.kpi-meta { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text-2); }
@container kb-app (max-width: 1023.98px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:last-child:nth-child(odd) { grid-column: 1 / -1; }
}

/* ---------- Banners ---------- */
.banner {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 16px; border-radius: var(--r-lg);
  background: var(--c-fill); color: var(--c-text);
}
.banner-icon { flex: none; width: 22px; height: 22px; margin-top: 1px; color: var(--c-text-2); }
.banner-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.banner-title { font-weight: 600; }
.banner-text { font-size: var(--fs-subhead); color: var(--c-text); }
.banner-action { flex: none; align-self: center; }
.banner-action .btn { min-height: var(--hit); }
.banner--warn { background: var(--c-warn-tint); }
.banner--warn .banner-icon { color: var(--c-warn-text); }
.banner--err { background: var(--c-err-tint); }
.banner--err .banner-icon { color: var(--c-err-text); }
.banner--info { background: var(--c-info-tint); }
.banner--info .banner-icon { color: var(--c-info-text); }
.banner--ok { background: var(--c-ok-tint); }
.banner--ok .banner-icon { color: var(--c-ok-text); }
.banner--accent { background: var(--c-accent-tint); }
.banner--accent .banner-icon { color: var(--c-accent-text); }
.banner--warn .link { color: var(--c-warn-text); }

/* ---------- Empty states ---------- */
.empty { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 40px 24px; text-align: center; color: var(--c-text-2); }
.empty-icon { display: grid; place-items: center; width: 60px; height: 60px; margin-bottom: 4px; border-radius: 50%; background: var(--c-fill); color: var(--c-text-2); }
.empty-icon svg { width: 28px; height: 28px; }
.empty-title { font-size: var(--fs-headline); font-weight: 600; color: var(--c-text); }
.empty-text { max-width: 38ch; font-size: var(--fs-subhead); }
.empty .btn { margin-top: 8px; }
.empty--card { background: var(--c-elev); border-radius: var(--r-xl); box-shadow: var(--sh-1); }

/* ---------- Day timeline: opening hours as a track, work, pause and absence as segments, now line ---------- */
.dtl { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.dtl-axis, .dtl-strip { display: block; width: 100%; overflow: visible; }
.dtl-axis { height: 14px; }
.dtl-axis text { font-size: var(--fs-caption2); font-weight: 500; fill: var(--c-text-3); }
.dtl-strip { height: 24px; }
.dtl-tick { stroke: var(--c-sep); stroke-width: 1; }
.dtl-open { fill: var(--c-fill-2); }
/* Each segment sits in its own box; the bar keeps a 1 px gap to its neighbours and stays at least 4 px wide */
.dtl-seg-box { overflow: visible; }
.dtl-seg { x: 1px; width: max(4px, calc(100% - 2px)); fill: var(--c-ok); }
.dtl-seg--pause { fill: var(--c-info); }
.dtl-seg--absence { fill: var(--c-text-3); }
.dtl-seg--open { fill: var(--c-warn-tint); stroke: var(--c-warn-text); stroke-width: 1.5; stroke-dasharray: 4 3; }
.dtl-now { stroke: var(--c-text); stroke-width: 2; stroke-linecap: round; opacity: .7; }
.dtl-note { font-size: var(--fs-footnote); color: var(--c-text-2); }
.dtl-legend { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; font-size: var(--fs-footnote); color: var(--c-text-2); }
.dtl-legend > span { display: inline-flex; align-items: center; gap: 6px; }
.dtl-key { display: inline-block; width: 14px; height: 8px; border-radius: 4px; background: var(--c-ok); }
.dtl-key--pause { background: var(--c-info); }
.dtl-key--absence { background: var(--c-text-3); }
.dtl-key--open { background: var(--c-warn-tint); box-shadow: inset 0 0 0 1.5px var(--c-warn-text); }
.dtl-key--now { width: 2px; height: 14px; border-radius: 1px; background: var(--c-text); opacity: .7; }

/* ---------- Booking timeline: the bookings of one day ---------- */
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.tl-item {
  position: relative;
  display: grid; grid-template-columns: 52px 30px minmax(0, 1fr) auto; column-gap: 12px; align-items: start;
  padding: 8px 0;
}
.tl-item::before { content: ""; position: absolute; left: calc(52px + 12px + 14px); top: 0; bottom: 0; width: 2px; background: var(--c-sep); }
.tl-item:first-child::before { top: 23px; }
.tl-item:last-child::before { bottom: calc(100% - 23px); }
.tl-item:only-child::before { display: none; }
.tl-time { padding-top: 4px; text-align: right; font-size: var(--fs-headline); font-weight: 600; font-variant-numeric: tabular-nums; line-height: 22px; }
.tl-mark {
  position: relative; z-index: 1;
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--c-elev); color: var(--mk, var(--c-accent-text));
  box-shadow: inset 0 0 0 2px var(--mk, var(--c-accent-text));
}
.tl-mark svg { width: 16px; height: 16px; }
.tl-mark--kommen { --mk: var(--c-ok); }
.tl-mark--pause, .tl-mark--pause_ende { --mk: var(--c-info); }
.tl-mark--gehen { --mk: var(--c-indigo); }
.tl-main { min-width: 0; display: flex; flex-direction: column; gap: 3px; padding-top: 3px; }
.tl-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tl-kind { font-weight: 600; line-height: 22px; }
.tl-meta { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text-2); }
.tl-old { color: var(--c-text-3); text-decoration: line-through; text-decoration-thickness: 1.5px; }
.tl-reason { margin-top: 2px; padding: 7px 10px; border-radius: var(--r-sm); background: var(--c-fill); font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text); }
.tl-reason b { font-weight: 600; }
.tl-trail { padding-top: 1px; }
.tl-item.is-void .tl-time, .tl-item.is-void .tl-kind { color: var(--c-text-3); text-decoration: line-through; }
.tl-item.is-pending .tl-mark { box-shadow: inset 0 0 0 2px var(--mk), 0 0 0 3px var(--c-elev), 0 0 0 4px var(--c-sep); }
@container kb-app (max-width: 1023.98px) {
  .tl-item { grid-template-columns: 46px 28px minmax(0, 1fr) auto; column-gap: 10px; }
  .tl-item::before { left: calc(46px + 10px + 13px); }
  .tl-mark { width: 28px; height: 28px; }
}

/* ---------- Balance in lists ---------- */
.saldo { font-variant-numeric: tabular-nums; font-weight: 600; }
.saldo--pos { color: var(--c-ok-text); }

/* ---------- Month navigation ---------- */
.month-nav { display: inline-flex; align-items: center; gap: 2px; }
.month-nav-label { min-width: 148px; padding: 0 4px; text-align: center; font-size: var(--fs-headline); font-weight: 600; font-variant-numeric: tabular-nums; }

.month-nav-card { flex: 1; min-width: 0; }
.month-nav-card .month-nav {
  display: flex; width: 100%; justify-content: space-between;
  padding: 4px; border-radius: var(--r-lg);
  background: var(--c-elev); box-shadow: var(--sh-1);
}
.month-nav-card .month-nav-label { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; border-radius: var(--r-lg); background: var(--c-elev); box-shadow: var(--sh-1); }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: var(--fs-subhead); font-variant-numeric: tabular-nums; }
.table th {
  position: sticky; top: 0; z-index: 1;
  padding: 10px 12px;
  background: var(--c-elev);
  border-bottom: 1px solid var(--c-sep);
  color: var(--c-text-2); font-size: var(--fs-footnote); font-weight: 600; text-align: left; white-space: nowrap;
}
.table td { height: 44px; padding: 8px 12px; border-bottom: 1px solid var(--c-sep); vertical-align: middle; white-space: nowrap; }
.table tbody th[scope="row"] { position: static; height: 44px; padding: 8px 12px; background: none; color: var(--c-text); font-size: inherit; font-weight: 500; border-bottom: 1px solid var(--c-sep); }
.table tbody tr:last-child th[scope="row"] { border-bottom: 0; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num { text-align: right; }
.table tbody tr { position: relative; transition: background var(--dur-1); }
.table tbody tr:hover > * { background: var(--c-hover); }
.table tbody tr.is-rest > * { background: color-mix(in srgb, var(--c-fill) 55%, transparent); color: var(--c-text-2); }
.table tr.is-future td { color: var(--c-text-3); }
.table tbody tr.is-today > :first-child { box-shadow: inset 3px 0 0 var(--c-accent); }
.table tbody tr.is-selected > * { background: var(--c-accent-tint); }
.table .row-link { color: inherit; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; min-height: 28px; }
/* The whole row is the hit area: the link spans the row, other controls sit above it */
.table .row-link::after { content: ""; position: absolute; inset: 0; }
.table td :is(a:not(.row-link), button, input, select, label) { position: relative; z-index: 1; }
.table .row-link:hover { color: var(--c-accent-text); text-decoration: underline; text-underline-offset: 2px; }
.table .marks { display: flex; gap: 4px; flex-wrap: wrap; }
.text-warn { color: var(--c-warn-text); }

/* ---------- Month table (lead): table from 1024 px, day list below; Kommen and Gehen share a column in a narrow pane ---------- */
.mt { container: mt / inline-size; min-width: 0; }
.mt > .mt-days { display: none; }
@container kb-app (max-width: 1023.98px) {
  .mt > .mt-table { display: none; }
  .mt > .mt-days { display: block; }
}
.mt-c-span, .mt-c-narrow { display: none; }
@container mt (max-width: 760px) {
  .mt-table :is(.mt-c-in, .mt-c-out, .mt-c-wide) { display: none; }
  .mt-table :is(.mt-c-span, .mt-c-narrow) { display: table-cell; }
  .mt-table td:last-child { white-space: normal; }
  .mt-table :is(td, th) { padding-inline: 8px; }
  .mt-table .marks .badge { padding-inline: 6px; }
  .mt-table .marks .badge .icon { margin: 0; }
  .mt-table .marks .badge-text, .mt-mk-wide { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
}
.mt-zero { color: var(--c-text-3); }
.mt-table .mt-gap { color: var(--c-text-2); }
.mt-missing { display: inline-flex; align-items: center; gap: 4px; color: var(--c-warn-text); font-weight: 600; }
.mt-missing svg { width: 16px; height: 16px; }
.mt-table tfoot th,
.mt-table tfoot td {
  position: static;
  height: 48px; padding: 10px 12px;
  border-top: 1px solid var(--c-border); border-bottom: 0;
  background: var(--c-elev);
  color: var(--c-text); font-size: var(--fs-subhead); font-weight: 600; text-align: left; white-space: nowrap;
}
.mt-table tfoot .num { text-align: right; }
.mt-table tfoot .mt-foot-note { color: var(--c-text-2); font-size: var(--fs-footnote); font-weight: 500; }
.mt-days { --lead-w: 38px; }
.mt-date {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  width: 38px; height: 42px; border-radius: var(--r-md);
  color: var(--c-text); line-height: 1;
}
.mt-date-wd { font-size: var(--fs-caption2); font-weight: 600; letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--c-text-2); }
.mt-date-n { margin-top: 3px; font-size: 19px; font-weight: 600; font-variant-numeric: tabular-nums; }
.mt-date.is-rest .mt-date-n { color: var(--c-text-2); }
.mt-date.is-today { background: var(--c-accent); color: var(--c-on-accent); }
.mt-date.is-today :is(.mt-date-wd, .mt-date-n) { color: var(--c-on-accent); }
.mt-free .cell-title { color: var(--c-text-2); }
.mt-cellsub { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 2px; }
.mt-cellsub .marks { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.mt-trail { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.mt-trail-ist { color: var(--c-text); font-weight: 600; }
.mt-trail-diff { font-size: var(--fs-footnote); }
.mt-pinmark .icon { width: 13px; height: 13px; }

/* ---------- Own month (person): weeks with day cells, free days as thin rows ---------- */
.md { display: flex; flex-direction: column; gap: var(--sp-6); min-width: 0; }
.md-weekhead { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); padding: 0 16px; }
.md-weekhead .group-title { padding: 0; }
.md-weekhead-sum { font-size: var(--fs-footnote); font-weight: var(--fw-semibold); color: var(--c-text-2); }
.md-days { --lead-w: 40px; }
.md-daycell { align-items: center; padding-block: 9px; }
.md-daycell .cell-trail { padding-top: 0; }
.md-daycell .cell-title { font-variant-numeric: tabular-nums; font-weight: var(--fw-medium); }
.md-date { display: flex; flex-direction: column; align-items: center; gap: 2px; width: 40px; line-height: 1; color: var(--c-text); }
.md-date-wd { font-size: var(--fs-caption2); font-weight: var(--fw-semibold); letter-spacing: var(--tracking-caps); text-transform: uppercase; color: var(--c-text-2); }
.md-date-num { display: grid; place-items: center; min-width: 30px; height: 26px; border-radius: var(--r-pill); font-size: var(--fs-headline); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; }
.md-date.is-rest .md-date-num { color: var(--c-text-2); }
.md-date.is-today .md-date-wd { color: var(--c-accent-text); }
.md-date.is-today .md-date-num { background: var(--c-accent); color: var(--c-on-accent); }
.md-sub { display: flex; align-items: center; gap: 4px 8px; flex-wrap: wrap; margin-top: 2px; }
.md-marks { display: inline-flex; align-items: center; gap: 4px; flex-wrap: wrap; }
.md-trail { display: flex; flex-direction: column; align-items: flex-end; gap: 1px; }
.md-trail-ist { font-size: var(--fs-body); font-weight: var(--fw-semibold); color: var(--c-text); }
.md-trail-ist.subtle { color: var(--c-text-3); font-weight: var(--fw-medium); }
.md-trail-diff { font-size: var(--fs-footnote); color: var(--c-text-2); }
.md-free { display: flex; align-items: center; gap: var(--sp-3); min-height: 32px; padding: 4px var(--sp-4); background: var(--c-fill); color: var(--c-text-2); font-size: var(--fs-footnote); }
.md-free-date { width: 40px; flex: none; text-align: center; font-size: var(--fs-caption); font-weight: var(--fw-semibold); font-variant-numeric: tabular-nums; color: var(--c-text-2); }

/* ---------- Sheet (<dialog>) ---------- */
.sheet {
  position: fixed; inset: auto; z-index: calc(var(--z-sheet) + 1);
  display: flex; flex-direction: column;
  margin: 0; padding: 0; border: 0;
  max-width: none; max-height: none; overflow: hidden;
  background: var(--c-elev-2); color: var(--c-text);
  box-shadow: var(--sh-3);
  left: 50%; top: 50%;
  width: min(var(--sheet-w, 520px), calc(100% - 48px));
  max-height: calc(100% - 64px);
  border-radius: var(--r-xl);
  opacity: 0; transform: translate(-50%, -47%) scale(.98);
  transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.sheet:not([open]) { display: none; }
.sheet.is-open { opacity: 1; transform: translate(-50%, -50%); }
.sheet::backdrop { background: rgba(8, 20, 22, 0.36); background: var(--c-overlay); opacity: 0; transition: opacity var(--dur-2); }
.sheet.is-open::backdrop { opacity: 1; }
.sheet--sm { --sheet-w: 420px; }
.sheet--lg { --sheet-w: 680px; }
.sheet--xl { --sheet-w: 860px; }
.sheet.is-closing { pointer-events: none; }
.sheet-grabber { display: none; flex: none; width: 36px; height: 5px; margin: 6px auto 0; border-radius: 3px; background: var(--c-fill-2); }
.sheet-head { flex: none; display: flex; align-items: center; gap: var(--sp-3); padding: 18px 20px 6px; }
.sheet-title { flex: 1; min-width: 0; font-size: var(--fs-title3); line-height: var(--lh-title3); font-weight: 700; letter-spacing: var(--tracking-tight); }
.sheet-close { flex: none; margin: -4px -6px -4px 0; --btn-fg: var(--c-text-2); }
.sheet-close svg { width: 16px; height: 16px; }
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: var(--sp-4); padding: 10px 20px 20px; }
.sheet-body > * { flex-shrink: 0; }
.sheet-foot { flex: none; display: flex; justify-content: flex-end; gap: var(--sp-2); padding: 14px 20px 18px; border-top: 1px solid var(--c-sep); }
.sheet-lead { color: var(--c-text-2); font-size: var(--fs-subhead); }
.sheet-hero { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0 4px; text-align: center; }
.sheet-hero-icon { display: grid; place-items: center; width: 64px; height: 64px; border-radius: 50%; background: var(--c-accent-tint); color: var(--c-accent-text); }
.sheet-hero-icon svg { width: 32px; height: 32px; }
.sheet-hero-icon--ok { background: var(--c-ok-tint); color: var(--c-ok-text); }
.sheet-hero-icon--warn { background: var(--c-warn-tint); color: var(--c-warn-text); }
.sheet-hero-title { font-size: var(--fs-headline); font-weight: 600; }
.sheet-hero-text { max-width: 36ch; color: var(--c-text-2); font-size: var(--fs-subhead); }
.sheet-error { color: var(--c-err-text); font-size: var(--fs-subhead); font-weight: 500; }
@media (max-width: 1023.98px) {
  .sheet {
    left: 0; right: 0; top: auto; bottom: 0; width: 100%;
    max-height: calc(100% - 54px);
    padding: 0 env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px);
    border-radius: 14px 14px 0 0;
    opacity: 1; transform: translateY(100%);
    transition: transform var(--dur-3) var(--ease-out);
  }
  .sheet.is-open { transform: none; }
  .sheet-grabber { display: block; }
  .sheet-head { padding: 10px 16px 4px; }
  .sheet-body { padding: 8px 16px 16px; }
  .sheet-foot { flex-direction: column-reverse; padding: 12px 16px 16px; border-top: 0; }
  .sheet-foot .btn { width: 100%; min-height: 50px; font-size: 17px; }
}

/* ---------- Toast ---------- */
.toast-region {
  position: fixed; left: 0; right: 0; bottom: var(--toast-bottom, 24px); z-index: var(--z-toast);
  display: flex; justify-content: center;
  padding: 0 max(16px, env(safe-area-inset-right, 0px)) 0 max(16px, env(safe-area-inset-left, 0px)); pointer-events: none;
  --toast-bottom: calc(52px + 16px + env(safe-area-inset-bottom, 0px));
}
@media (min-width: 1024px) {
  .toast-region { --toast-bottom: 24px; }
}
.toast {
  position: relative; overflow: hidden; pointer-events: auto;
  display: flex; align-items: center; gap: 10px;
  max-width: min(540px, 100%); min-height: 50px;
  padding: 6px 6px 6px 16px;
  border-radius: 14px;
  background: var(--c-toast-bg); color: var(--c-toast-fg);
  box-shadow: var(--sh-2);
  font-size: var(--fs-subhead); font-weight: 500;
  opacity: 0; transform: translateY(14px) scale(.98);
  transition: opacity var(--dur-2), transform var(--dur-2) var(--ease-out);
}
.toast.is-in { opacity: 1; transform: none; }
.toast.is-out { opacity: 0; transform: translateY(8px); }
.toast > svg { width: 20px; height: 20px; color: var(--c-toast-action); }
.toast-msg { flex: 1; min-width: 0; padding: 6px 0; }
.toast-action {
  flex: none; min-height: 38px; padding: 0 12px;
  border: 0; border-radius: 10px;
  background: transparent; color: var(--c-toast-action);
  font-weight: 650;
}
.toast-action:hover { background: color-mix(in srgb, var(--c-toast-fg) 10%, transparent); }
.toast-action:focus-visible { outline-color: var(--c-toast-action); outline-offset: 0; }
.toast-progress {
  position: absolute; left: 0; bottom: 0; height: 2px; width: 100%;
  background: var(--c-toast-action); opacity: .55; transform-origin: left center;
}
.toast-kbd { display: none; margin-left: 8px; padding: 1px 5px; border-radius: 5px; border: 1px solid color-mix(in srgb, var(--c-toast-action) 45%, transparent); font: 600 var(--fs-caption)/1.3 var(--font); color: var(--c-toast-action); }
@media (min-width: 1024px) {
  .toast-kbd { display: inline; }
}
.has-toast .app-main { scroll-padding-bottom: 96px; }
@media (prefers-reduced-motion: reduce) { .toast-progress { opacity: 0; } }

/* ---------- Request indicators (htmx includeIndicatorStyles is off) ---------- */
.htmx-indicator { opacity: 0; visibility: hidden; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; visibility: visible; transition: opacity 200ms ease-in; }

/* ---------- Motion ---------- */
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pop { 0% { transform: scale(.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
.spinner { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: spin .8s linear infinite; }
.pop-in { animation: pop var(--dur-3) var(--ease-out); }
@media (prefers-reduced-motion: reduce) {
  .pop-in { animation: none; }
  .spinner { animation-duration: 2.4s; }
}

/* ---------- Sign-in, invitation and onboarding (draft B1) ---------- */
.auth { display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh; max-width: 520px; margin: 0 auto; }
.auth-scroll { flex: 1 0 auto; display: flex; flex-direction: column; gap: var(--sp-8); padding: 20px max(24px, env(safe-area-inset-right, 0px)) 16px max(24px, env(safe-area-inset-left, 0px)); }
.auth-scroll--center { justify-content: center; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: var(--fs-subhead); font-weight: var(--fw-semibold); color: var(--c-text-2); }
.auth-brand .sb-logo { width: 32px; height: 32px; }
.auth-intro { display: flex; flex-direction: column; gap: var(--sp-2); }
.auth-hello { font-size: 40px; line-height: 46px; font-weight: var(--fw-bold); letter-spacing: -0.025em; }
.auth-lead { font-size: var(--fs-callout); line-height: 1.45; color: var(--c-text-2); }
.auth-features { list-style: none; display: flex; flex-direction: column; gap: 20px; }
.auth-features > li { display: flex; align-items: flex-start; gap: 14px; }
.auth-feature-icon { display: grid; place-items: center; flex: none; width: 42px; height: 42px; border-radius: var(--r-lg); background: var(--c-accent-tint); color: var(--c-accent-text); }
.auth-feature-icon .icon { width: 22px; height: 22px; }
.auth-feature-title { font-size: var(--fs-body); font-weight: var(--fw-semibold); }
.auth-feature-text { font-size: var(--fs-subhead); color: var(--c-text-2); }
.auth-foot { flex: none; display: flex; flex-direction: column; gap: 10px; padding: 12px max(24px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(24px, env(safe-area-inset-left, 0px)); }
.auth-fine { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-text-2); text-align: center; }
.auth-status { font-size: var(--fs-footnote); line-height: var(--lh-footnote); color: var(--c-err-text); text-align: center; }
.auth-hero { display: flex; flex-direction: column; align-items: center; gap: 12px; padding-top: var(--sp-10); text-align: center; }
.auth-check { display: grid; place-items: center; width: 88px; height: 88px; margin-bottom: 8px; border-radius: 50%; background: var(--c-ok-tint); color: var(--c-ok-text); }
.auth-check .icon { width: 44px; height: 44px; }
.auth-check--warn { background: var(--c-warn-tint); color: var(--c-warn-text); }
.auth-title { font-size: var(--fs-title1); line-height: var(--lh-title1); font-weight: var(--fw-bold); letter-spacing: var(--tracking-large); }
.auth-note { font-size: var(--fs-footnote); color: var(--c-text-2); }
.auth-signin { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.auth-signin .sb-logo { width: 76px; height: 76px; margin-bottom: 14px; }
.auth-state { display: inline-flex; align-items: center; gap: 6px; margin-top: var(--sp-5); padding: 6px 12px; border-radius: var(--r-pill); background: var(--c-ok-tint); color: var(--c-ok-text); font-size: var(--fs-footnote); font-weight: var(--fw-semibold); }
.auth-state .icon { width: 18px; height: 18px; }
.auth-facts { width: 100%; text-align: left; }

/* ---------- Utilities ---------- */
.stack { display: flex; flex-direction: column; gap: var(--sp-4); min-width: 0; }
.stack--sm { gap: var(--sp-2); }
.stack--lg { gap: var(--sp-6); }
.row { display: flex; align-items: center; gap: var(--sp-3); flex-wrap: wrap; min-width: 0; }
.muted { color: var(--c-text-2); }
.subtle { color: var(--c-text-3); }
.num { font-variant-numeric: tabular-nums; }
.strong { font-weight: 600; }
.small { font-size: var(--fs-footnote); line-height: var(--lh-footnote); }

/* ---------- Busy buttons, toast icons ---------- */
.btn > .spinner { display: none; }
.btn[aria-busy="true"] > .spinner { display: inline-block; }
.btn[aria-busy="true"] > .icon { display: none; }
.toast-icon--undo { display: none; }
.toast--undone .toast-icon--done { display: none; }
.toast--undone .toast-icon--undo { display: inline-block; }

/* ---------- Forced colours (Windows contrast mode) ---------- */
@media (forced-colors: active) {
  .btn, .sheet { border: 1px solid ButtonText; }
  .sheet { border-color: CanvasText; }
  .tab[aria-current="page"], .sb-item[aria-current="page"], .cell[aria-current="true"], .cell[aria-current="page"] { outline: 2px solid Highlight; outline-offset: -2px; }
  .seg, .toggle-track, .badge, .banner, .stat, .kpis, .table-wrap, .month-nav-card .month-nav { border: 1px solid CanvasText; }
  .seg-opt input:checked + span, .table tbody tr.is-selected > th { outline: 2px solid Highlight; outline-offset: -2px; }
  .toggle input:checked + .toggle-track { background: Highlight; }
  .toggle-track::after { background: ButtonText; }
  .dot, .dtl-key { forced-color-adjust: none; border: 1px solid CanvasText; }
  .tl-mark { border: 2px solid CanvasText; }
  .table tbody tr.is-today > :first-child { border-left: 3px solid Highlight; }
  .mt-date.is-today, .md-date.is-today .md-date-num { forced-color-adjust: none; background: Highlight; color: HighlightText; }
  .mt-date.is-today :is(.mt-date-wd, .mt-date-n) { color: HighlightText; }
  .md-free { border-block: 1px solid CanvasText; }
}

