/* ==========================================================================================================
   Rydwan - ewidencja czasu pracy: THE theme.

   Rules of this file
   - Every colour, size, radius, shadow, weight, duration and z-index is a custom property declared in the :root blocks
     below. Rules use var(--...) only. The only literals allowed outside :root are 0, 1px hairlines, %, auto, unitless
     ratios and keywords (and the breakpoints of @media, which CSS cannot take from variables).
   - Dark scheme: prefers-color-scheme redefines the colour tokens only. The sidebar stays near-black in both.
   - No web fonts, no images, no data: URIs (the CSP allows only same-origin resources).
   - Page stylesheets (public/pages/*.css) may use tokens only, never literals, and never edit this file.

   Components (pages use only these classes)
   Shell      .app .sidebar .brand-block .brand .brand-mark .brand-text .brand-name .brand-sub .demo-chip
              .nav .nav-label .nav-list .nav-link .nav-icon .nav-text .nav-badge .user-block .user .user-text .user-name
              .user-role .logout-form .main .content .skip-link .sr-only
   Page       .page-header (h1 + .page-sub + .actions) .toolbar .grid-2 (+ aside) .stack .kpi-grid .stats
              .kpi (.kpi-icon[data-tone=ok|warn|neutral|accent] .kpi-label .kpi-value .kpi-hint)
              .card (.card-header .card-title .card-body .card-footer, .card-highlight, a.card) .empty (+ svg, h1/h2, p, .btn)
   Data       .table-wrap .table (.table-dense, .num, .muted, .weekend, .problem, .corrected, tfoot totals) .cell-person
              .cell-text (.person) .row-actions .chip (.chip-ok|warn|danger|muted) .badge (.badge-ok|warn|danger|muted)
              .avatar[data-hue=0..5] (.avatar-sm .avatar-lg) .feed (li, .feed-time .feed-body|.feed-text .feed-meta .feed-icon) dl/dt/dd
   Forms      .form .form-row .form-inline .form-actions .field (label, input, select, textarea, .hint, .error) .check
              .btn .btn-primary .btn-danger .btn-ghost .btn-link .btn-sm .btn-lg .btn-block .btn-icon details/summary
   Messages   .flash .flash-ok .flash-error .flash-text
   Charts     .ring (svg + any non-svg child is centred over it: .ring-value .ring-label) .bars .daybar .legend
              SVG text/shape classes: .chart-label .chart-label-strong .chart-value .chart-tick .chart-grid .chart-axis
              .chart-bar .chart-bar-muted .chart-track .daybar-track .daybar-presence .daybar-normal .daybar-overtime
              .daybar-hatch (also data-kind="track|presence|normal|overtime|early" and data-current)
              Rings: draw the arc rotated from 12 o'clock with the transform ATTRIBUTE on the circle
              (transform="rotate(-90 60 60)"); circles with stroke-dasharray are the value, others the track.
   Misc       .mono .code-block .token-box .muted .num .nowrap .truncate .text-right .text-center .actions .stack .icon .icon-sm
   Sign-in    .auth .auth-aside .auth-main .auth-content .auth-card
   ========================================================================================================== */

