/*
  SurgiLog Pro v2 - Accessible Medical Design System
  Compliant with WCAG 2.2 Level AA (Contrast Ratio >= 4.5:1 for text)
*/

:root {
  color-scheme: light;
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;

  /* WCAG AA Compliant Text & Brand Colors (Contrast >= 4.5:1 on #ffffff) */
  --primary: #0f766e;
  --primary-hover: #115e59;
  
  --text-main: #0f172a;
  --text-muted: #475569;

  --danger: #b91c1c;
  --success: #15803d;
  --warning: #b45309;

  /* Clinical Semantic Palette (WCAG AA >= 4.5:1 on #ffffff) */
  --clinical-ned: #15803d;
  --clinical-due: #2563eb;
  --clinical-pending: #b45309;
  --clinical-urgent: #b91c1c;
  --clinical-neutral: #475569;

  /* Surfaces & Backgrounds */
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-elevated: #ffffff;
  --border: #cbd5e1;
  --border-focus: #0f766e;

  /* Tint & High-Contrast Helpers (Used for backgrounds, borders, or on dark) */
  --tint-teal: #ccfbf1;
  --tint-red: #fee2e2;
  --tint-green: #dcfce7;
  --tint-amber: #fef3c7;
  --tint-blue: #dbeafe;
  --btn-on-teal: #ffffff;
  --color-on-dark: #f8fafc;

  /* Aliases for backwards compatibility */
  --primary-light: var(--tint-teal);
  --primary-contrast: var(--btn-on-teal);
  --text-on-dark: var(--color-on-dark);
  --danger-light: var(--tint-red);
  --success-light: var(--tint-green);
  --warning-light: var(--tint-amber);

  /* Structure, Radius & Elevation */
  --radius: 8px;
  --radius-sm: 4px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -2px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -4px rgba(0,0,0,0.1);
  --touch-target: 44px;
}

[data-theme="dark"] {
  color-scheme: dark;
  --bg-main: #090d16;
  --bg-card: #131b2e;
  --bg-elevated: #1e293b;
  --border: #334155;
  --border-focus: #14b8a6;
  
  --text-main: #f8fafc;
  --text-muted: #cbd5e1;
  
  --primary: #14b8a6;
  --primary-hover: #2dd4bf;
  --primary-light: #134e4a;
  --primary-contrast: #0f172a;

  /* Semantic Alert Colors in Dark Mode */
  --danger: #f87171;
  --success: #34d399;
  --warning: #fbbf24;

  /* Clinical Semantic Palette for Dark Mode (Luminous & High Contrast WCAG AAA >= 7:1) */
  --clinical-ned: #34d399;       /* Emerald 400 - Sáng rõ rực rỡ */
  --clinical-due: #60a5fa;       /* Blue 400 - Nổi bật, dễ đọc */
  --clinical-pending: #fbbf24;   /* Amber 400 - Vàng cam sáng rõ, không bị chìm/bùn */
  --clinical-urgent: #f87171;    /* Red 400 - Đỏ cảnh báo nổi bật */
  --clinical-neutral: #cbd5e1;   /* Slate 300 - Xám bạc sáng rõ trên nền tối */

  /* Semantic Tints for Dark Mode */
  --danger-light: rgba(248, 113, 113, 0.18);
  --success-light: rgba(52, 211, 153, 0.18);
  --warning-light: rgba(251, 191, 36, 0.18);
  --tint-teal: rgba(20, 184, 166, 0.18);
  --tint-red: rgba(248, 113, 113, 0.18);
  --tint-green: rgba(52, 211, 153, 0.18);
  --tint-amber: rgba(251, 191, 36, 0.18);
  --tint-blue: rgba(96, 165, 250, 0.18);
}

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

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.font-mono {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

/* Accessible Focus States - WCAG 2.2 AA compliant & collision-free */
:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
}

.btn:focus-visible,
.phase-pill:focus-visible,
.action-menu-dropdown button:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 1px;
  position: relative;
  z-index: 2;
}

.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--primary);
  color: var(--primary-contrast);
  padding: 8px 16px;
  z-index: 1000;
  font-weight: 600;
  transition: top 0.2s ease;
}
.skip-link:focus {
  top: 0;
}

/* Header */
.app-header {
  background-color: var(--bg-card);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.header-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-group {
  display: flex;
  align-items: center;
  gap: 14px;
}
.brand-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-logo-img {
  width: auto;
  height: 44px;
  max-width: 40px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 2px 5px rgba(15, 118, 110, 0.18));
  transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.brand-logo-img:hover {
  transform: scale(1.05);
}
.brand-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.brand-title h1 {
  font-size: 1.25rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  line-height: 1.25;
  margin: 0;
}
.version-badge {
  font-size: 0.75rem;
  background: var(--primary-light);
  color: var(--primary);
  padding: 2px 8px;
  border-radius: 9999px;
  font-weight: 600;
}
.brand-subtitle {
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-weight: 500;
  letter-spacing: 0.02em;
  line-height: 1.25;
  margin-top: 2px;
}
.header-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}
.operator-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.875rem;
  background: var(--bg-main);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s ease;
}
.operator-badge:hover {
  border-color: var(--primary);
  background: var(--bg-card);
}
.operator-name {
  color: var(--text-main);
  font-weight: 600;
}
.operator-badge svg {
  color: var(--text-muted);
  stroke: currentColor;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
}
.role-tag {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
}
.session-widget {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.875rem;
  background: var(--bg-main);
  color: var(--text-main);
  padding: 4px 10px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  transition: all 0.25s ease;
}
.session-widget.warning {
  border-color: var(--warning, #f59e0b);
  background: rgba(245, 158, 11, 0.08);
  animation: pulse-session-border 1.5s infinite;
}
.session-widget.warning .session-time {
  color: #d97706;
  font-weight: 800;
}
@keyframes pulse-session-border {
  0% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.4); }
  70% { box-shadow: 0 0 0 6px rgba(245, 158, 11, 0); }
  100% { box-shadow: 0 0 0 0 rgba(245, 158, 11, 0); }
}
@keyframes pulse-session-icon {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}
.session-warning-card {
  border-radius: 20px !important;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25) !important;
}
.session-warning-icon {
  animation: pulse-session-icon 1.5s infinite ease-in-out;
}
.session-time {
  font-family: monospace;
  font-weight: 700;
  color: var(--warning);
}
.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 6px;
  cursor: pointer;
  color: var(--text-main);
  display: flex;
}
.btn-icon:hover {
  background: var(--bg-main);
}

/* Nav Tabs */
.app-nav {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.nav-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 0 24px;
}
.nav-tabs {
  display: flex;
  list-style: none;
  gap: 8px;
}
.nav-tab {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  padding: 12px 16px;
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s ease;
}
.nav-tab:hover {
  color: var(--text-main);
}
.nav-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Main Container */
.main-container {
  flex: 1;
  max-width: 1440px;
  width: 100%;
  margin: 0 auto;
  padding: 24px;
}
@media (min-width: 769px) and (max-width: 1200px) {
  .main-container {
    padding: 16px;
  }
}
.tab-panel {
  display: none;
}
.tab-panel.active {
  display: block;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}
.panel-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
}
.panel-desc {
  font-size: 0.875rem;
  color: var(--text-muted);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
}
.btn-primary {
  background: var(--primary);
  color: var(--primary-contrast);
}
.btn-primary:hover {
  background: var(--primary-hover);
}
.btn-secondary {
  background: var(--bg-main);
  border-color: var(--border);
  color: var(--text-main);
}
.btn-secondary:hover {
  background: var(--border);
}

/* Cards & Tables */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}
.table-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table-responsive {
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}
.data-table th, .data-table td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.data-table th {
  background: var(--bg-main);
  font-weight: 600;
  color: var(--text-muted);
}
.data-table tr:hover td {
  background: var(--bg-main);
}
.sortable-th {
  cursor: pointer;
  user-select: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}
