/* ==========================================================================
   DOCTORS' INCENTIVE PORTAL — LUXURY FINTECH / HEALTHCARE DESIGN SYSTEM
   Curated by UI/UX Pro Max Intelligence
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  /* Font Families */
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Theme Tokens - Default Dark Mode (Executive OLED / Midnight Slate) */
  --bg-app: #090d16;
  --bg-surface: #0f172a;
  --bg-surface-elevated: #162035;
  --bg-card: rgba(22, 32, 53, 0.75);
  --bg-card-hover: rgba(30, 41, 68, 0.9);
  --bg-input: #0b1120;
  
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-medium: rgba(255, 255, 255, 0.14);
  --border-focus: #3b82f6;
  --border-accent: rgba(59, 130, 246, 0.4);

  /* Text & Foreground */
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-inverse: #090d16;

  /* Primary Brand Gradients & Accents */
  --primary: #3b82f6;
  --primary-hover: #2563eb;
  --primary-glow: rgba(59, 130, 246, 0.35);
  --primary-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%);
  
  --accent-cyan: #06b6d4;
  --accent-cyan-glow: rgba(6, 182, 212, 0.25);
  --accent-gradient: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);

  /* Financial Accents */
  --gold: #f59e0b;
  --gold-light: rgba(245, 158, 11, 0.15);
  --gold-glow: rgba(245, 158, 11, 0.3);
  --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #d97706 100%);

  --emerald: #10b981;
  --emerald-light: rgba(16, 185, 129, 0.14);
  --emerald-border: rgba(16, 185, 129, 0.3);
  --emerald-gradient: linear-gradient(135deg, #34d399 0%, #059669 100%);

  --danger: #ef4444;
  --danger-light: rgba(239, 68, 68, 0.15);
  --danger-border: rgba(239, 68, 68, 0.35);

  --purple: #8b5cf6;
  --purple-light: rgba(139, 92, 246, 0.15);

  /* Shadows & Glassmorphism */
  --glass-bg: rgba(15, 23, 42, 0.85);
  --glass-border: 1px solid rgba(255, 255, 255, 0.1);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 25px -5px var(--primary-glow);

  /* Radii & Transitions */
  --radius-xs: 4px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 9999px;
  --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
  --transition-smooth: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* Light Theme Variables */
[data-theme="light"] {
  --bg-app: #f1f5f9;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #ffffff;
  --bg-card: rgba(255, 255, 255, 0.95);
  --bg-card-hover: #ffffff;
  --bg-input: #f8fafc;
  
  --border-subtle: #e2e8f0;
  --border-medium: #cbd5e1;
  --border-focus: #2563eb;
  --border-accent: rgba(37, 99, 235, 0.3);

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  --text-inverse: #ffffff;

  --glass-bg: rgba(255, 255, 255, 0.92);
  --glass-border: 1px solid rgba(226, 232, 240, 0.9);
  --glass-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
  --shadow-card: 0 4px 15px -2px rgba(15, 23, 42, 0.05), 0 2px 6px -2px rgba(15, 23, 42, 0.03);
}

/* Base Styles */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 14.5px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-app);
  color: var(--text-primary);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  transition: background-color var(--transition-smooth), color var(--transition-smooth);
}

/* Atmospheric Ambient Background Glows */
body::before {
  content: '';
  position: fixed;
  top: -150px;
  left: 20%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.12) 0%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

body::after {
  content: '';
  position: fixed;
  bottom: 0;
  right: 10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(6, 182, 212, 0.08) 0%, transparent 70%);
  filter: blur(80px);
  pointer-events: none;
  z-index: 0;
}

/* Accessibility: Focus Visible */
*:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* SVGs & Icons */
.icon {
  width: 1.15rem;
  height: 1.15rem;
  stroke-width: 2;
  stroke: currentColor;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  pointer-events: none;
}

/* App Header & Modern Sticky Nav */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--glass-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--glass-border);
  box-shadow: var(--glass-shadow);
  transition: background-color var(--transition-smooth);
}

