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

:root {
  /* Default Light Theme — Clean White Sidebar */
  --sidebar-bg: #ffffff;
  --sidebar-border: #e2e8f0;
  --sidebar-hover: #f1f5f9;
  --sidebar-hover-text: #0f172a;
  --sidebar-active: #eff6ff;
  --sidebar-active-border: #bfdbfe;
  --sidebar-text: #475569;
  --sidebar-text-active: #2563eb;
  --sidebar-logo-text: #0f172a;
  --sidebar-sub-border: #cbd5e1;
  
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #0284c7;
  --info-light: #f0f9ff;
  
  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
}

/* Dark Theme — Black/Slate Sidebar & Dark Workspace */
[data-theme="dark"] {
  --sidebar-bg: #0f172a;
  --sidebar-border: #1e293b;
  --sidebar-hover: #1e293b;
  --sidebar-hover-text: #f1f5f9;
  --sidebar-active: #2563eb;
  --sidebar-active-border: transparent;
  --sidebar-text: #94a3b8;
  --sidebar-text-active: #ffffff;
  --sidebar-logo-text: #ffffff;
  --sidebar-sub-border: #334155;

  --bg-main: #0b1120;
  --bg-card: #1e293b;
  --border-color: #334155;
  --border-subtle: #1e293b;

  --text-primary: #f8fafc;
  --text-secondary: #cbd5e1;
  --text-muted: #94a3b8;
  --primary-light: rgba(37, 99, 235, 0.18);
}

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

body {
  font-family: var(--font-sans);
  background-color: var(--bg-main);
  color: var(--text-primary);
  display: flex;
  height: 100vh;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  transition: background-color 0.2s ease, color 0.2s ease;
}

/* ── App Shell ────────────────────────────────────────────── */
#app-container {
  display: flex;
  width: 100vw;
  height: 100vh;
}

/* ── Sidebar ──────────────────────────────────────────────── */
.sidebar {
  width: 254px;
  background-color: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid var(--sidebar-border);
  z-index: 20;
  position: relative;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.sidebar-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  border-bottom: 1px solid var(--sidebar-border);
}

.logo-badge {
  width: 34px;
  height: 34px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.35);
}

.logo-text {
  font-size: 16px;
  font-weight: 700;
  color: var(--sidebar-logo-text);
  letter-spacing: -0.3px;
}

.logo-sub {
  font-size: 10px;
  color: #0284c7;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
[data-theme="dark"] .logo-sub {
  color: #38bdf8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar-nav::-webkit-scrollbar {
  width: 0px;
  height: 0px;
  display: none;
}

/* Clean Scroll Up / Down Bar inside Sidebar */
.sidebar-scroll-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: calc(100% - 24px);
  margin: 4px 12px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid var(--sidebar-border);
  background: var(--bg-main);
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}
.sidebar-scroll-btn:hover {
  background: var(--primary-light);
  color: var(--primary);
  border-color: #93c5fd;
}
.sidebar-scroll-btn.hidden-scroll {
  display: none;
}

.nav-section-title {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #64748b;
  padding: 10px 12px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background-color: var(--sidebar-hover);
  color: var(--sidebar-hover-text);
}

.nav-item.active {
  background-color: var(--sidebar-active);
  color: var(--sidebar-text-active);
  border-color: var(--sidebar-active-border);
  font-weight: 600;
  box-shadow: 0 1px 3px rgba(37, 99, 235, 0.12);
}
[data-theme="dark"] .nav-item.active {
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.3);
}

.nav-icon {
  width: 18px;
  height: 18px;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tenant-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--sidebar-text);
}

.tenant-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--success);
}

.sidebar-logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: #ef4444;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
}
.sidebar-logout-btn:hover {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #dc2626;
}
[data-theme="dark"] .sidebar-logout-btn {
  background: #1e293b;
  border-color: #334155;
  color: #f87171;
}
[data-theme="dark"] .sidebar-logout-btn:hover {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
  color: #fca5a5;
}

/* Mobile logout header button - hidden on desktop */
#btn-mobile-logout,
.mobile-logout-header-btn {
  display: none !important;
}

/* ── Main View Container ──────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ── Top Header ───────────────────────────────────────────── */
.top-header {
  height: 64px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* Organization Switcher Dropdown */
.org-switcher-badge {
  display: flex;
  align-items: center;
  gap: 10px;
  background-color: #f8fafc;
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s ease;
}

.org-switcher-badge:hover {
  background-color: #f1f5f9;
  border-color: #cbd5e1;
}

.org-flag {
  font-size: 18px;
}

.org-name-text {
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-primary);
}

.org-regime-tag {
  font-size: 10.5px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  background-color: var(--primary-light);
  color: var(--primary);
  text-transform: uppercase;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-quick-add {
  background-color: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease;
  box-shadow: 0 1px 2px rgba(37, 99, 235, 0.2);
}

.btn-quick-add:hover {
  background-color: var(--primary-hover);
}

.btn-secondary {
  background-color: white;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.btn-secondary:hover {
  background-color: #f8fafc;
  border-color: #cbd5e1;
}

/* ── Page Content Scrollable Area ─────────────────────────── */
.page-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
}

/* ── KPI Grid ─────────────────────────────────────────────── */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.kpi-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.kpi-icon-wrap {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--text-primary);
  letter-spacing: -0.5px;
}

.kpi-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── Content Cards & Tables ───────────────────────────────── */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  margin-bottom: 24px;
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafbfc;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* ── Tables ───────────────────────────────────────────────── */
.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 13.5px;
}

.data-table th {
  background-color: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-primary);
}

.data-table tr:hover td {
  background-color: #f8fafc;
}

.font-mono {
  font-family: var(--font-mono);
}

.text-right {
  text-align: right;
}

/* ── Status Badges ────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 9999px;
  font-size: 11.5px;
  font-weight: 600;
  text-transform: capitalize;
}

.badge-posted, .badge-paid {
  background-color: var(--success-light);
  color: #059669;
}

.badge-customer {
  background-color: var(--primary-light);
  color: var(--primary);
}

.badge-supplier {
  background-color: #f5f3ff;
  color: #7c3aed;
}

.contact-pill {
  border: none;
  background: transparent;
  padding: 6px 14px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.contact-pill:hover:not(.active) {
  color: #1e293b;
}

.contact-pill.active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.badge-draft {
  background-color: #f1f5f9;
  color: #475569;
}

.badge-sent, .badge-partially_paid {
  background-color: var(--info-light);
  color: #0284c7;
}

.badge-overdue {
  background-color: var(--danger-light);
  color: #dc2626;
}

/* ── Slide-over Drawers & Modals ──────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  z-index: 2200;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.active {
  display: flex;
}

.modal-card {
  background: white;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 760px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: modalScale 0.2s ease-out;
}

@keyframes modalScale {
  from { transform: scale(0.96); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background-color: #fafbfc;
}

.modal-title {
  font-size: 17px;
  font-weight: 700;
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  background-color: #fafbfc;
}

/* ── Form Controls ────────────────────────────────────────── */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 13.5px;
  background-color: #ffffff;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s ease;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* ── Toast Notifications ──────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  background-color: #0f172a;
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 13.5px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ── Global Search in Header ─────────────────────────────── */
.global-search-container {
  display: flex;
  align-items: center;
  gap: 8px;
  background-color: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 6px 12px;
  width: 320px;
  transition: all 0.2s ease;
}