.sortable-th:hover {
  background: var(--bg-card, #f1f5f9);
  color: var(--primary);
}
.date-cell-nowrap {
  white-space: nowrap !important;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}
.proc-cell-wrapper {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.proc-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 6px;
}
.proc-title-text {
  font-weight: 500;
  color: var(--text-main);
}
.proc-approach-tags {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
}
.proc-diag-text {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.action-buttons-row {
  display: flex;
}
.patient-cell-wrapper {
  display: contents;
}
.date-cell-wrapper {
  display: contents;
}
.date-tags-cluster {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

/* Grid & Clinical Math Section */
.grid-2-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}
@media (max-width: 900px) {
  .grid-2-cols { grid-template-columns: 1fr; }
}
.grade-selector-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin: 16px 0;
}
.grade-item {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}
.grade-header {
  display: flex;
  align-items: center;
  gap: 12px;
}
.grade-name {
  font-weight: 700;
  color: var(--text-main);
}
.grade-weight {
  font-size: 0.75rem;
  background: var(--border);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}
.grade-desc {
  grid-column: 1 / -1;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 4px;
}
.counter-control {
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 2;
  grid-row: 1;
}
.btn-counter {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  font-weight: 700;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.counter-value {
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Score Display */
.score-display {
  margin: 20px 0;
}
.score-number-wrapper {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.score-number {
  font-size: 3.5rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
}
.score-max {
  font-size: 1.25rem;
  color: var(--text-muted);
}
.score-progress-bar {
  width: 100%;
  height: 10px;
  background: var(--border);
  border-radius: 9999px;
  overflow: hidden;
  margin-top: 12px;
}
.progress-fill {
  height: 100%;
  background: var(--primary);
  transition: width 0.3s ease;
}
.math-formula-box {
  background: var(--bg-main);
  border-left: 4px solid var(--primary);
  padding: 12px;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin-bottom: 16px;
}
.interpretation-box {
  background: var(--bg-main);
  padding: 12px;
  border-radius: var(--radius);
}

/* Chart */
.chart-container {
  width: 100%;
  height: 350px;
}
.chart-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 20px;
  margin-top: 16px;
  font-size: 0.875rem;
}
.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
}
.legend-color {
  width: 20px;
  height: 4px;
}
.legend-color.s-line { background: var(--primary); }
.legend-color.h-line { background: var(--danger); }
.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.legend-dot.comp-dot { background: var(--danger); }
.legend-dot.succ-dot { background: var(--success); }

/* Footer */
.app-footer {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 16px 24px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  text-align: center;
}

/* ------------------------------------------------------------------------- */
/* Modal Dialog System (WCAG 2.2 AA Accessible) */
/* ------------------------------------------------------------------------- */
[hidden] {
  display: none !important;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1050;
  padding: 16px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.modal-overlay[hidden],
.modal-overlay.is-hidden,
.is-hidden {
  display: none !important;
}
.modal-content {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
  width: 100%;
  max-width: 720px;
  max-height: calc(100vh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: modalFadeIn 0.2s ease-out;
  margin: auto;
}
@keyframes modalFadeIn {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Accidental Backdrop Dismissal Protection: Pulse feedback when clicking outside modal */
@keyframes modalBackdropPulse {
  0% { transform: scale(1); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25); }
  50% { transform: scale(1.008); box-shadow: 0 0 0 5px var(--primary-light, rgba(15, 118, 110, 0.35)), 0 20px 25px -5px rgba(0, 0, 0, 0.35); }
  100% { transform: scale(1); box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.25); }
}

.modal-backdrop-pulse {
  animation: modalBackdropPulse 0.25s cubic-bezier(0.16, 1, 0.3, 1) !important;
}

/* Modal Form Flex Container - Essential for scrollable modal-body */
.modal-content > form,
.modal-form {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
}
.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}
.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius);
}
.modal-close:hover {
  color: var(--danger);
  background: var(--danger-light);
}
.modal-body {
  padding: 20px;
  overflow-y: auto;
  overflow-x: hidden;
  flex: 1 1 auto;
  min-height: 0;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg-main);
}

.modal-body::-webkit-scrollbar {
  width: 8px;
}
.modal-body::-webkit-scrollbar-track {
  background: var(--bg-main);
}
.modal-body::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}
.modal-body::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

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

/* Form Styles */
.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}
.form-row.form-row-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.form-row.form-row-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}
.form-row.form-row-mobile-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
@media (max-width: 768px) {
  .form-row.form-row-2:not(.form-row-mobile-2),
  .form-row.form-row-3:not(.form-row-hematology) {
    grid-template-columns: 1fr;
  }
  .form-row.form-row-hematology {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .form-row.form-row-hematology > div:not(.anemia-badge-group) .form-label {
    min-height: 2.6em;
  }
  .form-row.form-row-hematology .form-group > .form-control {
    margin-top: 0;
  }
  .form-row.form-row-hematology .anemia-badge-group {
    grid-column: span 2;
  }
}
.form-group {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
}
.form-group > .form-control,
.form-group > .form-select,
.form-group > .badge-anemia-container {
  margin-top: 0;
}
.form-group > .bmi-display-box {
  margin-top: auto;
}
.form-row.form-row-hematology .anemia-badge-group .badge-anemia-container {
  margin-top: 0;
  height: 38px;
  min-height: 38px;
  display: flex;
  align-items: center;
}
.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

/* Clavien-Dindo Choice Cards */
.comp-choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.comp-choice-card {
  display: flex;
  flex-direction: column;
  padding: 8px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease, transform 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.comp-choice-card:hover {
  border-color: var(--primary);
  background: rgba(15, 118, 110, 0.03);
}
.comp-choice-card:active {
  transform: scale(0.99);
}
.comp-choice-card:has(input:checked) {
  border-color: var(--primary);
  background: rgba(15, 118, 110, 0.08);
  box-shadow: 0 0 0 1px var(--primary);
}
.comp-choice-card.is-danger:hover {
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.03);
}
.comp-choice-card.is-danger:has(input:checked) {
  border-color: var(--danger);
  background: rgba(220, 38, 38, 0.08);
  box-shadow: 0 0 0 1px var(--danger);
}
.comp-choice-card input[type="checkbox"] {
  width: 18px;
  height: 18px;
  margin: 0;
  cursor: pointer;
  accent-color: var(--primary);
  flex-shrink: 0;
}
.comp-choice-card.is-danger input[type="checkbox"] {
  accent-color: var(--danger);
}
.comp-choice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--text-main);
}
.comp-choice-desc {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 3px;
  line-height: 1.3;
}
.form-control, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  font-size: 0.9375rem;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text-main);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.form-control:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--primary);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.2);
}
.form-textarea {
  min-height: 80px;
  resize: vertical;
}
.form-help {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Multi-Specialty Pills */
.specialty-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}
.specialty-pill-btn {
  padding: 6px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.specialty-pill-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.specialty-pill-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 2px 4px rgba(15, 118, 110, 0.25);
}

/* Quick Preset Chips */
.preset-chip-box {
  background: rgba(15, 118, 110, 0.05);
  border: 1px dashed var(--primary);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 16px;
}
.preset-chip-title {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.preset-chip-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.preset-chip {
  padding: 5px 10px;
  border-radius: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-main);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-chip:hover {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

/* Collapsible Sections */
.collapsible-wrapper {
  margin-bottom: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.collapsible-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-main);
  border: none;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
}
.collapsible-toggle:hover {
  background: var(--border);
}
.collapsible-body {
  padding: 14px;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
}

/* Status & Specialty Badges */
.badge-specialty {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
  background: #f1f5f9;
  color: #475569;
  white-space: nowrap !important;
}
.badge-specialty.colorectal { background: #e0f2fe; color: #0369a1; }
.badge-specialty.hpb { background: #fef3c7; color: #b45309; }
.badge-specialty.upper_gi { background: #ede9fe; color: #6d28d9; }
.badge-specialty.proctology { background: #fce7f3; color: #be185d; }
.badge-specialty.hernia { background: #dcfce7; color: #15803d; }
.badge-specialty.emergency_general { background: #fee2e2; color: #b91c1c; }
.badge-specialty.other { background: #f1f5f9; color: #475569; }

.badge-status {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-status.intraop { background: #fef9c3; color: #854d0e; }
.badge-status.pending { background: #ffedd5; color: #c2410c; }
.badge-status.complete { background: #dcfce7; color: #166534; }
.badge-status.lost { background: #f1f5f9; color: #64748b; }

/* Filter & Stats Bar */
.filter-bar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  margin-bottom: 16px;
  background: var(--bg-card);
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: all 0.2s ease;
}
.filter-primary-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}
.search-wrapper {
  flex: 1;
  min-width: 240px;
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  padding-left: 34px !important;
  padding-right: 32px !important;
  width: 100%;
  height: 38px;
}
.btn-clear-search {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: none;
  background: rgba(148, 163, 184, 0.25);
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  z-index: 2;
}
.btn-clear-search:hover {
  background: rgba(148, 163, 184, 0.45);
  color: var(--text-main);
}
.filter-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.filter-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.filter-toggle-btn:hover {
  background: var(--bg-main);
  border-color: var(--text-muted);
}
.filter-toggle-btn:active,
.filter-toggle-btn.is-active {
  background: rgba(14, 165, 233, 0.12);
  border-color: var(--primary);
  color: var(--primary);
}
.badge-active-filters {
  background: var(--primary);
  color: #ffffff;
  font-size: 0.7rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}
.filter-collapsible-group {
  display: none;
  width: 100%;
}
.filter-collapsible-group.is-open {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
  animation: filterSlideDown 0.2s ease-out;
}
@keyframes filterSlideDown {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  .filter-collapsible-group.is-open {
    animation: none !important;
  }
}
.filter-criteria-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  width: 100%;
}
.filter-field {
  width: 100%;
  display: block;
}
.filter-field select,
.filter-field .form-select {
  width: 100%;
  max-width: 100%;
  font-size: 0.8125rem;
  height: 38px;
  padding: 4px 8px;
}
.filter-secondary-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin-top: 2px;
  padding-top: 8px;
  border-top: 1px dashed var(--border);
  flex-wrap: wrap;
}
.filter-field-sort {
  width: 240px;
  flex-shrink: 0;
}
.time-filter-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.filter-actions-group {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
#btn-reset-filters {
  height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  white-space: nowrap;
}
#btn-close-filters-mobile {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 12px;
  font-size: 0.8125rem;
  font-weight: 500;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm, 6px);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
#btn-close-filters-mobile:hover {
  background: var(--bg-main);
  color: var(--text-main);
  border-color: var(--text-muted);
}
/* Timeframe Filter Segmented Control (Tuần - Tháng - Quý - Năm - Toàn bộ) */
.time-filter-container {
  display: inline-flex;
  align-items: center;
  background: var(--bg-main);
  padding: 3px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  gap: 2px;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.04);
}
.time-filter-btn {
  padding: 5px 12px;
  border-radius: 9999px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  user-select: none;
  line-height: 1.25;
}
.time-filter-btn:hover {
  color: var(--text-main);
  background: rgba(15, 118, 110, 0.08);
}
.time-filter-btn.active {
  background: var(--primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.25);
}
/* Time Period Navigator & Stepper (Tuần, Tháng, Quý, Năm) */
.time-period-navigator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--bg-card);
  padding: 2px 4px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
  transition: all 0.2s ease;
}
.btn-time-nav {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 0;
  line-height: 1;
}
.btn-time-nav:hover:not(:disabled) {
  background: var(--bg-main);
  color: var(--primary);
  border-color: var(--border);
}
.btn-time-nav:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}
.time-period-select-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}
.time-period-select {
  padding: 3px 8px;
  border-radius: 9999px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--primary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  max-width: 260px;
}
.time-period-select:hover {
  background: rgba(15, 118, 110, 0.06);
}
.time-period-select:focus {
  border-color: var(--primary);
  background: var(--bg-card);
}
.stats-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat-summary-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg, 12px);
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.stat-summary-card.highlight,
.stat-summary-card.card-stat-total {
  border-left: 4px solid var(--primary);
}
.stat-summary-card.card-stat-comp {
  border-left: 4px solid #d97706;
}
.stat-summary-card.card-stat-rate {
  border-left: 4px solid #0284c7;
}
.stat-summary-card.card-stat-cci {
  border-left: 4px solid #7c3aed;
}

.stat-summary-val {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.15;
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}
.stat-summary-card.card-stat-comp .stat-summary-val {
  color: #b45309;
}
.stat-summary-card.card-stat-rate .stat-summary-val {
  color: #0369a1;
}
.stat-summary-card.card-stat-cci .stat-summary-val {
  color: #6d28d9;
}

.stat-summary-lbl {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-top: 4px;
  line-height: 1.3;
}

/* Preset Chips */
.presets-group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}
.presets-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 8px;
}
.chips-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.preset-chip {
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: 9999px;
  padding: 4px 12px;
  font-size: 0.8125rem;
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.15s ease;
}
.preset-chip:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: var(--primary);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border-left: 4px solid var(--primary);
  color: var(--text-main);
  padding: 12px 18px;
  border-radius: var(--radius);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastSlideIn 0.25s ease-out;
}
.toast.toast-error {
  border-left-color: var(--danger);
  background: #fef2f2;
  color: #991b1b;
}
.toast.toast-success {
  border-left-color: var(--success);
}
@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Export Tab Styles */
.export-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-top: 12px;
}
.export-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.export-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.export-badge.badge-secure {
  background: #dbeafe;
  color: #1e40af;
}
.export-badge.badge-research {
  background: #fef3c7;
  color: #92400e;
}
.export-card h3 {
  font-size: 1.25rem;
  margin-bottom: 8px;
  color: var(--text-main);
}
.export-card p {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.6;
  margin-bottom: 16px;
}
.spec-list {
  list-style: none;
  margin-bottom: 20px;
  font-size: 0.8125rem;
}
.spec-list li {
  padding: 4px 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.spec-list li::before {
  content: "✓";
  color: var(--success);
  font-weight: bold;
}

/* Surveillance & Oncology Status Badges */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  white-space: nowrap;
}
.badge-status.badge-ned {
  background: var(--success-light);
  color: var(--success);
  border: 1px solid rgba(21, 128, 61, 0.3);
}
.badge-status.badge-awd {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.3);
}
.badge-status.badge-dead {
  background: #334155;
  color: #f8fafc;
}
.badge-status.badge-lost {
  background: var(--bg-main);
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.badge-status.badge-due {
  background: var(--warning-light);
  color: var(--warning);
  border: 1px solid rgba(180, 83, 9, 0.3);
  animation: pulseWarning 2s infinite;
}
.badge-status.badge-overdue {
  background: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(185, 28, 28, 0.4);
  font-weight: 800;
}

@keyframes pulseWarning {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.7; }
}

