/* ─── Design System: Therasoft AI v2 tokens ─── */
:root {
  /* Core Brand */
  --color-brand-primary:            #094CB0;
  --color-brand-primary-hover:      #0741A0;
  --color-brand-primary-light:      #E0EBFF;
  --color-brand-primary-opacity70:  rgba(9, 76, 176, 0.70);
  --color-brand-pressed-stroke:     rgba(48, 121, 230, 0.75);
  --color-brand-hovered-overlay:    rgba(215, 231, 255, 0.45);

  /* Surface Hierarchy */
  --surface-page:                   #F4F6FA;
  --surface-sidebar:                #EEF1F8;
  --surface-card:                   #FFFFFF;
  --surface-card-subtle:            #FBFBFB;
  --surface-overlay:                rgba(5, 41, 94, 0.40);
  --surface-skeleton:               #E8ECF3;
  --surface-skeleton-shimmer:       #F2F5FA;

  /* Typography */
  --text-heading:                   #05295E;
  --text-subheading:                #094CB0;
  --text-primary:                   #0A0A0A;
  --text-secondary:                 #292929;
  --text-muted:                     #5E6E85;
  --text-placeholder:               #A0AEBF;
  --text-disabled:                  #B0BAC8;
  --text-on-brand:                  #F5F5F5;
  --text-link:                      #094CB0;
  --text-link-hover:                #05295E;
  --text-caption:                   #6B7A8F;

  /* Borders & Dividers */
  --border-strong:                  #9CB0CF;
  --border-subtle:                  #E6E6E6;
  --border-focus:                   #094CB0;
  --border-focus-ring:              rgba(9, 76, 176, 0.30);
  --border-error:                   #C0392B;
  --border-disabled:                #C6CBD0;

  /* Interactive States */
  --state-hover-bg:                 #ECF8FF;
  --state-hover-blue:               #E0EBFF;
  --state-active:                   #D3E2FF;
  --state-focus-bg:                 #EBF2FF;
  --state-disabled-bg:              #C6CBD0;
  --state-required-bg:              rgba(150, 229, 122, 0.16);
  --state-pressed:                  rgba(48, 121, 230, 0.75);

  /* Semantic Status */
  --status-success-bg:              #9DE0B0;
  --status-success-text:            #0D462C;
  --status-success-icon:            #8AC98A;
  --status-success-border:          #6BCB8B;
  --status-warning-bg:              #F5EEA8;
  --status-warning-text:            #754703;
  --status-warning-border:          #E0D060;
  --status-error-bg:                #FFE5E5;
  --status-error-text:              #7F312C;
  --status-error-icon:              #FF8095;
  --status-error-border:            #C0392B;
  --status-info-bg:                 #E8F1FF;
  --status-info-text:               #465D81;
  --status-info-border:             #9CB0CF;
  --status-critical-bg:             #FFF0F0;
  --status-critical-text:           #8B0000;
  --status-critical-border:         #D9534F;

  /* Appointment Status */
  --appt-pending-bg:                #FFA3A3;
  --appt-pending-text:              #5C0A0A;
  --appt-confirmed-bg:              #BFDDCF;
  --appt-confirmed-text:            #0D3D22;
  --appt-in-progress-bg:            #D3E2FF;
  --appt-in-progress-text:          #05295E;
  --appt-finished-bg:               #95C6FF;
  --appt-finished-text:             #05295E;
  --appt-cancelled-bg:              #E8E8E8;
  --appt-cancelled-text:            #4A4A4A;
  --appt-no-show-bg:                #FFE0B2;
  --appt-no-show-text:              #7A3B00;
  --appt-waitlisted-bg:             #EDE7F6;
  --appt-waitlisted-text:           #4A148C;
  --appt-rejected-bg:               #FDC064;
  --appt-rejected-text:             #5C3200;

  /* Client Status */
  --client-active-bg:               #BFDDCF;
  --client-active-text:             #0D3D22;
  --client-inactive-bg:             #F1F1F1;
  --client-inactive-text:           #4A4A4A;
  --client-new-bg:                  #E8F1FF;
  --client-new-text:                #05295E;

  /* Billing Status */
  --billing-paid-bg:                #D4EDDA;
  --billing-paid-text:              #0D462C;
  --billing-pending-bg:             #FFF3CD;
  --billing-pending-text:           #754703;
  --billing-overdue-bg:             #FFE5E5;
  --billing-overdue-text:           #7F312C;
  --billing-denied-bg:              #F8D7DA;
  --billing-denied-text:            #721C24;
  --billing-submitted-bg:           #E8F1FF;
  --billing-submitted-text:         #465D81;

  /* Priority */
  --priority-low-bg:                #E8F5E9;
  --priority-low-text:              #1B5E20;
  --priority-medium-bg:             #FFF8E1;
  --priority-medium-text:           #754703;
  --priority-high-bg:               #FFE0B2;
  --priority-high-text:             #7A3B00;
  --priority-critical-bg:           #FFEBEE;
  --priority-critical-text:         #8B0000;

  /* Data Visualization */
  --chart-1:                        #094CB0;
  --chart-2:                        #4A9FD4;
  --chart-3:                        #6BCB8B;
  --chart-4:                        #FDC064;
  --chart-5:                        #9B8EC4;
  --chart-6:                        #F4A261;
  --chart-grid:                     #E6E6E6;
  --chart-axis-label:               #6B7A8F;

  /* Utility */
  --color-white:                    #FFFFFF;

  /* Legacy aliases (mapped to new tokens) */
  --navy: #05295E;
  --navy-dark: #031B3F;
  --navy-light: #094CB0;
  --blue: #094CB0;
  --blue-light: #4A9FD4;
  --blue-wash: var(--state-hover-blue);
  --green: #28A745;
  --green-light: #6BCB8B;
  --green-wash: var(--status-success-bg);
  --surface: var(--surface-page);
  --card: var(--surface-card);
  --text: var(--text-primary);
  --text-secondary-legacy: var(--text-secondary);
  --border: var(--border-subtle);
  --border-light: var(--border-subtle);
  --green-bg: var(--status-success-bg);
  --amber: #E5A100;
  --amber-bg: var(--status-warning-bg);
  --red: #C0392B;
  --red-bg: var(--status-error-bg);
  --blue-bg: var(--status-info-bg);
  --shadow-sm: 0 1px 2px rgba(5, 41, 94, 0.05);
  --shadow-md: 0 2px 8px rgba(5, 41, 94, 0.07);
  --shadow-lg: 0 4px 16px rgba(5, 41, 94, 0.09);
  --radius: 4px;
  --radius-lg: 4px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Roboto', sans-serif;
  background: var(--surface-page);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ─── Login Screen ─── */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #eef1f5;
  position: relative;
  overflow: hidden;
}
.login-screen::before {
  content: none;
}
.login-screen::after {
  content: none;
}
.login-shell {
  position: relative;
  z-index: 1;
  width: 850px;
  max-width: 95vw;
  min-height: 480px;
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface-card);
  border-radius: 20px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.08);
  overflow: hidden;
}
.login-copy {
  flex: 1;
  background: #f8f9fb;
  border-right: 1px solid #e8ecf1;
  color: var(--text-primary);
  max-width: none;
  padding: 48px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}
