/* ==========================================================================
   MediCore HMS — design system
   --------------------------------------------------------------------------
   No framework, no build step, no CDN. One file the browser caches once.
   Written for clinical screens: dense where density helps, generous where a
   mistake would be expensive, and legible at arm's length on a ward monitor.
   ========================================================================== */

/* --- 1. Tokens ---------------------------------------------------------- */

:root {
  color-scheme: light dark;

  /* Brand: a clinical teal that reads as calm rather than corporate. */
  --brand-h: 187;
  --brand: oklch(0.58 0.11 var(--brand-h));
  --brand-strong: oklch(0.48 0.12 var(--brand-h));
  --brand-soft: oklch(0.95 0.03 var(--brand-h));
  --brand-fg: oklch(0.99 0.005 var(--brand-h));

  --accent: oklch(0.62 0.16 265);
  --success: oklch(0.62 0.15 152);
  --warning: oklch(0.72 0.15 78);
  --danger: oklch(0.58 0.19 25);
  --info: oklch(0.62 0.13 240);

  --success-soft: oklch(0.95 0.04 152);
  --warning-soft: oklch(0.96 0.05 78);
  --danger-soft: oklch(0.95 0.04 25);
  --info-soft: oklch(0.95 0.04 240);

  /* Surfaces */
  --bg: oklch(0.98 0.004 220);
  --surface: oklch(1 0 0);
  --surface-2: oklch(0.975 0.004 220);
  --surface-3: oklch(0.955 0.006 220);
  --sidebar-bg: oklch(0.22 0.02 220);
  --sidebar-fg: oklch(0.86 0.01 220);
  --sidebar-muted: oklch(0.62 0.015 220);

  /* Text */
  --fg: oklch(0.22 0.015 250);
  --fg-muted: oklch(0.52 0.015 250);
  --fg-subtle: oklch(0.64 0.012 250);
  --fg-inverse: oklch(0.99 0 0);

  --border: oklch(0.90 0.006 250);
  --border-strong: oklch(0.82 0.008 250);

  /* Type: system stack — instant render, native feel, no font download. */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji";
  --font-mono: ui-monospace, "SF Mono", "Cascadia Mono", "Roboto Mono",
    Menlo, Consolas, monospace;

  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;

  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;

  --radius-sm: 5px;
  --radius: 9px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 999px;

  --shadow-xs: 0 1px 2px oklch(0.2 0.02 250 / 0.05);
  --shadow-sm: 0 1px 3px oklch(0.2 0.02 250 / 0.07), 0 1px 2px oklch(0.2 0.02 250 / 0.04);
  --shadow: 0 4px 12px oklch(0.2 0.02 250 / 0.08), 0 1px 3px oklch(0.2 0.02 250 / 0.05);
  --shadow-lg: 0 12px 32px oklch(0.2 0.02 250 / 0.12), 0 4px 8px oklch(0.2 0.02 250 / 0.06);
  --shadow-xl: 0 24px 56px oklch(0.2 0.02 250 / 0.18);

  --sidebar-w: 252px;
  --header-h: 58px;
  --ring: 0 0 0 3px oklch(from var(--brand) l c h / 0.28);

  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  --fast: 130ms var(--ease);
  --normal: 220ms var(--ease);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: oklch(0.17 0.012 250);
    --surface: oklch(0.21 0.014 250);
    --surface-2: oklch(0.235 0.014 250);
    --surface-3: oklch(0.27 0.015 250);
    --sidebar-bg: oklch(0.145 0.012 250);
    --sidebar-fg: oklch(0.84 0.01 250);
    --sidebar-muted: oklch(0.56 0.012 250);

    --fg: oklch(0.94 0.006 250);
    --fg-muted: oklch(0.70 0.012 250);
    --fg-subtle: oklch(0.58 0.012 250);

    --border: oklch(0.30 0.012 250);
    --border-strong: oklch(0.38 0.014 250);

    --brand: oklch(0.70 0.10 var(--brand-h));
    --brand-strong: oklch(0.78 0.10 var(--brand-h));
    --brand-soft: oklch(0.30 0.04 var(--brand-h));
    --brand-fg: oklch(0.15 0.02 var(--brand-h));

    --success: oklch(0.72 0.14 152);
    --warning: oklch(0.79 0.14 78);
    --danger: oklch(0.70 0.16 25);
    --info: oklch(0.72 0.12 240);

    --success-soft: oklch(0.28 0.05 152);
    --warning-soft: oklch(0.30 0.06 78);
    --danger-soft: oklch(0.29 0.06 25);
    --info-soft: oklch(0.28 0.05 240);

    --shadow-xs: 0 1px 2px oklch(0 0 0 / 0.3);
    --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.35);
    --shadow: 0 4px 14px oklch(0 0 0 / 0.42);
    --shadow-lg: 0 14px 36px oklch(0 0 0 / 0.5);
    --shadow-xl: 0 24px 60px oklch(0 0 0 / 0.6);
  }
}

