:root,
:root[data-theme="paper"],
:root[data-theme="light"] {
  color-scheme: light;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'SF Mono', Menlo, Consolas, ui-monospace, monospace;

  --bg-canvas: #FFFFFF;
  --bg-surface-elevated: #FAFAFA;
  --bg-subtle: #F4F4F5;
  --border-default: #E4E4E7;
  --border-subtle: #F4F4F5;
  --text-primary: #18181B;
  --text-secondary: #71717A;
  --text-muted: #A1A1AA;
  --accent-primary: #18181B;
  --accent-primary-fg: #FAFAFA;
  --dock-bg: rgba(255, 255, 255, 0.92);
  --dock-border: #E4E4E7;

  /* App aliases */
  --bg: var(--bg-canvas);
  --card: var(--bg-surface-elevated);
  --surface: var(--bg-surface-elevated);
  --surface-2: var(--bg-subtle);
  --surface-deep: var(--bg-subtle);
  --surface-hover: #E4E4E7;
  --header-bg: var(--bg-canvas);
  --nav-bg: var(--dock-bg);
  --modal-backdrop: rgba(24, 24, 27, 0.40);
  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(24, 24, 27, 0.10);
  --shadow-lg: 0 10px 30px rgba(24, 24, 27, 0.14);

  --line: var(--border-default);
  --line-soft: var(--border-subtle);
  --border-ctrl: #D4D4D8;

  --txt: var(--text-primary);
  --txt-2: #3F3F46;
  --mut: var(--text-secondary);
  --mut-2: var(--text-muted);

  --accent: var(--accent-primary);
  --accent-strong: var(--accent-primary);
  --accent-border: var(--border-default);
  --accent-dim: var(--bg-subtle);
  --accent-soft: var(--bg-subtle);
  --accent-tint: rgba(24, 24, 27, 0.06);
  --accent-txt: var(--text-primary);
  --accent-on-solid: var(--accent-primary-fg);

  /* Semantic clinical status colors (strictly clinical signals) */
  --danger: #E11D48;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.28);
  --danger-txt: #E11D48;
  --warn: #D97706;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(245, 158, 11, 0.28);
  --warn-txt: #D97706;
  --success: #059669;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.28);
  --success-txt: #059669;

  --info: var(--text-primary);
  --info-bg: var(--bg-subtle);
  --info-border: var(--border-default);
  --info-txt: var(--text-secondary);
  --info-strong: #E4E4E7;
  --info-strong-2: #D4D4D8;
  --purple: var(--text-secondary);
  --purple-bg: var(--bg-subtle);
  --purple-border: var(--border-default);
  --drip-bg: var(--danger-bg);
  --drip-border: var(--danger-border);
  --drip-txt: var(--danger-txt);
  --cat-bg: var(--bg-subtle);
  --cat-border: var(--border-default);
  --cat-txt: var(--text-secondary);
}

:root[data-theme="obsidian"],
:root[data-theme="dark"],
:root.dark {
  color-scheme: dark;
  --bg-canvas: #0D0D0F;
  --bg-surface-elevated: #141417;
  --bg-subtle: #27272A;
  --border-default: #27272A;
  --border-subtle: #1F1F23;
  --text-primary: #FAFAFA;
  --text-secondary: #A1A1AA;
  --text-muted: #71717A;
  --accent-primary: #FAFAFA;
  --accent-primary-fg: #18181B;
  --dock-bg: rgba(24, 24, 27, 0.92);
  --dock-border: #27272A;

  --bg: var(--bg-canvas);
  --card: var(--bg-surface-elevated);
  --surface: var(--bg-surface-elevated);
  --surface-2: var(--bg-subtle);
  --surface-deep: #111114;
  --surface-hover: #323236;
  --header-bg: var(--bg-canvas);
  --nav-bg: var(--dock-bg);
  --modal-backdrop: rgba(0, 0, 0, 0.56);
  --shadow-sm: none;
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.55);

  --line: var(--border-default);
  --line-soft: var(--border-subtle);
  --border-ctrl: #3F3F46;

  --txt: var(--text-primary);
  --txt-2: #D4D4D8;
  --mut: var(--text-secondary);
  --mut-2: var(--text-muted);

  --accent: var(--accent-primary);
  --accent-strong: var(--accent-primary);
  --accent-border: #3F3F46;
  --accent-dim: var(--bg-subtle);
  --accent-soft: var(--bg-subtle);
  --accent-tint: rgba(250, 250, 250, 0.08);
  --accent-txt: var(--text-primary);
  --accent-on-solid: var(--accent-primary-fg);

  --danger: #FB7185;
  --danger-bg: rgba(244, 63, 94, 0.12);
  --danger-border: rgba(244, 63, 94, 0.30);
  --danger-txt: #FB7185;
  --warn: #FBBF24;
  --warn-bg: rgba(245, 158, 11, 0.12);
  --warn-border: rgba(245, 158, 11, 0.30);
  --warn-txt: #FBBF24;
  --success: #34D399;
  --success-bg: rgba(16, 185, 129, 0.12);
  --success-border: rgba(16, 185, 129, 0.30);
  --success-txt: #34D399;

  --info: var(--text-primary);
  --info-bg: var(--bg-subtle);
  --info-border: #3F3F46;
  --info-txt: #D4D4D8;
  --info-strong: #323236;
  --info-strong-2: #3F3F46;
  --purple: #D4D4D8;
  --purple-bg: var(--bg-subtle);
  --purple-border: #3F3F46;
  --drip-bg: var(--danger-bg);
  --drip-border: var(--danger-border);
  --drip-txt: var(--danger-txt);
  --cat-bg: var(--bg-subtle);
  --cat-border: #3F3F46;
  --cat-txt: #D4D4D8;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

.svg-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.ui-ico {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: -2.5px;
}

.ico-inline {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.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;
}

.mt-8 { margin-top: 8px; }
.mt-10 { margin-top: 10px; }
.mb-0 { margin-bottom: 0; }
.mb-8 { margin-bottom: 8px; }
.mb-10 { margin-bottom: 10px; }
.mb-12 { margin-bottom: 12px; }
.mb-14 { margin-bottom: 14px; }
.flex-1 { flex: 1; }
.flex-14 { flex: 1.4; }
.min-w-0 { min-width: 0; }
.w-full { width: 100%; }
.align-end { justify-content: flex-end; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

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

html, body {
  overscroll-behavior-y: contain;
}

html.modal-open, html.modal-open body {
  overflow: hidden;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--txt);
  font: 15px/1.45 var(--font-sans);
  -webkit-font-smoothing: antialiased;
  padding-bottom: env(safe-area-inset-bottom);
}

.sw-update-banner {
  position: sticky;
  top: 0;
  z-index: 110;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 8px max(18px, env(safe-area-inset-left));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
}

.backup-warn-banner,
.vault-reconnect-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 7px 11px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--txt);
}
.vault-reconnect-banner[hidden],
.vault-sync-live-banner[hidden],
.vault-progress-wrap[hidden],
.backup-warn-banner[hidden] {
  display: none !important;
}
.vault-sync-live-banner,
.vault-progress-wrap {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px 12px;
  margin-bottom: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}
.vault-sync-live-head,
.vault-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.vault-sync-live-text {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt);
}
.vault-sync-live-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--txt);
}
.vault-progress-track {
  width: 100%;
  height: 4px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
}
.vault-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--txt);
  border-radius: 999px;
  transition: width 0.14s ease;
}
.vault-progress-bar.is-indeterminate {
  animation: vaultScanSlide 1.1s ease-in-out infinite;
}
@keyframes vaultScanSlide {
  0% { transform: translateX(-60%); }
  100% { transform: translateX(320%); }
}
.vault-progress-detail {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mut);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#vaultLastSummaryText {
  text-align: right;
  word-break: break-word;
  max-width: 68%;
}
.list-load-more-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
}
.backup-warn-msg {
  flex: 1 1 180px;
  min-width: 0;
  color: var(--warn-txt);
  font-weight: 500;
}

.storage-warn-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 10px;
  font-size: 12.5px;
  color: var(--txt);
}
.storage-warn-msg {
  flex: 1 1 220px;
  min-width: 0;
  line-height: 1.35;
}
.storage-status-box {
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 2px 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
}
.storage-stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  padding: 9px 0;
  border-bottom: 1px solid var(--line-soft);
}
.storage-stat-row:last-child {
  border-bottom: none;
}
#storageQuotaText,
#pwaInstallStatusText,
#swUpdateStatusText {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}

/* ==================== NEUTRAL HEADER & FLOATING DOCK ==================== */
header.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: 'title actions';
  align-items: center;
  gap: 8px 12px;
  max-width: 820px;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) 10px max(16px, env(safe-area-inset-left));
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-default);
  position: sticky;
  top: 0;
  z-index: 25;
}
.header-brand-row {
  grid-area: title;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.app-logo-mark {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.app-logo-btn {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
}
.app-logo-btn:hover {
  background: var(--surface-hover);
}
.logo-duty-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 8px;
  height: 8px;
  border-radius: 9999px;
  background: var(--warn);
  border: 1.5px solid var(--bg-canvas);
  pointer-events: none;
}
.header-title-wrap {
  min-width: 0;
}
.app-title {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: var(--text-primary);
}
.app-subtitle {
  margin-top: 2px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.3;
}
.header-actions {
  grid-area: actions;
  display: flex;
  align-items: center;
  gap: 8px;
}
.header-rounds-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.icon-circle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 9999px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.14s ease, opacity 0.14s ease;
}
.icon-circle-btn:hover {
  background: var(--surface-hover);
}
.icon-circle-btn.is-active {
  background: var(--bg-subtle);
  border-color: var(--border-ctrl);
}
.icon-circle-btn.solid {
  border-color: transparent;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
}
.icon-circle-btn.solid:hover {
  opacity: 0.88;
}
.icon-circle-btn .ui-ico {
  width: 17px;
  height: 17px;
  margin: 0;
}
.icon-dot-badge {
  position: absolute;
  top: -3px;
  right: -3px;
  min-width: 16px;
  height: 16px;
  padding: 0 4px;
  border-radius: 999px;
  background: var(--danger);
  color: #FFFFFF;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 16px;
  text-align: center;
}
.header-more-wrap,
.row-more-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.popover-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 75;
  min-width: 190px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.ledger-compact-bar .row-more-menu {
  left: 0;
  right: auto;
}
.ledger-footer .row-more-menu {
  top: auto;
  bottom: calc(100% + 6px);
  right: 0;
  left: auto;
}
.popover-menu.align-right,
.ledger-compact-bar .row-more-menu.align-right {
  right: 0;
  left: auto;
}
.popover-menu.open-up,
.ledger-compact-bar .row-more-menu.open-up {
  top: auto;
  bottom: calc(100% + 6px);
}
.row-more-menu.floating-row-menu {
  position: fixed;
  top: auto;
  right: auto;
  bottom: auto;
  left: auto;
  z-index: 1200;
  min-width: 190px;
  margin: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.popover-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  justify-content: flex-start;
  cursor: pointer;
}
.popover-menu-item:hover {
  background: var(--surface-2);
  border-color: transparent;
}
.popover-menu-item .ui-ico {
  width: 15px;
  height: 15px;
  color: var(--mut);
}

/* ==================== 4-TAB FLOATING PILL DOCK ==================== */
.nav-modes {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 45;
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 2px;
  padding: 5px;
  border-radius: 9999px;
  background: var(--dock-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--dock-border);
  box-shadow: var(--shadow-lg);
  max-width: calc(100vw - 24px);
}
.mode-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 9999px;
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 14px;
  min-height: 38px;
  cursor: pointer;
  white-space: nowrap;
  transition: color 0.14s ease, background 0.14s ease;
}
.nav-ico {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.nav-ico .ui-ico {
  width: 17px;
  height: 17px;
}
@media (max-width: 440px) {
  .nav-modes {
    padding: 4px;
    gap: 1px;
  }
  .nav-modes .mode-btn {
    padding: 8px 10px;
    gap: 5px;
    font-size: 12px;
  }
  .nav-modes .nav-ico .ui-ico {
    width: 16px;
    height: 16px;
  }
}
.nav-modes .ico-filled {
  display: none;
}
.nav-modes .mode-btn.active .ico-outline {
  display: none;
}
.nav-modes .mode-btn.active .ico-filled {
  display: inline-block;
}
.nav-alert-dot {
  width: 7px;
  height: 7px;
  border-radius: 9999px;
  background: var(--warn);
  flex-shrink: 0;
}
.nav-lbl { line-height: 1.1; }
.mode-btn:hover { color: var(--text-primary); }
.nav-modes .mode-btn:focus-visible {
  outline: none;
  background: var(--bg-subtle);
}
.mode-btn.active {
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-weight: 600;
}
html.kb-open .nav-modes {
  display: none;
}

.dock-bottom-fade {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(64px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg-canvas) 16%, transparent 100%);
  pointer-events: none;
  z-index: 35;
}
html.kb-open .dock-bottom-fade {
  display: none;
}

