/**
 * Design System — v1.0
 *
 * A self-contained CSS design system built on OKLCH color tokens.
 * No framework required. Works with any HTML/JS stack.
 *
 * Usage
 * -----
 * 1. Import this file in your project's entry point.
 * 2. Pair with ui.tsx (React components) for a full component library.
 * 3. Override tokens in :root to theme the system.
 *
 * Sections
 * --------
 *  1. Tokens (colors, radii, shadows)
 *  2. Base reset
 *  3. Typography helpers
 *  4. Buttons
 *  5. Cards
 *  6. Stat grid
 *  7. Status pills
 *  8. Data table
 *  9. Form inputs
 * 10. Segmented control
 * 11. Tabs
 * 12. Definition list
 * 13. Alert
 * 14. Progress bar
 * 15. Avatars
 * 16. Mode cards
 * 17. Weekday pills
 * 18. Modal
 * 19. Toast
 * 20. Search modal
 * 21. App shell & navigation
 * 22. Page layout
 * 23. Calendar
 * 24. Responsive
 */

/* ─────────────────────────────────────────────────────────────────────────────
   1. TOKENS
   ───────────────────────────────────────────────────────────────────────── */

:root {
  /* Backgrounds */
  --bg: oklch(0.985 0.003 250);
  --surface: #ffffff;
  --surface-2: oklch(0.975 0.004 250);

  /* Borders */
  --border: oklch(0.92 0.006 250);
  --border-strong: oklch(0.86 0.008 250);

  /* Text */
  --text: oklch(0.18 0.012 250);
  --text-muted: oklch(0.52 0.012 250);
  --text-faint: oklch(0.68 0.01 250);

  /* Primary */
  --primary: oklch(0.27 0.045 255);
  --primary-hover: oklch(0.22 0.048 255);
  --primary-soft: oklch(0.96 0.012 255);

  /* Semantic — foreground */
  --success: oklch(0.58 0.13 155);
  --warning: oklch(0.66 0.14 70);
  --danger: oklch(0.58 0.18 25);
  --info: oklch(0.55 0.12 235);
  --purple: oklch(0.55 0.13 295);

  /* Semantic — soft backgrounds */
  --success-soft: oklch(0.96 0.04 155);
  --warning-soft: oklch(0.965 0.04 80);
  --danger-soft: oklch(0.965 0.03 25);
  --info-soft: oklch(0.965 0.025 235);
  --purple-soft: oklch(0.965 0.025 295);

  /* Shadows */
  --shadow-sm: 0 1px 2px oklch(0.2 0.02 250 / 0.04);
  --shadow: 0 1px 3px oklch(0.2 0.02 250 / 0.06), 0 4px 12px oklch(0.2 0.02 250 / 0.04);

  /* Radii */
  --r-sm: 6px;
  --r: 8px;
  --r-md: 10px;
  --r-lg: 12px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   2. BASE
   ───────────────────────────────────────────────────────────────────────── */

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

html, body {
  background: var(--bg);
  color: var(--text);
}

body {
  font-size: 14px;
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01", "cv11";
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  margin: 0;
}

code, .mono, kbd {
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
}

button { cursor: pointer; }

:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ─────────────────────────────────────────────────────────────────────────────
   3. TYPOGRAPHY HELPERS
   ───────────────────────────────────────────────────────────────────────── */

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

/* ─────────────────────────────────────────────────────────────────────────────
   4. BUTTONS
   ───────────────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  transition: background 80ms;
  white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--surface-2); }

.btn-primary {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.btn-primary:hover { background: oklch(0.1 0.01 250); }

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

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

.btn-success {
  background: var(--success);
  color: white;
  border-color: var(--success);
}

.btn-sm { padding: 4px 8px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ─────────────────────────────────────────────────────────────────────────────
   5. CARDS
   ───────────────────────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { margin: 0; font-size: 13.5px; font-weight: 600; }
.card-body { padding: 16px; }

/* ─────────────────────────────────────────────────────────────────────────────
   6. STAT GRID
   ───────────────────────────────────────────────────────────────────────── */

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
}

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.stat-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.stat-value {
  font-size: 26px;
  font-weight: 500;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.stat-value.mono { font-feature-settings: "ss02", "tnum"; }
.stat-sub { font-size: 11.5px; color: var(--text-faint); margin-top: 6px; }
.stat-sub.warn  { color: var(--warning); }
.stat-sub.danger { color: var(--danger); }

/* ─────────────────────────────────────────────────────────────────────────────
   7. STATUS PILLS
   ───────────────────────────────────────────────────────────────────────── */

.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  letter-spacing: 0.005em;
  white-space: nowrap;
}
.pill-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}