.login-copy-logo {
  display: none;
}
.login-copy h1 {
  max-width: 360px;
  font-size: 30px;
  line-height: 1.18;
  font-weight: 800;
  color: #0f2d5c;
  margin: 0;
}
.login-copy h1 span {
  display: block;
}
.login-copy p {
  max-width: 360px;
  font-size: 18px;
  line-height: 1.45;
  color: #334155;
  margin: 24px 0 8px;
  font-weight: 600;
}
.login-copy p span {
  display: block;
}
.login-copy p + p {
  font-size: 15px;
  line-height: 1.55;
  color: #475569;
  margin: 0;
  font-weight: 400;
}
.login-trust-badges {
  display: flex;
  gap: 24px;
  margin-top: 32px;
  justify-content: center;
}
.login-trust-badge {
  text-align: center;
  font-size: 10px;
  line-height: 1.2;
  color: #475569;
}
.login-trust-icon {
  font-size: 18px;
  margin-bottom: 2px;
}
.login-trust-badge strong,
.login-trust-badge span {
  display: block;
}
.login-trust-badge strong {
  font-weight: 600;
}
.login-card {
  flex: 1;
  background: var(--surface-card);
  border-radius: 0;
  padding: 48px;
  width: auto;
  box-shadow: none;
  position: relative;
  animation: none;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.login-card-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-card-brand img {
  max-width: 260px;
  width: 100%;
  height: auto;
  margin-bottom: 8px;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.login-card h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 4px;
}
.login-card .subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 0;
}
.login-card .subtitle span {
  color: #2563eb;
  font-weight: 700;
}
.login-card .logo-mark {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--navy), var(--color-brand-primary));
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 24px;
  font-size: 24px; font-weight: 700; color: white;
  letter-spacing: -1px;
}
.form-group { margin-bottom: 18px; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-group input,
.form-group select {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  outline: none;
}
.form-group select {
  background: white;
}
.form-group input:focus,
.form-group select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--border-focus-ring);
}
.login-btn {
  width: 100%;
  padding: 13px;
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
  border: 1px solid var(--color-brand-primary);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  margin-top: 8px;
}
.login-btn:hover { background: var(--color-brand-primary-hover); box-shadow: var(--shadow-md); }
.login-btn:active { background: var(--color-brand-primary); }
.login-btn:disabled { background: var(--state-disabled-bg); border-color: var(--border-disabled); color: var(--text-disabled); cursor: not-allowed; }
.login-card-footer {
  text-align: center;
  margin-top: 18px;
  font-size: 12px;
  color: var(--text-muted);
}
.login-error {
  background: var(--status-error-bg);
  color: var(--status-error-text);
  font-size: 13px;
  padding: 10px 14px;
  border-radius: 4px;
  border-left: 3px solid var(--status-error-border);
  margin-bottom: 16px;
  display: none;
}

/* ─── App Shell ─── */
.app { display: none; min-height: 100vh; }
.app.active { display: flex; flex-direction: column; }
.login-screen.hidden { display: none; }