.header-container {
  max-width: 1720px;
  margin: 0 auto;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.brand-section {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  background: var(--primary-gradient);
  box-shadow: 0 0 20px -3px var(--primary-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  position: relative;
  overflow: hidden;
}

.brand-icon-wrap::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: linear-gradient(60deg, transparent, rgba(255,255,255,0.2), transparent);
  transform: rotate(30deg);
}

.brand-title-wrap h1 {
  font-size: 1.22rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 8px;
}

[data-theme="light"] .brand-title-wrap h1 {
  background: linear-gradient(135deg, #0f172a 40%, #3b82f6 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  background: var(--emerald-light);
  color: var(--emerald);
  border: 1px solid var(--emerald-border);
  -webkit-text-fill-color: initial;
}

.brand-subtitle {
  font-size: 0.78rem;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Header Controls Toolbar */
.header-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  max-width: 100%;
}

.header-controls::-webkit-scrollbar {
  display: none;
}

.control-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 5px 9px;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  transition: var(--transition-fast);
  white-space: nowrap;
  flex-shrink: 0;
}

.control-pill:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
  background: var(--bg-surface);
}

.control-pill input,
.control-pill select {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-weight: 700;
  font-size: 0.82rem;
  outline: none;
}

.control-pill input[type="text"] {
  width: 80px;
}

.control-pill input[type="number"] {
  width: 32px;
  text-align: center;
  font-family: var(--font-mono);
}

.control-pill select {
  cursor: pointer;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
  font-weight: 700;
  font-size: 0.82rem;
  transition: var(--transition-fast);
}

.control-pill select:hover {
  background: var(--bg-card-hover);
}

.control-pill select option {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  padding: 6px;
}

/* Button Component System */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 6px 11px;
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition-fast);
  white-space: nowrap;
  user-select: none;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

.btn-compact {
  padding: 5px 9px !important;
  font-size: 0.78rem !important;
  gap: 5px !important;
}

.btn-compact svg.icon {
  width: 14px;
  height: 14px;
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-md);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px -2px var(--primary-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 6px 20px 0 var(--primary-glow);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px -2px var(--accent-cyan-glow);
}

.btn-accent:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-emerald {
  background: var(--emerald-gradient);
  color: #ffffff;
  box-shadow: 0 4px 14px -2px rgba(16, 185, 129, 0.3);
}

.btn-emerald:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-danger-gradient {
  background: linear-gradient(135deg, #ef4444 0%, #b91c1c 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px -2px rgba(239, 68, 68, 0.3);
}

.btn-danger-gradient:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-glass {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.btn-glass:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-medium);
  transform: translateY(-1px);
}

.btn-icon-only {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 0.78rem;
  border-radius: var(--radius-sm);
}

/* View Mode Switcher Segmented Control */
.segmented-control {
  display: inline-flex;
  padding: 3px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  gap: 2px;
}

.segmented-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-family: inherit;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition-fast);
}

.segmented-btn:hover {
  color: var(--text-primary);
}

.segmented-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.4);
}

/* Main Layout Wrapper */
.main-wrapper {
  max-width: 1720px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  position: relative;
  z-index: 1;
}

/* Executive KPI Dashboard Cards */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
}

.kpi-card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-card);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  transition: transform var(--transition-smooth), border-color var(--transition-smooth), box-shadow var(--transition-smooth);
  position: relative;
  overflow: hidden;
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: transparent;
  transition: var(--transition-smooth);
}

.kpi-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-medium);
  box-shadow: 0 16px 32px -8px rgba(0, 0, 0, 0.45);
}

.kpi-card.blue::before { background: var(--primary-gradient); }
.kpi-card.emerald::before { background: var(--emerald-gradient); }
.kpi-card.gold::before { background: var(--gold-gradient); }
.kpi-card.cyan::before { background: var(--accent-gradient); }

.kpi-details .kpi-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-details .kpi-value {
  font-family: var(--font-mono);
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
}

.kpi-icon-box {
  width: 52px;
  height: 52px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-card.blue .kpi-icon-box { background: rgba(59, 130, 246, 0.12); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.25); }