.global-search-container:focus-within {
  background-color: #ffffff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
  width: 380px;
}

.global-search-container .search-icon {
  width: 16px;
  height: 16px;
  color: #64748b;
  flex-shrink: 0;
}

.global-search-container input {
  border: none;
  background: transparent;
  outline: none;
  font-size: 13px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  width: 100%;
}

.search-kbd-badge {
  font-size: 11px;
  font-weight: 700;
  color: #94a3b8;
  background-color: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 1px 6px;
  border-radius: 4px;
  line-height: 1.2;
}

/* ── Dashboard Sub-Navigation ────────────────────────────── */
.dash-subnav {
  display: flex;
  gap: 24px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 20px;
  padding-bottom: 0px;
}

.dash-tab {
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: #64748b;
  padding: 8px 4px 12px;
  cursor: pointer;
  position: relative;
  transition: color 0.15s ease;
}

.dash-tab:hover {
  color: #0f172a;
}

.dash-tab.active {
  color: #2563eb;
}

.dash-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2.5px;
  background-color: #2563eb;
  border-radius: 2px 2px 0 0;
}

/* ── Grid Layouts ────────────────────────────────────────── */
.dash-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

.dash-row {
  margin-bottom: 20px;
}

/* ── Executive Dashboard Cards ───────────────────────────── */
.dash-card {
  background-color: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
  transition: box-shadow 0.2s ease;
}

.dash-card:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}

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

.dash-card-title {
  font-size: 14.5px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.2px;
}

.dash-card-badge {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 4px;
  background-color: #f1f5f9;
  color: #64748b;
  letter-spacing: 0.5px;
}

.dash-metric-huge {
  font-size: 26px;
  font-weight: 800;
  color: #0f172a;
  margin-bottom: 14px;
  letter-spacing: -0.5px;
}

/* Dual-Color Progress Bar */
.progress-bar-wrap {
  width: 100%;
  height: 8px;
  background-color: #f1f5f9;
  border-radius: 999px;
  display: flex;
  overflow: hidden;
  margin-bottom: 12px;
}

.progress-segment {
  height: 100%;
  transition: width 0.4s ease;
}

.seg-blue {
  background-color: #2563eb;
}

.seg-orange {
  background-color: #f97316;
}

.seg-green {
  background-color: #10b981;
}

