/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-alt: #f1f5f9;
  --surface-hover: #f8fafc;
  --border: #e2e8f0;
  --border-strong: #cbd5e0;
  --border-focus: #3b82f6;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --primary: #1e3a8a;
  --primary-hover: #1e40af;
  --primary-light: #eff6ff;
  --danger: #dc2626;
  --danger-bg: #fef2f2;
  --warning: #d97706;
  --warning-bg: #fef3c7;
  --success: #059669;
  --success-bg: #d1fae5;
  --info: #2563eb;
  --info-bg: #dbeafe;
  --shadow-sm: 0 1px 2px rgba(15,23,42,0.05);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,0.07), 0 2px 4px -1px rgba(15,23,42,0.04);
  --shadow-lg: 0 10px 20px -3px rgba(15,23,42,0.08), 0 4px 8px -2px rgba(15,23,42,0.04);
  --shadow-xl: 0 20px 40px -4px rgba(15,23,42,0.10);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ============ LOGIN ============ */
.auth-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background:
    radial-gradient(circle at 20% 30%, rgba(30,58,138,0.05), transparent 40%),
    radial-gradient(circle at 80% 70%, rgba(37,99,235,0.05), transparent 40%),
    var(--bg);
}
.auth-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  border: 1px solid var(--border);
}
.auth-logo {
  display: block;
  height: 56px;
  margin: 0 auto 28px;
  object-fit: contain;
}
.auth-title {
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.auth-subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 32px;
  font-size: 14px;
}
.auth-form { display: flex; flex-direction: column; gap: 16px; }
.auth-label span {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}
.auth-label input {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.auth-label input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}
.auth-error {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  border: 1px solid #fecaca;
}
.auth-success {
  background: var(--success-bg);
  color: var(--success);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

/* ============ BUTTONS ============ */
.btn-primary {
  background: var(--primary);
  color: white;
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: inherit;
}
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}
.btn-secondary:hover { background: var(--surface-alt); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--surface-alt); border-color: var(--border-strong); }
.btn-icon.refreshing svg { animation: spin 0.8s linear infinite; }

/* ============ TOPBAR ============ */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 30;
  height: 56px;
}
.topbar-left { display: flex; align-items: center; gap: 20px; height: 100%; }
.topbar-logo { height: 32px; object-fit: contain; }
.topbar-right { display: flex; align-items: center; gap: 8px; }

/* View Switcher inside dropdown */
.dropdown-section {
  padding: 10px 14px 12px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
}
.dropdown-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 6px;
}
.view-switcher-dropdown {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 2px;
  border-radius: 7px;
  gap: 2px;
  width: 100%;
}
.view-switcher-dropdown .view-btn {
  flex: 1;
  background: transparent;
  border: none;
  padding: 6px 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 5px;
  transition: all 0.15s;
}
.view-switcher-dropdown .view-btn:hover { color: var(--text); }
.view-switcher-dropdown .view-btn.active {
  background: var(--primary);
  color: white;
}

/* Attribution — "by X · date" */
.attribution {
  font-size: 11px;
  color: var(--text-light);
  font-style: italic;
  margin-top: 4px;
}
.attribution strong { color: var(--text-muted); font-style: normal; font-weight: 600; }

/* ============ SECTION BAR (Parent Tabs) ============ */
.section-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.parent-tabs {
  display: inline-flex;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 4px;
  border-radius: 10px;
  gap: 2px;
}
.parent-tab {
  background: transparent;
  border: none;
  padding: 9px 18px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.18s;
  white-space: nowrap;
}
.parent-tab .ptab-icon { opacity: 0.7; }
.parent-tab:hover {
  color: var(--text);
  background: rgba(255,255,255,0.5);
}
.parent-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(15,23,42,0.10), 0 1px 2px rgba(15,23,42,0.05);
}
.parent-tab.active .ptab-icon { opacity: 1; }

/* ============ USER MENU ============ */
.user-menu { position: relative; }
.btn-user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 5px 10px 5px 5px;
  border-radius: 20px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--text);
}
.btn-user:hover { background: var(--surface-alt); }
.user-avatar {
  width: 26px;
  height: 26px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
}
.user-name { font-weight: 500; }

.dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  min-width: 220px;
  overflow: hidden;
  z-index: 40;
}
.dropdown-header {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-alt);
  font-size: 12px;
}
.dropdown-header strong { display: block; font-size: 13px; color: var(--text); margin-bottom: 2px; }
.dropdown-header span { color: var(--text-muted); }
.dropdown-item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  text-align: left;
  padding: 10px 14px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
}
.dropdown-item:hover { background: var(--surface-alt); }
.dropdown-danger { color: var(--danger); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ============ SUB TABS ============ */
.sub-tabs {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: thin;
  align-items: center;
}
.sub-tab {
  background: none;
  border: none;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-bottom: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  transition: all 0.15s;
  font-weight: 500;
}
.sub-tab:hover { color: var(--text); }
.sub-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  font-weight: 600;
}
.badge {
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  min-width: 22px;
  text-align: center;
}
.sub-tab.active .badge { background: var(--primary); color: white; }
.orders-stage-tabs { display: contents; }

/* ============ TOOLBAR ============ */
.toolbar {
  background: var(--surface);
  padding: 10px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  max-width: 400px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.search-box svg { color: var(--text-muted); flex-shrink: 0; }
.search-box input {
  border: none;
  outline: none;
  flex: 1;
  font-size: 13px;
  font-family: inherit;
  background: transparent;
  color: var(--text);
}
.search-box:focus-within { border-color: var(--border-focus); box-shadow: 0 0 0 3px rgba(59,130,246,0.12); }

.toolbar-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Filter group (date filter) */
.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
}
.date-filter-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.date-filter-wrap .filter-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.date-filter-wrap select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 6px 28px 6px 30px;
  font-size: 13px;
  font-family: inherit;
  color: var(--text);
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.5'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 10px center;
  font-weight: 500;
}
.date-filter-wrap select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.custom-range {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 4px 6px;
}
.custom-range input[type="date"] {
  border: none;
  padding: 2px 4px;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
  background: transparent;
  width: 120px;
  outline: none;
}
.custom-range input[type="date"]:focus { color: var(--primary); }
.range-sep {
  font-size: 11px;
  color: var(--text-muted);
}
#custom-clear {
  padding: 2px 6px;
  font-size: 14px;
  line-height: 1;
  color: var(--text-muted);
  border: none;
  background: transparent;
}
#custom-clear:hover { color: var(--danger); background: var(--surface-alt); }

/* Stale dot indicator */
.stale-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  margin-right: 8px;
  vertical-align: middle;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px rgba(220,38,38,0.15);
}
.result-count {
  color: var(--text-muted);
  font-size: 12px;
}
.sync-pill {
  background: var(--success-bg);
  color: var(--success);
  padding: 3px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}
.sync-pill.error { background: var(--danger-bg); color: var(--danger); }
.sync-pill.loading { background: var(--info-bg); color: var(--info); }

/* ============ TABLE ============ */
.table-wrapper {
  padding: 16px 24px 60px;
  position: relative;
  min-height: 300px;
}
.data-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.data-table thead {
  background: var(--surface-alt);
}
.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
}
.data-table th.sortable {
  cursor: pointer;
  user-select: none;
  transition: background 0.1s;
}
.data-table th.sortable:hover { background: var(--border); color: var(--text); }
.data-table th .sort-icon {
  display: inline-block;
  margin-left: 4px;
  opacity: 0.35;
  vertical-align: middle;
  transition: opacity 0.15s;
}
.data-table th.sortable:hover .sort-icon { opacity: 0.7; }
.data-table th.sort-active .sort-icon { opacity: 1; color: var(--primary); }
.data-table th.sort-active { color: var(--primary); }

/* Days until badge — plain-language format */
.days-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.days-badge.overdue {
  background: var(--danger-bg);
  color: var(--danger);
}
.days-badge.today {
  background: var(--warning-bg);
  color: var(--warning);
}
.days-badge.upcoming {
  background: var(--warning-bg);
  color: var(--warning);
}
.days-badge.future {
  background: var(--surface-alt);
  color: var(--text-muted);
}

/* Settings modal — tabbed */
.modal-wide { max-width: 620px; }
.settings-tabs {
  display: flex;
  gap: 2px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 3px;
  border-radius: 8px;
  margin-bottom: 16px;
}
.settings-tab {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  border-radius: 6px;
  transition: all 0.15s;
}
.settings-tab:hover { color: var(--text); }
.settings-tab.active {
  background: var(--surface);
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(15,23,42,0.10);
}
.settings-panel { min-height: 240px; }
.settings-panel > .settings-desc { margin-bottom: 14px; }
.settings-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
#password-form { display: flex; flex-direction: column; gap: 14px; }

.color-labels-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  max-height: 300px;
  overflow-y: auto;
  padding: 2px;
  margin-bottom: 14px;
}
.color-label-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  position: relative;
}
.color-label-row:hover { background: var(--surface-alt); }
.color-label-swatch {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid rgba(0,0,0,0.1);
  flex-shrink: 0;
}
.color-label-input {
  flex: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 8px;
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  min-width: 0;
}
.color-label-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.color-label-input::placeholder { color: var(--text-light); font-style: italic; }
.color-label-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 14px;
  line-height: 1;
  border-radius: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.color-label-row:hover .color-label-remove { opacity: 1; }
.color-label-remove:hover { color: var(--danger); background: var(--surface); }

.color-label-save {
  background: var(--primary);
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 4px;
  line-height: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
.color-label-save:hover { background: var(--primary-hover); }
.color-label-save.saving {
  background: var(--info);
  opacity: 0.7;
  pointer-events: none;
}
.color-label-save.saved {
  background: var(--success);
  pointer-events: none;
}
.color-label-badge {
  font-size: 9px;
  background: var(--primary-light);
  color: var(--primary);
  padding: 1px 5px;
  border-radius: 3px;
  font-weight: 700;
  flex-shrink: 0;
}

.add-custom-color {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-strong);
}
.add-custom-color input[type="color"] {
  width: 40px;
  height: 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 2px;
  background: var(--surface);
}
.add-custom-color input[type="text"] {
  flex: 1;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  font-size: 12px;
  font-family: inherit;
}
.add-custom-color input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.add-custom-color .btn-primary {
  padding: 7px 14px;
  font-size: 12px;
}