.kpi-card.emerald .kpi-icon-box { background: var(--emerald-light); color: #34d399; border: 1px solid var(--emerald-border); }
.kpi-card.gold .kpi-icon-box { background: var(--gold-light); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }
.kpi-card.cyan .kpi-icon-box { background: var(--accent-cyan-glow); color: #22d3ee; border: 1px solid rgba(6, 182, 212, 0.3); }

/* Policy & Context Ribbon */
.policy-banner {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.policy-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.policy-input-wrap {
  flex: 1;
  min-width: 280px;
}

.policy-input-wrap input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
}

.policy-input-wrap input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

/* Glass Panels */
.panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  transition: border-color var(--transition-smooth);
}

.panel:hover {
  border-color: var(--border-medium);
}

.panel-header {
  padding: 16px 22px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.panel-title-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.badge-center {
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.badge-center.main {
  background: rgba(59, 130, 246, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(59, 130, 246, 0.35);
}

.badge-center.branch {
  background: var(--purple-light);
  color: #c084fc;
  border: 1px solid rgba(139, 92, 246, 0.35);
}

.panel-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.panel-subtitle {
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* Modern Data Grid / Table Architecture */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.82rem;
  min-width: 1180px;
}

.modern-table th,
.modern-table td {
  padding: 8px 9px;
  border-right: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  text-align: center;
  vertical-align: middle;
}

.modern-table th:last-child,
.modern-table td:last-child {
  border-right: none;
}

/* Multi-Tier Table Headers */
.th-tier-1 {
  background: #0b1329;
  color: #f1f5f9;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  padding: 10px 8px;
}

[data-theme="light"] .th-tier-1 {
  background: #0f172a;
  color: #ffffff;
}

.th-tier-2 {
  background: #111c38;
  color: #cbd5e1;
  font-size: 0.76rem;
  font-weight: 600;
}

[data-theme="light"] .th-tier-2 {
  background: #1e293b;
  color: #f8fafc;
}

.th-tier-3 {
  background: #17254a;
  color: #94a3b8;
  font-size: 0.74rem;
  font-weight: 600;
}

[data-theme="light"] .th-tier-3 {
  background: #334155;
  color: #f1f5f9;
}

.th-labels {
  background: rgba(255, 255, 255, 0.03);
  color: #93c5fd;
  font-weight: 700;
  font-size: 0.77rem;
}

[data-theme="light"] .th-labels {
  background: #f1f5f9;
  color: #1e40af;
}

.th-rates {
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 2px solid var(--border-medium) !important;
}

/* Rate Badge Widget */
.rate-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  transition: var(--transition-fast);
}

.rate-pill:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.rate-pill input {
  width: 36px;
  border: none;
  background: transparent;
  font-family: var(--font-mono);
  font-weight: 800;
  text-align: center;
  color: var(--gold);
  font-size: 0.82rem;
  outline: none;
}

.rate-pill span {
  font-weight: 800;
  color: var(--text-muted);
  font-size: 0.72rem;
}

/* Formula Code-style Hint Row */
.th-formula {
  background: rgba(0, 0, 0, 0.15);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

/* Body Rows & Interactive Hover */
.modern-table tbody tr {
  transition: background-color var(--transition-fast);
}

.modern-table tbody tr:hover {
  background-color: rgba(59, 130, 246, 0.05);
}

.modern-table tbody tr:hover td.cell-doc input {
  color: var(--primary);
}

/* Hide default HTML5 number input up/down spin buttons completely */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Cell Input Elements */
.cell-input {
  width: 100%;
  border: 1px solid transparent;
  background: transparent;
  font-family: inherit;
  font-size: 0.85rem;
  color: inherit;
  padding: 4px 4px;
  border-radius: var(--radius-sm);
  text-align: right;
  outline: none;
  transition: var(--transition-fast);
}

.cell-input:hover {
  background: rgba(255, 255, 255, 0.04);
}

[data-theme="light"] .cell-input:hover {
  background: #f1f5f9;
}

.cell-input:focus {
  background: var(--bg-input);
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
  color: var(--text-primary);
}

.cell-doc {
  text-align: left !important;
  font-weight: 700;
}

.cell-doc input {
  text-align: left !important;
  font-weight: 700;
  color: #93c5fd;
}

[data-theme="light"] .cell-doc input {
  color: var(--primary);
}

.cell-remark input {
  text-align: left !important;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

/* Calculated Columns */
.cell-calc {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  font-weight: 600;
  text-align: right !important;
  color: var(--text-secondary);
  background: rgba(0, 0, 0, 0.1);
  white-space: nowrap;
}

[data-theme="light"] .cell-calc {
  background: #f8fafc;
  color: #334155;
}

/* Gross & Net Highlight Cells (High Visual Hierarchy) */
.cell-gross {
  font-family: var(--font-mono);
  background: var(--emerald-light) !important;
  color: #34d399 !important;
  font-weight: 700;
  text-align: right !important;
  white-space: nowrap;
}

[data-theme="light"] .cell-gross {
  color: #065f46 !important;
}

.cell-net {
  font-family: var(--font-mono);
  background: var(--gold-light) !important;
  color: #fbbf24 !important;
  font-weight: 800;
  font-size: 0.92rem;
  text-align: right !important;
  white-space: nowrap;
  box-shadow: inset 0 0 10px rgba(245, 158, 11, 0.08);
}

[data-theme="light"] .cell-net {
  color: #92400e !important;
}

/* Action Cell / Row Delete Button */
.btn-del-row {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition-fast);
}

.btn-del-row:hover {
  background: var(--danger-light);
  color: var(--danger);
  transform: scale(1.1);
}

/* Table Footer Summary Totals */
.modern-table tfoot td {
  background: var(--bg-surface-elevated);
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
  border-top: 2px solid var(--border-medium);
  padding: 11px 9px;
  text-align: right;
  white-space: nowrap;
}

.modern-table tfoot td:first-child {
  font-family: var(--font-sans);
  font-weight: 800;
  text-align: left;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--primary);
}

.modern-table tfoot .tf-net {
  background: var(--gold-light) !important;
  color: var(--gold) !important;
  font-size: 1.05rem;
  font-weight: 800;
}

/* Mobile Responsive Cards (Grid alternative to Wide Table) */
.mobile-cards-grid {
  display: none;
  padding: 18px;
  gap: 16px;
}

.doctor-mobile-card {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  box-shadow: var(--shadow-card);
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.doctor-mobile-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.m-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 12px;
  margin-bottom: 14px;
}

.m-doc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
}

.m-card-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  border: 1px solid var(--border-subtle);
}

.m-pill {
  display: flex;
  flex-direction: column;
}

.m-pill span:first-child {
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.m-pill span:last-child {
  font-family: var(--font-mono);
  font-size: 1.15rem;
  font-weight: 800;
}

.m-gross { color: #34d399 !important; }
.m-net { color: #fbbf24 !important; }

.m-input-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.m-input-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.m-input-item label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
}

.m-input-item input {
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 0.88rem;
  font-family: var(--font-mono);
  padding: 7px 10px;
  outline: none;
}

.m-input-item input:focus {
  border-color: var(--border-focus);
}

/* Toast Notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border-medium);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  font-weight: 600;
  box-shadow: 0 20px 40px -5px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 10px;
  opacity: 0;
  transform: translateY(14px) scale(0.95);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast .toast-icon {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-full);
  background: var(--emerald-light);
  color: var(--emerald);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  flex-shrink: 0;
}

/* Full History Sheets Modal (Editable Ledger) */
.history-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  overflow-y: auto;
  padding: 24px;
}

.history-modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 1680px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  overflow: hidden;
}

.history-modal-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--bg-surface-elevated);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  position: sticky;
  top: 0;
  z-index: 10;
}

