/* Daystar Merchandising — design tokens */
:root {
  --font-sans: 'Geist', -apple-system, system-ui, sans-serif;
  --font-mono: 'Geist Mono', ui-monospace, monospace;

  /* light */
  --bg: oklch(0.99 0.003 80);
  --bg-subtle: oklch(0.975 0.004 80);
  --surface: #ffffff;
  --surface-2: oklch(0.98 0.004 80);
  --border: oklch(0.92 0.005 80);
  --border-strong: oklch(0.86 0.006 80);
  --text: oklch(0.18 0.01 60);
  --text-muted: oklch(0.50 0.008 60);
  --text-dim: oklch(0.65 0.006 60);

  --accent: #f97316;
  --accent-hover: #ea580c;
  --accent-soft: oklch(0.96 0.04 60);
  --accent-text: #c2410c;

  --success: #10b981;
  --success-soft: oklch(0.95 0.05 160);
  --warn: #f59e0b;
  --warn-soft: oklch(0.96 0.06 90);
  --danger: #ef4444;
  --danger-soft: oklch(0.96 0.04 25);
  --info: #3b82f6;
  --info-soft: oklch(0.96 0.03 240);

  --shadow-xs: 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-sm: 0 1px 3px rgba(15, 15, 15, 0.05), 0 1px 2px rgba(15, 15, 15, 0.04);
  --shadow-md: 0 4px 12px -2px rgba(15, 15, 15, 0.06), 0 2px 4px rgba(15, 15, 15, 0.04);
  --shadow-lg: 0 12px 32px -8px rgba(15, 15, 15, 0.10), 0 4px 8px rgba(15, 15, 15, 0.04);

  --radius-sm: 6px;
  --radius: 10px;
  --radius-lg: 14px;

  /* density (comfortable default) */
  --row-h: 48px;
  --pad-card: 20px;
  --pad-cell: 14px 16px;
  --gap: 16px;
  --text-size: 14px;
}

[data-density="compact"] {
  --row-h: 36px;
  --pad-card: 14px;
  --pad-cell: 8px 12px;
  --gap: 10px;
  --text-size: 13px;
}

[data-theme="dark"] {
  --bg: oklch(0.16 0.005 60);
  --bg-subtle: oklch(0.18 0.005 60);
  --surface: oklch(0.20 0.006 60);
  --surface-2: oklch(0.22 0.006 60);
  --border: oklch(0.27 0.008 60);
  --border-strong: oklch(0.34 0.008 60);
  --text: oklch(0.96 0.005 80);
  --text-muted: oklch(0.68 0.008 60);
  --text-dim: oklch(0.50 0.008 60);

  --accent-soft: oklch(0.30 0.06 60);
  --accent-text: #fb923c;

  --success-soft: oklch(0.28 0.06 160);
  --warn-soft: oklch(0.30 0.07 90);
  --danger-soft: oklch(0.30 0.06 25);
  --info-soft: oklch(0.28 0.05 240);

  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: var(--text-size);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: 'cv11', 'ss01';
  letter-spacing: -0.005em;
}

#root { min-height: 100vh; }

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

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

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 14px;
  height: 36px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.btn-primary {
  background: linear-gradient(180deg, #fb923c 0%, var(--accent) 100%);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,0.2) inset, var(--shadow-sm);
}
.btn-primary:hover { background: linear-gradient(180deg, var(--accent) 0%, var(--accent-hover) 100%); }
.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover { background: var(--surface-2); }
.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--bg-subtle); color: var(--text); }
.btn-sm { height: 30px; padding: 0 10px; font-size: 12px; }
.btn-lg { height: 42px; padding: 0 18px; font-size: 14px; }
.btn-block { width: 100%; }

/* Inputs */
.input, .select {
  width: 100%;
  height: 38px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 8px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.input:focus, .select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder { color: var(--text-dim); }

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 6px;
}