/* Asian BMI Badges */
.badge-bmi {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-bmi.bmi-underweight {
  background: var(--warning-light);
  color: var(--warning);
}
.badge-bmi.bmi-normal {
  background: var(--success-light);
  color: var(--success);
}
.badge-bmi.bmi-overweight {
  background: #ffedd5;
  color: #c2410c;
}
.badge-bmi.bmi-obese {
  background: var(--danger-light);
  color: var(--danger);
}

/* Targeted Modules Styling */
.targeted-subpanel {
  padding: 12px 14px;
  background: rgba(15, 118, 110, 0.03);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-top: 8px;
}

/* Surveillance Timeline */
.timeline-container {
  position: relative;
  padding-left: 24px;
  margin-top: 16px;
}
.timeline-container::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 8px;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  margin-bottom: 20px;
}
.timeline-dot {
  position: absolute;
  left: -20px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid var(--bg-card);
  box-shadow: 0 0 0 2px var(--primary-light);
}
.timeline-dot.dot-awd {
  background: var(--danger);
  box-shadow: 0 0 0 2px var(--danger-light);
}
.timeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow);
}
.timeline-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.timeline-milestone {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--primary);
}
.timeline-date {
  font-size: 0.8125rem;
  color: var(--text-muted);
}
.timeline-body {
  font-size: 0.875rem;
  color: var(--text-main);
  line-height: 1.6;
}
.timeline-badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

/* ==========================================================================
   Clinical Worklist 4 Streams & Oncology Multi-Panel Modal (Section 6)
   ========================================================================== */