/* ==================== LEFT SIDEPANEL & DUTY QUEUE ==================== */
.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  transition: opacity 240ms ease;
}
.drawer-backdrop.is-open {
  opacity: 1;
}
.workspace-drawer {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 90;
  width: 88vw;
  max-width: 380px;
  background: var(--bg-surface-elevated);
  border-right: 1px solid var(--border-default);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 240ms cubic-bezier(0.22, 1, 0.36, 1);
  padding-top: env(safe-area-inset-top);
}
.workspace-drawer.is-open {
  transform: translateX(0);
}
.drawer-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-default);
  flex-shrink: 0;
}
.drawer-brand {
  display: flex;
  align-items: center;
  gap: 9px;
}
.drawer-logo-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.drawer-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.15;
}
.drawer-sub {
  font-size: 11px;
  color: var(--text-secondary);
}
.drawer-body {
  flex: 1 1 0;
  overflow-y: auto;
  padding: 10px 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overscroll-behavior: contain;
}
.drawer-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.drawer-sec-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
}
.drawer-sec-title-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.drawer-sec-right {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
.drawer-sec-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--text-muted);
}
.drawer-sec-meta {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
}
.drawer-link-btn {
  border: none;
  background: transparent;
  padding: 2px 4px;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.drawer-link-btn:hover { color: var(--text-primary); }
.drawer-link-btn.is-active {
  color: var(--warn-txt);
  font-weight: 600;
}

.dq-count-badge {
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9999px;
  background: var(--warn-bg);
  color: var(--warn-txt);
}
.dq-add-form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.dq-add-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.dq-add-row input {
  flex: 1 1 0;
  min-width: 0;
  height: 34px;
  padding: 0 10px;
  font-size: 12.5px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: var(--text-primary);
}
.dq-add-submit {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: none;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
}
.dq-tag-pills {
  display: flex;
  gap: 5px;
}
.dq-tag-pill {
  flex: 1 1 0;
  height: 26px;
  border-radius: 9999px;
  border: 1px solid var(--border-default);
  background: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.dq-tag-pill.active {
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  border-color: var(--accent-primary);
}
.dq-filter-pills {
  display: flex;
  align-items: center;
  gap: 4px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}
.dq-filter-pills::-webkit-scrollbar { display: none; }
.dq-filter-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 24px;
  padding: 0 8px;
  border-radius: 9999px;
  border: 1px solid var(--border-default);
  background: var(--bg-canvas);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.dq-filter-pill.active {
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  border-color: var(--accent-primary);
}
.dq-filter-count {
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  font-weight: 700;
  color: var(--text-muted);
}
.dq-filter-pill:not(.active) .dq-filter-count.has-items {
  color: var(--warn);
}
.dq-filter-pill.active .dq-filter-count {
  color: var(--accent-primary-fg);
  opacity: 0.9;
}
.dq-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.dq-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 6px 2px;
}
.dq-item {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 8px;
  border-radius: 8px;
  background: var(--bg-canvas);
  border: 1px solid var(--border-default);
}
.dq-item.is-done {
  opacity: 0.65;
}
.dq-item input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
  cursor: pointer;
}
.dq-item-main {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.dq-item-top {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  flex-wrap: wrap;
}
.dq-tag {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 1px 6px;
  border-radius: 5px;
  flex-shrink: 0;
}
.dq-tag.is-deck { background: var(--warn-bg); color: var(--warn-txt); }
.dq-tag.is-ref { background: var(--danger-bg); color: var(--danger-txt); }
.dq-tag.is-task { background: var(--bg-subtle); color: var(--text-secondary); }
.dq-item-text {
  font-size: 12.5px;
  line-height: 1.35;
  color: var(--text-primary);
  word-break: break-word;
}
.dq-item.is-done .dq-item-text {
  text-decoration: line-through;
  color: var(--text-muted);
}
.dq-item-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.dq-admit-btn {
  height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.dq-admit-btn:hover { background: var(--surface-hover); }
.dq-del-btn {
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.dq-del-btn:hover { color: var(--danger-txt); background: var(--danger-bg); }
.dq-del-btn .ui-ico { width: 13px; height: 13px; }

.drawer-bed-list,
.drawer-action-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.drawer-bed-list {
  gap: 5px;
}
.drawer-bed-card {
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-canvas);
  overflow: hidden;
}
.drawer-action-row,
.drawer-bed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 36px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.drawer-bed-row {
  border-radius: 0;
  min-height: 34px;
}
.drawer-action-row {
  justify-content: flex-start;
  gap: 10px;
}
.drawer-action-row .ui-ico {
  width: 16px;
  height: 16px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.drawer-action-row:hover,
.drawer-bed-row:hover {
  background: var(--bg-subtle);
}
.drawer-bed-left {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.drawer-bed-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.drawer-bed-pending-pill {
  font-variant-numeric: tabular-nums;
  font-size: 10.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9999px;
  background: var(--warn-bg);
  color: var(--warn-txt);
}
.drawer-bed-pending {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px 8px 7px;
  border-top: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
}
.drawer-bed-pending-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  cursor: pointer;
}
.drawer-bed-pending-chk {
  margin: 2px 0 0;
  width: 13px;
  height: 13px;
  accent-color: var(--accent-primary);
  flex-shrink: 0;
  cursor: pointer;
}
.drawer-bed-pending-txt {
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--text-secondary);
  word-break: break-word;
}
.drawer-bed-more-btn {
  align-self: flex-start;
  border: none;
  background: transparent;
  padding: 1px 0 0 19px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.drawer-bed-more-btn:hover { color: var(--text-primary); }
.drawer-bed-badge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  flex-shrink: 0;
}
.drawer-bed-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12.5px;
}
.drawer-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  flex-shrink: 0;
}
.drawer-status-dot.is-ok { background: var(--success); }
.drawer-status-dot.is-warn { background: var(--warn); }
.drawer-status-dot.is-muted { background: var(--text-muted); }

.drawer-footer {
  border-top: 1px solid var(--border-default);
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-shrink: 0;
  background: var(--bg-surface-elevated);
}
.drawer-footer-row {
  display: flex;
  align-items: center;
  gap: 6px;
}
.drawer-theme-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 11.5px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
}
.drawer-theme-btn .ui-ico { width: 14px; height: 14px; }
.drawer-settings-row {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 38px;
  padding: 6px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
}
.drawer-settings-row:hover { background: var(--bg-subtle); }
.drawer-settings-left {
  display: inline-flex;
  align-items: center;
  gap: 9px;
}
.drawer-settings-left .ui-ico { width: 16px; height: 16px; color: var(--text-secondary); }
.drawer-settings-chev { width: 15px; height: 15px; color: var(--text-muted); }

.settings-top-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border-default);
}
.settings-back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: auto;
  height: 34px;
  padding: 0 10px 0 4px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--text-primary);
  font-size: 13.5px;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
}
.settings-back-btn:hover {
  background: var(--bg-subtle);
}
.settings-back-btn .ui-ico {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.pill,
.status-meta {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--mut);
  white-space: nowrap;
}
.pill .ui-ico,
.status-meta .ui-ico {
  width: 12px;
  height: 12px;
  flex-shrink: 0;
}
.pill.safe,
.status-meta.safe { color: var(--success-txt); background: transparent; }
.pill.block,
.status-meta.block { color: var(--danger-txt); background: transparent; }
.pill.warn,
.status-meta.warn { color: var(--warn-txt); background: transparent; }
.pill.offline-pill,
.status-meta.offline-pill { color: var(--warn-txt); background: transparent; }
.clickable-pill { cursor: pointer; }

main {
  padding: 6px max(16px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
  max-width: 820px;
  margin: 0 auto;
  scroll-padding-bottom: 108px;
}

.view-panel { width: 100%; }

/* ==================== ROUNDS CAPSULE TABS & SEARCH ==================== */
.rounds-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 0;
  padding: 10px 0 12px;
  border-bottom: 1px solid var(--border-default);
}
.rounds-tabs-bar {
  min-width: 0;
  max-width: 100%;
}
.filter-chips-wrap {
  position: relative;
  min-width: 0;
  max-width: 100%;
}
.filter-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0;
}
.filter-chips::-webkit-scrollbar { display: none; }
.chip {
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 9999px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 12px;
  min-height: 32px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: color 0.14s ease, background 0.14s ease, border-color 0.14s ease;
}
.chip:hover { color: var(--text-primary); }
.chip.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--accent-primary-fg);
  font-weight: 600;
}
.chip-count {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  background: transparent;
  padding: 0;
}
.chip.active .chip-count {
  color: var(--accent-primary-fg);
  opacity: 0.85;
}
.chip-count.is-warn {
  color: var(--warn-txt);
}
.chip.active .chip-count.is-warn {
  color: var(--accent-primary-fg);
}
.chip-group {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  border-radius: 9999px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  padding-right: 4px;
}
.chip-group.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
}
.chip-group .chip {
  border: none;
  background: transparent;
  padding-right: 4px;
}
.chip-del-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 4px;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  border-radius: 9999px;
}
.chip-group.active .chip-del-btn {
  color: var(--accent-primary-fg);
  opacity: 0.8;
}
.chip-del-btn:hover,
.chip-del-btn:focus-visible {
  color: var(--danger);
  border-color: transparent;
}
.chip-del-btn .ui-ico {
  width: 12px;
  height: 12px;
}
.add-cat-chip {
  background: transparent;
  border-style: dashed;
  color: var(--text-secondary);
  font-weight: 500;
}
.add-cat-chip:hover {
  color: var(--text-primary);
}
.profile-custom-cats {
  display: contents;
}
.cat-flag-pill {
  display: inline-flex;
  align-items: stretch;
  border-radius: 8px;
  overflow: hidden;
  border: none;
  background: var(--surface-2);
}
.cat-flag-pill label {
  border: none;
  border-radius: 0;
  background: transparent;
  padding: 5px 10px 5px 12px;
}
.cat-flag-del {
  border: none;
  border-left: 1px solid var(--line-soft);
  border-radius: 0;
  background: transparent;
  color: var(--mut);
  padding: 4px 9px;
  font-size: 13px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.cat-flag-del:hover,
.cat-flag-del:focus-visible {
  color: var(--danger);
  background: var(--danger-bg);
}
.inline-cat-form {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  width: 100%;
  max-width: 100%;
}
.inline-cat-form input {
  flex: 1 1 0;
  min-width: 0;
  padding: 7px 10px;
}
.inline-cat-form[hidden] {
  display: none !important;
}

.rounds-search-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rounds-search-box {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  padding: 0 10px;
}
.rounds-search-box .search-ico {
  width: 15px;
  height: 15px;
  color: var(--text-muted);
  flex-shrink: 0;
}
.rounds-search-box input {
  flex: 1 1 0;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 8px 0;
  font-size: 13.5px;
  color: var(--text-primary);
}
.rounds-search-box input::placeholder {
  color: var(--text-muted);
}
.rounds-search-box input:focus {
  outline: none;
}
.rounds-sort-wrap {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  height: 36px;
  padding: 0 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 12.5px;
}
.rounds-sort-wrap .sort-ico {
  width: 14px;
  height: 14px;
  color: var(--text-secondary);
  flex-shrink: 0;
}
.rounds-sort-wrap select {
  width: auto;
  border: none;
  background: transparent;
  padding: 6px 2px;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
}

/* ==================== CLINICAL LEDGER LIST ==================== */
.ledger-list {
  display: flex;
  flex-direction: column;
  width: 100%;
  margin: 0 calc(-1 * max(16px, env(safe-area-inset-right))) 0 calc(-1 * max(16px, env(safe-area-inset-left)));
  width: calc(100% + max(16px, env(safe-area-inset-left)) + max(16px, env(safe-area-inset-right)));
}
.ledger-empty {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-secondary);
}
.ledger-empty-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 6px;
}
.ledger-empty-sub {
  font-size: 13px;
  margin: 0 0 16px;
}
.ledger-empty-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}
.ledger-list-footer {
  padding: 20px 12px 10px;
  text-align: center;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.ledger-row {
  width: 100%;
  border-radius: 0;
  background: var(--bg-canvas);
  border-bottom: 1px solid var(--border-default);
  border-left: 3px solid transparent;
  padding: 12px max(16px, env(safe-area-inset-right)) 10px calc(max(16px, env(safe-area-inset-left)) - 3px);
  transition: background 0.12s ease;
  content-visibility: auto;
  contain: layout style;
  contain-intrinsic-size: auto 115px;
}
.ledger-row.is-overdue {
  border-left-color: var(--warn);
}
.ledger-row.is-updated {
  border-left-color: var(--success);
}
.ledger-row.expanded {
  background: var(--bg-surface-elevated);
}

.ledger-head {
  cursor: pointer;
  user-select: none;
}
.ledger-head:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
  border-radius: 4px;
}
.ledger-head-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.ledger-id-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.ledger-bed {
  display: inline-block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  padding: 3px 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  white-space: nowrap;
  flex-shrink: 0;
}
.ledger-row.expanded .ledger-bed {
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
}
.ledger-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-row.expanded .ledger-name {
  white-space: normal;
  overflow: visible;
}
.ledger-head-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.ledger-status {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 9999px;
  white-space: nowrap;
}
.ledger-status.ok {
  color: var(--success-txt);
  background: var(--success-bg);
}
.ledger-status.warn {
  color: var(--warn-txt);
  background: var(--warn-bg);
}
.ledger-status.muted {
  color: var(--text-secondary);
  background: var(--bg-subtle);
}
.ledger-chevron {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
}
.ledger-chevron .ui-ico {
  width: 15px;
  height: 15px;
}
.ledger-chevron.is-open .ui-ico {
  transform: rotate(180deg);
}

.ledger-meta-compact {
  margin-top: 5px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ledger-meta-expanded,
.ledger-ap-expanded {
  display: none;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.ledger-meta-expanded { margin-top: 5px; }
.ledger-ap-expanded { margin-top: 3px; }
.ledger-row.expanded .ledger-meta-compact { display: none; }
.ledger-row.expanded .ledger-meta-expanded,
.ledger-row.expanded .ledger-ap-expanded { display: block; }

.ap-more-btn {
  border: none;
  background: transparent;
  padding: 0 2px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--txt-2);
  cursor: pointer;
}
.ap-more-btn:hover { color: var(--txt); text-decoration: underline; border-color: transparent; }

.ledger-compact-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
}
.ledger-row.expanded .ledger-compact-bar {
  display: none;
}
.ledger-compact-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ledger-compact-actions .ghost-action {
  padding: 5px 2px;
}
.ledger-compact-actions .ghost-action:hover:not(:disabled) {
  background: transparent;
}
.ledger-chevron-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--mut);
  cursor: pointer;
  padding: 0;
}
.ledger-chevron-btn:hover { color: var(--txt); border-color: transparent; }
.ledger-chevron-btn .ui-ico { width: 16px; height: 16px; }

.ledger-body {
  display: none;
  margin-top: 10px;
}
.ledger-row.expanded .ledger-body {
  display: flex;
  flex-direction: column;
}
.ledger-impression {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--txt);
  line-height: 1.4;
  margin-bottom: 8px;
  overflow-wrap: anywhere;
}
.ledger-drips {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 8px 0;
  border-top: 1px solid var(--border-subtle);
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  overflow-wrap: anywhere;
}
.ledger-drips .crimson-dot {
  align-self: flex-start;
  margin-top: 6px;
  flex-shrink: 0;
}
.ledger-drips .drip-lbl {
  margin-top: 1px;
}
.ledger-drips .drip-val {
  min-width: 0;
  line-height: 1.45;
}
.crimson-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  background: var(--danger);
  flex-shrink: 0;
  align-self: center;
}
.drip-lbl {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--danger);
  flex-shrink: 0;
}
.drip-val {
  color: var(--text-primary);
  font-weight: 500;
}

.ledger-params {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border-subtle);
}
.ledger-kv {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border-subtle);
}
.ledger-kv.is-labs,
.ledger-kv.is-abx {
  grid-template-columns: minmax(0, 1fr);
  gap: 6px;
}
.ledger-k {
  font-family: var(--font-sans);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 2px;
}
.ledger-labs-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.ledger-all-labs-btn {
  border: none;
  background: transparent;
  padding: 2px 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
}
.ledger-all-labs-btn:hover { opacity: 0.72; border-color: transparent; }
.ledger-v {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-primary);
  overflow-wrap: anywhere;
}
.ledger-v.muted { color: var(--text-muted); }
.ledger-tok .tok-k {
  color: var(--text-secondary);
  font-weight: 500;
}
.ledger-tok .tok-v {
  color: var(--text-primary);
  font-weight: 600;
}
.ledger-tok .tok-v.lab-abn {
  color: var(--danger);
  font-weight: 700;
}
.lab-prev {
  color: var(--text-muted);
  font-weight: 400;
}
.ledger-dot {
  color: var(--text-muted);
}
.ledger-age {
  color: var(--text-muted);
  font-size: 11.5px;
  margin-left: 4px;
}
.ledger-io-sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.45;
}

.ledger-accordion {
  border-bottom: 1px solid var(--border-subtle);
}
.ledger-accordion summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  padding: 8px 0;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.ledger-accordion summary::-webkit-details-marker { display: none; }
.acc-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}
.acc-right {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}
.acc-count {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
}
.acc-right .ui-ico {
  width: 14px;
  height: 14px;
  transition: transform 0.14s ease;
}
.ledger-accordion[open] .acc-right .ui-ico {
  transform: rotate(90deg);
}
.ledger-meds-list {
  margin: 0 0 12px;
  padding-left: 16px;
  font-size: 13px;
  color: var(--txt-2);
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 240px;
  overflow-y: auto;
}
.ledger-plans-grid {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 8px 10px;
  padding: 2px 0 12px;
}
.ledger-plan-tag {
  font-family: var(--font-sans);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding-top: 2px;
  overflow-wrap: anywhere;
}
.ledger-plan-txt {
  font-size: 13px;
  line-height: 1.45;
  color: var(--txt-2);
  overflow-wrap: anywhere;
}

