/* ============================================================
   JODESI — Business Management Platform
   Main Stylesheet
   ============================================================ */

:root {
  /* Brand */
  --brand-primary: #2F66F5;
  --brand-blue: #3670FF;   /* the logo blue */
  --brand-gold: #E09927;
  --brand-gold-light: #FFC569;
  --brand-secondary: #2453D6;
  --brand-gradient: linear-gradient(135deg, #3670FF, #2453D6);

  /* Sidebar */
  /* Sidebar: white, with the logo blue for the selected item and a gold marker */
  --sidebar-bg: #ffffff;
  --sidebar-hover: #F3F6FF;
  --sidebar-active-bg: #2F66F5;
  --sidebar-active-border: #2F66F5;
  --sidebar-text: #4B5563;
  --sidebar-text-hover: #111827;
  --sidebar-text-active: #ffffff;
  --sidebar-title: #6B7280;
  --sidebar-brand: #111827;
  --sidebar-line: #E4E8F1;
  --sidebar-icon: #2F66F5;
  --sidebar-width: 260px;
  --sidebar-collapsed: 64px;

  /* Colors */
  --white: #ffffff;
  --gray-50: #f8fafc;
  --gray-100: #f1f5f9;
  --gray-200: #e2e8f0;
  --gray-300: #cbd5e1;
  --gray-400: #94a3b8;
  --gray-500: #64748b;
  --gray-600: #475569;
  --gray-700: #334155;
  --gray-800: #1e293b;
  --gray-900: #0f172a;

  /* Status */
  --success: #10b981;
  --success-light: #d1fae5;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --info: #3b82f6;
  --info-light: #dbeafe;

  /* Surface */
  --bg-body: #f1f5f9;
  --bg-card: #ffffff;
  --bg-card-hover: #f8fafc;
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;

  /* Topbar */
  --topbar-height: 60px;
  --topbar-bg: #ffffff;

  /* Misc */
  --radius: 8px;
  --radius-lg: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --transition: 0.2s ease;
}

[data-theme="dark"] {
  /* Surfaces */
  --bg-body: #0f172a;
  --bg-card: #1e293b;
  --bg-card-hover: #263548;
  --border: #334155;
  --border-light: #1a2535;
  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  /* Navigation */
  --topbar-bg: #1e293b;
  --sidebar-bg: #0a0f1e;
  --sidebar-hover: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-title: #7c8aa0;
  --sidebar-brand: #f1f5f9;
  --sidebar-line: rgba(255,255,255,0.06);
  --sidebar-icon: #8FB0FF;
  /* Gray scale — used by btn-secondary, search bg, hover states, badges */
  --gray-50: #1a2535;
  --gray-100: #263548;
  --gray-200: #334155;
  --gray-300: #475569;
  --gray-600: #94a3b8;
  /* Status lights — muted so they don't glow on dark bg */
  --success-light: rgba(16,185,129,0.15);
  --warning-light: rgba(245,158,11,0.15);
  --danger-light: rgba(239,68,68,0.15);
  --info-light: rgba(59,130,246,0.15);
  /* Shadows — heavier so elevation reads on dark */
  --shadow: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-md: 0 4px 8px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 24px rgba(0,0,0,0.5);
}

/* ---- Dark-mode overrides for hardcoded colours ---- */
[data-theme="dark"] .auth-bg { background: var(--bg-body); }
[data-theme="dark"] .auth-right { background: var(--bg-card-hover); }
[data-theme="dark"] .auth-card { background: var(--bg-card); color: var(--text-primary); }
[data-theme="dark"] .auth-card h2 { color: var(--text-primary); }
[data-theme="dark"] .pipeline-col { background: var(--bg-card-hover); }
[data-theme="dark"] .pipeline-card { background: var(--bg-card); color: var(--text-primary); }
[data-theme="dark"] .platform-bar { background: #0a0f1e; }
[data-theme="dark"] .status-draft,
[data-theme="dark"] .status-pending,
[data-theme="dark"] .status-todo { background: var(--gray-100); color: var(--text-secondary); }
[data-theme="dark"] .invoice-doc { background: var(--bg-card); color: var(--text-primary); }

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

html { font-size: 14px; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.5;
  overflow-x: hidden;
}

/* ============================================================
   UTILITIES
   ============================================================ */
.hidden { display: none !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-danger { color: var(--danger) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-sm { font-size: 0.8rem; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-1 { flex: 1; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.w-full { width: 100%; }

/* ============================================================
   AUTH SCREEN
   ============================================================ */
/* The overlay scrolls so tall forms (registration) stay reachable on small screens */
.auth-screen {
  position: fixed; inset: 0; z-index: 9999;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}

.auth-bg {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-body);
}

.auth-left {
  flex: 1;
  background: var(--brand-gradient);
  padding: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  color: white;
  overflow: hidden;
  position: relative;
}

.auth-left::before {
  content: '';
  position: absolute;
  width: 500px; height: 500px;
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  top: -200px; right: -100px;
}

.brand-logo-large {
  height: 72px; width: 72px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 1.5rem;
  /* the blue logo needs a white tile to show on the blue panel */
  background: #fff; border-radius: 18px; padding: 10px; box-sizing: border-box;
}

.brand-name-large {
  font-size: 3rem; font-weight: 800;
  letter-spacing: -1px;
  margin-bottom: 0.75rem;
}

.brand-tagline {
  font-size: 1.1rem;
  opacity: 0.85;
  margin-bottom: 3rem;
  max-width: 380px;
  line-height: 1.6;
}

.auth-features { display: flex; flex-direction: column; gap: 0.75rem; margin-bottom: 2.5rem; }

.auth-feature {
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.95rem;
}

.auth-feature i { color: rgba(255,255,255,0.9); font-size: 1rem; }

.auth-industries {
  display: flex; flex-wrap: wrap; gap: 0.5rem;
  margin-top: auto;
}

.auth-industries span {
  background: rgba(255,255,255,0.15);
  padding: 0.3rem 0.75rem;
  border-radius: 20px;
  font-size: 0.8rem;
  backdrop-filter: blur(5px);
}

.auth-right {
  width: 480px;
  display: flex; align-items: center; justify-content: center;
  padding: 2rem;
  background: var(--bg-card-hover);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}

/* Admin login card */
.admin-auth-card {
  background: #0f172a !important;
  border: 1px solid #334155;
  color: #f1f5f9;
}
.admin-auth-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 2rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #334155;
}
.admin-shield {
  width: 48px; height: 48px; flex-shrink: 0;
  background: linear-gradient(135deg, #1e3a5f, #3670FF);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; color: white;
}
.admin-auth-title { font-size: 1rem; font-weight: 700; color: #f1f5f9; }
.admin-auth-sub   { font-size: 0.75rem; color: #64748b; margin-top: 0.2rem; }
.admin-auth-card .form-control {
  background: #1e293b; border-color: #334155; color: #f1f5f9;
}
.admin-auth-card .form-control::placeholder { color: #475569; }
.admin-auth-card .form-control:focus { border-color: #3670FF; box-shadow: 0 0 0 3px rgba(54,112,255,0.2); }
.admin-auth-card label { color: #94a3b8; }
.admin-signin-btn {
  background: linear-gradient(135deg, #1e3a5f, #3670FF);
  color: white; border: none;
  box-shadow: 0 4px 15px rgba(54,112,255,0.3);
}
.admin-signin-btn:hover:not(:disabled) {
  background: linear-gradient(135deg, #243f6a, #4a80ff);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(54,112,255,0.4);
}

.auth-card-logo {
  display: flex; flex-direction: column; align-items: center; gap: 0.5rem;
  margin-bottom: 2rem;
  font-weight: 700; font-size: 1.5rem;
  color: #3670FF; text-align: center;
}

.brand-logo-sm {
  height: 32px; width: auto;
  display: flex; align-items: center;
  flex-shrink: 0;
}

.auth-card-logo .brand-logo-sm { height: 60px; }

.auth-card h2 { font-size: 1.6rem; font-weight: 700; margin-bottom: 0.5rem; text-align: center; }

.auth-subtitle { color: var(--text-secondary); margin-bottom: 2rem; font-size: 0.9rem; text-align: center; }

.auth-switch {
  text-align: center;
  margin-top: 1.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.auth-switch a { color: var(--brand-primary); font-weight: 500; text-decoration: none; }

/* ============================================================
   FORM ELEMENTS
   ============================================================ */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 500; margin-bottom: 0.4rem; color: var(--text-primary); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

.form-control {
  width: 100%;
  padding: 0.625rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: inherit;
  background: var(--bg-card);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-control:focus {
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(54,112,255,0.12);
}

.form-control::placeholder { color: var(--text-muted); }

select.form-control { cursor: pointer; }
textarea.form-control { resize: vertical; min-height: 100px; }

.input-with-icon {
  position: relative;
}

.input-with-icon .form-control { padding-right: 2.5rem; }

.input-icon-btn {
  position: absolute; right: 0.75rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-muted);
  cursor: pointer; padding: 0;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  padding: 0.625rem 1.25rem;
  border: 1.5px solid transparent;
  border-radius: var(--radius);
  font-size: 0.875rem; font-weight: 500; font-family: inherit;
  cursor: pointer; transition: all var(--transition);
  text-decoration: none; white-space: nowrap;
  outline: none;
}

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

.btn-primary {
  background: var(--brand-primary); color: white;
  border-color: var(--brand-primary);
}
.btn-primary:hover:not(:disabled) {
  background: #2453D6; border-color: #2453D6;
  box-shadow: 0 4px 12px rgba(54,112,255,0.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-100); color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-200); }

.btn-success { background: var(--success); color: white; border-color: var(--success); }
.btn-success:hover:not(:disabled) { background: #059669; }

.btn-danger { background: var(--danger); color: white; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: #dc2626; }

.btn-outline {
  background: transparent; color: var(--brand-primary);
  border-color: var(--brand-primary);
}
.btn-outline:hover:not(:disabled) { background: rgba(54,112,255,0.08); }

.btn-ghost {
  background: transparent; color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--gray-100); color: var(--text-primary); }

.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.875rem 1.75rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn-icon { padding: 0.5rem; width: 36px; height: 36px; border-radius: var(--radius); }

.btn-spinner { display: inline-flex; align-items: center; }

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 1rem;
}
.alert-danger { background: var(--danger-light); color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: var(--success-light); color: #065f46; border: 1px solid #6ee7b7; }
.alert-warning { background: var(--warning-light); color: #92400e; border: 1px solid #fcd34d; }
.alert-info { background: var(--info-light); color: #1e40af; border: 1px solid #93c5fd; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* SIDEBAR */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-line);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition);
  overflow: hidden;
  z-index: 100;
}

.sidebar.collapsed { width: var(--sidebar-collapsed); }

.sidebar-header {
  padding: 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--sidebar-line);
  min-height: 64px;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 0.75rem;
  cursor: pointer; flex: 1; overflow: hidden;
}

.brand-logo {
  height: 28px; width: auto; flex-shrink: 0;
  display: flex; align-items: center;
}

.brand-info {
  display: flex; flex-direction: column;
  overflow: hidden;
  transition: opacity var(--transition);
}

.brand-name { font-size: 1rem; font-weight: 800; color: var(--sidebar-brand); letter-spacing: 0.5px; }
.brand-business { font-size: 0.7rem; color: var(--sidebar-text); truncate; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }

.sidebar-toggle {
  background: none; border: none; color: var(--sidebar-text);
  cursor: pointer; padding: 0.25rem; font-size: 1rem; flex-shrink: 0;
  transition: color var(--transition);
}
.sidebar-toggle:hover { color: var(--sidebar-icon); }

.sidebar.collapsed .brand-info,
.sidebar.collapsed .nav-label { display: none; }

/* SIDEBAR NAV */
.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.5rem 0;
  scrollbar-width: thin;
  scrollbar-color: var(--sidebar-line) transparent;
}

.nav-section {
  margin-bottom: 0.25rem;
}

.nav-section-title {
  font-size: 0.65rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 1px;
  color: var(--sidebar-title);
  padding: 0.75rem 1.25rem 0.4rem;
  transition: opacity var(--transition);
}

.sidebar.collapsed .nav-section-title { opacity: 0; height: 0; padding: 0; overflow: hidden; }

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1rem;
  margin: 0 0.5rem;
  border-radius: var(--radius);
  color: var(--sidebar-text);
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.875rem;
  font-weight: 500;
  position: relative;
  white-space: nowrap;
  overflow: hidden;
  border: 1px solid transparent;
}

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

.nav-item.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-text-active);
  border-color: var(--sidebar-active-border);
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(47,102,245,0.25);
}
.nav-item.active::before {
  content: ''; position: absolute; left: 0; top: 22%; bottom: 22%; width: 3px; border-radius: 0 3px 3px 0; background: var(--brand-gold);
}

.nav-item.active .nav-icon { color: #ffffff; }

.nav-icon {
  width: 18px; height: 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.9rem;
  transition: color var(--transition);
}

.sidebar.collapsed .nav-item { justify-content: center; margin: 0 0.35rem; }

/* SIDEBAR FOOTER */
.sidebar-footer {
  padding: 0.75rem;
  border-top: 1px solid var(--sidebar-line);
}

.sidebar-user {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background var(--transition);
  overflow: hidden;
}
.sidebar-user:hover { background: var(--sidebar-hover); }

.user-avatar {
  width: 34px; height: 34px; flex-shrink: 0;
  background: var(--brand-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem; font-weight: 700; color: white;
}

.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 0.82rem; font-weight: 600; color: var(--sidebar-brand); truncate; }
.user-role { font-size: 0.72rem; color: var(--sidebar-text); }

/* MAIN CONTENT */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

/* TOPBAR */
.topbar {
  height: var(--topbar-height);
  background: var(--topbar-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 1rem;
  padding: 0 1.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 50;
}

.topbar-left { display: flex; align-items: center; gap: 1rem; min-width: 200px; }
.topbar-center { flex: 1; max-width: 500px; margin: 0 1rem; }
.topbar-right { display: flex; align-items: center; gap: 0.5rem; }

.mobile-menu-btn {
  display: none; background: none; border: none;
  color: var(--text-secondary); cursor: pointer; font-size: 1.1rem;
  padding: 0.4rem;
}

.breadcrumb {
  font-size: 0.95rem; font-weight: 600;
  color: var(--text-primary);
}

.search-box {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--gray-100);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0 0.875rem;
  transition: all var(--transition);
}

.search-box:focus-within {
  background: var(--bg-card);
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 3px rgba(54,112,255,0.1);
}

.search-box i { color: var(--text-muted); font-size: 0.85rem; }
.search-box input {
  border: none; background: transparent;
  padding: 0.5rem 0; font-size: 0.875rem;
  color: var(--text-primary); outline: none; width: 100%;
}
.search-clear-btn {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); padding: 0.2rem 0.25rem;
  border-radius: 4px; line-height: 1; flex-shrink: 0;
  transition: color 0.15s;
}
.search-clear-btn:hover { color: var(--text-primary); }

/* Global Search Dropdown — appended to body, positioned via JS */
.search-dropdown {
  position: fixed;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: var(--shadow-lg);
  z-index: 9500;
  max-height: 420px;
  overflow-y: auto;
}
.search-dropdown-group-label {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.875rem 0.25rem;
  font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--text-muted);
  border-top: 1px solid var(--border);
}
.search-dropdown-group-label:first-child { border-top: none; }
.search-dropdown-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.875rem;
  cursor: pointer; transition: background var(--transition);
  text-decoration: none;
}
.search-dropdown-item:hover,
.search-dropdown-item.active {
  background: var(--gray-100);
}
.search-dropdown-item-icon {
  width: 30px; height: 30px; border-radius: 6px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(54,112,255,0.1); color: var(--brand-primary);
  font-size: 0.75rem;
}
.search-dropdown-item-body { flex: 1; min-width: 0; }
.search-dropdown-item-name {
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-dropdown-item-sub {
  font-size: 0.75rem; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.search-dropdown-item-ref {
  font-size: 0.7rem; color: var(--text-muted);
  background: var(--gray-100); border-radius: 4px;
  padding: 0.1rem 0.35rem; flex-shrink: 0;
}
.search-dropdown-empty {
  padding: 1.25rem; text-align: center;
  color: var(--text-muted); font-size: 0.875rem;
}
.search-dropdown-spinner {
  padding: 1rem; text-align: center; color: var(--text-muted); font-size: 0.875rem;
}
.topbar-center { position: relative; }

[data-theme="dark"] .search-dropdown-item:hover,
[data-theme="dark"] .search-dropdown-item.active { background: var(--gray-200); }
[data-theme="dark"] .search-dropdown-item-ref { background: var(--gray-200); }

.topbar-btn {
  position: relative;
  background: none; border: none;
  width: 36px; height: 36px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-secondary); cursor: pointer; font-size: 1rem;
  transition: all var(--transition);
}
.topbar-btn:hover { background: var(--gray-100); color: var(--text-primary); }

.badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--danger); color: white;
  font-size: 0.65rem; font-weight: 700;
  min-width: 16px; height: 16px;
  border-radius: 8px; padding: 0 3px;
  display: flex; align-items: center; justify-content: center;
}

.topbar-user {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer; font-size: 0.875rem;
  font-weight: 500; transition: background var(--transition);
}
.topbar-user:hover { background: var(--gray-100); }
.topbar-user i { color: var(--text-muted); font-size: 0.75rem; }

.user-avatar-sm {
  width: 28px; height: 28px;
  background: var(--brand-gradient);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.75rem; font-weight: 700; color: white;
}

.user-dropdown {
  position: absolute; top: calc(var(--topbar-height) - 4px); right: 1rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 0.5rem;
  min-width: 200px;
  z-index: 200;
}

.user-dropdown a {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.75rem;
  border-radius: var(--radius);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  text-decoration: none;
  transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--gray-100); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 0.3rem 0; }

/* PAGE CONTENT */
.page-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.5rem;
}

.loading-page {
  display: flex; align-items: center; justify-content: center;
  height: 200px; color: var(--text-muted); gap: 0.5rem; font-size: 0.9rem;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

/* ── Tab bar ────────────────────────────────────────────── */
.tabs-bar {
  display: flex;
  gap: 0.25rem;
  margin-bottom: 1.25rem;
  border-bottom: 2px solid var(--border);
  padding-bottom: 0;
}

.tab-btn {
  padding: 0.55rem 1.1rem;
  font-size: 0.875rem;
  font-weight: 500;
  font-family: inherit;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: var(--radius) var(--radius) 0 0;
  transition: color 0.15s, border-color 0.15s, background 0.15s;
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--text-primary);
  background: var(--bg-card-hover);
}

.tab-btn.active {
  color: var(--brand-primary);
  border-bottom-color: var(--brand-primary);
  font-weight: 600;
}

/* ── Dual-currency label ────────────────────────────────── */
.fx-base {
  font-size: 0.78em;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 0.25em;
}

.card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border-light);
}

.card-title { font-size: 1rem; font-weight: 600; color: var(--text-primary); }
.card-subtitle { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.2rem; }

/* STAT CARDS */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
  transition: transform var(--transition), box-shadow var(--transition);
}

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

.stat-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 0.75rem;
}