.field { margin-bottom: 14px; }
.help { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* Card */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
}
.card-pad { padding: var(--pad-card); }
.card-header {
  padding: 16px var(--pad-card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.card-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0;
  letter-spacing: -0.01em;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #047857; }
[data-theme="dark"] .badge-success { color: #34d399; }
.badge-warn { background: var(--warn-soft); color: #b45309; }
[data-theme="dark"] .badge-warn { color: #fbbf24; }
.badge-danger { background: var(--danger-soft); color: #b91c1c; }
[data-theme="dark"] .badge-danger { color: #f87171; }
.badge-info { background: var(--info-soft); color: #1d4ed8; }
[data-theme="dark"] .badge-info { color: #60a5fa; }
.badge-neutral { background: var(--bg-subtle); color: var(--text-muted); border: 1px solid var(--border); }

/* Mono numbers */
.mono { font-family: var(--font-mono); font-feature-settings: 'tnum'; }

/* Table */
.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.table thead th {
  text-align: left;
  padding: var(--pad-cell);
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.table tbody td {
  padding: var(--pad-cell);
  border-bottom: 1px solid var(--border);
  color: var(--text);
  vertical-align: middle;
}
.table tbody tr { transition: background 0.1s; }
.table tbody tr:hover { background: var(--bg-subtle); cursor: pointer; }
.table tbody tr:last-child td { border-bottom: none; }

/* Sidebar */
.sidebar {
  width: 240px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  z-index: 10;
}
.sidebar-brand {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
}
.sidebar-nav {
  padding: 12px 10px;
  flex: 1;
  overflow-y: auto;
}
.sidebar-section {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 14px 12px 8px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.12s;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
}
.nav-item:hover { background: var(--bg-subtle); color: var(--text); }
.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent-text);
}
.nav-item.active svg { color: var(--accent); }

/* Topbar */
.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 5;
  backdrop-filter: blur(8px);
}

.app-shell {
  display: flex;
  min-height: 100vh;
  background: var(--bg);
}

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

.page {
  padding: 28px;
  max-width: 1400px;
  width: 100%;
  margin: 0 auto;
}

/* Avatar */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: linear-gradient(135deg, #fb923c, #f97316);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 12px;
  font-weight: 600;
  font-family: var(--font-mono);
  flex-shrink: 0;
}
.avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.avatar-sm { width: 24px; height: 24px; font-size: 10px; }

/* Image placeholder */
.placeholder-img {
  background:
    repeating-linear-gradient(
      45deg,
      var(--bg-subtle) 0px,
      var(--bg-subtle) 8px,
      var(--surface-2) 8px,
      var(--surface-2) 16px
    );
  border: 1px solid var(--border);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  text-align: center;
  padding: 8px;
}

/* Search */
.search {
  position: relative;
  display: flex;
  align-items: center;
}
.search input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  outline: none;
}
.search input:focus { border-color: var(--accent); background: var(--surface); }
.search svg {
  position: absolute;
  left: 12px;
  color: var(--text-dim);
  pointer-events: none;
}
.search kbd {
  position: absolute;
  right: 8px;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  color: var(--text-muted);
}

/* Auth pages */
.auth-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse at top right, oklch(0.96 0.04 60) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, oklch(0.97 0.02 240) 0%, transparent 60%),
    var(--bg);
}
[data-theme="dark"] .auth-shell {
  background:
    radial-gradient(ellipse at top right, oklch(0.25 0.06 60) 0%, transparent 60%),
    radial-gradient(ellipse at bottom left, oklch(0.22 0.04 240) 0%, transparent 60%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  padding: 36px;
}

/* KPI tile */
.kpi-tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--pad-card);
  position: relative;
  overflow: hidden;
}
.kpi-tile::before {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, var(--surface-2) 0%, transparent 50%);
  pointer-events: none;
  opacity: 0.6;
}
.kpi-tile > * { position: relative; }
.kpi-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}
.kpi-value {
  font-size: 28px;
  font-weight: 600;
  letter-spacing: -0.02em;
  margin: 8px 0 4px;
  font-family: var(--font-mono);
  font-feature-settings: 'tnum';
}
.kpi-delta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 12px;
  font-weight: 500;
  font-family: var(--font-mono);
}
.kpi-delta.up { color: #047857; }
.kpi-delta.down { color: #b91c1c; }
[data-theme="dark"] .kpi-delta.up { color: #34d399; }
[data-theme="dark"] .kpi-delta.down { color: #f87171; }

/* Progress bar */
.bar {
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.bar-fill {
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 2px;
  border-bottom: 1px solid var(--border);
}
.tab {
  padding: 10px 14px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--accent-text); border-bottom-color: var(--accent); }

/* Segment */
.segment {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  gap: 2px;
}
.segment button {
  padding: 5px 10px;
  border-radius: 6px;
  background: transparent;
  border: none;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  font-family: var(--font-mono);
}
.segment button.active {
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-xs);
}

/* Scrollbar */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 5px; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in { animation: fadeIn 0.25s ease; }

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Checkbox */
.checkbox {
  width: 16px;
  height: 16px;
  border: 1.5px solid var(--border-strong);
  border-radius: 4px;
  background: var(--surface);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.12s;
}
.checkbox.checked {
  background: var(--accent);
  border-color: var(--accent);
}
.checkbox.checked svg { color: white; }

/* Toast */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

/* ── Responsive ──────────────────────────────────────────────────────
   Hard rule: every clickable element in the SPA must keep its label
   on a single line. Buttons that don't use the .btn class also get
   covered here (e.g. inline-styled topbar profile button).         */
.app-shell button,
.app-shell .btn { white-space: nowrap; }

/* Sidebar drawer affordances — visible on mobile only via media queries */
.sidebar-toggle {
  display: none;
  background: transparent;
  border: none;
  padding: 6px 8px;
  border-radius: 6px;
  cursor: pointer;
  color: var(--text-muted);
  align-items: center;
  justify-content: center;
  height: 36px;
}
.sidebar-toggle:hover { background: var(--bg-subtle); color: var(--text); }
.sidebar-close { display: none; }
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  z-index: 19;
}

@media (max-width: 1024px) {
  .topbar-search { width: 220px; }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    z-index: 20;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-backdrop.show { display: block; }
  .sidebar-toggle { display: inline-flex; }
  .sidebar-close { display: grid; }

  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-search { width: auto; flex: 1; min-width: 0; max-width: none; }
  .topbar-search kbd { display: none; }
  .topbar-new-visit-label { display: none; }
  .topbar-profile-text { display: none; }
  .topbar-profile-chevron { display: none; }
  .topbar-divider { display: none; }

  .page { padding: 16px; }

  /* Inline two-col grids → single col. React serializes inline styles
     as kebab-case, so the attribute substring matches reliably. */
  .app-shell [style*="grid-template-columns: 1fr 1fr"],
  .app-shell [style*="grid-template-columns:1fr 1fr"],
  .app-shell [style*="grid-template-columns: 220px 1fr"],
  .app-shell [style*="grid-template-columns:220px 1fr"] {
    grid-template-columns: 1fr !important;
  }

  /* Tables: let the card scroll horizontally rather than line-wrap. */
  .card:has(> .table),
  .card-pad:has(> .table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .table { min-width: 560px; }

  /* Toolbars / filter rows — let them wrap instead of overflowing. */
  .toolbar, .filters { flex-wrap: wrap; }
}

@media (max-width: 480px) {
  .topbar { gap: 4px; padding: 0 8px; }
  .topbar-crumbs { font-size: 12px; }
  .stat-card, .card-pad { padding: 14px; }
}

/* ── Right-side drawer (patient detail, new visit) ─────────────────── */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  z-index: 29;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}
.drawer-backdrop.open { opacity: 1; pointer-events: auto; }

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: 720px;
  max-width: 95vw;
  background: var(--surface);
  z-index: 30;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.25s ease;
  box-shadow: -4px 0 20px rgba(15, 23, 42, 0.08);
}
.drawer.open { transform: translateX(0); }

.drawer-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.drawer-title {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.drawer-close {
  margin-left: auto;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
}
.drawer-close:hover { background: var(--bg-subtle); color: var(--text); }

.drawer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

/* Inside a drawer, embedded page-level wrappers shouldn't add their
   own padding/max-width — the drawer body owns that. */
.drawer-body .page { padding: 0; max-width: none; }

.drawer-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .drawer { width: 100vw; max-width: 100vw; }
  .drawer-body { padding: 16px; }
}

/* ── MDatePicker ────────────────────────────────────────────────────── */
.mdp {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  width: 100%;
}
.mdp-input {
  flex: 1;
  min-width: 0;
  padding-right: 36px;  /* leave room for the calendar button */
  font-variant-numeric: tabular-nums;
}
.mdp-icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.mdp-icon-btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.mdp-icon-btn:disabled { cursor: not-allowed; opacity: 0.5; }

.mdp-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 1100;  /* above .toast (1000) and any drawer (≤1000) */
  min-width: 260px;
  user-select: none;
}
.mdp-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}
.mdp-month-label {
  flex: 1;
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.01em;
}
.mdp-nav {
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.mdp-nav:hover { background: var(--bg-subtle); color: var(--text); border-color: var(--border); }

.mdp-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 0 2px;
}
.mdp-weekdays > div { text-align: center; }