:root[data-theme="dark"] {
  --bg: oklch(0.17 0.012 250);
  --surface: oklch(0.21 0.014 250);
  --surface-2: oklch(0.235 0.014 250);
  --surface-3: oklch(0.27 0.015 250);
  --sidebar-bg: oklch(0.145 0.012 250);
  --sidebar-fg: oklch(0.84 0.01 250);
  --sidebar-muted: oklch(0.56 0.012 250);
  --fg: oklch(0.94 0.006 250);
  --fg-muted: oklch(0.70 0.012 250);
  --fg-subtle: oklch(0.58 0.012 250);
  --border: oklch(0.30 0.012 250);
  --border-strong: oklch(0.38 0.014 250);
  --brand: oklch(0.70 0.10 var(--brand-h));
  --brand-strong: oklch(0.78 0.10 var(--brand-h));
  --brand-soft: oklch(0.30 0.04 var(--brand-h));
  --brand-fg: oklch(0.15 0.02 var(--brand-h));
  --success: oklch(0.72 0.14 152);
  --warning: oklch(0.79 0.14 78);
  --danger: oklch(0.70 0.16 25);
  --info: oklch(0.72 0.12 240);
  --success-soft: oklch(0.28 0.05 152);
  --warning-soft: oklch(0.30 0.06 78);
  --danger-soft: oklch(0.29 0.06 25);
  --info-soft: oklch(0.28 0.05 240);
  --shadow-sm: 0 1px 3px oklch(0 0 0 / 0.35);
  --shadow: 0 4px 14px oklch(0 0 0 / 0.42);
  --shadow-lg: 0 14px 36px oklch(0 0 0 / 0.5);
}

/* --- 2. Base ------------------------------------------------------------ */

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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--fg);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, h5, h6 {
  margin: 0;
  font-weight: 640;
  line-height: 1.25;
  letter-spacing: -0.011em;
  color: var(--fg);
}
h1 { font-size: var(--text-2xl); }
h2 { font-size: var(--text-xl); }
h3 { font-size: var(--text-lg); }
h4 { font-size: var(--text-md); }

p { margin: 0 0 var(--space-3); }
p:last-child { margin-bottom: 0; }

a {
  color: var(--brand-strong);
  text-decoration: none;
  transition: color var(--fast);
}
a:hover { color: var(--brand); text-decoration: underline; text-underline-offset: 2px; }

img, svg, video { max-width: 100%; height: auto; display: block; }

code, kbd, pre, samp { font-family: var(--font-mono); font-size: 0.92em; }

kbd {
  display: inline-block;
  padding: 1px 5px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  color: var(--fg-muted);
  line-height: 1.5;
}

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

:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; border-radius: 3px; }

::selection { background: oklch(from var(--brand) l c h / 0.25); }

::-webkit-scrollbar { width: 11px; height: 11px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: var(--radius-full);
  border: 3px solid var(--bg);
}
::-webkit-scrollbar-thumb:hover { background: var(--fg-subtle); }

/* --- 3. Layout ---------------------------------------------------------- */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}
.app.is-collapsed { --sidebar-w: 0px; }

.sidebar {
  grid-row: 1 / -1;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow: hidden;
  transition: width var(--normal);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid oklch(1 0 0 / 0.07);
  min-height: var(--header-h);
  flex-shrink: 0;
}
.sidebar__logo {
  width: 30px; height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--brand) 0%, var(--accent) 100%);
  display: grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px oklch(from var(--brand) l c h / 0.4);
}
.sidebar__name {
  font-weight: 660; font-size: var(--text-md); color: #fff;
  letter-spacing: -0.01em; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar__tagline {
  font-size: 10.5px; color: var(--sidebar-muted); letter-spacing: 0.04em;
  text-transform: uppercase; white-space: nowrap;
}

.sidebar__scroll { flex: 1; overflow-y: auto; padding: var(--space-3) 0 var(--space-6); }
.sidebar__scroll::-webkit-scrollbar { width: 6px; }
.sidebar__scroll::-webkit-scrollbar-thumb {
  background: oklch(1 0 0 / 0.12); border: none;
}

.nav-section { margin-bottom: var(--space-1); }
.nav-section__label {
  padding: var(--space-4) var(--space-5) var(--space-2);
  font-size: 10.5px; font-weight: 650; letter-spacing: 0.09em;
  text-transform: uppercase; color: var(--sidebar-muted);
}

.nav-item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: 7px var(--space-5);
  color: var(--sidebar-fg);
  font-size: var(--text-base);
  border-left: 2.5px solid transparent;
  transition: background var(--fast), color var(--fast), border-color var(--fast);
  white-space: nowrap;
}
.nav-item:hover {
  background: oklch(1 0 0 / 0.055); color: #fff; text-decoration: none;
}
.nav-item.is-active {
  background: oklch(1 0 0 / 0.085);
  color: #fff;
  border-left-color: var(--brand);
  font-weight: 560;
}
.nav-item__icon { width: 17px; height: 17px; flex-shrink: 0; opacity: 0.8; }
.nav-item.is-active .nav-item__icon { opacity: 1; color: var(--brand-strong); }
.nav-item__label { flex: 1; overflow: hidden; text-overflow: ellipsis; }
.nav-item__badge {
  background: var(--brand); color: var(--brand-fg);
  font-size: 10.5px; font-weight: 700;
  padding: 1px 6px; border-radius: var(--radius-full);
  min-width: 19px; text-align: center;
}
.nav-item__badge--alert { background: var(--danger); color: #fff; }

.sidebar__footer {
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid oklch(1 0 0 / 0.07);
  flex-shrink: 0;
}

/* Header ---------------------------------------------------------------- */

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

.header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-h);
  display: flex; align-items: center; gap: var(--space-3);
  padding: 0 var(--space-5);
  background: oklch(from var(--surface) l c h / 0.86);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}