.stat-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem;
}

.stat-icon.primary { background: rgba(54,112,255,0.12); color: var(--brand-primary); }
.stat-icon.success { background: rgba(16,185,129,0.12); color: var(--success); }
.stat-icon.warning { background: rgba(245,158,11,0.12); color: var(--warning); }
.stat-icon.danger  { background: rgba(239,68,68,0.12); color: var(--danger); }
.stat-icon.info    { background: rgba(59,130,246,0.12); color: var(--info); }

.stat-change {
  font-size: 0.75rem;
  font-weight: 500;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}
.stat-change.up { background: var(--success-light); color: #059669; }
.stat-change.down { background: var(--danger-light); color: #dc2626; }

.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-primary); line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* GRID LAYOUTS */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 1.25rem; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 1rem; }

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap; gap: 1rem;
}

.page-header-left h1 {
  font-size: 1.5rem; font-weight: 700;
  color: var(--text-primary);
}

.page-header-left p {
  font-size: 0.875rem; color: var(--text-secondary); margin-top: 0.25rem;
}

.page-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }

/* ============================================================
   TABLE
   ============================================================ */
.table-container { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

thead tr { border-bottom: 2px solid var(--border); }

thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  font-weight: 600; font-size: 0.8rem;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--border-light);
  transition: background var(--transition);
}
tbody tr:hover { background: var(--bg-card-hover); }
tbody tr:last-child { border-bottom: none; }