.history-modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.history-month-block {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow-card);
}

.history-month-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border-subtle);
}

/* Consolidated Print & PDF Modes */
#multiExportArea {
  display: none;
  background: #ffffff;
  color: #0f172a;
  padding: 0;
  margin: 0 auto;
  width: 1100px;
  box-sizing: border-box;
}

body.multi-pdf-mode #exportArea,
body.multi-pdf-mode .app-header,
body.multi-pdf-mode .no-print {
  display: none !important;
}

body.multi-pdf-mode #multiExportArea {
  display: block !important;
}

@page {
  size: A4 landscape;
  margin: 6mm;
}

/* View Mode Toggle: Works globally on any screen resolution */
body.mobile-view .table-responsive {
  display: none !important;
}

body.mobile-view .mobile-cards-grid {
  display: grid !important;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 340px), 1fr)) !important;
  gap: 16px;
  padding: 16px;
  width: 100%;
  box-sizing: border-box;
}

/* ================= DOCTOR MOBILE CARDS STYLING ================= */
.mobile-cards-grid {
  display: none;
  width: 100%;
  box-sizing: border-box;
}

.doctor-mobile-card {
  background: var(--bg-card);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  transition: transform var(--transition-fast), border-color var(--transition-fast);
}

.doctor-mobile-card:hover {
  border-color: var(--border-medium);
  transform: translateY(-2px);
}