:root {
  color-scheme: light;

  /* ---- spacing: 4px base, every step a multiple ---- */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;
  --space-12: 48px;
  --space-16: 64px;
  --space-20: 80px;

  /* ---- type ---- */
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, Menlo, "Liberation Mono", monospace;
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
  --text-display: 56px;
  --leading-xs: 16px;
  --leading-sm: 20px;
  --leading-base: 22px;
  --leading-md: 24px;
  --leading-lg: 28px;
  --leading-xl: 32px;
  --leading-2xl: 40px;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-title: 650;
  --weight-bold: 700;
  --weight-heavy: 800;
  --tracking-tight: -0.01em;
  --tracking-wide: 0.06em;
  --tracking-brand: 0.12em;
  --tracking-mono: 0.02em;

  /* ---- shape ---- */
  --radius-xs: 4px;
  --radius-1: 8px;
  --radius-2: 12px;
  --radius-pill: 999px;
  --stroke: 2px;
  --focus-width: 2px;
  --focus-offset: 2px;
  --rotate-closed: -45deg;
  --rotate-open: 45deg;

  /* ---- layout sizes ---- */
  --screen-h: 100vh;
  --sidebar-width: 248px;
  --content-max: 1280px;
  --aside-width: 340px;
  --gutter: 32px;
  --gutter-narrow: 24px;
  --control-h: 36px;
  --control-h-sm: 28px;
  --control-h-lg: 44px;
  --row-h: 52px;
  --row-h-dense: 44px;
  --nav-h: 40px;
  --avatar: 36px;
  --avatar-sm: 28px;
  --avatar-lg: 48px;
  --icon: 20px;
  --icon-sm: 16px;
  --brand-mark: 36px;
  --auth-mark: 56px;
  --kpi-icon: 40px;
  --ring-size: 160px;
  --empty-art: 48px;
  --chip-h: 24px;
  --badge-h: 20px;
  --dot: 8px;
  --bar-w: 3px;
  --form-max: 480px;
  --field-min: 180px;
  --auth-card-w: 400px;
  --auth-aside-w: 440px;
  --deco-size: 520px;
  --deco-stroke: 56px;
  --measure: 46ch;
  --feed-time-w: 48px;
  --table-min-h: 320px;
  --table-max-h: max(var(--table-min-h), calc(var(--screen-h) - var(--space-12) * 3));
  --z-behind: -1;
  --z-sticky: 2;
  --z-topbar: 10;
  --z-skip: 100;

  /* ---- motion ---- */
  --duration-fast: 120ms;
  --duration: 140ms;
  --duration-slow: 160ms;
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --transition: background-color var(--duration) var(--ease), border-color var(--duration) var(--ease), color var(--duration) var(--ease),
    box-shadow var(--duration) var(--ease), opacity var(--duration) var(--ease);
  --transition-lift: var(--transition), transform var(--duration) var(--ease);
  --select-arrow: linear-gradient(45deg, transparent 50%, var(--color-muted) 50%), linear-gradient(135deg, var(--color-muted) 50%, transparent 50%);
  --opacity-disabled: 0.5;
  --opacity-glow: 0.55;

  /* ---- colour: surfaces and text (light) ---- */
  --color-bg: #f3f4f6;
  --color-surface: #ffffff;
  --color-surface-2: #f8f9fb;
  --color-surface-3: #eff1f4;
  --color-border: #e4e6eb;
  --color-border-subtle: #eceef2;
  --color-border-strong: #cdd1da;
  --color-text: #16181d;
  --color-muted: #5b6270;
  --color-faint: #8a91a0;
  --color-white: #ffffff;
  --color-row-hover: #f6f7fa;
  --color-weekend: #f6f7f9;
  --color-track: #e6e8ed;
  --color-ink: #16181d;
  --color-ink-soft: #8a91a0;
  --color-scroll: #c8ccd5;

  /* ---- colour: sidebar (near-black in both schemes) ---- */
  --color-sidebar: #141313;
  --color-sidebar-2: #232121;
  --color-sidebar-3: #2e2b2b;
  --color-sidebar-line: #2b2929;
  --color-sidebar-text: #f1f1f1;
  --color-sidebar-muted: #a9a7a7;
  --color-demo-dot: #f2b441;

  /* ---- colour: brand accent ---- */
  --color-accent: #d80000;
  --color-accent-hover: #b80000;
  --color-accent-press: #970000;
  --color-accent-bright: #ff0000;
  --color-accent-deep: #550000;
  --color-accent-tint: #fff0f0;
  --color-accent-text: #ffffff;
  --color-link: #d80000;
  --color-link-hover: #b80000;
  --color-focus: #ff0000;

  /* ---- colour: status pairs (text on tint) ---- */
  --color-ok: #0f7b4f;
  --color-ok-bg: #e5f5ec;
  --color-ok-border: #bfe3d0;
  --color-warn: #9a5b00;
  --color-warn-bg: #fff3dc;
  --color-warn-border: #f1d8a3;
  --color-danger: #b42318;
  --color-danger-bg: #feecea;
  --color-danger-border: #f4c3bd;
  --color-neutral: #4b5260;
  --color-neutral-bg: #eceef2;

  /* ---- colour: six calm avatar tints ---- */
  --hue-0-bg: #fde7e7;
  --hue-0-fg: #a61b1b;
  --hue-1-bg: #fbebcf;
  --hue-1-fg: #7f4b00;
  --hue-2-bg: #ddf1e6;
  --hue-2-fg: #0d6240;
  --hue-3-bg: #e0eafa;
  --hue-3-fg: #234682;
  --hue-4-bg: #ebe4f7;
  --hue-4-fg: #53358a;
  --hue-5-bg: #e6e8ed;
  --hue-5-fg: #3c4352;

  /* ---- elevation ---- */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.08);
  --shadow-2: 0 4px 12px rgba(16, 24, 40, 0.1);
  --shadow-3: 0 12px 32px rgba(16, 24, 40, 0.16);
  --glow-mark: drop-shadow(0 4px 12px rgba(255, 0, 0, 0.3));
}

@media screen and (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;

    --color-bg: #0e0e10;
    --color-surface: #17171a;
    --color-surface-2: #1e1e22;
    --color-surface-3: #26262b;
    --color-border: #2a2a30;
    --color-border-subtle: #222226;
    --color-border-strong: #3a3a42;
    --color-text: #f1f1f3;
    --color-muted: #a3a7b3;
    --color-faint: #7b8090;
    --color-row-hover: #1c1c20;
    --color-weekend: #131316;
    --color-track: #2a2a30;
    --color-ink: #f1f1f3;
    --color-ink-soft: #7b8090;
    --color-scroll: #3a3a42;

    --color-accent: #e11d1d;
    --color-accent-hover: #f03a3a;
    --color-accent-press: #c41616;
    --color-accent-tint: #2a1517;
    --color-link: #ff7b7b;
    --color-link-hover: #ff9c9c;

    --color-ok: #52d6a0;
    --color-ok-bg: #10281e;
    --color-ok-border: #1d4d39;
    --color-warn: #f2b441;
    --color-warn-bg: #2e2310;
    --color-warn-border: #5a4317;
    --color-danger: #ff8f85;
    --color-danger-bg: #321614;
    --color-danger-border: #6a2a25;
    --color-neutral: #b9becb;
    --color-neutral-bg: #26272d;

    --hue-0-bg: #3a1a1c;
    --hue-0-fg: #ff9a94;
    --hue-1-bg: #36290f;
    --hue-1-fg: #f0b95a;
    --hue-2-bg: #12301f;
    --hue-2-fg: #6fd7a3;
    --hue-3-bg: #172a4a;
    --hue-3-fg: #8fb3f2;
    --hue-4-bg: #2a2140;
    --hue-4-fg: #b9a2ee;
    --hue-5-bg: #2b2c33;
    --hue-5-fg: #bfc4d2;

    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.5), 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-2: 0 4px 16px rgba(0, 0, 0, 0.5);
    --shadow-3: 0 12px 32px rgba(0, 0, 0, 0.6);
  }
}

@supports (height: 100dvh) {
  :root {
    --screen-h: 100dvh;
  }
}

/* ==========================================================================================================
   Base
   ========================================================================================================== */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-padding-top: var(--space-6);
}