tbody td { padding: 0.875rem 1rem; color: var(--text-primary); vertical-align: middle; }

.table-empty {
  text-align: center; padding: 3rem 1rem;
  color: var(--text-muted);
}
.table-empty i { font-size: 2.5rem; margin-bottom: 0.75rem; display: block; opacity: 0.4; }
.table-empty p { font-size: 0.9rem; }

/* ============================================================
   BADGES / STATUS
   ============================================================ */
.badge-status {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.6rem;
  border-radius: 20px;
  font-size: 0.75rem; font-weight: 600;
  white-space: nowrap;
}

.badge-status::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  display: inline-block;
}

.status-active, .status-confirmed, .status-approved, .status-paid, .status-completed {
  background: var(--success-light); color: #059669;
}
.status-draft, .status-pending, .status-todo {
  background: var(--gray-100); color: var(--gray-600);
}
.status-warning, .status-partial, .status-partially_paid, .status-in_progress {
  background: var(--warning-light); color: #b45309;
}
.status-danger, .status-overdue, .status-cancelled, .status-rejected, .status-inactive {
  background: var(--danger-light); color: #b91c1c;
}
.status-info, .status-sent, .status-processing {
  background: var(--info-light); color: #1e40af;
}

/* ============================================================
   FILTERS / SEARCH BAR
   ============================================================ */