/* Status variants */
.pill.draft       { background: var(--surface-2); color: var(--text-muted); border: 1px solid var(--border); }
.pill.dispatched  { background: var(--info-soft); color: var(--info); }
.pill.filled      { background: var(--success-soft); color: var(--success); }
.pill.cancelled   { background: var(--danger-soft); color: var(--danger); }
.pill.pending     { background: var(--warning-soft); color: var(--warning); }
.pill.accepted    { background: var(--success-soft); color: var(--success); }
.pill.declined    { background: var(--danger-soft); color: var(--danger); }
.pill.series      { background: var(--purple-soft); color: var(--purple); }
.pill.info        { background: var(--info-soft); color: var(--info); }

/* Borderless subtle variant */
.pill-subtle {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  padding: 2px 7px;
  border-radius: 999px;
  line-height: 1.5;
  white-space: nowrap;
}

/* ─────────────────────────────────────────────────────────────────────────────
   8. DATA TABLE
   ───────────────────────────────────────────────────────────────────────── */

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.data-table thead th {
  text-align: left;
  font-weight: 500;
  color: var(--text-muted);
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.data-table tbody td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table tbody tr.clickable { cursor: pointer; }

/* ─────────────────────────────────────────────────────────────────────────────
   9. FORM INPUTS
   ───────────────────────────────────────────────────────────────────────── */

.field-label {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text);
  display: block;
  margin-bottom: 6px;
}
.field-hint { font-size: 11.5px; color: var(--text-faint); margin-top: 4px; }

.input, .ds-select, .ds-textarea {
  width: 100%;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  font-size: 13.5px;
  color: var(--text);
  outline: none;
  transition: border 80ms, box-shadow 80ms;
  font-family: inherit;
}
.input:focus, .ds-select:focus, .ds-textarea:focus {
  border-color: var(--text);
  box-shadow: 0 0 0 3px oklch(0.18 0.012 250 / 0.08);
}
.input.error, .ds-select.error { border-color: var(--danger); }
.ds-textarea {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

/* ─────────────────────────────────────────────────────────────────────────────
   10. SEGMENTED CONTROL
   ───────────────────────────────────────────────────────────────────────── */

.seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 2px;
  gap: 2px;
}
.seg button {
  border: 0;
  background: transparent;
  padding: 5px 11px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  border-radius: 5px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.seg button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* ─────────────────────────────────────────────────────────────────────────────
   11. TABS
   ───────────────────────────────────────────────────────────────────────── */

.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}
.tab-btn {
  padding: 9px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
  border: 0;
  background: transparent;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  cursor: pointer;
}
.tab-btn.active { color: var(--text); border-bottom-color: var(--text); }
.tab-btn:hover:not(.active) { color: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────────
   12. DEFINITION LIST
   ───────────────────────────────────────────────────────────────────────── */

.dl {
  display: grid;
  grid-template-columns: 110px 1fr;
  row-gap: 10px;
  column-gap: 14px;
  font-size: 13.5px;
}
.dl dt { color: var(--text-muted); font-weight: 400; font-size: 12.5px; padding-top: 1px; }
.dl dd { margin: 0; color: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────────
   13. ALERT
   ───────────────────────────────────────────────────────────────────────── */

.ds-alert {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--warning-soft);
  border: 1px solid oklch(0.86 0.06 70);
  color: oklch(0.4 0.1 70);
  border-radius: var(--r);
  padding: 10px 12px;
  font-size: 13px;
}
.ds-alert.info {
  background: var(--info-soft);
  border-color: oklch(0.86 0.05 235);
  color: oklch(0.36 0.1 235);
}
.ds-alert.success {
  background: var(--success-soft);
  border-color: oklch(0.86 0.07 155);
  color: oklch(0.36 0.1 155);
}
.ds-alert.danger {
  background: var(--danger-soft);
  border-color: oklch(0.86 0.07 25);
  color: oklch(0.4 0.14 25);
}

/* ─────────────────────────────────────────────────────────────────────────────
   14. PROGRESS BAR
   ───────────────────────────────────────────────────────────────────────── */

.bar {
  height: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.bar > i {
  display: block;
  height: 100%;
  background: var(--text);
  transition: width 220ms;
  border-radius: 999px;
}
.bar.success > i { background: var(--success); }
.bar.warning > i { background: var(--warning); }
.bar.danger  > i { background: var(--danger); }

/* ─────────────────────────────────────────────────────────────────────────────
   15. AVATARS
   ───────────────────────────────────────────────────────────────────────── */

.avatars { display: inline-flex; }
.av {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  margin-left: -6px;
  display: grid;
  place-items: center;
  font-size: 9.5px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
}
.avatars .av:first-child { margin-left: 0; }
.av-more { background: var(--surface-2); color: var(--text-muted); }

/* ─────────────────────────────────────────────────────────────────────────────
   16. MODE CARDS
   ───────────────────────────────────────────────────────────────────────── */

.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.mode-card {
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: var(--r);
  padding: 12px 14px;
  text-align: left;
  cursor: pointer;
}
.mode-card.active { border-color: var(--text); background: var(--surface-2); }
.mode-card-title { font-weight: 500; font-size: 13.5px; margin-bottom: 2px; }
.mode-card-sub { font-size: 11.5px; color: var(--text-faint); }

/* ─────────────────────────────────────────────────────────────────────────────
   17. WEEKDAY PILLS
   ───────────────────────────────────────────────────────────────────────── */

.weekday-pill {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text);
}
.weekday-pill.active {
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}

/* ─────────────────────────────────────────────────────────────────────────────
   18. MODAL
   ───────────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: oklch(0.18 0.012 250 / 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-dialog {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 100%;
  max-width: 520px;
  box-shadow: 0 20px 60px oklch(0.1 0.01 250 / 0.2);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 32px);
  overflow: hidden;
}
.modal-dialog.sm { max-width: 380px; }
.modal-dialog.lg { max-width: 720px; }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { margin: 0; font-size: 15px; font-weight: 600; }
.modal-body {
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* ─────────────────────────────────────────────────────────────────────────────
   19. TOAST
   ───────────────────────────────────────────────────────────────────────── */

.toast-viewport {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  pointer-events: none;
  width: 320px;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 12px 14px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  pointer-events: all;
  font-size: 13px;
  animation: toast-in 180ms ease;
}
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
}
.toast-content { flex: 1; min-width: 0; }
.toast-title { font-weight: 500; color: var(--text); }
.toast-desc { color: var(--text-muted); font-size: 12px; margin-top: 2px; }
.toast-action {
  border: 0;
  background: transparent;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 0;
  cursor: pointer;
  white-space: nowrap;
}
.toast-action:hover { text-decoration: underline; }
.toast-dismiss {
  border: 0;
  background: transparent;
  color: var(--text-faint);
  padding: 0;
  cursor: pointer;
  line-height: 1;
  flex-shrink: 0;
}
.toast-dismiss:hover { color: var(--text); }
.toast.toast-success { border-left: 3px solid var(--success); }
.toast.toast-error   { border-left: 3px solid var(--danger); }
.toast.toast-info    { border-left: 3px solid var(--info); }