.mdp-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}
.mdp-cell {
  height: 32px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
  padding: 0;
  transition: background 0.08s, color 0.08s;
}
.mdp-cell:hover:not(:disabled):not(.mdp-cell-empty) {
  background: var(--bg-subtle);
}
.mdp-cell-empty { cursor: default; pointer-events: none; }
.mdp-cell-today {
  border-color: var(--border);
  font-weight: 600;
}
.mdp-cell-selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.mdp-cell-selected:hover:not(:disabled) { background: var(--accent); }
.mdp-cell-disabled,
.mdp-cell:disabled {
  color: var(--text-dim);
  cursor: not-allowed;
  opacity: 0.45;
}

.mdp-footer {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.mdp-foot-btn {
  flex: 1;
  height: 28px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.mdp-foot-btn:hover { background: var(--bg-subtle); color: var(--text); }

@media (max-width: 480px) {
  .mdp-popover { min-width: 240px; padding: 8px; }
  .mdp-cell { height: 30px; font-size: 12px; }
}

/* ── MSelect ────────────────────────────────────────────────────────── */
.msel {
  position: relative;
  display: inline-flex;
  width: 100%;
}
.msel-trigger {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  cursor: pointer;
  padding-right: 32px;
  position: relative;
}
.msel-trigger:disabled { cursor: not-allowed; opacity: 0.5; }
.msel-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msel-placeholder { color: var(--text-dim); }
.msel-chevron {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  color: var(--text-muted);
  pointer-events: none;
}

.msel-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 6px;
  z-index: 1100;
  min-width: 220px;
  display: flex;
  flex-direction: column;
  max-height: 360px;
}
.msel-search {
  padding: 4px 4px 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}
.msel-search .input { height: 32px; font-size: 13px; }
.msel-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.msel-empty {
  padding: 12px;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
}
.msel-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text);
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  width: 100%;
}
.msel-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msel-item-check { color: var(--accent); font-size: 13px; font-weight: 600; }
.msel-item-highlight { background: var(--bg-subtle); }
.msel-item-selected { color: var(--accent-text); font-weight: 500; }
.msel-item-selected.msel-item-highlight { background: var(--accent-soft); }

/* ── MTimePicker ────────────────────────────────────────────────────── */
.mtp {
  position: relative;
  display: inline-flex;
  align-items: stretch;
  width: 100%;
}
.mtp-input {
  flex: 1;
  min-width: 0;
  padding-right: 36px;
  font-variant-numeric: tabular-nums;
}
.mtp-icon-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0;
}
.mtp-icon-btn:hover:not(:disabled) { background: var(--bg-subtle); color: var(--text); }
.mtp-icon-btn:disabled { cursor: not-allowed; opacity: 0.5; }

.mtp-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  padding: 8px;
  z-index: 1100;
  min-width: 220px;
}
.mtp-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  height: 220px;
}
.mtp-col {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: 8px;
  scrollbar-width: thin;
}
.mtp-cell {
  padding: 6px 0;
  background: transparent;
  border: none;
  border-radius: 4px;
  color: var(--text);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-mono);
  cursor: pointer;
  text-align: center;
}
.mtp-cell:hover { background: var(--bg-subtle); }
.mtp-cell-selected {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.mtp-cell-selected:hover { background: var(--accent); }
.mtp-footer {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