/* Audit Log */
.audit-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.audit-filters input[type="text"],
.audit-filters select {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.audit-filters input[type="text"] {
  flex: 1;
  min-width: 180px;
}
.audit-filters input[type="text"]:focus,
.audit-filters select:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.audit-load-more {
  padding: 12px;
  text-align: center;
  border-top: 1px solid var(--border);
}
.audit-load-more .btn-secondary {
  padding: 8px 16px;
  font-size: 12px;
}
.audit-log-controls {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 10px;
}
.audit-log-list {
  max-height: 380px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}
.audit-entry {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  font-size: 12px;
}
.audit-entry:last-child { border-bottom: none; }
.audit-entry:hover { background: var(--surface-hover); }
.audit-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: var(--primary-light);
  color: var(--primary);
}
.audit-icon.success { background: var(--success-bg); color: var(--success); }
.audit-icon.warn { background: var(--warning-bg); color: var(--warning); }
.audit-icon.danger { background: var(--danger-bg); color: var(--danger); }
.audit-body { flex: 1; min-width: 0; }
.audit-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 2px;
}
.audit-title { color: var(--text); font-weight: 500; word-break: break-word; }
.audit-title strong { color: var(--primary); font-weight: 600; }
.audit-time {
  color: var(--text-muted);
  font-size: 11px;
  white-space: nowrap;
  flex-shrink: 0;
}
.audit-detail {
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 2px;
  line-height: 1.4;
}
.audit-empty {
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
}

/* Weight History display */
.weight-history {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.weight-entry {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
}
.weight-entry:last-child { border-bottom: none; }
.weight-entry .w-date { color: var(--text-muted); }
.weight-entry .w-value { font-weight: 600; color: var(--text); }
.weight-entry .w-source {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.weight-entry .w-source.manual { background: var(--info-bg); color: var(--info); }
.log-weight-btn {
  margin-top: 8px;
  width: 100%;
  padding: 8px;
  border: 1px dashed var(--border-strong);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.log-weight-btn:hover { background: var(--surface-alt); color: var(--text); border-color: var(--text-muted); }
.log-weight-form {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.log-weight-form input {
  flex: 1;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
}
.log-weight-form input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.log-weight-form button {
  padding: 6px 14px;
  border: none;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
}
.log-weight-form button:hover { background: var(--primary-hover); }
.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--surface-hover); }
.data-table tbody tr:last-child td { border-bottom: none; }

/* Row coloring overrides default backgrounds */
.data-table tbody tr[data-color] td {
  background: var(--row-color) !important;
}

.cell-name { font-weight: 600; color: var(--text); cursor: pointer; }
.cell-name:hover { color: var(--primary); }
.cell-muted { color: var(--text-muted); font-size: 12px; }
.cell-mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; }

.days-overdue { color: var(--danger); font-weight: 700; }
.days-upcoming { color: var(--warning); font-weight: 600; }
.days-future { color: var(--text-muted); }

.status-pill {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  white-space: nowrap;
}
.status-paid { background: var(--success-bg); color: var(--success); }
.status-partial { background: var(--warning-bg); color: var(--warning); }
.status-overdue { background: var(--danger-bg); color: var(--danger); }
.status-sent { background: var(--info-bg); color: var(--info); }
.status-draft { background: var(--surface-alt); color: var(--text-muted); }
.status-neutral { background: var(--surface-alt); color: var(--text); }

.amount-due { color: var(--danger); font-weight: 700; }
.amount-paid { color: var(--success); }

.notes-cell { position: relative; min-width: 220px; }
.notes-input {
  width: 100%;
  padding: 6px 28px 6px 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-family: inherit;
  min-height: 32px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.notes-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.notes-input.dirty {
  border-color: #f59e0b;
  background: #fffbeb;
}
.notes-input.dirty:focus {
  box-shadow: 0 0 0 2px rgba(245,158,11,0.15);
}
.notes-input.saved {
  border-color: #10b981;
}

/* Save indicator inside notes cell */
.notes-status {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.notes-status.visible { opacity: 1; }
.notes-status .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #f59e0b;
}
.notes-status .mini-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.notes-status .check {
  color: #10b981;
}
.notes-status .err {
  color: var(--danger);
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.color-btn {
  width: 22px;
  height: 22px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  position: relative;
  font-size: 0;
}
.color-btn::after {
  content: '';
  position: absolute;
  inset: 3px;
  border-radius: 2px;
  background: var(--swatch-color, repeating-conic-gradient(#e5e7eb 0% 25%, white 0% 50%) 50% / 6px 6px);
}
.color-btn:hover { border-color: var(--text); }

.checkbox-wrap {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
}
.checkbox-wrap input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--primary);
}

/* ============ COLOR POPOVER (Google Sheets-style) ============ */
.color-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 10px;
  z-index: 50;
  width: 260px;
}
.color-popover-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.color-popover-close {
  background: none;
  border: none;
  font-size: 18px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  padding: 0 4px;
  border-radius: 3px;
}
.color-popover-close:hover { color: var(--danger); background: var(--surface-alt); }
.color-none {
  width: 24px;
  height: 22px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  cursor: pointer;
  background: white;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}
.color-none:hover { border-color: var(--text); }
.color-grid {
  display: grid;
  grid-template-columns: repeat(10, 22px);
  gap: 3px;
}
.color-swatch {
  width: 22px;
  height: 22px;
  border-radius: 3px;
  border: 1px solid rgba(0,0,0,0.1);
  cursor: pointer;
  padding: 0;
  position: relative;
  transition: transform 0.1s;
}
.color-swatch:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  z-index: 2;
}
.color-swatch.selected {
  border: 2px solid var(--primary);
  outline: 1px solid white;
  outline-offset: -2px;
}
.color-hint {
  margin-top: 8px;
  padding: 6px 8px;
  background: var(--surface-alt);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text);
  min-height: 26px;
  line-height: 1.3;
}
.color-hint:empty { display: none; }

/* ============ SUGGESTIONS POPOVER ============ */
.suggestions-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 50;
  max-width: 320px;
  max-height: 200px;
  overflow-y: auto;
}
.suggestion-item {
  padding: 8px 12px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover, .suggestion-item.active { background: var(--primary-light); }

/* ============ EMPTY / LOADING ============ */
.empty-state, .loading-state {
  padding: 60px 20px;
  text-align: center;
  color: var(--text-muted);
}
.empty-state svg { display: block; margin: 0 auto 12px; opacity: 0.4; }
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ SLIDE-OVER PANEL (Patient Detail) ============ */
.slideover-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 90;
  backdrop-filter: blur(2px);
  animation: fadeIn 0.18s ease-out;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.slideover {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 480px;
  max-width: 100vw;
  background: var(--surface);
  z-index: 100;
  box-shadow: -8px 0 24px rgba(15,23,42,0.10);
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.22s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.slideover-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}
.slideover-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}
.slideover-contact {
  font-size: 13px;
  color: var(--text-muted);
}
.slideover-contact a {
  color: var(--text-muted);
  text-decoration: none;
}
.slideover-contact a:hover { color: var(--primary); text-decoration: underline; }
.slideover-close {
  background: none;
  border: none;
  font-size: 26px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.slideover-close:hover { background: var(--surface-alt); color: var(--text); }

.slideover-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px 40px;
}

.detail-pill-row {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.detail-section {
  margin-top: 16px;
}
.detail-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.detail-section-title .count {
  background: var(--surface-alt);
  color: var(--text-muted);
  padding: 2px 7px;
  border-radius: 8px;
  font-size: 10px;
  margin-left: 6px;
}
.detail-section-title .edit-link {
  text-transform: none;
  letter-spacing: 0;
  font-size: 12px;
  color: var(--primary);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
}
.detail-section-title .edit-link:hover { text-decoration: underline; }

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  column-gap: 22px;
  row-gap: 0;
  border-top: 1px solid var(--border);
}
.detail-field {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 2px;
  padding: 7px 0 8px;
  border-bottom: 1px solid var(--border);
  min-width: 0;
}
.detail-field-label {
  font-size: 10px;
  color: var(--text-light);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.detail-field-value {
  font-size: 13.5px;
  color: var(--text);
  font-weight: 600;
  line-height: 1.35;
  word-break: break-word;
}
.detail-field-value.muted { color: var(--text-muted); font-weight: 400; }

/* Tags row */
.tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
}
.tag-chip {
  background: var(--primary-light);
  color: var(--primary);
  padding: 3px 9px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
}

/* Order history list */
.order-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.order-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr auto auto;
  gap: 10px;
  padding: 10px 12px;
  font-size: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border);
}
.order-row:last-child { border-bottom: none; }
.order-row:hover { background: var(--surface-hover); }
.order-row .order-date { color: var(--text-muted); white-space: nowrap; }
.order-row .order-program { color: var(--text); font-weight: 500; }
.order-row .order-amount { font-weight: 600; color: var(--text); }

/* Tracking link */
.tracking-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--primary);
  text-decoration: none;
}
.tracking-link:hover { text-decoration: underline; }

/* GHL Note Add Form */
.ghl-note-form {
  background: var(--surface-alt);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-top: 8px;
  margin-bottom: 12px;
}
.ghl-note-warn {
  font-size: 11px;
  color: var(--warning);
  background: var(--warning-bg);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  border-left: 3px solid var(--warning);
}
.ghl-note-form textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  resize: vertical;
  min-height: 60px;
}
.ghl-note-form textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.ghl-note-form-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  margin-top: 8px;
}
.ghl-note-form-actions button {
  padding: 6px 14px;
  font-size: 12px;
}

/* GHL notes list */
.ghl-notes {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
  padding-right: 4px;
}
.ghl-note {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  border-left: 3px solid var(--primary);
}
.ghl-note-date {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
  font-weight: 600;
}
.ghl-note-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
}
.ghl-notes-empty {
  font-size: 12px;
  color: var(--text-muted);
  padding: 16px;
  text-align: center;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
}
.detail-loading {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 8px 0;
}
.detail-loading .mini-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid var(--border);
  border-top-color: var(--info);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.detail-notes-box {
  position: relative;
}
.detail-notes-box textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-family: inherit;
  min-height: 90px;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.detail-notes-box textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.detail-notes-box textarea.dirty {
  border-color: #f59e0b;
  background: #fffbeb;
}
.detail-notes-box textarea.saved {
  border-color: #10b981;
}
.detail-notes-status {
  position: absolute;
  bottom: 10px;
  right: 12px;
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255,255,255,0.85);
  padding: 2px 6px;
  border-radius: 4px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