/* Worklist Pill Navigation Bar */
.worklist-nav-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  box-shadow: var(--shadow-sm);
}
.worklist-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
.wl-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 9999px;
  border: 1px solid var(--border);
  background: var(--bg-main);
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}
.wl-pill:hover {
  background: var(--surface);
  color: var(--text-main);
  border-color: var(--primary);
}
.wl-pill.active {
  background: var(--primary);
  color: #ffffff;
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}
.wl-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(0, 0, 0, 0.08);
  color: inherit;
}
.wl-pill.active .wl-badge {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff;
}
.wl-badge-due { background: #fef3c7; color: #b45309; }
.wl-badge-overdue { background: #fee2e2; color: #b91c1c; }
.wl-badge-pending { background: #e0e7ff; color: #4338ca; }
.wl-badge-triage { background: #f1f5f9; color: #475569; }

/* Worklist Stream Cards Container */
.worklist-stream-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}
.work-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
.work-card:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-md);
}
.work-card.due { border-left: 5px solid #f59e0b; }
.work-card.overdue { border-left: 5px solid #ef4444; background: rgba(239, 68, 68, 0.02); }
.work-card.pending { border-left: 5px solid #6366f1; background: rgba(99, 102, 241, 0.02); }
.work-card.triage { border-left: 5px solid #0d9488; }

.work-icon-circle {
  width: 44px;
  height: 44px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  background: var(--bg-main);
  border: 1px solid var(--border);
}
.work-card.due .work-icon-circle { background: #fffbeb; color: #d97706; border-color: #fde68a; }
.work-card.overdue .work-icon-circle { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.work-card.pending .work-icon-circle { background: #eef2ff; color: #4f46e5; border-color: #c7d2fe; }
.work-card.triage .work-icon-circle { background: #f0fdfa; color: #0d9488; border-color: #99f6e4; }

.work-details { min-width: 0; }
.work-proc-name {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}
.work-meta {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.work-reason {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-top: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.work-card.due .work-reason { color: #b45309; }
.work-card.overdue .work-reason { color: #b91c1c; }
.work-card.pending .work-reason { color: #4338ca; }
.work-card.triage .work-reason { color: #0f766e; }

.work-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Multi-Panel Cancer Selector in Followup Modal */
.fuv-panel-tabs {
  display: flex;
  gap: 6px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
  padding-bottom: 4px;
}
.fuv-panel-tab {
  padding: 6px 12px;
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid transparent;
  border-bottom: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.fuv-panel-tab:hover {
  color: var(--primary);
  background: rgba(15, 118, 110, 0.05);
}
.fuv-panel-tab.active {
  color: var(--primary);
  background: var(--surface);
  border-color: var(--border);
  border-bottom: 2px solid var(--primary);
  margin-bottom: -6px;
  font-weight: 700;
}

/* Exam 5-Status Row Layout */
.exam-status-row {
  display: grid;
  grid-template-columns: 200px 1fr;
  align-items: start;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}
.exam-status-label {
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-main);
  padding-top: 6px;
}
.exam-status-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.exam-status-subbox {
  background: rgba(0, 0, 0, 0.02);
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin-top: 4px;
}

/* ---------------------------------------------------------------------------
   Mobile Navigation, Bottom Sheet, Card View & Viewport dvh (v2.3.0)
   Touch target >= 44x44px — exceeds WCAG 2.2 SC 2.5.8 (AA, 24x24px),
   meets SC 2.5.5 (AAA) and Apple HIG standards.
--------------------------------------------------------------------------- */

/* Tabular numbers for numeric data, codes and dates */
.font-mono,
.data-table td,
.metric-val,
.stat-summary-val,
.stat-val,
.badge-mono,
.tabular-nums {
  font-variant-numeric: tabular-nums;
}

/* Body Scroll-Lock helper for accessible modal focus trap */
body.scroll-lock {
  overflow: hidden;
}

/* Bottom Navigation */
.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  padding: 6px 8px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom, 0px));
  justify-content: space-around;
  align-items: center;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 4px 8px;
  min-width: 52px;
  min-height: 44px; /* Touch target >= 44x44px per Apple HIG / WCAG AAA */
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item:hover,
.bottom-nav-item:focus-visible {
  color: var(--primary);
}

.bottom-nav-item.is-active {
  color: var(--primary);
  font-weight: 700;
}

.bottom-nav-icon {
  flex-shrink: 0;
  margin-bottom: 2px;
}

.bottom-nav-label {
  font-size: 0.6875rem;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

/* Floating Add Action Button */
.bottom-nav-item.bottom-nav-add {
  margin-top: -16px;
}

.bottom-nav-add-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--primary);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(15, 118, 110, 0.4);
  transition: transform 0.15s ease;
  margin-bottom: 2px;
}

.bottom-nav-item.bottom-nav-add:active .bottom-nav-add-btn {
  transform: scale(0.95);
}

/* Mobile More Menu Sheet */
.mobile-sheet {
  position: fixed;
  inset: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

.mobile-sheet.is-hidden {
  display: none !important;
}

.mobile-sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}

.mobile-sheet-panel {
  position: relative;
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  border-radius: 20px 20px 0 0;
  padding: 16px 20px 28px;
  padding-bottom: calc(28px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 25px rgba(0, 0, 0, 0.15);
  max-height: 80vh;
  max-height: 80dvh;
  overflow-y: auto;
  animation: slideUp 0.25s ease-out;
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

.mobile-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 12px;
}

.mobile-sheet-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.mobile-sheet-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--text-main);
}

.mobile-sheet-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.mobile-sheet-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px 12px;
  background: var(--bg-main);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  cursor: pointer;
  min-height: 80px;
  transition: all 0.15s ease;
}

.mobile-sheet-btn:hover,
.mobile-sheet-btn:active {
  background: var(--tint-teal);
  border-color: var(--primary);
  color: var(--primary);
}

/* Mobile Card View for All 3 Data Tables */
@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
  }
  
  body {
    padding-bottom: 74px; /* Space for bottom navigation */
  }

  .app-nav {
    display: none; /* Desktop tabs hidden on mobile, replaced by Bottom Nav */
  }

  .header-container {
    padding: 8px 12px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .brand-subtitle {
    display: none;
  }

  .brand-logo-img {
    height: 32px;
    max-width: 28px;
  }

  .header-controls {
    gap: 6px;
    flex-wrap: wrap;
  }

  .operator-badge {
    padding: 4px 8px;
    font-size: 0.75rem;
  }

  .operator-badge .role-tag {
    display: none;
  }

  .session-widget {
    padding: 3px 6px;
    font-size: 0.75rem;
  }

  .session-widget .session-label {
    display: none;
  }

  #btn-theme-toggle {
    padding: 4px 8px;
  }

  #theme-text {
    display: none;
  }

  .main-content {
    padding: 12px 10px;
  }

  .filter-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 8px 10px;
    margin-bottom: 12px;
  }

  .filter-primary-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
  }

  .filter-primary-row .search-wrapper {
    flex: 1;
    min-width: 0;
    position: relative;
    display: flex;
    align-items: center;
  }

  .filter-primary-row .search-input {
    width: 100%;
    height: 40px;
    font-size: 16px !important; /* Minimum 16px prevents iOS Safari auto-zoom on input focus */
    padding-left: 34px !important;
    padding-right: 32px !important;
    border-radius: var(--radius-sm, 6px);
  }

  .btn-clear-search {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    padding: 0;
    border-radius: 50%;
    border: none;
    background: rgba(148, 163, 184, 0.25);
    color: var(--text-muted);
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    z-index: 2;
  }

  /* 44x44px touch target hitbox via pseudo-element */
  .btn-clear-search::after {
    content: '';
    position: absolute;
    top: -10px;
    bottom: -10px;
    left: -10px;
    right: -10px;
  }

  .btn-clear-search:active {
    background: rgba(148, 163, 184, 0.45);
    transform: translateY(-50%) scale(0.92);
  }

  .filter-quick-actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .filter-toggle-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 5px;
    height: 40px;
    padding: 0 10px;
    font-size: 0.8125rem;
    font-weight: 600;
    border-radius: var(--radius-sm, 6px);
    border: 1px solid var(--border);
    background: var(--bg-card);
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.15s ease;
    white-space: nowrap;
  }

  .filter-toggle-btn:active,
  .filter-toggle-btn.is-active {
    background: rgba(14, 165, 233, 0.12);
    border-color: var(--primary);
    color: var(--primary);
  }

  .badge-active-filters {
    background: var(--primary);
    color: #ffffff;
    font-size: 0.7rem;
    font-weight: 700;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 9999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
  }

  #btn-toggle-privacy-shield {
    height: 40px;
    padding: 0 10px;
    white-space: nowrap;
  }

  @media (max-width: 480px) {
    #privacy-shield-text {
      display: none;
    }
    #btn-toggle-privacy-shield {
      padding: 0 8px;
    }
    .filter-toggle-label {
      font-size: 0.75rem;
    }
  }

  /* Collapsible Filters Group on Mobile */
  .filter-collapsible-group {
    display: none;
    width: 100%;
  }

  .filter-collapsible-group.is-open {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed var(--border);
    animation: filterSlideDown 0.2s ease-out;
  }

  @keyframes filterSlideDown {
    from {
      opacity: 0;
      transform: translateY(-6px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  @media (prefers-reduced-motion: reduce) {
    .filter-collapsible-group.is-open {
      animation: none !important;
    }
  }

  .filter-criteria-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    width: 100%;
  }

  .filter-criteria-row .filter-field {
    width: 100%;
    display: block;
  }

  .filter-criteria-row .filter-field select,
  .filter-criteria-row .filter-field .form-select {
    width: 100%;
    max-width: 100%;
    font-size: 0.8125rem;
    height: 38px;
    padding: 4px 8px;
  }

  .filter-secondary-row {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    margin-top: 2px;
    padding-top: 8px;
    border-top: 1px dashed var(--border);
  }

  .filter-field-sort {
    width: 100%;
  }

  .filter-field-sort select,
  .filter-field-sort .form-select {
    width: 100%;
    max-width: 100%;
    font-size: 0.8125rem;
    height: 38px;
    padding: 4px 8px;
  }

  .time-filter-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 6px;
  }

  .filter-actions-group {
    display: flex;
    gap: 8px;
    width: 100%;
  }

  .filter-actions-group #btn-reset-filters {
    flex: 1;
    height: 36px;
    font-size: 0.8125rem;
  }

  .filter-actions-group #btn-close-filters-mobile {
    flex: 1;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    height: 36px;
    font-size: 0.8125rem;
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    border-radius: var(--radius-sm, 6px);
    cursor: pointer;
  }

  .time-filter-container {
    width: 100%;
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .time-filter-btn {
    flex: 1;
    text-align: center;
    padding: 6px 2px;
    font-size: 0.75rem;
  }

  .time-period-navigator {
    width: 100%;
    display: flex;
    justify-content: space-between;
    box-sizing: border-box;
  }

  .time-period-select-wrap {
    flex: 1;
    display: flex;
  }

  .time-period-select {
    width: 100%;
    text-align: center;
    font-size: 0.75rem;
    max-width: 100%;
  }

  .stats-summary-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .stats-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  /* 16px font-size for form controls inside mobile media query prevents iOS auto-zoom */
  .form-control,
  .form-select,
  .form-textarea,
  input,
  select,
  textarea {
    font-size: 16px !important;
  }

  /* Bottom sheet modal styling for mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal-content {
    width: 100%;
    max-width: 100%;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    max-height: 92vh;
    max-height: 92dvh;
  }

  .modal-body {
    padding: 14px 16px;
  }

  /* Card View Scoped to Cases, Surveillance, and Audit (Preserves multi-column scroll on tables like #table-doctors) */
  #tab-cases .table-responsive,
  #tab-surveillance .table-responsive,
  #tab-audit .table-responsive {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100% !important;
    overscroll-behavior-x: none !important;
  }

  #tab-cases .table-card,
  #tab-surveillance .table-card,
  #tab-audit .table-card {
    overflow: visible !important;
    max-width: 100% !important;
  }

  #tab-cases .data-table thead,
  #tab-surveillance .data-table thead,
  #tab-audit .data-table thead {
    display: none;
  }

  #tab-cases .data-table,
  #tab-cases .data-table tbody,
  #tab-surveillance .data-table,
  #tab-surveillance .data-table tbody,
  #tab-audit .data-table,
  #tab-audit .data-table tbody {
    display: block;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  #tab-cases .data-table tbody,
  #tab-surveillance .data-table tbody,
  #tab-audit .data-table tbody {
    display: flex;
    flex-direction: column;
    gap: 10px;
  }

  #tab-cases .data-table tr,
  #tab-surveillance .data-table tr,
  #tab-audit .data-table tr {
    display: block;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md, 8px);
    padding: 10px 14px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: visible !important;
  }

  #tab-cases .data-table tr:hover td,
  #tab-surveillance .data-table tr:hover td,
  #tab-audit .data-table tr:hover td {
    background: transparent;
  }

  #tab-cases .data-table td,
  #tab-surveillance .data-table td,
  #tab-audit .data-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border-bottom: 1px solid rgba(0, 0, 0, 0.03);
    text-align: right;
    min-height: 26px;
    min-width: 0 !important;
    max-width: 100%;
    box-sizing: border-box;
  }

  #tab-cases .data-table td:last-child,
  #tab-surveillance .data-table td:last-child,
  #tab-audit .data-table td:last-child {
    border-bottom: none;
  }

  #tab-cases .data-table td[data-label]::before,
  #tab-surveillance .data-table td[data-label]::before,
  #tab-audit .data-table td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: left;
    margin-right: 12px;
    flex-shrink: 0;
  }

  /* Scoped Wrapping for Patient Name & Completeness Tracker */
  #tab-cases .data-table td[data-label="Bệnh Nhân"] {
    white-space: normal !important;
  }

  #tab-cases .data-table td[data-label="Bệnh Nhân"] .patient-cell-wrapper {
    text-align: right;
    max-width: calc(100% - 85px);
    min-width: 0;
  }

  .patient-name-revealed {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.25 !important;
  }

  #tab-cases .data-table td[data-label="Tiến Độ / Theo Dõi"] .completeness-tracker {
    text-align: right;
    max-width: calc(100% - 110px);
    min-width: 0;
  }

  #tab-cases .data-table td[data-label="Tiến Độ / Theo Dõi"] .completeness-header {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 4px;
  }

  .completeness-label {
    white-space: normal !important;
    word-break: break-word !important;
    line-height: 1.25 !important;
    text-align: right;
  }

  /* Specific Mobile Card: Date & ASA/Urgency Badges Layout */
  .data-table td[data-label="Ngày Mổ / ASA"],
  .data-table td.date-cell-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    min-height: 32px;
    white-space: normal;
  }

  .data-table td.date-cell-container .date-cell-wrapper,
  .data-table td[data-label="Ngày Mổ / ASA"] .date-cell-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    flex-wrap: wrap;
    text-align: right;
  }

  .data-table td.date-cell-container .date-cell-nowrap {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text-main);
    letter-spacing: 0.02em;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .data-table td.date-cell-container .date-tags-cluster,
  .data-table td[data-label="Ngày Mổ / ASA"] .date-tags-cluster {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: nowrap;
    flex-shrink: 0;
  }

  /* Specific Mobile Card: Procedure & Diagnosis Full Width */
  .data-table td[data-label="Phẫu Thuật & Tiếp Cận"],
  .data-table td.proc-cell-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    text-align: left;
    padding: 6px 0 8px 0;
    border-bottom: 1px dashed var(--border);
    width: 100%;
  }

  .data-table td[data-label="Phẫu Thuật & Tiếp Cận"]::before,
  .data-table td.proc-cell-container::before {
    content: "PHẪU THUẬT & CHẨN ĐOÁN";
    font-size: 0.6875rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 0.04em;
    margin-bottom: 4px;
    margin-right: 0;
    text-align: left;
  }

  .proc-cell-wrapper {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 4px;
  }

  .proc-title-row {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 6px;
    width: 100%;
    text-align: left;
  }

  .proc-title-text {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.35;
    text-align: left;
  }

  .proc-approach-tags {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
  }

  .proc-diag-text {
    font-size: 0.8125rem;
    color: var(--text-muted);
    line-height: 1.35;
    text-align: left;
    width: 100%;
  }

  /* Specific Mobile Card: Action Cell Full Width & Clean Multi-Pills */
  #tab-cases .data-table td[data-label="Thao Tác"],
  #tab-cases .data-table td.action-cell-container {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    padding-top: 8px;
    padding-bottom: 2px;
    border-bottom: none;
    width: 100%;
    gap: 6px;
  }

  #tab-cases .action-cell-wrapper {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
    min-width: 0;
    gap: 6px;
  }

  #tab-cases .data-table td[data-label="Thao Tác"]::before,
  #tab-cases .data-table td.action-cell-container::before {
    display: none !important;
  }

  .action-buttons-row {
    display: flex !important;
    flex-wrap: wrap !important;
    align-items: center;
    gap: 6px;
    width: 100%;
  }

  .action-btn-p1,
  .action-btn-p2 {
    flex: 1 1 calc(50% - 6px) !important;
    min-height: 36px !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    padding: 0 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
  }

  .action-btn-next-action {
    flex: 1 1 100% !important;
    width: 100% !important;
    order: 2 !important;
    min-height: 36px !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    padding: 0 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    box-sizing: border-box !important;
  }

  .action-btn-detail {
    flex: 1 1 auto !important;
    min-height: 36px !important;
    font-size: 0.8125rem !important;
    font-weight: 600 !important;
    padding: 0 8px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    white-space: nowrap !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
    order: 3 !important;
  }

  .action-buttons-row .action-menu-wrapper {
    flex: 0 0 auto !important;
    order: 4 !important;
  }

  .action-buttons-row .action-menu-wrapper .btn {
    min-width: 44px !important;
    min-height: 36px !important;
    padding: 0 12px !important;
  }

  /* Dynamic Dropup Menu to prevent collision with bottom navigation */
  .action-menu-dropdown.dropup {
    top: auto !important;
    bottom: 100% !important;
    margin-top: 0 !important;
    margin-bottom: 4px !important;
    box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.1), 0 -4px 6px -2px rgba(0, 0, 0, 0.05) !important;
  }

  .action-cell-container .phase-pill-cluster,
  .action-cell-wrapper .phase-pill-cluster {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr) !important;
    gap: 4px !important;
    width: 100% !important;
    margin-top: 2px;
    box-sizing: border-box !important;
  }

  .action-cell-container .phase-pill,
  .action-cell-wrapper .phase-pill {
    min-width: 0 !important;
    text-align: center;
    min-height: 28px;
    font-size: 0.75rem;
    padding: 2px 2px !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
  }

  /* Extreme narrow screen fallback (< 350px) or enlarged Accessibility font */
  @media (max-width: 350px) {
    #tab-cases .data-table td[data-label="Bệnh Nhân"],
    #tab-cases .data-table td[data-label="Tiến Độ / Theo Dõi"],
    #tab-cases .data-table td[data-label="Ngày Mổ / ASA"] {
      flex-direction: column !important;
      align-items: flex-start !important;
      text-align: left !important;
      gap: 4px !important;
    }
    #tab-cases .data-table td[data-label]::before {
      margin-bottom: 2px !important;
    }
    #tab-cases .data-table td[data-label="Bệnh Nhân"] .patient-cell-wrapper,
    #tab-cases .data-table td[data-label="Tiến Độ / Theo Dõi"] .completeness-tracker {
      max-width: 100% !important;
      text-align: left !important;
    }
    #tab-cases .data-table td[data-label="Tiến Độ / Theo Dõi"] .completeness-header {
      justify-content: flex-start !important;
    }
  }
}