.ledger-pending {
  padding: 11px 0 6px;
}
.ledger-pending-hdr {
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.pending-items {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.pending-line {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  padding: 5px 0;
  font-size: 13.5px;
  line-height: 1.35;
  color: var(--txt);
  cursor: pointer;
  user-select: none;
}
.pending-line input[type="checkbox"],
.tpl-id-chip input[type="checkbox"],
.tpl-section-check input[type="checkbox"],
.tpl-subitem-check input[type="checkbox"],
.cf-option input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 17px;
  height: 17px;
  padding: 0;
  margin: 0;
  border: 1.5px solid var(--mut);
  border-radius: 4px;
  background: transparent;
  display: inline-grid;
  place-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background-color 0.14s ease, border-color 0.14s ease;
}
.pending-line input[type="checkbox"] {
  margin-top: 2px;
}
.pending-line input[type="checkbox"]:checked,
.tpl-id-chip input[type="checkbox"]:checked,
.tpl-section-check input[type="checkbox"]:checked,
.tpl-subitem-check input[type="checkbox"]:checked,
.cf-option input[type="checkbox"]:checked {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}
.pending-line input[type="checkbox"]:checked::after,
.tpl-id-chip input[type="checkbox"]:checked::after,
.tpl-section-check input[type="checkbox"]:checked::after,
.tpl-subitem-check input[type="checkbox"]:checked::after,
.cf-option input[type="checkbox"]:checked::after {
  content: "";
  width: 9px;
  height: 5px;
  border-left: 1.8px solid var(--accent-on-solid);
  border-bottom: 1.8px solid var(--accent-on-solid);
  transform: rotate(-45deg) translate(0.5px, -0.5px);
}
.pending-line.done {
  text-decoration: line-through;
  color: var(--mut);
}
.pending-add-row {
  margin-top: 4px;
}
.pending-add-input {
  width: 100%;
  border: none;
  background: transparent;
  padding: 6px 0;
  font-size: 13px;
  color: var(--txt);
  border-radius: 0;
}
.pending-add-input::placeholder {
  color: var(--mut);
}
.pending-add-input:focus {
  outline: none;
}

.ledger-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 0;
  margin-bottom: 0;
  padding-top: 2px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line-soft);
}
.ledger-footer + .ledger-drips,
.ledger-footer + .ledger-params,
.ledger-dx-accordion + .ledger-drips,
.ledger-dx-accordion + .ledger-params,
.ledger-footer + .ledger-params > .ledger-param:first-child {
  border-top: none;
}
.ledger-dx-accordion .ledger-impression {
  margin: 0 0 12px;
  font-size: 13.5px;
}
.ledger-btn-primary {
  flex: 1.25 1 0;
  height: 38px;
  border: none;
  border-radius: 8px;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.ledger-btn-primary:hover { opacity: 0.88; border-color: transparent; }
.ledger-btn-subtle {
  flex: 1 1 0;
  height: 38px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
}
.ledger-btn-subtle:hover { background: var(--surface-hover); }
.ledger-btn-subtle .ui-ico { width: 15px; height: 15px; }
.ledger-btn-icon {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  padding: 0;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.ledger-btn-icon:hover { background: var(--surface-hover); }
.ledger-btn-icon .ui-ico { width: 16px; height: 16px; }

/* ==================== CHART EDITOR LAYOUT ==================== */
.editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 12px;
  gap: 8px;
}
.sticky-editor-bar {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 9;
  background: var(--bg);
  padding: 8px 0 10px;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  contain: layout style;
}
html.kb-open .sticky-editor-bar {
  position: static;
}
.editor-topbar-left,
.editor-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  min-width: 0;
}
.editor-patient-nav {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.editor-patient-nav select {
  max-width: 240px;
  padding: 6px 8px;
  font-size: 13px;
}
.editor-hint {
  display: block;
  margin-top: 4px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mut);
}
.editor-panel-head {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}
.editor-title-block {
  min-width: 0;
  flex: none;
  width: 100%;
}
.editor-note-title {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.25;
  color: var(--txt);
}
.editor-note-title .ledger-bed {
  font-size: 11px;
  padding: 2px 7px;
}
.editor-title-name {
  min-width: 0;
  overflow-wrap: anywhere;
}
.editor-actions-bar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
}
.editor-primary-bar {
  display: grid;
  grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr);
  align-items: stretch;
  gap: 8px;
  width: 100%;
}
.editor-cta-btn {
  min-width: 0;
  white-space: nowrap;
}
.editor-sec-pair {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}
.editor-sec-pair .editor-sec-btn {
  min-width: 0;
  padding: 0 8px;
  gap: 4px;
  font-size: 12.5px;
  white-space: nowrap;
  justify-content: center;
}
.editor-utility-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 12px;
  width: 100%;
}

.more-menu {
  position: relative;
}
.more-menu summary {
  list-style: none;
}
.more-menu summary::-webkit-details-marker {
  display: none;
}
.more-menu-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 205px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 5px;
  box-shadow: var(--shadow-md);
  z-index: 25;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.menu-item-btn {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: 13px;
  padding: 8px 10px;
}
.menu-item-btn:hover {
  background: var(--surface-2);
}
.menu-item-btn.danger-item {
  color: var(--danger);
}
.menu-item-btn.danger-item:hover {
  background: var(--danger-bg);
}

.empty-editor-panel {
  text-align: center;
  padding: 36px 16px;
}
.empty-editor-panel .row {
  justify-content: center;
}

.panel {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-width: 0;
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
h2 { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -0.015em; }
.row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  align-items: center;
}
.row.tight { margin-top: 10px; }

button, .btn {
  background: var(--surface-2);
  color: var(--txt);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: background 0.14s ease, opacity 0.14s ease, color 0.14s ease;
}
button:hover, .btn:hover {
  background: var(--surface-hover);
  border-color: transparent;
}
button:disabled {
  background: var(--surface-2);
  color: var(--mut);
  opacity: 0.48;
  border-color: transparent;
  cursor: not-allowed;
}

/* Tier 1: Primary Solid Monochrome CTA (strictly 1 per view/context) */
button.primary,
.btn.primary,
.primary {
  background: var(--accent-strong);
  border: none;
  color: var(--accent-on-solid);
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
}
button.primary:hover:not(:disabled),
.btn.primary:hover:not(:disabled),
.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  opacity: 0.88;
}
button.primary:disabled,
.btn.primary:disabled,
.primary:disabled {
  background: var(--surface-2);
  color: var(--mut);
  opacity: 0.5;
}

/* Tier 1 Exception: Topbar Save button (quiet when saved, solid when dirty) */
.editor-save-btn {
  height: 32px;
  min-height: 32px;
  padding: 0 12px;
  font-size: 12.5px;
  font-weight: 500;
  border-radius: 7px;
  border: none;
  background: var(--surface-2);
  color: var(--txt-2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
}
.editor-save-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--txt);
}
.editor-save-btn.is-dirty {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  font-weight: 600;
}
.editor-save-btn.is-dirty:hover:not(:disabled) {
  background: var(--accent-strong);
  opacity: 0.88;
}

/* Tier 2: Secondary Surface Action (paired beside a Tier 1 CTA) */
.btn-secondary,
label.btn-secondary.file {
  background: var(--surface-2);
  color: var(--txt);
  border: none;
  border-radius: 8px;
  height: 36px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  text-decoration: none;
  transition: background 0.14s ease, opacity 0.14s ease, color 0.14s ease;
}
.btn-secondary:hover:not(:disabled),
label.btn-secondary.file:hover {
  background: var(--surface-hover);
  color: var(--txt);
}
.btn-secondary:disabled {
  background: var(--surface-2);
  color: var(--mut);
  opacity: 0.48;
  cursor: not-allowed;
}

/* Tier 3: Borderless Ghost Utility Link / Icon Action */
.ghost-action,
summary.ghost-action,
label.ghost-action.file {
  background: transparent;
  border: none;
  border-radius: 7px;
  color: var(--txt-2);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 6px;
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}
.ghost-action:hover:not(:disabled),
summary.ghost-action:hover,
label.ghost-action.file:hover {
  background: var(--accent-tint);
  color: var(--txt);
}
.ghost-action:disabled {
  background: transparent;
  color: var(--mut);
  opacity: 0.45;
  cursor: not-allowed;
}
.ghost-action .ui-ico,
summary.ghost-action .ui-ico,
label.ghost-action.file .ui-ico {
  width: 14px;
  height: 14px;
  color: var(--mut);
  transition: color 0.14s ease;
}
.ghost-action:hover:not(:disabled) .ui-ico,
summary.ghost-action:hover .ui-ico,
label.ghost-action.file:hover .ui-ico {
  color: var(--txt);
}
.ghost-action.danger-ghost {
  color: var(--danger-txt);
}
.ghost-action.danger-ghost .ui-ico {
  color: var(--danger-txt);
}
.ghost-action.danger-ghost:hover:not(:disabled) {
  background: var(--danger-bg);
  color: var(--danger-txt);
}

button.danger {
  background: var(--danger-bg);
  border: none;
  border-radius: 8px;
  height: 36px;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--danger-txt);
}
button.danger:hover:not(:disabled) {
  background: var(--danger-border);
}
.btn.subtle {
  background: transparent;
  border-color: transparent;
  color: var(--txt-2);
  font-size: 12.5px;
}
.btn.subtle:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--txt);
}
button.ghost, .ghost {
  background: transparent;
  border: none;
  color: var(--txt-2);
  font-weight: 500;
}
button.ghost:hover:not(:disabled), .ghost:hover {
  background: var(--accent-tint);
  color: var(--txt);
}
.ghost.small {
  background: transparent;
  border: none;
  color: var(--txt-2);
  font-size: 12.5px;
  font-weight: 500;
  padding: 5px 6px;
  min-height: 30px;
  border-radius: 7px;
}
.ghost.small:hover:not(:disabled) {
  background: var(--accent-tint);
  color: var(--txt);
}
.sm-btn {
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  border-radius: 7px;
}
.ghost-action.sm-btn,
.btn.subtle.sm-btn {
  height: auto;
  min-height: 30px;
  padding: 4px 6px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin-bottom: 12px;
  border-top: 1px solid var(--line);
}
.item {
  border: none;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 12px 4px;
  background: transparent;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  transition: background 0.12s ease;
}
.item.active {
  border-left-color: var(--txt);
  background: var(--card);
  padding-left: 10px;
}
#noteList .item {
  content-visibility: auto;
  contain: layout style;
  contain-intrinsic-size: auto 76px;
}
.item-main-btn {
  flex: 1;
  min-width: 190px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 2px 0;
  text-align: left;
  justify-content: flex-start;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}
.item-main-btn:hover {
  background: transparent;
  border-color: transparent;
  color: var(--txt);
}
.item-main-head {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-width: 0;
}
.lib-item-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--txt);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.item-main-btn b { display: block; width: 100%; overflow-wrap: anywhere; }
.item-main-btn small {
  color: var(--mut);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
}
.item-row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.status-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}
.status-tag.fresh {
  background: transparent;
  color: var(--success);
  padding: 0;
}
.status-tag.discharged {
  background: transparent;
  padding: 0;
  color: var(--mut);
}
.status-tag.charity,
.status-tag.category {
  background: var(--surface-2);
  color: var(--txt-2);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field > label, .lbl { font-size: 12px; color: var(--mut); margin: 6px 0 4px; display: block; }
:where(input:not([type="checkbox"]):not([type="radio"]), textarea, select) {
  width: 100%;
  background: var(--surface-2);
  color: var(--txt);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 9px 10px;
  font: inherit;
  transition: border-color 0.14s ease, background 0.14s ease;
}
:where(input:not([type="checkbox"]):not([type="radio"]), textarea, select):focus {
  border-color: var(--border-ctrl);
  outline: none;
}
textarea {
  min-height: 220px;
  resize: vertical;
  font-family: var(--font-mono);
  font-size: 13px;
  overscroll-behavior: contain;
}
#chartRawPane #noteText {
  min-height: 46vh;
  line-height: 1.5;
}
.raw-md-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}
.raw-md-bar-left {
  display: flex;
  align-items: center;
  min-width: 0;
}
.raw-md-bar-left .lbl {
  margin: 0;
}
.raw-md-fs-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.raw-md-bar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
#chartRawPane.is-fullscreen {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: max(10px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
  gap: 8px;
}
#chartRawPane.is-fullscreen .raw-md-bar {
  margin-bottom: 0;
}
#chartRawPane.is-fullscreen #noteText {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  resize: none;
  overflow-y: auto;
  border-radius: 8px;
}
body.raw-md-fs-open {
  overflow: hidden;
}
#question { min-height: 70px; font-family: inherit; font-size: 14px; }

.input-with-btn {
  display: flex;
  gap: 6px;
  align-items: stretch;
}
.input-with-btn input {
  flex: 1;
  min-width: 0;
}

.companion-details,
#scratchEditorCard {
  scroll-margin-top: 120px;
}

.companion-details {
  margin-top: 16px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.companion-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  list-style: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--txt);
  padding: 4px 2px;
}
.companion-summary::-webkit-details-marker { display: none; }
.companion { padding-top: 10px; }

.preview, .reply {
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 280px;
  overflow: auto;
  overscroll-behavior: contain;
  font: 12px/1.5 var(--font-mono);
}
.preview mark { background: var(--accent-dim); color: var(--accent-txt); border-radius: 3px; padding: 0 2px; }
.report { font-size: 12px; color: var(--mut); margin: 8px 0; }
.report .bad { color: var(--danger); }
.reply { margin-top: 10px; color: var(--txt); }
.fine { font-size: 11px; color: var(--mut); margin-top: 8px; }

.toast {
  position: fixed;
  bottom: calc(18px + var(--kb-inset, 0px) + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  padding: 10px 16px;
  border-radius: 999px;
  z-index: 150;
  border: none;
  box-shadow: var(--shadow-md);
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right));
}
.toast-undo-btn {
  background: var(--surface-2);
  color: var(--txt);
  border: none;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

/* ==================== MODALS & SHARED CONTROLS ==================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  overscroll-behavior: contain;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}
html.kb-open .modal-overlay {
  align-items: flex-start;
  padding-top: calc(var(--vvt, 0px) + max(8px, env(safe-area-inset-top)));
  padding-bottom: calc(var(--kb-inset, 0px) + max(8px, env(safe-area-inset-bottom)));
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  max-height: 92vh;
  max-height: 92dvh;
  max-height: calc(var(--vvh, 100dvh) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow: hidden;
  padding: 18px 20px;
  box-shadow: var(--shadow-lg);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}
.modal-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  scroll-padding-bottom: 84px;
  padding-right: 4px;
}
.modal-head h3 {
  margin: 0;
  font-size: 17px;
  color: var(--txt);
}
.modal-sub {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
  font-weight: 500;
}
.close-btn {
  background: transparent;
  border: none;
  border-radius: 7px;
  font-size: 16px;
  color: var(--mut);
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.close-btn:hover {
  color: var(--txt);
  background: var(--accent-tint);
}
.shift-select-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.date-inline-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.compact-date-input {
  width: auto;
  min-width: 0;
  max-width: 100%;
  padding: 4px 8px;
  font-size: 12px;
  border-radius: 7px;
}
.lbl-inline {
  font-size: 12px;
  color: var(--mut);
  font-weight: 500;
}
.shift-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.shift-pill {
  background: var(--surface-2);
  border: none;
  color: var(--txt-2);
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
}
.shift-pill[data-shift="interim"] {
  border: 1px dashed var(--border-ctrl);
  background: transparent;
  color: var(--txt-2);
}
.shift-pill.active {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  font-weight: 600;
}
.shift-pill[data-shift="interim"].active {
  background: var(--accent-strong);
  border-color: transparent;
  color: var(--accent-on-solid);
}
.compact-time-input {
  width: auto !important;
  min-width: 96px;
  padding: 4px 7px !important;
  font-size: 12px !important;
}

.shift-presets-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.shift-schedule-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shift-slot-row {
  display: grid;
  grid-template-columns: minmax(110px, 130px) minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.shift-time-input,
.shift-label-input {
  min-width: 0;
}
.shift-slot-del-btn {
  min-width: 38px;
  min-height: 38px;
  padding: 6px 10px;
}

/* Telegram-Style Voice Console */
.tg-voice-console {
  background: var(--bg);
  border: none;
  border-radius: 10px;
  padding: 14px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 110px;
}
.rec-state {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.tg-record-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--accent-strong);
  border: none;
  color: var(--accent-on-solid);
  padding: 12px 24px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.14s ease;
}
.tg-record-btn:hover {
  opacity: 0.88;
}
.tg-mic-icon {
  display: inline-flex;
  align-items: center;
}
.tg-mic-icon .ui-ico {
  width: 18px;
  height: 18px;
}
.tg-hint {
  font-size: 11.5px;
  color: var(--mut);
  text-align: center;
}