.filters-bar {
  display: flex; align-items: center; gap: 0.75rem;
  margin-bottom: 1rem; flex-wrap: wrap;
}

.filter-search {
  display: flex; align-items: center; gap: 0.5rem;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0 0.875rem;
  transition: border-color var(--transition);
  flex: 1; min-width: 200px;
}

.filter-search:focus-within { border-color: var(--brand-primary); }
.filter-search i { color: var(--text-muted); font-size: 0.85rem; }
.filter-search input {
  border: none; background: transparent; outline: none;
  padding: 0.5rem 0; font-size: 0.875rem; width: 100%;
  color: var(--text-primary);
}

.filter-select {
  padding: 0.5rem 0.875rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem; font-family: inherit;
  background: var(--bg-card); color: var(--text-primary);
  cursor: pointer; outline: none;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.2s ease;
}

.modal-lg { max-width: 800px; }
.modal-xl { max-width: 1000px; }
.modal-sm { max-width: 400px; }
.modal-wide { max-width: 1100px; width: 96vw; }

@keyframes modalIn {
  from { opacity: 0; transform: translateY(-20px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title { font-size: 1.05rem; font-weight: 700; }

.modal-close {
  background: none; border: none;
  width: 32px; height: 32px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted); cursor: pointer; font-size: 1rem;
  transition: all var(--transition);
}
.modal-close:hover { background: var(--gray-100); color: var(--text-primary); }

.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 0.75rem;
}

/* ============================================================
   BUSINESS SELECTOR
   ============================================================ */
.business-selector-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 2rem;
  width: 90%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
}