.header__search { position: relative; flex: 1; max-width: 460px; }
.header__search input {
  width: 100%;
  height: 34px;
  padding: 0 var(--space-3) 0 34px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--fg);
  font-size: var(--text-base);
  font-family: inherit;
  transition: border-color var(--fast), box-shadow var(--fast), background var(--fast);
}
.header__search input:focus {
  outline: none; border-color: var(--brand);
  background: var(--surface); box-shadow: var(--ring);
}
.header__search-icon {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; color: var(--fg-subtle); pointer-events: none;
}
.header__search-kbd {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  pointer-events: none;
}

.header__actions { display: flex; align-items: center; gap: var(--space-2); margin-left: auto; }

.content { flex: 1; padding: var(--space-6) var(--space-6) var(--space-12); min-width: 0; }
.content--wide { max-width: none; }
.content--narrow { max-width: 880px; }

.page-head {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: var(--space-4); margin-bottom: var(--space-5); flex-wrap: wrap;
}
.page-head__title { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.page-head__eyebrow {
  font-size: var(--text-xs); font-weight: 620; letter-spacing: 0.07em;
  text-transform: uppercase; color: var(--fg-subtle);
}
.page-head h1 { font-size: var(--text-2xl); }
.page-head__subtitle { color: var(--fg-muted); font-size: var(--text-base); }
.page-head__actions { display: flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }

.breadcrumbs {
  display: flex; align-items: center; gap: var(--space-2); flex-wrap: wrap;
  font-size: var(--text-sm); color: var(--fg-subtle); margin-bottom: var(--space-2);
}
.breadcrumbs a { color: var(--fg-muted); }
.breadcrumbs span[aria-hidden] { opacity: 0.45; }

/* --- 4. Buttons --------------------------------------------------------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: var(--space-2);
  height: 34px; padding: 0 var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit; font-size: var(--text-base); font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background var(--fast), border-color var(--fast),
              box-shadow var(--fast), transform var(--fast), color var(--fast);
  box-shadow: var(--shadow-xs);
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); text-decoration: none; }
.btn:active { transform: translateY(0.5px); box-shadow: none; }
.btn:disabled, .btn.is-disabled {
  opacity: 0.5; cursor: not-allowed; pointer-events: none;
}
.btn svg { width: 15px; height: 15px; flex-shrink: 0; }

.btn--primary {
  background: var(--brand-strong); border-color: var(--brand-strong); color: var(--brand-fg);
  box-shadow: 0 1px 2px oklch(from var(--brand) l c h / 0.3);
}
.btn--primary:hover { background: var(--brand); border-color: var(--brand); color: var(--brand-fg); }

.btn--danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn--danger:hover { filter: brightness(1.08); color: #fff; }

.btn--success { background: var(--success); border-color: var(--success); color: #fff; }
.btn--success:hover { filter: brightness(1.08); color: #fff; }

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

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

.btn--sm { height: 28px; padding: 0 var(--space-3); font-size: var(--text-sm); }
.btn--sm svg { width: 13px; height: 13px; }
.btn--lg { height: 40px; padding: 0 var(--space-5); font-size: var(--text-md); }
.btn--icon { width: 34px; padding: 0; }
.btn--icon.btn--sm { width: 28px; }
.btn--block { width: 100%; }

.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: var(--radius) 0 0 var(--radius); margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 var(--radius) var(--radius) 0; }
.btn-group .btn.is-active { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-strong); z-index: 1; }

/* --- 5. Cards ----------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card + .card { margin-top: var(--space-4); }

.card__header {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.card__title { font-size: var(--text-md); font-weight: 620; margin: 0; }
.card__subtitle { font-size: var(--text-sm); color: var(--fg-muted); margin-top: 1px; }
.card__body { padding: var(--space-5); }
.card__body--flush { padding: 0; }
.card__body--tight { padding: var(--space-3) var(--space-4); }
.card__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
  font-size: var(--text-sm);
}
.card--accent { border-top: 3px solid var(--brand); }
.card--danger { border-color: oklch(from var(--danger) l c h / 0.4); }
.card--warning { border-color: oklch(from var(--warning) l c h / 0.4); }

/* --- 6. Grid ------------------------------------------------------------ */

.grid { display: grid; gap: var(--space-4); }
.grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid--auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.grid--sidebar { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; }
.grid--sidebar-left { grid-template-columns: 300px minmax(0, 1fr); align-items: start; }

.stack { display: flex; flex-direction: column; gap: var(--space-4); }
.stack--sm { gap: var(--space-2); }
.stack--lg { gap: var(--space-6); }

.row {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
}
.row--between { justify-content: space-between; }
.row--end { justify-content: flex-end; }
.row--tight { gap: var(--space-2); }
.row--top { align-items: flex-start; }

/* --- 7. KPI tiles ------------------------------------------------------- */

.kpi {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-4) var(--space-5);
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: var(--space-1);
  overflow: hidden;
  transition: box-shadow var(--fast), transform var(--fast), border-color var(--fast);
}
a.kpi:hover {
  text-decoration: none; box-shadow: var(--shadow); transform: translateY(-1px);
  border-color: var(--border-strong);
}
.kpi::after {
  content: ""; position: absolute; inset: 0 auto 0 0; width: 3px;
  background: var(--tone, var(--brand));
}
.kpi--accent { --tone: var(--brand); }
.kpi--info { --tone: var(--info); }
.kpi--success { --tone: var(--success); }
.kpi--warning { --tone: var(--warning); }
.kpi--danger { --tone: var(--danger); }