.dash-metric-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  color: #64748b;
}

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

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.dot-blue { background-color: #2563eb; }
.dot-orange { background-color: #f97316; }
.dot-green { background-color: #10b981; }
.dot-red { background-color: #ef4444; }
.dot-coral { background-color: #f43f5e; }
.dot-gray { background-color: #94a3b8; }

.tag-overdue {
  font-size: 11px;
  font-weight: 700;
  color: #ea580c;
  background-color: #fff7ed;
  padding: 1px 6px;
  border-radius: 4px;
}

/* ── Select & Toggles in Dashboard ────────────────────────── */
.dash-select {
  border: 1px solid #cbd5e1;
  background-color: #ffffff;
  border-radius: var(--radius-sm);
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  outline: none;
  cursor: pointer;
}

.toggle-pill-group {
  display: flex;
  background-color: #f1f5f9;
  border-radius: var(--radius-sm);
  padding: 2px;
}

.toggle-pill {
  border: none;
  background: transparent;
  padding: 3px 10px;
  font-size: 11.5px;
  font-weight: 600;
  color: #64748b;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.toggle-pill.active {
  background-color: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* ── Cash Flow Section Layout ────────────────────────────── */
.cashflow-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  align-items: center;
}

.cashflow-chart-container {
  width: 100%;
  height: 220px;
  position: relative;
}

.cashflow-summary-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background-color: #f8fafc;
  border-radius: var(--radius-md);
  border: 1px solid #e2e8f0;
}

.cf-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.cf-item.cf-highlight {
  padding-top: 10px;
  border-top: 1px dashed #cbd5e1;
}

.cf-label {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 6px;
}

.cf-val {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: -0.3px;
}

/* ── Income & Expense Chart ──────────────────────────────── */
.income-expense-header {
  display: flex;
  gap: 20px;
  margin-bottom: 12px;
}

.legend-badge {
  font-size: 13px;
  color: #475569;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.bar-chart-container {
  width: 100%;
  height: 220px;
}

.dash-footnote {
  font-size: 11px;
  color: #94a3b8;
  margin-top: 10px;
  font-style: italic;
}

/* ── Top Expenses Donut Section ───────────────────────────── */
.top-expenses-body {
  display: flex;
  align-items: center;
  gap: 20px;
}

.donut-wrap {
  width: 190px;
  height: 190px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.donut-legend {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 190px;
  overflow-y: auto;
}

.donut-legend-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.donut-legend-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #334155;
  font-weight: 500;
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.donut-legend-val {
  font-weight: 600;
  color: #0f172a;
}

/* ── Journal Entries Module Styling ──────────────────────── */
.nav-item:hover .nav-sub-add,
.nav-item.active .nav-sub-add {
  opacity: 1 !important;
}

.badge-source-manual {
  background-color: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-source-invoice {
  background-color: #eff6ff;
  color: #2563eb;
  border: 1px solid #bfdbfe;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-source-bill {
  background-color: #fffbeb;
  color: #d97706;
  border: 1px solid #fde68a;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-source-banking {
  background-color: #ecfeff;
  color: #0891b2;
  border: 1px solid #a5f3fc;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-source-expense {
  background-color: #faf5ff;
  color: #7c3aed;
  border: 1px solid #e9d5ff;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-source-default {
  background-color: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  padding: 2px 7px;
  border-radius: 4px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.journal-row-clickable {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.journal-row-clickable:hover {
  background-color: #f8fafc;
}

@media print {
  body * {
    visibility: hidden !important;
  }
  #journal-view-modal.active,
  #journal-view-modal.active .modal-card,
  #journal-view-modal.active .modal-card * {
    visibility: visible !important;
  }
  #journal-view-modal.active {
    position: absolute !important;
    left: 0 !important;
    top: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    background: #ffffff !important;
    backdrop-filter: none !important;
    display: block !important;
    padding: 0 !important;
    box-shadow: none !important;
  }
  #journal-view-modal .modal-card {
    box-shadow: none !important;
    max-width: 100% !important;
    width: 100% !important;
    border: none !important;
  }
  #journal-view-modal .modal-footer,
  #journal-view-modal .btn-close-modal {
    display: none !important;
  }
}

/* ── Dark Mode Workspace & Component Overrides ─────────────────────── */
[data-theme="dark"] .top-header {
  background-color: #0f172a;
  border-bottom-color: #1e293b;
}
[data-theme="dark"] .org-switcher-badge,
[data-theme="dark"] .global-search-container,
[data-theme="dark"] #header-user-pill {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] #header-user-name,
[data-theme="dark"] .org-name-text {
  color: #f8fafc !important;
}
[data-theme="dark"] #global-search-input {
  color: #f8fafc !important;
}
[data-theme="dark"] .dash-card,
[data-theme="dark"] .card,
[data-theme="dark"] .kpi-card,
[data-theme="dark"] .table-card,
[data-theme="dark"] .modal-card,
[data-theme="dark"] .im-card,
[data-theme="dark"] .im-kpi,
[data-theme="dark"] .bd-card,
[data-theme="dark"] .zb-table-card,
[data-theme="dark"] .cd-card,
[data-theme="dark"] .cd-info-card,
[data-theme="dark"] .dbl-card,
[data-theme="dark"] .ep-card,
[data-theme="dark"] .pm-card,
[data-theme="dark"] .po-card,
[data-theme="dark"] .rm-card {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .im-toolbar,
[data-theme="dark"] .bd-toolbar,
[data-theme="dark"] .zb-bulk-bar,
[data-theme="dark"] .sub-top-bar,
[data-theme="dark"] .report-toolbar {
  background-color: #1e293b !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .im-seg,
[data-theme="dark"] .zb-seg-group,
[data-theme="dark"] .cd-nav,
[data-theme="dark"] .ep-tab-nav {
  background-color: #0f172a !important;
  border: 1px solid #334155 !important;
}
[data-theme="dark"] .im-search,
[data-theme="dark"] .bd-search,
[data-theme="dark"] .dbl-search-box {
  background-color: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .im-search input,
[data-theme="dark"] .bd-search input,
[data-theme="dark"] .dbl-search-box input {
  background-color: transparent !important;
  color: #f8fafc !important;
}
[data-theme="dark"] .dash-card-title,
[data-theme="dark"] .dash-metric-huge,
[data-theme="dark"] .page-title,
[data-theme="dark"] .card-title,
[data-theme="dark"] .cf-val {
  color: #f8fafc !important;
}
[data-theme="dark"] .cashflow-summary-panel,
[data-theme="dark"] .dash-card-badge,
[data-theme="dark"] .progress-bar-wrap,
[data-theme="dark"] .toggle-pill-group {
  background-color: #0f172a !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .data-table th {
  background-color: #0f172a !important;
  color: #94a3b8 !important;
  border-bottom-color: #334155 !important;
}
[data-theme="dark"] .data-table td {
  border-bottom-color: #334155 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .data-table tr:hover td {
  background-color: rgba(51, 65, 85, 0.45) !important;
}
[data-theme="dark"] .btn-secondary,
[data-theme="dark"] .dash-select {
  background-color: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
  background-color: #0f172a;
  color: #f8fafc;
  border-color: #334155;
}

/* Light Mode overrides for Subscription & Super Admin sidebar links */
html:not([data-theme="dark"]) #nav-subscription span {
  color: #065f46 !important;
}
html:not([data-theme="dark"]) #nav-super-admin-section .sa-side-link span:first-of-type {
  color: #1e293b !important;
}

/* Light Mode Navigation Group Toggles (Items & Pricing, Sales, Purchases, Expenses) */
html:not([data-theme="dark"]) .nav-group-toggle {
  color: #334155 !important;
  background-color: transparent !important;
}
html:not([data-theme="dark"]) .nav-group-toggle span {
  color: #334155 !important;
}
html:not([data-theme="dark"]) .nav-group-toggle .nav-icon {
  stroke: #475569 !important;
  color: #475569 !important;
}
html:not([data-theme="dark"]) .nav-group-toggle .nav-chevron {
  stroke: #64748b !important;
  color: #64748b !important;
}
html:not([data-theme="dark"]) .nav-group-toggle:hover,
html:not([data-theme="dark"]) .nav-group-toggle:focus,
html:not([data-theme="dark"]) .nav-group-toggle:focus-visible {
  background-color: #f1f5f9 !important;
  color: #0f172a !important;
}
html:not([data-theme="dark"]) .nav-group-toggle:hover span,
html:not([data-theme="dark"]) .nav-group-toggle:focus span {
  color: #0f172a !important;
}
html:not([data-theme="dark"]) .nav-group.open > .nav-group-toggle {
  background-color: #f8fafc !important;
  border-color: #e2e8f0 !important;
}
html:not([data-theme="dark"]) .nav-group.open > .nav-group-toggle span {
  color: #1e293b !important;
}
html:not([data-theme="dark"]) .nav-group.has-active > .nav-group-toggle {
  background-color: #eff6ff !important;
  border-color: #bfdbfe !important;
  color: #2563eb !important;
}
html:not([data-theme="dark"]) .nav-group.has-active > .nav-group-toggle span,
html:not([data-theme="dark"]) .nav-group.has-active > .nav-group-toggle .nav-icon,
html:not([data-theme="dark"]) .nav-group.has-active > .nav-group-toggle .nav-chevron {
  color: #2563eb !important;
  stroke: #2563eb !important;
}

/* ── Top Header Theme Toggle & AI Copilot Buttons ──────────────────── */
.btn-icon-header {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 11px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.18s ease;
}
.btn-icon-header:hover {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary);
}
.btn-ai-header {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 36px;
  padding: 0 13px 0 11px;
  border-radius: 999px;
  background: linear-gradient(135deg, #2563eb 0%, #4f46e5 50%, #7c3aed 100%);
  color: #ffffff !important;
  border: 1px solid rgba(255, 255, 255, 0.22);
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.32), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: -0.1px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.btn-ai-header:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(99, 102, 241, 0.48), inset 0 1px 0 rgba(255, 255, 255, 0.35);
  background: linear-gradient(135deg, #1d4ed8 0%, #4338ca 50%, #6d28d9 100%);
}
.btn-ai-header:active {
  transform: translateY(0);
}

/* ── AI Spark Vector Icon ──────────────────────────────────────────── */
.ai-spark-svg {
  display: inline-block;
  vertical-align: middle;
  filter: drop-shadow(0 0 3px rgba(255, 255, 255, 0.5));
  transition: transform 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.btn-ai-header:hover .ai-spark-svg,
.ai-copilot-fab:hover .ai-spark-svg {
  transform: rotate(12deg) scale(1.15);
}

.ai-spark-icon-wrap,
.ai-fab-icon-box {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* ── Live Pulsating Beacon Marker (Header & General) ───────────────── */
.ai-live-beacon {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 9px;
  height: 9px;
  margin-left: 2px;
}
.ai-beacon-dot {
  position: relative;
  width: 6.5px;
  height: 6.5px;
  border-radius: 50%;
  background: #34d399; /* Emerald */
  box-shadow: 0 0 7px #10b981;
}
.ai-beacon-ping {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1.5px solid #34d399;
  animation: aiRadarPing 2s cubic-bezier(0, 0, 0.2, 1) infinite;
  pointer-events: none;
}
@keyframes aiRadarPing {
  0% {
    width: 6.5px;
    height: 6.5px;
    opacity: 0.95;
  }
  75%, 100% {
    width: 18px;
    height: 18px;
    opacity: 0;
  }
}

/* ── Floating AI Copilot FAB on Workspace ──────────────────────────── */
.ai-copilot-fab {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 15px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(135deg, #1e40af 0%, #4338ca 50%, #6d28d9 100%);
  color: #ffffff;
  font-family: var(--font-sans);
  font-size: 13.5px;
  font-weight: 700;
  letter-spacing: -0.15px;
  cursor: pointer;
  box-shadow: 0 10px 25px -4px rgba(67, 56, 202, 0.5), 0 4px 12px -2px rgba(15, 23, 42, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.25);
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-copilot-fab:hover {
  transform: translateY(-2px) scale(1.025);
  box-shadow: 0 14px 30px -4px rgba(109, 40, 217, 0.65), 0 6px 14px -2px rgba(30, 64, 175, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.ai-copilot-fab:active {
  transform: translateY(0) scale(0.99);
}

/* FAB Live Marker Badge */
.ai-fab-live-marker {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2.5px 7px;
  background: rgba(16, 185, 129, 0.18);
  border: 1px solid rgba(52, 211, 153, 0.45);
  border-radius: 999px;
  margin-left: 2px;
}
.ai-fab-live-text {
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.6px;
  color: #6ee7b7;
  line-height: 1;
}

/* ── AI Copilot Slide-Over Drawer ──────────────────────────────────── */
.ai-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.42);
  backdrop-filter: blur(2px);
  z-index: 120;
  display: none;
}
.ai-drawer-backdrop.open {
  display: block;
}
.ai-copilot-drawer {
  position: fixed;
  top: 0;
  right: -470px;
  width: 450px;
  max-width: 95vw;
  height: 100vh;
  background: var(--bg-card);
  border-left: 1px solid var(--border-color);
  box-shadow: -12px 0 32px rgba(15, 23, 42, 0.18);
  z-index: 125;
  display: flex;
  flex-direction: column;
  transition: right 0.26s cubic-bezier(0.16, 1, 0.3, 1);
}
.ai-copilot-drawer.open {
  right: 0;
}
.ai-drawer-header {
  padding: 14px 16px;
  background: linear-gradient(135deg, #1e1b4b, #1e3a8a);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.ai-engine-status-bar {
  padding: 7px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ai-engine-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
  display: inline-block;
}
.ai-drawer-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg-main);
}
.ai-msg {
  max-width: 94%;
  padding: 11px 14px;
  border-radius: 12px;
  font-size: 12.8px;
  line-height: 1.5;
  word-wrap: break-word;
}
.ai-msg.bot {
  align-self: flex-start;
  background: var(--bg-card);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
  box-shadow: var(--shadow-sm);
}
.ai-msg.bot code {
  font-family: var(--font-mono);
  font-size: 11.5px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
}
.ai-msg.bot table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 11.8px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
}
.ai-msg.bot th,
.ai-msg.bot td {
  padding: 6px 8px;
  border-bottom: 1px solid var(--border-color);
  text-align: left;
}
.ai-msg.bot th {
  background: rgba(148, 163, 184, 0.12);
  font-weight: 700;
  color: var(--text-primary);
}
.ai-msg-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px dashed var(--border-color);
}
.ai-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 11px;
  border-radius: 7px;
  border: 1px solid #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-action-btn:hover {
  background: #2563eb;
  border-color: #2563eb;
  color: #ffffff;
}
.ai-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}
.ai-quick-chips {
  padding: 10px 14px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  scrollbar-width: none;
}
.ai-quick-chips::-webkit-scrollbar {
  display: none;
}
.ai-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  white-space: nowrap;
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.ai-drawer-input-bar {
  padding: 12px 14px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-card);
  display: flex;
  gap: 8px;
}
.ai-drawer-input-bar input {
  flex: 1;
  padding: 9px 13px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-primary);
  font-size: 13px;
  outline: none;
}
.ai-drawer-input-bar input:focus {
  border-color: var(--primary);
}
.ai-send-btn {
  padding: 0 16px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  color: #ffffff;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease;
}
.ai-send-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.ai-header-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 700;
  transition: background 0.15s ease;
}
.ai-header-pill-btn:hover,
.ai-header-pill-btn.active {
  background: rgba(255, 255, 255, 0.28);
}
.ai-input-prompts-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.15s ease;
}
.ai-input-prompts-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}
.ai-prompt-hub {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.ai-prompt-hub-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.ai-prompt-hub-title {
  font-size: 11.5px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-secondary);
}
.ai-add-prompt-mini-btn {
  border: 1px solid rgba(37, 99, 235, 0.3);
  background: rgba(37, 99, 235, 0.08);
  color: #2563eb;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-add-prompt-mini-btn:hover {
  background: #2563eb;
  color: #ffffff;
}
.ai-prompt-search-input {
  width: 100%;
  padding: 7px 11px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 12px;
  outline: none;
}
.ai-prompt-search-input:focus {
  border-color: var(--primary);
}
.ai-prompt-cat-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.ai-prompt-cat-tab {
  padding: 4px 9px;
  border-radius: 999px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-prompt-cat-tab:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.ai-prompt-cat-tab.active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  border-color: transparent;
  color: #ffffff;
}
.ai-prompt-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.ai-prompt-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 10px 11px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-primary);
  text-align: left;
  cursor: pointer;
  transition: all 0.15s ease;
  box-shadow: var(--shadow-sm);
}
.ai-prompt-card:hover {
  border-color: #3b82f6;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.12);
}
.ai-prompt-card-top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ai-prompt-card-icon {
  font-size: 14px;
  line-height: 1;
}
.ai-prompt-card-badge {
  font-size: 9.5px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(99, 102, 241, 0.1);
  color: #4f46e5;
  white-space: nowrap;
}
.ai-prompt-card-badge.custom {
  background: rgba(245, 158, 11, 0.14);
  color: #b45309;
}
.ai-prompt-card-title {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}
.ai-prompt-card-desc {
  font-size: 10.8px;
  color: var(--text-secondary);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.ai-prompt-library-overlay {
  background: var(--bg-main);
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.12);
  z-index: 5;
}
.ai-prompt-library-overlay-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 14px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
}
.ai-msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 6px;
}
.ai-msg-copy-btn {
  border: 1px solid var(--border-color);
  background: var(--bg-main);
  color: var(--text-secondary);
  font-size: 10px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 5px;
  cursor: pointer;
}
.ai-msg-copy-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.ai-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.ai-typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #6366f1;
  animation: aiDotPulse 1.2s infinite ease-in-out;
}
.ai-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes aiDotPulse {
  0%, 80%, 100% { opacity: 0.25; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.1); }
}