/* -----------------------------------------------------------------------------
 * Authentication, Login Screen & User Dropdown Styles
 * Standard: WCAG 2.2 AA High Contrast & Fluid Responsive
 * --------------------------------------------------------------------------- */
.login-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-main);
  background-image: radial-gradient(circle at 50% 20%, rgba(15, 118, 110, 0.08) 0%, transparent 65%);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  overflow-y: auto;
  box-sizing: border-box;
}

[data-theme="dark"] .login-overlay {
  background: var(--bg-main);
  background-image: radial-gradient(circle at 50% 20%, rgba(20, 184, 166, 0.08) 0%, transparent 65%);
}

.login-card {
  width: 100%;
  max-width: 460px;
  min-width: 0;
  background: var(--bg-card);
  border: 1px solid rgba(203, 213, 225, 0.85);
  border-radius: 28px;
  padding: 44px 38px 36px;
  box-shadow: 0 20px 45px -12px rgba(15, 23, 42, 0.09),
              0 0 0 1px rgba(15, 23, 42, 0.03),
              0 2px 6px rgba(15, 23, 42, 0.02);
  box-sizing: border-box;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

[data-theme="dark"] .login-card {
  background: var(--bg-card);
  border: 1px solid rgba(51, 65, 85, 0.85);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.55),
              0 0 0 1px rgba(255, 255, 255, 0.06);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 72px;
  height: 72px;
  border-radius: 24px;
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.12) 0%, rgba(15, 118, 110, 0.04) 100%);
  border: 1px solid rgba(15, 118, 110, 0.20);
  margin-bottom: 18px;
  box-shadow: 0 8px 24px -4px rgba(15, 118, 110, 0.18), inset 0 1px 1px rgba(255, 255, 255, 0.6);
}

.login-logo-img {
  width: auto;
  height: 52px;
  max-width: 46px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 4px 10px rgba(15, 118, 110, 0.20));
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.login-logo:hover .login-logo-img {
  transform: scale(1.06);
}

[data-theme="dark"] .login-logo {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.25) 0%, rgba(15, 118, 110, 0.08) 100%);
  border-color: rgba(45, 212, 191, 0.25);
  box-shadow: 0 10px 28px -4px rgba(0, 0, 0, 0.55), inset 0 1px 1px rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .login-logo-img {
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

[data-theme="dark"] .brand-logo-img {
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.45));
}

.login-brand {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-main);
  margin: 0 0 8px 0;
  letter-spacing: -0.025em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-brand .version-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 9999px;
  background: rgba(15, 118, 110, 0.12);
  color: var(--primary);
  border: 1px solid rgba(15, 118, 110, 0.25);
  letter-spacing: 0;
  vertical-align: middle;
}

.login-tagline {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.5;
}

.login-form .form-group {
  margin-bottom: 20px;
}

.login-form .form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-main);
  margin-bottom: 8px;
}

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

.input-with-icon .input-icon {
  position: absolute;
  left: 15px;
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  pointer-events: none;
  transition: color 0.2s ease;
  z-index: 2;
}

.input-with-icon:focus-within .input-icon {
  color: var(--primary);
}

.form-input {
  width: 100%;
  height: 48px;
  padding: 0 16px;
  font-size: 0.9375rem;
  font-family: inherit;
  font-weight: 500;
  border: 1.5px solid var(--border);
  border-radius: 14px;
  background: var(--bg-card);
  color: var(--text-main);
  box-sizing: border-box;
  transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
  outline: none;
}

.input-with-icon .form-input,
.input-with-icon .form-control {
  padding-left: 44px;
  padding-right: 44px;
  width: 100%;
  border-radius: 14px;
  height: 48px;
}