.kpi__label {
  font-size: var(--text-xs); font-weight: 600; letter-spacing: 0.045em;
  text-transform: uppercase; color: var(--fg-subtle);
}
.kpi__value {
  font-size: var(--text-3xl); font-weight: 680; line-height: 1.1;
  letter-spacing: -0.025em; color: var(--fg);
  font-variant-numeric: tabular-nums;
}
.kpi__hint { font-size: var(--text-sm); color: var(--fg-muted); }
.kpi__trend { margin-top: var(--space-2); color: var(--tone, var(--brand)); opacity: 0.75; }

/* --- 8. Tables ---------------------------------------------------------- */

.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

.table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.table th {
  position: sticky; top: 0; z-index: 2;
  padding: var(--space-3) var(--space-4);
  text-align: left; font-weight: 620; font-size: var(--text-xs);
  letter-spacing: 0.045em; text-transform: uppercase; color: var(--fg-subtle);
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table td {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.table tbody tr { transition: background var(--fast); }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table--compact th, .table--compact td { padding: var(--space-2) var(--space-3); }
.table__num { text-align: right; font-variant-numeric: tabular-nums; }
.table__actions { width: 1%; white-space: nowrap; text-align: right; }
.table a { font-weight: 550; }
.table--striped tbody tr:nth-child(even) { background: oklch(from var(--surface-2) l c h / 0.5); }

.cell-primary { font-weight: 570; color: var(--fg); display: block; }
.cell-meta { font-size: var(--text-sm); color: var(--fg-muted); display: block; }
.cell-mono { font-family: var(--font-mono); font-size: var(--text-sm); }

/* --- 9. Badges & pills -------------------------------------------------- */

.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: 600;
  line-height: 1.6; white-space: nowrap;
  border: 1px solid transparent;
}
.badge--neutral { background: var(--surface-3); color: var(--fg-muted); }
.badge--accent  { background: var(--brand-soft); color: var(--brand-strong); }
.badge--info    { background: var(--info-soft); color: oklch(from var(--info) calc(l - 0.16) c h); }
.badge--success { background: var(--success-soft); color: oklch(from var(--success) calc(l - 0.16) c h); }
.badge--warning { background: var(--warning-soft); color: oklch(from var(--warning) calc(l - 0.26) c h); }
.badge--danger  { background: var(--danger-soft); color: oklch(from var(--danger) calc(l - 0.12) c h); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .badge--info { color: var(--info); }
  :root:not([data-theme="light"]) .badge--success { color: var(--success); }
  :root:not([data-theme="light"]) .badge--warning { color: var(--warning); }
  :root:not([data-theme="light"]) .badge--danger { color: var(--danger); }
  :root:not([data-theme="light"]) .badge--accent { color: var(--brand-strong); }
}
:root[data-theme="dark"] .badge--info { color: var(--info); }
:root[data-theme="dark"] .badge--success { color: var(--success); }
:root[data-theme="dark"] .badge--warning { color: var(--warning); }
:root[data-theme="dark"] .badge--danger { color: var(--danger); }
:root[data-theme="dark"] .badge--accent { color: var(--brand-strong); }

.dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
  background: var(--fg-subtle); display: inline-block;
}
.dot--success { background: var(--success); }
.dot--warning { background: var(--warning); }
.dot--danger { background: var(--danger); }
.dot--info { background: var(--info); }
.dot--pulse { animation: pulse 2s var(--ease) infinite; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 currentColor; }
  50% { opacity: 0.65; box-shadow: 0 0 0 4px transparent; }
}

.avatar {
  border-radius: 50%; flex-shrink: 0; object-fit: cover;
  display: inline-grid; place-items: center;
}
.avatar--text { color: oklch(0.2 0.02 250); font-weight: 640; letter-spacing: -0.02em; }