/* ─────────────────────────────────────────────────────────────────────────────
   20. SEARCH MODAL
   ───────────────────────────────────────────────────────────────────────── */

.search-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: oklch(0.1 0.01 250 / 0.45);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
}
.search-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  width: 100%;
  max-width: 560px;
  overflow: hidden;
  box-shadow: 0 20px 60px oklch(0.1 0.01 250 / 0.25);
  margin: 0 16px;
}
.search-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.search-input-row input {
  flex: 1;
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
  color: var(--text);
}
.search-results { max-height: 400px; overflow-y: auto; }
.search-section-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-faint);
  padding: 10px 16px 4px;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  color: var(--text);
}
.search-result-item:hover,
.search-result-item.active { background: var(--surface-2); }
.search-result-label { font-size: 13.5px; font-weight: 500; }
.search-result-sub   { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
.search-empty {
  padding: 32px 16px;
  text-align: center;
  font-size: 13px;
  color: var(--text-muted);
}

/* ─────────────────────────────────────────────────────────────────────────────
   21. APP SHELL & NAVIGATION
   ───────────────────────────────────────────────────────────────────────── */

.app-shell {
  display: grid;
  grid-template-columns: 232px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 18px 14px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px 18px;
}
.brand-mark {
  width: 28px;
  height: 28px;
  background: var(--text);
  color: var(--surface);
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.02em;
  flex-shrink: 0;
}
.brand-name { font-weight: 600; letter-spacing: -0.01em; font-size: 15px; line-height: 1.2; }
.brand-sub  { font-size: 11px; color: var(--text-faint); }
.nav-section {
  font-size: 11px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 14px 10px 6px;
  font-weight: 500;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  font-weight: 500;
  font-size: 13.5px;
  cursor: pointer;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  transition: background 80ms, color 80ms;
  text-decoration: none;
}
.nav-item:hover  { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: var(--primary-soft); color: var(--primary); }
.nav-badge {
  margin-left: auto;
  background: var(--text);
  color: var(--surface);
  font-size: 10.5px;
  padding: 2px 6px;
  border-radius: 999px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.nav-item.active .nav-badge { background: var(--primary); }
.sidebar-footer {
  margin-top: auto;
  padding: 12px 10px 0;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
}
.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, oklch(0.85 0.05 250), oklch(0.7 0.06 250));
  display: grid;
  place-items: center;
  font-size: 11px;
  font-weight: 600;
  color: var(--text);
  flex-shrink: 0;
}