.m-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-subtle);
  min-width: 0;
}

.m-doc-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.m-doc-title .f-doc {
  font-size: 0.95rem;
  font-weight: 800;
  border-bottom: 1px dashed transparent;
  padding: 4px 6px;
  min-width: 0;
  width: 100% !important;
  max-width: 220px;
}

.m-doc-title .f-doc:focus {
  border-bottom-color: var(--primary);
}

.m-card-pills {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.m-pill {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  overflow: hidden;
}

[data-theme="light"] .m-pill {
  background: #f8fafc;
}

.m-pill span:first-child {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-transform: uppercase;
}

.m-pill .m-gross {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #34d399;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-pill .m-net {
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 800;
  color: #fbbf24;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Inputs Responsive 2-Column Grid */
.m-input-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: 100%;
  box-sizing: border-box;
}

.m-input-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.m-input-item label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.m-input-item input {
  width: 100% !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-family: inherit;
  font-size: 0.85rem;
  color: var(--text-primary);
  outline: none;
  transition: var(--transition-fast);
  min-width: 0;
}

.m-input-item input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

@media (max-width: 480px) {
  body.mobile-view .mobile-cards-grid {
    grid-template-columns: 1fr !important;
    padding: 10px;
    gap: 12px;
  }

  .m-input-grid {
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

/* Print and Single Month PDF Mode: Fits 100% on 1 landscape A4 page with zero cut-off */
body.pdf-mode .no-print,
body.pdf-mode .app-header,
body.pdf-mode .kpi-grid,
body.pdf-mode .btn,
body.pdf-mode .segmented-control,
body.pdf-mode .btn-del-row,
body.pdf-mode .action-col,
body.pdf-mode .mobile-cards-grid,
body.pdf-mode .badge-center,
body.pdf-mode .panel-subtitle {
  display: none !important;
}

body.pdf-mode .table-responsive {
  display: block !important;
  overflow: visible !important;
  width: 100% !important;
}

body.pdf-mode {
  background: #ffffff !important;
  color: #000000 !important;
}

body.pdf-mode .main-wrapper {
  padding: 0 !important;
  margin: 0 !important;
  gap: 6px !important;
  max-width: 100% !important;
  width: 100% !important;
}

body.pdf-mode .policy-banner {
  padding: 4px 8px !important;
  margin-bottom: 4px !important;
  border: 1px solid #94a3b8 !important;
}

body.pdf-mode .panel {
  box-shadow: none !important;
  border: 1px solid #94a3b8 !important;
  background: #ffffff !important;
  margin-bottom: 6px !important;
  border-radius: 4px !important;
}

body.pdf-mode .panel-header {
  padding: 4px 8px !important;
  background: #f1f5f9 !important;
}

body.pdf-mode .panel-title {
  font-size: 0.95rem !important;
  color: #0f172a !important;
}

body.pdf-mode .modern-table {
  width: 100% !important;
  font-size: 7.2px !important;
  table-layout: fixed !important;
}

body.pdf-mode .modern-table th,
body.pdf-mode .modern-table td {
  padding: 2px 2px !important;
  border: 1px solid #718096 !important;
  color: #000000 !important;
  overflow: hidden !important;
  text-overflow: clip !important;
}

body.pdf-mode .modern-table td.cell-doc input {
  font-size: 7.5px !important;
  font-weight: 700 !important;
  text-align: left !important;
  width: 100% !important;
}

body.pdf-mode .modern-table td.cell-net,
body.pdf-mode .modern-table td.cell-gross,
body.pdf-mode .modern-table td.tf-net {
  font-size: 7.6px !important;
  font-weight: 800 !important;
  text-align: right !important;
  padding-right: 3px !important;
  white-space: nowrap !important;
  overflow: visible !important;
}

body.pdf-mode .th-tier-1,
body.pdf-mode .th-tier-2,
body.pdf-mode .th-tier-3 {
  background: #e2e8f0 !important;
  color: #0f172a !important;
}

body.pdf-mode .cell-input {
  padding: 0 !important;
  font-size: 7.2px !important;
}

@page {
  size: A4 landscape;
  margin: 4mm;
}

@media print {
  body {
    background: #ffffff !important;
    color: #000000 !important;
    font-size: 7.2px !important;
  }

  body::before, body::after {
    display: none !important;
  }

  .no-print,
  .app-header,
  .kpi-grid,
  .btn,
  .segmented-control,
  .btn-del-row,
  .action-col,
  .mobile-cards-grid,
  .badge-center,
  .panel-subtitle {
    display: none !important;
  }

  .table-responsive {
    display: block !important;
    overflow: visible !important;
    width: 100% !important;
  }

  .main-wrapper {
    padding: 0 !important;
    margin: 0 !important;
    gap: 6px !important;
    max-width: 100% !important;
    width: 100% !important;
  }

  .policy-banner {
    padding: 4px 8px !important;
    margin-bottom: 4px !important;
    border: 1px solid #718096 !important;
  }

  .panel {
    border: 1px solid #718096 !important;
    box-shadow: none !important;
    background: #ffffff !important;
    margin-bottom: 6px !important;
    border-radius: 4px !important;
    page-break-inside: avoid;
  }

  .panel-header {
    background: #f1f5f9 !important;
    padding: 4px 8px !important;
  }

  .panel-title {
    font-size: 0.95rem !important;
    color: #0f172a !important;
  }

  .modern-table {
    width: 100% !important;
    font-size: 7.2px !important;
    table-layout: fixed !important;
  }

  .modern-table th,
  .modern-table td {
    padding: 2px 2px !important;
    border: 1px solid #718096 !important;
    color: #000000 !important;
    overflow: hidden !important;
    text-overflow: clip !important;
  }

  .modern-table td.cell-doc input {
    font-size: 7.5px !important;
    font-weight: 700 !important;
    text-align: left !important;
    width: 100% !important;
  }

  .modern-table td.cell-net,
  .modern-table td.cell-gross,
  .modern-table td.tf-net {
    font-size: 7.6px !important;
    font-weight: 800 !important;
    text-align: right !important;
    padding-right: 3px !important;
    white-space: nowrap !important;
    overflow: visible !important;
  }

  .th-tier-1, .th-tier-2, .th-tier-3 {
    background: #e2e8f0 !important;
    color: #0f172a !important;
  }

  .cell-input {
    padding: 0 !important;
    font-size: 7.2px !important;
  }

  .rate-pill {
    border: none !important;
    padding: 0 !important;
  }

  .rate-pill input {
    width: auto !important;
    color: #000000 !important;
  }
}

/* Media Queries for Mobile & Tablets */
@media (max-width: 1200px) {
  .kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  .brand-section {
    justify-content: space-between;
  }

  .header-controls {
    justify-content: flex-start;
  }

  .main-wrapper {
    padding: 12px;
    gap: 14px;
  }

  .kpi-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }
}

@media (max-width: 480px) {
  .control-pill {
    flex: 1 1 100%;
    justify-content: space-between;
  }

  .control-pill input[type="text"],
  .control-pill select {
    flex: 1;
    text-align: right;
  }

  .btn {
    flex: 1 1 100%;
  }
}

/* ================= EXCEL UPLOAD AUDIT SUMMARY CARD ================= */
.upload-summary-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 5px solid var(--primary);
  border-radius: var(--radius-lg);
  padding: 18px 24px;
  box-shadow: var(--shadow-md);
  animation: fadeInDown 0.3s ease-out;
}

.upload-summary-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-summary-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-primary);
}

.upload-summary-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

.summary-stat-box {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 14px;
}

[data-theme="light"] .summary-stat-box {
  background: rgba(0, 0, 0, 0.02);
}

.stat-box-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
}

.stat-box-val {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 4px;
}

.summary-stat-box.success .stat-box-val { color: var(--emerald); }
.summary-stat-box.warning .stat-box-val { color: var(--gold); }
.summary-stat-box.info .stat-box-val { color: var(--cyan); }

.upload-summary-note {
  font-size: 0.85rem;
  color: var(--text-secondary);
  background: rgba(245, 158, 11, 0.1);
  border: 1px dashed rgba(245, 158, 11, 0.35);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  gap: 8px;
}

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