.sparkline { display: block; overflow: visible; }
.sparkline--accent { color: var(--brand); }
.sparkline--success { color: var(--success); }
.sparkline--warning { color: var(--warning); }
.sparkline--danger { color: var(--danger); }
.sparkline--info { color: var(--info); }

/* --- 10. Forms ---------------------------------------------------------- */

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

.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field__label {
  font-size: var(--text-sm); font-weight: 580; color: var(--fg);
  display: flex; align-items: center; gap: 5px;
}
.field__required { color: var(--danger); font-weight: 700; }
.field__help { font-size: var(--text-sm); color: var(--fg-muted); line-height: 1.45; }
.field__error {
  font-size: var(--text-sm); color: var(--danger); font-weight: 540;
  display: flex; align-items: flex-start; gap: 5px;
}
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea { border-color: var(--danger); }

.input, .select, .textarea {
  width: 100%;
  min-height: 34px;
  padding: 6px var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--fg);
  font: inherit; font-size: var(--text-base);
  transition: border-color var(--fast), box-shadow var(--fast);
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--brand); box-shadow: var(--ring);
}
.input:disabled, .select:disabled, .textarea:disabled {
  background: var(--surface-3); color: var(--fg-subtle); cursor: not-allowed;
}
.input::placeholder, .textarea::placeholder { color: var(--fg-subtle); }
.textarea { resize: vertical; line-height: 1.55; min-height: 76px; }

.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.input--colour { padding: 3px; height: 34px; cursor: pointer; }

.checkbox, input[type="radio"] {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--brand-strong);
  cursor: pointer; flex-shrink: 0;
}

.check-row {
  display: flex; align-items: flex-start; gap: var(--space-2);
  font-size: var(--text-base); cursor: pointer; padding: 3px 0;
}
.check-row span { line-height: 1.4; }

.file-input {
  padding: 5px var(--space-3);
  font-size: var(--text-sm);
  background: var(--surface-2);
  cursor: pointer;
}
.file-input::file-selector-button {
  margin-right: var(--space-3); padding: 4px 10px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg); font: inherit;
  font-size: var(--text-sm); cursor: pointer;
}

.form-grid { display: grid; gap: var(--space-4); grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.form-grid--4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form-grid .field--full { grid-column: 1 / -1; }

.fieldset {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5) var(--space-5);
  margin: 0;
}
.fieldset legend {
  padding: 0 var(--space-2);
  font-size: var(--text-sm); font-weight: 620;
  letter-spacing: 0.03em; text-transform: uppercase; color: var(--fg-subtle);
}

.form-actions {
  display: flex; gap: var(--space-3); align-items: center;
  padding-top: var(--space-4); border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.form-actions--sticky {
  position: sticky; bottom: 0;
  background: oklch(from var(--surface) l c h / 0.94);
  backdrop-filter: blur(10px);
  margin: 0 calc(var(--space-5) * -1) calc(var(--space-5) * -1);
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  z-index: 10;
}

.filter-bar {
  display: flex; gap: var(--space-2); align-items: flex-end;
  flex-wrap: wrap; margin-bottom: var(--space-4);
  padding: var(--space-3) var(--space-4);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xs);
}
.filter-bar .field { min-width: 140px; flex: 0 1 auto; }
.filter-bar .field--grow { flex: 1 1 220px; }

/* --- 11. Alerts & messages ---------------------------------------------- */

.alert {
  display: flex; gap: var(--space-3); align-items: flex-start;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface-2);
  font-size: var(--text-base);
  line-height: 1.5;
}
.alert__icon { width: 17px; height: 17px; flex-shrink: 0; margin-top: 2px; }
.alert__body { flex: 1; min-width: 0; }
.alert__title { font-weight: 620; margin-bottom: 2px; }
.alert__text { color: var(--fg-muted); }
.alert__close { margin-left: auto; flex-shrink: 0; }

.alert--info    { background: var(--info-soft);    border-color: oklch(from var(--info) l c h / 0.3);    color: oklch(from var(--info) calc(l - 0.2) c h); }
.alert--success { background: var(--success-soft); border-color: oklch(from var(--success) l c h / 0.3); color: oklch(from var(--success) calc(l - 0.2) c h); }
.alert--warning { background: var(--warning-soft); border-color: oklch(from var(--warning) l c h / 0.35); color: oklch(from var(--warning) calc(l - 0.32) c h); }
.alert--danger  { background: var(--danger-soft);  border-color: oklch(from var(--danger) l c h / 0.3);  color: oklch(from var(--danger) calc(l - 0.14) c h); }

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .alert--info { color: oklch(0.9 0.05 240); }
  :root:not([data-theme="light"]) .alert--success { color: oklch(0.9 0.05 152); }
  :root:not([data-theme="light"]) .alert--warning { color: oklch(0.92 0.06 78); }
  :root:not([data-theme="light"]) .alert--danger { color: oklch(0.9 0.06 25); }
}
:root[data-theme="dark"] .alert--info { color: oklch(0.9 0.05 240); }
:root[data-theme="dark"] .alert--success { color: oklch(0.9 0.05 152); }
:root[data-theme="dark"] .alert--warning { color: oklch(0.92 0.06 78); }
:root[data-theme="dark"] .alert--danger { color: oklch(0.9 0.06 25); }