.form-input:hover {
  border-color: #94a3b8;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.16);
}

/* Chrome/Safari Autofill Styling with rounded corners preservation */
.form-input:-webkit-autofill,
.form-input:-webkit-autofill:hover,
.form-input:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px var(--bg-card) inset !important;
  -webkit-text-fill-color: var(--text-main) !important;
  border-radius: 14px !important;
  transition: background-color 5000s ease-in-out 0s;
}

.btn-toggle-eye {
  position: absolute;
  right: 8px;
  width: 34px;
  height: 34px;
  background: transparent;
  border: none;
  padding: 0;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  transition: color 0.15s ease, background-color 0.15s ease;
  z-index: 2;
}

.btn-toggle-eye:hover {
  color: var(--primary);
  background: rgba(15, 118, 110, 0.08);
}

.btn-toggle-eye:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}

#btn-submit-login {
  width: 100%;
  height: 50px;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 10px;
  box-sizing: border-box;
}

#btn-submit-login:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(15, 118, 110, 0.4);
}

#btn-submit-login:active {
  transform: translateY(0);
  box-shadow: 0 2px 8px rgba(15, 118, 110, 0.25);
}

.alert-box {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 0.875rem;
  margin-bottom: 20px;
  line-height: 1.4;
  box-sizing: border-box;
}

.alert-error {
  background: rgba(239, 68, 68, 0.1);
  border: 1px solid rgba(239, 68, 68, 0.3);
  color: #dc2626;
}

.alert-success {
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: #059669;
}

.login-footer {
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.security-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
  padding: 6px 14px;
  border-radius: 9999px;
  background: rgba(15, 118, 110, 0.04);
  border: 1px solid rgba(15, 118, 110, 0.12);
  max-width: 100%;
  box-sizing: border-box;
  flex-wrap: wrap;
  text-align: center;
  line-height: 1.4;
}

.security-badge span {
  white-space: normal;
  word-break: break-word;
}

/* Fluid Mobile & Tablet Adjustments for Login Screen */
@media (max-width: 640px) {
  .login-overlay {
    padding: 16px 12px;
  }

  .login-card {
    padding: 28px 18px 24px;
    border-radius: 24px;
    max-width: 100%;
    width: 100%;
  }

  .login-header {
    margin-bottom: 22px;
  }

  .login-logo {
    width: 64px;
    height: 64px;
    border-radius: 20px;
    margin-bottom: 14px;
  }

  .login-logo-img {
    height: 44px;
    max-width: 38px;
  }

  .login-brand {
    font-size: 1.5rem;
    gap: 8px;
  }

  .login-tagline {
    font-size: 0.8125rem;
  }

  .security-badge {
    font-size: 0.7rem;
    padding: 6px 12px;
    line-height: 1.35;
  }
}

/* User Account Dropdown */
.user-menu-container {
  position: relative;
}

.operator-badge:hover {
  border-color: var(--primary);
  background: var(--bg-card);
}

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 230px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 1000;
  overflow: hidden;
}

.dropdown-header {
  padding: 12px 14px;
  background: rgba(15, 118, 110, 0.06);
  border-bottom: 1px solid var(--border);
}

.dropdown-user-fullname {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dropdown-user-role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary);
  margin-top: 2px;
}

.dropdown-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 0;
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  font-size: 0.875rem;
  font-family: inherit;
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: background 0.15s;
}

.dropdown-item:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .dropdown-item:hover {
  background: rgba(255, 255, 255, 0.07);
}

.dropdown-item.danger {
  color: var(--danger);
}

.dropdown-item.danger:hover {
  background: rgba(239, 68, 68, 0.1);
}

/* -----------------------------------------------------------------------------
   Privacy Shield Protocol (Toggle Mask / Reveal Patient Names)
   ----------------------------------------------------------------------------- */
.btn-privacy-revealed {
  background: rgba(15, 118, 110, 0.12) !important;
  color: var(--primary) !important;
  border-color: var(--primary) !important;
  font-weight: 600 !important;
}
.patient-name-revealed {
  color: var(--primary);
  font-weight: 700;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.patient-name-masked {
  font-weight: 700;
  color: var(--text-main);
  cursor: help;
  text-decoration: underline dotted var(--text-muted);
}
.btn-icon-subtle {
  transition: background 0.15s, transform 0.1s;
}
.btn-icon-subtle:hover {
  background: var(--border) !important;
  transform: scale(1.05);
}

/* -----------------------------------------------------------------------------
   Smart Clinical Metrics Grid & Visual Hierarchy (Active vs Ghost States)
   ----------------------------------------------------------------------------- */
.clinical-section-box {
  margin-bottom: 16px;
  padding: 14px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.clinical-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.clinical-section-title {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  margin: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.status-pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.clinical-metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 10px;
  margin: 10px 0;
}

.metric-card {
  padding: 10px 12px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 76px;
  transition: all 0.2s ease;
}

.metric-card-active {
  background: rgba(15, 118, 110, 0.05);
  border: 1.5px solid rgba(15, 118, 110, 0.35);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

[data-theme="dark"] .metric-card-active {
  background: rgba(15, 118, 110, 0.15);
  border-color: rgba(20, 184, 166, 0.4);
}

.metric-card-ghost {
  background: transparent;
  border: 1px dashed var(--border);
  opacity: 0.58;
}

.metric-card-ghost:hover {
  opacity: 0.85;
}

.metric-label {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.metric-value-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px;
}

.metric-value {
  font-size: 1.125rem;
  font-weight: 700;
  font-family: var(--font-mono, monospace);
  color: var(--text-main);
  line-height: 1.2;
}

.metric-unit {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-left: 2px;
}

.metric-ghost-text {
  font-size: 0.8125rem;
  font-style: italic;
  color: var(--text-muted);
}

.metric-tag {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  margin-top: 4px;
  width: fit-content;
}

.metric-tag.tag-normal {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
}

.metric-tag.tag-warning {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
}

.metric-tag.tag-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #b91c1c;
}

/* Transfusion Styles */
.transfusion-bar-none {
  font-size: 0.8125rem;
  color: var(--text-muted);
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.02);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 6px;
}

.transfusion-alert-card {
  padding: 10px 12px;
  background: #fef2f2;
  border: 1.5px solid #f87171;
  border-radius: var(--radius);
  margin-top: 8px;
}

[data-theme="dark"] .transfusion-alert-card {
  background: rgba(239, 68, 68, 0.12);
  border-color: rgba(239, 68, 68, 0.4);
}

.transfusion-alert-title {
  font-size: 0.8125rem;
  font-weight: 700;
  color: #b91c1c;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
}

.transfusion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 4px;
}

.transfusion-chip {
  background: #fee2e2;
  color: #991b1b;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid #fca5a5;
}

/* Outcomes 30-Day Grid */
.outcomes-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 8px;
}

.outcome-card {
  padding: 8px 10px;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.outcome-card.active-clean {
  background: rgba(16, 185, 129, 0.05);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.outcome-card.active-adverse {
  background: rgba(239, 68, 68, 0.08);
  border: 1.5px solid rgba(239, 68, 68, 0.5);
}

.outcome-card.ghost {
  background: transparent;
  border: 1px dashed var(--border);
  opacity: 0.58;
}

/* CCI Slankamenac Box */
.cci-clean-box {
  background: rgba(16, 185, 129, 0.06);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-left: 4px solid #10b981;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

.cci-alert-box {
  background: rgba(239, 68, 68, 0.06);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-left: 4px solid #ef4444;
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 14px;
}

/* ==========================================================================
   Pathology & TNM Staging Engine V2.1 Styles
   ========================================================================== */
.pathology-status-segmented {
  display: flex;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 3px;
  gap: 4px;
  margin-bottom: 12px;
}

.pathology-status-btn,
.p2-path-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  font-size: 0.8125rem;
  font-weight: 600;
  border: none;
  background: transparent;
  color: var(--text-muted);
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  transition: all 0.18s ease;
}

.pathology-status-btn:hover,
.p2-path-btn:hover {
  color: var(--text-main);
  background: rgba(15, 118, 110, 0.06);
}

.pathology-status-btn.active,
.p2-path-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.pathology-organ-pills {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(135px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.organ-pill-btn,
.p2-organ-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 10px;
  font-size: 0.8125rem;
  font-weight: 600;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  cursor: pointer;
  transition: all 0.2s ease;
}

.organ-pill-btn:hover,
.p2-organ-btn:hover {
  border-color: var(--primary);
  transform: translateY(-1px);
}

.organ-pill-btn.active,
.p2-organ-btn.active {
  background: rgba(15, 118, 110, 0.1);
  border-color: var(--primary);
  color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
}

.organ-icon-svg {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.tnm-category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 6px;
  margin-top: 6px;
  margin-bottom: 12px;
}

.tnm-btn,
.p2-tnm-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 6px 10px;
  font-size: 0.75rem;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-main);
  cursor: pointer;
  text-align: left;
  transition: all 0.16s ease;
}

.tnm-btn:hover,
.p2-tnm-btn:hover {
  border-color: var(--primary);
  background: rgba(15, 118, 110, 0.04);
}

.tnm-btn.active,
.p2-tnm-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #ffffff;
}

.tnm-btn.active .tnm-btn-desc,
.p2-tnm-btn.active .tnm-btn-desc {
  color: rgba(255, 255, 255, 0.88);
}

.tnm-btn-code {
  font-weight: 700;
  font-size: 0.875rem;
  line-height: 1.2;
}

.tnm-btn-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  line-height: 1.25;
}