.rec-status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
.rec-blink-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--danger);
  animation: rec-blink 1s infinite alternate;
}
@keyframes rec-blink {
  0% { opacity: 1; transform: scale(1.1); }
  100% { opacity: 0.3; transform: scale(0.9); }
}
.rec-tag {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--danger);
}
.rec-timer {
  font-size: 16px;
  font-weight: 700;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--txt);
  background: var(--surface-2);
  padding: 2px 8px;
  border-radius: 6px;
  border: none;
}
.audio-wave-canvas {
  width: 100%;
  max-width: 340px;
  height: 44px;
  background: var(--surface);
  border: none;
  border-radius: 8px;
}
.rec-actions-row {
  display: flex;
  gap: 10px;
  width: 100%;
  justify-content: center;
}
.tg-ctrl-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
}
.audio-preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: 100%;
}
.tg-audio-player {
  flex: 1 1 200px;
  min-width: 0;
  max-width: 100%;
  height: 38px;
}

.transcript-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.transcript-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.mobile-keyboard-tip {
  font-size: 11.5px;
  color: var(--mut);
  background: var(--surface-2);
  border: none;
  border-radius: 7px;
  padding: 6px 10px;
  margin-top: 5px;
  line-height: 1.4;
}

#voiceTranscript {
  font-family: inherit;
  font-size: 13.5px;
  min-height: 95px;
  line-height: 1.45;
}
.voice-soap-review {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  border: none;
  background: var(--surface-2);
}
.voice-soap-review textarea {
  min-height: 140px;
  font-size: 12.5px;
}
.voice-ai-status {
  margin-top: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: var(--surface-2);
  border: none;
  color: var(--txt);
  font-size: 12px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.voice-ai-status.error {
  background: var(--danger-bg);
  color: var(--danger-txt);
}
.modal-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
  align-items: center;
  flex-shrink: 0;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}
.modal-foot button:not(.ghost-action) {
  flex: 1 1 175px;
  height: auto;
  min-height: 36px;
  padding: 8px 12px;
  white-space: nowrap;
}
.modal-foot .ghost-action {
  flex: 0 0 auto;
  margin-right: auto;
}

.editor-actions-bar .dictate-btn,
.editor-primary-bar .dictate-btn,
.editor-primary-bar .editor-sec-btn {
  background: var(--surface-2);
  border: none;
  color: var(--txt);
  font-weight: 500;
}
.editor-actions-bar .dictate-btn:hover:not(:disabled),
.editor-primary-bar .dictate-btn:hover:not(:disabled),
.editor-primary-bar .editor-sec-btn:hover:not(:disabled) {
  background: var(--surface-hover);
  color: var(--txt);
}

/* ==================== SHIFT CARRY-FORWARD & HANDOVER MODALS ==================== */
.cf-options {
  display: flex;
  flex-direction: column;
  gap: 6px;
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.cf-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 2px;
  font-size: 13px;
  color: var(--txt);
  cursor: pointer;
}
.cf-option:has(input:disabled) {
  opacity: 0.6;
  cursor: not-allowed;
}
.cf-meta {
  font-size: 11.5px;
  color: var(--mut);
}
.bp-split-inputs {
  display: flex;
  align-items: center;
  gap: 4px;
}
.bp-split-inputs input {
  min-width: 0;
  flex: 1;
  text-align: center;
  padding-left: 6px;
  padding-right: 6px;
}
.bp-slash {
  color: var(--mut);
  font-weight: 700;
  flex-shrink: 0;
}
.quick-vs-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
  margin-top: 8px;
}
.quick-io-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin-top: 6px;
}
.quick-io-grid.has-unit {
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 1.1fr) 82px minmax(0, 1.1fr) auto;
}
.tl-quick-edit .quick-io-grid {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 82px minmax(0, 1.3fr) auto;
}
#shiftPreviewText {
  min-height: 220px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
}
.shift-modal-box {
  max-width: 720px;
}
.shift-mode-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.shift-mode-tabs {
  display: inline-flex;
  gap: 6px;
}
.shift-guided-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.shift-guided-form[hidden],
#shiftRawPane[hidden] {
  display: none;
}
.shift-field-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shift-field-card:last-child {
  border-bottom: none;
}
.shift-field-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.shift-field-card-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--info-txt);
}
.shift-field-subgrid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.shift-sub-label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  color: var(--mut);
  margin-bottom: 4px;
}
.shift-guided-form textarea {
  min-height: 74px;
  font-size: 13px;
  line-height: 1.4;
}
.shift-io-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 82px minmax(0, 1.1fr);
  gap: 6px;
}
.shift-pe-actions {
  display: flex;
  gap: 6px;
}

.handover-modal {
  max-width: 760px;
}
.handover-controls-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 8px;
}
.handover-controls-bar select {
  width: auto;
  padding: 5px 8px;
  font-size: 12px;
}
.handover-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.handover-preview {
  max-height: none;
  overflow: visible;
  margin: 0;
  white-space: normal;
  font: 13px/1.5 var(--font-sans);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
}
.ho-doc-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
}
.ho-stats-bar {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--mut);
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
}
.ho-card {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 11px 13px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.ho-card.ho-gaps {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
}
.ho-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--txt);
  border-bottom: 1px solid var(--line);
  padding-bottom: 5px;
  margin-bottom: 2px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.ho-jump-btn {
  background: var(--surface);
  border: none;
  color: var(--txt);
  font-size: 11.5px;
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.ho-jump-btn:hover { background: var(--accent-dim); }
.ho-card.ho-gaps .ho-header {
  color: var(--warn);
  border-bottom-color: var(--warn-border);
}
.ho-line {
  font-size: 12.5px;
  line-height: 1.48;
  color: var(--txt-2);
}
.ho-clickable {
  cursor: pointer;
  border-radius: 6px;
  padding: 2px 4px;
  margin: 0 -4px;
}
.ho-clickable:hover {
  background: var(--surface-2);
}
.ho-label {
  font-weight: 600;
  color: var(--info-txt);
  margin-right: 4px;
}
.ho-card.ho-gaps .ho-label {
  color: var(--warn-txt);
}
.ho-val { color: var(--txt-2); }
.ho-pending-hdr {
  font-size: 12px;
  font-weight: 600;
  color: var(--warn);
  margin-top: 2px;
}
.ho-pending-item {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt-2);
  padding-left: 4px;
}
.ho-pending-item.done { color: var(--mut); }
.ho-box {
  color: var(--mut);
  font-size: 13px;
  line-height: 1.3;
}
.ho-resolved {
  font-style: italic;
  color: var(--success);
}
.ho-empty {
  font-size: 12.5px;
  color: var(--mut);
  font-style: italic;
}
.ho-footnote {
  font-size: 11.5px;
  color: var(--mut);
  font-style: italic;
  padding: 2px 4px;
}

.template-hint {
  font-size: 11.5px;
  color: var(--mut);
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 8px 10px;
  margin-bottom: 10px;
  line-height: 1.45;
}
.template-hint code {
  color: var(--accent);
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
}
#defaultTemplateInput {
  min-height: 280px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
}
.scut-footer .copy-update-btn {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}
.scut-footer .copy-update-btn:hover {
  background: var(--accent-dim);
  color: var(--accent-on-solid);
}

/* ==================== SETTINGS PAGE & COMPANION BAR ==================== */
.settings-shell {
  display: grid;
  grid-template-columns: 205px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding-top: 8px;
}
.settings-subnav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  position: sticky;
  top: 20px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.settings-nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: 0 8px 8px 0;
  border: none;
  border-left: 2px solid transparent;
  background: transparent;
  color: var(--mut);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.settings-nav-btn:hover {
  background: var(--surface-hover);
  color: var(--txt);
}
.settings-nav-btn.active,
.settings-nav-btn[aria-selected="true"] {
  background: var(--surface-2);
  border-left-color: var(--txt);
  color: var(--txt);
}
.settings-nav-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  flex-shrink: 0;
}
.settings-nav-ico .ui-ico {
  width: 17px;
  height: 17px;
  color: var(--mut);
}
.settings-nav-btn.active .settings-nav-ico .ui-ico,
.settings-nav-btn[aria-selected="true"] .settings-nav-ico .ui-ico {
  color: var(--txt);
}
.settings-nav-text {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}
.settings-nav-title {
  font-size: 13.5px;
  font-weight: 600;
  color: inherit;
  line-height: 1.2;
}
.settings-nav-sub {
  font-size: 11px;
  color: var(--mut);
  line-height: 1.2;
}
.settings-nav-btn.active .settings-nav-sub,
.settings-nav-btn[aria-selected="true"] .settings-nav-sub {
  color: var(--txt-2);
  opacity: 0.85;
}
.settings-content,
.settings-subpanel {
  min-width: 0;
}
.settings-stack {
  display: flex;
  flex-direction: column;
  gap: 18px;
}
.shortcuts-legend summary {
  padding: 2px 0;
}
.shortcuts-grid {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  font-size: 12.5px;
  color: var(--txt-2);
}
.shortcuts-grid kbd {
  background: var(--surface-2);
  border: none;
  border-radius: 5px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--txt);
  margin-right: 6px;
}

/* Offline WASM Whisper UI */
.whisper-bar {
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  margin-bottom: 10px;
}
.whisper-meta-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.whisper-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--txt-2);
}
.whisper-progress-wrap {
  margin-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.whisper-progress-track {
  width: 100%;
  height: 7px;
  background: var(--surface-2);
  border-radius: 99px;
  overflow: hidden;
}
.whisper-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent-strong);
  transition: width 0.2s ease;
}
.voice-idle-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.whisper-review-actions {
  display: flex;
  width: 100%;
  justify-content: center;
  gap: 8px;
}
.whisper-transcribe-btn {
  width: 100%;
  font-size: 13px;
  padding: 8px 14px;
}
.settings-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 12px;
  margin-top: 12px;
  align-items: center;
}
.settings-actions > .primary,
.settings-actions > .btn-secondary {
  flex: 0 1 auto;
}
.settings-actions > .ghost-action {
  flex: 0 0 auto;
  min-width: 0;
}
.ai-preset-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}
.ai-preset-chip,
.ai-model-chip {
  background: var(--surface-2);
  border: none;
  border-radius: 7px;
  color: var(--txt-2);
  padding: 6px 11px;
  font-size: 12.5px;
  font-weight: 500;
  margin-bottom: 0;
}
.ai-preset-chip:hover,
.ai-model-chip:hover {
  background: var(--surface-hover);
  color: var(--txt);
}
.ai-preset-chip.active,
.ai-model-chip.active {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  font-weight: 600;
}
.ai-gemini-hint {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 10px;
  background: var(--surface);
  border: none;
  border-radius: 8px;
}
.ai-gemini-hint[hidden] {
  display: none;
}
.ai-model-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ai-key-link {
  font-size: 12px;
  font-weight: 600;
  color: var(--txt);
  text-decoration: none;
  white-space: nowrap;
}
.ai-key-link:hover {
  text-decoration: underline;
}
#fetchAiModelsBtn {
  white-space: nowrap;
  flex-shrink: 0;
}
.ai-live-model-select {
  width: 100%;
  margin-top: 6px;
}
.ai-live-model-select[hidden] {
  display: none;
}
.companion-conn-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 7px 10px;
  margin: 8px 0 10px;
}

/* ==================== VISUAL TEMPLATE BUILDER ==================== */
#tplHeaderInput {
  min-height: 62px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
#tplFooterInput {
  min-height: 76px;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.4;
}
.tpl-id-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.tpl-id-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 6px 12px;
  margin: 0;
  font-size: 12.5px;
  line-height: 1.2;
  color: var(--txt);
  cursor: pointer;
  vertical-align: middle;
}
.tpl-id-chip > span {
  line-height: 1.2;
}
.tpl-sections-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--line-soft);
}
.tpl-section-item {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 9px 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tpl-section-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.tpl-section-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--txt);
  cursor: pointer;
}
.tpl-section-item.disabled .tpl-section-check {
  color: var(--mut);
}
.tpl-order-btns {
  display: flex;
  gap: 4px;
}
.tpl-order-btn {
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.1;
  min-width: 34px;
  text-align: center;
}
.tpl-subitems {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding-left: 24px;
  padding-top: 2px;
}
.tpl-subitems.disabled {
  color: var(--mut-2);
}
.tpl-subitems.disabled .tpl-subitem-check {
  color: var(--mut-2);
  cursor: not-allowed;
}
.tpl-subitem-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12.5px;
  color: var(--txt-2);
  cursor: pointer;
}
.tpl-preview-box {
  max-height: 220px;
  font-family: var(--font-sans);
  font-size: 12.5px;
  line-height: 1.45;
  margin: 0;
}
.advanced-template {
  margin-top: 12px;
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0 0;
}
.advanced-template summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mut);
  user-select: none;
}
.advanced-template[open] summary {
  color: var(--accent);
  margin-bottom: 8px;
}