body {
  margin: 0;
  min-height: var(--screen-h);
  background: var(--color-bg);
  color: var(--color-text);
  font-family: var(--font);
  font-size: var(--text-base);
  line-height: var(--leading-base);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

h1 {
  font-size: var(--text-xl);
  line-height: var(--leading-xl);
  font-weight: var(--weight-title);
  letter-spacing: var(--tracking-tight);
}

h2 {
  font-size: var(--text-md);
  line-height: var(--leading-md);
}

h3 {
  font-size: var(--text-base);
  line-height: var(--leading-base);
}

p {
  margin: 0;
}

p + p {
  margin-top: var(--space-2);
}

ul,
ol {
  margin: 0;
  padding-left: var(--space-5);
}

small {
  font-size: var(--text-sm);
}

strong,
b {
  font-weight: var(--weight-semibold);
}

hr {
  height: 0;
  margin: var(--space-6) 0;
  border: 0;
  border-top: 1px solid var(--color-border);
}

a {
  color: var(--color-link);
  text-decoration: none;
  transition: var(--transition);
}

a:hover {
  color: var(--color-link-hover);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: var(--focus-width) solid var(--color-focus);
  outline-offset: var(--focus-offset);
}

:focus:not(:focus-visible) {
  outline: none;
}

::selection {
  background: var(--color-accent-tint);
  color: var(--color-text);
}

svg {
  flex: none;
  vertical-align: middle;
}

/* an icon svg without its own size attributes still gets a sane size */
svg:where(:not([width]):not([height])) {
  width: var(--icon);
  height: var(--icon);
}

.icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
}

.icon-sm {
  width: var(--icon-sm);
  height: var(--icon-sm);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

[hidden] {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: var(--space-2);
  left: var(--space-2);
  z-index: var(--z-skip);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-1);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-weight: var(--weight-semibold);
  transform: translateY(-200%);
  transition: transform var(--duration) var(--ease);
}

.skip-link:focus {
  transform: translateY(0);
  color: var(--color-accent-text);
  text-decoration: none;
}

code,
kbd,
samp,
.mono {
  font-family: var(--font-mono);
  letter-spacing: var(--tracking-mono);
}

code,
kbd,
samp {
  padding: 0 var(--space-1);
  border-radius: var(--radius-xs);
  background: var(--color-surface-3);
  font-size: var(--text-sm);
}

.mono {
  font-size: var(--text-sm);
}

.muted {
  color: var(--color-muted);
}

.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.text-right {
  text-align: right;
}

.text-center {
  text-align: center;
}

.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

time,
.tabular {
  font-variant-numeric: tabular-nums;
}

dl {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: var(--space-2) var(--space-6);
  margin: 0;
}

dl > div {
  display: contents;
}

dt {
  color: var(--color-muted);
  font-weight: var(--weight-medium);
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

pre,
.code-block,
.token-box {
  display: block;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--leading-md);
  letter-spacing: var(--tracking-mono);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  user-select: all;
}

pre code {
  padding: 0;
  background: none;
}

/* ==========================================================================================================
   Shell: sidebar + content
   ========================================================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr);
  min-height: var(--screen-h);
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  height: var(--screen-h);
  padding: var(--space-5) var(--space-3) var(--space-4);
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  scrollbar-width: thin;
  scrollbar-color: var(--color-sidebar-3) transparent;
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-1) var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-sidebar-line);
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  color: var(--color-sidebar-text);
  text-decoration: none;
}

.brand:hover {
  color: var(--color-white);
  text-decoration: none;
}

.brand-mark {
  width: var(--brand-mark);
  height: var(--brand-mark);
  flex: none;
  filter: var(--glow-mark);
}

.mark-bg {
  fill: var(--color-accent-bright);
}

.mark-fg {
  fill: var(--color-white);
}

.mark-hand {
  fill: none;
  stroke: var(--color-accent-bright);
}

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

.brand-name {
  font-size: var(--text-md);
  line-height: var(--leading-sm);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-brand);
  text-transform: uppercase;
  color: var(--color-white);
}

.brand-sub {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  color: var(--color-sidebar-muted);
}

.demo-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--chip-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-sidebar-line);
  border-radius: var(--radius-pill);
  background: var(--color-sidebar-2);
  color: var(--color-sidebar-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
}

.demo-chip::before {
  content: "";
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--color-demo-dot);
}

.nav {
  min-height: 0;
}

.nav-label {
  margin: 0 0 var(--space-2);
  padding: 0 var(--space-3);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--color-sidebar-muted);
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin: 0;
  padding: 0;
  list-style: none;
}

.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--nav-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-1);
  color: var(--color-sidebar-muted);
  font-weight: var(--weight-medium);
  text-decoration: none;
  transition: var(--transition);
}

.nav-icon {
  width: var(--icon);
  height: var(--icon);
  flex: none;
}

.nav-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-link:hover {
  background: var(--color-sidebar-2);
  color: var(--color-sidebar-text);
  text-decoration: none;
}

.nav-link:active {
  background: var(--color-sidebar-3);
}

.nav-link[aria-current="page"] {
  background: var(--color-sidebar-3);
  color: var(--color-white);
  font-weight: var(--weight-semibold);
}

.nav-link[aria-current="page"]::before {
  content: "";
  position: absolute;
  top: var(--space-2);
  bottom: var(--space-2);
  left: 0;
  width: var(--bar-w);
  border-radius: var(--radius-pill);
  background: var(--color-accent-bright);
}

.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: var(--icon);
  height: var(--icon);
  margin-left: auto;
  padding: 0 var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--color-accent);
  color: var(--color-accent-text);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  line-height: 1;
}

.user-block {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: auto;
  padding-top: var(--space-4);
  border-top: 1px solid var(--color-sidebar-line);
}

.user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
  padding: 0 var(--space-3);
}

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

.user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-sidebar-text);
  font-weight: var(--weight-medium);
  line-height: var(--leading-sm);
}

.user-role {
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  color: var(--color-sidebar-muted);
}

.sidebar .avatar[data-hue],
.sidebar .avatar {
  background: var(--color-accent-deep);
  color: var(--color-white);
}

.logout-form {
  margin: 0;
}

.logout-form .btn {
  width: 100%;
}

.sidebar .btn-ghost {
  border-color: var(--color-sidebar-line);
  color: var(--color-sidebar-muted);
}

.sidebar .btn-ghost:hover {
  border-color: var(--color-sidebar-3);
  background: var(--color-sidebar-2);
  color: var(--color-white);
}

.sidebar .btn-ghost:active {
  background: var(--color-sidebar-3);
}

.main {
  min-width: 0;
}

.main:focus {
  outline: none;
}

.content {
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-8) var(--gutter) var(--space-12);
}

/* vertical rhythm between the blocks of a page */
.content > * + * {
  margin-top: var(--space-6);
}