.toasts {
  position: fixed; bottom: var(--space-5); right: var(--space-5);
  z-index: 200; display: flex; flex-direction: column; gap: var(--space-2);
  max-width: 400px; pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: var(--space-3) var(--space-4);
  display: flex; gap: var(--space-3); align-items: flex-start;
  animation: toast-in 280ms var(--ease);
}
.toast--success { border-left-color: var(--success); }
.toast--warning { border-left-color: var(--warning); }
.toast--danger  { border-left-color: var(--danger); }
.toast--info    { border-left-color: var(--info); }
.toast.is-leaving { animation: toast-out 200ms var(--ease) forwards; }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(18px) scale(0.97); }
  to   { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(18px) scale(0.97); }
}

/* --- 12. Empty & loading states ----------------------------------------- */

.empty {
  text-align: center; padding: var(--space-12) var(--space-5);
  color: var(--fg-muted);
}
.empty__icon {
  width: 42px; height: 42px; margin: 0 auto var(--space-4);
  color: var(--fg-subtle); opacity: 0.55;
}
.empty__title {
  font-size: var(--text-md); font-weight: 600; color: var(--fg);
  margin-bottom: var(--space-1);
}
.empty__text { font-size: var(--text-base); max-width: 42ch; margin: 0 auto var(--space-4); }

.skeleton {
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite linear;
  border-radius: var(--radius-sm);
}
@keyframes shimmer { to { background-position: -200% 0; } }

.spinner {
  width: 15px; height: 15px;
  border: 2px solid oklch(from var(--fg) l c h / 0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 620ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* --- 13. Modal & palette ------------------------------------------------ */

.overlay {
  position: fixed; inset: 0; z-index: 100;
  background: oklch(0.18 0.02 250 / 0.55);
  backdrop-filter: blur(3px);
  display: grid; place-items: start center;
  padding: 12vh var(--space-4) var(--space-4);
  animation: fade-in 140ms var(--ease);
}
.overlay[hidden] { display: none; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  width: min(560px, 100%);
  max-height: 76vh;
  display: flex; flex-direction: column;
  overflow: hidden;
  animation: modal-in 200ms var(--ease);
}
@keyframes modal-in {
  from { opacity: 0; transform: translateY(-10px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
.modal--wide { width: min(820px, 100%); }
.modal__header {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: var(--space-3);
}
.modal__body { padding: var(--space-5); overflow-y: auto; flex: 1; }
.modal__footer {
  padding: var(--space-3) var(--space-5);
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex; gap: var(--space-2); justify-content: flex-end;
}

.palette__input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border);
  padding: var(--space-4) var(--space-5);
  font: inherit; font-size: var(--text-lg);
  background: transparent; color: var(--fg);
}
.palette__input:focus { outline: none; }
.palette__list { overflow-y: auto; padding: var(--space-2); max-height: 52vh; }
.palette__item {
  display: flex; align-items: center; gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius);
  cursor: pointer; color: var(--fg);
}
.palette__item:hover, .palette__item.is-active {
  background: var(--brand-soft); color: var(--brand-strong); text-decoration: none;
}
.palette__item-label { flex: 1; font-weight: 540; }
.palette__item-section { font-size: var(--text-xs); color: var(--fg-subtle); }
.palette__footer {
  padding: var(--space-2) var(--space-5);
  border-top: 1px solid var(--border);
  font-size: var(--text-xs); color: var(--fg-subtle);
  display: flex; gap: var(--space-4);
}

/* --- 14. Tabs, timeline, misc ------------------------------------------- */

.tabs {
  display: flex; gap: var(--space-1);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--space-5);
  overflow-x: auto;
}
.tab {
  padding: var(--space-3) var(--space-4);
  border-bottom: 2px solid transparent;
  color: var(--fg-muted);
  font-weight: 550; font-size: var(--text-base);
  white-space: nowrap; cursor: pointer;
  transition: color var(--fast), border-color var(--fast);
  background: none; border-top: 0; border-left: 0; border-right: 0;
  font-family: inherit;
}
.tab:hover { color: var(--fg); text-decoration: none; }
.tab.is-active { color: var(--brand-strong); border-bottom-color: var(--brand); }
.tab__count {
  margin-left: 5px; font-size: var(--text-xs); color: var(--fg-subtle);
  background: var(--surface-3); padding: 0 5px; border-radius: var(--radius-full);
}

.timeline { position: relative; padding-left: var(--space-6); }
.timeline::before {
  content: ""; position: absolute; left: 6px; top: 6px; bottom: 6px;
  width: 1.5px; background: var(--border);
}
.timeline__item { position: relative; padding-bottom: var(--space-5); }
.timeline__item:last-child { padding-bottom: 0; }
.timeline__dot {
  position: absolute; left: calc(var(--space-6) * -1); top: 5px;
  width: 13px; height: 13px; border-radius: 50%;
  background: var(--surface); border: 2.5px solid var(--brand);
}
.timeline__dot--success { border-color: var(--success); }
.timeline__dot--warning { border-color: var(--warning); }
.timeline__dot--danger  { border-color: var(--danger); }
.timeline__time { font-size: var(--text-xs); color: var(--fg-subtle); }
.timeline__title { font-weight: 570; }
.timeline__body { font-size: var(--text-sm); color: var(--fg-muted); }

.meter {
  height: 7px; border-radius: var(--radius-full);
  background: var(--surface-3); overflow: hidden;
}
.meter__fill {
  height: 100%; border-radius: var(--radius-full);
  background: var(--brand);
  transition: width var(--normal);
}
.meter__fill--success { background: var(--success); }
.meter__fill--warning { background: var(--warning); }
.meter__fill--danger  { background: var(--danger); }

.definition { display: grid; gap: var(--space-3); }
.definition__row {
  display: grid; grid-template-columns: minmax(120px, 34%) 1fr;
  gap: var(--space-3); align-items: baseline;
}
.definition__label { font-size: var(--text-sm); color: var(--fg-muted); }
.definition__value { font-weight: 540; min-width: 0; overflow-wrap: anywhere; }

.pagination {
  display: flex; align-items: center; justify-content: space-between;
  gap: var(--space-3); padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border); font-size: var(--text-sm);
  color: var(--fg-muted); flex-wrap: wrap;
}
.pagination__pages { display: flex; gap: var(--space-1); }