.detail-notes-status.visible { opacity: 1; }
.detail-notes-status.unsaved { color: #d97706; }
.detail-notes-status.saving { color: var(--info); }
.detail-notes-status.saved { color: #10b981; }
.detail-notes-status.error { color: var(--danger); }

/* ============ MODAL ============ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
  backdrop-filter: blur(4px);
}
.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 28px;
  width: 100%;
  max-width: 440px;
  box-shadow: var(--shadow-xl);
  position: relative;
}
.modal-content h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  padding-right: 30px;
}
.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
}
.modal-close:hover { background: var(--surface-alt); }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}
#password-form { display: flex; flex-direction: column; gap: 14px; }

.info-content {
  font-size: 13px;
  color: var(--text);
  line-height: 1.7;
}
.info-content .info-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.info-content .info-row:last-child { border-bottom: none; }
.info-content .info-label { color: var(--text-muted); font-weight: 500; }
.info-content .info-value { color: var(--text); font-weight: 600; }

/* ============ TOAST ============ */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 200;
}
.toast {
  background: var(--text);
  color: white;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  font-size: 13px;
  box-shadow: var(--shadow-lg);
  animation: slideIn 0.2s ease-out;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes slideIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ============ RESPONSIVE ============ */
@media (max-width: 900px) {
  .topbar { padding: 0 14px; }
  .topbar-left { gap: 12px; }
  .section-bar { padding: 10px 14px; }
  .parent-tab { padding: 8px 14px; font-size: 13px; }
  .parent-tab .ptab-icon { display: none; }
  .sub-tabs, .toolbar, .table-wrapper { padding-left: 14px; padding-right: 14px; }
  .user-name { display: none; }
  .refresh-text { display: none; }
  .view-btn { padding: 5px 8px; font-size: 11px; }
  .data-table { font-size: 12px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .slideover { width: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .toolbar { flex-wrap: wrap; }
  .custom-range input[type="date"] { width: 110px; }
  .color-labels-grid { grid-template-columns: 1fr; }
}

/* ============ PRIORITIES / KANBAN ============ */
.priorities-view {
  padding: 16px 24px 60px;
  min-height: 400px;
}

.priorities-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.priorities-filters {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex: 1;
}
.priorities-filters select,
.priorities-filters input[type="text"] {
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
.priorities-filters input[type="text"] {
  min-width: 180px;
}
.priorities-filters select:focus,
.priorities-filters input[type="text"]:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  font-size: 12px;
  font-family: inherit;
  color: var(--text);
}
.filter-toggle.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.priorities-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.priorities-actions .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
}

/* Kanban board */
.kanban-board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  min-height: 300px;
}

.kanban-column {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 12px;
  min-height: 200px;
  transition: background 0.15s;
}
.kanban-column.drag-over {
  background: var(--primary-light);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}
.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 4px;
}
.kanban-column-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.kanban-column.urgent .kanban-column-title { color: var(--danger); }
.kanban-column.high .kanban-column-title { color: var(--warning); }
.kanban-column.medium .kanban-column-title { color: var(--info); }
.kanban-column.admin .kanban-column-title { color: var(--text-muted); }
.kanban-column-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 10px;
}
.kanban-tasks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

.task-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  box-shadow: var(--shadow-sm);
}
.task-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.task-card.dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}
.task-card.done {
  opacity: 0.6;
  background: var(--surface-alt);
}
.task-card.done .task-card-title {
  text-decoration: line-through;
  color: var(--text-muted);
}

.task-card-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.4;
  margin-bottom: 6px;
  word-break: break-word;
}
.task-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.task-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}
.task-card-badges {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.task-card-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.task-card-badge.status-in_progress { background: var(--info-bg); color: var(--info); }
.task-card-badge.status-blocked { background: var(--warning-bg); color: var(--warning); }
.task-card-badge.status-done { background: var(--success-bg); color: var(--success); }
.task-card-badge.patient {
  background: var(--primary-light);
  color: var(--primary);
  cursor: pointer;
}
.task-card-badge.due-overdue { background: var(--danger-bg); color: var(--danger); }
.task-card-badge.due-today { background: var(--warning-bg); color: var(--warning); font-weight: 700; }
.task-card-badge.comments {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.task-card-assignee {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.task-card-assignee.unassigned {
  background: var(--surface-alt);
  color: var(--text-muted);
  border: 1px dashed var(--border-strong);
}

.kanban-empty {
  padding: 20px 10px;
  text-align: center;
  color: var(--text-light);
  font-size: 11px;
  font-style: italic;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
}

/* List view for tasks */
.tasks-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.tasks-list-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto auto;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
}
.tasks-list-row:hover { background: var(--surface-hover); }
.tasks-list-row:last-child { border-bottom: none; }
.tasks-list-row.done { opacity: 0.5; }
.tasks-list-row.done .tasks-list-title { text-decoration: line-through; }
.tasks-list-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.tasks-list-priority-dot.urgent { background: var(--danger); }
.tasks-list-priority-dot.high { background: var(--warning); }
.tasks-list-priority-dot.medium { background: var(--info); }
.tasks-list-priority-dot.admin { background: var(--text-muted); }
.tasks-list-title {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}

/* Task Modal */
.task-modal-content {
  max-width: 640px;
  padding: 0;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.task-modal-header {
  padding: 24px 28px 12px;
  border-bottom: 1px solid var(--border);
}
.task-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  padding: 6px 4px;
  background: transparent;
  font-family: inherit;
}
.task-title-input:focus {
  background: var(--surface-alt);
  border-radius: 4px;
}
.task-title-input::placeholder { color: var(--text-light); }
.task-modal-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding-left: 4px;
}
.task-modal-body {
  padding: 20px 28px;
  overflow-y: auto;
  flex: 1;
}
.task-fields-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}
.task-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 14px;
}
.task-field label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.task-field select,
.task-field input,
.task-field textarea {
  padding: 9px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  width: 100%;
  box-sizing: border-box;
}
.task-field select:focus,
.task-field input:focus,
.task-field textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.task-field textarea { resize: vertical; min-height: 80px; padding: 10px 12px; }
.task-related-patient {
  padding: 8px 12px;
  background: var(--primary-light);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: inline-block;
}

.task-section-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: block;
  margin: 20px 0 10px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.task-comments-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
  max-height: 240px;
  overflow-y: auto;
}
.task-comment {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.task-comment-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}
.task-comment-author {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
}
.task-comment-time {
  font-size: 10px;
  color: var(--text-muted);
}
.task-comment-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.task-comment-add {
  display: flex;
  gap: 6px;
  align-items: flex-start;
}
.task-comment-add textarea {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  resize: vertical;
  min-height: 60px;
  outline: none;
}
.task-comment-add textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.task-comment-add button { padding: 8px 14px; font-size: 12px; align-self: flex-end; }

.task-modal-footer {
  padding: 14px 28px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.task-save-status {
  flex: 1;
  font-size: 11px;
  color: var(--text-muted);
}
.task-save-status.saving { color: var(--info); }
.task-save-status.saved { color: var(--success); }
.task-save-status.error { color: var(--danger); }

/* Responsive Kanban */
@media (max-width: 1100px) {
  .kanban-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 700px) {
  .kanban-board { grid-template-columns: 1fr; }
  .task-fields-grid { grid-template-columns: 1fr; }
  .priorities-view { padding: 12px 14px 60px; }
  .tasks-list-row {
    grid-template-columns: 16px 1fr auto auto;
    font-size: 12px;
  }
  .tasks-list-row .tasks-list-hide-mobile { display: none; }
}

/* ============ TASK MODAL TITLE ROW + DONE TOGGLE ============ */
.task-modal-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.task-modal-title-row .task-title-input { flex: 1; }
.task-done-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  user-select: none;
  transition: all 0.15s;
  flex-shrink: 0;
}
.task-done-toggle:hover { border-color: var(--primary); }
.task-done-toggle input[type="checkbox"] {
  width: 14px;
  height: 14px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--success);
}
.task-done-toggle:has(input:checked) {
  background: var(--success-bg);
  border-color: var(--success);
  color: var(--success);
}

/* ============ RICH TEXT EDITOR ============ */
.rich-editor-wrap {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  overflow: hidden;
  transition: border-color 0.15s;
}
.rich-editor-wrap:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.rich-editor-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 6px 8px;
  background: var(--surface-alt);
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.rich-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 6px;
  border: none;
  background: transparent;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 13px;
  transition: all 0.1s;
}
.rich-btn:hover { background: var(--surface); color: var(--text); }
.rich-btn:active { transform: scale(0.95); }
.rich-btn input[type="file"] { display: none; }
.rich-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 4px;
}
.rich-editor {
  min-height: 120px;
  max-height: 400px;
  overflow-y: auto;
  padding: 10px 12px;
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
  outline: none;
  font-family: inherit;
}
.rich-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-light);
  pointer-events: none;
}
.rich-editor h3, .rich-editor h4 {
  margin: 8px 0 4px;
  font-weight: 700;
  color: var(--text);
}
.rich-editor h3 { font-size: 15px; }
.rich-editor h4 { font-size: 14px; }
.rich-editor p { margin: 0 0 6px; }
.rich-editor ul, .rich-editor ol { margin: 4px 0 6px; padding-left: 22px; }
.rich-editor li { margin: 2px 0; }
.rich-editor a { color: var(--primary); text-decoration: underline; }
.rich-editor img { max-width: 100%; height: auto; border-radius: 6px; margin: 4px 0; display: block; }
.rich-editor b, .rich-editor strong { font-weight: 700; }

/* Task card - top row with title + done checkbox */
.task-card-top {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 6px;
}
.task-card-top .task-card-title { flex: 1; margin-bottom: 0; }
.task-card-check {
  width: 16px;
  height: 16px;
  margin: 2px 0 0;
  cursor: pointer;
  flex-shrink: 0;
  accent-color: var(--success);
}

/* Description in card - keep it clean */
.task-card-desc {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============ TOPBAR CENTER: GLOBAL SEARCH ============ */
.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 16px;
  align-items: center;
}
.topbar-center {
  display: flex;
  justify-content: center;
  max-width: 500px;
  width: 100%;
  margin: 0 auto;
}
.global-search {
  position: relative;
  width: 100%;
  max-width: 420px;
}
.global-search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
#global-search-input {
  width: 100%;
  padding: 8px 12px 8px 32px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
#global-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}
.global-search-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  margin-top: 4px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
}
.gs-result {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background 0.1s;
}
.gs-result:last-child { border-bottom: none; }
.gs-result:hover, .gs-result.active { background: var(--surface-alt); }
.gs-result-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.gs-result-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  flex-wrap: wrap;
}
.gs-result-detail { color: var(--text-muted); }
.gs-status-pill {
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
.gs-status-pill.gs-success { background: var(--success-bg); color: var(--success); }
.gs-status-pill.gs-danger { background: var(--danger-bg); color: var(--danger); }
.gs-status-pill.gs-neutral { background: var(--surface-alt); color: var(--text-muted); }
.gs-status-pill.gs-muted { background: var(--surface-alt); color: var(--text-muted); }
.gs-loading, .gs-empty {
  padding: 12px 14px;
  color: var(--text-muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 900px) {
  .topbar { grid-template-columns: auto auto; }
  .topbar-center { display: none; }
}

/* ============ DOCS MANAGER ============ */
.docs-view {
  padding: 16px 24px 60px;
  min-height: 400px;
}
.page-header {
  margin-bottom: 20px;
}
.page-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 4px;
}
.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0;
}
.docs-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.docs-breadcrumbs {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}
.breadcrumb-link {
  background: none;
  border: none;
  color: var(--primary);
  cursor: pointer;
  font-size: 13px;
  padding: 2px 4px;
  border-radius: 3px;
  font-family: inherit;
}
.breadcrumb-link:hover { text-decoration: underline; }
.breadcrumb-sep { color: var(--text-light); }
.breadcrumb-current { color: var(--text); font-weight: 600; }

.docs-actions {
  display: flex;
  gap: 8px;
}
.docs-actions button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
}