/* ══════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE SYSTEM (TABLETS & SMARTPHONES <= 768px)
   ══════════════════════════════════════════════════════════════════ */

.mobile-menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-sidebar-close {
  display: none;
  background: var(--bg-main);
  border: 1px solid var(--border-color);
  width: 28px;
  height: 28px;
  border-radius: 6px;
  color: var(--text-secondary);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
}

.mobile-sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  z-index: 99;
}

@media (max-width: 768px) {
  .mobile-menu-toggle {
    display: inline-flex;
  }
  .mobile-sidebar-close {
    display: inline-flex;
  }
  .mobile-sidebar-backdrop.active {
    display: block;
  }

  /* Off-Canvas Sliding Sidebar */
  .sidebar {
    position: fixed;
    top: 0;
    left: -285px;
    height: 100vh;
    width: 275px;
    z-index: 100;
    box-shadow: 10px 0 30px rgba(15, 23, 42, 0.25);
    transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .sidebar.mobile-open {
    left: 0;
  }

  /* Top Header on Mobile — Perfectly Fitted No-Wrap */
  .top-header {
    height: 56px;
    padding: 0 10px;
    gap: 6px;
    overflow: hidden;
  }
  .header-left {
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
  }
  .org-switcher-badge {
    padding: 4px 8px;
    gap: 6px;
    max-width: 150px;
    overflow: hidden;
  }
  .org-name-text {
    max-width: 90px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
  }
  .org-flag {
    font-size: 15px;
  }
  .org-regime-tag,
  .global-search-container,
  #header-plan-pill,
  .btn-secondary,
  #btn-quick-add,
  #header-user-pill {
    display: none !important;
  }

  .header-right {
    gap: 6px;
    flex-shrink: 0;
  }
  .btn-icon-header {
    height: 32px;
    padding: 0 9px;
    font-size: 11.5px;
  }
  #theme-toggle-label {
    display: none;
  }

  #btn-mobile-logout,
  .mobile-logout-header-btn {
    display: inline-flex !important;
    align-items: center;
    gap: 4px;
    background: #fef2f2 !important;
    border-color: #fca5a5 !important;
    color: #ef4444 !important;
    padding: 0 8px !important;
  }
  [data-theme="dark"] #btn-mobile-logout,
  [data-theme="dark"] .mobile-logout-header-btn {
    background: rgba(239, 68, 68, 0.15) !important;
    border-color: #7f1d1d !important;
    color: #f87171 !important;
  }

  /* Main View adjustments */
  #app-container {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .main-content {
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden;
  }
  .page-body {
    padding: 12px 10px;
    max-width: 100vw;
    overflow-x: hidden;
  }

  /* Dashboard Cards Grid & Headers */
  .dash-kpi-grid,
  .kpi-grid,
  .dash-grid-2,
  .dash-grid-3,
  .cashflow-body {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
  }
  .dash-card {
    padding: 14px;
    width: 100% !important;
    box-sizing: border-box;
  }
  .dash-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .income-expense-header {
    flex-wrap: wrap;
    gap: 8px;
  }
  .income-expense-header .legend-badge {
    font-size: 11.5px;
  }
  .top-expenses-body {
    flex-direction: column !important;
    align-items: center;
    gap: 14px;
    width: 100%;
  }
  .donut-legend {
    width: 100%;
    max-height: none;
  }

  /* Responsive Horizontal Scroll for all Data Tables */
  .table-responsive,
  .table-card,
  .cd-statement-wrap {
    width: 100%;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  .dash-card table,
  .data-table {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
  }

  /* AI Floating Button adjustments */
  .ai-copilot-fab {
    bottom: 16px;
    right: 16px;
    padding: 9px 14px;
    font-size: 12px;
  }
  .ai-copilot-drawer {
    width: 100vw;
    right: -100vw;
  }
}