/* ==================== STRUCTURED PROFILE & CHART TIMELINE ==================== */
.grid-5 {
  display: grid;
  grid-template-columns: 0.55fr 0.5fr 0.72fr 0.72fr 1.1fr 1.1fr;
  gap: 8px;
  margin-bottom: 8px;
}
.grid-profile-extra {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}
.profile-flags {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  padding-bottom: 0;
}
.profile-categories-bar {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line-soft);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.editor-view-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
  padding-top: 4px;
  border-top: 1px solid var(--line);
}
.editor-tabs {
  display: flex;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  max-width: 100%;
  width: 100%;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 0;
  gap: 18px;
}
.editor-tabs::-webkit-scrollbar { display: none; }
.editor-tabs .mode-btn {
  flex: 0 0 auto;
  white-space: nowrap;
  padding: 9px 2px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.editor-tabs .mode-btn.active {
  border-bottom-color: var(--txt);
  color: var(--txt);
}
.toolbar-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
}
.toolbar-search {
  flex: 1 1 0;
  min-width: 0;
}
.toolbar-sort {
  flex-shrink: 0;
}
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-chips .filter-chip {
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: var(--mut);
  font-size: 13.5px;
  font-weight: 500;
  padding: 8px 1px;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-bottom: -1px;
  transition: color 0.14s ease, border-color 0.14s ease;
}
.filter-chips .filter-chip:hover {
  background: transparent;
  color: var(--txt);
}
.filter-chips .filter-chip.active {
  color: var(--txt);
  font-weight: 600;
  border-bottom-color: var(--txt);
}
.pitch-presets .filter-chip {
  background: var(--surface-2);
  border: none;
  border-radius: 7px;
  padding: 6px 11px;
  font-size: 12.5px;
  color: var(--txt-2);
}
.pitch-presets .filter-chip:hover {
  background: var(--surface-hover);
  color: var(--txt);
}
.pitch-presets .filter-chip.active {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  font-weight: 600;
}
.timeline-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 10px;
}
.timeline-shift-chips-wrap {
  min-width: 0;
  max-width: 100%;
}
.timeline-shift-chips-wrap[hidden] {
  display: none !important;
}
.timeline-shift-chips {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 2px 0;
}
.timeline-shift-chips::-webkit-scrollbar {
  display: none;
}
.timeline-shift-chip {
  height: auto;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--txt-2);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background 0.14s ease, color 0.14s ease, border-color 0.14s ease;
}
.timeline-shift-chip:hover {
  background: var(--surface-hover);
  color: var(--txt);
  border-color: var(--mut);
}
.timeline-shift-chip.is-interim {
  border-style: dashed;
}
.timeline-shift-chip .shift-interim-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.7;
  flex-shrink: 0;
}
.timeline-shift-chip.active {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  border-color: var(--accent-strong);
  border-style: solid;
  font-weight: 600;
}
.timeline-shift-chip.active:hover {
  background: var(--accent-strong);
  color: var(--accent-on-solid);
  border-color: var(--accent-strong);
  opacity: 0.92;
}
.timeline-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

#chartLabsPane {
  min-width: 0;
  max-width: 100%;
}
.labs-summary-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.labs-export-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}
.labs-export-actions button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.labs-summary-content {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}
.labs-summary-meta {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 6px 12px;
  padding: 4px 0 10px;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
}
.labs-meta-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--txt);
}
.labs-meta-inline,
.labs-meta-badges {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--mut);
}
.labs-meta-sep {
  color: var(--mut-2);
}
.labs-meta-flagged {
  color: var(--danger-txt);
  font-weight: 600;
}
.labs-meta-pill {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  background: transparent;
  border: none;
  color: var(--mut);
}
.labs-meta-pill.is-abnormal {
  background: transparent;
  border: none;
  color: var(--danger-txt);
}
.labs-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.labs-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mut);
}
.labs-panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px 24px;
}
.labs-panel-card {
  background: transparent;
  border: none;
  border-radius: 0;
  padding-bottom: 4px;
  overflow: visible;
  min-width: 0;
}
.labs-panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  background: transparent;
  border-bottom: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--mut);
}
.labs-panel-count {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  color: var(--mut);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}
.labs-kv-list {
  display: flex;
  flex-direction: column;
}
.labs-kv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}
.labs-kv-row:last-child {
  border-bottom: none;
}
.labs-kv-key {
  display: flex;
  align-items: baseline;
  gap: 5px;
  min-width: 0;
}
.labs-key-name {
  font-weight: 600;
  color: var(--txt);
}
.labs-unit,
.labs-table-unit {
  font-size: 10.5px;
  color: var(--mut);
  font-weight: 400;
}
.labs-table-unit {
  margin-left: 4px;
}
.labs-kv-val {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 5px;
  text-align: right;
}
.labs-val-num {
  font-family: var(--font-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--txt);
}
.labs-val-num.flag-h,
.labs-trend-table td.flag-h {
  color: var(--danger);
  font-weight: 700;
}
.labs-val-num.flag-l,
.labs-trend-table td.flag-l {
  color: var(--warn);
  font-weight: 700;
}
.lab-flag-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  padding: 2px 5px;
  border-radius: 4px;
}
.lab-flag-pill.flag-h {
  background: var(--danger-bg);
  border: none;
  color: var(--danger-txt);
}
.lab-flag-pill.flag-l {
  background: var(--warn-bg);
  border: none;
  color: var(--warn-txt);
}
.labs-delta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mut);
  font-variant-numeric: tabular-nums;
}
.labs-when {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--mut-2);
}
.labs-table-wrap {
  max-width: 100%;
  overflow-x: auto;
  border: none;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  -webkit-overflow-scrolling: touch;
}
.labs-trend-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.labs-trend-table th,
.labs-trend-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--line-soft);
  border-right: none;
  text-align: right;
}
.labs-trend-table tbody tr:last-child th,
.labs-trend-table tbody tr:last-child td {
  border-bottom: none;
}
.labs-trend-table thead th {
  background: var(--surface);
  color: var(--mut);
  border-bottom: 1px solid var(--line);
  font-weight: 600;
  font-size: 11px;
}
.labs-trend-table .labs-sticky-col {
  position: sticky;
  left: 0;
  z-index: 2;
  background: var(--bg);
  text-align: left;
  border-right: 1px solid var(--line);
  contain: layout style;
}
.labs-trend-table thead .labs-sticky-col {
  background: var(--surface);
  z-index: 3;
}
.labs-trend-table .labs-ref-col {
  text-align: left;
  color: var(--mut);
  font-size: 11px;
}
.labs-td-empty {
  color: var(--mut-2);
}
.labs-diag-list {
  display: flex;
  flex-direction: column;
  gap: 0;
  border-top: 1px solid var(--line);
}
.labs-diag-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 10px 0;
}
.labs-diag-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}
.labs-diag-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--txt);
}
.labs-diag-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mut);
}
.labs-diag-body {
  font-size: 12.5px;
  color: var(--txt-2);
  line-height: 1.45;
  white-space: pre-wrap;
}
.timeline-cumfb-bar {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.timeline-cumfb-main {
  font-size: 13px;
  color: var(--txt);
}
.timeline-cumfb-total {
  color: var(--txt);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
  margin-left: 4px;
}
.timeline-cumfb-days {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.timeline-cumfb-chip {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  background: transparent;
  border: none;
  color: var(--txt-2);
  border-radius: 0;
  padding: 0;
}
.timeline-cumfb-chip small {
  color: var(--mut);
}
.timeline-empty {
  text-align: center;
  padding: 28px 16px;
  background: transparent;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--mut);
}
.timeline-date-group {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.timeline-date-hdr {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mut);
  padding: 10px 0 6px;
  border-bottom: 1px solid var(--line);
}
.timeline-shift-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 12px 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  content-visibility: auto;
  contain: layout style;
  contain-intrinsic-size: auto 220px;
}
.timeline-shift-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.timeline-shift-badge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--txt);
  background: var(--surface-2);
  border: none;
  padding: 2px 7px;
  border-radius: 4px;
}
.timeline-badges {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.metric-pill {
  display: block;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--txt-2);
  overflow-wrap: anywhere;
}
.metric-pill b {
  color: var(--mut);
  font-weight: 600;
  margin-right: 4px;
}
.metric-pill.drip {
  color: var(--txt);
}
.metric-pill.drip b {
  color: var(--danger);
}
.timeline-events {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--txt);
  line-height: 1.45;
}
.timeline-event-line {
  white-space: pre-wrap;
  word-break: break-word;
}
.tl-soap-tag {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--mut);
  margin-right: 4px;
}
.tl-boilerplate-details summary {
  cursor: pointer;
  font-size: 11.5px;
  color: var(--mut);
}
.tl-fulltext-details {
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}
.tl-fulltext-details summary {
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mut);
}
.tl-fulltext {
  margin: 8px 0 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: 13px;
  line-height: 1.5;
  color: var(--txt);
}
.tl-history-card .admit-history-grid {
  margin-top: 4px;
}
.timeline-subsection {
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.timeline-sub-lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--mut);
}
.tl-meta-edit-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr) auto;
  gap: 8px;
  align-items: end;
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.tl-meta-edit-row .field {
  min-width: 0;
}
.tl-meta-edit-row input,
.tl-meta-edit-row select {
  width: 100%;
  min-width: 0;
}
.tl-edit-time-wrap[hidden] {
  display: none;
}
.tl-quick-edit {
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}
.timeline-inline-edit .tl-edit-textarea {
  min-height: 160px;
  font-size: 12.5px;
  font-family: var(--font-mono);
  line-height: 1.45;
  margin-bottom: 8px;
}

/* ==================== PROFILE DROPDOWN & CHART EXPLORER ==================== */
.profile-dropdown {
  background: transparent;
  border: none;
  border-top: 1px solid var(--line);
  border-radius: 0;
  padding: 11px 0;
  margin-bottom: 0;
}
.profile-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt);
}
.profile-summary::-webkit-details-marker { display: none; }
#profileSummaryText {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-summary-badge {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--mut);
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  white-space: nowrap;
  flex-shrink: 0;
}
.profile-dropdown[open] .profile-summary-badge {
  background: transparent;
  border-color: transparent;
  color: var(--txt);
}
.profile-dropdown-body {
  border-top: 1px solid var(--line-soft);
  margin-top: 10px;
  padding-top: 10px;
}
.library-toolbar {
  margin-bottom: 8px;
  border-bottom: none;
  padding-bottom: 4px;
}
#librarySection .list {
  max-height: none;
  overflow: visible;
}

/* ==================== QUICK NOTES / SCRATCHPAD ==================== */
.grid-scratch-meta {
  display: grid;
  grid-template-columns: 2fr 1fr auto;
  gap: 8px;
  align-items: end;
  margin-bottom: 8px;
}
#scratchBodyInput {
  min-height: 140px;
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.5;
}
#scratchEditorCard {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  margin-bottom: 8px;
}
.scratch-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.scratch-card {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-left: 3px solid transparent;
  border-radius: 0;
  padding: 14px 4px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  content-visibility: auto;
  contain: layout style;
  contain-intrinsic-size: auto 160px;
}
.scratch-card.pinned {
  border-left-color: var(--txt);
  padding-left: 11px;
}
.scratch-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
}
.scratch-title-wrap {
  min-width: 0;
}
.scratch-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--txt);
  margin: 0;
}
.scratch-pin-tag {
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--txt);
}
.scratch-cat-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--surface-2);
  border: none;
  color: var(--txt-2);
  white-space: nowrap;
  flex-shrink: 0;
}
.scratch-body {
  font-size: 13px;
  line-height: 1.5;
  color: var(--txt-2);
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--surface);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 6;
  overflow: hidden;
}
.scratch-body.expanded {
  display: block;
  -webkit-line-clamp: unset;
  overflow: visible;
}
.scratch-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: flex-start;
  margin-top: 2px;
  padding-top: 2px;
  border-top: none;
}
.scratch-foot .ghost-action {
  flex: 0 0 auto;
}
.scratch-foot .scratch-del-btn {
  margin-left: auto;
  color: var(--danger);
  padding: 5px 6px;
}
.scratch-foot .scratch-del-btn .ui-ico {
  color: var(--danger);
}

/* ==================== DUMP-TO-CHART INBOX & LAB PARSER ==================== */
.inbox-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-dim);
  border: 1px solid var(--accent);
  color: var(--accent-txt);
  font-size: 11px;
  font-weight: 700;
  margin-left: 4px;
}
.inbox-modal {
  max-width: 760px;
}
#inboxPasteInput {
  min-height: 84px;
  font-size: 13px;
  line-height: 1.45;
}
#inboxDryRunPreview {
  min-height: 130px;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 12.5px;
  line-height: 1.45;
}
.inbox-queue {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 165px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin-bottom: 10px;
}
.inbox-queue-item-wrap {
  display: flex;
  align-items: stretch;
  gap: 6px;
}
.inbox-queue-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 8px 10px;
  cursor: pointer;
}
.inbox-queue-item.active {
  border-radius: 7px;
  border-bottom-color: transparent;
  background: var(--surface-2);
}
.inbox-queue-snippet {
  font-size: 12.5px;
  color: var(--txt);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}
.inbox-status {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  border: none;
  background: transparent;
  color: var(--mut);
  white-space: nowrap;
}
.inbox-status.pending {
  background: transparent;
  color: var(--mut);
  border: none;
}
.inbox-status.unresolved {
  background: transparent;
  color: var(--warn-txt);
  border: none;
}
.inbox-status.filed {
  background: transparent;
  color: var(--success-txt);
  border: none;
}
.inbox-filing-pane {
  border-top: 1px solid var(--line);
  padding-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.resolve-banner {
  font-size: 12.5px;
  font-weight: 500;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--mut);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.resolve-banner.matched,
.resolve-banner.resolved {
  background: var(--success-bg);
  border-color: var(--success-border);
  color: var(--success-txt);
}
.resolve-banner.warn {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn);
}
.resolve-banner.unresolved {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger);
}
.inbox-candidate-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.inbox-candidate-chip {
  background: var(--surface-2);
  border: 1px solid var(--border-ctrl);
  color: var(--txt);
  border-radius: 7px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
}
.inbox-target-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}
.inbox-controls-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.inbox-narrative-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
}
.lab-chips-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.lab-chip {
  font-size: 11.5px;
  font-family: ui-monospace, Menlo, monospace;
  padding: 3px 8px;
  border-radius: 6px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  color: var(--txt-2);
}
.lab-chip.high {
  background: var(--danger-bg);
  border-color: var(--danger-border);
  color: var(--danger-txt);
  font-weight: 600;
}
.lab-chip.low {
  background: var(--warn-bg);
  border-color: var(--warn-border);
  color: var(--warn-txt);
  font-weight: 600;
}