@media (max-width: 820px) {
  .login-screen {
    align-items: flex-start;
    padding: 40px 0;
  }
  .login-shell {
    width: min(420px, calc(100vw - 32px));
    display: flex;
    flex-direction: column;
    gap: 28px;
  }
  .login-copy {
    max-width: none;
    border-right: 0;
    border-bottom: 1px solid #e8ecf1;
    padding: 32px 24px;
  }
  .login-copy-logo {
    display: none;
  }
  .login-copy h1 {
    font-size: 28px;
    margin-bottom: 14px;
  }
  .login-copy p {
    font-size: 16px;
  }
  .login-card {
    width: 100%;
    padding: 32px 24px;
  }
}

/* ─── Top Bar ─── */
.topbar {
  background: var(--text-heading);
  border-bottom: 1px solid var(--navy-dark);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.topbar-logo {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--navy), var(--color-brand-primary));
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; color: white;
}
.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}
.topbar-title span { font-weight: 400; color: rgba(255,255,255,0.6); margin-left: 6px; font-size: 13px; }
.topbar-right { display: flex; align-items: center; gap: 14px; }
.topbar-user {
  font-size: 13px;
  color: rgba(255,255,255,0.8);
}
.topbar-badge {
  background: rgba(107, 203, 139, 0.2);
  color: var(--status-success-icon);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 4px;
}
.logout-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover {
  border-color: var(--status-error-border);
  color: #fff;
  background: rgba(192,57,43,0.2);
}
.refresh-btn {
  width: 32px;
  height: 32px;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: 4px;
  font-size: 16px;
  color: rgba(255,255,255,0.7);
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.refresh-btn:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
  border-color: rgba(255,255,255,0.4);
}
.refresh-btn.spinning {
  animation: spin 0.8s linear infinite;
  pointer-events: none;
}

/* ─── Nav Tabs ─── */
.nav-tabs {
  display: flex;
  gap: 2px;
  padding: 0 28px;
  background: var(--text-heading);
  border-bottom: 2px solid var(--navy-dark);
}
.nav-tab {
  padding: 12px 20px;
  font-size: 14px;
  font-weight: 400;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
  user-select: none;
}
.nav-tab:hover { color: rgba(255,255,255,0.8); }
.nav-tab.active {
  color: #ffffff;
  border-bottom-color: var(--color-brand-primary);
  font-weight: 600;
}

/* ─── Main Content ─── */
.main { flex: 1; padding: 24px 28px; max-width: 1440px; margin: 0 auto; width: 100%; }

/* ─── App Layout: content + persistent sidebar ─── */
.app-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.app-content { min-width: 0; }

/* ─── Metrics Row ─── */
.dashboard-section-group {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--surface-page);
  margin-bottom: 16px;
}
.dashboard-section {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
}
.dashboard-section:nth-child(even) {
  background: var(--surface-card-subtle);
}
.dashboard-section + .dashboard-section {
  border-top: 1px solid var(--border-subtle);
}
.dashboard-section-label {
  font-size: 13px;
  font-weight: 700;
  color: var(--heading);
  min-width: 85px;
  flex-shrink: 0;
}
.dashboard-section .metrics-row {
  flex: 1;
  margin-bottom: 0;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
}
.dashboard-section .metric-card {
  padding: 10px 12px;
  border: none;
  box-shadow: none;
  background: var(--surface-card);
}
.dashboard-section .metric-card:hover {
  box-shadow: none;
}
.dashboard-section .metric-label {
  font-size: 10px;
  margin-bottom: 4px;
}
.dashboard-section .metric-value {
  font-size: 22px;
}
.metrics-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.metric-card {
  background: var(--surface-card);
  border-radius: 4px;
  padding: 16px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  transition: box-shadow 0.2s;
}
.metric-card:hover {
  box-shadow: var(--shadow-md);
}
.metric-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.metric-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
  margin-bottom: 8px;
}

/* ─── Front Desk - Action Badges ─── */
.fd-action-col {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
}
.fd-action-badge {
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  border-radius: 2px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  cursor: default;
  user-select: none;
}
.fd-action-badge.fd-green  { background: green;  color: white; }
.fd-action-badge.fd-yellow { background: yellow; color: black; }
.fd-action-badge.fd-red    { background: red;    color: white; }
.fd-action-badge.fd-blue   { background: blue;   color: white; }
.fd-action-badge.fd-orange { background: orange; color: black; }
.fd-action-badge.fd-gray   { background: gray;   color: black; }

.metric-compare {
  display: flex;
  align-items: center;
  gap: 6px;
}
.metric-bar-wrap {
  flex: 1;
  display: flex;
  gap: 3px;
  align-items: flex-end;
  height: 20px;
}
.metric-bar {
  flex: 1;
  border-radius: 3px;
  min-height: 4px;
  position: relative;
}
.metric-bar.current { background: var(--navy); }
.metric-bar.prev { background: var(--border); }
.metric-bar-label {
  font-size: 10px;
  color: var(--text-muted);
}
.metric-delta {
  font-size: 12px;
  font-weight: 600;
}
.metric-delta.up { color: var(--status-success-text); }
.metric-delta.down { color: var(--status-error-text); }