/* ── CloudLedgerAI Bento Command Center Upgrade ────────────────────────── */
.dash-bento-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 16px;
  padding-bottom: 10px;
  flex-wrap: wrap;
  gap: 12px;
}

.dash-mode-pills {
  display: inline-flex;
  background: #f1f5f9;
  padding: 3px;
  border-radius: 8px;
  gap: 4px;
}

.dash-mode-pill {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}

.dash-mode-pill.active {
  background: #ffffff;
  color: #2563eb;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.08);
}

/* ── Financial Statement Executive Shortcut Pills ── */
.dash-quick-reports {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: #f8fafc;
  padding: 3px 6px;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
}

.dash-report-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  color: #334155;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease-in-out;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
  white-space: nowrap;
}

.dash-report-pill svg {
  color: #475569;
  transition: color 0.15s;
}

.dash-report-pill:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  color: #1d4ed8;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(37, 99, 235, 0.12);
}

.dash-report-pill:hover svg {
  color: #2563eb;
}

.dash-report-pill:active {
  transform: translateY(0);
}

body.dark-mode .dash-quick-reports {
  background: #1e293b;
  border-color: #334155;
}

body.dark-mode .dash-report-pill {
  background: #0f172a;
  border-color: #334155;
  color: #cbd5e1;
}

body.dark-mode .dash-report-pill svg {
  color: #94a3b8;
}

body.dark-mode .dash-report-pill:hover {
  background: #1e3a8a;
  border-color: #3b82f6;
  color: #93c5fd;
}

body.dark-mode .dash-report-pill:hover svg {
  color: #60a5fa;
}

.bento-grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 18px;
}

.bento-grid-main {
  display: grid;
  grid-template-columns: 1.75fr 1fr;
  gap: 18px;
  margin-bottom: 18px;
}

.bento-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1.05fr 1.25fr;
  gap: 18px;
  margin-bottom: 20px;
  align-items: stretch;
}