/* Topbar */
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  background: oklch(0.99 0.003 250 / 0.9);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  padding: 0 28px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.breadcrumb {
  font-size: 13px;
  color: var(--text-faint);
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb b { color: var(--text); font-weight: 500; }
.topbar-search {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 5px 10px;
  width: 240px;
  color: var(--text-muted);
  font-size: 13px;
}
.topbar-search input {
  background: transparent;
  border: 0;
  outline: 0;
  flex: 1;
  font-size: 13px;
  color: var(--text-muted);
}
.topbar-kbd {
  font-size: 10.5px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-faint);
}

/* Hamburger (hidden on desktop) */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 4px;
  width: 36px;
  height: 36px;
  border: 0;
  background: transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  flex-shrink: 0;
  padding: 0;
}
.hamburger span {
  display: block;
  width: 18px;
  height: 1.5px;
  background: var(--text-muted);
  border-radius: 999px;
  transition: background 80ms;
}
.hamburger:hover span { background: var(--text); }

/* ─────────────────────────────────────────────────────────────────────────────
   22. PAGE LAYOUT
   ───────────────────────────────────────────────────────────────────────── */

.page { padding: 28px 32px 60px; max-width: 1280px; }
.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}
.page-title { font-size: 22px; font-weight: 600; letter-spacing: -0.015em; line-height: 1.1; }
.page-sub   { color: var(--text-muted); font-size: 13.5px; margin-top: 4px; }

/* Two-column layout with sticky rail */
.two-col { display: grid; grid-template-columns: 3fr 1fr; gap: 12px; align-items: start; }
.rail { position: sticky; top: 80px; display: flex; flex-direction: column; gap: 12px; }

/* Common form grids */
.two-col-form { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.four-col-form { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.col-span-full { grid-column: 1 / -1; }

/* Sticky action bar */
.sticky-action-bar {
  position: sticky;
  bottom: 0;
  z-index: 10;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 -4px 12px oklch(0.1 0.01 250 / 0.06);
}

/* ─────────────────────────────────────────────────────────────────────────────
   23. CALENDAR
   ───────────────────────────────────────────────────────────────────────── */

.cal {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--surface);
}
.cal-head {
  padding: 10px 12px;
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
}
.cal-cell {
  min-height: 100px;
  padding: 8px;
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.dim { background: var(--surface-2); color: var(--text-faint); }
.cal-day {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}
.cal-cell.today .cal-day {
  color: var(--surface);
  background: var(--text);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11.5px;
}
.cal-event {
  background: var(--primary-soft);
  color: var(--primary);
  border-left: 2px solid var(--primary);
  font-size: 11px;
  padding: 3px 6px;
  border-radius: 3px;
  margin-bottom: 3px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  cursor: pointer;
  line-height: 1.35;
}
.cal-event.filled  { background: var(--success-soft); color: var(--success); border-color: var(--success); }
.cal-event.urgent  { background: var(--danger-soft); color: var(--danger); border-color: var(--danger); }
.cal-event.warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }

/* Mini date picker */
.mcal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; user-select: none; }
.mcal .h {
  font-size: 10.5px;
  color: var(--text-faint);
  text-align: center;
  padding: 4px 0;
  font-weight: 500;
}
.mcal button {
  height: 30px;
  border: 0;
  background: transparent;
  border-radius: 4px;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  cursor: pointer;
}
.mcal button:hover { background: var(--surface-2); }
.mcal button.sel   { background: var(--text); color: var(--surface); }
.mcal button.dim   { color: var(--text-faint); }

/* ─────────────────────────────────────────────────────────────────────────────
   24. RESPONSIVE
   ───────────────────────────────────────────────────────────────────────── */

@media (max-width: 767px) {
  .hamburger { display: flex; }

  .app-shell { grid-template-columns: 1fr; }

  .sidebar {
    position: fixed;
    top: 0; left: 0;
    z-index: 50;
    height: 100vh;
    transform: translateX(-100%);
    transition: transform 220ms ease;
    box-shadow: 4px 0 24px oklch(0.1 0.01 250 / 0.12);
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    z-index: 40;
    background: oklch(0.1 0.01 250 / 0.35);
  }

  .topbar { padding: 0 12px; gap: 10px; }
  .topbar-search { display: none; }

  .page { padding: 16px 16px 48px; }
  .page-header { flex-wrap: wrap; gap: 12px; }

  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .two-col   { grid-template-columns: 1fr; }
  .rail      { position: static; top: auto; }

  .card-body:has(.data-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }

  .mode-cards { grid-template-columns: 1fr; }

  .dl { grid-template-columns: 80px 1fr; }

  .two-col-form  { grid-template-columns: 1fr; }
  .four-col-form { grid-template-columns: 1fr 1fr; }

  .sticky-action-bar { position: fixed; bottom: 0; left: 0; right: 0; }
  .sticky-action-bar + * { padding-bottom: 80px; }
}