/* ==================== CLINICAL CALCULATORS & AUDIT MODAL ==================== */
.calc-modal {
  max-width: 760px;
  max-height: 92vh;
  max-height: 92dvh;
  max-height: calc(var(--vvh, 100dvh) - 16px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
}
.calc-patient-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 10px;
}
.calc-patient-bar > .field {
  flex: 1 1 220px;
}
.calc-weight-banner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  background: var(--warn-bg);
  border: 1px solid var(--warn-border);
  border-radius: 10px;
  padding: 9px 12px;
  margin-bottom: 12px;
  font-size: 12.5px;
  color: var(--warn-txt);
}
.calc-weight-banner input {
  width: 110px;
  padding: 6px 8px;
}
.calc-renal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}
.calc-card {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.calc-card.missing {
  border-left: 3px solid var(--warn);
  background: var(--warn-bg);
}
.calc-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
}
.calc-card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
  color: var(--txt-2);
  text-transform: uppercase;
}
.calc-badge {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  font-weight: 600;
  padding: 0;
  border-radius: 0;
  background: transparent;
  color: var(--mut);
}
.calc-badge.calculated { background: transparent; color: var(--mut); }
.calc-badge.charted { background: transparent; color: var(--mut); }
.calc-badge.missing { background: transparent; color: var(--warn-txt); }
.calc-badge.warn { background: transparent; color: var(--danger-txt); }
.calc-val {
  font-size: 22px;
  font-weight: 800;
  color: var(--accent);
  line-height: 1.2;
}
.calc-val.missing-txt {
  font-size: 13.5px;
  color: var(--warn);
  font-weight: 700;
}
.calc-sub {
  font-size: 11.5px;
  color: var(--mut);
  line-height: 1.4;
}
.calc-override-box {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 9px 12px;
  margin-bottom: 12px;
}
.calc-override-summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--info-txt);
  list-style: none;
}
.calc-override-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}
.calc-section { margin-top: 12px; }
.calc-section-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--txt-2);
  margin-bottom: 6px;
}
.calc-flags-list, .calc-interactions-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.calc-flag-card {
  background: var(--surface-2);
  border: 1px solid var(--line-soft);
  border-left: 3px solid var(--warn);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  line-height: 1.45;
}
.calc-flag-card.info { border-left-color: var(--info); }
.calc-flag-title {
  font-weight: 700;
  color: var(--warn-txt);
  margin-bottom: 2px;
}
.calc-flag-card.info .calc-flag-title { color: var(--info); }
.calc-flag-src { font-size: 11px; color: var(--mut); margin-top: 3px; }
.calc-interaction-row {
  background: var(--purple-bg);
  border: 1px solid var(--purple-border);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--purple);
  line-height: 1.45;
}
.calc-ok-note {
  font-size: 12px;
  color: var(--success);
  background: var(--success-bg);
  border: 1px solid var(--success-border);
  border-radius: 8px;
  padding: 8px 10px;
}
.calc-drip-top {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 8px;
  align-items: end;
}
.drip-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}
.drip-results-box {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 12px;
}
.drip-result-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.drip-metric {
  background: var(--surface);
  border: none;
  border-radius: 7px;
  padding: 8px 10px;
}
.drip-metric-lbl { font-size: 11px; color: var(--mut); text-transform: uppercase; }
.drip-metric-val { font-size: 15px; font-weight: 700; color: var(--accent); margin-top: 2px; }
.drip-shortfall {
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12.5px;
  line-height: 1.4;
}
.drip-shortfall.warn { background: var(--danger-bg); border: 1px solid var(--danger-border); color: var(--danger-txt); }
.drip-shortfall.ok { background: var(--success-bg); border: 1px solid var(--success-border); color: var(--success); }

/* Restore preview dialog */
.restore-preview-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.restore-preview-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 7px 0;
  border-radius: 0;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  font-size: 12.5px;
}

/* ==================== APPEARANCE & SWISS THEMES ==================== */
.theme-palette-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.theme-swatch-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 13px;
  min-height: 68px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--txt);
  text-align: left;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}
.theme-swatch-card:hover {
  border-color: var(--border-ctrl);
  background: var(--surface-hover);
}
.theme-swatch-card[aria-checked="true"] {
  border: 2px solid var(--txt);
  background: var(--surface-2);
}
.theme-swatch-dots {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.theme-swatch-dot {
  width: 16px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border-ctrl);
  flex-shrink: 0;
}
.theme-swatch-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.theme-swatch-name {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt);
}
.theme-swatch-mode {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--mut);
}

/* ==================== ADMIT PATIENT & ADMITTING HISTORY ==================== */
.modal-box.telegram-modal,
.modal-box.admit-modal {
  max-width: 760px;
}
.admit-section {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 10px 0 12px;
}
.admit-pmh-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.admit-pmh-item {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.admit-pmh-item.admit-pmh-wide {
  grid-column: 1 / -1;
}
.admit-pmh-detail {
  flex: 1 1 130px;
  min-width: 0;
  padding: 6px 8px !important;
  font-size: 13px !important;
}
.admit-pmh-detail:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
#admitModal .admit-pane textarea {
  min-height: 70px;
  font-family: inherit;
  font-size: 14px;
}
#admitPasteInput,
#admitDictateTranscript {
  min-height: 150px !important;
}
.admit-dictate-bar {
  background: var(--surface-2);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
}
.admit-history-grid {
  display: flex;
  flex-direction: column;
  gap: 0;
}
.admit-history-row {
  display: grid;
  grid-template-columns: 165px minmax(0, 1fr);
  gap: 8px;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--line-soft);
  border-radius: 0;
  padding: 8px 0;
  font-size: 13px;
}
.admit-history-row:last-child {
  border-bottom: none;
}
.admit-history-lbl {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admit-history-val {
  color: var(--txt-2);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

@media (max-width: 820px) {
  header.app-header {
    padding: max(10px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
  }
  main {
    padding: 0 max(14px, env(safe-area-inset-right)) calc(96px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  }
  body.mode-editor main {
    padding-bottom: calc(96px + env(safe-area-inset-bottom));
  }
  .toast {
    bottom: calc(84px + var(--kb-inset, 0px) + env(safe-area-inset-bottom));
  }
  html.kb-open .toast {
    bottom: calc(14px + var(--kb-inset, 0px) + env(safe-area-inset-bottom));
  }
  .shift-pill { min-height: 36px; padding: 6px 10px; }
  .chip { min-height: 32px; padding: 6px 12px; }
  .close-btn { min-width: 36px; min-height: 36px; }
  .pending-line { padding: 6px 0; }
  .pending-line input[type="checkbox"] { width: 18px; height: 18px; }
  .ledger-list {
    margin: 0 calc(-1 * max(14px, env(safe-area-inset-right))) 0 calc(-1 * max(14px, env(safe-area-inset-left)));
    width: calc(100% + max(14px, env(safe-area-inset-left)) + max(14px, env(safe-area-inset-right)));
  }
  .ledger-row {
    padding: 12px max(14px, env(safe-area-inset-right)) 10px calc(max(14px, env(safe-area-inset-left)) - 3px);
  }
  .rounds-toolbar { gap: 8px; padding: 8px 0 10px; }
  .editor-hint, .editor-view-bar .cf-meta { display: none; }
  .sticky-editor-bar {
    border-radius: 0;
    margin: 0 calc(-1 * max(14px, env(safe-area-inset-right))) 10px calc(-1 * max(14px, env(safe-area-inset-left)));
    flex-wrap: nowrap;
    background: var(--bg);
    padding: 8px max(14px, env(safe-area-inset-right)) 8px max(14px, env(safe-area-inset-left));
    gap: 6px;
  }
  .editor-topbar-left,
  .editor-topbar-right {
    flex-wrap: nowrap;
    gap: 6px;
  }
  .sticky-editor-bar .pill,
  .sticky-editor-bar .status-meta {
    font-size: 11px;
    padding: 0;
    white-space: nowrap;
  }
  .sticky-editor-bar .ghost-action {
    padding: 5px 6px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .sticky-editor-bar .editor-save-btn {
    height: 32px;
    min-height: 32px;
    padding: 0 12px;
    font-size: 12.5px;
    white-space: nowrap;
  }
  .calc-patient-bar { flex-direction: column; align-items: stretch; }
  .calc-patient-bar > .field { flex: 1 1 auto; width: 100%; }
  .more-menu-popover {
    position: fixed;
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
    top: auto;
    bottom: calc(68px + env(safe-area-inset-bottom));
    min-width: 0;
    width: auto;
    max-width: none;
    z-index: 95;
    padding: 8px;
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
  }
  .modal-overlay {
    align-items: flex-end;
    padding: max(12px, env(safe-area-inset-top)) 0 0 0;
  }
  html.kb-open .modal-overlay {
    align-items: flex-start;
    padding: calc(var(--vvt, 0px) + max(8px, env(safe-area-inset-top))) 0 calc(var(--kb-inset, 0px)) 0;
  }
  .modal-box,
  .calc-modal,
  .inbox-modal,
  .handover-modal,
  .admit-modal {
    max-width: 100%;
    border-radius: 16px 16px 0 0;
    border-bottom: none;
    padding: 14px max(14px, env(safe-area-inset-right)) calc(12px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    max-height: calc(var(--vvh, 100dvh) - max(12px, env(safe-area-inset-top)));
  }
  .admit-pmh-grid,
  .admit-history-row {
    grid-template-columns: 1fr;
  }
  .inbox-queue {
    max-height: none;
    overflow-y: visible;
  }
  .grid-5 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .editor-layout, .settings-shell, .grid-2, .grid-profile-extra, .grid-scratch-meta, .calc-renal-grid, .calc-override-grid, .drip-form-grid, .drip-result-grid {
    grid-template-columns: 1fr;
  }
  .settings-shell {
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding-top: 0;
    width: 100%;
    max-width: 100%;
  }
  .settings-shell > * {
    min-width: 0;
  }
  .settings-subnav {
    position: static;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    flex-direction: row;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
    gap: 16px;
    border-bottom: 1px solid var(--line);
    padding: 0;
    margin-bottom: 6px;
  }
  .settings-subnav::-webkit-scrollbar { display: none; }
  .settings-nav-ico {
    display: none;
  }
  .settings-nav-btn {
    flex: 0 0 auto;
    width: auto;
    min-width: 0;
    min-height: 40px;
    padding: 8px 1px;
    margin-bottom: -1px;
    border: none;
    border-bottom: 2px solid transparent;
    border-radius: 0;
    background: transparent;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    gap: 6px;
  }
  .settings-nav-btn:hover {
    background: transparent;
    color: var(--txt);
  }
  .settings-nav-btn.active,
  .settings-nav-btn[aria-selected="true"] {
    background: transparent;
    border-left-color: transparent;
    border-bottom-color: var(--txt);
    color: var(--txt);
  }
  .settings-nav-title {
    font-size: 12.5px;
  }
  .settings-nav-sub {
    display: none;
  }
  .quick-vs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .quick-vs-grid > .field:first-child {
    grid-column: 1 / -1;
  }
  .quick-io-grid,
  .quick-io-grid.has-unit,
  .tl-quick-edit .quick-io-grid,
  .shift-io-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tl-meta-edit-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tl-meta-edit-row .tl-edit-time-wrap {
    grid-column: 1 / -1;
  }
  .quick-io-grid > .field.align-end {
    grid-column: 1 / -1;
  }
  textarea { min-height: 180px; }
  .shift-guided-form textarea { min-height: 72px; }
}

@media (max-width: 600px) {
  .grid-5 {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }
  .grid-5 > .field:nth-child(-n+3) {
    grid-column: span 2;
  }
  .grid-5 > .field:nth-child(n+4) {
    grid-column: span 3;
  }
}

/* ==================== BEDSIDE PITCH MODAL ==================== */
.modal-box.pitch-modal {
  max-width: 640px;
}
.pitch-guard-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.pitch-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.pitch-preview-details {
  border: none;
  border-radius: 8px;
  background: var(--surface-2);
  padding: 9px 12px;
}
.pitch-preview-details summary {
  cursor: pointer;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--txt-2);
  user-select: none;
}
#pitchSafePreview {
  max-height: 220px;
  overflow: auto;
  max-width: 100%;
}
.pitch-reply-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.pitch-reply-head button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
#pitchReply {
  max-height: 280px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.pitch-modal-foot {
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.pitch-modal-foot button {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.pitch-foot-secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

@media (max-width: 640px) {
  .editor-utility-strip {
    gap: 4px 8px;
  }
  .editor-utility-strip .ghost-action {
    padding: 5px 4px;
    font-size: 12px;
  }
  .labs-summary-toolbar {
    flex-direction: column;
    align-items: stretch;
  }
  .labs-export-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
  }
  .labs-export-actions button {
    flex: 0 0 auto;
    justify-content: flex-start;
    padding: 5px 4px;
    font-size: 12px;
    white-space: nowrap;
  }
  .editor-tabs {
    gap: 14px;
  }
  .editor-tabs .mode-btn {
    font-size: 12.5px;
    gap: 4px;
  }
  .labs-panel-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .pitch-modal-foot {
    flex-direction: column-reverse;
    align-items: stretch;
  }
  .pitch-modal-foot #pitchGenerateBtn {
    flex: 0 0 auto;
    width: 100%;
  }
  .pitch-foot-secondary {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .pitch-foot-secondary button {
    flex: 0 0 auto;
    width: 100%;
  }
}

@media (max-width: 520px) {
  .editor-tabs {
    gap: 10px;
  }
  .editor-tabs .mode-btn {
    flex: 0 0 auto;
    white-space: nowrap;
    text-align: left;
    line-height: 1.2;
    font-size: 12px;
    padding: 8px 1px;
  }
  .editor-tabs .mode-btn .ui-ico {
    width: 13px;
    height: 13px;
  }
}

@media (max-width: 420px) {
  .grid-5 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .grid-5 > .field:nth-child(n+5) {
    grid-column: 1 / -1;
  }
}

@media (pointer: coarse), (max-width: 820px) {
  header {
    position: static;
  }
  input:not([type="checkbox"]):not([type="radio"]),
  textarea,
  select {
    font-size: 16px !important;
  }
  .pending-add-input {
    padding: 8px 0;
  }
  .compact-date-input {
    padding: 7px 9px;
  }
  .pending-line {
    min-height: 36px;
    align-items: center;
    padding: 6px 2px;
  }
  button.primary,
  .btn.primary,
  .primary,
  .btn-secondary,
  label.btn-secondary.file,
  .ledger-btn-primary,
  .ledger-btn-subtle,
  .modal-foot button:not(.ghost-action) {
    min-height: 38px;
    height: auto;
    padding: 8px 12px;
    white-space: nowrap;
  }
  .ledger-btn-icon {
    min-height: 38px;
    padding: 0;
  }
  .ghost-action,
  summary.ghost-action,
  label.ghost-action.file,
  .ghost.small,
  .shift-pill,
  .editor-tabs .mode-btn,
  .cf-option,
  .tpl-id-chip,
  .tpl-subitem-check,
  .ho-jump-btn,
  .inbox-candidate-chip,
  .toast-undo-btn,
  .tg-ctrl-btn,
  .whisper-bar button,
  .audio-preview-row button {
    min-height: 36px;
  }
  .cf-option,
  .tpl-id-chip,
  .tpl-subitem-check,
  .ho-jump-btn,
  .inbox-candidate-chip {
    align-items: center;
  }
  #prevPatientBtn,
  #nextPatientBtn,
  .pending-add-btn,
  #toggleApiKeyBtn,
  .tpl-order-btn,
  .close-btn {
    min-width: 36px;
    min-height: 36px;
  }
  .sm-btn,
  .editor-save-btn,
  #saveBtn {
    min-height: 32px;
  }
  .ghost-action.sm-btn {
    min-height: 36px;
  }
  .header-pills .theme-quick-btn {
    min-height: 36px;
    min-width: 36px;
    padding: 3px 8px;
  }
  .accent-dot {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
  }
  .accent-color-label {
    min-height: 44px;
  }
}

@media (max-width: 480px) {
  .ledger-footer {
    gap: 5px;
    max-width: 100%;
  }
  .ledger-footer .ledger-btn-primary,
  .ledger-footer .ledger-btn-subtle {
    min-width: 0;
    height: 36px;
    min-height: 36px;
    padding: 0 7px;
    font-size: 12px;
    gap: 4px;
  }
  .ledger-footer .ledger-btn-subtle .ui-ico {
    width: 14px;
    height: 14px;
  }
  .ledger-footer .ledger-btn-icon {
    width: 34px;
    height: 36px;
    min-height: 36px;
    padding: 0;
  }
}

@media (max-height: 540px) {
  header,
  .sticky-editor-bar,
  .nav-modes,
  #editorPatientNav {
    position: static;
  }
  .nav-modes .mode-btn {
    flex-direction: row;
    min-height: 44px;
    padding: 6px 8px;
    font-size: 12px;
  }
  main,
  body.mode-editor main {
    padding-bottom: 14px;
  }
  .toast {
    bottom: calc(14px + var(--kb-inset, 0px) + env(safe-area-inset-bottom));
  }
  .modal-overlay {
    align-items: center;
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  .modal-box,
  .calc-modal,
  .inbox-modal,
  .handover-modal {
    border-radius: 14px;
    border-bottom: 1px solid var(--border-ctrl);
    padding: 10px 12px;
    gap: 8px;
  }
  .modal-box textarea,
  #shiftPreviewText,
  #voiceTranscript,
  #inboxPasteInput,
  #inboxDryRunPreview {
    min-height: 90px;
  }
}

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

/* ==================== KARDEX v74: WESTERN / INTERNATIONAL CLINICAL EXPANSION ==================== */

.ledger-row.severity-unstable {
  border-left-color: var(--danger);
}

.ledger-safety-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 5px 6px;
  margin-top: 6px;
  font-family: var(--font-sans);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  line-height: 1;
}
.safety-tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: 6px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  color: var(--text-secondary);
  font-weight: 600;
}
.safety-tag.is-code {
  color: var(--text-primary);
  font-weight: 600;
}
.safety-tag.is-warn {
  background: var(--warn-bg);
  border-color: transparent;
  color: var(--warn-txt);
  font-weight: 600;
}
.safety-tag.is-crit,
.safety-tag.is-rose {
  background: var(--danger-bg);
  border-color: transparent;
  color: var(--danger-txt);
  font-weight: 600;
}
.safety-tag.is-iso {
  color: var(--text-secondary);
  font-weight: 600;
}

.ledger-inline-warn {
  color: var(--warn-txt);
}
.ledger-inline-crit {
  color: var(--danger-txt);
}

/* Profile Details: Clinical Safety, Lines & Antibiotics */
.profile-clinical-grid,
.profile-clinical-extras,
.profile-tracked-grid {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}
.profile-clinical-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}
.profile-field-span2 {
  grid-column: span 2;
}
.profile-clinical-extras,
.profile-tracked-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.tracked-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tracked-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.tracked-block-hdr {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--mut);
}
.tracked-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tracked-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}
.tracked-row.is-overdue {
  color: var(--warn-txt);
}
.tracked-row.is-crit {
  color: var(--danger-txt);
}
.tracked-row.is-editing {
  background: var(--surface-deep);
  box-shadow: inset 0 0 0 1px var(--border-ctrl);
}
.tracked-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}
.tracked-abx-add-row #cancelProfileAbxEditBtn {
  justify-self: start;
}
.tracked-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
}
.tracked-add-row .btn-secondary {
  height: 36px;
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}
.profile-tracked-grid .tracked-block:last-child .tracked-add-row,
.tracked-add-row.tracked-abx-add-row {
  grid-template-columns: minmax(0, 1.4fr) 92px minmax(0, 1fr) 96px 64px auto;
}