.bento-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  transition: box-shadow 0.2s ease, transform 0.15s ease;
}

.bento-card:hover {
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.06);
}

.bento-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: #0f172a;
  letter-spacing: -0.5px;
  margin: 6px 0 8px;
  line-height: 1.2;
}

.bento-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 11.5px;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.bento-action-btn.btn-orange {
  background: #fff7ed;
  color: #ea580c;
  border-color: #fed7aa;
}
.bento-action-btn.btn-orange:hover {
  background: #ffedd5;
}

.bento-action-btn.btn-blue {
  background: #eff6ff;
  color: #2563eb;
  border-color: #bfdbfe;
}
.bento-action-btn.btn-blue:hover {
  background: #dbeafe;
}

.bento-action-btn.btn-green {
  background: #ecfdf5;
  color: #059669;
  border-color: #a7f3d0;
}
.bento-action-btn.btn-green:hover {
  background: #d1fae5;
}

.action-queue-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}

.action-queue-item:hover {
  border-color: #cbd5e1;
}

.aging-bucket-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.aging-bucket-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  padding: 8px 6px;
  text-align: center;
}

.aging-bucket-label {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
}

.aging-bucket-val {
  font-size: 12.5px;
  font-weight: 800;
  color: #0f172a;
  margin-top: 3px;
}

.inv-pulse-stat {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 12px;
}

@media (max-width: 1280px) {
  .bento-grid-4 {
    grid-template-columns: repeat(2, 1fr);
  }
  .bento-grid-main {
    grid-template-columns: 1fr;
  }
  .bento-grid-3 {
    grid-template-columns: 1fr;
  }
}

/* Dark Mode Overrides for Bento Command Center */
[data-theme="dark"] .bento-card {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .bento-kpi-value,
[data-theme="dark"] .aging-bucket-val {
  color: #f8fafc;
}
[data-theme="dark"] .dash-mode-pills {
  background: #1e293b;
}
[data-theme="dark"] .dash-mode-pill.active {
  background: #2563eb;
  color: #ffffff;
}
[data-theme="dark"] .action-queue-item,
[data-theme="dark"] .aging-bucket-box,
[data-theme="dark"] .inv-pulse-stat {
  background: #1e293b;
  border-color: #334155;
}


/* ──────────────────────────────────────────────────────────────────────────
   Dark Mode Command Center Visibility & High-Contrast Polish
   ────────────────────────────────────────────────────────────────────────── */
[data-theme="dark"] .dash-report-pill {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #cbd5e1 !important;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25) !important;
}
[data-theme="dark"] .dash-report-pill svg {
  color: #94a3b8 !important;
}
[data-theme="dark"] .dash-report-pill:hover {
  background: #334155 !important;
  border-color: #3b82f6 !important;
  color: #60a5fa !important;
}
[data-theme="dark"] .dash-select {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #f8fafc !important;
}

/* Action Queue & Right Bento Card */
.action-item-title {
  font-size: 12.5px;
  font-weight: 700;
  color: #0f172a;
}
.action-item-sub {
  font-size: 11px;
  color: #64748b;
}
.action-item-amt {
  color: #334155;
}
[data-theme="dark"] .action-item-title {
  color: #f8fafc !important;
}
[data-theme="dark"] .action-item-sub {
  color: #94a3b8 !important;
}
[data-theme="dark"] .action-item-amt {
  color: #e2e8f0 !important;
}
[data-theme="dark"] .action-queue-empty {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #94a3b8 !important;
}

/* KPI Subtitles & Metric Footers */
[data-theme="dark"] #dash-liquidity-sub {
  color: #94a3b8 !important;
}
[data-theme="dark"] .dash-metric-footer,
[data-theme="dark"] .metric-legend {
  color: #94a3b8 !important;
}
[data-theme="dark"] .metric-legend strong {
  color: #f8fafc !important;
}
[data-theme="dark"] .dash-rev-split-label {
  color: #94a3b8 !important;
}
[data-theme="dark"] .dash-rev-split-label strong {
  color: #f8fafc !important;
}
[data-theme="dark"] #dash-gst-shield-status {
  color: #cbd5e1 !important;
}

/* Cash Flow Panel */
[data-theme="dark"] .cf-label {
  color: #cbd5e1 !important;
}
[data-theme="dark"] #cf-opening-val {
  color: #f8fafc !important;
}
[data-theme="dark"] .cf-highlight {
  background: rgba(37, 99, 235, 0.15) !important;
  border-color: rgba(37, 99, 235, 0.4) !important;
}

/* Bank Account Cards */
.dash-bank-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 14px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  transition: all 0.15s ease;
}
.dash-bank-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: #eff6ff;
  color: #2563eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 16px;
}
.dash-bank-title {
  font-weight: 600;
  font-size: 13px;
  color: #0f172a;
}
.dash-bank-meta {
  font-size: 11px;
  color: #64748b;
}
.dash-bank-balance {
  font-weight: 700;
  font-size: 14px;
  color: #0f172a;
}
[data-theme="dark"] .dash-bank-card {
  background: #1e293b !important;
  border-color: #334155 !important;
}
[data-theme="dark"] .dash-bank-icon {
  background: rgba(37, 99, 235, 0.2) !important;
}
[data-theme="dark"] .dash-bank-title {
  color: #f8fafc !important;
}
[data-theme="dark"] .dash-bank-meta {
  color: #94a3b8 !important;
}
[data-theme="dark"] .dash-bank-balance {
  color: #f8fafc !important;
}

/* Inventory Pulse */
.inv-pulse-label {
  color: #64748b;
  font-weight: 600;
}
.inv-pulse-val {
  color: #0f172a;
}
.inv-pulse-accent {
  color: #2563eb;
}
[data-theme="dark"] .inv-pulse-label {
  color: #94a3b8 !important;
}
[data-theme="dark"] .inv-pulse-val {
  color: #f8fafc !important;
}
[data-theme="dark"] .inv-pulse-accent {
  color: #60a5fa !important;
}

/* Card Dividers & Mini Footers */
[data-theme="dark"] .dash-card-bottom-bar,
[data-theme="dark"] .dash-footer-note {
  color: #94a3b8 !important;
  border-top-color: #334155 !important;
}
[data-theme="dark"] #mini-expenses-total {
  color: #f8fafc !important;
}


/* ══════════════════════════════════════════════════════════════════════════
   FULL-PAGE AI INTELLIGENCE & INTERNAL AUDIT HUB (#view-ai-hub)
   ══════════════════════════════════════════════════════════════════════════ */