.stack > * + * {
  margin-top: var(--space-4);
}

/* a heading sits close to the block it introduces */
.content > h2 + *,
.content > h3 + * {
  margin-top: var(--space-3);
}

/* ==========================================================================================================
   Page structure
   ========================================================================================================== */

.page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  column-gap: var(--space-4);
  row-gap: var(--space-1);
}

.page-header > :not(.actions) {
  grid-column: 1;
  min-width: 0;
}

.page-header > .actions {
  grid-column: 2;
  grid-row: 1 / span 2;
  justify-self: end;
}

.page-sub {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-base);
  line-height: var(--leading-base);
}

.actions:not(td):not(th),
.page-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: var(--space-3) var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
}

.toolbar .field {
  flex: 0 1 var(--field-min);
}

.toolbar .field input,
.toolbar .field select {
  width: 100%;
}

.toolbar .actions,
.toolbar-end {
  margin-left: auto;
}

.grid-2 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) var(--aside-width);
  gap: var(--space-6);
  align-items: start;
}

.grid-2 > aside,
.grid-2 > .aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-6);
  min-width: 0;
}

.grid-2 > * {
  min-width: 0;
}

/* ---- cards ---- */

.card {
  min-width: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
  transition: var(--transition-lift);
}

a.card,
.card-interactive {
  display: block;
  color: inherit;
  text-decoration: none;
}

a.card:hover,
.card-interactive:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-2);
  color: inherit;
  text-decoration: none;
  transform: translateY(-1px);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  min-height: var(--control-h-lg);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
}

.card-header h2,
.card-header h3,
.card-title {
  margin: 0;
  font-size: var(--text-md);
  line-height: var(--leading-md);
  font-weight: var(--weight-semibold);
}

.card-header a,
.card-header .btn-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}

.card-body {
  padding: var(--space-5);
}

.card-body > * + * {
  margin-top: var(--space-4);
}

.card-footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--color-border-subtle);
  border-radius: 0 0 var(--radius-2) var(--radius-2);
  background: var(--color-surface-2);
}

.card-body:has(> .table-wrap),
.card-body:has(> .table),
.card-body:has(> .feed),
.card-body.flush {
  padding: 0;
}

.card-highlight,
.card-accent,
.token-reveal,
.card[data-tone="accent"] {
  border-color: var(--color-accent);
  background: var(--color-accent-tint);
  box-shadow: var(--shadow-2);
}

.card-highlight .badge,
.card-accent .badge,
.token-reveal .badge {
  background: var(--color-surface);
}

.card-highlight .card-header,
.card-accent .card-header,
.token-reveal .card-header {
  border-bottom-color: var(--color-danger-border);
}

/* ---- KPI tiles ---- */

.kpi-grid,
.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: var(--space-4);
}

.kpi {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: var(--space-3);
  align-content: start;
  min-width: 0;
  padding: var(--space-5);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
  transition: var(--transition-lift);
}

a.kpi {
  color: inherit;
  text-decoration: none;
}

a.kpi:hover {
  border-color: var(--color-border-strong);
  box-shadow: var(--shadow-2);
  color: inherit;
  text-decoration: none;
  transform: translateY(-1px);
}

.kpi > * {
  grid-column: 1;
  min-width: 0;
}

.kpi > :not(.kpi-icon):not(.kpi-value):not(.kpi-hint),
.kpi-label {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
}

.kpi-icon {
  grid-column: 2;
  grid-row: 1 / span 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--kpi-icon);
  height: var(--kpi-icon);
  border-radius: 50%;
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.kpi-icon svg {
  width: var(--icon);
  height: var(--icon);
}