.folder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.folder-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
}
.folder-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.folder-card-icon {
  flex-shrink: 0;
  color: var(--warning);
}
.folder-card-body { flex: 1; min-width: 0; }
.folder-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 4px;
}
.folder-card-meta { font-size: 11px; }
.visibility-pill {
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
.visibility-pill.shared { background: var(--info-bg); color: var(--info); }
.visibility-pill.private { background: var(--surface-alt); color: var(--text-muted); }

.folder-menu-btn, .link-menu-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 5px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.folder-menu-btn:hover, .link-menu-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.link-menu-btn.danger:hover { color: var(--danger); }

/* Doc links list */
.doc-links-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.doc-link-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.doc-link-row:last-child { border-bottom: none; }
.doc-link-row:hover { background: var(--surface-alt); }
.doc-link-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.doc-link-body { flex: 1; min-width: 0; }
.doc-link-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.doc-link-url {
  font-size: 11px;
  color: var(--text-muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.doc-link-actions {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

/* Radio buttons in folder modal */
.folder-visibility-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.radio-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.radio-option:hover { background: var(--surface-alt); }
.radio-option input[type="radio"] { margin: 0; accent-color: var(--primary); }
.radio-option:has(input:checked) { border-color: var(--primary); background: var(--primary-light); color: var(--primary); font-weight: 600; }

@media (max-width: 700px) {
  .folder-grid { grid-template-columns: 1fr; }
  .docs-toolbar { flex-direction: column; align-items: stretch; }
  .docs-actions { justify-content: stretch; }
  .docs-actions button { flex: 1; justify-content: center; }
  .docs-view, .priorities-view { padding: 12px 14px 60px; }
}

/* ============ ORDER QUEUE ============ */
.orderqueue-view {
  padding: 16px 24px 60px;
  min-height: 400px;
}
.oq-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.oq-search {
  position: relative;
  flex: 1;
  min-width: 240px;
  max-width: 380px;
}
.oq-search svg {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
}
#oq-search-input {
  width: 100%;
  padding: 7px 10px 7px 30px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
#oq-search-input:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
.oq-error {
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  color: var(--warning);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}
.oq-error small { display: block; margin-top: 4px; color: var(--text-muted); }

/* OQ Board (5 columns) */
.oq-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  min-height: 300px;
}
.oq-column {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 10px;
  min-height: 200px;
  transition: background 0.15s;
}
.oq-column.drag-over {
  background: var(--primary-light);
  outline: 2px dashed var(--primary);
  outline-offset: -4px;
}
.oq-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 4px;
}
.oq-column-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.oq-column.queue .oq-column-title { color: var(--info); }
.oq-column.dispensing .oq-column-title { color: var(--warning); }
.oq-column.shipped .oq-column-title { color: #8B5CF6; }
.oq-column.delivered .oq-column-title { color: var(--success); }
.oq-column.renewal .oq-column-title { color: var(--text-muted); }
.oq-column-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 10px;
}
.oq-cards {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 40px;
}

.oq-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.oq-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.oq-card.dragging {
  opacity: 0.5;
  transform: rotate(1deg);
}
.oq-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}
.oq-card-rx {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.oq-card-mute { color: var(--text-light); }
.oq-card-tracking {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  color: var(--primary);
  text-decoration: none;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  margin-bottom: 5px;
}
.oq-card-tracking:hover { text-decoration: underline; }
.oq-card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.oq-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
}
.oq-badge.value {
  background: var(--success-bg);
  color: var(--success);
}
.oq-badge.notes-badge {
  background: var(--warning-bg);
}

/* OQ Modal */
.oq-modal-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.oq-modal-meta a { color: var(--primary); }
.oq-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 14px;
  padding: 10px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.oq-info-field {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.oq-info-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.oq-info-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
}
.oq-info-value a { color: var(--primary); }
.oq-notes-meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 4px;
  font-style: italic;
}

/* Responsive OQ */
@media (max-width: 1200px) {
  .oq-board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .oq-board { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 550px) {
  .oq-board { grid-template-columns: 1fr; }
  .orderqueue-view { padding: 12px 14px 60px; }
  .oq-info-grid { grid-template-columns: 1fr; }
}

/* ============ PRIVATE ROOM ============ */
.private-view {
  padding: 16px 24px 60px;
  min-height: 400px;
}

.dropdown-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  border-radius: 9px;
  margin-left: auto;
}

.private-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
  overflow-x: auto;
}
.private-tab {
  background: transparent;
  border: none;
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.private-tab:hover { color: var(--text); }
.private-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.private-pane { min-height: 300px; }

/* Tasks Toolbar */
.private-tasks-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
#priv-task-search {
  flex: 1;
  min-width: 200px;
  padding: 7px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface);
  color: var(--text);
  font-family: inherit;
}
#priv-task-search:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(59,130,246,0.12);
}
#priv-show-done-wrap { cursor: pointer; }
#priv-show-done-wrap input { cursor: pointer; }
.private-tasks-toolbar .btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 14px;
  font-size: 13px;
}

/* Tasks List */
.priv-tasks-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.priv-task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.priv-task-row:hover { background: var(--surface-alt); }
.priv-task-row:last-child { border-bottom: none; }
.priv-task-row.done { opacity: 0.55; }
.priv-task-row.done .priv-task-title { text-decoration: line-through; color: var(--text-muted); }
.priv-task-row.unseen {
  background: linear-gradient(90deg, rgba(59,130,246,0.06) 0%, transparent 60%);
  border-left: 3px solid var(--primary);
  padding-left: 13px;
}

.priv-task-info { flex: 1; min-width: 0; }
.priv-task-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.priv-task-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  flex-wrap: wrap;
}
.priv-task-badge {
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
  background: var(--surface-alt);
  color: var(--text-muted);
}
.priv-task-badge.updates { background: var(--info-bg); color: var(--info); }
.priv-task-badge.working { background: var(--warning-bg); color: var(--warning); }
.priv-task-badge.unseen-badge { background: var(--danger); color: white; }
.priv-task-assignee-mini {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  font-size: 10px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Daily Log */
.priv-daily-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.priv-daily-entry {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}
.priv-daily-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 12px;
  flex-wrap: wrap;
}
.priv-daily-author {
  font-weight: 700;
  color: var(--primary);
}
.priv-daily-task {
  color: var(--text-muted);
  cursor: pointer;
}
.priv-daily-task:hover { color: var(--text); text-decoration: underline; }
.priv-daily-date {
  color: var(--text-light);
  margin-left: auto;
  font-size: 11px;
}
.priv-daily-status {
  padding: 1px 8px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
.priv-daily-status.working { background: var(--warning-bg); color: var(--warning); }
.priv-daily-status.done { background: var(--success-bg); color: var(--success); }
.priv-daily-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.priv-daily-body img { max-width: 100%; height: auto; border-radius: 4px; margin: 6px 0; display: block; }
.priv-daily-body p { margin: 0 0 6px; }
.priv-daily-body ul, .priv-daily-body ol { margin: 4px 0 6px; padding-left: 22px; }

/* Modal */
.priv-modal-header {
  padding: 22px 26px 12px;
  border-bottom: 1px solid var(--border);
}
.priv-task-title-input {
  width: 100%;
  border: none;
  outline: none;
  font-size: 19px;
  font-weight: 700;
  color: var(--text);
  padding: 4px;
  background: transparent;
  font-family: inherit;
  box-sizing: border-box;
}
.priv-task-title-input:focus {
  background: var(--surface-alt);
  border-radius: 4px;
}
.priv-task-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}
.priv-modal-body {
  padding: 18px 26px;
  overflow-y: auto;
  flex: 1;
}
.priv-modal-footer {
  padding: 12px 26px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

/* Updates section */
.priv-updates-section {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.priv-updates-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 10px;
}
.priv-updates-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
  max-height: 340px;
  overflow-y: auto;
}
.priv-update {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.priv-update-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 11px;
}
.priv-update-author {
  font-weight: 700;
  color: var(--primary);
  font-size: 12px;
}
.priv-update-date {
  color: var(--text-muted);
}
.priv-update-status-pill {
  padding: 1px 7px;
  border-radius: 8px;
  font-size: 10px;
  font-weight: 600;
}
.priv-update-status-pill.working { background: var(--warning-bg); color: var(--warning); }
.priv-update-status-pill.done { background: var(--success-bg); color: var(--success); }
.priv-update-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.priv-update-body img { max-width: 100%; height: auto; border-radius: 4px; margin: 4px 0; display: block; }
.priv-update-body p { margin: 0 0 6px; }
.priv-update-body ul, .priv-update-body ol { margin: 4px 0 6px; padding-left: 22px; }

.priv-add-update {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 12px;
}
.priv-add-update-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}
.priv-update-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.priv-update-date-info {
  flex: 1;
  font-size: 11px;
  color: var(--text-muted);
  min-width: 100px;
}
.priv-update-actions button {
  padding: 7px 14px;
  font-size: 12px;
}

/* Calendar (Ira's activity tracking) */
.priv-calendar-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.priv-cal-nav {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
}
.priv-cal-nav:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.priv-calendar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  min-width: 180px;
  text-align: center;
}
.priv-calendar-stats {
  margin-left: auto;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--surface-alt);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
}
.priv-calendar-stats strong { color: var(--text); }