.ai-hub-shell {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.ai-hub-hero {
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #1e3a8a 100%);
  color: #ffffff;
  padding: 20px 22px;
  border-radius: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: 0 10px 25px -5px rgba(30, 58, 138, 0.3);
}

.ai-hub-hero-left {
  display: flex;
  align-items: center;
  gap: 14px;
}

.ai-hub-icon-orb {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.45);
  flex-shrink: 0;
}

.ai-hub-title {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #ffffff;
}

.ai-hub-subtitle {
  margin: 4px 0 0 0;
  font-size: 12.5px;
  color: #cbd5e1;
}

.ai-hub-engine-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.4);
  color: #6ee7b7;
  font-size: 11px;
  font-weight: 700;
}

.ai-hub-hero-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ai-hub-btn-ghost {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.24);
  color: #ffffff;
  padding: 7px 13px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-hub-btn-ghost:hover {
  background: rgba(255, 255, 255, 0.22);
}

.ai-hub-btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #2563eb, #7c3aed);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #ffffff;
  padding: 7px 14px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(124, 58, 237, 0.35);
  transition: all 0.15s ease;
}
.ai-hub-btn-primary:hover {
  filter: brightness(1.06);
  transform: translateY(-1px);
}

.ai-hub-key-bar {
  padding: 14px 18px;
  background: #eff6ff;
  border: 1px solid #93c5fd;
  border-radius: 10px;
}

.ai-hub-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.ai-hub-kpi-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 12px;
  padding: 15px 16px;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
}

.ai-hub-kpi-label {
  font-size: 11.5px;
  font-weight: 700;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: 0.2px;
}

.ai-hub-kpi-val {
  font-size: 24px;
  font-weight: 800;
  margin-top: 4px;
  line-height: 1.15;
}

.ai-hub-tabs-bar {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  background: var(--bg-card, #ffffff);
  padding: 6px;
  border-radius: 12px;
  border: 1px solid var(--border-color, #e2e8f0);
}

.ai-hub-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--text-secondary, #475569);
  font-size: 12.8px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s ease;
}
.ai-hub-tab-btn:hover {
  background: rgba(37, 99, 235, 0.06);
  color: #2563eb;
}
.ai-hub-tab-btn.active {
  background: linear-gradient(135deg, #2563eb, #4f46e5);
  color: #ffffff;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.28);
}

.ai-hub-tab-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.12);
  color: inherit;
}
.ai-hub-tab-btn.active .ai-hub-tab-badge {
  background: rgba(255, 255, 255, 0.24);
  color: #ffffff;
}