.prose { max-width: 72ch; line-height: 1.68; }
.prose h1, .prose h2, .prose h3 { margin: var(--space-5) 0 var(--space-2); }
.prose h1:first-child, .prose h2:first-child, .prose h3:first-child { margin-top: 0; }
.prose ul, .prose ol { padding-left: var(--space-5); margin: 0 0 var(--space-3); }
.prose li { margin-bottom: var(--space-1); }
.prose strong { font-weight: 620; }

.ai-output {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-left: 3px solid var(--brand);
  border-radius: var(--radius);
  padding: var(--space-4) var(--space-5);
  white-space: pre-wrap;
  line-height: 1.68;
  font-size: var(--text-md);
  overflow-wrap: anywhere;
}

.ai-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: var(--radius-full);
  background: linear-gradient(135deg,
    oklch(from var(--brand) l c h / 0.15),
    oklch(from var(--accent) l c h / 0.15));
  border: 1px solid oklch(from var(--brand) l c h / 0.3);
  color: var(--brand-strong);
  font-size: var(--text-xs); font-weight: 620;
}

.bed {
  aspect-ratio: 1; min-height: 62px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-2);
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: var(--text-xs);
  background: var(--surface);
  transition: transform var(--fast), box-shadow var(--fast);
  cursor: pointer; color: var(--fg);
}
.bed:hover { transform: translateY(-1.5px); box-shadow: var(--shadow); text-decoration: none; }
.bed__number { font-weight: 670; font-size: var(--text-sm); }
.bed__patient { color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bed--available  { background: var(--success-soft); border-color: oklch(from var(--success) l c h / 0.35); }
.bed--occupied   { background: var(--info-soft);    border-color: oklch(from var(--info) l c h / 0.35); }
.bed--reserved   { background: var(--warning-soft); border-color: oklch(from var(--warning) l c h / 0.35); }
.bed--cleaning   { background: var(--surface-3); border-style: dashed; }
.bed--maintenance{ background: var(--danger-soft);  border-color: oklch(from var(--danger) l c h / 0.35); }

.bed-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(88px, 1fr)); gap: var(--space-2); }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: var(--space-2); }
.slot {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: var(--text-sm); text-align: center; background: var(--surface);
  color: var(--fg); transition: all var(--fast);
}
.slot--free { border-color: oklch(from var(--success) l c h / 0.4); background: var(--success-soft); cursor: pointer; }
.slot--free:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); text-decoration: none; }
.slot--booked { background: var(--info-soft); border-color: oklch(from var(--info) l c h / 0.35); }
.slot--blocked { background: var(--danger-soft); border-color: oklch(from var(--danger) l c h / 0.3); opacity: 0.75; }
.slot--past { opacity: 0.4; background: var(--surface-3); }
.slot__time { font-weight: 640; font-variant-numeric: tabular-nums; }
.slot__label { font-size: var(--text-xs); color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.roster-grid { width: 100%; border-collapse: separate; border-spacing: 2px; font-size: var(--text-sm); }
.roster-grid th { background: var(--surface-2); padding: var(--space-2); border-radius: var(--radius-sm); font-size: var(--text-xs); }
.roster-grid td { background: var(--surface-2); padding: var(--space-1); border-radius: var(--radius-sm); vertical-align: top; min-width: 92px; }
.roster-grid td.is-today { outline: 2px solid var(--brand); }
.shift-chip {
  display: block; padding: 3px 6px; border-radius: var(--radius-sm);
  font-size: 11px; font-weight: 580; margin-bottom: 2px;
  color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.token-card {
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: var(--space-4); background: var(--surface); text-align: center;
}
.token-card__number {
  font-size: var(--text-3xl); font-weight: 720; letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums; color: var(--brand-strong);
}

/* --- 15. Utilities ------------------------------------------------------ */

.text-xs { font-size: var(--text-xs); }
.text-sm { font-size: var(--text-sm); }
.text-md { font-size: var(--text-md); }
.text-lg { font-size: var(--text-lg); }
.text-xl { font-size: var(--text-xl); }
.text-2xl { font-size: var(--text-2xl); }
.muted { color: var(--fg-muted); }
.subtle { color: var(--fg-subtle); }
.strong { font-weight: 620; }
.semibold { font-weight: 560; }
.mono { font-family: var(--font-mono); }
.nums { font-variant-numeric: tabular-nums; }
.uppercase { text-transform: uppercase; letter-spacing: 0.05em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-success { color: var(--success); }
.text-warning { color: oklch(from var(--warning) calc(l - 0.14) c h); }
.text-danger { color: var(--danger); }
.text-brand { color: var(--brand-strong); }

.mt-0 { margin-top: 0; } .mt-1 { margin-top: var(--space-1); }
.mt-2 { margin-top: var(--space-2); } .mt-3 { margin-top: var(--space-3); }
.mt-4 { margin-top: var(--space-4); } .mt-5 { margin-top: var(--space-5); }
.mt-6 { margin-top: var(--space-6); }
.mb-0 { margin-bottom: 0; } .mb-2 { margin-bottom: var(--space-2); }
.mb-3 { margin-bottom: var(--space-3); } .mb-4 { margin-bottom: var(--space-4); }
.mb-5 { margin-bottom: var(--space-5); }
.ml-auto { margin-left: auto; }

.flex { display: flex; } .grow { flex: 1; } .shrink-0 { flex-shrink: 0; }
.items-center { align-items: center; } .items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-1); } .gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); } .gap-4 { gap: var(--space-4); }
.wrap { flex-wrap: wrap; }
.full { width: 100%; }
.hidden { display: none !important; }
.relative { position: relative; }

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