.marketing-kpi-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.marketing-kpi-row-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
}
.marketing-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.marketing-metric-card {
  cursor: default;
  min-height: 136px;
}
.marketing-metric-proxy {
  background: var(--surface-card-subtle);
  border-style: dashed;
}
.marketing-metric-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.marketing-metric-note {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}
.marketing-story-card {
  padding: 18px;
}
.marketing-bullet-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-primary);
}
.marketing-bullet-list li {
  margin-bottom: 8px;
}
.marketing-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.billing-kpi-stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.billing-kpi-row-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.45px;
}
.billing-kpi-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
}
.billing-metric-card {
  cursor: default;
  min-height: 136px;
}
.billing-metric-proxy {
  background: var(--surface-card-subtle);
  border-style: dashed;
}
.billing-metric-meta {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
}
.billing-metric-note {
  font-size: 11px;
  line-height: 1.35;
  color: var(--text-muted);
}
.billing-story-card {
  padding: 18px;
}
.billing-bullet-list {
  margin: 0;
  padding-left: 18px;
  color: var(--text-primary);
}
.billing-bullet-list li {
  margin-bottom: 8px;
}
.billing-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}


@media (max-width: 1400px) {
  .marketing-kpi-grid,
  .billing-kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .marketing-kpi-grid,
  .billing-kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .marketing-kpi-grid,
  .billing-kpi-grid { grid-template-columns: 1fr; }
}

/* ─── Content Grid ─── */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

/* ─── Location Selector (Persistent across all tabs) ─── */
.location-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}
.location-select {
  flex: 1;
  max-width: 360px;
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 400;
  color: var(--text-primary);
  background: var(--surface-card);
  cursor: pointer;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%235E6E85' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}
.location-select:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--border-focus-ring);
}
.location-stats {
  font-size: 12px;
  color: var(--text-muted);
}

/* Time scope toggle */
.time-scope-group {
  display: flex;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  overflow: hidden;
}
.time-scope-btn {
  padding: 6px 16px;
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface-card);
  border: none;
  border-right: 1px solid var(--border-subtle);
  cursor: pointer;
  transition: all 0.15s;
}
.time-scope-btn:last-child { border-right: none; }
.time-scope-btn:hover { background: var(--state-hover-bg); color: var(--text-primary); }
.time-scope-btn.active {
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
}

/* ─── Panel ─── */
.panel {
  background: var(--surface-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.panel-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}
.panel-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}
.panel-body { padding: 16px; }

/* ─── Data Table ─── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.data-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border-strong);
}
.data-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}
.data-table tbody tr:nth-child(even) td { background: var(--surface-card-subtle); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--state-hover-bg); }

/* ─── Status Badges ─── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  line-height: 16px;
}
.badge-green { background: var(--status-success-bg); color: var(--status-success-text); }
.badge-amber { background: var(--status-warning-bg); color: var(--status-warning-text); }
.badge-red { background: var(--status-error-bg); color: var(--status-error-text); }
.badge-blue { background: var(--status-info-bg); color: var(--status-info-text); }
.badge-gray { background: var(--appt-cancelled-bg); color: var(--appt-cancelled-text); }

/* ─── Micro Bar ─── */
.micro-bar-wrap {
  width: 80px; height: 6px;
  background: var(--border-light);
  border-radius: 3px;
  overflow: hidden;
  display: inline-block;
  vertical-align: middle;
  margin-right: 6px;
}
.micro-bar {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease-out;
}

/* ─── Charts ─── */
.chart-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
}
.chart-card {
  background: var(--surface-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  height: 300px;
  overflow: hidden;
}
.chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  margin-bottom: 12px;
}
.chart-wrap {
  position: relative;
  height: 240px;
}

/* ─── JazClaw Layout ─── */
.jc-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 20px;
  margin-top: 20px;
}
.jc-main { min-width: 0; }
.jc-sidebar {
  position: sticky;
  top: 140px;
  align-self: start;
}
.jc-chat-panel {
  background: var(--surface-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  height: calc(100vh - 200px);
  min-height: 500px;
}
.jc-chat-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 600;
  color: var(--text-heading);
  display: flex;
  align-items: center;
  gap: 8px;
}
.jc-chat-header .status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--status-success-icon);
}
.jc-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}
.jc-msg {
  margin-bottom: 12px;
  font-size: 14px;
  line-height: 1.5;
}
.jc-msg-bot {
  background: var(--surface-page);
  border-radius: 4px;
  padding: 8px 12px;
  color: var(--text-primary);
}
.jc-msg-user {
  background: var(--color-brand-primary);
  border-radius: 4px;
  padding: 8px 12px;
  color: var(--text-on-brand);
  margin-left: 40px;
}
.jc-msg-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.jc-suggestions {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.jc-suggestions .chip {
  font-size: 12px;
  padding: 4px 8px;
}
.jc-chat-input {
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  gap: 8px;
}
.jc-chat-input input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.jc-chat-input input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--border-focus-ring);
}
.jc-chat-input button {
  padding: 8px 16px;
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
  border: 1px solid var(--color-brand-primary);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.jc-chat-input button:hover {
  background: var(--color-brand-primary-hover);
}
.jc-agent-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
@media (max-width: 1100px) {
  .jc-layout { grid-template-columns: 1fr; }
  .jc-chat-panel { height: 400px; min-height: 400px; }
  .jc-agent-grid .panel > div { flex-wrap: wrap; }
}

/* ─── AI Command Bar ─── */
.command-bar {
  margin-bottom: 24px;
  position: relative;
}
.command-input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-card);
  box-shadow: var(--shadow-sm);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.command-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--border-focus-ring);
}
.command-input::placeholder { color: var(--text-placeholder); }
.command-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-brand-primary);
  font-size: 16px;
}
.command-chips {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  flex-wrap: wrap;
}
.chip {
  padding: 4px 12px;
  background: var(--state-hover-blue);
  color: var(--text-heading);
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
  user-select: none;
}
.chip:hover { background: var(--state-active); }