.kpi-icon[data-tone="ok"] {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.kpi-icon[data-tone="warn"] {
  background: var(--color-warn-bg);
  color: var(--color-warn);
}

.kpi-icon[data-tone="accent"] {
  background: var(--color-accent-tint);
  color: var(--color-accent);
}

.kpi-icon[data-tone="neutral"] {
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.kpi-value {
  margin: var(--space-1) 0 0;
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  color: var(--color-text);
}

.kpi-hint {
  margin: 0;
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

/* ==========================================================================================================
   Tables
   ========================================================================================================== */

.table-wrap {
  /* contains the absolutely positioned .sr-only labels of its cells, so they cannot widen the page */
  position: relative;
  max-height: var(--table-max-h);
  overflow: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-1);
  scrollbar-width: thin;
  scrollbar-color: var(--color-scroll) transparent;
}

.card .table-wrap,
.card-body > .table-wrap {
  border: 0;
  border-radius: 0 0 var(--radius-2) var(--radius-2);
  box-shadow: none;
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.table caption {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

.table caption.caption-visible {
  position: static;
  width: auto;
  height: auto;
  margin: 0;
  padding: var(--space-3) var(--space-5);
  clip: auto;
  clip-path: none;
  text-align: left;
  font-weight: var(--weight-semibold);
  white-space: normal;
}

.table th,
.table td {
  padding: var(--space-2) var(--space-4);
  text-align: left;
  vertical-align: middle;
}

.table thead,
.table thead tr {
  background: var(--color-surface-2);
}

.table thead th {
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
  height: var(--control-h-lg);
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  white-space: nowrap;
}

.table tbody td,
.table tbody th {
  height: var(--row-h);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-surface);
  transition: background-color var(--duration) var(--ease);
}

.table tbody th {
  font-weight: var(--weight-medium);
}

.table th:first-child,
.table td:first-child {
  padding-left: var(--space-5);
}

.table tbody td:first-child {
  font-weight: var(--weight-medium);
}

.table th:last-child,
.table td:last-child {
  padding-right: var(--space-5);
}

.table tbody tr:last-child > * {
  border-bottom: 0;
}

.table tbody tr:hover > * {
  background: var(--color-row-hover);
}

.table-dense tbody td,
.table-dense tbody th,
.table-compact tbody td,
.table-compact tbody th {
  height: var(--row-h-dense);
  padding-top: var(--space-1);
  padding-bottom: var(--space-1);
}

.table-dense th,
.table-dense td,
.table-compact th,
.table-compact td {
  padding-right: var(--space-3);
  padding-left: var(--space-3);
}

.table-dense th:first-child,
.table-dense td:first-child,
.table-compact th:first-child,
.table-compact td:first-child {
  padding-left: var(--space-5);
}

.table-dense th:last-child,
.table-dense td:last-child,
.table-compact th:last-child,
.table-compact td:last-child {
  padding-right: var(--space-5);
}

.table .num,
.table th.num,
.table td.num {
  text-align: right;
  white-space: nowrap;
}

.table .weekend > *,
.table tr.weekend > *,
.table td.weekend,
.table th.weekend {
  background: var(--color-weekend);
  color: var(--color-muted);
}

.table tr.problem > :first-child {
  box-shadow: inset var(--bar-w) 0 0 var(--color-warn);
}

.table tfoot td,
.table tfoot th {
  position: sticky;
  bottom: 0;
  height: var(--row-h-dense);
  border-top: 1px solid var(--color-border);
  background: var(--color-surface-2);
  color: var(--color-text);
  font-weight: var(--weight-semibold);
}

.table td.actions,
.table th.actions,
.row-actions {
  text-align: right;
  white-space: nowrap;
}

.row-actions {
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.cell-person,
.person {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

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

.cell-text > :first-child {
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.cell-text > .muted,
.cell-sub {
  color: var(--color-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-regular);
}

.corrected {
  text-decoration: underline dotted;
  text-underline-offset: var(--space-1);
  cursor: help;
}

/* ==========================================================================================================
   Chips, badges, avatars
   ========================================================================================================== */

.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  height: var(--chip-h);
  padding: 0 var(--space-3);
  border-radius: var(--radius-pill);
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
}

.chip::before {
  content: "";
  width: var(--dot);
  height: var(--dot);
  flex: none;
  border-radius: 50%;
  background: currentColor;
}

.chip-ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.chip-warn {
  background: var(--color-warn-bg);
  color: var(--color-warn);
}

.chip-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.chip-muted {
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.badge {
  display: inline-flex;
  align-items: center;
  height: var(--badge-h);
  padding: 0 var(--space-2);
  border-radius: var(--radius-xs);
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  line-height: 1;
  white-space: nowrap;
}

.badge-ok {
  background: var(--color-ok-bg);
  color: var(--color-ok);
}

.badge-warn {
  background: var(--color-warn-bg);
  color: var(--color-warn);
}

.badge-danger {
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.badge-muted {
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar);
  height: var(--avatar);
  flex: none;
  border-radius: 50%;
  background: var(--hue-5-bg);
  color: var(--hue-5-fg);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-mono);
  line-height: 1;
  text-transform: uppercase;
  user-select: none;
}

.avatar[data-hue="0"] {
  background: var(--hue-0-bg);
  color: var(--hue-0-fg);
}

.avatar[data-hue="1"] {
  background: var(--hue-1-bg);
  color: var(--hue-1-fg);
}

.avatar[data-hue="2"] {
  background: var(--hue-2-bg);
  color: var(--hue-2-fg);
}

.avatar[data-hue="3"] {
  background: var(--hue-3-bg);
  color: var(--hue-3-fg);
}

.avatar[data-hue="4"] {
  background: var(--hue-4-bg);
  color: var(--hue-4-fg);
}

.avatar[data-hue="5"] {
  background: var(--hue-5-bg);
  color: var(--hue-5-fg);
}

.avatar-sm {
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  font-size: var(--text-xs);
}

.avatar-lg {
  width: var(--avatar-lg);
  height: var(--avatar-lg);
  font-size: var(--text-md);
}

/* ==========================================================================================================
   Forms
   ========================================================================================================== */

.form {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(var(--field-min), 1fr));
  gap: var(--space-4);
}

.form-inline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.form-inline > select,
.form-inline > input:where(:not([type="checkbox"], [type="radio"], [type="hidden"])) {
  flex: 1 1 var(--field-min);
  width: auto;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

label,
.label {
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

input:where(:not([type="checkbox"], [type="radio"], [type="hidden"], [type="submit"], [type="button"], [type="range"], [type="file"])),
select,
textarea {
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 var(--space-3);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  color: var(--color-text);
  line-height: var(--leading-sm);
  transition: var(--transition);
}

textarea {
  height: auto;
  min-height: calc(var(--control-h) * 3);
  padding: var(--space-2) var(--space-3);
  resize: vertical;
}

select {
  padding-right: var(--space-8);
  appearance: none;
  background-image: var(--select-arrow);
  background-position: calc(100% - var(--space-5)) 50%, calc(100% - var(--space-4)) 50%;
  background-size: var(--space-1) var(--space-1), var(--space-1) var(--space-1);
  background-repeat: no-repeat;
  cursor: pointer;
}

select option {
  background: var(--color-surface);
  color: var(--color-text);
}

input::placeholder,
textarea::placeholder {
  color: var(--color-faint);
}

input:where(:not([type="checkbox"], [type="radio"])):hover,
select:hover,
textarea:hover {
  border-color: var(--color-faint);
}

input[aria-invalid="true"],
select[aria-invalid="true"],
textarea[aria-invalid="true"],
.field:has(.error) input,
.field:has(.error) select,
.field:has(.error) textarea {
  border-color: var(--color-danger);
}

input:disabled,
select:disabled,
textarea:disabled {
  background: var(--color-surface-2);
  color: var(--color-muted);
  cursor: not-allowed;
}

input[type="date"],
input[type="time"],
input[type="month"],
input[type="number"] {
  font-variant-numeric: tabular-nums;
}

input[type="checkbox"],
input[type="radio"] {
  width: var(--icon-sm);
  height: var(--icon-sm);
  margin: 0;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.check {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-regular);
}

fieldset {
  margin: 0;
  padding: var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-1);
}

legend {
  padding: 0 var(--space-2);
  font-weight: var(--weight-medium);
}

.hint {
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
}

.error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  color: var(--color-danger);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-weight: var(--weight-medium);
}

.error svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
  margin-top: var(--space-1);
}

/* ---- buttons ---- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  height: var(--control-h);
  padding: 0 var(--space-4);
  border: 1px solid var(--color-border-strong);
  border-radius: var(--radius-1);
  background: var(--color-surface);
  color: var(--color-text);
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  transition: var(--transition);
}

.btn svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
}

.btn:hover {
  border-color: var(--color-faint);
  background: var(--color-surface-2);
  color: var(--color-text);
  text-decoration: none;
}

.btn:active {
  background: var(--color-surface-3);
}

.btn-primary {
  border-color: var(--color-accent);
  background: var(--color-accent);
  color: var(--color-accent-text);
  box-shadow: var(--shadow-1);
}

.btn-primary:hover {
  border-color: var(--color-accent-hover);
  background: var(--color-accent-hover);
  color: var(--color-accent-text);
}

.btn-primary:active {
  border-color: var(--color-accent-press);
  background: var(--color-accent-press);
}

.btn-danger {
  border-color: var(--color-danger);
  background: var(--color-surface);
  color: var(--color-danger);
}

.btn-danger:hover {
  border-color: var(--color-danger);
  background: var(--color-danger-bg);
  color: var(--color-danger);
}

.btn-danger:active {
  background: var(--color-danger-border);
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--color-muted);
}

.btn-ghost:hover {
  border-color: transparent;
  background: var(--color-surface-3);
  color: var(--color-text);
}

.btn-link {
  display: inline;
  height: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: none;
  color: var(--color-link);
  font-weight: var(--weight-medium);
  line-height: inherit;
}

.btn-link:hover {
  background: none;
  color: var(--color-link-hover);
  text-decoration: underline;
  text-underline-offset: var(--space-1);
}

.btn-sm {
  height: var(--control-h-sm);
  padding: 0 var(--space-3);
  font-size: var(--text-sm);
}

.btn-lg {
  height: var(--control-h-lg);
  padding: 0 var(--space-6);
  font-size: var(--text-md);
}

.btn-block {
  width: 100%;
}

.btn-icon {
  width: var(--control-h);
  padding: 0;
}

.btn-icon.btn-sm {
  width: var(--control-h-sm);
}

.btn[disabled],
.btn[aria-disabled="true"] {
  opacity: var(--opacity-disabled);
  cursor: not-allowed;
  pointer-events: none;
}

/* ---- details / summary: the no-JavaScript confirm step and the per-day panels ---- */

details > summary {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  border-radius: var(--radius-1);
  color: var(--color-link);
  font-weight: var(--weight-medium);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: var(--transition);
}

details > summary::-webkit-details-marker {
  display: none;
}

details > summary::before {
  content: "";
  width: var(--space-2);
  height: var(--space-2);
  flex: none;
  border-right: var(--stroke) solid currentColor;
  border-bottom: var(--stroke) solid currentColor;
  transform: rotate(var(--rotate-closed));
  transition: transform var(--duration) var(--ease);
}

details[open] > summary::before {
  transform: rotate(var(--rotate-open));
}

details > summary.btn::before {
  display: none;
}

details > summary:hover {
  color: var(--color-link-hover);
}

details > summary.btn:hover {
  color: var(--color-text);
}

details > summary.btn-danger:hover {
  color: var(--color-danger);
}

details > summary.btn-primary:hover {
  color: var(--color-accent-text);
}

details > :not(summary) {
  margin-top: var(--space-3);
}

/* ==========================================================================================================
   Flash, empty state, feed
   ========================================================================================================== */

.flash {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
  animation: flash-in var(--duration-slow) var(--ease);
}

.flash > svg {
  width: var(--icon);
  height: var(--icon);
  margin-top: var(--space-1);
}

.flash-text {
  margin: 0;
  min-width: 0;
  font-weight: var(--weight-medium);
}

.flash-ok {
  border-color: var(--color-ok-border);
  background: var(--color-ok-bg);
  color: var(--color-ok);
  box-shadow: inset var(--bar-w) 0 0 var(--color-ok), var(--shadow-2);
}

.flash-error {
  border-color: var(--color-danger-border);
  background: var(--color-danger-bg);
  color: var(--color-danger);
  box-shadow: inset var(--bar-w) 0 0 var(--color-danger), var(--shadow-2);
}

@keyframes flash-in {
  from {
    opacity: 0;
    transform: translateY(calc(var(--space-2) * -1));
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-12) var(--space-6);
  border: 1px dashed var(--color-border-strong);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  text-align: center;
}

.empty > svg {
  width: var(--empty-art);
  height: var(--empty-art);
  margin-bottom: var(--space-2);
  color: var(--color-faint);
}

.empty .il-dot {
  fill: var(--color-accent-bright);
}

.empty h1,
.empty h2,
.empty h3,
.empty-title {
  margin: 0;
  font-size: var(--text-md);
  line-height: var(--leading-md);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
}

.empty p {
  max-width: var(--measure);
  margin: 0;
  color: var(--color-muted);
}

.empty .btn,
.empty form {
  margin-top: var(--space-3);
}

.card .empty,
.table-wrap .empty {
  border: 0;
  border-radius: 0;
  background: none;
}

.feed {
  margin: 0;
  padding: 0;
  list-style: none;
}

.feed > li,
.feed-item {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--color-border-subtle);
  transition: background-color var(--duration) var(--ease);
}

.feed > li:last-child {
  border-bottom: 0;
}

.feed > li:hover {
  background: var(--color-row-hover);
}

.feed-time {
  flex: none;
  min-width: var(--feed-time-w);
  padding-top: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-variant-numeric: tabular-nums;
}

.feed-body,
.feed-text {
  flex: 1;
  min-width: 0;
}

.feed-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--avatar-sm);
  height: var(--avatar-sm);
  flex: none;
  border-radius: 50%;
  background: var(--color-neutral-bg);
  color: var(--color-neutral);
}