.priv-calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px;
}
.priv-cal-day-name {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  text-align: center;
  padding: 6px 0;
}
.priv-cal-day {
  aspect-ratio: 1;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background: var(--surface);
  position: relative;
  overflow: hidden;
  min-height: 60px;
}
.priv-cal-day:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.priv-cal-day.empty {
  visibility: hidden;
  cursor: default;
}
.priv-cal-day.today {
  border-color: var(--primary);
  border-width: 2px;
}
.priv-cal-day.level-0 { background: var(--surface); }
.priv-cal-day.level-1 { background: #E6F4E6; }
.priv-cal-day.level-2 { background: #B7E4B7; }
.priv-cal-day.level-3 { background: #6FBF6F; }
.priv-cal-day.level-4 { background: #2E8B2E; color: white; }
.priv-cal-day.level-4 .priv-cal-day-count { color: white; }
.priv-cal-day.level-4 .priv-cal-day-num { color: white; }
.priv-cal-day.level-3 .priv-cal-day-count { color: #0d3d0d; }

.priv-cal-day-num {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.priv-cal-day-count {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 600;
}
.priv-cal-day-count.zero { visibility: hidden; }

.priv-calendar-legend {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 12px;
  justify-content: flex-end;
}
.priv-cal-legend-label { margin-right: 4px; }
.priv-cal-legend-cell {
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.priv-cal-legend-cell.level-0 { background: var(--surface); }
.priv-cal-legend-cell.level-1 { background: #E6F4E6; }
.priv-cal-legend-cell.level-2 { background: #B7E4B7; }
.priv-cal-legend-cell.level-3 { background: #6FBF6F; }
.priv-cal-legend-cell.level-4 { background: #2E8B2E; }
.priv-cal-legend-hint { margin-left: 4px; }

/* Day detail panel (slide-in from right) */
.priv-day-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 999;
  animation: fadeIn 0.15s;
}
.priv-day-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 480px;
  background: var(--surface);
  box-shadow: -4px 0 16px rgba(0, 0, 0, 0.12);
  z-index: 1000;
  display: flex;
  flex-direction: column;
  animation: slideInRight 0.2s ease-out;
}
@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}
.priv-day-panel-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.priv-day-panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}
.priv-day-panel-close {
  background: transparent;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 6px;
  line-height: 1;
  border-radius: 4px;
}
.priv-day-panel-close:hover {
  color: var(--text);
  background: var(--surface-alt);
}
.priv-day-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 22px;
}
.priv-day-entry {
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  margin-bottom: 10px;
}
.priv-day-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}
.priv-day-entry-task {
  font-weight: 700;
  color: var(--primary);
  font-size: 13px;
  cursor: pointer;
}
.priv-day-entry-task:hover { text-decoration: underline; }
.priv-day-entry-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}
.priv-day-entry-body {
  font-size: 13px;
  color: var(--text);
  line-height: 1.5;
}
.priv-day-entry-body img {
  max-width: 100%;
  height: auto;
  border-radius: 4px;
  margin: 4px 0;
  display: block;
}
.priv-day-entry-body p { margin: 0 0 6px; }
.priv-day-entry-body ul, .priv-day-entry-body ol { margin: 4px 0 6px; padding-left: 22px; }
.priv-day-empty {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 40px 20px;
  font-style: italic;
}

/* Delete button style */
.btn-danger {
  background: transparent;
  color: var(--danger);
  border: 1px solid transparent;
  padding: 7px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  margin-right: auto;
}
.btn-danger:hover {
  background: var(--danger-bg);
  border-color: var(--danger);
}

@media (max-width: 700px) {
  .private-view { padding: 12px 14px 60px; }
  .priv-modal-body, .priv-modal-header, .priv-modal-footer { padding-left: 16px; padding-right: 16px; }
  .priv-calendar-header { gap: 8px; }
  .priv-calendar-title { min-width: 120px; font-size: 15px; }
  .priv-calendar-stats { margin-left: 0; width: 100%; text-align: center; }
  .priv-cal-day { min-height: 50px; padding: 4px; }
  .priv-cal-day-num { font-size: 12px; }
  .priv-day-panel { max-width: 100%; }
}

/* ============ NSF TAB & ANIMATION ============ */
.nsf-tab {
  position: relative;
  color: var(--danger) !important;
}
.nsf-tab .nsf-tab-inner {
  display: inline-flex;
  align-items: center;
}
.nsf-tab.has-new {
  animation: nsfPulse 2s infinite;
}
.nsf-tab.has-new::after {
  content: '';
  position: absolute;
  top: 6px;
  right: 4px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
  animation: nsfDotPulse 1.5s infinite;
}
@keyframes nsfPulse {
  0%, 100% { background: transparent; }
  50% { background: rgba(220, 38, 38, 0.08); }
}
@keyframes nsfDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.6); }
  50% { box-shadow: 0 0 0 6px rgba(220, 38, 38, 0); }
}
.nsf-badge {
  background: var(--danger) !important;
  color: white !important;
}

/* NSF new item banner */
.nsf-new-banner {
  background: linear-gradient(90deg, var(--danger-bg), transparent);
  border-left: 4px solid var(--danger);
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
  color: var(--text);
  animation: nsfBannerSlide 0.4s ease-out;
}
.nsf-new-banner strong { color: var(--danger); }
@keyframes nsfBannerSlide {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* NSF list styling */
.nsf-list {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}
.nsf-item {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.nsf-item:hover { background: var(--surface-alt); }
.nsf-item:last-child { border-bottom: none; }
.nsf-item.is-new {
  background: linear-gradient(90deg, rgba(220,38,38,0.05) 0%, transparent 70%);
  border-left: 3px solid var(--danger);
  padding-left: 13px;
}
.nsf-item-info { min-width: 0; }
.nsf-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.nsf-new-pill {
  background: var(--danger);
  color: white;
  font-size: 9px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.nsf-item-reason {
  font-size: 11px;
  color: var(--text-muted);
}
.nsf-item-amount {
  font-size: 13px;
  font-weight: 700;
  color: var(--danger);
  text-align: right;
  min-width: 80px;
}
.nsf-item-date {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
  min-width: 90px;
}
.nsf-item-count {
  background: var(--danger-bg);
  color: var(--danger);
  padding: 3px 10px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}

/* Quick Info NSF badge */
.quick-info-nsf {
  background: linear-gradient(135deg, rgba(220,38,38,0.08), rgba(220,38,38,0.02));
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  padding: 10px 12px;
  margin-bottom: 12px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.quick-info-nsf-icon {
  color: var(--danger);
  flex-shrink: 0;
  margin-top: 2px;
}
.quick-info-nsf-body { flex: 1; }
.quick-info-nsf-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--danger);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.quick-info-nsf-desc {
  font-size: 12px;
  color: var(--text);
  line-height: 1.4;
}
.quick-info-nsf-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

@media (max-width: 700px) {
  .nsf-item {
    grid-template-columns: 1fr auto;
    gap: 8px;
  }
  .nsf-item-date { grid-column: 1; text-align: left; }
  .nsf-item-count { grid-column: 2; }
}

/* Version update banner */
.version-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: linear-gradient(90deg, #3B82F6, #2563EB);
  color: white;
  padding: 10px 20px;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  animation: versionSlideDown 0.3s ease-out;
}
@keyframes versionSlideDown {
  from { transform: translateY(-100%); }
  to { transform: translateY(0); }
}
#version-refresh-btn {
  background: white;
  color: #2563EB;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}
#version-refresh-btn:hover {
  background: #F1F5F9;
  transform: scale(1.03);
}
body:has(.version-banner:not([hidden])) { padding-top: 42px; }

/* ============ STAR / SNOOZE ICONS IN ROWS ============ */
.star-icon-in-row {
  cursor: pointer;
  color: #D1D5DB;
  font-size: 15px;
  margin-right: 4px;
  transition: all 0.15s;
  display: inline-block;
  user-select: none;
  vertical-align: middle;
}
.star-icon-in-row:hover { color: #F59E0B; transform: scale(1.15); }
.star-icon-in-row.starred { color: #F59E0B; }
.snooze-icon-in-row {
  cursor: pointer;
  color: var(--primary);
  margin-right: 4px;
  display: inline-flex;
  align-items: center;
  vertical-align: middle;
  transition: transform 0.15s;
}
.snooze-icon-in-row:hover { transform: scale(1.15); }

/* Star modal */
.star-modal-info { margin-bottom: 12px; }
.star-modal-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}
.star-modal-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Snooze modal */
.snooze-days-row {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.snooze-days-row input {
  width: 80px !important;
  flex: 0 0 auto !important;
}
.snooze-preset-buttons {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.snooze-preset {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-muted);
  transition: all 0.15s;
  font-family: inherit;
}
.snooze-preset:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.snooze-until-preview {
  font-size: 11px;
  color: var(--primary);
  margin-top: 8px;
  font-style: italic;
  font-weight: 600;
}

/* Filter chips + saved view */
.filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  border-radius: 14px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.filter-chip.active {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary);
}
.filter-chip svg { flex-shrink: 0; }

.saved-view-wrap {
  position: relative;
}
.saved-view-btn {
  gap: 6px;
}
.saved-view-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 280px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  max-height: 400px;
  overflow-y: auto;
}
.sv-header {
  padding: 10px 14px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.sv-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  font-style: italic;
}
.sv-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.sv-item:hover { background: var(--surface-alt); }
.sv-item-name {
  flex: 1;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.sv-item-name:hover { color: var(--primary); }
.sv-item-meta {
  font-size: 10px;
  color: var(--text-muted);
}
.sv-delete-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 16px;
  line-height: 1;
}
.sv-delete-btn:hover {
  background: var(--danger-bg);
  color: var(--danger);
}
.sv-divider {
  height: 1px;
  background: var(--border);
}
.sv-save-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 14px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  font-family: inherit;
  transition: background 0.15s;
}
.sv-save-btn:hover { background: var(--primary-light); }

/* Save view summary */
.saveview-summary {
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 10px 0;
  font-size: 12px;
  color: var(--text);
}
.sv-summary-title {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.saveview-note {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
  margin-top: 8px;
}

/* ============ OVERVIEW / HOMEPAGE ============ */
.overview-container {
  padding: 20px 24px 40px;
}
.overview-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 16px;
}
.overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.overview-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 3px solid var(--border-strong);
  border-radius: var(--radius-md);
  padding: 16px;
  cursor: pointer;
  transition: all 0.15s;
}
.overview-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--primary);
}
.overview-card-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
  margin-bottom: 6px;
}
.overview-card-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.overview-card-danger { border-left-color: var(--danger); }
.overview-card-danger .overview-card-value { color: var(--danger); }
.overview-card-success { border-left-color: var(--success); }
.overview-card-success .overview-card-value { color: var(--success); }
.overview-card-primary { border-left-color: var(--primary); }
.overview-card-warning { border-left-color: var(--warning); }
.overview-card-warning .overview-card-value { color: var(--warning); }
.overview-card-gold { border-left-color: #F59E0B; }
.overview-card-gold .overview-card-value { color: #F59E0B; }
.overview-card-muted { border-left-color: var(--text-muted); }

/* Starting weight date */
.starting-weight-date {
  color: var(--text-muted);
  font-size: 11px;
  font-weight: normal;
}

@media (max-width: 700px) {
  .overview-grid { grid-template-columns: repeat(2, 1fr); }
  .overview-card-value { font-size: 22px; }
}

/* ============ LEFT NAVIGATION ============ */
.app-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: calc(100vh - 60px);
}
.left-nav {
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 8px;
  overflow-y: auto;
  height: calc(100vh - 60px);
  position: sticky;
  top: 60px;
}
.left-nav-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
  display: none;
}
.lnav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: all 0.15s;
  font-family: inherit;
  margin-bottom: 2px;
}
.lnav-item:hover {
  background: var(--surface-alt);
  color: var(--text);
}
.lnav-item.active {
  background: var(--primary-light);
  color: var(--primary);
  font-weight: 700;
}
.lnav-item.active .lnav-icon {
  color: var(--primary);
}
.lnav-icon {
  flex-shrink: 0;
  color: var(--text-muted);
}
.lnav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lnav-badge {
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 9px;
  min-width: 18px;
  text-align: center;
}
.lnav-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 4px;
}
.app-main {
  min-width: 0;
  overflow-x: hidden;
}
.hamburger-btn {
  background: transparent;
  border: none;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  display: none;
  margin-right: 4px;
}
.hamburger-btn:hover {
  background: var(--surface-alt);
  color: var(--text);
}

@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .hamburger-btn { display: inline-flex; align-items: center; }
  .left-nav {
    position: fixed;
    top: 60px;
    left: 0;
    height: calc(100vh - 60px);
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.25s ease-out;
    box-shadow: 4px 0 12px rgba(0,0,0,0.1);
  }
  .left-nav.open {
    transform: translateX(0);
  }
  .left-nav-backdrop.open {
    display: block;
  }
}