/* ─── Alerts Feed ─── */
.alert-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 4px;
  margin-bottom: 8px;
  font-size: 14px;
}
.alert-item.alert-red { background: var(--status-error-bg); border-left: 3px solid var(--status-error-border); }
.alert-item.alert-amber { background: var(--status-warning-bg); border-left: 3px solid var(--status-warning-border); }
.alert-item.alert-blue { background: var(--status-info-bg); border-left: 3px solid var(--status-info-border); }
.alert-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 5px;
  flex-shrink: 0;
}
.alert-red .alert-dot { background: var(--status-error-border); }
.alert-amber .alert-dot { background: var(--status-warning-border); }
.alert-blue .alert-dot { background: var(--color-brand-primary); }
.alert-text { flex: 1; color: var(--text-primary); }
.alert-action {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-link);
  cursor: pointer;
  white-space: nowrap;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}
.alert-action:hover { background: var(--state-hover-blue); }

/* ─── Note Summary Panel (Clinical tab) ─── */
.note-pencil-btn {
  width: 24px; height: 24px;
  background: var(--state-active);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.note-pencil-btn:hover { background: var(--color-brand-primary-light); }
.note-summary-row td { background: var(--surface-card-subtle); }
.note-summary-panel {
  padding: 16px;
  border-left: 3px solid var(--color-brand-primary);
  margin: 0;
}
.note-summary-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 8px;
}
.note-summary-close {
  background: none; border: none; font-size: 16px;
  color: var(--text-muted); cursor: pointer; padding: 4px 8px;
}
.note-summary-close:hover { color: var(--text-primary); }
.note-summary-input {
  width: 100%;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-primary);
  background: var(--surface-card);
  resize: vertical;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.note-summary-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 4px var(--border-focus-ring);
}
.note-summary-input::placeholder { color: var(--text-placeholder); }
.note-summary-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 8px;
}
.note-summary-hint {
  font-size: 12px; color: var(--text-muted);
}
.note-dictate-btn {
  display: flex; align-items: center; gap: 4px;
  padding: 6px 12px;
  background: var(--surface-card);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 12px; font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}
.note-dictate-btn:hover { background: var(--state-hover-bg); border-color: var(--color-brand-primary); }
.note-dictate-btn.recording {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error-text);
}
.note-generate-btn {
  padding: 6px 16px;
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
  border: 1px solid var(--color-brand-primary);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 12px; font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}
.note-generate-btn:hover { background: var(--color-brand-primary-hover); }

/* ─── Recent Sessions - Action Circles ─── */
.rs-action-col {
  display: flex;
  gap: 4px;
  align-items: center;
}
.rs-action-circle {
  min-width: 20px;
  height: 18px;
  padding: 0 4px;
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
  line-height: 1;
  cursor: default;
  flex-shrink: 0;
  user-select: none;
}
.rs-action-circle.rs-green  { background: green;  color: white; }
.rs-action-circle.rs-yellow { background: yellow; color: black; }
.rs-action-circle.rs-red    { background: red;    color: white; }
.rs-action-circle.rs-blue   { background: blue;   color: white; }
.rs-action-circle.rs-orange { background: orange; color: black; }
.rs-action-circle.rs-gray   { background: gray;   color: black; }
.rs-session-row:hover td {
  background: var(--state-hover-bg);
}

/* ─── Clinical Review Queue ─── */
.clinical-review-panel {
  margin-top: 20px;
}
.clinical-review-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.clinical-review-summary-card {
  background: var(--surface-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px;
}
.clinical-review-summary-card .label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.clinical-review-summary-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
}
.clinical-review-summary-card .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.clinical-review-group {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--surface-card-subtle);
  margin-bottom: 12px;
  overflow: hidden;
}
.clinical-review-group:last-child {
  margin-bottom: 0;
}
.clinical-review-group-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
}
.clinical-review-group-summary::-webkit-details-marker {
  display: none;
}
.clinical-review-group-summary:hover {
  background: var(--state-hover-bg);
}
.clinical-review-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
}
.clinical-review-group-chevron {
  font-size: 12px;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}