.feed-icon svg {
  width: var(--icon-sm);
  height: var(--icon-sm);
}

.feed-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  color: var(--color-muted);
  font-size: var(--text-sm);
}

/* ==========================================================================================================
   Charts (inline SVG; shapes get their colour from these classes, never from style attributes)
   ========================================================================================================== */

.ring {
  position: relative;
  width: var(--ring-size);
  max-width: 100%;
  margin: 0 auto;
}

.ring > svg,
.bars > svg,
.daybar > svg {
  display: block;
  width: 100%;
  height: auto;
}

.ring > :not(svg) {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.ring-value {
  font-size: var(--text-xl);
  line-height: var(--leading-lg);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
}

.ring-label {
  color: var(--color-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-xs);
}

:where(.ring) text {
  fill: var(--color-text);
  font-family: var(--font);
}

:where(.ring) circle {
  fill: none;
  stroke: var(--color-track);
}

:where(.ring) circle:where([stroke-dasharray]) {
  stroke: var(--color-accent-bright);
  stroke-linecap: round;
}

.ring .ring-track,
.ring .chart-track {
  stroke: var(--color-track);
}

.ring .ring-value-arc,
.ring .ring-progress,
.ring .ring-fill {
  stroke: var(--color-accent-bright);
  stroke-linecap: round;
}

.bars,
.daybar {
  min-width: 0;
}

:where(.bars) rect {
  fill: var(--color-accent-bright);
}

:where(.daybar) rect {
  fill: var(--color-ink);
}

:where(.bars, .daybar) text,
.chart-label {
  fill: var(--color-muted);
  font-family: var(--font);
  font-size: var(--text-xs);
}

:where(.bars, .daybar) line,
.chart-axis {
  stroke: var(--color-border);
}

:where(.bars) text[data-current],
:where(.bars) .is-current,
:where(.bars) .current,
.chart-label-strong {
  fill: var(--color-text);
  font-weight: var(--weight-semibold);
}

.chart-value {
  fill: var(--color-text);
  font-family: var(--font);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.chart-tick {
  fill: var(--color-faint);
  font-family: var(--font);
  font-size: var(--text-xs);
}

.chart-grid {
  stroke: var(--color-border-subtle);
}

.chart-bar {
  fill: var(--color-accent-bright);
}

.chart-bar-muted {
  fill: var(--color-track);
}

.chart-track,
.daybar-track,
.daybar rect[data-kind="track"] {
  fill: var(--color-track);
}

.daybar-presence,
.daybar rect[data-kind="presence"] {
  fill: var(--color-ink-soft);
}

.daybar-normal,
.daybar rect[data-kind="normal"] {
  fill: var(--color-text);
}

.daybar-overtime,
.daybar rect[data-kind="overtime"] {
  fill: var(--color-accent-bright);
}

.daybar-early,
.daybar rect[data-kind="early"] {
  fill: var(--color-ink-soft);
}

.daybar-hatch {
  stroke: var(--color-faint);
  fill: none;
}

.daybar {
  min-width: calc(var(--space-12) * 3);
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--color-muted);
  font-size: var(--text-sm);
}

.legend > li {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.legend > li::before {
  content: "";
  width: var(--dot);
  height: var(--dot);
  border-radius: 50%;
  background: var(--color-accent-bright);
}

/* ==========================================================================================================
   Sign-in
   ========================================================================================================== */

.auth {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  min-height: var(--screen-h);
}

.auth-aside {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-12);
  overflow: hidden;
  isolation: isolate;
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
}

.auth-aside::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: var(--z-behind);
  opacity: var(--opacity-glow);
  background: radial-gradient(circle at 12% 8%, var(--color-accent-deep) 0, transparent 46%),
    radial-gradient(circle at 92% 100%, var(--color-sidebar-3) 0, transparent 52%);
}