/* Quick Antibiotics Tracker Modal (Rounds Pop-up) */
.abx-modal {
  max-width: 600px;
}
.abx-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.abx-section-hdr {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 10px;
}
.abx-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--txt-2);
}
.abx-modal-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line-soft);
}
.abx-modal-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--line-soft);
}
.abx-modal-row.is-editing {
  background: var(--surface-deep);
  padding: 10px;
  margin: 0 -4px;
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px var(--border-ctrl);
}
.abx-modal-row.is-overdue .abx-modal-row-title {
  color: var(--warn-txt);
}
.abx-modal-row.is-crit .abx-modal-row-title {
  color: var(--danger-txt);
}
.abx-modal-row-main {
  min-width: 0;
}
.abx-modal-row-title {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--txt);
}
.abx-modal-row-meta {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--mut);
  margin-top: 2px;
  word-break: break-word;
}
.abx-modal-row-actions {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}
.abx-empty-note {
  padding: 10px 0;
  font-size: 12.5px;
  color: var(--mut);
  border-bottom: 1px solid var(--line-soft);
}
.abx-form-card {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-deep);
}
.abx-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.abx-field-span2 {
  grid-column: span 2;
}
.abx-live-preview {
  margin-top: 8px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--txt-2);
}
.abx-form-actions {
  margin-top: 10px;
  display: flex;
  justify-content: flex-end;
}
.abx-completed-details {
  margin-top: 12px;
  border-top: 1px solid var(--line-soft);
  padding-top: 8px;
}
.abx-completed-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--mut);
  cursor: pointer;
  list-style: none;
  padding: 4px 0;
}
.abx-completed-summary::-webkit-details-marker {
  display: none;
}
.abx-completed-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 6px;
}
.abx-completed-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  background: var(--surface-2);
  border-radius: 6px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 11.5px;
  color: var(--txt-2);
}

/* Settings: Clinical Options */
.clinical-option-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.clinical-option-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  text-align: left;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--txt);
  cursor: pointer;
}
.clinical-option-card[aria-checked="true"] {
  border-color: var(--txt);
  background: var(--surface-hover);
}
.clinical-option-title {
  font-size: 13px;
  font-weight: 700;
}
.clinical-option-desc {
  font-size: 11.5px;
  color: var(--mut);
  line-height: 1.35;
}

/* Lab Unit Toggle & Fishbone Diagrams */
.labs-unit-toggle {
  display: inline-flex;
  align-items: center;
  background: var(--surface-2);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}
.labs-unit-toggle .mode-btn {
  padding: 4px 8px;
  font-size: 11.5px;
  font-family: var(--font-mono);
  border: none;
  border-radius: 4px;
  color: var(--mut);
  background: transparent;
}
.labs-unit-toggle .mode-btn.active {
  background: var(--txt);
  color: var(--accent-on-solid);
  font-weight: 700;
}

.fishbone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}
.fishbone-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
}
.fishbone-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--txt-2);
  margin-bottom: 8px;
}
.fishbone-unit-tag {
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--mut);
  font-weight: 500;
}
.fb-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3px 5px;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  min-width: 0;
}
.fb-val {
  font-size: 13.5px;
  font-weight: 700;
  color: var(--txt);
  line-height: 1.15;
}
.fb-lbl {
  font-size: 9.5px;
  color: var(--mut);
  line-height: 1.1;
}
.fb-cell.flag-h .fb-val {
  color: var(--danger-txt);
}
.fb-cell.flag-l .fb-val {
  color: var(--warn-txt);
}
.fb-cell.is-empty .fb-val {
  color: var(--mut-2);
  font-weight: 400;
}

.fishbone-cbc {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 76px;
}
.fb-cbc-mid {
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--border-ctrl);
  border-right: 1px solid var(--border-ctrl);
  padding: 0 8px;
}
.fb-cbc-top {
  border-bottom: 1px solid var(--border-ctrl);
  padding-bottom: 4px;
}
.fb-cbc-bot {
  padding-top: 4px;
}

.fishbone-bmp {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) minmax(0, 0.9fr);
  align-items: center;
  min-height: 76px;
}
.fb-bmp-col {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border-ctrl);
}
.fb-bmp-col > .fb-cell:first-child {
  border-bottom: 1px solid var(--border-ctrl);
  padding-bottom: 4px;
}
.fb-bmp-col > .fb-cell:last-child {
  padding-top: 4px;
}
.fb-bmp-glu {
  padding-left: 4px;
}

/* Calc Modal: Physiology & Scores */
.phys-input-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.phys-results-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.phys-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--surface-2);
}
.phys-card.is-missing {
  opacity: 0.72;
}
.phys-card-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--mut);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.phys-card-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  font-weight: 700;
  color: var(--txt);
  margin: 4px 0 2px;
}
.phys-card-sub {
  font-size: 11.5px;
  color: var(--txt-2);
  line-height: 1.35;
}

.score-picker-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 8px;
}
.score-picker-bar > .field {
  flex: 1 1 auto;
}
.score-inputs-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.score-result-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: var(--surface-2);
}
.score-result-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.score-result-name {
  font-size: 14px;
  font-weight: 700;
}
.score-result-risk {
  font-size: 12px;
  color: var(--txt-2);
  margin-top: 2px;
}
.score-result-val {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  font-weight: 700;
}
.score-breakdown-list {
  margin: 8px 0 0;
  padding-left: 16px;
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--mut);
  line-height: 1.45;
}

/* Printable Scutsheet */
.print-scutsheet-root {
  display: none;
}

@media (max-width: 720px) {
  .profile-clinical-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .profile-clinical-extras,
  .profile-tracked-grid,
  .clinical-option-grid,
  .fishbone-grid,
  .phys-results-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
  }
  .phys-input-grid,
  .score-inputs-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tracked-add-row,
  .profile-tracked-grid .tracked-block:last-child .tracked-add-row,
  .tracked-add-row.tracked-abx-add-row {
    grid-template-columns: minmax(0, 1fr);
  }
  .tracked-add-row .btn-secondary {
    margin-top: 2px;
    width: 100%;
  }
  .abx-form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .abx-form-actions button {
    width: 100%;
  }
}

/* ==================== KARDEX v82: CHART EDITOR REFACTOR ==================== */

body.mode-editor header.app-header .header-brand-row,
body.mode-editor header.app-header .header-actions {
  display: none;
}

@media (min-width: 821px) {
  body.mode-editor header.app-header {
    grid-template-areas: 'nav nav';
    gap: 0;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: 0;
  }
}

@media (max-width: 820px) {
  body.mode-editor header.app-header {
    padding: 0;
    min-height: 0;
  }
}

.editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  min-height: 46px;
  margin-bottom: 10px;
}
.sticky-editor-bar {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 25;
  background: var(--bg);
  padding: 6px 0;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
}
.editor-topbar-left {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: nowrap;
}
.editor-topbar-right {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}
.editor-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  min-width: 34px;
  min-height: 34px;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--txt-2);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.14s ease, color 0.14s ease, opacity 0.14s ease;
}
.editor-icon-btn:hover:not(:disabled) {
  background: var(--surface-2);
  color: var(--txt);
  border-color: transparent;
}
.editor-icon-btn:disabled {
  background: transparent;
  color: var(--mut);
  opacity: 0.34;
}
.editor-icon-btn .ui-ico {
  width: 17px;
  height: 17px;
}
.editor-save-micro {
  font-size: 11px;
  margin-right: 4px;
}

.editor-patient-switcher {
  position: relative;
  flex: 0 1 auto;
  min-width: 0;
  max-width: 100%;
}
.editor-patient-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
  height: 34px;
  min-height: 34px;
  padding: 4px 8px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--txt);
  cursor: pointer;
  text-align: left;
  transition: background 0.14s ease;
}
.editor-patient-trigger:hover,
.editor-patient-trigger[aria-expanded="true"] {
  background: var(--surface-2);
  border-color: transparent;
}
.editor-patient-trigger .editor-note-title {
  display: inline-flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 7px;
  min-width: 0;
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
  line-height: 1.2;
}
.editor-patient-trigger .editor-note-title .ledger-bed {
  flex-shrink: 0;
  font-size: 11px;
  padding: 2px 7px;
}
.editor-patient-trigger .editor-title-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-switcher-chev {
  width: 14px;
  height: 14px;
  color: var(--mut);
  flex-shrink: 0;
  transition: transform 0.14s ease;
}
.editor-patient-trigger[aria-expanded="true"] .editor-switcher-chev {
  transform: rotate(180deg);
}

.editor-patient-dropdown {
  left: 0;
  right: auto;
  top: calc(100% + 6px);
  width: min(310px, calc(100vw - 24px));
  max-height: min(60vh, 360px);
  overflow-y: auto;
  z-index: 85;
}
.editor-pt-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: auto;
  padding: 8px 10px;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--txt);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  justify-content: flex-start;
  cursor: pointer;
}
.editor-pt-opt:hover {
  background: var(--surface-2);
  border-color: transparent;
}
.editor-pt-opt.is-active {
  background: var(--surface-2);
  font-weight: 600;
}
.editor-pt-opt .ledger-bed {
  flex-shrink: 0;
  font-size: 10.5px;
  padding: 2px 6px;
}
.editor-pt-opt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.editor-pt-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 999px;
  flex-shrink: 0;
  margin-left: auto;
}
.editor-pt-status-dot.is-ok {
  background: var(--success);
}
.editor-pt-status-dot.is-warn {
  background: var(--warn);
}
.editor-pt-status-dot.is-crit {
  background: var(--danger);
}
.editor-pt-empty {
  padding: 12px 10px;
  font-size: 12.5px;
  color: var(--mut);
  text-align: center;
}

.editor-more-popover {
  min-width: 210px;
  z-index: 85;
}
.popover-menu-sep {
  height: 1px;
  background: var(--line);
  margin: 4px 6px;
}
.editor-more-popover .popover-menu-item.danger-item,
.editor-more-popover .popover-menu-item.danger-item .ui-ico {
  color: var(--danger-txt);
}
.editor-more-popover .popover-menu-item.danger-item:hover {
  background: var(--danger-bg);
}