.clinical-review-group[open] .clinical-review-group-chevron {
  transform: rotate(90deg);
}
.clinical-review-group-body {
  padding: 0 16px 16px;
}
.clinical-review-group-count {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}
.clinical-review-row {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.clinical-review-row:last-child {
  margin-bottom: 0;
}
.clinical-review-row-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.clinical-review-client-btn {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-link);
  cursor: pointer;
  text-align: left;
}
.clinical-review-client-btn:hover {
  color: var(--text-link-hover);
}
.clinical-review-row-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.clinical-review-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}
.clinical-review-cell {
  background: var(--surface-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 10px;
  min-width: 0;
}
.clinical-review-cell-wide {
  grid-column: span 2;
}
.clinical-review-cell-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.clinical-review-cell-value {
  font-size: 13px;
  color: var(--text-primary);
}
.clinical-review-cell-value-muted {
  color: var(--text-muted);
}
.clinical-review-subtext {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}
.clinical-review-state {
  border-radius: 4px;
  padding: 16px;
  border: 1px solid var(--border-subtle);
}
.clinical-review-state.pending {
  background: var(--status-warning-bg);
  border-color: var(--status-warning-border);
}
.clinical-review-state.error {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
}
.clinical-review-state.info {
  background: var(--status-info-bg);
  border-color: var(--status-info-border);
}
.clinical-review-state-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-heading);
  margin-bottom: 6px;
}
.clinical-review-state-copy {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
}
.clinical-review-state-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 8px;
}
.clinical-review-empty {
  padding: 14px;
  background: var(--surface-card);
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  font-size: 13px;
  color: var(--text-muted);
}
.clinical-review-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 41, 94, 0.40);
  z-index: 220;
  display: flex;
  justify-content: flex-end;
  padding: 16px;
}
.clinical-review-drawer {
  width: min(720px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin-top: 56px;
  background: var(--surface-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.clinical-review-drawer-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.clinical-review-drawer-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subheading);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}
.clinical-review-drawer-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
}
.clinical-review-drawer-meta {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.clinical-review-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
}
.clinical-review-drawer-close:hover {
  color: var(--text-primary);
  background: var(--state-hover-bg);
}
.clinical-review-drawer-body {
  overflow-y: auto;
  padding: 20px 24px 24px;
}
.clinical-review-drawer-banner {
  border: 1px solid var(--status-info-border);
  background: var(--status-info-bg);
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.clinical-review-drawer-flash {
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  margin-bottom: 16px;
  border: 1px solid var(--border-subtle);
}
.clinical-review-drawer-flash.success {
  background: var(--status-success-bg);
  border-color: var(--status-success-border);
  color: var(--status-success-text);
}
.clinical-review-drawer-flash.error {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error-text);
}
.clinical-review-drawer-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}
.clinical-review-drawer-summary-card {
  background: var(--surface-card-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px;
}
.clinical-review-drawer-summary-card .label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.clinical-review-drawer-summary-card .value {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
}
.clinical-review-drawer-summary-card .sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
}
.clinical-review-detail-section {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--surface-card-subtle);
}
.clinical-review-detail-section:last-child {
  margin-bottom: 0;
}
.clinical-review-detail-section-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 14px;
}
.clinical-review-detail-section-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}
.clinical-review-detail-section-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.clinical-review-detail-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.clinical-review-action-btn {
  padding: 8px 12px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-card);
  color: var(--text-primary);
  font-family: 'Roboto', sans-serif;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.clinical-review-action-btn:hover {
  background: var(--state-hover-bg);
}
.clinical-review-action-btn.primary {
  background: var(--color-brand-primary);
  border-color: var(--color-brand-primary);
  color: var(--text-on-brand);
}
.clinical-review-action-btn.primary:hover {
  background: var(--color-brand-primary-hover);
}
.clinical-review-action-btn.danger {
  border-color: var(--status-error-border);
  color: var(--status-error-text);
  background: var(--status-error-bg);
}
.clinical-review-action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}
.clinical-review-detail-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.clinical-review-detail-fact {
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  background: var(--surface-card);
  padding: 10px 12px;
}
.clinical-review-detail-fact-label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 6px;
}
.clinical-review-detail-fact-value {
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
}
.clinical-review-rich-text {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 14px;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.6;
  white-space: pre-wrap;
}
.clinical-review-callout {
  margin-top: 12px;
  border-radius: 4px;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.5;
  border: 1px solid var(--border-subtle);
}
.clinical-review-callout.info {
  background: var(--status-info-bg);
  border-color: var(--status-info-border);
  color: var(--text-secondary);
}
.clinical-review-callout.warn {
  background: var(--status-warning-bg);
  border-color: var(--status-warning-border);
  color: var(--status-warning-text);
}
.clinical-review-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}
.clinical-review-list-item {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px 14px;
}
.clinical-review-list-item-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.clinical-review-list-item-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.clinical-review-list-item-copy {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 8px;
  line-height: 1.5;
}
.clinical-review-kv-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.clinical-review-kv-row {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 12px;
  font-size: 13px;
}
.clinical-review-kv-row dt {
  color: var(--text-muted);
  font-weight: 600;
}
.clinical-review-kv-row dd {
  color: var(--text-primary);
}
.clinical-review-inline-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.clinical-review-inline-copy {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-top: 12px;
}
.clinical-review-progress-counts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.clinical-review-progress-count {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 12px;
  text-align: center;
}
.clinical-review-progress-count .count {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
}
.clinical-review-progress-count .label {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 6px;
  letter-spacing: 0.4px;
}
@media (max-width: 1100px) {
  .clinical-review-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .clinical-review-cell-wide {
    grid-column: span 2;
  }
  .clinical-review-drawer {
    width: min(680px, calc(100vw - 24px));
    margin-top: 24px;
  }
}
@media (max-width: 700px) {
  .clinical-review-grid {
    grid-template-columns: 1fr;
  }
  .clinical-review-cell-wide {
    grid-column: span 1;
  }
  .clinical-review-row-header,
  .clinical-review-group-summary {
    flex-direction: column;
    align-items: flex-start;
  }
  .clinical-review-drawer-overlay {
    padding: 8px;
  }
  .clinical-review-drawer {
    width: 100%;
    max-height: calc(100vh - 16px);
    margin-top: 0;
  }
  .clinical-review-drawer-header,
  .clinical-review-detail-section-header {
    flex-direction: column;
    align-items: flex-start;
  }
  .clinical-review-drawer-body {
    padding: 16px;
  }
  .clinical-review-detail-grid,
  .clinical-review-progress-counts {
    grid-template-columns: 1fr;
  }
  .clinical-review-kv-row {
    grid-template-columns: 1fr;
    gap: 4px;
  }
}