.pathology-stage-live-card {
  background: linear-gradient(135deg, rgba(15, 118, 110, 0.08), rgba(20, 184, 166, 0.12));
  border: 1px solid rgba(15, 118, 110, 0.3);
  border-left: 4px solid var(--primary);
  padding: 12px 16px;
  border-radius: var(--radius);
  margin-top: 14px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.pathology-stage-title {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-muted);
}

.pathology-stage-formula {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.02em;
}

.pathology-stage-badge {
  background: var(--primary);
  color: #ffffff;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 700;
  font-size: 0.875rem;
  box-shadow: 0 1px 3px rgba(15, 118, 110, 0.3);
}

.nodal-adequacy-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.75rem;
  padding: 3px 8px;
  border-radius: 4px;
  font-weight: 600;
  margin-top: 4px;
}

.nodal-adequacy-tag.adequate {
  background: rgba(16, 185, 129, 0.12);
  color: #059669;
  border: 1px solid rgba(16, 185, 129, 0.3);
}

.nodal-adequacy-tag.inadequate {
  background: rgba(245, 158, 11, 0.12);
  color: #d97706;
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.pathology-notice-box {
  background: rgba(15, 118, 110, 0.04);
  border: 1px dashed rgba(15, 118, 110, 0.3);
  padding: 14px 16px;
  border-radius: var(--radius);
  text-align: center;
  color: var(--text-muted);
  font-size: 0.875rem;
  margin-top: 6px;
}

/* ==========================================================================
   Phase Pill Cluster & Next Best Action Button (Phase Split Architecture)
   ========================================================================== */
.phase-pill-cluster {
  display: inline-flex;
  align-items: center;
  background: var(--bg-main, #f1f5f9);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.phase-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 6px;
  font-size: 0.6875rem;
  font-weight: 700;
  border-radius: 4px;
  border: 1px solid transparent;
  cursor: pointer;
  background: transparent;
  color: var(--text-muted, #64748b);
  transition: all 0.15s ease;
  white-space: nowrap;
}

.phase-pill:hover {
  background: rgba(0, 0, 0, 0.07);
  color: var(--text-main, #0f172a);
}

.phase-pill.pill-done {
  background: rgba(16, 185, 129, 0.15);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.25);
}

.phase-pill.pill-pending {
  background: rgba(245, 158, 11, 0.15);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.phase-pill.pill-active {
  background: rgba(14, 165, 233, 0.15);
  color: #0369a1;
  border-color: rgba(14, 165, 233, 0.25);
}

.phase-pill.pill-na {
  color: #94a3b8;
  opacity: 0.7;
  cursor: default;
}

/* Phase Pill & Cluster Dark Mode Enhancements (WCAG AAA Luminous Contrast) */
[data-theme="dark"] .phase-pill-cluster {
  background: #0b1120;
  border-color: #334155;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .phase-pill {
  color: #cbd5e1;
}

[data-theme="dark"] .phase-pill:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

[data-theme="dark"] .phase-pill.pill-done {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399; /* Emerald 400 - Sáng rõ rực rỡ, chữ ✓ P1, ✓ P2 cực kỳ sắc nét */
  border-color: rgba(52, 211, 153, 0.45);
  font-weight: 800;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .phase-pill.pill-pending {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24; /* Amber 400 - Vàng cam sáng nổi bật, chữ ⏳ P3 không bị bùn/chìm */
  border-color: rgba(251, 191, 36, 0.45);
  font-weight: 800;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .phase-pill.pill-active {
  background: rgba(14, 165, 233, 0.25);
  color: #38bdf8; /* Sky 400 - Xanh dương sáng */
  border-color: rgba(56, 189, 248, 0.45);
  font-weight: 800;
  text-shadow: 0 0 1px rgba(0, 0, 0, 0.5);
}

[data-theme="dark"] .phase-pill.pill-na {
  color: #94a3b8;
  opacity: 0.9; /* Độ hiển thị sắc nét, chữ — P4 không bị mờ nhạt */
  font-weight: 600;
}

/* Completeness Tracker & Indicators */
.completeness-tracker {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.completeness-header {
  display: flex;
  align-items: center;
  gap: 6px;
}

.completeness-label {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

[data-theme="dark"] .completeness-label {
  font-weight: 700;
  letter-spacing: 0.015em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

/* Base Badge System & Semantic Badges */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 1px 7px;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  border: 1px solid transparent;
}

.badge.badge-success {
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  border-color: rgba(16, 185, 129, 0.25);
}

.badge.badge-due {
  background: rgba(37, 99, 235, 0.12);
  color: #1d4ed8;
  border-color: rgba(37, 99, 235, 0.25);
}

.badge.badge-pending {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge.badge-neutral {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.2);
}

.badge.badge-warning {
  background: rgba(245, 158, 11, 0.12);
  color: #b45309;
  border-color: rgba(245, 158, 11, 0.25);
}

.badge.badge-danger {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
  border-color: rgba(239, 68, 68, 0.25);
}

.badge.badge-normal {
  background: rgba(100, 116, 139, 0.12);
  color: #475569;
  border-color: rgba(100, 116, 139, 0.2);
}

.badge.badge-approach {
  background: rgba(15, 118, 110, 0.12);
  color: #0f766e;
  border-color: rgba(15, 118, 110, 0.25);
}

/* Dark Mode Badges (Luminous, High Contrast WCAG AAA) */
[data-theme="dark"] .badge.badge-success {
  background: rgba(16, 185, 129, 0.25);
  color: #34d399;
  border-color: rgba(52, 211, 153, 0.4);
}

[data-theme="dark"] .badge.badge-due {
  background: rgba(59, 130, 246, 0.25);
  color: #60a5fa;
  border-color: rgba(96, 165, 250, 0.4);
}

[data-theme="dark"] .badge.badge-pending {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
}

[data-theme="dark"] .badge.badge-neutral {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border-color: rgba(203, 213, 225, 0.35);
}

[data-theme="dark"] .badge.badge-warning {
  background: rgba(245, 158, 11, 0.25);
  color: #fbbf24;
  border-color: rgba(251, 191, 36, 0.4);
}

[data-theme="dark"] .badge.badge-danger {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.4);
}

[data-theme="dark"] .badge.badge-normal {
  background: rgba(148, 163, 184, 0.2);
  color: #cbd5e1;
  border-color: rgba(203, 213, 225, 0.35);
}

[data-theme="dark"] .badge.badge-approach {
  background: rgba(20, 184, 166, 0.25);
  color: #2dd4bf;
  border-color: rgba(45, 212, 191, 0.4);
}

/* Utility Text Colors */
.text-success { color: var(--success, #15803d) !important; }
.text-warning { color: var(--warning, #b45309) !important; }
.text-danger { color: var(--danger, #b91c1c) !important; }
.text-muted { color: var(--text-muted, #475569) !important; }

[data-theme="dark"] .text-success { color: #34d399 !important; }
[data-theme="dark"] .text-warning { color: #fbbf24 !important; }
[data-theme="dark"] .text-danger { color: #f87171 !important; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }

/* Action Buttons in Table */
.btn-warning {
  background: var(--warning, #b45309);
  color: #ffffff;
  border-color: transparent;
}
.btn-warning:hover {
  background: #92400e;
}
.btn-danger {
  background: var(--danger, #b91c1c);
  color: #ffffff;
  border-color: transparent;
}
.btn-danger:hover {
  background: #991b1b;
}

[data-theme="dark"] .btn-warning {
  background: #d97706;
  color: #0f172a;
  font-weight: 700;
}
[data-theme="dark"] .btn-warning:hover {
  background: #f59e0b;
}
[data-theme="dark"] .btn-danger {
  background: #dc2626;
  color: #ffffff;
}
[data-theme="dark"] .btn-danger:hover {
  background: #ef4444;
}

/* Action Cell Layout (Desktop > 768px Scoped to #tab-cases) */
@media (min-width: 769px) {
  #tab-cases .data-table th,
  #tab-cases .data-table td {
    padding: 6px 8px;
  }

  #tab-cases .data-table th:last-child,
  #tab-cases .data-table td.action-cell-container {
    min-width: 250px;
    padding: 6px 8px;
    vertical-align: middle;
  }

  #tab-cases .action-cell-wrapper {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 3px;
    width: 100%;
    min-width: 0;
    box-sizing: border-box;
  }

  #tab-cases .action-buttons-row {
    display: flex;
    align-items: center;
    gap: 3px;
    flex-wrap: wrap;
    width: 100%;
  }

  #tab-cases .action-buttons-row .btn {
    padding: 2px 5px;
    font-size: 0.72rem;
    font-weight: 600;
    height: 24px;
    min-height: 24px;
    line-height: 1;
    border-radius: 5px;
    white-space: nowrap;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
  }

  #tab-cases .action-buttons-row .action-menu-wrapper {
    flex-shrink: 0;
  }

  #tab-cases .action-buttons-row .action-menu-wrapper .btn {
    padding: 2px 4px;
    min-width: 26px;
  }

  #tab-cases .action-cell-wrapper .phase-pill-cluster {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    margin-top: 2px;
    box-sizing: border-box;
  }

  #tab-cases .action-cell-wrapper .phase-pill {
    padding: 1px 4px;
    font-size: 0.65rem;
    height: 18px;
    min-height: 18px;
    line-height: 1;
    white-space: nowrap;
  }
}

.action-menu-wrapper {
  position: relative;
  display: inline-block;
}

.action-menu-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 4px;
  min-width: 190px;
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border, #e2e8f0);
  border-radius: 8px;
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  z-index: 50;
  display: none;
  flex-direction: column;
  padding: 4px 0;
}

.action-menu-dropdown.is-open {
  display: flex;
}

.action-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  font-size: 0.8125rem;
  color: var(--text-main, #0f172a);
  background: transparent;
  border: none;
  text-align: left;
  width: 100%;
  cursor: pointer;
  transition: background 0.1s ease;
}

.action-menu-item:hover {
  background: rgba(15, 118, 110, 0.08);
  color: var(--primary, #0f766e);
}

.action-menu-item.danger-item:hover {
  background: rgba(239, 68, 68, 0.08);
  color: var(--danger, #ef4444);
}

/* -----------------------------------------------------------------------------
 * Dark Mode Contrast Enhancements (Header, User Dropdown & Badges)
 * --------------------------------------------------------------------------- */
[data-theme="dark"] .operator-badge {
  background: var(--bg-card);
  color: #f1f5f9 !important;
  border-color: var(--border);
}

[data-theme="dark"] .operator-badge:hover {
  background: var(--bg-elevated);
  border-color: var(--primary);
}

[data-theme="dark"] .operator-name,
[data-theme="dark"] #header-operator-name {
  color: #f1f5f9 !important;
}

[data-theme="dark"] .operator-badge svg {
  color: #cbd5e1 !important;
}

[data-theme="dark"] .session-widget {
  background: var(--bg-card);
  color: #f1f5f9;
  border-color: var(--border);
}

[data-theme="dark"] .session-label {
  color: #94a3b8;
}

[data-theme="dark"] #btn-theme-toggle {
  background: var(--bg-card);
  color: #f1f5f9;
  border-color: var(--border);
}

[data-theme="dark"] .btn-icon {
  color: #f1f5f9;
}

[data-theme="dark"] .dropdown-header {
  background: rgba(20, 184, 166, 0.12);
  border-bottom: 1px solid var(--border);
}

[data-theme="dark"] .action-menu-dropdown {
  background: var(--bg-card, #131b2e);
  border-color: var(--border, #334155);
}

[data-theme="dark"] .action-menu-item {
  color: #f1f5f9;
}

[data-theme="dark"] .action-menu-item:hover {
  background: rgba(20, 184, 166, 0.15);
  color: #2dd4bf;
}

/* Dark Mode Multi-Specialty & Status Badges */
[data-theme="dark"] .badge-specialty {
  background: #1e293b;
  color: #cbd5e1;
}
[data-theme="dark"] .badge-specialty.colorectal { background: rgba(3, 105, 161, 0.25); color: #38bdf8; border: 1px solid rgba(56, 189, 248, 0.35); }
[data-theme="dark"] .badge-specialty.hpb { background: rgba(180, 83, 9, 0.25); color: #fbbf24; border: 1px solid rgba(251, 191, 36, 0.35); }
[data-theme="dark"] .badge-specialty.upper_gi { background: rgba(109, 40, 217, 0.25); color: #c084fc; border: 1px solid rgba(192, 132, 252, 0.35); }
[data-theme="dark"] .badge-specialty.proctology { background: rgba(190, 24, 93, 0.25); color: #f472b6; border: 1px solid rgba(244, 114, 182, 0.35); }
[data-theme="dark"] .badge-specialty.hernia { background: rgba(21, 128, 61, 0.25); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.35); }
[data-theme="dark"] .badge-specialty.emergency_general { background: rgba(185, 28, 28, 0.25); color: #f87171; border: 1px solid rgba(248, 113, 113, 0.35); }
[data-theme="dark"] .badge-specialty.other { background: rgba(71, 85, 105, 0.25); color: #cbd5e1; border: 1px solid rgba(203, 213, 225, 0.35); }

[data-theme="dark"] .badge-status.intraop { background: rgba(234, 179, 8, 0.25); color: #fde047; border: 1px solid rgba(253, 224, 71, 0.35); }
[data-theme="dark"] .badge-status.pending { background: rgba(249, 115, 22, 0.25); color: #fb923c; border: 1px solid rgba(251, 146, 60, 0.35); }
[data-theme="dark"] .badge-status.complete { background: rgba(22, 163, 74, 0.25); color: #4ade80; border: 1px solid rgba(74, 222, 128, 0.35); }
[data-theme="dark"] .badge-status.lost { background: rgba(100, 116, 139, 0.25); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.35); }

/* -----------------------------------------------------------------------------
 * Dark Mode Clinical Stats Summary Cards (High-Contrast Luminous HUD)
 * --------------------------------------------------------------------------- */
[data-theme="dark"] .stat-summary-card {
  background: linear-gradient(145deg, #182440 0%, #121b2f 100%);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 4px 16px -2px rgba(0, 0, 0, 0.45), inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .stat-summary-card:hover {
  border-color: rgba(148, 163, 184, 0.4);
  box-shadow: 0 6px 20px -2px rgba(0, 0, 0, 0.55), inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

[data-theme="dark"] .stat-summary-card.card-stat-total,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(1) {
  border-left: 4px solid #34d399 !important;
}
[data-theme="dark"] .stat-summary-card.card-stat-total .stat-summary-val,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(1) .stat-summary-val,
[data-theme="dark"] #stat-total-cases {
  color: #34d399 !important;
  text-shadow: 0 0 18px rgba(52, 211, 153, 0.4);
}

[data-theme="dark"] .stat-summary-card.card-stat-comp,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(2) {
  border-left: 4px solid #fbbf24 !important;
}
[data-theme="dark"] .stat-summary-card.card-stat-comp .stat-summary-val,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(2) .stat-summary-val,
[data-theme="dark"] #stat-complication-cases {
  color: #fbbf24 !important;
  text-shadow: 0 0 18px rgba(251, 191, 36, 0.4);
}

[data-theme="dark"] .stat-summary-card.card-stat-rate,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(3) {
  border-left: 4px solid #38bdf8 !important;
}
[data-theme="dark"] .stat-summary-card.card-stat-rate .stat-summary-val,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(3) .stat-summary-val,
[data-theme="dark"] #stat-complication-rate {
  color: #38bdf8 !important;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.4);
}

[data-theme="dark"] .stat-summary-card.card-stat-cci,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(4) {
  border-left: 4px solid #c084fc !important;
}
[data-theme="dark"] .stat-summary-card.card-stat-cci .stat-summary-val,
[data-theme="dark"] .clinical-stats-grid .stat-summary-card:nth-child(4) .stat-summary-val,
[data-theme="dark"] #stat-avg-cci {
  color: #c084fc !important;
  text-shadow: 0 0 18px rgba(192, 132, 252, 0.4);
}

/* Luminous, High-Contrast Labels for Dark Mode */
[data-theme="dark"] .stat-summary-lbl {
  color: #e2e8f0 !important;
  font-weight: 600 !important;
  letter-spacing: 0.015em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

/* Dark Mode CUSUM Status Cards */
[data-theme="dark"] .card-cusum-s,
[data-theme="dark"] .cusum-stats-grid .stat-summary-card:nth-child(1) {
  border-left: 4px solid #38bdf8 !important;
}
[data-theme="dark"] .card-cusum-s .stat-summary-val,
[data-theme="dark"] #cusum-current-s {
  color: #38bdf8 !important;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.4);
}

[data-theme="dark"] .card-cusum-thresh,
[data-theme="dark"] .cusum-stats-grid .stat-summary-card:nth-child(2) {
  border-left: 4px solid #f87171 !important;
}
[data-theme="dark"] .card-cusum-thresh .stat-summary-val {
  color: #f87171 !important;
  text-shadow: 0 0 18px rgba(248, 113, 113, 0.4);
}

[data-theme="dark"] .card-cusum-points,
[data-theme="dark"] .cusum-stats-grid .stat-summary-card:nth-child(3) {
  border-left: 4px solid #94a3b8 !important;
}
[data-theme="dark"] .card-cusum-points .stat-summary-val,
[data-theme="dark"] #cusum-total-points {
  color: #f8fafc !important;
}

[data-theme="dark"] .card-cusum-status,
[data-theme="dark"] .cusum-stats-grid .stat-summary-card:nth-child(4) {
  border-left: 4px solid #34d399 !important;
}
[data-theme="dark"] #cusum-alarm-status {
  text-shadow: 0 0 16px rgba(52, 211, 153, 0.4);
}

/* Dark Mode Worklist and Clinical Card Enhancements */
[data-theme="dark"] .worklist-card {
  background: linear-gradient(145deg, #182440 0%, #121b2f 100%) !important;
  border-color: rgba(148, 163, 184, 0.25) !important;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35) !important;
}
[data-theme="dark"] .worklist-card div:last-child {
  color: #cbd5e1 !important;
}

/* BUG-CSS-04: Dark Mode WCAG AA Contrast Fixes */
[data-theme="dark"] .work-reason {
  color: #fcd34d !important;
}
[data-theme="dark"] .transfusion-alert-title {
  color: #fca5a5 !important;
}
[data-theme="dark"] .toast-error {
  color: #fecaca !important;
}

/* BUG-A11Y-02: Minimum Touch Target Enforcement (>= 36px) */
.btn-phase,
.btn-action-trigger,
.specialty-pill,
.specialty-pill-btn,
.organ-pill-btn,
.pathology-status-btn,
.preset-chip {
  min-height: 36px;
}

/* BUG-MOB-04 & BUG-MOB-05: Mobile Stacking for Work Cards & Exam Status Rows */
@media (max-width: 640px) {
  .work-card {
    flex-direction: column !important;
    align-items: stretch !important;
    gap: 10px !important;
  }
  .exam-status-row {
    grid-template-columns: 1fr !important;
    gap: 8px !important;
  }
}
