/* =========================================================================
   App styles. Sections: base · shell · page · buttons · forms · filters ·
   table · badges · load · absences · stats/cards · dialog · alerts · empty ·
   pager · layout utils · login · error · styleguide
   Module CSS goes to <app>/static/<app>/<app>.css and only uses tokens.
   ========================================================================= */

/* ---------------------------------------------------------------- base */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  font-family: var(--font-sans); font-size: var(--fs-md); line-height: var(--lh-body);
  color: var(--color-text); background: var(--color-bg);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: var(--lh-tight); font-weight: var(--fw-bold); letter-spacing: -0.01em; }
h1 { font-size: var(--fs-2xl); }
h2 { font-size: var(--fs-xl); }
h3 { font-size: var(--fs-lg); }
h4 { font-size: var(--fs-md); }
p { margin: 0 0 var(--sp-3); }
p:last-child { margin-bottom: 0; }
a { color: var(--color-primary); text-underline-offset: 2px; }
a:hover { color: var(--color-primary-hover); }
small { font-size: var(--fs-sm); }
code, pre { font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: .875em; }
hr { border: 0; border-top: 1px solid var(--color-border); margin: var(--sp-6) 0; }
:focus-visible { outline: 3px solid var(--color-focus); outline-offset: 2px; border-radius: 3px; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.icon {
  width: 1.2em; height: 1.2em; flex: none; vertical-align: -0.24em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.lead { font-size: var(--fs-lg); color: var(--color-text-2); max-width: 70ch; margin-top: var(--sp-2); }
.muted { color: var(--color-text-3); }
.num, .date { font-variant-numeric: tabular-nums; white-space: nowrap; }  /* .num = quantities (right-aligned in tables), .date = dates (left) */
.nowrap { white-space: nowrap; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: var(--sp-4); top: -60px; z-index: 100; padding: var(--sp-2) var(--sp-4);
  background: var(--color-surface); border-radius: var(--r-sm); box-shadow: var(--shadow-2); }
.skip-link:focus { top: var(--sp-4); }
[hidden] { display: none !important; }

/* ---------------------------------------------------------------- shell */
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100vh; }
.rail {
  position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column;
  background: var(--c-scrub-800); color: #dcece9;
  background-image: linear-gradient(180deg, var(--c-scrub-800) 0%, var(--c-scrub-900) 100%);
  padding: var(--sp-5) 0 var(--sp-4) var(--sp-3);
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: var(--sp-3); padding: 0 var(--sp-3) var(--sp-6) var(--sp-2);
  color: #fff; text-decoration: none; }
.brand:hover { color: #fff; }
.brand__mark { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 12px;
  background: #f2faf8; color: var(--c-scrub-800); }
.brand__mark .icon { width: 24px; height: 24px; stroke-width: 1.9; }
.brand__mark--lg { width: 56px; height: 56px; border-radius: 16px; background: var(--c-scrub-800); color: #f2faf8; }
.brand__mark--lg .icon { width: 32px; height: 32px; }
.brand__text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand__text strong { font-size: var(--fs-lg); letter-spacing: .01em; }
.brand__text span { font-size: var(--fs-xs); color: #a9cbc6; }

.nav ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav__link {
  position: relative; display: flex; align-items: center; gap: var(--sp-3);
  min-height: 46px; padding: var(--sp-2) var(--sp-4);
  border-radius: var(--r-md) 0 0 var(--r-md);
  color: #cfe3df; text-decoration: none; font-weight: var(--fw-medium);
}
.nav__link .icon { width: 22px; height: 22px; flex: none; }
.nav__link span { white-space: nowrap; }
/* Narrow rail (224 px): tighter padding so the bold active label ("Kalendarz zabiegów") stays on one line. */
@media (max-width: 1400px) { .nav__link { padding-inline: var(--sp-3) var(--sp-2); gap: var(--sp-2); } }
.nav__link:hover { color: #fff; background: rgba(255, 255, 255, .07); }
/* The active item is a tab cut out of the rail: it shares the page canvas colour
   and curves into it, so "where am I" reads as a physical connection. */
.nav__link.is-active { background: var(--color-bg); color: var(--c-scrub-900); font-weight: var(--fw-bold); }
.nav__link.is-active .icon { color: var(--color-primary); }
.nav__link.is-active::before, .nav__link.is-active::after {
  content: ""; position: absolute; right: 0; width: 16px; height: 16px; pointer-events: none;
}
.nav__link.is-active::before { top: -16px; background: radial-gradient(circle at 0 0, transparent 15.5px, var(--color-bg) 16px); }
.nav__link.is-active::after { bottom: -16px; background: radial-gradient(circle at 0 100%, transparent 15.5px, var(--color-bg) 16px); }
.nav__link:focus-visible { outline-offset: -3px; }

.rail__foot { margin-top: auto; padding-right: var(--sp-3); }
.usermenu { position: relative; }
.usermenu__toggle { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2); border-radius: var(--r-md);
  cursor: pointer; list-style: none; color: #fff; }
.usermenu__toggle::-webkit-details-marker { display: none; }
.usermenu__toggle:hover { background: rgba(255, 255, 255, .07); }
.usermenu__who { display: flex; flex-direction: column; min-width: 0; line-height: 1.25; }
.usermenu__who strong { font-size: var(--fs-sm); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__who span { font-size: var(--fs-xs); color: #a9cbc6; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.usermenu__chev { margin-left: auto; transition: transform .15s var(--ease); }
.usermenu[open] .usermenu__chev { transform: rotate(180deg); }
.usermenu__panel { position: absolute; bottom: calc(100% + 6px); left: 0; right: 0; min-width: 220px; padding: var(--sp-2);
  background: var(--color-surface); color: var(--color-text); border-radius: var(--r-md); box-shadow: var(--shadow-3); }
.usermenu__panel form { margin: 0; }
.usermenu__item { display: flex; width: 100%; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3);
  border: 0; background: none; font: inherit; font-size: var(--fs-sm); color: var(--color-text); text-decoration: none;
  border-radius: var(--r-sm); cursor: pointer; text-align: left; }
.usermenu__item:hover { background: var(--c-teal-50); color: var(--color-text); }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: #2b6b69; color: #fff; font-size: var(--fs-sm); font-weight: var(--fw-bold); letter-spacing: .02em; }

.main { min-width: 0; display: flex; flex-direction: column; }

/* Collapsed rail (tablets / narrow windows): icons only. */
@media (max-width: 1100px) {
  .rail { padding-left: var(--sp-2); }
  .brand { padding: 0 0 var(--sp-6) var(--sp-1); }
  .brand__text, .nav__link span, .usermenu__who, .usermenu__chev { display: none; }
  .nav__link { justify-content: center; padding: var(--sp-2); }
  .rail__foot { padding-right: var(--sp-2); }
  .usermenu__panel { left: 0; right: auto; }
}

/* ---------------------------------------------------------------- demo tape */
.demo-tape {
  display: flex; align-items: center; justify-content: center; gap: var(--sp-4);
  min-height: 30px; padding: 4px var(--sp-4);
  background: repeating-linear-gradient(-45deg, #f6c445 0 14px, #1d2a2c 14px 28px);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.demo-tape span { background: #f6c445; color: #1d2a2c; padding: 1px var(--sp-3); border-radius: var(--r-xs); }
.demo-tape span:first-child { text-transform: uppercase; letter-spacing: .08em; }
.demo-tape__hint { font-weight: var(--fw-medium); }

/* ---------------------------------------------------------------- page */
.page { width: 100%; max-width: var(--content-max); padding: var(--sp-6) var(--page-pad) var(--sp-12); outline: none; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: var(--sp-6);
  flex-wrap: wrap; margin-bottom: var(--sp-6); }
.page-head__text { min-width: 0; }
.page-head__actions { display: flex; gap: var(--sp-2); flex-wrap: wrap; align-items: center; }
.page-head__actions:empty { display: none; }
.crumbs { display: flex; flex-wrap: wrap; gap: var(--sp-1); list-style: none; margin: 0 0 var(--sp-2); padding: 0;
  font-size: var(--fs-sm); color: var(--color-text-3); }
.crumbs li + li::before { content: "/"; margin-right: var(--sp-1); color: var(--color-border-strong); }
.crumbs a { color: var(--color-text-2); }
.tabs { display: flex; gap: var(--sp-1); border-bottom: 1px solid var(--color-border); margin: 0 0 var(--sp-6); overflow-x: auto; }
.tabs a { display: inline-flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2) var(--sp-4); margin-bottom: -1px;
  border-bottom: 3px solid transparent; color: var(--color-text-2); text-decoration: none; font-weight: var(--fw-medium); white-space: nowrap; }
.tabs a:hover { color: var(--color-text); border-bottom-color: var(--color-border-strong); }
.tabs a.is-active, .tabs a[aria-current="page"] { color: var(--color-text); border-bottom-color: var(--color-primary); font-weight: var(--fw-bold); }
.tabs .count { font-size: var(--fs-xs); padding: 0 6px; border-radius: var(--r-pill); background: var(--tone-neutral-bg); color: var(--color-text-2); }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  min-height: var(--control-h); padding: 0 var(--sp-4);
  border: 1px solid transparent; border-radius: var(--r-sm);
  font: inherit; font-weight: var(--fw-bold); font-size: var(--fs-md); line-height: 1.1;
  text-decoration: none; white-space: nowrap; cursor: pointer;
  transition: background-color .12s var(--ease), border-color .12s var(--ease), box-shadow .12s var(--ease);
}
.btn .icon { width: 18px; height: 18px; }
.btn--primary { background: var(--color-primary); color: #fff; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15); }
.btn--primary:hover { background: var(--color-primary-hover); color: #fff; }
.btn--secondary { background: var(--color-surface); color: var(--color-text); border-color: var(--color-border-strong); }
.btn--secondary:hover { border-color: var(--color-primary); color: var(--color-primary-hover); background: var(--c-teal-50); }
.btn--ghost { background: transparent; color: var(--color-primary); }
.btn--ghost:hover { background: var(--c-teal-50); color: var(--color-primary-hover); }
.btn--danger { background: var(--tone-danger-fg); color: #fff; }
.btn--danger:hover { background: #861d15; color: #fff; }
.btn--danger-ghost { background: transparent; color: var(--tone-danger-fg); border-color: var(--tone-danger-bd); }
.btn--danger-ghost:hover { background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.btn--sm { min-height: 32px; padding: 0 var(--sp-3); font-size: var(--fs-sm); }
.btn--lg { min-height: 48px; padding: 0 var(--sp-6); font-size: var(--fs-lg); }
.btn--block { width: 100%; }
.btn--icon { width: var(--control-h); padding: 0; }
.btn--icon.btn--sm { width: 32px; }
.btn[disabled], .btn.is-disabled { opacity: .45; cursor: not-allowed; box-shadow: none; }
.btn-group { display: inline-flex; gap: var(--sp-2); flex-wrap: wrap; }

/* htmx request indicator (htmx's own inline styles are disabled for CSP) */
.htmx-indicator { opacity: 0; transition: opacity .15s; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }
.spinner { display: inline-block; width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid currentColor; border-right-color: transparent; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: var(--sp-4) var(--sp-5); }
.form-grid .field--textarea, .form-grid .field--radioselect, .form-grid .field--checkbox, .form-grid .field--wide { grid-column: 1 / -1; }
.form-actions { display: flex; gap: var(--sp-2); justify-content: flex-end; align-items: center; flex-wrap: wrap;
  margin-top: var(--sp-6); padding-top: var(--sp-4); border-top: 1px solid var(--color-border); }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field__label { font-weight: var(--fw-bold); font-size: var(--fs-sm); color: var(--color-text); padding: 0; }
.req { color: var(--tone-danger-fg); margin-left: 2px; }
.field__help { margin: 0; font-size: var(--fs-sm); color: var(--color-text-3); }
.field__error { display: flex; gap: 6px; align-items: flex-start; margin: 0; font-size: var(--fs-sm); color: var(--tone-danger-fg); font-weight: var(--fw-medium); }
.field__error .icon { margin-top: 2px; width: 16px; height: 16px; }

input[type="text"], input[type="email"], input[type="tel"], input[type="date"], input[type="number"],
input[type="password"], input[type="search"], input[type="time"], input[type="url"], select, textarea {
  width: 100%; min-height: var(--control-h); padding: 8px 12px;
  font: inherit; color: var(--color-text); background: var(--color-surface);
  border: 1px solid var(--color-border-strong); border-radius: var(--r-sm);
  box-shadow: inset 0 1px 2px rgba(15, 61, 62, .06);
  transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 96px; resize: vertical; line-height: var(--lh-body); }
select { appearance: none; padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2345575b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; background-size: 18px; }
input:hover, select:hover, textarea:hover { border-color: var(--c-ink-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px rgba(10, 107, 103, .22); }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: none; }
input::placeholder, textarea::placeholder { color: #84959a; }
input:disabled, select:disabled, textarea:disabled { background: var(--c-sunken); color: var(--color-text-3); cursor: not-allowed; }
.has-error input, .has-error select, .has-error textarea, [aria-invalid="true"] {
  border-color: var(--tone-danger-fg); background: #fffafa; box-shadow: 0 0 0 1px var(--tone-danger-fg) inset; }
input[type="checkbox"], input[type="radio"] { width: 20px; height: 20px; margin: 0; accent-color: var(--color-primary); flex: none; }
.check { display: inline-flex; align-items: center; gap: var(--sp-3); cursor: pointer; font-weight: var(--fw-medium); }
.choices { border: 0; margin: 0; padding: 0; min-width: 0; }
.choices legend { margin-bottom: 6px; }
.choices > div { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.choices label { display: inline-flex; align-items: center; gap: var(--sp-2); min-height: var(--control-h);
  padding: 0 var(--sp-4) 0 var(--sp-3); border: 1px solid var(--color-border-strong); border-radius: var(--r-sm);
  background: var(--color-surface); cursor: pointer; font-weight: var(--fw-medium); }
.choices label:has(input:checked) { border-color: var(--color-primary); background: var(--c-teal-50); box-shadow: 0 0 0 1px var(--color-primary) inset; }
.form-errors { margin-bottom: var(--sp-4); }

/* ---------------------------------------------------------------- filter bar */
.filters { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--sp-3) var(--sp-4);
  padding: var(--sp-4); margin-bottom: var(--sp-4);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r-md); }
.filters .field { flex: 1 1 170px; max-width: 260px; }
.filters .field--search { flex: 2 1 260px; max-width: 380px; }
.filters__actions { display: flex; gap: var(--sp-2); margin-left: auto; align-items: center; }
.search { position: relative; }
.search .icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--color-text-3); pointer-events: none; }
.search input { padding-left: 40px; }
.chips { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.chip { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 var(--sp-3);
  border: 1px solid var(--color-border-strong); border-radius: var(--r-pill); background: var(--color-surface);
  color: var(--color-text-2); font: inherit; font-size: var(--fs-sm); font-weight: var(--fw-medium); text-decoration: none; cursor: pointer; }
.chip:hover { border-color: var(--color-primary); color: var(--color-text); }
.chip.is-active, .chip[aria-pressed="true"] { background: var(--c-scrub-800); border-color: var(--c-scrub-800); color: #fff; }
.chip .count { font-size: var(--fs-xs); opacity: .8; }
.result-meta { display: flex; justify-content: space-between; align-items: center; gap: var(--sp-4); margin: 0 0 var(--sp-3);
  font-size: var(--fs-sm); color: var(--color-text-2); }

/* ---------------------------------------------------------------- table */
.table-wrap { overflow-x: auto; background: var(--color-surface); border: 1px solid var(--color-border);
  border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.table { width: 100%; border-collapse: collapse; font-size: var(--fs-md); }
.table th, .table td { padding: 10px var(--sp-4); text-align: left; vertical-align: middle; border-bottom: 1px solid var(--color-border); }
.table thead th { position: sticky; top: 0; z-index: 1; background: var(--c-sunken); color: var(--color-text-2);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); white-space: nowrap; border-bottom-color: var(--color-border-strong); }
.table thead th a { color: inherit; text-decoration: none; display: inline-flex; align-items: center; gap: 4px; }
.table thead th a:hover { color: var(--color-primary); }
.table thead th[aria-sort] { color: var(--color-text); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: #f6faf9; }
.table td.num, .table th.num { text-align: right; }
.table td.actions { text-align: right; white-space: nowrap; width: 1%; }
.table .cell-main { display: block; font-weight: var(--fw-bold); color: var(--color-text); }
.table .cell-main a { color: inherit; text-decoration: none; }
.table .cell-main a:hover { color: var(--color-primary); text-decoration: underline; }
.table .cell-sub { display: block; font-size: var(--fs-sm); color: var(--color-text-3); white-space: nowrap; }
.table--compact th, .table--compact td { padding: 6px var(--sp-3); font-size: var(--fs-sm); }
.table tr.is-urgent td:first-child { box-shadow: inset 4px 0 0 var(--tone-danger-fg); }
.table tr.is-muted td { color: var(--color-text-3); }
.table tr.is-muted .cell-main { color: var(--color-text-2); text-decoration: line-through; text-decoration-color: var(--color-border-strong); }
.table tr.is-selected { background: var(--c-teal-50); }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: var(--r-pill);
  border: 1px solid var(--tone-neutral-bd); background: var(--tone-neutral-bg); color: var(--tone-neutral-fg);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1.35; white-space: nowrap; }
.badge .icon { width: 15px; height: 15px; }
.badge--info    { background: var(--tone-info-bg);    color: var(--tone-info-fg);    border-color: var(--tone-info-bd); }
.badge--accent  { background: var(--tone-accent-bg);  color: var(--tone-accent-fg);  border-color: var(--tone-accent-bd); }
.badge--success { background: var(--tone-success-bg); color: var(--tone-success-fg); border-color: var(--tone-success-bd); }
.badge--warning { background: var(--tone-warning-bg); color: var(--tone-warning-fg); border-color: var(--tone-warning-bd); }
.badge--danger  { background: var(--tone-danger-bg);  color: var(--tone-danger-fg);  border-color: var(--tone-danger-bd); }
.badge--muted   { background: var(--tone-muted-bg);   color: var(--tone-muted-fg);   border-color: var(--tone-muted-bd); border-style: dashed; }
.badge--solid.badge--danger { background: var(--tone-danger-fg); color: #fff; }

/* ---------------------------------------------------------------- day load */
.load { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 6px; border-radius: var(--r-xs);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1.35; white-space: nowrap;
  color: var(--load-c); background: var(--load-bg); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--load-c) 35%, transparent); }
.load .icon { width: 15px; height: 15px; stroke-width: 2.2; }
.load--free     { --load-c: var(--load-free);     --load-bg: var(--load-free-bg); }
.load--moderate { --load-c: var(--load-moderate); --load-bg: var(--load-moderate-bg); }
.load--heavy    { --load-c: var(--load-heavy);    --load-bg: var(--load-heavy-bg); }
.load--full     { --load-c: var(--load-full);     --load-bg: var(--load-full-bg); }
.load--closed   { --load-c: var(--load-closed);   --load-bg: var(--load-closed-bg); }

/* Capacity bar: ticks at 50 % and 85 % mark the level thresholds. */
.meter { position: relative; display: inline-block; width: 100%; min-width: 64px; height: 10px; vertical-align: middle;
  border-radius: var(--r-xs); background: var(--c-sunken); box-shadow: inset 0 0 0 1px var(--color-border); overflow: hidden; }
.meter__fill { position: absolute; inset: 0 auto 0 0; width: 0; background: var(--meter-c, var(--load-free)); border-radius: var(--r-xs) 0 0 var(--r-xs); }
.meter__tick { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--color-surface); opacity: .9; }
.meter__tick--50 { left: 50%; }
.meter__tick--85 { left: 85%; }
.meter--free     { --meter-c: var(--load-free); }
.meter--moderate { --meter-c: var(--load-moderate); }
.meter--heavy    { --meter-c: var(--load-heavy); }
.meter--full     { --meter-c: var(--load-full); }
.meter--closed   { background: repeating-linear-gradient(-45deg, var(--load-closed-bg) 0 4px, #dde2e3 4px 8px); }
.meter--full .meter__fill, .meter--over .meter__fill {
  background: repeating-linear-gradient(-45deg, var(--load-full) 0 5px, #7c1219 5px 10px); }
.fill-0{width:0}.fill-5{width:5%}.fill-10{width:10%}.fill-15{width:15%}.fill-20{width:20%}.fill-25{width:25%}
.fill-30{width:30%}.fill-35{width:35%}.fill-40{width:40%}.fill-45{width:45%}.fill-50{width:50%}.fill-55{width:55%}
.fill-60{width:60%}.fill-65{width:65%}.fill-70{width:70%}.fill-75{width:75%}.fill-80{width:80%}.fill-85{width:85%}
.fill-90{width:90%}.fill-95{width:95%}.fill-100{width:100%}
.legend { display: flex; flex-wrap: wrap; gap: var(--sp-2) var(--sp-4); align-items: center; font-size: var(--fs-sm); color: var(--color-text-2); }

/* ---------------------------------------------------------------- absences */
.absence--vacation  { --abs-bg: var(--abs-vacation-bg); --abs-bd: var(--abs-vacation-bd); --abs-fg: var(--abs-vacation-fg); }
.absence--on-demand { --abs-bg: var(--abs-ondemand-bg); --abs-bd: var(--abs-ondemand-bd); --abs-fg: var(--abs-ondemand-fg); }
.absence--sick      { --abs-bg: var(--abs-sick-bg);     --abs-bd: var(--abs-sick-bd);     --abs-fg: var(--abs-sick-fg); }
.absence--training  { --abs-bg: var(--abs-training-bg); --abs-bd: var(--abs-training-bd); --abs-fg: var(--abs-training-fg); }
.absence--trip      { --abs-bg: var(--abs-trip-bg);     --abs-bd: var(--abs-trip-bd);     --abs-fg: var(--abs-trip-fg); }
.absence--care      { --abs-bg: var(--abs-care-bg);     --abs-bd: var(--abs-care-bd);     --abs-fg: var(--abs-care-fg); }
.absence--other     { --abs-bg: var(--abs-other-bg);    --abs-bd: var(--abs-other-bd);    --abs-fg: var(--abs-other-fg); }
.absence--hidden    { --abs-bg: var(--abs-hidden-bg);   --abs-bd: var(--abs-hidden-bd);   --abs-fg: var(--abs-hidden-fg); }
.absence-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px 2px 7px; border-radius: var(--r-xs);
  background: var(--abs-bg); color: var(--abs-fg); box-shadow: inset 3px 0 0 var(--abs-bd);
  font-size: var(--fs-sm); font-weight: var(--fw-bold); line-height: 1.35; white-space: nowrap; }
.absence-chip .icon { width: 15px; height: 15px; }
/* Bar for timelines/calendars: left edge = kind colour, fill = tint. */
.absence-bar { display: flex; align-items: center; gap: 6px; min-height: 28px; padding: 2px 8px; overflow: hidden;
  background: var(--abs-bg); color: var(--abs-fg); border-left: 4px solid var(--abs-bd); border-radius: var(--r-xs);
  font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; }
.absence-bar .icon { width: 15px; height: 15px; }
.absence--hidden.absence-bar, .absence--hidden.absence-chip {
  background: repeating-linear-gradient(-45deg, var(--abs-hidden-bg) 0 6px, #e2e6e7 6px 12px); }

/* ---------------------------------------------------------------- stats / cards */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: var(--sp-4); margin-bottom: var(--sp-6); }
.stat { position: relative; display: flex; flex-direction: column; gap: var(--sp-1); padding: var(--sp-4) var(--sp-5) var(--sp-4);
  background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); color: var(--color-text); text-decoration: none; overflow: hidden; }
.stat::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--stat-c, var(--color-border-strong)); }
a.stat:hover { border-color: var(--color-primary); color: var(--color-text); }
.stat__label { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-sm); font-weight: var(--fw-bold); color: var(--color-text-2); }
.stat__label .icon { color: var(--stat-c, var(--color-text-3)); }
.stat__value { font-size: var(--fs-3xl); font-weight: var(--fw-bold); line-height: 1.1; letter-spacing: -0.02em; }
.stat__value small { font-size: var(--fs-md); font-weight: var(--fw-medium); color: var(--color-text-2); letter-spacing: 0; }
.stat__note { font-size: var(--fs-sm); color: var(--color-text-3); }
.stat--info { --stat-c: var(--tone-info-fg); }
.stat--accent { --stat-c: var(--color-primary); }
.stat--success { --stat-c: var(--tone-success-fg); }
.stat--warning { --stat-c: #c27c0e; }
.stat--danger { --stat-c: var(--tone-danger-fg); }

.card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--r-md);
  box-shadow: var(--shadow-1); padding: var(--sp-5); }
.card + .card { margin-top: var(--sp-4); }
.card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); margin: calc(-1 * var(--sp-1)) 0 var(--sp-4); }
.card__title { font-size: var(--fs-lg); margin-bottom: var(--sp-3); }
.card__head .card__title { margin: 0; }
.card--flush { padding: 0; overflow: hidden; }
.card--flush .card__head { padding: var(--sp-4) var(--sp-5) 0; }
.card--plaster { background: var(--c-plaster); border-color: #e7dfd2; }
.card--alert { border-color: var(--tone-danger-bd); box-shadow: inset 4px 0 0 var(--tone-danger-fg), var(--shadow-1); }
.dl { display: grid; grid-template-columns: max-content 1fr; gap: var(--sp-2) var(--sp-5); margin: 0; }
.dl dt { color: var(--color-text-3); font-size: var(--fs-sm); padding-top: 2px; }
.dl dd { margin: 0; font-weight: var(--fw-medium); }

/* ---------------------------------------------------------------- dialog / drawer */
dialog.dialog, dialog.drawer { padding: 0; border: 0; color: var(--color-text); background: var(--color-surface); box-shadow: var(--shadow-3); }
dialog.dialog { width: min(560px, calc(100vw - 32px)); max-height: calc(100vh - 64px); border-radius: var(--r-lg); }
dialog.dialog--wide { width: min(820px, calc(100vw - 32px)); }
dialog.drawer { margin: 0 0 0 auto; width: min(480px, 92vw); height: 100vh; max-height: 100vh; border-radius: var(--r-lg) 0 0 var(--r-lg); }
dialog::backdrop { background: rgba(11, 47, 48, .45); }
dialog[open] { display: flex; flex-direction: column; }
.dialog__head { display: flex; align-items: flex-start; justify-content: space-between; gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-6) var(--sp-4); border-bottom: 1px solid var(--color-border); }
.dialog__head h2 { font-size: var(--fs-xl); }
.dialog__head p { margin: var(--sp-1) 0 0; color: var(--color-text-2); font-size: var(--fs-sm); }
.dialog__body { padding: var(--sp-5) var(--sp-6); overflow-y: auto; flex: 1; }
.dialog__foot { display: flex; justify-content: flex-end; gap: var(--sp-2); padding: var(--sp-4) var(--sp-6);
  border-top: 1px solid var(--color-border); background: var(--c-sunken); border-radius: 0 0 var(--r-lg) var(--r-lg); }
.drawer .dialog__foot { border-radius: 0 0 0 var(--r-lg); }
@media (prefers-reduced-motion: no-preference) {
  dialog.dialog[open] { animation: dialog-in .18s var(--ease); }
  dialog.drawer[open] { animation: drawer-in .22s var(--ease); }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes drawer-in { from { transform: translateX(40px); opacity: .4; } }

/* ---------------------------------------------------------------- alerts / toasts */
.toasts { display: flex; flex-direction: column; gap: var(--sp-2); margin-bottom: var(--sp-5); }
.alert { display: flex; align-items: flex-start; gap: var(--sp-3); padding: var(--sp-3) var(--sp-4);
  border-radius: var(--r-md); border: 1px solid var(--tone-info-bd); background: var(--tone-info-bg); color: var(--tone-info-fg); }
.alert > .icon { width: 20px; height: 20px; margin-top: 1px; }
.alert p { margin: 0; color: var(--color-text); font-weight: var(--fw-medium); flex: 1; }
.alert div { flex: 1; }
.alert--success { border-color: var(--tone-success-bd); background: var(--tone-success-bg); color: var(--tone-success-fg); }
.alert--warning { border-color: var(--tone-warning-bd); background: var(--tone-warning-bg); color: var(--tone-warning-fg); }
.alert--error, .alert--danger { border-color: var(--tone-danger-bd); background: var(--tone-danger-bg); color: var(--tone-danger-fg); }
.alert__close { margin: -4px -6px -4px 0; display: grid; place-items: center; width: 30px; height: 30px; border: 0; background: none;
  color: var(--color-text-2); border-radius: var(--r-sm); cursor: pointer; }
.alert__close:hover { background: rgba(0, 0, 0, .06); }

/* ---------------------------------------------------------------- empty state */
.empty { display: flex; flex-direction: column; align-items: center; text-align: center; gap: var(--sp-2);
  padding: var(--sp-12) var(--sp-6); border: 2px dashed var(--color-border); border-radius: var(--r-md); background: rgba(255, 255, 255, .55); }
.empty__icon { display: grid; place-items: center; width: 56px; height: 56px; margin-bottom: var(--sp-2); border-radius: 50%;
  background: var(--color-primary-soft); color: var(--color-primary); }
.empty__icon .icon { width: 28px; height: 28px; }
.empty__title { font-size: var(--fs-lg); }
.empty__text { color: var(--color-text-2); max-width: 52ch; }
.empty .btn { margin-top: var(--sp-3); }

/* ---------------------------------------------------------------- pager */
.pager { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); flex-wrap: wrap; margin-top: var(--sp-4); }
.pager__info { margin: 0; font-size: var(--fs-sm); color: var(--color-text-3); }
.pager__links { display: flex; align-items: center; gap: var(--sp-2); }
.pager__current { font-size: var(--fs-sm); color: var(--color-text-2); padding: 0 var(--sp-2); }

/* ---------------------------------------------------------------- layout utilities */
.stack > * + * { margin-top: var(--sp-4); }
.stack-lg > * + * { margin-top: var(--sp-8); }
.cluster { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2); }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--sp-5); }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-5); }
.split { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: var(--sp-6); align-items: start; }
@media (max-width: 1280px) { .split { grid-template-columns: minmax(0, 1fr) 300px; } }
@media (max-width: 1000px) { .grid-2, .grid-3, .split { grid-template-columns: 1fr; } }
.section { margin-top: var(--sp-8); }
.section__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-4); margin-bottom: var(--sp-3); }
.section__head h2 { font-size: var(--fs-xl); }

/* ---------------------------------------------------------------- login */
.login-body { background: var(--c-scrub-900); }
.login { display: grid; grid-template-columns: minmax(420px, 520px) 1fr; min-height: calc(100vh - 30px); }
.plain:not(:has(.demo-tape)) .login { min-height: 100vh; }
.login__panel { display: flex; flex-direction: column; justify-content: center; gap: var(--sp-8);
  padding: var(--sp-12) clamp(var(--sp-8), 5vw, 72px); background: var(--color-surface); }
.login__brand { display: flex; align-items: center; gap: var(--sp-4); }
.login__ward { margin: 0 0 2px; font-size: var(--fs-sm); color: var(--color-text-2); font-weight: var(--fw-bold); }
.login__title { font-size: var(--fs-2xl); max-width: 16ch; }
.login__form .form-grid { grid-template-columns: 1fr; gap: var(--sp-4); }
.login__form .btn { margin-top: var(--sp-6); }
.login__aside { position: relative; display: flex; flex-direction: column; justify-content: center; gap: var(--sp-8);
  padding: var(--sp-12) clamp(var(--sp-8), 6vw, 120px); color: #dcece9; overflow: hidden;
  background:
    radial-gradient(ellipse 60% 50% at 85% 15%, rgba(31, 122, 116, .45), transparent 70%),
    linear-gradient(160deg, var(--c-scrub-800), var(--c-scrub-900)); }
.login__week { display: grid; gap: var(--sp-4); max-width: 520px; }
.lw { display: grid; grid-template-columns: 48px 1fr; align-items: center; gap: var(--sp-4); }
.lw__d { font-size: var(--fs-lg); font-weight: var(--fw-bold); color: #a9cbc6; }
.lw .meter { height: 22px; background: rgba(255, 255, 255, .08); box-shadow: none; border-radius: 6px; }
.lw .meter__fill { border-radius: 6px; }
.login__aside .meter--free { --meter-c: #5fc08a; }
.login__aside .meter--moderate { --meter-c: #e7b043; }
.login__aside .meter--heavy { --meter-c: #f08a4b; }
.login__aside .meter--full .meter__fill { background: repeating-linear-gradient(-45deg, #e2595f 0 6px, #b8343b 6px 12px); }
.login__aside-text { font-size: var(--fs-xl); font-weight: var(--fw-bold); color: #fff; max-width: 22ch; line-height: 1.3; margin: 0; }
@media (max-width: 900px) { .login { grid-template-columns: 1fr; } .login__aside { display: none; } }

/* ---------------------------------------------------------------- error pages */
.error-page { max-width: 640px; margin: 12vh auto; padding: var(--sp-8); text-align: left; }
.error-page__code { display: inline-block; font-size: 4rem; font-weight: var(--fw-bold); color: var(--color-primary); line-height: 1; margin-bottom: var(--sp-4); }
.error-page__code .icon { width: 56px; height: 56px; }
.error-page h1 { margin-bottom: var(--sp-3); }
.error-page p { color: var(--color-text-2); margin-bottom: var(--sp-6); }

/* ---------------------------------------------------------------- styleguide */
.sg { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: var(--sp-8); align-items: start; }
.sg__toc { position: sticky; top: var(--sp-6); display: flex; flex-direction: column; gap: 2px; font-size: var(--fs-sm); }
.sg__toc a { padding: 5px var(--sp-3); border-radius: var(--r-sm); color: var(--color-text-2); text-decoration: none; }
.sg__toc a:hover { background: var(--color-surface); color: var(--color-text); }
.sg__section { scroll-margin-top: var(--sp-6); padding-bottom: var(--sp-8); margin-bottom: var(--sp-8); border-bottom: 1px solid var(--color-border); }
.sg__section > h2 { margin-bottom: var(--sp-4); }
.sg__demo > p.muted, .sg__demo > .legend { margin-top: var(--sp-4); }
.sg__demo { padding: var(--sp-5); background: var(--color-bg); border: 1px solid var(--color-border); border-radius: var(--r-md) var(--r-md) 0 0; }
.sg__code { margin: 0; }
.sg__code summary { cursor: pointer; padding: var(--sp-2) var(--sp-4); font-size: var(--fs-sm); font-weight: var(--fw-bold);
  background: var(--c-sunken); border: 1px solid var(--color-border); border-top: 0; border-radius: 0 0 var(--r-md) var(--r-md); color: var(--color-text-2); }
.sg__code[open] summary { border-radius: 0; }
.sg__code pre { margin: 0; padding: var(--sp-4); max-height: 420px; overflow: auto; background: #10282a; color: #d8ece8;
  border-radius: 0 0 var(--r-md) var(--r-md); font-size: 13px; line-height: 1.55; white-space: pre-wrap; }
.swatches { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: var(--sp-3); }
.swatch { border-radius: var(--r-md); overflow: hidden; background: var(--color-surface); border: 1px solid var(--color-border); font-size: var(--fs-xs); }
.swatch__chip { height: 52px; }
.swatch__meta { padding: var(--sp-2) var(--sp-3); }
.swatch__meta strong { display: block; font-size: var(--fs-sm); }
.icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: var(--sp-2); }
.icon-grid div { display: flex; align-items: center; gap: var(--sp-2); padding: var(--sp-2); background: var(--color-surface);
  border: 1px solid var(--color-border); border-radius: var(--r-sm); font-size: var(--fs-xs); color: var(--color-text-2); }
.icon-grid .icon { width: 22px; height: 22px; color: var(--color-text); }
.sw-scrub { background: var(--c-scrub-800); } .sw-teal { background: var(--c-teal-700); } .sw-canvas { background: var(--c-canvas); }
.sw-surface { background: var(--c-surface); } .sw-ink { background: var(--c-ink); } .sw-ink2 { background: var(--c-ink-2); }
.sw-line { background: var(--c-line); } .sw-plaster { background: var(--c-plaster); } .sw-focus { background: var(--color-focus); }
.type-sample > * { margin-bottom: var(--sp-3); }