/* ─── Loading States ─── */
.loading-overlay {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-muted);
  font-size: 14px;
}
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--border-subtle);
  border-top-color: var(--color-brand-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-right: 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Responsive ─── */
@media (max-width: 1100px) {
  .chart-grid { grid-template-columns: 1fr; }
  .app-layout { grid-template-columns: 1fr; }
  .jc-assistant { position: static; min-height: auto; }
  .jc-layout { grid-template-columns: 1fr; }
  .dashboard-section {
    flex-direction: column;
    align-items: stretch;
  }
  .dashboard-section-label {
    min-width: 0;
  }
  .dashboard-section .metrics-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .jc-location-bar {
    flex-wrap: wrap;
    align-items: stretch;
  }
  .jc-location-select,
  .clinician-select {
    min-width: 0;
    width: 100%;
  }
  .agent-card {
    grid-template-columns: 1fr;
  }
  .agent-stats {
    flex-wrap: wrap;
    gap: 12px;
  }
}
@media (max-width: 700px) {
  .topbar {
    height: auto;
    min-height: 56px;
    padding: 10px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar-right {
    width: 100%;
    justify-content: flex-end;
    flex-wrap: wrap;
  }
  .topbar-title span,
  .topbar-user {
    display: none;
  }
  .nav-tabs {
    padding: 0 12px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }
  .nav-tab {
    flex: 0 0 auto;
    padding: 12px 16px;
  }
  .main {
    padding: 16px 12px;
  }
  .panel-header {
    flex-wrap: wrap;
    gap: 8px;
    align-items: flex-start;
  }
  .metrics-row,
  .dashboard-section .metrics-row {
    grid-template-columns: 1fr;
  }
  .panel-body {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .data-table {
    min-width: 640px;
    font-size: 13px;
  }
  .data-table th,
  .data-table td {
    padding: 8px 10px;
  }
  .agent-card {
    padding: 16px;
  }
}
/* ─── JazClaw Tab Layout ─── */
.jc-layout {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
  align-items: start;
}
.jc-main { min-width: 0; }

/* Location bar */
.jc-location-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.jc-location-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 6px 12px;
  background: var(--surface);
  border-radius: 4px;
}
.jc-location-select {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-card);
  min-width: 260px;
  outline: none;
}
.jc-location-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 4px var(--border-focus-ring); }
.clinician-select {
  padding: 8px 14px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-card);
  min-width: 200px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.clinician-select:focus { border-color: var(--border-focus); box-shadow: 0 0 0 4px var(--border-focus-ring); }
.jc-location-summary {
  font-size: 13px;
  color: var(--text-muted);
}

/* Agent status cards */
.agent-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px 24px;
  margin-bottom: 12px;
  display: grid;
  grid-template-columns: 200px 1fr auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}
.agent-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.agent-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}
.agent-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 600;
  width: fit-content;
  line-height: 16px;
}
.agent-badge.green { background: var(--status-success-bg); color: var(--status-success-text); }
.agent-badge.amber { background: var(--status-warning-bg); color: var(--status-warning-text); }
.agent-badge.red { background: var(--status-error-bg); color: var(--status-error-text); }
.agent-hero {
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
}
.agent-hero-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.agent-stats {
  display: flex;
  gap: 20px;
  font-size: 12px;
  color: var(--text-secondary);
}
.agent-stat-val {
  font-size: 14px;
  font-weight: 500;
  display: block;
}
.agent-stat-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.agent-right {
  display: flex;
  gap: 20px;
  align-items: center;
  font-size: 12px;
  color: var(--text-secondary);
}
.agent-kpi-label { font-size: 11px; color: var(--text-muted); }
.agent-kpi-val {
  font-weight: 600;
}
.agent-kpi-val.green { color: var(--status-success-text); }
.agent-kpi-val.amber { color: var(--status-warning-text); }
.agent-kpi-val.red { color: var(--status-error-text); }
.agent-uptime {
  font-size: 14px;
  font-weight: 600;
  color: var(--status-success-text);
}