/* ============ PRICING ENGINE ============ */
.pricing-view {
  padding: 20px 24px 60px;
  min-height: 400px;
}
.pricing-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.pricing-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
}
.pricing-status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 4px 10px;
  background: var(--surface-alt);
  border-radius: 12px;
}
.pricing-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}
.pricing-status-indicator.connected .pricing-status-dot {
  background: var(--success);
  animation: pricingPulse 2s infinite;
}
.pricing-status-indicator.error .pricing-status-dot { background: var(--danger); }
@keyframes pricingPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  50% { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

.pricing-toolbar {
  margin-bottom: 16px;
}
#pricing-search {
  width: 100%;
  max-width: 400px;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
}
#pricing-search:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.12);
}

.pricing-error {
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  color: var(--danger);
  padding: 12px 14px;
  border-radius: var(--radius-md);
  font-size: 13px;
  margin-bottom: 16px;
}

.pricing-board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
  min-height: 300px;
}
.pricing-column {
  background: var(--surface-alt);
  border-radius: var(--radius-lg);
  padding: 10px;
  min-height: 200px;
}
.pricing-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding: 0 4px;
}
.pricing-column-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.pricing-column.quoted .pricing-column-title { color: var(--text-muted); }
.pricing-column.paid .pricing-column-title { color: var(--success); }
.pricing-column.in_qc .pricing-column-title { color: var(--warning); }
.pricing-column.submitted .pricing-column-title { color: #8B5CF6; }
.pricing-column.fulfilled .pricing-column-title { color: var(--primary); }
.pricing-column-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface);
  padding: 1px 8px;
  border-radius: 10px;
}
.pricing-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.pricing-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow-sm);
}
.pricing-card:hover {
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
.pricing-card-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}
.pricing-card-number {
  font-size: 10px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
  margin-bottom: 5px;
}
.pricing-card-med {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.pricing-card-price {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.pricing-card-badges {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.pricing-badge {
  font-size: 9px;
  padding: 1px 6px;
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.pricing-badge.promo { background: #FEF3C7; color: #92400E; }
.pricing-badge.finance { background: var(--info-bg); color: var(--info); }
.pricing-badge.ghl-sent { background: var(--success-bg); color: var(--success); }

/* Advance button */
.pricing-card-advance {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding: 5px 8px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  width: 100%;
  justify-content: center;
  transition: background 0.15s;
  font-family: inherit;
}
.pricing-card-advance:hover { background: #2563EB; }
.pricing-card-advance:disabled {
  background: var(--text-light);
  cursor: not-allowed;
}

/* Pricing modal */
.pricing-modal-header {
  padding: 22px 26px 12px;
  border-bottom: 1px solid var(--border);
}
.pricing-modal-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}
.pricing-modal-sub {
  font-size: 11px;
  color: var(--text-muted);
  font-family: ui-monospace, monospace;
}
.pricing-modal-body {
  padding: 18px 26px;
}
.pricing-info-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 16px;
  padding: 12px;
  background: var(--surface-alt);
  border-radius: var(--radius-sm);
}
.pricing-info-field {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.pricing-info-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.pricing-info-value {
  font-size: 12px;
  color: var(--text);
  font-weight: 500;
  word-break: break-word;
}
.pricing-info-value strong { font-weight: 700; }
.pricing-info-value a { color: var(--primary); }

.pricing-modal-section {
  margin-bottom: 16px;
}
.pricing-section-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}

.pricing-dmp-highlight {
  background: linear-gradient(135deg, var(--success-bg), rgba(34,197,94,0.05));
  border-left: 3px solid var(--success);
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}
.pricing-dmp-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 3px;
}
.pricing-dmp-value {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

.pricing-modal-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 12px 26px;
  border-top: 1px solid var(--border);
  background: var(--surface-alt);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}
.pricing-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s;
  font-family: inherit;
}
.pricing-action-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.pricing-action-btn.primary {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}
.pricing-action-btn.primary:hover {
  background: #2563EB;
  color: white;
}

@media (max-width: 1200px) {
  .pricing-board { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .pricing-board { grid-template-columns: repeat(2, 1fr); }
  .pricing-info-grid { grid-template-columns: 1fr; }
}
@media (max-width: 550px) {
  .pricing-board { grid-template-columns: 1fr; }
  .pricing-view { padding: 14px 16px 60px; }
}

/* ============ SEND ORDER ============ */
.sendorder-view {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}
.sendorder-view .page-header { margin-bottom: 16px; }
.so-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 16px;
}
.so-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 14px;
}
/* Patient search */
.so-contact-search { position: relative; display: flex; align-items: center; }
.so-search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-light);
  pointer-events: none;
}
.so-contact-search input {
  width: 100%;
  padding: 10px 12px 10px 36px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.so-contact-search input:focus { outline: none; border-color: var(--border-focus); }
.so-contact-search-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl, 0 10px 25px rgba(15,23,42,0.12));
  z-index: 40;
  max-height: 320px;
  overflow-y: auto;
}
.so-contact-result {
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.so-contact-result:last-child { border-bottom: none; }
.so-contact-result:hover { background: var(--surface-hover); }
.so-contact-result-name { font-weight: 600; font-size: 14px; color: var(--text); }
.so-contact-result-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.so-contact-empty { padding: 12px 14px; font-size: 13px; color: var(--text-muted); }
/* Selected patient */
.so-selected-patient {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.so-patient-name { font-weight: 700; font-size: 16px; color: var(--text); }
.so-patient-contact { font-size: 13px; color: var(--text-muted); margin-top: 3px; }
/* State error */
.so-state-error {
  margin-top: 16px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
}
.so-state-error-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 14px;
  color: var(--danger);
  margin-bottom: 8px;
}
.so-state-error-body { font-size: 13px; color: var(--text); line-height: 1.5; }
.so-state-error-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
/* Form grid */
.so-form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 16px;
}
.so-field { display: flex; flex-direction: column; gap: 6px; }
.so-field-full { grid-column: 1 / -1; }
.so-field label { font-size: 13px; font-weight: 600; color: var(--text); }
.so-field .req { color: var(--danger); }
.so-field input,
.so-field select {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.so-field input:focus,
.so-field select:focus { outline: none; border-color: var(--border-focus); }
/* Radio cards */
.so-radio-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 10px;
  cursor: pointer;
}
.so-radio-row:last-child { margin-bottom: 0; }
.so-radio-row input[type="radio"] { margin-top: 2px; accent-color: var(--primary); }
.so-radio-row:has(input:checked) {
  border-color: var(--primary);
  background: var(--primary-light);
}
.so-radio-title { font-weight: 600; font-size: 14px; color: var(--text); }
.so-radio-desc { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.so-temp-address { margin-top: 14px; padding-top: 4px; }
/* Actions */
.so-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

/* ===== Multiple products ===== */
.so-product-block {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px 4px;
  margin-bottom: 12px;
  background: var(--bg-subtle, #fafbfc);
}
.so-product-block[data-block="1"] { border-style: solid; }
.so-product-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.so-product-label {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .04em; color: var(--text-light);
}
.so-product-remove {
  background: transparent; border: none; color: #b91c1c;
  font-size: 13px; font-weight: 500; cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.so-product-remove:hover { background: #fef2f2; }
.so-add-product {
  display: inline-flex; align-items: center; gap: 7px;
  background: transparent; border: 1px dashed var(--border);
  color: var(--primary, #2563eb); font-size: 13px; font-weight: 600;
  padding: 9px 16px; border-radius: 9px; cursor: pointer; margin-bottom: 4px;
}
.so-add-product:hover { background: var(--bg-subtle, #f3f4f6); border-color: var(--primary, #2563eb); }
.so-shared-grid { margin-top: 8px; }

/* ===== Drafts ===== */
.so-drafts-list { display: flex; flex-direction: column; gap: 8px; }
.so-draft-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 11px 14px; border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-subtle, #fafbfc); cursor: pointer;
}
.so-draft-item:hover { border-color: var(--primary, #2563eb); background: var(--surface, #fff); }
.so-draft-main { min-width: 0; }
.so-draft-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-draft-sub { font-size: 12px; color: var(--text-light); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.so-draft-actions { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.so-draft-resume { font-size: 13px; font-weight: 600; color: var(--primary, #2563eb); }
.so-draft-del {
  background: transparent; border: none; color: var(--text-light);
  font-size: 20px; line-height: 1; cursor: pointer; padding: 0 4px; border-radius: 6px;
}
.so-draft-del:hover { background: #fef2f2; color: #b91c1c; }

/* ===== Send To GetHeally ===== */
.getheally-view {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}
.getheally-view .page-header { margin-bottom: 16px; }
.gh-card {
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 22px;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.gh-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-light);
  margin-bottom: 8px;
}
.gh-search .so-search-icon { opacity: .6; }
.gh-search input { height: 46px; font-size: 15px; }

/* Selected patient card */
.gh-patient-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-subtle, #f9fafb);
}
.gh-avatar {
  flex: 0 0 auto;
  width: 44px; height: 44px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; color: #fff;
  background: linear-gradient(135deg, #3b82f6, #2563eb);
  letter-spacing: .5px;
}
.gh-patient-info { flex: 1 1 auto; min-width: 0; }
.gh-patient-name { font-size: 16px; font-weight: 600; color: var(--text); }
.gh-patient-sub { font-size: 13px; color: var(--text-light); margin-top: 2px; }
.gh-change-btn {
  flex: 0 0 auto;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-light);
  border-radius: 8px;
  padding: 7px 14px;
  font-size: 13px; font-weight: 500;
  cursor: pointer;
}
.gh-change-btn:hover { background: var(--surface, #fff); color: var(--text); }

/* Confirm step */
.gh-confirm {
  margin-top: 16px;
  padding: 16px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--surface, #fff);
}
.gh-confirm-text { font-size: 14px; color: var(--text); line-height: 1.5; margin-bottom: 14px; }
.gh-actions { display: flex; gap: 12px; }
.gh-run-btn { display: inline-flex; align-items: center; gap: 8px; }
.gh-run-btn svg { flex: 0 0 auto; }
.gh-run-btn:disabled { opacity: .6; cursor: default; }

.gh-status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.gh-status-loading { background: #eff6ff; color: #1e40af; border-color: #bfdbfe; }
.gh-status-loading::before {
  content: ''; width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid #bfdbfe; border-top-color: #1e40af;
  animation: gh-spin .7s linear infinite; flex: 0 0 auto;
}
@keyframes gh-spin { to { transform: rotate(360deg); } }
.gh-status-success { background: #ecfdf5; color: #065f46; border-color: #a7f3d0; }
.gh-status-error { background: #fef2f2; color: #991b1b; border-color: #fecaca; }

.gh-result {
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle, #f9fafb);
}
.gh-result-label { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; color: var(--text-light); margin-bottom: 6px; }
.gh-result-link { font-size: 14px; color: var(--primary, #2563eb); word-break: break-all; text-decoration: underline; }
.gh-result-hint { margin-top: 8px; font-size: 13px; color: #991b1b; }

/* History */
.gh-history-card {
  margin-top: 22px;
  background: var(--surface, #fff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px 22px;
}
.gh-history-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.gh-history-title { font-size: 14px; font-weight: 700; color: var(--text); }
.gh-history-refresh {
  background: transparent; border: none; color: var(--text-light);
  cursor: pointer; padding: 6px; border-radius: 6px; display: inline-flex;
}
.gh-history-refresh:hover { background: var(--bg-subtle, #f3f4f6); color: var(--text); }
.gh-history-list { display: flex; flex-direction: column; }
.gh-history-empty { font-size: 13px; color: var(--text-light); padding: 14px 0; }
.gh-history-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 0; border-bottom: 1px solid var(--border);
}
.gh-history-item:last-child { border-bottom: none; }
.gh-history-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700; color: var(--text-light);
  background: var(--bg-subtle, #eef2f7);
}
.gh-history-main { flex: 1 1 auto; min-width: 0; }
.gh-history-name { font-size: 14px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gh-history-meta { font-size: 12px; color: var(--text-light); margin-top: 1px; }
.gh-history-right { flex: 0 0 auto; display: flex; align-items: center; gap: 10px; }
.gh-history-badge { font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 999px; }
.gh-history-badge.done { background: #ecfdf5; color: #065f46; }
.gh-history-badge.running { background: #eff6ff; color: #1e40af; }
.gh-history-link { font-size: 13px; color: var(--primary, #2563eb); text-decoration: underline; white-space: nowrap; }
.gh-history-pending { font-size: 12px; color: var(--text-light); }
/* History */
.so-history-list { display: flex; flex-direction: column; }
.so-history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.so-history-item:last-child { border-bottom: none; }
.so-history-name { font-weight: 600; font-size: 14px; color: var(--text); }
.so-history-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }
.so-history-empty { padding: 10px 0; font-size: 13px; color: var(--text-muted); }
/* Status badges */
.so-status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 3px 10px;
  border-radius: 10px;
  white-space: nowrap;
}
.so-status-success { background: var(--success-bg); color: var(--success); }
.so-status-failed { background: var(--danger-bg); color: var(--danger); }
.so-status-pending { background: #fef3c7; color: #92400e; }
.so-status-scheduled { background: #dbeafe; color: #1e40af; }
/* Progress modal */
.so-progress-content { text-align: left; }
.so-progress-header { margin-bottom: 18px; }
.so-progress-title { font-size: 17px; font-weight: 700; color: var(--text); }
.so-progress-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.so-progress-steps { display: flex; flex-direction: column; gap: 12px; }
.so-progress-step { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text); }
.so-step-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
}
.so-step-success { background: var(--success-bg); color: var(--success); }
.so-step-failed { background: var(--danger-bg); color: var(--danger); }
.so-step-text { flex: 1; }
.so-mini-spinner {
  border: 2px solid var(--border-strong);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  animation: so-spin 0.7s linear infinite;
}
@keyframes so-spin { to { transform: rotate(360deg); } }
.so-progress-error {
  margin-top: 16px;
  background: var(--danger-bg);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  color: var(--danger);
  line-height: 1.5;
}
.so-progress-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}
/* Responsive */
@media (max-width: 700px) {
  .so-form-grid { grid-template-columns: 1fr; }
  .sendorder-view { padding: 14px 16px 60px; }
  .getheally-view { padding: 14px 16px 60px; }
  .so-selected-patient { flex-direction: column; align-items: flex-start; }
}

/* ===== Send Order: pre-send checks + inline fixes ===== */
.so-check-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-height: 300px;
  overflow-y: auto;
}
.so-check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 13.5px;
  color: var(--text);
  line-height: 1.45;
  animation: so-check-in 0.22s ease both;
}
@keyframes so-check-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: none; }
}
.so-check-text { flex: 1; }
.so-check-ok .so-check-text { color: var(--text-muted); }
.so-check-fail .so-check-text { color: var(--danger); font-weight: 500; }
/* Inline fix panel */
.so-fix-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}
.so-fix-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 12px;
}
.so-fix-fields {
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 320px;
  overflow-y: auto;
}
.so-fix-row {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  animation: so-check-in 0.22s ease both;
}
.so-fix-blocked {
  background: var(--danger-bg);
  border-color: var(--danger);
}
.so-fix-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
}
.so-fix-dest {
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text-light);
}
.so-fix-problem {
  font-size: 12px;
  color: var(--text-muted);
  margin: 4px 0 8px;
  line-height: 1.45;
}
.so-fix-blocked .so-fix-problem { color: var(--danger); }
.so-fix-input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
.so-fix-input:focus { outline: none; border-color: var(--border-focus); }
.so-fix-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 16px;
}
.so-fix-error {
  margin-top: 12px;
  font-size: 12.5px;
  color: var(--danger);
}
/* Success appreciation note */
.so-success-note {
  margin-top: 18px;
  text-align: center;
  font-size: 15px;
  font-weight: 600;
  color: var(--success);
  animation: so-praise-in 0.4s cubic-bezier(0.2, 0.8, 0.3, 1) both;
}
@keyframes so-praise-in {
  from { opacity: 0; transform: scale(0.94) translateY(6px); }
  to   { opacity: 1; transform: none; }
}

/* Send Order: check rows show what was verified (two-line layout) */
.so-check-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.so-check-title {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}
.so-check-detail {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.4;
  word-break: break-word;
}
.so-check-detail-bad { color: var(--danger); }
.so-check-active .so-check-title { color: var(--text-muted); font-weight: 500; }
.so-check-ok .so-check-title { color: var(--text); }
.so-check-fail .so-check-title { color: var(--danger); }

/* Order Queue: remove button + clickable logo + footer layout */
.btn-danger-outline {
  background: var(--surface);
  color: var(--danger);
  border: 1px solid #fecaca;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn-danger-outline:hover:not(:disabled) { background: var(--danger-bg); border-color: var(--danger); }
.btn-danger-outline:disabled { opacity: 0.6; cursor: not-allowed; }
.modal-footer-spacer { flex: 1; }
.topbar-logo[role="button"] { cursor: pointer; }
.topbar-logo[role="button"]:hover { opacity: 0.8; }
.topbar-logo[role="button"]:focus-visible { outline: 2px solid var(--border-focus); outline-offset: 3px; border-radius: 4px; }

/* Order Queue: renewal countdown badge */
.oq-renew {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  white-space: nowrap;
}
.oq-renew.renew-ok   { background: var(--success-bg); color: var(--success); }
.oq-renew.renew-soon { background: #fef3c7; color: #92400e; }
.oq-renew.renew-due  { background: var(--danger-bg); color: var(--danger); }

.so-optional { font-weight: 400; font-size: 11px; color: var(--text-light); }

/* ===== Left nav section label ===== */
.lnav-section-label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-light);
  padding: 4px 14px 2px;
}

/* ===== Timezone Calculator ===== */
.timezone-view {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 24px 80px;
}
.tz-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.tz-search-row {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}
.tz-input-wrap { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.tz-input-wrap label { font-size: 13px; font-weight: 600; color: var(--text); }
#tz-zip-input {
  width: 100%;
  padding: 11px 13px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 18px;
  letter-spacing: 0.08em;
  background: var(--surface);
  color: var(--text);
}
#tz-zip-input:focus { outline: none; border-color: var(--border-focus); }
#tz-lookup-btn { padding: 11px 22px; font-size: 14px; white-space: nowrap; }
.tz-error {
  margin-top: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 13px;
  font-size: 13px;
}
.tz-result {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px 20px;
  margin-bottom: 18px;
  animation: so-check-in 0.25s ease both;
}
.tz-result-head { text-align: center; margin-bottom: 20px; }
.tz-zone-name { font-size: 22px; font-weight: 700; color: var(--primary); }
.tz-location { font-size: 14px; color: var(--text-muted); margin-top: 4px; }
.tz-clocks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.tz-clock {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 16px;
  text-align: center;
}
.tz-clock-patient { background: var(--primary-light); border-color: var(--primary); }
.tz-clock-karachi { background: var(--surface-alt); }
.tz-clock-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.tz-clock-time {
  font-size: 30px;
  font-weight: 700;
  color: var(--text);
  margin: 8px 0 4px;
  font-variant-numeric: tabular-nums;
}
.tz-clock-date { font-size: 13px; color: var(--text-muted); }
.tz-clock-meta { font-size: 11px; color: var(--text-light); margin-top: 8px; word-break: break-word; }
.tz-note {
  text-align: center;
  margin-top: 18px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text);
}
.tz-hint {
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.6;
  background: var(--surface-alt);
  border-radius: var(--radius-md);
  padding: 14px 16px;
}
@media (max-width: 640px) {
  .tz-clocks { grid-template-columns: 1fr; }
  .tz-search-row { flex-direction: column; align-items: stretch; }
  .timezone-view { padding: 14px 16px 60px; }
}

/* Send Order: clickable recent-order + detail modal */
.so-history-clickable { cursor: pointer; border-radius: var(--radius-sm); transition: background 0.12s; padding-left: 8px; padding-right: 8px; margin: 0 -8px; }
.so-history-clickable:hover { background: var(--surface-hover); }
.so-detail-content { text-align: left; }
.so-detail-title { font-size: 17px; font-weight: 700; color: var(--text); margin-bottom: 16px; padding-right: 28px; }
.so-detail-body { display: flex; flex-direction: column; }
.so-od-row { display: flex; gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13.5px; }
.so-od-row:last-child { border-bottom: none; }
.so-od-label { flex: 0 0 42%; color: var(--text-muted); font-weight: 600; }
.so-od-value { flex: 1; color: var(--text); word-break: break-word; }
.so-od-empty { color: var(--text-light); }

/* Send Order: product search combobox */
.so-combo { position: relative; }
.so-combo input[type="text"] {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.so-combo input[type="text"]:focus { outline: none; border-color: var(--border-focus); }
.so-combo-list {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-xl, 0 10px 25px rgba(15,23,42,0.12));
  z-index: 40;
  max-height: 260px;
  overflow-y: auto;
}
.so-combo-item {
  padding: 9px 13px;
  cursor: pointer;
  font-size: 13.5px;
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.so-combo-item:last-child { border-bottom: none; }
.so-combo-item:hover { background: var(--surface-hover); }
.so-combo-empty { padding: 10px 13px; font-size: 13px; color: var(--text-muted); }

/* Send Order: invoice quick-pick dropdown */
.so-invoice-select {
  width: 100%;
  padding: 8px 11px;
  margin-bottom: 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13px;
  background: var(--surface-alt);
  color: var(--text);
}
.so-invoice-select:focus { outline: none; border-color: var(--border-focus); }

/* Patient detail: Order History (with dosing) + Survey History */
.oh-list, .sh-list { display: flex; flex-direction: column; gap: 8px; }
.oh-row { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px; }
.oh-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.oh-product { font-weight: 600; font-size: 13.5px; color: var(--text); }
.oh-status { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; color: var(--text-muted); }
.oh-sub { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.oh-delivered { color: var(--success); font-weight: 600; }
.oh-dir { font-size: 12px; color: var(--text); margin-top: 5px; line-height: 1.4; }
.sh-row { display: flex; justify-content: space-between; gap: 10px; padding: 8px 2px; border-bottom: 1px solid var(--border); font-size: 13px; }
.sh-row:last-child { border-bottom: none; }
.sh-name { color: var(--text); font-weight: 500; }
.sh-date { color: var(--text-muted); white-space: nowrap; }

/* Patient detail: show-more collapse (5 rows) */
.oh-list.collapsed .oh-row:nth-child(n+6),
.order-list.collapsed .order-row:nth-child(n+6) { display: none; }
.detail-showmore {
  margin-top: 8px;
  background: none;
  border: none;
  color: var(--primary);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  padding: 4px 2px;
}
.detail-showmore:hover { text-decoration: underline; }

/* ===== Dosing Calculator ===== */
.dosing-view { max-width: 780px; margin: 0 auto; padding: 20px 24px 80px; }
.dosing-view .page-header { margin-bottom: 16px; }
.dc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
  margin-bottom: 18px;
}
.dc-row { display: flex; gap: 14px; align-items: flex-end; flex-wrap: wrap; }
.dc-field { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 150px; }
.dc-field label { font-size: 12px; font-weight: 600; color: var(--text); }
.dc-field select, .dc-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 14px;
  background: var(--surface);
  color: var(--text);
}
.dc-field select:focus, .dc-field input:focus { outline: none; border-color: var(--border-focus); }
#dc-go { padding: 10px 22px; white-space: nowrap; }
.dc-toggles { display: flex; gap: 16px; margin-top: 12px; font-size: 13px; color: var(--text-muted); align-items: center; flex-wrap: wrap; }
.dc-toggles label { font-weight: 500; display: flex; gap: 6px; align-items: center; cursor: pointer; }
.dc-toggles select { padding: 4px 8px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 12.5px; background: var(--surface); color: var(--text); }
.dc-hint { font-size: 12px; color: var(--text-muted); margin-top: 10px; }
.dc-results-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); margin: 20px 0 10px; }
.dc-opt {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  margin-bottom: 9px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.dc-opt.best { border-color: #f59e0b; background: #fef3c7; }
.dc-opt-left { min-width: 0; }
.dc-opt-combo { font-size: 15px; font-weight: 700; color: var(--text); }
.dc-opt-total { font-weight: 600; color: var(--text-muted); }
.dc-star { color: #f59e0b; margin-right: 5px; }
.dc-opt-name { font-size: 12px; color: var(--text-muted); margin-top: 3px; word-break: break-word; }
.dc-opt-meta { font-size: 11.5px; color: var(--text-muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dc-pill { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 7px; border-radius: 6px; background: var(--surface-alt); color: var(--text-muted); }
.dc-pill.exact { background: var(--success-bg); color: var(--success); }
.dc-opt-right { text-align: right; white-space: nowrap; }
.dc-opt-price { font-size: 20px; font-weight: 800; color: var(--text); }
.dc-opt.best .dc-opt-price { color: #92400e; }
.dc-best-flag { display: inline-block; background: #f59e0b; color: #fff; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; padding: 2px 8px; border-radius: 6px; margin-bottom: 6px; }
.dc-empty { color: var(--text-muted); font-size: 14px; padding: 8px 0; }
@media (max-width: 640px) {
  .dc-row { flex-direction: column; align-items: stretch; }
  .dosing-view { padding: 14px 16px 60px; }
}

/* Send Order: dosing helper (find product by dosage) */
.so-dc {
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 16px;
  background: var(--surface-alt);
}
.so-dc-title { font-size: 12.5px; font-weight: 700; color: var(--text); margin-bottom: 10px; }
.so-dc-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.so-dc-row select, .so-dc-row input {
  padding: 8px 11px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  background: var(--surface);
  color: var(--text);
}
.so-dc-row select { min-width: 140px; }
.so-dc-row input { flex: 1; min-width: 150px; }
.so-dc-row select:focus, .so-dc-row input:focus { outline: none; border-color: var(--border-focus); }
.so-dc-row #so-dc-go { padding: 8px 18px; }
.so-dc-toggles { display: flex; gap: 14px; margin-top: 10px; font-size: 12.5px; color: var(--text-muted); align-items: center; flex-wrap: wrap; }
.so-dc-toggles label { display: flex; gap: 6px; align-items: center; cursor: pointer; }
.so-dc-toggles select { padding: 3px 7px; border: 1px solid var(--border-strong); border-radius: 6px; font-size: 12px; background: var(--surface); color: var(--text); }
.so-dc-out { margin-top: 12px; }
.dc-opt { cursor: pointer; transition: box-shadow 0.12s, border-color 0.12s; }
.dc-opt:hover { border-color: var(--primary); }
.dc-opt.picked { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }

/* ============ SCHEDULED ORDERS SIDEBAR ============ */
/* The Send Order page becomes two columns: the form on the left, and what is
   queued for later on the right, so a scheduled order is never out of sight. */
.so-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 20px;
  align-items: start;
}
.so-layout > .so-main { min-width: 0; }

.so-side {
  position: sticky;
  top: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 14px 14px 16px;
  max-height: calc(100vh - 40px);
  overflow-y: auto;
}
.so-side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.so-side-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}
.so-side-refresh {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm, 6px);
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  line-height: 0;
}
.so-side-refresh:hover { background: var(--surface-alt); color: var(--text); }

.so-sched-health {
  font-size: 11px;
  line-height: 1.45;
  border-radius: 6px;
  padding: 7px 9px;
  margin-bottom: 10px;
}
.so-sched-health-ok { background: var(--success-bg); color: #065f46; }
.so-sched-health-bad { background: var(--danger-bg); color: #991b1b; font-weight: 600; }

.so-sched-empty {
  font-size: 12px;
  color: var(--text-muted);
  text-align: center;
  padding: 22px 8px;
  line-height: 1.6;
}
.so-sched-empty span { color: var(--text-light); font-size: 11px; }

.so-sched-list { display: flex; flex-direction: column; gap: 10px; }

.so-sched-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 8px);
  padding: 10px 11px;
  background: var(--surface);
}
.so-sched-card-late { border-color: var(--warning); background: #fffbeb; }

.so-sched-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 3px;
}
.so-sched-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  text-transform: capitalize;
  min-width: 0;
  overflow-wrap: anywhere;
}
.so-sched-when { font-size: 11px; color: var(--text-muted); }
.so-sched-countdown {
  font-size: 12px;
  font-weight: 700;
  color: var(--primary);
  margin: 3px 0 7px;
}
.so-sched-late { color: var(--warning); }

.so-sched-products {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.so-sched-products li {
  font-size: 11px;
  color: var(--text);
  background: var(--surface-alt);
  border-radius: 5px;
  padding: 4px 6px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.so-sched-qty { color: var(--text-muted); }
.so-sched-meta { font-size: 11px; color: var(--text-muted); }

.so-sched-problems {
  margin-top: 7px;
  background: var(--danger-bg);
  border-radius: 6px;
  padding: 7px 8px;
}
.so-sched-problems-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #991b1b;
  margin-bottom: 3px;
}
.so-sched-problems ul { margin: 0; padding-left: 15px; }
.so-sched-problems li { font-size: 11px; color: #991b1b; line-height: 1.4; }

.so-sched-actions { display: flex; gap: 6px; margin-top: 9px; }
.so-sched-btn {
  flex: 1;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.so-sched-btn:hover:not(:disabled) { background: var(--surface-alt); }
.so-sched-btn:disabled { opacity: 0.55; cursor: default; }
.so-sched-btn-danger { color: var(--danger); border-color: #fecaca; }
.so-sched-btn-danger:hover:not(:disabled) { background: var(--danger-bg); }

/* Status pills */
.so-sb {
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  padding: 2px 6px;
  border-radius: 999px;
  white-space: nowrap;
  flex-shrink: 0;
}
.so-sb-wait { background: var(--info-bg); color: #1e40af; }
.so-sb-send { background: var(--warning-bg); color: #92400e; }
.so-sb-ok { background: var(--success-bg); color: #065f46; }
.so-sb-warn { background: #ffedd5; color: #9a3412; }
.so-sb-fail { background: var(--danger-bg); color: #991b1b; }
.so-sb-cancel { background: var(--surface-alt); color: var(--text-muted); }

/* Date + time + zone row in the timing step */
.so-sched-inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 4px;
}
.so-sched-preview {
  margin-top: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--primary);
}
.so-sched-note {
  margin-top: 8px;
  font-size: 11px;
  line-height: 1.5;
  color: var(--text-muted);
  background: var(--surface-alt);
  border-radius: 6px;
  padding: 8px 10px;
}

@media (max-width: 1080px) {
  .so-layout { grid-template-columns: minmax(0, 1fr); }
  .so-side { position: static; max-height: none; order: -1; }
}

/* ============ SCHEDULED ORDER: EDIT MODE + HISTORY ============ */
/* Editing reuses the normal Send Order form, so this banner is what tells you the
   save will replace an existing order rather than create a second one. */
.so-edit-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--warning-bg);
  border: 1px solid var(--warning);
  border-radius: var(--radius-md, 8px);
  padding: 11px 14px;
  margin-bottom: 16px;
}
.so-edit-banner-text {
  flex: 1;
  font-size: 12px;
  line-height: 1.5;
  color: #92400e;
  font-weight: 500;
}
.so-edit-banner-btn {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  padding: 5px 10px;
  border: 1px solid var(--warning);
  border-radius: 6px;
  background: var(--surface);
  color: #92400e;
  cursor: pointer;
}
.so-edit-banner-btn:hover { background: #fff7ed; }

.so-sched-who {
  font-size: 10px;
  color: var(--text-light);
  margin-top: 6px;
  line-height: 1.4;
}

.so-sched-history-toggle {
  margin-top: 8px;
  background: none;
  border: none;
  padding: 0;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  text-decoration: underline;
}
.so-sched-history-toggle:hover { color: var(--text); }

.so-sched-history {
  margin-top: 8px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.so-sched-hist-loading { font-size: 11px; color: var(--text-muted); }
.so-sched-hist-row {
  font-size: 11px;
  line-height: 1.45;
  border-left: 2px solid var(--border-strong);
  padding-left: 8px;
}
.so-sched-hist-head {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}
.so-sched-hist-action { font-weight: 700; color: var(--text); }
.so-sched-hist-when { color: var(--text-light); white-space: nowrap; }
.so-sched-hist-actor { color: var(--text-muted); }
.so-sched-hist-note { color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }
.so-sched-hist-changes {
  margin: 3px 0 0;
  padding-left: 15px;
  color: var(--text-muted);
}
.so-sched-hist-changes li { margin-bottom: 2px; overflow-wrap: anywhere; }
.so-sched-hist-changes s { opacity: 0.7; }
.so-sched-hist-changes b { color: var(--text); }