.auth-aside::after {
  content: "";
  position: absolute;
  right: calc(var(--deco-size) / -3);
  bottom: calc(var(--deco-size) / -3);
  z-index: var(--z-behind);
  width: var(--deco-size);
  height: var(--deco-size);
  border: var(--deco-stroke) solid var(--color-sidebar-2);
  border-radius: 50%;
}

.auth-aside-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-4);
  width: 100%;
  max-width: var(--auth-aside-w);
}

.auth-mark {
  width: var(--auth-mark);
  height: var(--auth-mark);
  filter: var(--glow-mark);
}

.auth-wordmark {
  margin: 0;
  color: var(--color-white);
  font-size: var(--text-display);
  line-height: 1;
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-brand);
  text-transform: uppercase;
}

.auth-bar {
  display: block;
  width: var(--space-12);
  height: var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-accent-bright);
}

.auth-tagline {
  margin: 0;
  color: var(--color-sidebar-muted);
  font-size: var(--text-lg);
  line-height: var(--leading-lg);
}

.auth-main {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: var(--space-8) var(--space-6);
  background: var(--color-bg);
}

.auth-main:focus {
  outline: none;
}

.auth-brand {
  display: none;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
}

.auth-brand-name {
  font-size: var(--text-lg);
  font-weight: var(--weight-heavy);
  letter-spacing: var(--tracking-brand);
  text-transform: uppercase;
  color: var(--color-text);
}