/* JazClaw KPI row */
.jc-kpis {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 16px 0;
}
.jc-kpi {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
}
.jc-kpi-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.jc-kpi-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1;
  margin-bottom: 6px;
}
.jc-kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}
.jc-kpi-sub .green { color: var(--status-success-text); font-weight: 600; }
.jc-kpi-sub .red { color: var(--status-error-text); font-weight: 600; }
.jc-kpi-sub .amber { color: var(--status-warning-text); font-weight: 600; }

/* Proactive intelligence section */
.jc-proactive-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
  margin-top: 24px;
  margin-bottom: 4px;
}
.jc-proactive-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* JazClaw — AI Operations Manager sidebar */
.jc-assistant {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  box-shadow: var(--shadow-sm);
  padding: 16px;
  position: sticky;
  top: 130px;
  min-height: 580px;
  display: flex;
  flex-direction: column;
}
.jc-assistant-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 16px;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-heading);
}
.jc-assistant-dot {
  width: 8px; height: 8px;
  background: var(--status-success-icon);
  border-radius: 50%;
}
.jc-chat-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}
.jc-chat-bubble {
  background: var(--surface-page);
  border-radius: 4px;
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text-primary);
  line-height: 1.5;
  margin-bottom: 16px;
}
.jc-chat-bubble strong { font-weight: 600; }
.jc-chat-messages {
  flex: 1;
  overflow-y: auto;
  margin-bottom: 12px;
  max-height: 400px;
  min-height: 200px;
  padding-right: 4px;
}
.jc-chat-messages::-webkit-scrollbar { width: 4px; }
.jc-chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.jc-msg {
  font-size: 14px;
  line-height: 1.5;
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 8px;
  max-width: 95%;
}
.jc-msg-assistant {
  background: var(--surface-page);
  color: var(--text-primary);
}
.jc-msg-assistant strong { font-weight: 600; }
.jc-msg-user {
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
  margin-left: auto;
  text-align: right;
}
.jc-msg-loading {
  display: flex;
  align-items: center;
  background: var(--surface-page);
  padding: 8px 12px;
}
.jc-quick-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 16px;
  flex: 1;
  align-content: flex-start;
}
.jc-quick-chip {
  padding: 4px 12px;
  background: var(--surface-page);
  border: 1px solid var(--border-subtle);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}
.jc-quick-chip:hover {
  background: var(--state-hover-blue);
  border-color: var(--color-brand-primary);
  color: var(--text-heading);
}
.jc-input-row {
  display: flex;
  gap: 8px;
}
.jc-input {
  flex: 1;
  padding: 8px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  outline: none;
}
.jc-input:focus { border-color: var(--border-focus); box-shadow: 0 0 0 4px var(--border-focus-ring); }
.jc-input::placeholder { color: var(--text-placeholder); }
.jc-send-btn {
  padding: 8px 16px;
  background: var(--color-brand-primary);
  color: var(--text-on-brand);
  border: 1px solid var(--color-brand-primary);
  border-radius: 4px;
  font-family: 'Roboto', sans-serif;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.jc-send-btn:hover { background: var(--color-brand-primary-hover); }

@media (max-width: 1100px) {
  .jc-layout { grid-template-columns: 1fr; }
  .jc-assistant { position: static; }
  .agent-card { grid-template-columns: 1fr; }
}

/* ── Intake Detail Drawer ── */
.intake-drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 41, 94, 0.40);
  z-index: 220;
  display: flex;
  justify-content: flex-end;
  padding: 16px;
}
.intake-drawer {
  width: min(520px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  margin-top: 56px;
  background: var(--surface-card);
  border-radius: 4px;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.intake-drawer-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}
.intake-drawer-eyebrow {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subheading);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.intake-drawer-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-heading);
}
.intake-drawer-meta {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.5;
}
.intake-drawer-close {
  background: none;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  flex-shrink: 0;
}
.intake-drawer-close:hover {
  color: var(--text-primary);
  background: var(--state-hover-bg);
}
.intake-drawer-body {
  overflow-y: auto;
  padding: 18px 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.intake-drawer-field-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-subheading);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.intake-drawer-field-value {
  font-size: 13px;
  color: var(--text-primary);
}
.intake-drawer-field-value.muted {
  color: var(--text-muted);
  font-style: italic;
}
.intake-drawer-message-box {
  font-size: 13px;
  color: var(--text-primary);
  white-space: pre-wrap;
  line-height: 1.6;
  padding: 12px 14px;
  background: var(--bg-secondary);
  border-left: 3px solid var(--blue);
  border-radius: 0 4px 4px 0;
}
.intake-drawer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px 16px;
}
.intake-queue-row { cursor: pointer; }
.intake-queue-row:hover td { background: var(--state-hover-bg); }
@media (max-width: 700px) {
  .intake-drawer { width: calc(100vw - 32px); }
}