.ai-cfo-cards-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.ai-cfo-insight-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 15px 16px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.ai-audit-checks-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.ai-audit-check-card {
  background: var(--bg-card, #ffffff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}
.ai-audit-check-card.border-crit {
  border-left: 4px solid #ef4444;
}
.ai-audit-check-card.border-warn {
  border-left: 4px solid #f59e0b;
}
.ai-audit-check-card.border-pass {
  border-left: 4px solid #10b981;
}

.ai-audit-sev-badge {
  font-size: 10.5px;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: 999px;
}
.ai-audit-sev-badge.sev-critical {
  background: #fee2e2;
  color: #dc2626;
}
.ai-audit-sev-badge.sev-warning {
  background: #fef3c7;
  color: #b45309;
}
.ai-audit-sev-badge.sev-passed {
  background: #dcfce7;
  color: #15803d;
}

.ai-audit-findings-box {
  background: var(--bg-main, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 9px 12px;
  margin: 8px 0;
}
.ai-audit-finding-item {
  font-size: 12px;
  color: var(--text-primary, #1e293b);
  padding: 2px 0;
}

.ai-sim-grid {
  display: grid;
  grid-template-columns: 1fr 1.15fr;
  gap: 16px;
  align-items: start;
}

.ai-sim-control {
  padding: 12px 14px;
  background: var(--bg-main, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 9px;
  margin-bottom: 12px;
}

.ai-analyst-studio-grid {
  display: grid;
  grid-template-columns: 315px 1fr;
  gap: 16px;
  align-items: stretch;
}

.ai-playbook-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  padding: 9px 11px;
  border-radius: 9px;
  border: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-main, #f8fafc);
  color: var(--text-primary, #1e293b);
  cursor: pointer;
  transition: all 0.15s ease;
}
.ai-playbook-btn:hover {
  background: #eff6ff;
  border-color: #93c5fd;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.08);
}

.ai-playbook-icon {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

body.ai-hub-active .ai-copilot-fab {
  display: none !important;
}

@media (max-width: 1200px) {
  .ai-hub-kpi-grid,
  .ai-cfo-cards-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .ai-audit-checks-grid,
  .ai-sim-grid,
  .ai-analyst-studio-grid {
    grid-template-columns: 1fr;
  }
}

/* ── Senior Enterprise UI/UX Utilities for AI Hub & Assistant ────────────── */
.ai-tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
}

.ai-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}
.ai-dot-red    { background: #dc2626; }
.ai-dot-amber  { background: #d97706; }
.ai-dot-green  { background: #10b981; }
.ai-dot-blue   { background: #2563eb; }
.ai-dot-purple { background: #7c3aed; }

.ai-grade-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #334155;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.ai-kpi-subgrid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
  font-size: 11px;
  color: #64748b;
}

.ai-pill-neutral {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 10.5px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

.ai-progress-track {
  height: 6px;
  background: #e2e8f0;
  border-radius: 999px;
  overflow: hidden;
  margin: 8px 0 6px;
}

.ai-section-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.ai-code-chip {
  font-size: 10.5px;
  font-weight: 700;
  color: #475569;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  padding: 2px 6px;
  border-radius: 5px;
}

.ai-seg-group {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px;
  border-radius: 9px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
}

.ai-audit-clean-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  margin: 8px 0;
  border-radius: 8px;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #047857;
  font-size: 12px;
  font-weight: 600;
}

.ai-surface-subtle {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 9px;
}

.ai-surface-accent {
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
  border-radius: 9px;
}

.ai-wa-textarea {
  width: 100%;
  box-sizing: border-box;
  border-radius: 8px;
  border: 1px solid #cbd5e1;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 12.5px;
  line-height: 1.5;
  color: #0f172a;
  background: #ffffff;
  resize: vertical;
  outline: none;
}
.ai-wa-textarea:focus {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.ai-chip-svg {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

/* Custom Enterprise Range Sliders for Cash Flow Simulator */
.ai-sim-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: #cbd5e1;
  outline: none;
  cursor: pointer;
}
.ai-sim-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4f46e5;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
  transition: transform 0.12s ease, background 0.12s ease;
}
.ai-sim-slider::-webkit-slider-thumb:hover {
  transform: scale(1.12);
  background: #4338ca;
}
.ai-sim-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4f46e5;
  border: 2px solid #ffffff;
  box-shadow: 0 1px 4px rgba(15, 23, 42, 0.25);
  cursor: pointer;
}

/* ── Dark Mode Overrides for Full-Page AI Hub & Assistant Drawer ─────────── */
[data-theme="dark"] .ai-hub-kpi-card,
[data-theme="dark"] .ai-hub-tabs-bar,
[data-theme="dark"] .ai-cfo-insight-card,
[data-theme="dark"] .ai-audit-check-card {
  background: #111827;
  border-color: #1f2937;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
}
[data-theme="dark"] .ai-hub-kpi-label,
[data-theme="dark"] .ai-kpi-subgrid {
  color: #94a3b8;
}
[data-theme="dark"] .ai-hub-tab-btn {
  color: #94a3b8;
}
[data-theme="dark"] .ai-hub-tab-btn:hover {
  background: rgba(59, 130, 246, 0.14);
  color: #93c5fd;
}
[data-theme="dark"] .ai-grade-badge,
[data-theme="dark"] .ai-pill-neutral,
[data-theme="dark"] .ai-code-chip {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}
[data-theme="dark"] .ai-seg-group {
  background: #0f172a;
  border-color: #334155;
}
[data-theme="dark"] .ai-progress-track {
  background: #334155;
}
[data-theme="dark"] .ai-surface-subtle,
[data-theme="dark"] .ai-audit-findings-box,
[data-theme="dark"] .ai-sim-control,
[data-theme="dark"] .ai-playbook-btn {
  background: #1e293b;
  border-color: #334155;
  color: #e2e8f0;
}
[data-theme="dark"] .ai-playbook-btn:hover {
  background: #273549;
  border-color: #3b82f6;
}
[data-theme="dark"] .ai-surface-accent {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(129, 140, 248, 0.35);
}
[data-theme="dark"] .ai-audit-clean-banner {
  background: rgba(16, 185, 129, 0.14);
  border-color: rgba(52, 211, 153, 0.35);
  color: #6ee7b7;
}
[data-theme="dark"] .ai-audit-finding-item {
  color: #e2e8f0;
}
[data-theme="dark"] .ai-audit-sev-badge.sev-critical {
  background: rgba(239, 68, 68, 0.18);
  color: #fca5a5;
}
[data-theme="dark"] .ai-audit-sev-badge.sev-warning {
  background: rgba(245, 158, 11, 0.18);
  color: #fcd34d;
}
[data-theme="dark"] .ai-audit-sev-badge.sev-passed {
  background: rgba(16, 185, 129, 0.18);
  color: #6ee7b7;
}
[data-theme="dark"] .ai-hub-key-bar,
[data-theme="dark"] #ai-apikey-panel {
  background: #1e293b !important;
  border-color: #334155 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .ai-wa-textarea {
  background: #0f172a;
  border-color: #334155;
  color: #f8fafc;
}
[data-theme="dark"] .ai-sim-slider {
  background: #334155;
}
[data-theme="dark"] .ai-sim-slider::-webkit-slider-thumb {
  border-color: #0f172a;
}

/* ── AI Hub Voice Input Toolbar (English & Malayalam) ───────────────────── */
.ai-voice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border-radius: 10px;
  background: #f5f3ff;
  border: 1px solid #ddd6fe;
}

.ai-lang-pill {
  display: inline-flex;
  align-items: center;
  padding: 2px;
  border-radius: 8px;
  background: #e2e8f0;
  gap: 2px;
}

.ai-lang-btn {
  border: none;
  background: transparent;
  color: #475569;
  font-size: 11.5px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-lang-btn.active {
  background: #ffffff;
  color: #4f46e5;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.12);
}

.ai-voice-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: 8px;
  border: 1px solid #c7d2fe;
  background: #ffffff;
  color: #4f46e5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.ai-voice-btn:hover {
  background: #eef2ff;
  border-color: #818cf8;
}

.ai-voice-btn-compact {
  padding: 8px 10px;
  flex-shrink: 0;
}

.ai-voice-btn.recording {
  background: #dc2626;
  border-color: #b91c1c;
  color: #ffffff;
  animation: ai-voice-pulse 1.35s infinite;
}

@keyframes ai-voice-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
  70%  { box-shadow: 0 0 0 9px rgba(220, 38, 38, 0); }
  100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0); }
}

[data-theme="dark"] .ai-voice-bar {
  background: rgba(99, 102, 241, 0.14);
  border-color: rgba(129, 140, 248, 0.35);
}
[data-theme="dark"] .ai-lang-pill {
  background: #0f172a;
}
[data-theme="dark"] .ai-lang-btn {
  color: #94a3b8;
}
[data-theme="dark"] .ai-lang-btn.active {
  background: #4f46e5;
  color: #ffffff;
}
[data-theme="dark"] .ai-voice-btn {
  background: #1e293b;
  border-color: #334155;
  color: #a5b4fc;
}
[data-theme="dark"] .ai-voice-btn:hover {
  background: #334155;
}
[data-theme="dark"] .ai-voice-btn.recording {
  background: #dc2626;
  border-color: #ef4444;
  color: #ffffff;
}

/* ── AI Document Extraction Drag & Drop Upload Zone ─────────────────────── */
.ai-doc-dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 26px 18px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.18s ease;
}
.ai-doc-dropzone:hover,
.ai-doc-dropzone.dragover {
  border-color: #4f46e5;
  background: #eef2ff;
}
.ai-doc-dropzone-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #e0e7ff;
  color: #4f46e5;
}
.ai-format-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #475569;
  font-size: 11px;
  font-weight: 700;
}

[data-theme="dark"] .ai-doc-dropzone {
  background: #0f172a;
  border-color: #334155;
}
[data-theme="dark"] .ai-doc-dropzone:hover,
[data-theme="dark"] .ai-doc-dropzone.dragover {
  border-color: #6366f1;
  background: rgba(99, 102, 241, 0.12);
}
[data-theme="dark"] .ai-doc-dropzone-icon {
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
}
[data-theme="dark"] .ai-format-chip {
  background: #1e293b;
  border-color: #334155;
  color: #cbd5e1;
}

/* ── Print Styles for Audit Certificate & Analyst Brief ─────────────────── */
@media print {
  .sidebar,
  .top-header,
  .ai-copilot-fab,
  .ai-copilot-drawer,
  .ai-drawer-backdrop,
  .ai-hub-hero-actions,
  .ai-hub-tabs-bar,
  .ai-hub-key-bar {
    display: none !important;
  }
  .main-content,
  .page-body {
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .ai-hub-hero {
    background: #0f172a !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
  .ai-audit-check-card,
  .ai-hub-kpi-card,
  .ai-cfo-insight-card {
    break-inside: avoid;
    box-shadow: none !important;
  }
}