.biz-sel-header {
  display: flex; align-items: center; gap: 1rem;
  margin-bottom: 1.5rem;
}

.biz-sel-header h3 { font-size: 1.1rem; font-weight: 700; }
.biz-sel-header p { font-size: 0.85rem; color: var(--text-muted); }

.business-list { display: flex; flex-direction: column; gap: 0.5rem; }

.business-card {
  display: flex; align-items: center; gap: 1rem;
  padding: 1rem 1.25rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
}
.business-card:hover {
  border-color: var(--brand-primary);
  background: rgba(54,112,255,0.04);
  transform: translateX(2px);
}

.biz-icon {
  width: 44px; height: 44px;
  background: var(--brand-gradient);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 800; color: white; flex-shrink: 0;
}

.biz-info { flex: 1; }
.biz-name { font-weight: 600; font-size: 0.95rem; }
.biz-meta { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 0.5rem; }

/* ============================================================
   DASHBOARD PAGE
   ============================================================ */
.dashboard-welcome {
  background: var(--brand-gradient);
  border-radius: var(--radius-lg);
  padding: 2rem;
  color: white;
  margin-bottom: 1.5rem;
  position: relative;
  overflow: hidden;
}

.dashboard-welcome::after {
  content: '';
  position: absolute;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255,255,255,0.06);
  right: -50px; top: -100px;
}

.dashboard-welcome h2 { font-size: 1.5rem; font-weight: 700; }
.dashboard-welcome p { opacity: 0.85; margin-top: 0.25rem; font-size: 0.9rem; }

/* APP GRID */
.app-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.app-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem;
}
.app-card:hover {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.app-card .app-icon {
  width: 44px; height: 44px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}

.app-card .app-name { font-weight: 600; font-size: 0.875rem; line-height: 1.4; }
.app-card .app-status { font-size: 0.72rem; color: var(--text-muted); }
.app-card .installed-badge {
  font-size: 0.65rem; padding: 0.15rem 0.4rem;
  background: var(--success-light); color: #059669;
  border-radius: 4px; font-weight: 600;
}

/* CHART CONTAINER */
.chart-container { position: relative; height: 260px; }

/* ============================================================
   DETAIL PANEL
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  font-size: 0.875rem;
}

.detail-item label {
  display: block; font-size: 0.75rem; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.detail-item span { color: var(--text-primary); font-weight: 500; }

/* ============================================================
   INVOICE DOCUMENT
   ============================================================ */
.invoice-doc {
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 2.5rem;
  max-width: 750px;
}

.invoice-header {
  display: flex; justify-content: space-between;
  margin-bottom: 2rem;
}

.invoice-from { max-width: 280px; }
.invoice-meta { text-align: right; }
.invoice-no { font-size: 1.8rem; font-weight: 800; color: var(--brand-primary); }
.invoice-table { width: 100%; margin: 1.5rem 0; }
.invoice-totals { float: right; width: 280px; }
.invoice-total-row { display: flex; justify-content: space-between; padding: 0.4rem 0; border-bottom: 1px solid var(--border-light); }
.invoice-grand-total { font-size: 1.1rem; font-weight: 700; color: var(--brand-primary); }

/* ============================================================
   PIPELINE / KANBAN
   ============================================================ */
.pipeline-board { display: flex; gap: 1rem; overflow-x: auto; padding-bottom: 1rem; }
.pipeline-col {
  min-width: 240px; flex-shrink: 0;
  background: var(--bg-card-hover);
  border-radius: var(--radius-lg);
  padding: 1rem;
}
.pipeline-col-header {
  font-size: 0.8rem; font-weight: 700;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin-bottom: 0.75rem;
  display: flex; align-items: center; justify-content: space-between;
}
.pipeline-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.875rem;
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all var(--transition);
  font-size: 0.8rem;
}
.pipeline-card:hover { border-color: var(--brand-primary); box-shadow: var(--shadow); }