.auth-content {
  width: 100%;
  max-width: var(--auth-card-w);
}

.auth-content > * + * {
  margin-top: var(--space-4);
}

.auth-card {
  padding: var(--space-8);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-2);
  background: var(--color-surface);
  box-shadow: var(--shadow-2);
}

.auth-card .page-sub {
  margin-top: var(--space-1);
  margin-bottom: var(--space-6);
}

.auth-card .error {
  margin-top: var(--space-4);
}

/* ==========================================================================================================
   Responsive
   ========================================================================================================== */

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

  .grid-2 > aside,
  .grid-2 > .aside {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(var(--field-min), 1fr));
    align-items: start;
  }
}

@media (max-width: 1099px) {
  .content {
    padding-right: var(--gutter-narrow);
    padding-left: var(--gutter-narrow);
  }

  .kpi-grid,
  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

/* under 1000px the sidebar becomes a top bar: brand left, nav as a scrollable row */
@media (max-width: 999px) {
  .app {
    display: block;
  }

  .sidebar {
    position: sticky;
    z-index: var(--z-topbar);
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand user"
      "nav nav";
    align-items: center;
    gap: var(--space-2) var(--space-4);
    height: auto;
    padding: var(--space-2) var(--space-4) 0;
    overflow: visible;
  }

  .brand-block {
    grid-area: brand;
    flex-direction: row;
    align-items: center;
    padding: 0;
    border-bottom: 0;
  }

  .nav {
    grid-area: nav;
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .nav::-webkit-scrollbar {
    display: none;
  }

  .nav-label {
    display: none;
  }

  .nav-list {
    flex-direction: row;
    gap: var(--space-1);
  }

  .nav-link {
    min-height: var(--control-h);
    white-space: nowrap;
  }

  .nav-link[aria-current="page"]::before {
    top: auto;
    right: var(--space-3);
    bottom: 0;
    left: var(--space-3);
    width: auto;
    height: var(--bar-w);
  }

  .user-block {
    grid-area: user;
    flex-direction: row;
    align-items: center;
    margin: 0;
    padding: 0;
    border-top: 0;
  }

  .user {
    padding: 0;
  }

  .user-text {
    display: none;
  }

  .logout-form .btn {
    width: auto;
  }

  .content {
    padding-top: var(--space-6);
    padding-bottom: var(--space-8);
  }

  .table-wrap {
    max-height: none;
  }

  .table thead th,
  .table tfoot td,
  .table tfoot th {
    position: static;
  }
}

@media (max-width: 899px) {
  .auth {
    grid-template-columns: minmax(0, 1fr);
  }

  .auth-aside {
    display: none;
  }

  .auth-brand {
    display: flex;
  }

  .auth-main {
    justify-content: flex-start;
    padding-top: var(--space-12);
  }
}

@media (max-width: 719px) {
  .brand-sub,
  .sidebar .demo-chip {
    display: none;
  }

  .logout-form .btn span {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .logout-form .btn {
    width: var(--control-h);
    padding: 0;
  }

  .content {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }

  .page-header {
    grid-template-columns: minmax(0, 1fr);
  }

  .page-header > .actions {
    grid-column: 1;
    grid-row: auto;
    justify-self: start;
    margin-top: var(--space-3);
  }

  .toolbar {
    align-items: stretch;
    padding: var(--space-4);
  }

  .toolbar .field {
    flex: 1 1 100%;
  }

  .toolbar .actions,
  .toolbar-end {
    margin-left: 0;
  }

  .card-header,
  .card-body {
    padding-right: var(--space-4);
    padding-left: var(--space-4);
  }

  .table th:first-child,
  .table td:first-child {
    padding-left: var(--space-4);
  }

  .table th:last-child,
  .table td:last-child {
    padding-right: var(--space-4);
  }

  dl {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-1);
  }

  dd {
    margin-bottom: var(--space-3);
  }

  .auth-card {
    padding: var(--space-6);
  }
}

@media (max-width: 479px) {
  .kpi-grid,
  .stats {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ==========================================================================================================
   Accessibility preferences and print
   ========================================================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
    scroll-behavior: auto !important;
  }

  a.card:hover,
  .card-interactive:hover,
  a.kpi:hover {
    transform: none;
  }
}

@media print {
  body {
    background: var(--color-surface);
  }

  .sidebar,
  .skip-link,
  .flash,
  .toolbar,
  .actions,
  .btn,
  .row-actions,
  details > summary {
    display: none !important;
  }

  .app {
    display: block;
  }

  .content {
    max-width: none;
    padding: 0;
  }

  .card,
  .kpi,
  .table-wrap {
    border-color: var(--color-border);
    box-shadow: none;
  }

  .table-wrap {
    max-height: none;
    overflow: visible;
  }

  .table thead th,
  .table tfoot td,
  .table tfoot th {
    position: static;
  }

  .table tr {
    break-inside: avoid;
  }

  a {
    color: inherit;
    text-decoration: none;
  }
}