.divider { height: 1px; background: var(--border); margin: var(--space-4) 0; }
.divider--vertical { width: 1px; height: 20px; background: var(--border); margin: 0 var(--space-2); }

/* --- 16. Responsive ----------------------------------------------------- */

@media (max-width: 1200px) {
  .grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid--sidebar, .grid--sidebar-left { grid-template-columns: minmax(0, 1fr); }
  .form-grid--4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

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

@media (max-width: 780px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed; top: 0; left: 0; bottom: 0;
    width: 262px; z-index: 90;
    transform: translateX(-100%);
    transition: transform var(--normal);
    box-shadow: var(--shadow-xl);
  }
  .app.is-open .sidebar { transform: none; }
  .scrim {
    position: fixed; inset: 0; z-index: 80;
    background: oklch(0.18 0.02 250 / 0.5);
  }
  .content { padding: var(--space-4) var(--space-4) var(--space-10); }
  .grid--2, .grid--3, .grid--4 { grid-template-columns: minmax(0, 1fr); }
  .form-grid, .form-grid--3, .form-grid--4 { grid-template-columns: minmax(0, 1fr); }
  .header__search { max-width: none; }
  .header__search-kbd { display: none; }
  .page-head { flex-direction: column; align-items: stretch; }
  .kpi__value { font-size: var(--text-2xl); }
  .definition__row { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .toasts { left: var(--space-4); right: var(--space-4); bottom: var(--space-4); max-width: none; }
}

/* --- 17. Print ---------------------------------------------------------- */

@media print {
  :root { --bg: #fff; --surface: #fff; --fg: #000; --border: #ccc; }
  .sidebar, .header, .no-print, .toasts, .form-actions { display: none !important; }
  .app { display: block; }
  .content { padding: 0; }
  .card { border: 1px solid #ddd; box-shadow: none; break-inside: avoid; }
  .table th { background: #f4f4f4 !important; -webkit-print-color-adjust: exact; }
  a { color: #000; text-decoration: none; }
  .print-doc { max-width: 100%; padding: 0; }
  @page { margin: 14mm; }
}

.print-doc { max-width: 800px; margin: 0 auto; padding: var(--space-8) var(--space-5); background: var(--surface); }
.print-head {
  display: flex; justify-content: space-between; align-items: flex-start;
  gap: var(--space-5); padding-bottom: var(--space-4);
  border-bottom: 2px solid var(--fg); margin-bottom: var(--space-5);
}
.print-title { font-size: var(--text-xl); font-weight: 700; letter-spacing: 0.02em; text-transform: uppercase; }
.print-sign {
  margin-top: var(--space-10); padding-top: var(--space-2);
  border-top: 1px solid var(--fg); width: 220px; font-size: var(--text-sm);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