.editor-shell {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.editor-sidebar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}
.editor-meta-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  height: auto;
  min-height: 52px;
  padding: 10px 12px;
  border: none;
  border-radius: 10px;
  background: var(--surface-2);
  box-shadow: none;
  color: var(--mut);
  font-size: 12.5px;
  font-weight: 400;
  text-align: left;
  cursor: pointer;
  transition: color 0.14s ease, background 0.14s ease;
}
.editor-meta-line:hover {
  background: var(--surface-hover, var(--line));
  border: none;
  color: var(--txt-2);
}
.editor-meta-line:focus {
  outline: none;
}
.editor-meta-line:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--line);
}
.editor-meta-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.editor-meta-label {
  color: var(--txt);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.25;
}
.editor-meta-dx {
  font-size: 12.5px;
  font-weight: 500;
  color: var(--txt-2);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.editor-meta-dx[hidden] {
  display: none;
}
.editor-meta-text {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  font-weight: 400;
  color: var(--mut);
}
.editor-meta-cta {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  height: auto;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--mut);
}
.editor-meta-cta .ui-ico {
  width: 16px;
  height: 16px;
}
.editor-sidebar-cumfb {
  display: none;
}
.editor-main-col {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-x: clip;
}
@keyframes editorSwipeFromRight {
  from { opacity: 0.35; transform: translateX(22px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes editorSwipeFromLeft {
  from { opacity: 0.35; transform: translateX(-22px); }
  to { opacity: 1; transform: translateX(0); }
}
.swipe-in-from-right { animation: editorSwipeFromRight 160ms cubic-bezier(0.22, 1, 0.36, 1); }
.swipe-in-from-left { animation: editorSwipeFromLeft 160ms cubic-bezier(0.22, 1, 0.36, 1); }
.editor-view-bar {
  margin-bottom: 10px;
}

.timeline-date-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border-bottom: 1px solid var(--line);
  min-width: 0;
}
.timeline-date-chips-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.timeline-date-row .filter-chips {
  border-bottom: none;
}
.timeline-search-toggle-btn {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  min-width: 32px;
  min-height: 32px;
  padding: 0;
  border: none;
  border-radius: 7px;
  background: transparent;
  color: var(--mut);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.timeline-search-toggle-btn:hover,
.timeline-search-toggle-btn.is-active {
  background: var(--surface-2);
  color: var(--txt);
  border-color: transparent;
}
.timeline-search-toggle-btn .ui-ico {
  width: 15px;
  height: 15px;
}
.timeline-search-wrap[hidden] {
  display: none !important;
}
.timeline-search-wrap .rounds-search-box {
  position: relative;
}
.timeline-search-wrap .rounds-search-box input {
  padding-right: 34px;
}
.timeline-search-clear-btn {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 26px;
  height: 26px;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--mut);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.timeline-search-clear-btn:hover {
  background: var(--surface-hover);
  color: var(--txt);
}
.timeline-search-clear-btn .ui-ico {
  width: 14px;
  height: 14px;
}

.patient-info-modal {
  max-width: 680px;
}
.patient-info-modal .modal-body {
  overflow-x: hidden;
}
.patient-info-modal .grid {
  align-items: end;
}
.patient-info-modal .tracked-add-row input,
.patient-info-modal .tracked-add-row select {
  min-width: 0;
  max-width: 100%;
}
@media (min-width: 721px) {
  .patient-info-modal .profile-tracked-grid .tracked-block:last-child .tracked-add-row,
  .patient-info-modal .tracked-add-row.tracked-abx-add-row {
    grid-template-columns: minmax(0, 1.8fr) minmax(88px, 1fr) minmax(0, 1.1fr);
  }
}
.patient-info-tabs {
  display: flex;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.patient-info-tabs .mode-btn {
  padding: 8px 2px;
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  border-radius: 0;
}
.patient-info-tabs .mode-btn.active {
  border-bottom-color: var(--txt);
  color: var(--txt);
}

@media (min-width: 720px) {
  body.mode-editor header.app-header,
  body.mode-editor main {
    max-width: 1120px;
  }
  body.mode-editor .sticky-editor-bar {
    margin-left: 0;
    margin-right: 0;
    padding-left: 0;
    padding-right: 0;
  }
  .editor-shell {
    display: grid;
    grid-template-columns: minmax(220px, 1fr) minmax(0, 2fr);
    gap: 24px;
    align-items: start;
  }
  .editor-sidebar {
    position: sticky;
    top: calc(env(safe-area-inset-top) + 56px);
    padding-right: 18px;
    border-right: 1px solid var(--line);
    gap: 12px;
  }
  .editor-sidebar .editor-meta-line {
    padding: 10px 12px;
    background: var(--surface-2);
    border: none;
    border-radius: 10px;
    align-items: center;
  }
  .editor-sidebar .editor-meta-text {
    white-space: normal;
    line-height: 1.45;
  }
  .editor-sidebar .editor-primary-bar {
    grid-template-columns: minmax(0, 1fr);
    gap: 8px;
  }
  .editor-sidebar-cumfb {
    display: block;
  }
  .editor-sidebar-cumfb[hidden] {
    display: none !important;
  }
  .editor-sidebar-cumfb .timeline-cumfb-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .editor-main-col .timeline-cumfb-bar {
    display: none;
  }
}

/* ==================== KARDEX v83: GUIDED INLINE SHIFT EDITOR ==================== */

.tl-edit-mode-tabs {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--surface-2);
  border-radius: 7px;
  flex-shrink: 0;
}
.tl-mode-btn {
  height: auto;
  min-height: 26px;
  padding: 4px 10px;
  border: none;
  border-radius: 5px;
  background: transparent;
  color: var(--mut);
  font-size: 11.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.14s ease, color 0.14s ease;
}
.tl-mode-btn:hover {
  background: transparent;
  color: var(--txt);
}
.tl-mode-btn.active {
  background: var(--card);
  color: var(--txt);
  font-weight: 600;
}
.tl-guided-form[hidden],
.tl-raw-pane[hidden] {
  display: none !important;
}
.tl-guided-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 10px;
  min-width: 0;
}
.tl-edit-section {
  background: var(--surface);
  border-radius: 8px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.tl-edit-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}
.tl-edit-sec-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mut);
  margin: 0;
}
.tl-edit-sec-actions {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.tl-guided-form textarea {
  min-height: 54px;
  font-size: 13px;
  line-height: 1.45;
  padding: 8px 10px;
  margin-bottom: 0;
}
.tl-guided-form input,
.tl-guided-form select {
  font-size: 13px;
  padding: 7px 9px;
}
.tl-guided-form .field > label {
  margin: 2px 0 3px;
  font-size: 11.5px;
}
.tl-io-edit-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 74px minmax(0, 1fr);
  gap: 6px;
  margin-top: 2px;
}
.tl-g-fb-row {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  color: var(--txt);
  padding-top: 2px;
}
.tl-g-fb-row[hidden] {
  display: none !important;
}
.tl-edit-subgrid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.tl-edit-subgrid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.tl-pending-edit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tl-pending-edit-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.tl-pending-edit-chk {
  width: 17px;
  height: 17px;
  margin: 0;
  flex-shrink: 0;
  cursor: pointer;
}
.tl-pending-add-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.tl-pending-del-btn {
  min-width: 30px;
  min-height: 30px;
  padding: 4px;
}
.tl-edit-more {
  background: var(--surface);
  border-radius: 8px;
  padding: 9px 10px;
}
.tl-edit-more > summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  color: var(--mut);
  list-style: none;
  user-select: none;
}
.tl-edit-more > summary::-webkit-details-marker {
  display: none;
}
.tl-edit-more[open] > summary {
  color: var(--txt);
  margin-bottom: 8px;
}
.tl-edit-more-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

@media (max-width: 640px) {
  .tl-io-edit-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .tl-edit-subgrid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}

.field-span-full {
  grid-column: 1 / -1;
}
#assessmentInput {
  min-height: 76px;
  line-height: 1.45;
  resize: vertical;
}
.ledger-dx-line {
  line-height: 1.42;
}
.ledger-dx-line + .ledger-dx-line {
  margin-top: 2px;
}

.editor-subpane-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 6px;
}
.editor-subpane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.editor-subpane-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--mut);
}
.problem-order-btn {
  min-width: 30px;
  padding: 0 7px;
  font-weight: 600;
}
.problem-order-btn:disabled {
  opacity: 0.35;
  cursor: default;
}

.textarea-overlay-wrap {
  position: relative;
  width: 100%;
}
.textarea-overlay-wrap textarea {
  width: 100%;
  padding-top: 10px;
  padding-right: 78px;
}
.textarea-corner-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  height: 28px;
  min-height: 28px;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 500;
  border-radius: 6px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--txt);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  cursor: pointer;
}
.textarea-corner-btn:hover {
  background: var(--surface-hover);
  border-color: var(--border-ctrl);
}
.textarea-corner-btn .ui-ico {
  width: 13px;
  height: 13px;
}

.feature-toggle-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.feature-toggle-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--surface);
  border: 1px solid var(--line-soft);
  cursor: pointer;
}
.feature-toggle-row:hover {
  border-color: var(--line);
}
.feature-toggle-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  margin: 2px 0 0;
  cursor: pointer;
}
.feature-toggle-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.feature-toggle-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--txt);
}
.feature-toggle-desc {
  font-size: 12px;
  line-height: 1.4;
  color: var(--mut);
}

body.hide-dictation-ui .dictate-btn,
body.hide-dictation-ui #settingsTabVoice,
body.hide-dictation-ui #admitTabDictate {
  display: none !important;
}
body.hide-dictation-ui .editor-sec-pair {
  grid-template-columns: minmax(0, 1fr);
}
body.hide-samples-ui #loadSyntheticBtn,
body.hide-samples-ui #emptyLoadBtn,
body.hide-samples-ui #librarySampleBtn,
body.hide-samples-ui #libEmptySampleBtn,
body.hide-samples-ui #loadSampleScratchBtn,
body.hide-samples-ui #emptyLoadSampleScratchBtn,
body.hide-samples-ui #inboxSampleBtn,
body.hide-samples-ui #admitSamplePasteBtn {
  display: none !important;
}

@media print {
  .ledger-row,
  #noteList .item,
  .timeline-shift-card,
  .scratch-card {
    content-visibility: visible !important;
    contain: none !important;
  }
  .app-header,
  main,
  .modal-overlay,
  #swUpdateBanner,
  #toast {
    display: none !important;
  }
  body {
    background: #FFFFFF !important;
    color: #111111 !important;
    margin: 0 !important;
    padding: 0 !important;
  }
  #printScutsheetRoot {
    display: block !important;
    color: #111111;
    background: #FFFFFF;
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', sans-serif;
    font-size: 9.5pt;
    line-height: 1.25;
  }
  .ps-sheet-header {
    display: flex;
    justify-content: space-between;
    border-bottom: 1.5px solid #111111;
    padding-bottom: 4px;
    margin-bottom: 8px;
    font-size: 10pt;
  }
  .ps-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }
  .ps-card {
    border: 1px solid #111111;
    padding: 6px 8px;
    break-inside: avoid;
    page-break-inside: avoid;
  }
  .ps-card-head {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #CCCCCC;
    padding-bottom: 2px;
    margin-bottom: 3px;
  }
  .ps-bed,
  .ps-code,
  .ps-meta,
  .ps-row span {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  }
  .ps-meta,
  .ps-allergy {
    font-size: 8.5pt;
    color: #333333;
    margin-bottom: 2px;
  }
  .ps-dx,
  .ps-row,
  .ps-plans {
    font-size: 8.5pt;
    margin-top: 2px;
  }
  .ps-row span {
    display: inline-block;
    min-width: 44px;
    font-weight: 700;
  }
  .ps-tasks {
    margin-top: 4px;
    padding-top: 3px;
    border-top: 1px dashed #999999;
    font-size: 8.5pt;
  }
  .ps-task {
    margin-top: 1px;
  }
  .ps-box {
    font-family: ui-monospace, monospace;
  }
}

/* ==================== KARDEX PRO PAYWALL & CLINICAL DISCLAIMER ==================== */
.drawer-pro-row[hidden] {
  display: none;
}
.drawer-pro-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 11px;
  margin-top: 2px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-canvas);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
}
.drawer-pro-row:hover {
  background: var(--bg-subtle);
}
.drawer-pro-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.drawer-pro-title {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-primary);
}
.drawer-pro-sub {
  font-size: 11px;
  color: var(--text-secondary);
}
.pro-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 3px 7px;
  border-radius: 9999px;
  background: var(--accent-primary);
  color: var(--accent-primary-fg);
  flex-shrink: 0;
}
.pro-rounds-gate-card {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 14px;
  margin: 10px 0 6px;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-elevated);
}
.pro-rounds-gate-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.pro-rounds-gate-text strong {
  font-size: 13px;
  color: var(--text-primary);
}
.pro-rounds-gate-text span {
  font-size: 12px;
  color: var(--text-secondary);
}
.pro-modal-box {
  max-width: 440px;
}
.pro-eyebrow {
  display: block;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.pro-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-elevated);
}
.pro-price-amt {
  font-size: 24px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
  color: var(--text-primary);
}
.pro-benefits-list,
.disclaimer-list {
  margin: 8px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.disclaimer-list strong {
  color: var(--text-primary);
}
.disclaimer-ios-box[hidden] {
  display: none;
}
.disclaimer-ios-box {
  margin-top: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-default);
  background: var(--bg-surface-elevated);
  padding: 9px 12px;
}
.disclaimer-ios-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  list-style: none;
}
.disclaimer-ios-summary::-webkit-details-marker {
  display: none;
}
.disclaimer-ios-chev {
  font-size: 12px;
  color: var(--text-secondary);
  transition: transform 0.15s ease;
}
.disclaimer-ios-box[open] .disclaimer-ios-chev {
  transform: rotate(180deg);
}
.disclaimer-ios-steps {
  margin: 8px 0 2px;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--text-secondary);
}
.disclaimer-ios-steps strong {
  color: var(--text-primary);
}
.pro-modal-box .modal-foot {
  flex-wrap: wrap;
}

/* Cross-Device Cloud Sync */
.cloud-provider-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  padding: 4px;
  margin: 10px 0 12px;
  background: var(--bg-soft, var(--bg));
  border: 1px solid var(--border);
  border-radius: 10px;
}

.cloud-tab-btn {
  appearance: none;
  border: none;
  border-radius: 7px;
  padding: 8px 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  background: transparent;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  text-align: center;
  min-width: 0;
}

.cloud-tab-btn.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
}

.cloud-provider-panel,
.cloud-shared-fields {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cloud-field-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.cloud-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.cloud-field > span {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.cloud-field input {
  width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

.cloud-oauth-details {
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: var(--bg-soft, var(--bg));
}

.cloud-oauth-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.cloud-shared-fields {
  margin-top: 10px;
}

.cloud-check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
}

.cloud-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin: 0;
  flex-shrink: 0;
}

.cloud-hint,
.cloud-last-meta {
  margin-top: 8px;
  word-break: break-word;
}

#cloudIosGuide {
  margin-top: 12px;
}

/* Pro License Key Activation */
.pro-license-wrap,
.pro-license-box {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pro-license-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.pro-license-row input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.pro-license-row button {
  flex-shrink: 0;
}

/* Expanded Interactive App Tour Modal */
.tour-modal-box {
  max-width: 460px;
}

.tour-dots {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 12px;
}

.tour-dot {
  appearance: none;
  border: none;
  padding: 0;
  height: 6px;
  flex: 1 1 0;
  border-radius: 999px;
  background: var(--border);
  cursor: pointer;
  transition: background 0.18s ease, flex-grow 0.18s ease;
}

.tour-dot.active {
  background: var(--text-primary, #111214);
  flex-grow: 1.8;
}

.tour-dot.done {
  background: var(--text-secondary, #5a5f68);
}

.tour-preview-wrap {
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #ffffff;
  max-height: 225px;
  margin-bottom: 12px;
}

.tour-preview-wrap[hidden] {
  display: none;
}

.tour-preview-img {
  display: block;
  width: 100%;
  height: 225px;
  object-fit: cover;
  object-position: top center;
}

.tour-lead {
  margin: 0 0 8px;
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--text-primary);
}

.tour-bullets {
  gap: 6px;
  font-size: 13px;
}

.tour-action-wrap {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.tour-action-wrap[hidden] {
  display: none;
}

.tour-modal-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.tour-foot-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.field-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}
.field-label-row label {
  margin: 0;
}
.field-inline-btn {
  height: auto;
  min-height: 28px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  flex-shrink: 0;
}
.admit-history-val {
  white-space: pre-line;
}

.onboard-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 14px;
}

.onboard-section-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--mut);
}

.onboard-preview-card {
  background: var(--surface-2);
  color: var(--txt);
  border: none;
  border-radius: 8px;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  margin: 0;
}

.onboard-freq-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.onboard-freq-btn {
  width: 100%;
  justify-content: center;
}

.onboard-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

#onboardStartTime {
  flex: 1 1 130px;
  min-width: 128px;
}

.onboard-shifts-preview {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 10px 12px;
}

.onboard-shift-chip {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
  font-weight: 600;
  color: var(--txt);
}

.onboard-shift-sep {
  color: var(--mut);
  font-size: 12px;
}

.abx-renal-strip {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
  background: var(--surface-2);
  border-radius: 8px;
  padding: 7px 10px;
  margin-bottom: 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--txt-2);
}

.abx-renal-strip:empty {
  display: none;
}

.abx-renal-lbl {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mut);
}

.abx-renal-item {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--txt);
  font-weight: 600;
}

.abx-renal-item.is-renal-low {
  color: var(--danger);
}

.abx-renal-meta {
  font-size: 11.5px;
  color: var(--mut);
}

.custom-abx-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.custom-abx-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface-2);
  color: var(--txt);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 500;
}

.custom-abx-del-btn {
  border: none;
  background: transparent;
  color: var(--mut);
  padding: 0 2px;
  cursor: pointer;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.custom-abx-del-btn:hover {
  color: var(--danger);
}

.custom-abx-add-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.custom-abx-add-row input {
  flex: 1 1 auto;
  min-width: 0;
}