/* ============================================================
   TOAST NOTIFICATIONS
   ============================================================ */
.toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem;
  display: flex; flex-direction: column; gap: 0.5rem;
  z-index: 99999;
}

.toast {
  background: var(--gray-900); color: white;
  padding: 0.875rem 1.25rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 0.75rem;
  font-size: 0.875rem;
  animation: toastIn 0.3s ease;
  max-width: 380px;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateX(50px); }
  to   { opacity: 1; transform: translateX(0); }
}

.toast.success { background: #065f46; border-left: 3px solid var(--success); }
.toast.error   { background: #7f1d1d; border-left: 3px solid var(--danger); }
.toast.warning { background: #78350f; border-left: 3px solid var(--warning); }
.toast.info    { background: #1e3a5f; border-left: 3px solid var(--info); }

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center; padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.3; display: block; }
.empty-state h3 { font-size: 1rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.875rem; max-width: 300px; margin: 0 auto 1.5rem; }

/* ============================================================
   SETUP / ONBOARDING
   ============================================================ */
.setup-wizard {
  max-width: 640px; margin: 0 auto; padding: 2rem 1rem;
}

.setup-steps {
  display: flex; gap: 0; margin-bottom: 2.5rem;
  position: relative;
}

.setup-steps::before {
  content: '';
  position: absolute; top: 18px; left: 0; right: 0;
  height: 2px; background: var(--border); z-index: 0;
}

.step-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  gap: 0.5rem; position: relative; z-index: 1;
}

.step-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 2px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem; color: var(--text-muted);
  transition: all var(--transition);
}

.step-item.active .step-dot {
  background: var(--brand-primary); border-color: var(--brand-primary); color: white;
}
.step-item.completed .step-dot {
  background: var(--success); border-color: var(--success); color: white;
}
.step-label { font-size: 0.72rem; text-align: center; color: var(--text-muted); font-weight: 500; }
.step-item.active .step-label { color: var(--brand-primary); font-weight: 600; }

/* ============================================================
   PLATFORM ADMIN
   ============================================================ */
.platform-bar {
  background: #1a1a2e;
  color: #e2e8f0;
  padding: 0.5rem 1.5rem;
  font-size: 0.75rem;
  display: flex; align-items: center; gap: 1rem;
}
.platform-bar .platform-badge {
  background: var(--brand-primary); color: white;
  padding: 0.2rem 0.5rem; border-radius: 4px;
  font-weight: 700; font-size: 0.7rem;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .grid-3 { grid-template-columns: 1fr 1fr; }
  .grid-4 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  :root { --sidebar-width: 0px; }

  .sidebar {
    position: fixed; left: -260px;
    height: 100vh; z-index: 200;
    width: 260px !important;
    transition: left var(--transition);
  }

  .sidebar.mobile-open { left: 0; box-shadow: var(--shadow-lg); }

  .mobile-menu-btn { display: flex; }
  .auth-left { display: none; }
  .auth-right { width: 100%; background: var(--bg-card-hover); padding: 1rem; align-items: flex-start; }
  .auth-card { margin: 1rem auto 2rem; }

  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .topbar-center { display: none; }
  .page-content { padding: 1rem; }
  .form-row { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }

  .app-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .page-header { flex-direction: column; align-items: flex-start; }
  .auth-card { padding: 1.5rem; }
}

/* ============================================================
   PRINT STYLES
   ============================================================ */
@media print {
  body { background: #fff !important; color: #000 !important; font-size: 11pt; }
  .sidebar, .topbar, .page-actions, .btn, .tabs-bar, .filters-bar,
  #sidebar-nav, #topbar, .modal-overlay { display: none !important; }
  .main-content { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; page-break-inside: avoid; }
  #print-area { display: block !important; }
  a { color: #000 !important; text-decoration: none !important; }
  .badge-status { border: 1px solid #999 !important; background: none !important; color: #000 !important; }
  table { border-collapse: collapse; width: 100%; }
  th, td { border: 1px solid #ddd; padding: 6px 8px; font-size: 10pt; }
  th { background: #f5f5f5 !important; color: #000 !important; }
  .print-doc { max-width: 100%; padding: 0; }
  .print-doc .print-header { border-bottom: 2px solid #333; padding-bottom: 1rem; margin-bottom: 1.5rem; }
  .print-doc .print-footer { border-top: 1px solid #ccc; margin-top: 2rem; padding-top: 1rem; font-size: 9pt; color: #666; }
  @page { margin: 1.5cm; }
}

/* Print preview overlay */
#print-area {
  display: none;
  position: fixed; inset: 0; z-index: 9999;
  background: #fff; overflow-y: auto; padding: 2rem;
}
#print-area .print-close {
  position: fixed; top: 1rem; right: 1rem;
  display: flex; gap: .5rem;
}
.print-doc { max-width: 800px; margin: 0 auto; font-family: 'Segoe UI', sans-serif; color: #111; }
.print-doc .print-header { display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 2px solid #2F66F5; padding-bottom: 1rem; margin-bottom: 1.5rem; }
.print-doc .print-title { font-size: 2rem; font-weight: 700; color: #2F66F5; }
.print-doc .print-meta { font-size: .85rem; color: #555; line-height: 1.6; }
.print-doc .print-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 2rem; margin-bottom: 1.5rem; }
.print-doc .print-party strong { display: block; font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: #888; margin-bottom: .25rem; }
.print-doc table { width: 100%; border-collapse: collapse; margin-bottom: 1.5rem; }
.print-doc th { background: #f8f8f8; padding: 8px 10px; text-align: left; font-size: .8rem; border-bottom: 2px solid #eee; }
.print-doc td { padding: 8px 10px; border-bottom: 1px solid #f0f0f0; font-size: .9rem; }
.print-doc .totals-box { display: flex; justify-content: flex-end; }
.print-doc .totals-table { width: 280px; }
.print-doc .totals-table tr:last-child td { font-weight: 700; font-size: 1.1rem; border-top: 2px solid #333; padding-top: .5rem; }
.print-doc .print-footer { text-align: center; font-size: .75rem; color: #888; margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #eee; }

/* ============================================================
   PRINT / PDF EXPORT
   ============================================================ */
@media print {
  /* Force all colors and backgrounds to render */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* Hide everything except the report content */
  .sidebar,
  .topbar,
  .page-actions,
  #business-selector,
  .modal-overlay,
  .user-menu,
  .search-dropdown,
  .toast-container,
  #print-area .print-close {
    display: none !important;
  }

  /* Flatten the fixed-height flex layout so content can flow across pages */
  html, body {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    background: #fff !important;
    color: #000 !important;
  }

  .app {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
  }

  .main-content {
    display: block !important;
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    margin-left: 0 !important;
    padding: 0 !important;
  }

  .page-content {
    overflow: visible !important;
    height: auto !important;
    min-height: 0 !important;
    padding: 24px !important;
  }

  /* Base text */
  body, .page-content, #report-body, p, span, td, th, li {
    color: #000 !important;
  }
  .text-muted {
    color: #555 !important;
  }

  /* Cards */
  .card {
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    break-inside: avoid;
    background: #fff !important;
  }

  /* Stat grid: 4 columns on print */
  .stat-grid {
    grid-template-columns: repeat(4, 1fr) !important;
  }

  /* Detail card grid: 2 columns on print */
  #report-body > div[style*="grid"] {
    grid-template-columns: repeat(2, 1fr) !important;
  }

  /* Page breaks */
  .stat-grid { break-inside: avoid; }
  h1 { break-after: avoid; }
}

/* ── Module guides ("How it works") and the Getting started checklist ── */
.module-guide { position: fixed; right: 24px; bottom: 24px; z-index: 900; width: 380px; max-width: calc(100vw - 32px); max-height: calc(100vh - 110px); overflow: auto;
  background: var(--bg-card); border: 1px solid var(--border); border-top: 4px solid var(--brand-gold); border-radius: 16px; padding: 1rem 1.1rem .9rem;
  box-shadow: 0 18px 50px rgba(15, 23, 42, .22), 0 4px 12px rgba(15, 23, 42, .08); transform-origin: bottom right; animation: mg-pop .55s cubic-bezier(.34, 1.56, .64, 1) both; }
.module-guide.leaving { animation: mg-out .26s ease-in forwards; }
@keyframes mg-pop { 0% { opacity: 0; transform: translateY(40px) scale(.85); } 100% { opacity: 1; transform: none; } }
@keyframes mg-out { to { opacity: 0; transform: translateY(30px) scale(.92); } }
.module-guide .mg-head { display: flex; gap: .7rem; align-items: center; padding-right: 1.6rem; }
.module-guide .mg-icon { flex: 0 0 38px; height: 38px; border-radius: 10px; background: var(--brand-primary); color: #fff; display: flex; align-items: center; justify-content: center; animation: mg-wiggle 1.2s .5s ease-in-out 2; }
@keyframes mg-wiggle { 0%, 100% { transform: rotate(0); } 25% { transform: rotate(-12deg) scale(1.08); } 75% { transform: rotate(12deg) scale(1.08); } }
.module-guide .mg-kicker { font-size: 11px; font-weight: 700; letter-spacing: .12em; color: var(--brand-primary); text-transform: uppercase; }
.module-guide h3 { margin: 1px 0 0; font-size: 1.02rem; color: var(--text-primary); }
.module-guide p { margin: .6rem 0; color: var(--text-secondary); font-size: .875rem; }
.module-guide .mg-steps { margin: 0; padding: 0; list-style: none; display: grid; gap: .4rem; counter-reset: mg; }
.module-guide .mg-steps li { counter-increment: mg; display: flex; gap: .55rem; align-items: flex-start; font-size: .85rem; color: var(--text-primary); background: var(--bg-body); border-radius: 8px; padding: .5rem .6rem;
  opacity: 0; animation: mg-step .35s ease-out forwards; }
.module-guide .mg-steps li:nth-child(1) { animation-delay: .25s; } .module-guide .mg-steps li:nth-child(2) { animation-delay: .4s; } .module-guide .mg-steps li:nth-child(3) { animation-delay: .55s; }
@keyframes mg-step { from { opacity: 0; transform: translateX(14px); } to { opacity: 1; transform: none; } }
.module-guide .mg-steps li::before { content: counter(mg); flex: 0 0 22px; height: 22px; border-radius: 6px; background: var(--brand-primary); color: #fff; font-weight: 700; font-size: 12px; display: flex; align-items: center; justify-content: center; }
.module-guide .mg-tip { margin-top: .6rem; font-size: .82rem; color: var(--text-secondary); }
.module-guide .mg-tip i { color: var(--brand-gold); margin-right: .3rem; }
.module-guide .mg-actions { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .75rem; }
.module-guide .mg-close { position: absolute; top: .55rem; right: .6rem; border: 0; background: none; color: var(--text-secondary); cursor: pointer; font-size: 1rem; padding: .25rem; }
.module-guide .mg-timer { height: 3px; background: var(--bg-body); border-radius: 99px; margin-top: .8rem; overflow: hidden; }
.module-guide .mg-timer span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold)); transform-origin: left; animation: mg-timer linear forwards; }
.module-guide.paused .mg-timer span { animation-play-state: paused; }
@keyframes mg-timer { from { transform: scaleX(1); } to { transform: scaleX(0); } }
.topbar-btn.nudge { animation: mg-nudge .9s ease-in-out 2; }
@keyframes mg-nudge { 0%, 100% { transform: scale(1); } 40% { transform: scale(1.3); box-shadow: 0 0 0 6px rgba(54,112,255,.18); border-radius: 50%; } }
@media (prefers-reduced-motion: reduce) { .module-guide, .module-guide .mg-steps li, .module-guide .mg-icon, .topbar-btn.nudge { animation: none !important; opacity: 1; } }

.setup-card { background: var(--bg-card); border: 1px solid var(--border); border-top: 4px solid var(--brand-primary); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.setup-card .sc-head { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; }
.setup-card h3 { margin: 0; font-size: 1.05rem; color: var(--text-primary); }
.setup-card .sc-sub { margin: 2px 0 0; color: var(--text-secondary); font-size: .875rem; }
.setup-card .sc-bar { height: 8px; border-radius: 99px; background: var(--bg-body); margin: .8rem 0; overflow: hidden; }
.setup-card .sc-bar span { display: block; height: 100%; background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold)); border-radius: 99px; }
.setup-card .sc-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: .5rem; }
.setup-card .sc-step { display: flex; gap: .7rem; align-items: center; padding: .6rem .75rem; border: 1px solid var(--border); border-radius: 10px; cursor: pointer; background: var(--bg-card); text-align: left; font: inherit; color: inherit; width: 100%; }
.setup-card .sc-step:hover { border-color: var(--brand-primary); }
.setup-card .sc-step .sc-dot { flex: 0 0 26px; height: 26px; border-radius: 50%; border: 2px solid var(--gray-300); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; color: var(--text-secondary); }
.setup-card .sc-step.next { border-color: var(--brand-primary); background: rgba(54,112,255,.06); }
.setup-card .sc-step.next .sc-dot { border-color: var(--brand-primary); color: var(--brand-primary); }
.setup-card .sc-step.done .sc-dot { background: var(--success); border-color: var(--success); color: #fff; }
.setup-card .sc-step.done .sc-label { text-decoration: line-through; color: var(--text-secondary); }
.setup-card .sc-label { font-weight: 600; font-size: .9rem; color: var(--text-primary); }
.setup-card .sc-hint { font-size: .8rem; color: var(--text-secondary); }
.search-box .search-kbd { font-size: 11px; color: var(--text-secondary); border: 1px solid var(--border); border-radius: 5px; padding: 0 5px; margin-left: .25rem; white-space: nowrap; }
@media (max-width: 768px) { .search-box .search-kbd { display: none; } .module-guide { right: 12px; left: 12px; bottom: 12px; width: auto; max-width: none; transform-origin: bottom center; } }

/* ── Billing ── */
.billing-banner { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.5rem; font-size: .9rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.billing-banner.hidden { display: none; }
.billing-banner span { flex: 1; min-width: 200px; }
.billing-banner.warn { background: #FFF7E8; color: #7A4A00; }
.billing-banner.warn i { color: var(--brand-gold); }
.billing-banner.danger { background: #FEECEC; color: #8A1C1C; }
.billing-banner .btn { background: var(--brand-primary); color: #fff; border: 0; }
[data-theme="dark"] .billing-banner.warn { background: #3a2a0c; color: #FFD58A; }
[data-theme="dark"] .billing-banner.danger { background: #3b1414; color: #FFB4B4; }
.cycle-toggle { display: inline-flex; background: var(--gray-100); border-radius: 10px; padding: 4px; margin-bottom: 1rem; }
.cycle-toggle button { border: 0; background: none; padding: .5rem 1.1rem; border-radius: 8px; font: inherit; font-weight: 600; color: var(--text-secondary); cursor: pointer; }
.cycle-toggle button.on { background: var(--bg-card); color: var(--text-primary); box-shadow: var(--shadow); }
.cycle-toggle button span { font-size: .72rem; color: #7A4A00; background: #FFE7B8; border-radius: 99px; padding: 2px 7px; margin-left: 4px; }
.plan-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1rem; }
.plan-card { position: relative; background: var(--bg-card); border: 1px solid var(--border); border-radius: 14px; padding: 1.25rem; display: flex; flex-direction: column; box-shadow: var(--shadow); }
.plan-card.popular { border: 2px solid var(--brand-primary); }
.plan-card.current { border-color: var(--success); }
.plan-card h3 { margin: 0; font-size: 1.1rem; color: var(--text-primary); }
.plan-desc { margin: .25rem 0 .9rem; color: var(--text-secondary); font-size: .85rem; min-height: 2.4em; }
.plan-price { font-size: 2rem; font-weight: 800; color: var(--text-primary); }
.plan-price span { font-size: .9rem; font-weight: 500; color: var(--text-secondary); margin-left: 2px; }
.plan-save { font-size: .8rem; color: #0F7A4A; font-weight: 600; margin: .2rem 0 .8rem; }
.plan-feat { list-style: none; padding: 0; margin: 0 0 1.1rem; display: grid; gap: .45rem; font-size: .87rem; color: var(--text-primary); flex: 1; }
.plan-feat i { color: var(--brand-primary); margin-right: .45rem; width: 14px; }
.plan-flag { position: absolute; top: -12px; left: 1rem; background: var(--brand-gold); color: #1F2937; font-size: .72rem; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
