/* AqariPro (عقاري برو) — Design System
   Colors: Deep teal-navy + warm gold
   Fonts: Cairo (body), Amiri (Arabic headings)
*/


/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  /* Primary — AqariPro Brand */
  --navy: #0C2D48;
  --navy-light: #164068;
  --navy-mid: #082240;
  --teal: #5B8DB8;
  --teal-dark: #4A7CA6;
  --gold: #D4A843;
  --gold-dark: #B8922E;

  /* Semantic */
  --success: #10B981;
  --warning: #F59E0B;
  --danger: #EF4444;
  --info: #3B82F6;

  /* Neutrals — AqariPro Brand */
  --white: #FFFFFF;
  --pearl: #FAFAF9;
  --sand: #F0EBE3;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;

  /* Glass */
  --glass-bg: rgba(12, 45, 72, 0.6);
  --glass-border: rgba(91, 141, 184, 0.2);
  --glass-blur: 20px;

  /* Layout */
  --sidebar-width: 260px;
  --header-height: 64px;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --border-radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.15);
  --gold-glow: 0 4px 12px rgba(212,168,67,0.3);

  /* Transitions */
  --transition: all 0.3s ease;

  /* Theme-aware colors (light mode defaults) */
  --bg-primary: #FAFAF9;
  --bg-secondary: #ffffff;
  --bg-card: #ffffff;
  --bg-header: #ffffff;
  --bg-input: #ffffff;
  --bg-hover: #f3f4f6;
  --bg-modal: #ffffff;
  --bg-table-stripe: #f8fafc;
  --text-primary: #1F2937;
  --text-secondary: #6B7280;
  --text-muted: #9CA3AF;
  --text-heading: #0C2D48;
  --border-main: #E5E7EB;
  --border-light: #F3F4F6;
}

/* ============================================================
   DARK MODE — deep navy gradient
   ============================================================ */
[data-theme="dark"] {
  --bg-primary: #0B1929;
  --bg-secondary: #0F2744;
  --bg-card: #0F2744;
  --bg-header: #0F2744;
  --bg-input: #0A1E38;
  --bg-hover: #1A3556;
  --bg-modal: #0F2744;
  --bg-table-stripe: #0A1E38;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-heading: #f1f5f9;
  --border-main: #1A3A5C;
  --border-light: #0A1E38;
  --pearl: #0B1929;
  --white: #0F2744;
  --gray-100: #0A1E38;
  --gray-200: #1A3A5C;
  --gray-300: #475569;
  --gray-400: #64748b;
  --gray-500: #94a3b8;
  --gray-600: #cbd5e1;
  --gray-700: #e2e8f0;
  --gray-800: #f1f5f9;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.5);
  --gold-glow: 0 4px 12px rgba(212,168,67,0.3);
}

/* Dark mode sidebar — darker than cards */
[data-theme="dark"] .sidebar {
  background: #0a1e3a;
}
[data-theme="dark"] .sidebar > div:last-child {
  background: #0a1e3a;
}
/* Dark mode buttons readable */
[data-theme="dark"] .btn-primary {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}
[data-theme="dark"] .btn-primary:hover {
  background: #1d4ed8;
}
[data-theme="dark"] .btn-outline {
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] .btn-outline:hover {
  background: #132e52;
}
[data-theme="dark"] .btn {
  color: #e2e8f0;
}
[data-theme="dark"] .btn-danger {
  background: #dc2626;
  color: #ffffff;
}

/* Dark mode login page */
[data-theme="dark"] .login-page {
  background: linear-gradient(135deg, #0c1829 0%, #0a1e3a 50%, #132e52 100%);
}
[data-theme="dark"] .login-card {
  background: rgba(15, 23, 42, 0.7);
}

/* Dark mode transitions for smooth toggle */
body, .main-header, .kpi-card, .card, .modal, .form-control,
.pipeline-step, .pipeline-card, .compliance-item, table th, table td,
.user-badge, .btn-lang, .btn-outline, .modal-close, .photo-card {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* Dark mode body background — matches login gradient */
[data-theme="dark"] body {
  background: #0a1e3a;
  color: #e2e8f0;
}

/* Dark mode header — matches login card */
[data-theme="dark"] .main-header {
  background: #132e52;
  border-bottom: 1px solid #1a3a5c;
}
[data-theme="dark"] .header-left h1 { color: #f1f5f9; }
[data-theme="dark"] .header-left img { filter: brightness(0) invert(1); }

/* Dark mode cards & panels — matches login page */
[data-theme="dark"] .card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .card-header {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .card-header h3 { color: #f1f5f9; }
[data-theme="dark"] h1, [data-theme="dark"] h2, [data-theme="dark"] h3, [data-theme="dark"] h4 { color: #f1f5f9; }
[data-theme="dark"] strong { color: #e2e8f0; }
[data-theme="dark"] .text-muted { color: #94a3b8 !important; }

/* Dark mode KPI cards — matches login page */
[data-theme="dark"] .kpi-card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .kpi-card .kpi-value { color: #e2d5c0; }
[data-theme="dark"] .kpi-card .kpi-label { color: #94a3b8; }
[data-theme="dark"] .kpi-card .kpi-sub { color: #64748b; }

/* Dark mode tables — alternating rows visible */
[data-theme="dark"] table th {
  background: #0c1829;
  color: #94a3b8;
}
[data-theme="dark"] table td {
  color: #e2e8f0;
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] table tr:nth-child(even) td {
  background: #0e2240;
}
[data-theme="dark"] table tr:hover td {
  background: #1a3a5c;
}

/* Dark mode form inputs — dark bg, light text, visible borders */
[data-theme="dark"] .form-control {
  background: #0e2240;
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] .form-control:focus {
  border-color: #60a5fa;
}
[data-theme="dark"] .form-control::placeholder {
  color: #64748b;
}
[data-theme="dark"] select.form-control {
  background-color: #0e2240 !important;
  color: #e2e8f0 !important;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%2394a3b8'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: left 12px center !important;
}
[data-theme="dark"] select.form-control option {
  background: #0e2240;
  color: #e2e8f0;
}
[data-theme="dark"] .filter-bar,
[data-theme="dark"] .toolbar {
  background: transparent !important;
}
[data-theme="dark"] .btn-lang,
[data-theme="dark"] .btn-theme {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .escalation-tabs > * {
  background: #132e52 !important;
  border-color: #1a3a5c !important;
  color: #cbd5e1 !important;
}
[data-theme="dark"] .escalation-tabs > .active {
  background: #0a1e3a !important;
  color: #ffffff !important;
}
[data-theme="dark"] .form-group label {
  color: #94a3b8;
}

/* Dark mode badge adjustments — keep their own colored backgrounds */
[data-theme="dark"] .badge-success { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .badge-danger { background: rgba(239,68,68,0.2); color: #f87171; }
[data-theme="dark"] .badge-warning { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .badge-info { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .badge-teal { background: rgba(0,212,170,0.2); color: #5eead4; }
[data-theme="dark"] .badge-gold { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .badge-gray { background: rgba(100,116,139,0.2); color: #94a3b8; }
[data-theme="dark"] .badge-purple { background: rgba(139,92,246,0.2); color: #a78bfa; }
[data-theme="dark"] .compliance-ok { background: rgba(16,185,129,0.15); color: #34d399; border-color: rgba(16,185,129,0.3); }
[data-theme="dark"] .compliance-fail { background: rgba(239,68,68,0.15); color: #f87171; border-color: rgba(239,68,68,0.3); }

/* Dark mode demo/live banners */
[data-theme="dark"] .demo-banner { background: #1a2a10; color: #fbbf24; border-bottom-color: #2d4a1a; }
[data-theme="dark"] .live-banner { background: #0a2a1a; color: #86efac; border-bottom-color: #1a4a2a; }

/* Dark mode photo cards */
[data-theme="dark"] .photo-card { background: #0e2240; border-color: #1a3a5c; }
[data-theme="dark"] .photo-card .photo-caption { color: #94a3b8; border-top-color: #1a3a5c; }
[data-theme="dark"] .photo-type-issue { background: rgba(239,68,68,0.2); color: #f87171; }
[data-theme="dark"] .photo-type-before { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .photo-type-after { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .photo-type-evidence { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .photo-type-general { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* Dark mode unit type badges */
[data-theme="dark"] .unit-type-badge.commercial { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .unit-type-badge.worker { background: rgba(0,212,170,0.2); color: #5eead4; }
[data-theme="dark"] .unit-type-badge.residential { background: rgba(245,158,11,0.2); color: #fbbf24; }

/* Dark mode escalation bar */
[data-theme="dark"] .escalation-bar .level { background: #1a3a5c; }

/* Dark mode KPI icon backgrounds */
[data-theme="dark"] .kpi-icon.blue { background: rgba(59,130,246,0.15); }
[data-theme="dark"] .kpi-icon.green { background: rgba(16,185,129,0.15); }
[data-theme="dark"] .kpi-icon.gold { background: rgba(0,52,104,0.2); }
[data-theme="dark"] .kpi-icon.red { background: rgba(239,68,68,0.15); }
[data-theme="dark"] .kpi-icon.teal { background: rgba(0,212,170,0.15); }

/* Dark mode sidebar text */
[data-theme="dark"] .sidebar-section-title { color: rgba(167,191,219,0.5); }

/* Dark mode pipeline cards */
[data-theme="dark"] .pipeline-step { background: #132e52; border-color: #1a3a5c; }
[data-theme="dark"] .pipeline-step-header .step-name { color: #f1f5f9; }
[data-theme="dark"] .pipeline-card { background: #0e2240; border-color: #1a3a5c; color: #e2e8f0; }

/* Dark mode select dropdown arrow */
[data-theme="dark"] select.form-control {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2394a3b8' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
}

/* Dark mode modal */
[data-theme="dark"] .modal-overlay {
  background: rgba(0,0,0,0.75);
}
[data-theme="dark"] .modal {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .modal-header {
  border-bottom-color: #1a3a5c;
  color: #f1f5f9;
}
[data-theme="dark"] .modal-header h3 { color: #f1f5f9; }
[data-theme="dark"] .modal-footer {
  border-top-color: #1a3a5c;
}

/* Dark mode buttons */
[data-theme="dark"] .btn-outline {
  border-color: #475569;
  color: #e2e8f0;
}
[data-theme="dark"] .btn-outline:hover {
  border-color: #e2d5c0;
  color: #e2d5c0;
}
[data-theme="dark"] .btn-lang {
  border-color: #475569;
  color: #94a3b8;
}
[data-theme="dark"] .btn-theme {
  border-color: #475569;
  color: #94a3b8;
}

/* Dark mode user badge */
[data-theme="dark"] .user-badge {
  background: #0e2240;
  color: #e2e8f0;
}
[data-theme="dark"] .user-badge .role {
  color: #a7bfdb;
}

/* Dark mode audit page specifics */
[data-theme="dark"] .audit-stat-card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .audit-stat-card .stat-label { color: #94a3b8; }
[data-theme="dark"] .audit-stat-card .stat-value { color: #f1f5f9; }
/* Colorful audit entries by action type */
.timeline-entry.action-create { border-inline-start: 5px solid #10b981 !important; }
.timeline-entry.action-update { border-inline-start: 5px solid #3b82f6 !important; }
.timeline-entry.action-delete { border-inline-start: 5px solid #ef4444 !important; }
.timeline-entry.action-login { border-inline-start: 5px solid #f59e0b !important; }
.timeline-entry.action-logout { border-inline-start: 5px solid #6b7280 !important; }
.timeline-entry.action-upload { border-inline-start: 5px solid #8b5cf6 !important; }
.timeline-entry.action-export { border-inline-start: 5px solid #8b5cf6 !important; }
.timeline-entry.action-download { border-inline-start: 5px solid #8b5cf6 !important; }
.timeline-entry.action-status_change { border-inline-start: 5px solid #0ea5e9 !important; }
.timeline-entry.action-escalation { border-inline-start: 5px solid #ef4444 !important; }
.timeline-entry.action-page_view { border-inline-start: 5px solid #cbd5e1 !important; }
.timeline-entry.action-interaction { border-inline-start: 5px solid #cbd5e1 !important; }

/* Colorful text for action sentences */
.timeline-entry.action-create .timeline-header { color: #059669; }
.timeline-entry.action-delete .timeline-header { color: #dc2626; }
.timeline-entry.action-login .timeline-header { color: #d97706; }
.timeline-entry.action-escalation .timeline-header { color: #dc2626; }
[data-theme="dark"] .timeline-entry.action-create .timeline-header { color: #34d399; }
[data-theme="dark"] .timeline-entry.action-delete .timeline-header { color: #f87171; }
[data-theme="dark"] .timeline-entry.action-login .timeline-header { color: #fbbf24; }
[data-theme="dark"] .timeline-entry.action-escalation .timeline-header { color: #f87171; }

[data-theme="dark"] .timeline-entry {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .timeline-user { color: #e2e8f0; }
[data-theme="dark"] .timeline-resource { color: #94a3b8; }
[data-theme="dark"] .timeline-resource strong { color: #e2e8f0; }
[data-theme="dark"] .timeline-details { background: #0e2240; color: #94a3b8; }
[data-theme="dark"] .view-toggle { border-color: #1a3a5c; }
[data-theme="dark"] .view-toggle button { color: #94a3b8; }
[data-theme="dark"] .view-toggle button:hover:not(.active) { background: #233556; }
[data-theme="dark"] .view-toggle button.active { background: #003468; color: #fff; }

/* Dark mode action badges */
[data-theme="dark"] .action-badge.create { background: rgba(16,185,129,0.2); color: #34d399; }
[data-theme="dark"] .action-badge.update { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .action-badge.delete { background: rgba(239,68,68,0.2); color: #f87171; }
[data-theme="dark"] .action-badge.login { background: rgba(245,158,11,0.2); color: #fbbf24; }
[data-theme="dark"] .action-badge.logout { background: rgba(100,116,139,0.2); color: #94a3b8; }
[data-theme="dark"] .action-badge.export { background: rgba(139,92,246,0.2); color: #a78bfa; }
[data-theme="dark"] .action-badge.upload { background: rgba(0,212,170,0.2); color: #5eead4; }
[data-theme="dark"] .action-badge.download { background: rgba(0,212,170,0.2); color: #5eead4; }
[data-theme="dark"] .action-badge.status_change { background: rgba(59,130,246,0.2); color: #60a5fa; }
[data-theme="dark"] .action-badge.escalation { background: rgba(239,68,68,0.2); color: #f87171; }
[data-theme="dark"] .resource-badge { background: rgba(100,116,139,0.2); color: #94a3b8; }

/* Dark mode filter inputs */
[data-theme="dark"] .audit-filters input,
[data-theme="dark"] .audit-filters select {
  background: #0e2240;
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] .audit-filters label { color: #94a3b8; }

/* Dark mode details expand pills */
[data-theme="dark"] .timeline-details span[style*="background:#f1f5f9"] {
  background: #233556 !important;
  color: #e2e8f0 !important;
}

/* Dark mode charts — labels and gridlines */
[data-theme="dark"] .chart-legend,
[data-theme="dark"] .chart-label { color: #e2e8f0; }

/* Theme toggle button */
.btn-theme {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-600);
  font-size: 0.9rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Somar Sans', sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
}
.btn-theme:hover {
  border-color: var(--gold);
  color: var(--gold);
}

/* ============================================================
   FONTS — Local Somar Sans (brand) + Google Amiri (Arabic headings)
   ============================================================ */
@font-face { font-family: 'Somar Sans'; src: url('../fonts/SomarSans-Light.otf') format('opentype'); font-weight: 300; font-style: normal; font-display: swap; }
@font-face { font-family: 'Somar Sans'; src: url('../fonts/SomarSans-Regular.otf') format('opentype'); font-weight: 400; font-style: normal; font-display: swap; }
@font-face { font-family: 'Somar Sans'; src: url('../fonts/SomarSans-SemiBold.otf') format('opentype'); font-weight: 600; font-style: normal; font-display: swap; }
@font-face { font-family: 'Somar Sans'; src: url('../fonts/SomarSans-Bold.otf') format('opentype'); font-weight: 700; font-style: normal; font-display: swap; }
@import url('https://fonts.googleapis.com/css2?family=Amiri:wght@400;700&display=swap');

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'Somar Sans', sans-serif;
  background: var(--pearl);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.8;
  letter-spacing: 0.01em;
}

body.rtl {
  direction: rtl;
  text-align: right;
}

body.ltr {
  direction: ltr;
  text-align: left;
}

h1, h2, h3, h4 {
  font-weight: 700;
  line-height: 1.3;
}

.rtl h1, .rtl h2, .rtl h3 {
  font-family: 'Amiri', serif;
}

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--navy-mid) 50%, var(--navy-light) 100%);
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle at 30% 40%, rgba(0,212,170,0.08) 0%, transparent 50%),
              radial-gradient(circle at 70% 60%, rgba(0,52,104,0.06) 0%, transparent 50%);
  animation: float 20s ease-in-out infinite;
}

@keyframes float {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(-2%, -2%); }
}

.login-card {
  position: relative;
  background: rgba(0, 30, 60, 0.5);
  backdrop-filter: blur(var(--glass-blur));
  border: none;
  outline: none;
  border-radius: var(--border-radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: none;
}

.login-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  margin-bottom: 32px;
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 2.5rem;
  color: var(--gold);
  font-family: 'Amiri', serif;
  margin-bottom: 4px;
}

.login-logo p {
  color: var(--gray-400);
  font-size: 0.875rem;
}

/* ============================================================
   APP SHELL (sidebar + header + main)
   ============================================================ */
.app-shell {
  display: flex;
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background: var(--navy);
  color: var(--white);
  position: fixed;
  top: 0;
  bottom: 0;
  overflow-y: auto;
  z-index: 100;
  transition: var(--transition);
  display: flex;
  flex-direction: column;
  padding-bottom: 0;
}

.sidebar > div:last-child {
  margin-top: auto;
  padding-bottom: 20px;
  position: relative;
  bottom: auto;
  background: var(--navy);
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.rtl .sidebar { right: 0; }
.ltr .sidebar { left: 0; }

.sidebar-header {
  padding: 20px 24px;
  border-bottom: none;
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-header h2 {
  font-family: 'Amiri', serif;
  color: var(--gold);
  font-size: 1.5rem;
}

.sidebar-header small {
  display: block;
  color: var(--gray-400);
  font-size: 0.75rem;
}

.sidebar-section {
  padding: 16px 0;
}

.sidebar-section-title {
  text-transform: uppercase;
  font-size: 0.65rem;
  color: rgba(255,255,255,0.4);
  letter-spacing: 0.1em;
  padding: 0 24px;
  margin-bottom: 8px;
  font-weight: 600;
}

.sidebar-nav {
  list-style: none;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 24px;
  color: var(--gray-300);
  text-decoration: none;
  font-size: 0.95rem;
  transition: var(--transition);
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
}

.rtl .sidebar-nav a { border-right: 3px solid transparent; border-left: none; }
.ltr .sidebar-nav a { border-left: 3px solid transparent; border-right: none; }

.sidebar-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
}
[data-theme="dark"] .sidebar-nav a:hover {
  background: rgba(255,255,255,0.1);
  color: #ffffff;
}
[data-theme="dark"] .sidebar-nav a {
  color: #cbd5e1;
}
[data-theme="dark"] .sidebar-nav a.active {
  color: #ffffff;
  background: rgba(255,255,255,0.08);
}

.sidebar-nav a.active {
  color: var(--gold);
  background: rgba(0,52,104,0.08);
}

.rtl .sidebar-nav a.active { border-right-color: var(--gold); }
.ltr .sidebar-nav a.active { border-left-color: var(--gold); }

.sidebar-nav .nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.sidebar-nav .badge {
  margin-inline-start: auto;
  background: var(--danger);
  color: var(--white);
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}

/* Header */
.main-header {
  height: var(--header-height);
  background: var(--white);
  border-bottom: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: fixed;
  top: 0;
  right: 0;
  left: var(--sidebar-width);
  z-index: 90;
  box-shadow: none;
}

.rtl .main-header { right: var(--sidebar-width); left: 0; }

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.header-left h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--navy);
}

.header-right {
  display: flex;
  align-items: center;
  gap: 16px;
}

.btn-lang {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-600);
  font-size: 0.8rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Somar Sans', sans-serif;
}

.btn-lang:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-demo {
  padding: 5px 12px;
  border-radius: 20px;
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-500);
  font-size: 0.75rem;
  cursor: pointer;
  transition: var(--transition);
  font-family: 'Somar Sans', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-demo:hover {
  border-color: var(--teal);
  color: var(--teal);
}

.btn-demo.demo-active {
  background: rgba(0, 212, 170, 0.1);
  border-color: var(--teal);
  color: var(--teal);
  font-weight: 600;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: var(--gray-100);
  border-radius: 20px;
  font-size: 0.8rem;
}

.user-badge .role {
  color: var(--teal);
  font-weight: 600;
}

/* Main Content */
.main-content {
  flex: 1;
  padding: calc(var(--header-height) + 24px) 24px 24px;
  min-width: 0;
}

.rtl .main-content { margin-right: var(--sidebar-width); }
.ltr .main-content { margin-left: var(--sidebar-width); }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: var(--white);
  border-radius: var(--border-radius);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  transition: var(--transition);
}

.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.kpi-card .kpi-label {
  font-size: 0.9rem;
  color: var(--gray-500);
  margin-bottom: 8px;
}

.kpi-card .kpi-value {
  font-size: 1.85rem;
  font-weight: 700;
  color: var(--navy);
}

.kpi-card .kpi-sub {
  font-size: 0.8rem;
  color: var(--gray-400);
  margin-top: 4px;
}

.kpi-card .kpi-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  margin-bottom: 12px;
}

.kpi-icon.blue { background: rgba(59,130,246,0.1); color: var(--info); }
.kpi-icon.green { background: rgba(16,185,129,0.1); color: var(--success); }
.kpi-icon.gold { background: rgba(0,52,104,0.1); color: var(--gold); }
.kpi-icon.red { background: rgba(239,68,68,0.1); color: var(--danger); }
.kpi-icon.teal { background: rgba(0,212,170,0.1); color: var(--teal); }

/* ============================================================
   CARDS & PANELS
   ============================================================ */
.card {
  background: var(--white);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--gray-200);
}

.card-header h3 {
  font-size: 1rem;
  font-weight: 600;
}

.card-body {
  padding: 20px;
}

/* ============================================================
   TABLES
   ============================================================ */
.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

table th {
  background: var(--gray-100);
  padding: 14px 18px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--gray-600);
  letter-spacing: 0.02em;
  white-space: nowrap;
}

table td {
  padding: 14px 18px;
  font-size: 0.95rem;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-700);
  line-height: 1.6;
}

table tr:hover td {
  background: var(--gray-100);
}

.rtl table th, .rtl table td {
  text-align: right;
}

/* Force LTR for phone numbers, emails, and numeric content in RTL */
.ltr-text, [dir="ltr"], .phone-cell, .email-cell {
  direction: ltr;
  unicode-bidi: embed;
  text-align: left;
}

/* ============================================================
   BADGES & STATUS
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
  line-height: 1.4;
  gap: 4px;
}

.badge-success { background: #dcfce7; color: #166534; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-teal { background: #ccfbf1; color: #115e59; }
.badge-gold { background: #fef3c7; color: #92400e; }
.badge-gray { background: #f3f4f6; color: #374151; }
.badge-purple { background: #ede9fe; color: #5b21b6; }

/* Compliance badge */
.compliance-ok { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.compliance-fail { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
  font-family: 'Somar Sans', sans-serif;
  text-decoration: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--navy), var(--navy-light));
  color: var(--white);
}

.btn-primary:hover {
  box-shadow: 0 4px 12px rgba(0,52,104,0.3);
  transform: translateY(-1px);
}

.btn-teal {
  background: var(--teal);
  color: var(--white);
}

.btn-teal:hover {
  background: var(--teal-dark);
}

.btn-outline {
  border: 1px solid var(--gray-300);
  background: transparent;
  color: var(--gray-700);
}

.btn-outline:hover {
  border-color: var(--gold);
  color: var(--gold);
}

.btn-danger {
  background: var(--danger);
  color: var(--white);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.8rem;
}

/* Settings tab content — hide/show based on active class */
.settings-content { display: none; }
.settings-content.active { display: block; }

/* Hide horizontal scrollbars on desktop — only useful on mobile touch */
.tabs::-webkit-scrollbar,
.fin-tabs::-webkit-scrollbar,
.settings-tabs::-webkit-scrollbar,
.escalation-tabs::-webkit-scrollbar,
.property-tabs::-webkit-scrollbar,
.filter-bar::-webkit-scrollbar,
.unit-selector::-webkit-scrollbar {
  display: none;
}
.tabs, .fin-tabs, .settings-tabs, .escalation-tabs, .property-tabs, .filter-bar, .unit-selector,
.sidebar {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.sidebar::-webkit-scrollbar { display: none; }

/* Delete button — red trash icon */
.btn-delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: 6px;
  font-size: 0.85rem;
  transition: background 0.2s, color 0.2s;
}
.btn-delete:hover {
  background: #fee2e2;
  color: #991b1b;
}
[data-theme="dark"] .btn-delete { color: #f87171; }
[data-theme="dark"] .btn-delete:hover { background: #450a0a; color: #fca5a5; }

/* Legacy — remove old text delete */
.btn-text-delete {
  background: none;
  border: none;
  color: #dc2626;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  transition: background 0.2s;
}
.btn-text-delete:hover {
  background: #fee2e2;
}
[data-theme="dark"] .btn-text-delete { color: #f87171; }
[data-theme="dark"] .btn-text-delete:hover { background: #450a0a; }

/* ============================================================
   FORMS
   ============================================================ */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
}

.form-control {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 0.95rem;
  font-family: 'Somar Sans', sans-serif;
  transition: var(--transition);
  background: var(--white);
  color: var(--gray-800);
  line-height: 1.5;
}

.form-control:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(0,52,104,0.1);
}

.form-control::placeholder {
  color: var(--gray-400);
}

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.rtl select.form-control {
  background-position: left 12px center;
  padding-left: 36px;
  padding-right: 14px;
}

/* Login form on dark background */
.login-card .form-control {
  background: rgba(6,13,26,0.5);
  border: none;
  color: var(--white);
  backdrop-filter: blur(10px);
}

.login-card .form-control:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(0,52,104,0.15);
}

.login-card .form-control::placeholder {
  color: var(--gray-500);
}

.login-card label {
  color: var(--gray-400);
}

/* ============================================================
   PIPELINE (7-step leasing)
   ============================================================ */
.pipeline {
  display: flex;
  gap: 12px;
  overflow-x: auto;
  padding-bottom: 8px;
  max-width: 100%;
  -webkit-overflow-scrolling: touch;
}

.pipeline-step {
  flex: 1 1 0;
  min-width: 120px;
  background: var(--gray-100);
  border-radius: var(--border-radius);
  padding: 12px;
}

.pipeline-step-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--gray-300);
}

.pipeline-step-header .step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--navy);
  color: var(--white);
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.pipeline-step-header .step-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--gray-700);
}

.pipeline-step-header .step-count {
  font-size: 0.7rem;
  color: var(--gray-400);
}

.pipeline-card {
  background: var(--white);
  border-radius: var(--border-radius-sm);
  padding: 10px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
  cursor: pointer;
  transition: var(--transition);
}

.pipeline-card:hover {
  box-shadow: var(--shadow-md);
}

.pipeline-card .tenant-name {
  font-weight: 600;
  font-size: 0.85rem;
  margin-bottom: 4px;
}

.pipeline-card .unit-info {
  font-size: 0.75rem;
  color: var(--gray-500);
}

/* ============================================================
   MOMRAH COMPLIANCE GRID
   ============================================================ */
.compliance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 16px;
}

.compliance-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  background: var(--white);
  border-radius: var(--border-radius-sm);
  border: 1px solid var(--gray-200);
}

.compliance-item .check-label {
  font-size: 0.875rem;
  font-weight: 500;
}

.compliance-item .check-value {
  font-weight: 700;
  font-size: 0.9rem;
}

/* ============================================================
   ESCALATION INDICATOR
   ============================================================ */
.escalation-bar {
  display: flex;
  gap: 4px;
  margin-top: 8px;
}

.escalation-bar .level {
  flex: 1;
  height: 6px;
  border-radius: 3px;
  background: var(--gray-200);
}

.escalation-bar .level.active-1 { background: var(--warning); }
.escalation-bar .level.active-2 { background: #F97316; }
.escalation-bar .level.active-3 { background: var(--danger); }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

.modal-overlay.active {
  display: flex;
}

.modal {
  background: var(--white);
  border-radius: var(--border-radius-lg);
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
}

.modal-close {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  background: var(--gray-100);
  cursor: pointer;
  font-size: 1.1rem;
  color: var(--gray-500);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
}

.modal-close:hover {
  background: var(--gray-200);
}

.modal-body {
  padding: 24px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 16px 24px;
  border-top: 1px solid var(--gray-200);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
/* Mobile overlay for sidebar */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 99;
}

.sidebar-overlay.active {
  display: block;
}

/* ============================================================
   TABLET (max 1024px)
   ============================================================ */
@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
    z-index: 200;
    box-shadow: var(--shadow-xl);
    width: 280px;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    max-height: 100vh;
  }
  .rtl .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0) !important; }

  .main-header,
  .rtl .main-header {
    left: 0 !important;
    right: 0 !important;
    padding: 0 16px;
    box-shadow: none;
    height: 56px;
    overflow: visible;
  }

  .main-content,
  .rtl .main-content,
  .ltr .main-content {
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding: 72px 16px 24px;
    width: 100% !important;
    max-width: 100vw !important;
    overflow-x: hidden !important;
    flex: none !important;
  }

  .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .pipeline { flex-direction: column; }
  .pipeline-step { flex: none; min-width: auto; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; gap: 16px; }

  .modal-overlay { align-items: flex-end; padding: 0; }
  .modal {
    max-width: 100vw !important;
    width: 100%;
    margin: 0;
    max-height: 92vh;
    border-radius: 20px 20px 0 0;
  }

  .login-card { margin: 16px; padding: 32px 24px; max-width: 100%; }
  .login-logo img { max-width: 240px !important; }

  .btn-mobile-menu { display: block !important; }

  .card-header { flex-direction: column; gap: 8px; align-items: flex-start; }

  .table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 0 -16px;
    padding: 0 16px;
  }
  table { min-width: 600px; }

  .compliance-grid, .momrah-panel { grid-template-columns: 1fr; }
  .bed-grid { grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)) !important; gap: 8px !important; }

  .tabs, .fin-tabs, .settings-tabs, .escalation-tabs {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    white-space: nowrap;
    flex-wrap: nowrap;
    padding-bottom: 6px;
    gap: 0;
  }
  .tab, .fin-tab, .settings-tab, .esc-tab { white-space: nowrap; flex-shrink: 0; }

  .prop-header { flex-wrap: wrap; gap: 8px; }
  .prop-header h2 { font-size: 1.2rem; }

  .unit-selector { overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap; padding-bottom: 4px; }
  .unit-chip { flex-shrink: 0; white-space: nowrap; }
  .detail-grid { grid-template-columns: 1fr 1fr; }
  .bulk-actions { flex-wrap: wrap; gap: 8px; }
}

/* ============================================================
   PHONE (max 480px) — comprehensive mobile experience
   ============================================================ */
@media (max-width: 480px) {
  /* --- Header --- */
  .main-header,
  .rtl .main-header {
    height: 52px;
    padding: 0 10px !important;
    overflow: visible;
  }

  .main-content,
  .rtl .main-content,
  .ltr .main-content {
    padding: 64px 12px 24px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw !important;
  }

  /* Everything inside main content scrollable */
  .card, .section-card, .sla-info, .escalation-bar, .filter-bar,
  .kpi-grid, .chart-grid, .charts-row, .pipeline,
  .toolbar, .stats-row, .detail-grid, .compliance-grid,
  .momrah-panel, .bed-grid, .photo-grid, .timeline-container {
    max-width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }

  /* Tables must scroll */
  .table-wrapper {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    max-width: 100% !important;
  }

  /* Tabs scroll horizontally */
  .tabs, .fin-tabs, .settings-tabs, .escalation-tabs, .property-tabs {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    flex-wrap: nowrap !important;
    max-width: 100% !important;
  }

  /* Grids single column so nothing overflows */
  .grid-2, .grid-3 { grid-template-columns: 1fr !important; }

  /* Modals scrollable */
  .modal { max-width: 95vw !important; max-height: 90vh !important; }
  .modal-body { overflow-y: auto !important; max-height: 70vh !important; }

  .header-left { gap: 8px; min-width: 0; overflow: hidden; flex: 1; }
  .header-left h1 { font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .header-left img { display: none !important; }
  /* Hide mode badge on phone to save space */
  .mode-badge { display: none !important; }

  /* Ensure header-right items never get cut off */
  .header-right { gap: 6px; flex-shrink: 0; overflow: visible; }
  .user-badge { display: none !important; }
  .btn-lang { padding: 5px 10px; font-size: 0.72rem; flex-shrink: 0; white-space: nowrap; }
  .btn-theme { width: 30px; height: 30px; font-size: 0.8rem; flex-shrink: 0; }
  .btn-demo { padding: 4px 8px; font-size: 0.7rem; }
  .btn-demo .fa-flask { font-size: 0.65rem; }
  .notif-wrapper { flex-shrink: 0; }

  /* --- KPI Cards — clean 2-col grid --- */
  .kpi-grid {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
  .kpi-card {
    padding: 16px 12px;
    text-align: center;
  }
  .kpi-card .kpi-icon {
    width: 36px;
    height: 36px;
    font-size: 1rem;
    margin: 0 auto 10px;
  }
  .kpi-card .kpi-label {
    font-size: 0.8rem;
    margin-bottom: 6px;
    line-height: 1.3;
  }
  .kpi-card .kpi-value {
    font-size: 1.3rem;
    font-weight: 700;
  }

  /* --- Cards --- */
  .card { border-radius: 12px; }
  .card-header { padding: 14px 16px; }
  .card-body { padding: 16px; }

  /* --- Tables — scrollable with better touch --- */
  .table-wrapper {
    margin: 0 -12px;
    padding: 0 12px;
    border-radius: 0;
  }
  table { min-width: 500px; font-size: 0.85rem; }
  table th { padding: 10px 12px; font-size: 0.8rem; }
  table td { padding: 12px; line-height: 1.5; }

  /* --- Forms — prevent iOS zoom with 16px font --- */
  .form-control {
    font-size: 16px !important;
    padding: 12px 14px;
    border-radius: 10px;
  }
  .form-group { margin-bottom: 16px; }
  .form-group label { font-size: 0.85rem; margin-bottom: 6px; }

  /* --- Buttons — bigger touch targets --- */
  .btn {
    padding: 12px 20px;
    font-size: 0.9rem;
    border-radius: 10px;
    min-height: 44px;
  }
  .btn-sm {
    padding: 8px 14px;
    font-size: 0.8rem;
    min-height: 36px;
  }

  /* --- Pipeline steps --- */
  .pipeline-step {
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 8px;
  }
  .pipeline-step h4 { font-size: 1rem; }

  /* --- Escalation tabs — wrap nicely --- */
  .escalation-tabs {
    display: flex;
    flex-wrap: wrap !important;
    gap: 6px;
    white-space: normal !important;
  }
  .esc-tab {
    padding: 8px 14px;
    font-size: 0.8rem;
    border-radius: 20px;
    white-space: nowrap;
  }

  /* --- Modals — full-screen bottom sheet --- */
  .modal {
    border-radius: 20px 20px 0 0;
    max-height: 94vh;
  }
  .modal-header { padding: 16px 20px; }
  .modal-header h3 { font-size: 1.1rem; }
  .modal-body { padding: 20px; }
  .modal-footer { padding: 16px 20px; }

  /* --- Badges --- */
  .badge { padding: 4px 10px; font-size: 0.75rem; border-radius: 16px; }

  /* --- Detail grid --- */
  .detail-grid { grid-template-columns: 1fr; gap: 8px; }
  .detail-item { padding: 10px 0; }
  .detail-item .label { font-size: 0.8rem; }
  .detail-item .value { font-size: 1rem; }

  /* --- SLA Summary --- */
  .card .grid-2 {
    grid-template-columns: 1fr 1fr !important;
    gap: 8px;
  }

  /* --- Login page --- */
  .login-card { padding: 28px 20px; margin: 12px; }
  .login-logo img { max-width: 220px !important; }
  .login-logo p { font-size: 0.8rem; }

  /* --- Sidebar on phone — full width + scrollable --- */
  .sidebar { width: 85vw !important; max-width: 320px; overflow-y: auto !important; -webkit-overflow-scrolling: touch; max-height: 100vh; }
  .sidebar-brand img { max-width: 140px; }
  .sidebar-nav a {
    padding: 14px 20px;
    font-size: 0.95rem;
  }
  .sidebar-nav .nav-icon { width: 22px; height: 22px; }
  .sidebar-section-label {
    padding: 20px 20px 8px;
    font-size: 0.7rem;
  }

  /* --- Property detail tabs --- */
  .tabs {
    gap: 0;
    border-bottom-width: 1px;
  }
  .tab {
    padding: 10px 14px;
    font-size: 0.8rem;
  }

  /* --- Finance tabs --- */
  .fin-tabs { gap: 0; }
  .fin-tab { padding: 10px 14px; font-size: 0.8rem; }
  .settings-tabs { gap: 0; overflow-x: auto; flex-wrap: nowrap; margin-top: 8px; }
  .settings-tab { padding: 8px 12px; font-size: 0.75rem; flex-shrink: 0; white-space: nowrap; }

  /* --- Charts responsive --- */
  canvas { max-width: 100% !important; height: auto !important; }

  /* --- Spacing utilities --- */
  .mb-4 { margin-bottom: 16px; }
  .flex { display: flex; }
  .flex-wrap { flex-wrap: wrap; }

  /* --- Filter bars — stack vertically --- */
  .filter-bar, .toolbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .filter-bar select,
  .filter-bar input {
    width: 100%;
    min-width: 100%;
  }

  /* --- Dashboard stats row (if using .stats-row) --- */
  .stats-row { grid-template-columns: repeat(2, 1fr); }

  /* --- Dashboard grid-2 stack vertically --- */
  .grid-2 { grid-template-columns: 1fr !important; }

  /* --- Sidebar logout — always visible at bottom --- */
  .sidebar-nav { padding-bottom: 20px; }
  .sidebar > div:last-child {
    position: relative;
    bottom: auto;
    background: inherit;
    padding: 8px 16px;
    z-index: 10;
    flex-shrink: 0;
  }

  /* --- Lightbox --- */
  .lightbox-overlay img { max-width: 95%; }

  /* --- Audit timeline — stack entries --- */
  .audit-stats { grid-template-columns: repeat(2, 1fr); gap: 8px; }
  .timeline-header { flex-wrap: wrap; }
  .timeline-entry { padding: 12px; }

  /* --- Worker housing bed grid --- */
  .bed-grid { grid-template-columns: repeat(2, 1fr) !important; }

  /* --- Demo banner compact --- */
  .demo-banner { font-size: 0.65rem; padding: 4px 8px; flex-wrap: wrap; justify-content: center; gap: 4px; text-align: center; }
  .demo-banner button { font-size: 0.65rem !important; padding: 3px 10px !important; margin: 0 !important; }
  .live-banner { font-size: 0.65rem; padding: 4px 8px; flex-wrap: wrap; justify-content: center; gap: 4px; text-align: center; }
  .live-banner button { font-size: 0.65rem !important; padding: 3px 10px !important; margin: 0 !important; }

  /* --- Mobile Cards — replace tables on phone --- */
  .table-wrapper { display: none !important; }
  #tab-roles .table-wrapper { display: block !important; overflow-x: auto; }
  /* Keep tables visible inside modals — detail views need them */
  .modal-body .table-wrapper { display: block !important; overflow-x: auto; }
  .mobile-cards-container { display: block !important; }

  .mobile-card {
    background: var(--bg-card, #fff);
    border: 1px solid var(--border-main, #e2e8f0);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 10px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  }
  [data-theme="dark"] .mobile-card {
    background: #132e52;
    border-color: #1a3a5c;
  }
  .mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 8px;
  }
  .mobile-card-header strong {
    font-size: 0.95rem;
    flex: 1;
  }
  .mobile-card-body {
    display: flex;
    flex-direction: column;
    gap: 6px;
  }
  .mobile-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    padding: 2px 0;
  }
  .mobile-card-row .mobile-label {
    color: var(--text-secondary, #64748b);
    font-size: 0.8rem;
  }
  [data-theme="dark"] .mobile-card-row .mobile-label {
    color: #94a3b8;
  }
  .mobile-card-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-main, #e2e8f0);
    justify-content: flex-end;
  }
  [data-theme="dark"] .mobile-card-actions {
    border-top-color: #1a3a5c;
  }
  .mobile-card-thumb {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
  }
  .mobile-card-thumb-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray-400);
    font-size: 1.2rem;
    flex-shrink: 0;
  }
}

/* Mobile cards hidden on desktop */
.mobile-cards-container { display: none; }

/* ============================================================
   TOUCH DEVICES — better tap targets
   ============================================================ */
@media (pointer: coarse) {
  .btn { min-height: 44px; }
  .btn-sm { min-height: 38px; }
  .form-control { min-height: 44px; }
  select.form-control { min-height: 44px; }
  .sidebar-nav a { min-height: 48px; }
  table td, table th { padding: 12px; }
  .tab, .fin-tab, .settings-tab, .esc-tab { min-height: 40px; }
}

/* ============================================================
   iOS SAFE AREA
   ============================================================ */
@supports (padding: env(safe-area-inset-bottom)) {
  .sidebar { padding-bottom: env(safe-area-inset-bottom); }
  .main-content { padding-bottom: calc(24px + env(safe-area-inset-bottom)); }
  .modal { padding-bottom: env(safe-area-inset-bottom); }
}

/* Touch-friendly tap targets */
@media (pointer: coarse) {
  .btn {
    min-height: 44px;
    min-width: 44px;
  }
  .btn-sm {
    min-height: 38px;
    min-width: 38px;
  }
  .sidebar-nav a {
    padding: 14px 24px;
  }
  .tab, .fin-tab, .settings-tab {
    padding: 14px 20px;
  }
  table td, table th {
    padding: 14px 16px;
  }
}

/* ============================================================
   UTILITY CLASSES
   ============================================================ */
.text-center { text-align: center; }
.text-gold { color: var(--gold); }
.text-teal { color: var(--teal); }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--gray-500); }
.text-sm { font-size: 0.8rem; }
.text-lg { font-size: 1.25rem; }
.font-bold { font-weight: 700; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.gap-4 { gap: 16px; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.hidden { display: none; }
.w-full { width: 100%; }

/* LTR content in RTL context (phone numbers, emails, URLs) */
.ltr-content, [dir="ltr"], .phone-num, .email-text, .iban-text {
  unicode-bidi: embed;
  direction: ltr;
  text-align: left;
}
.rtl .ltr-content, .rtl .phone-num, .rtl .email-text, .rtl .iban-text {
  text-align: right;
}
input[type="tel"], input[type="email"], input[type="url"] {
  direction: ltr;
  text-align: left;
}
.rtl input[type="tel"], .rtl input[type="email"], .rtl input[type="url"] {
  text-align: right;
}

/* ============================================================
   UNIT TYPE BADGES (global)
   ============================================================ */
/* Keep unit descriptions on one line */
td .unit-type-badge + span,
td .unit-type-badge ~ * { white-space: nowrap; }

.unit-type-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-inline-end: 6px;
  vertical-align: middle;
  line-height: 1.4;
}
.unit-type-badge i { font-size: 0.65rem; }
.unit-type-badge.commercial { background: #dbeafe; color: #1e40af; }
.unit-type-badge.worker { background: #ccfbf1; color: #115e59; }
.unit-type-badge.residential { background: #fef3c7; color: #92400e; }

/* ============================================================
   DEMO MODE BANNER
   ============================================================ */
.demo-banner {
  background: #fef3c7;
  color: #92400e;
  text-align: center;
  padding: 10px 20px;
  font-size: 0.85rem;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  border-bottom: 2px solid #f59e0b;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.live-banner {
  background: #dcfce7;
  color: #166534;
  text-align: center;
  padding: 6px 20px;
  font-size: 0.8rem;
  font-weight: 600;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  border-bottom: 1px solid #86efac;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Both demo and live banners push content down */
body.demo-mode .main-header,
body.demo-mode .rtl .main-header {
  top: 40px;
}
body.demo-mode .main-content {
  padding-top: calc(var(--header-height) + 64px);
}
body.demo-mode .sidebar {
  top: 40px;
  height: calc(100vh - 40px);
}

/* Live mode has smaller banner */
body:not(.demo-mode) .main-header,
body:not(.demo-mode) .rtl .main-header {
  top: 32px;
}
body:not(.demo-mode) .main-content {
  padding-top: calc(var(--header-height) + 56px);
}
body:not(.demo-mode) .sidebar {
  top: 32px;
  height: calc(100vh - 32px);
}

@media (max-width: 480px) {
  .demo-banner, .live-banner {
    font-size: 0.65rem;
    padding: 3px 8px;
    gap: 4px;
    position: fixed;
    top: 0;
    height: 24px;
  }
  .demo-banner button, .live-banner button {
    font-size: 0.6rem;
    padding: 1px 6px;
  }
  body.demo-mode .main-header,
  body.demo-mode .rtl .main-header {
    top: 24px !important;
  }
  body.demo-mode .main-content {
    padding-top: 88px !important;
  }
  body.demo-mode .sidebar {
    top: 24px !important;
    height: calc(100vh - 24px) !important;
  }
  body:not(.demo-mode) .main-header,
  body:not(.demo-mode) .rtl .main-header {
    top: 24px !important;
  }
  body:not(.demo-mode) .main-content {
    padding-top: 88px !important;
  }
  body:not(.demo-mode) .sidebar {
    top: 24px !important;
    height: calc(100vh - 24px) !important;
  }
}

/* ============================================================
   PHOTO SYSTEM
   ============================================================ */

/* Photo Grid */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.photo-card { position: relative; border-radius: var(--border-radius-sm); overflow: hidden; background: var(--gray-100); border: 1px solid var(--gray-200); transition: var(--transition); }
.photo-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.photo-card img { width: 100%; height: 180px; object-fit: cover; cursor: pointer; display: block; }
.photo-card .photo-caption { padding: 8px 12px; font-size: 0.85rem; color: var(--gray-700); border-top: 1px solid var(--gray-200); }
.photo-card .photo-actions { position: absolute; top: 8px; right: 8px; display: flex; gap: 4px; opacity: 0; transition: opacity 0.2s; }
.photo-card:hover .photo-actions { opacity: 1; }
.photo-card .photo-actions button { background: rgba(0,0,0,0.6); color: white; border: none; border-radius: 50%; width: 28px; height: 28px; cursor: pointer; font-size: 0.75rem; display: flex; align-items: center; justify-content: center; }
.photo-card .photo-actions button:hover { background: rgba(0,0,0,0.85); }
.photo-card .cover-star { position: absolute; top: 8px; left: 8px; color: #f59e0b; font-size: 1.2rem; text-shadow: 0 1px 3px rgba(0,0,0,0.5); }

/* Photo type badges */
.photo-type-badge { font-size: 0.7rem; padding: 2px 8px; border-radius: 4px; font-weight: 600; display: inline-block; margin-top: 4px; }
.photo-type-issue { background: #fee2e2; color: #991b1b; }
.photo-type-before { background: #dbeafe; color: #1e40af; }
.photo-type-after { background: #dcfce7; color: #166534; }
.photo-type-evidence { background: #fef3c7; color: #92400e; }
.photo-type-general { background: var(--gray-100); color: var(--gray-700); }

/* Lightbox */
.lightbox-overlay { position: fixed; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0.92); z-index: 10000; display: flex; align-items: center; justify-content: center; flex-direction: column; }
.lightbox-overlay img { max-width: 90%; max-height: 80vh; object-fit: contain; border-radius: var(--border-radius-sm); }
.lightbox-overlay .lightbox-close { position: absolute; top: 20px; right: 20px; color: white; font-size: 2rem; cursor: pointer; background: none; border: none; z-index: 10001; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; }
.lightbox-overlay .lightbox-close:hover { color: var(--gray-300); }
.lightbox-overlay .lightbox-caption { color: white; text-align: center; margin-top: 16px; font-size: 1rem; max-width: 80%; }

/* Property thumbnail in list */
.property-thumb { width: 60px; height: 60px; border-radius: var(--border-radius-sm); object-fit: cover; flex-shrink: 0; }
.property-thumb-placeholder { width: 60px; height: 60px; border-radius: var(--border-radius-sm); background: var(--gray-200); display: flex; align-items: center; justify-content: center; color: var(--gray-400); font-size: 1.5rem; flex-shrink: 0; }

/* Upload preview */
.upload-preview { max-width: 100%; max-height: 200px; border-radius: var(--border-radius-sm); margin: 12px 0; object-fit: contain; display: block; }

/* Photo count badge in inspections table */
.photo-count-badge { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; color: var(--gray-500); }

/* Empty photo state */
.photo-empty-state { text-align: center; padding: 40px 20px; color: var(--gray-400); }
.photo-empty-state i { font-size: 3rem; margin-bottom: 12px; display: block; }
.photo-empty-state p { font-size: 0.9rem; }

/* Responsive */
@media (max-width: 768px) { .photo-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px) { .photo-grid { grid-template-columns: 1fr; } .photo-card img { height: 200px; } }

/* ============================================================
   NOTIFICATION BELL & DROPDOWN
   ============================================================ */
.notif-wrapper { position: relative; }
.btn-notif {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  font-size: 1.1rem;
  color: var(--gray-600);
  position: relative;
}
.btn-notif:hover { color: var(--navy); }
.notif-badge {
  position: absolute;
  top: 0;
  right: 0;
  background: #dc2626;
  color: white;
  font-size: 0.6rem;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 99px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}
.notif-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  width: 360px;
  max-height: 480px;
  background: var(--white, #fff);
  border: 1px solid var(--gray-200, #e2e8f0);
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-xl);
  z-index: 500;
  overflow: hidden;
}
[dir="rtl"] .notif-dropdown { left: 0; right: auto; }
.notif-dropdown.active { display: block; }
.notif-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--gray-200, #e2e8f0);
}
.notif-header strong { font-size: 0.9rem; color: var(--navy); }
.notif-header button {
  background: none;
  border: none;
  color: var(--teal-dark, #0d9488);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: inherit;
}
.notif-header button:hover { text-decoration: underline; }
.notif-list {
  overflow-y: auto;
  max-height: 400px;
}
.notif-item {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid var(--gray-100, #f1f5f9);
  transition: background 0.15s;
}
.notif-item:hover { background: var(--gray-100, #f8fafc); }
.notif-item.unread { background: #eff6ff; }
.notif-icon { font-size: 1rem; padding-top: 2px; flex-shrink: 0; }
.notif-content { flex: 1; min-width: 0; }
.notif-title { font-size: 0.85rem; font-weight: 600; margin-bottom: 2px; color: var(--gray-800); }
.notif-body { font-size: 0.8rem; color: var(--gray-500); line-height: 1.4; }
.notif-time { font-size: 0.7rem; color: var(--gray-400); margin-top: 4px; }
.notif-empty { padding: 24px; text-align: center; color: var(--gray-400); font-size: 0.85rem; }

/* Dark mode — notifications */
[data-theme="dark"] .btn-notif { color: #94a3b8; }
[data-theme="dark"] .btn-notif:hover { color: #e2e8f0; }
[data-theme="dark"] .notif-dropdown { background: #132e52; border-color: #1a3a5c; }
[data-theme="dark"] .notif-header { border-bottom-color: #1a3a5c; }
[data-theme="dark"] .notif-header strong { color: #e2e8f0; }
[data-theme="dark"] .notif-item { border-bottom-color: #0e2240; }
[data-theme="dark"] .notif-item:hover { background: #0e2240; }
[data-theme="dark"] .notif-item.unread { background: #0a2a4a; }
[data-theme="dark"] .notif-title { color: #e2e8f0; }
[data-theme="dark"] .notif-body { color: #94a3b8; }
[data-theme="dark"] .notif-empty { color: #64748b; }

/* Mobile — notifications */
@media (max-width: 480px) {
  .notif-dropdown {
    width: calc(100vw - 24px);
    max-width: 340px;
    position: fixed;
    top: 52px;
    left: 12px;
    right: 12px;
  }
  [dir="rtl"] .notif-dropdown { left: 12px; right: 12px; }
}

/* ============================================================
   INSPECTION CHECKLIST
   ============================================================ */
.checklist-section {
  margin-top: 16px;
  border: 1px solid var(--border-main);
  border-radius: var(--border-radius-sm);
  background: var(--bg-card);
}
.checklist-section .checklist-header {
  padding: 12px 16px;
  font-weight: 600;
  font-size: 0.9rem;
  border-bottom: 1px solid var(--border-main);
  background: var(--bg-table-stripe);
  border-radius: var(--border-radius-sm) var(--border-radius-sm) 0 0;
}
.checklist-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border-light);
}
.checklist-item:last-child { border-bottom: none; }
.checklist-item label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  flex-shrink: 0;
}
.checklist-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--success);
  cursor: pointer;
}
.checklist-item input[type="text"] {
  flex: 1;
  min-width: 0;
}
@media (max-width: 480px) {
  .checklist-item {
    flex-direction: column;
    gap: 6px;
  }
  .checklist-item label {
    min-width: auto;
  }
  .checklist-item input[type="text"] {
    width: 100%;
  }
}

/* Camera capture button */
.camera-capture-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  border: 2px dashed var(--border-main);
  border-radius: var(--border-radius-sm);
  background: var(--bg-table-stripe);
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
  color: var(--text-secondary);
  font-size: 0.85rem;
  width: 100%;
}
.camera-capture-btn:hover {
  border-color: var(--navy);
  color: var(--navy);
  background: rgba(0,52,104,0.05);
}
.camera-capture-btn i {
  font-size: 2rem;
}
.camera-capture-btn input[type="file"] {
  display: none;
}
[data-theme="dark"] .camera-capture-btn {
  border-color: #1a3a5c;
  background: #0e2240;
  color: #94a3b8;
}
[data-theme="dark"] .camera-capture-btn:hover {
  border-color: #60a5fa;
  color: #60a5fa;
  background: rgba(96,165,250,0.08);
}

/* Checklist display in detail modal */
.checklist-display-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.85rem;
}
.checklist-display-item .check-icon {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  flex-shrink: 0;
}
.checklist-display-item .check-pass {
  background: var(--success);
  color: #fff;
}
.checklist-display-item .check-fail {
  background: var(--gray-300);
  color: var(--gray-500);
}
.checklist-display-item .check-notes {
  color: var(--text-secondary);
  font-size: 0.8rem;
  margin-inline-start: 4px;
}

/* ============================================================
   GLOBAL SEARCH BAR
   ============================================================ */
.global-search-wrapper {
  position: relative;
  margin-bottom: 20px;
}
.global-search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}
.global-search-input-wrapper .search-icon {
  position: absolute;
  right: 16px;
  color: var(--gray-400);
  font-size: 1rem;
  pointer-events: none;
  z-index: 1;
}
.ltr .global-search-input-wrapper .search-icon {
  right: auto;
  left: 16px;
}
.global-search-input {
  width: 100%;
  padding: 14px 48px 14px 16px;
  font-size: 0.95rem;
  border: 2px solid var(--gray-200);
  border-radius: 12px;
  background: var(--white);
  color: var(--gray-800);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
  font-family: inherit;
}
.ltr .global-search-input {
  padding: 14px 16px 14px 48px;
}
.global-search-input::placeholder {
  color: var(--gray-400);
}
.global-search-input:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(0, 52, 104, 0.08);
}
[data-theme="dark"] .global-search-input {
  background: var(--card-bg, #1e293b);
  border-color: var(--gray-600, #475569);
  color: var(--gray-100, #f1f5f9);
}
[data-theme="dark"] .global-search-input:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(0, 212, 170, 0.1);
}
/* Search results dropdown */
.global-search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
  z-index: 200;
  max-height: 420px;
  overflow-y: auto;
  display: none;
}
.global-search-results.active {
  display: block;
}
[data-theme="dark"] .global-search-results {
  background: var(--card-bg, #1e293b);
  border-color: var(--gray-600, #475569);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}
.search-results-group {
  padding: 8px 0;
  border-bottom: 1px solid var(--gray-100);
}
.search-results-group:last-child {
  border-bottom: none;
}
[data-theme="dark"] .search-results-group {
  border-bottom-color: var(--gray-600, #475569);
}
.search-results-group-title {
  padding: 6px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  display: flex;
  align-items: center;
  gap: 6px;
}
.search-results-group-title i {
  font-size: 0.7rem;
}
.search-result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  color: inherit;
}
.search-result-item:hover {
  background: var(--gray-50, #f9fafb);
}
[data-theme="dark"] .search-result-item:hover {
  background: rgba(255, 255, 255, 0.05);
}
.search-result-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
}
.search-result-icon.properties { background: #dbeafe; color: #1e40af; }
.search-result-icon.units { background: #d1fae5; color: #065f46; }
.search-result-icon.tenants { background: #fef3c7; color: #92400e; }
.search-result-icon.leases { background: #ede9fe; color: #5b21b6; }
.search-result-icon.maintenance { background: #ffedd5; color: #9a3412; }
.search-result-icon.complaints { background: #fee2e2; color: #991b1b; }
.search-result-icon.sales_listings { background: #d1fae5; color: #065f46; }
.search-result-icon.sales_transactions { background: #dbeafe; color: #1e40af; }

[data-theme="dark"] .search-result-icon.properties { background: rgba(59,130,246,0.15); color: #93c5fd; }
[data-theme="dark"] .search-result-icon.units { background: rgba(16,185,129,0.15); color: #6ee7b7; }
[data-theme="dark"] .search-result-icon.tenants { background: rgba(245,158,11,0.15); color: #fcd34d; }
[data-theme="dark"] .search-result-icon.leases { background: rgba(139,92,246,0.15); color: #c4b5fd; }
[data-theme="dark"] .search-result-icon.maintenance { background: rgba(249,115,22,0.15); color: #fdba74; }
[data-theme="dark"] .search-result-icon.complaints { background: rgba(239,68,68,0.15); color: #fca5a5; }
[data-theme="dark"] .search-result-icon.sales_listings { background: rgba(16,185,129,0.15); color: #6ee7b7; }
[data-theme="dark"] .search-result-icon.sales_transactions { background: rgba(59,130,246,0.15); color: #93c5fd; }

.search-result-text {
  flex: 1;
  min-width: 0;
}
.search-result-name {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--gray-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
[data-theme="dark"] .search-result-name {
  color: var(--gray-100, #f1f5f9);
}
.search-result-subtitle {
  font-size: 0.78rem;
  color: var(--gray-500);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.search-no-results {
  padding: 24px 16px;
  text-align: center;
  color: var(--gray-400);
  font-size: 0.9rem;
}
.search-no-results i {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 8px;
  opacity: 0.5;
}
@media (max-width: 768px) {
  .global-search-input {
    padding: 12px 44px 12px 14px;
    font-size: 0.88rem;
  }
  .ltr .global-search-input {
    padding: 12px 14px 12px 44px;
  }
  .global-search-results {
    max-height: 350px;
  }
}

/* ============================================================
   DARK MODE — COMPREHENSIVE FIXES (all new features)
   ============================================================ */

/* --- 1. Mode Selection Popup (shell.js inline overrides) --- */
[data-theme="dark"] #modeSelectorOverlay > div {
  background: #132e52 !important;
  box-shadow: 0 25px 60px rgba(0,0,0,0.6) !important;
}
[data-theme="dark"] #modeSelectorOverlay h2 {
  color: #f1f5f9 !important;
}
[data-theme="dark"] #modeSelectorOverlay p {
  color: #94a3b8 !important;
}
[data-theme="dark"] #modeSelectorOverlay button[id^="modeBtn_"] {
  background: #0e2240 !important;
  border-color: #1a3a5c !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] #modeSelectorOverlay button[id^="modeBtn_"] div[style*="font-weight:700"] {
  color: #e2e8f0 !important;
}
[data-theme="dark"] #modeSelectorOverlay button[id^="modeBtn_"] div[style*="color:var(--gray-500"],
[data-theme="dark"] #modeSelectorOverlay button[id^="modeBtn_"] div[style*="color:#0d9488"] {
  color: #94a3b8 !important;
}
[data-theme="dark"] #modeSelectorOverlay button[id^="modeBtn_"]:hover {
  border-color: #60a5fa !important;
  box-shadow: 0 8px 24px rgba(96,165,250,0.15) !important;
  background: #1a3a5c !important;
}

/* --- 2. Mode Switcher in Sidebar (already on dark bg, just needs better contrast) --- */
[data-theme="dark"] .sidebar div[style*="background:rgba(255,255,255,0.06)"] {
  background: rgba(255,255,255,0.08) !important;
}

/* --- 3. Mode Badge in Header (inline styles need override) --- */
[data-theme="dark"] .header-left > span[style*="background:rgba(0,52,104,0.1)"] {
  background: rgba(96,165,250,0.15) !important;
  color: #93c5fd !important;
  border-color: rgba(96,165,250,0.3) !important;
}
[data-theme="dark"] .header-left > span[style*="background:rgba(13,148,136,0.1)"] {
  background: rgba(94,234,212,0.15) !important;
  color: #5eead4 !important;
  border-color: rgba(94,234,212,0.3) !important;
}

/* --- 4. Global Search Bar — ensure dark mode works properly --- */
[data-theme="dark"] .global-search-input {
  background: #0e2240 !important;
  border-color: #1a3a5c !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .global-search-input::placeholder {
  color: #64748b !important;
}
[data-theme="dark"] .global-search-input:focus {
  border-color: #60a5fa !important;
  box-shadow: 0 0 0 3px rgba(96,165,250,0.15) !important;
}
[data-theme="dark"] .global-search-input-wrapper .search-icon {
  color: #64748b !important;
}
[data-theme="dark"] .global-search-results {
  background: #132e52 !important;
  border-color: #1a3a5c !important;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5) !important;
}
[data-theme="dark"] .search-results-group {
  border-bottom-color: #1a3a5c !important;
}
[data-theme="dark"] .search-results-group-title {
  color: #64748b !important;
}
[data-theme="dark"] .search-result-item:hover {
  background: #0e2240 !important;
}
[data-theme="dark"] .search-result-name {
  color: #e2e8f0 !important;
}
[data-theme="dark"] .search-result-subtitle {
  color: #94a3b8 !important;
}
[data-theme="dark"] .search-no-results {
  color: #64748b !important;
}

/* --- 5. Sales Dashboard KPIs (same as rental KPIs, should work via .kpi-card rules) --- */
/* KPI cards generated by JS — ensure they pick up dark colors */
[data-theme="dark"] .kpi-card,
[data-theme="dark"] #salesKPIs .kpi-card,
[data-theme="dark"] #tenantKPIs .kpi-card,
[data-theme="dark"] #inspKPIs .kpi-card,
[data-theme="dark"] #finKPIs .kpi-card {
  background: #132e52 !important;
  border-color: #1a3a5c !important;
}
[data-theme="dark"] .kpi-card .kpi-value {
  color: #e2d5c0 !important;
}
[data-theme="dark"] .kpi-card .kpi-label {
  color: #94a3b8 !important;
}
[data-theme="dark"] .kpi-card .kpi-sub {
  color: #64748b !important;
}

/* --- 6. Sales Finance Tabs --- */
[data-theme="dark"] .fin-tabs {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .fin-tab {
  color: #94a3b8;
}
[data-theme="dark"] .fin-tab:hover {
  color: #e2e8f0;
}
[data-theme="dark"] .fin-tab.active {
  color: #5eead4;
  border-bottom-color: #5eead4;
}
[data-theme="dark"] .pl-row {
  border-bottom-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .pl-row.header {
  border-bottom-color: #475569;
}
[data-theme="dark"] .pl-row.total {
  border-top-color: #1a3a5c;
}
[data-theme="dark"] .pl-row .amount {
  color: #e2e8f0;
}
[data-theme="dark"] .break-even-meter {
  background: #1a3a5c;
}
[data-theme="dark"] .break-even-meter .target-label {
  color: #93c5fd;
}
[data-theme="dark"] .break-even-meter .end-label {
  color: #94a3b8;
}

/* --- 7. Sales Tabs (sales.html) --- */
[data-theme="dark"] .sales-tabs {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .sales-tab {
  color: #94a3b8;
}
[data-theme="dark"] .sales-tab:hover {
  color: #e2e8f0;
}
[data-theme="dark"] .sales-tab.active {
  color: #e2d5c0;
  border-bottom-color: #e2d5c0;
}

/* Sales listing cards */
[data-theme="dark"] .listing-card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .listing-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .listing-card-title {
  color: #f1f5f9;
}
[data-theme="dark"] .listing-card-info {
  color: #94a3b8;
}
[data-theme="dark"] .listing-card-price {
  color: #e2d5c0;
}
[data-theme="dark"] .listing-card-footer {
  border-top-color: #1a3a5c;
}

/* Sales type badges in dark mode */
[data-theme="dark"] .listing-type-land { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .listing-type-property { background: rgba(245,158,11,0.2); color: #fcd34d; }
[data-theme="dark"] .listing-type-building { background: rgba(139,92,246,0.2); color: #c4b5fd; }

/* Sales status badges in dark mode */
[data-theme="dark"] .badge-available { background: rgba(16,185,129,0.2); color: #6ee7b7; }
[data-theme="dark"] .badge-reserved { background: rgba(245,158,11,0.2); color: #fcd34d; }
[data-theme="dark"] .badge-sold { background: rgba(59,130,246,0.2); color: #93c5fd; }
[data-theme="dark"] .badge-withdrawn { background: rgba(100,116,139,0.2); color: #94a3b8; }
[data-theme="dark"] .badge-pending { background: rgba(245,158,11,0.2); color: #fcd34d; }
[data-theme="dark"] .badge-completed { background: rgba(16,185,129,0.2); color: #6ee7b7; }
[data-theme="dark"] .badge-cancelled { background: rgba(239,68,68,0.2); color: #fca5a5; }
[data-theme="dark"] .badge-comm-paid { background: rgba(16,185,129,0.2); color: #6ee7b7; }
[data-theme="dark"] .badge-comm-unpaid { background: rgba(239,68,68,0.2); color: #fca5a5; }

/* Marketer cards */
[data-theme="dark"] .marketer-card {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .marketer-stat {
  background: #0e2240;
}
[data-theme="dark"] .marketer-stat-value {
  color: #e2d5c0;
}
[data-theme="dark"] .marketer-stat-label {
  color: #94a3b8;
}

/* Photo gallery in sales */
[data-theme="dark"] .photo-gallery img {
  border-color: #1a3a5c;
}
[data-theme="dark"] .photo-gallery img:hover {
  border-color: #60a5fa;
}
[data-theme="dark"] .maps-preview {
  border-color: #1a3a5c;
}
[data-theme="dark"] .deed-viewer {
  border-color: #1a3a5c;
}

/* OCR extraction banners */
[data-theme="dark"] .extraction-banner.loading { background: rgba(59,130,246,0.15); color: #93c5fd; border-color: rgba(59,130,246,0.3); }
[data-theme="dark"] .extraction-banner.success { background: rgba(16,185,129,0.15); color: #6ee7b7; border-color: rgba(16,185,129,0.3); }
[data-theme="dark"] .extraction-banner.failed { background: rgba(249,115,22,0.15); color: #fdba74; border-color: rgba(249,115,22,0.3); }

/* Auto-filled field highlight */
[data-theme="dark"] .auto-filled {
  background: rgba(245,158,11,0.15) !important;
  border-color: #d97706 !important;
}

/* --- 8. Sales Clients Tabs (tenants.html sales mode) --- */
/* Uses same .sales-tabs classes — covered above */

/* --- 9. Chat Page --- */
/* Chat uses CSS vars extensively — just ensure the key areas work */
[data-theme="dark"] .chat-container {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .chat-sidebar {
  background: #0e2240;
  border-color: #1a3a5c;
}
[data-theme="dark"] .chat-sidebar-header {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .chat-sidebar-header h2 {
  color: #f1f5f9;
}
[data-theme="dark"] .chat-search input {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .chat-search input::placeholder {
  color: #64748b;
}
[data-theme="dark"] .conv-item {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .conv-item:hover {
  background: #1a3a5c;
}
[data-theme="dark"] .conv-item.active {
  background: #1a3a5c;
  border-inline-start-color: #60a5fa;
}
[data-theme="dark"] .conv-name {
  color: #e2e8f0;
}
[data-theme="dark"] .conv-preview {
  color: #94a3b8;
}
[data-theme="dark"] .conv-time {
  color: #64748b;
}
[data-theme="dark"] .conv-empty {
  color: #64748b;
}
[data-theme="dark"] .chat-main-header {
  background: #0e2240;
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .chat-partner-name {
  color: #f1f5f9;
}
[data-theme="dark"] .btn-chat-back {
  color: #e2e8f0;
}
[data-theme="dark"] .chat-messages {
  background: #0a1e3a;
}
[data-theme="dark"] .chat-date-divider::before,
[data-theme="dark"] .chat-date-divider::after {
  background: #1a3a5c;
}
[data-theme="dark"] .chat-date-divider span {
  color: #64748b;
  background: #0a1e3a;
}
[data-theme="dark"] .msg-bubble-wrapper.received .msg-bubble {
  background: #132e52;
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] .msg-time {
  color: #64748b;
}
[data-theme="dark"] .chat-empty-state {
  color: #64748b;
}
[data-theme="dark"] .chat-empty-state h3 {
  color: #94a3b8;
}
[data-theme="dark"] .chat-input-area {
  background: #0e2240;
  border-top-color: #1a3a5c;
}
[data-theme="dark"] .chat-input-area textarea {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .chat-input-area textarea::placeholder {
  color: #64748b;
}
[data-theme="dark"] .chat-input-area textarea:focus {
  border-color: #60a5fa;
}
[data-theme="dark"] .btn-send {
  background: #2563eb;
}
[data-theme="dark"] .btn-send:hover {
  background: #1d4ed8;
}

/* New chat modal */
[data-theme="dark"] .new-chat-content {
  background: #132e52;
}
[data-theme="dark"] .new-chat-header {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .new-chat-header h3 {
  color: #f1f5f9;
}
[data-theme="dark"] .new-chat-close {
  color: #94a3b8;
}
[data-theme="dark"] .new-chat-search input {
  background: #0e2240;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .new-chat-search input::placeholder {
  color: #64748b;
}

/* --- 10. Business Cards Page --- */
[data-theme="dark"] .bc-controls {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .bc-controls h3 {
  color: #f1f5f9;
}
[data-theme="dark"] .bc-controls h3 i {
  color: #93c5fd;
}
[data-theme="dark"] .bc-controls label {
  color: #94a3b8;
}
[data-theme="dark"] .bc-controls input,
[data-theme="dark"] .bc-controls select {
  background: #0e2240;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .bc-controls input::placeholder {
  color: #64748b;
}
[data-theme="dark"] .bc-controls input:focus,
[data-theme="dark"] .bc-controls select:focus {
  border-color: #60a5fa;
}

/* --- 11. Inspection Checklist --- */
[data-theme="dark"] .checklist-section {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .checklist-section .checklist-header {
  background: #0e2240;
  border-bottom-color: #1a3a5c;
  color: #f1f5f9;
}
[data-theme="dark"] .checklist-item {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .checklist-item label {
  color: #e2e8f0;
}
[data-theme="dark"] .checklist-item label span {
  color: #e2e8f0;
}
[data-theme="dark"] .checklist-item input[type="text"] {
  background: #0e2240;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .checklist-item input[type="text"]::placeholder {
  color: #64748b;
}
[data-theme="dark"] .checklist-display-item {
  color: #e2e8f0;
}
[data-theme="dark"] .checklist-display-item .check-fail {
  background: #475569;
  color: #94a3b8;
}
[data-theme="dark"] .checklist-display-item .check-notes {
  color: #94a3b8;
}

/* --- 12. Camera Capture Button (already covered above, adding hover override) --- */
/* Already has dark mode rules at line 2271 */

/* --- 13. 360 Panorama Page --- */
[data-theme="dark"] .pano-top-bar select {
  background: #0e2240;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .floor-tab {
  background: #132e52;
  border-color: #1a3a5c;
  color: #94a3b8;
}
[data-theme="dark"] .floor-tab.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}
[data-theme="dark"] .floor-tab:hover:not(.active) {
  background: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .floor-plan-view {
  background: #0e2240;
  border-color: #1a3a5c;
}
[data-theme="dark"] .floor-plan-dot {
  border-color: #1a3a5c;
}
[data-theme="dark"] .floor-plan-dot-tooltip {
  background: rgba(0,0,0,0.9);
}

/* Panorama upload area */
[data-theme="dark"] .pano-upload-area,
[data-theme="dark"] div[style*="border:2px dashed"] {
  border-color: #1a3a5c !important;
  background: #0e2240 !important;
  color: #94a3b8 !important;
}
[data-theme="dark"] .pano-upload-area:hover,
[data-theme="dark"] div[style*="border:2px dashed"]:hover {
  border-color: #60a5fa !important;
}

/* Panorama cards */
[data-theme="dark"] .pano-card,
[data-theme="dark"] .pano-item-card {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}

/* --- 14. Reports Page --- */
[data-theme="dark"] .report-controls label {
  color: #94a3b8;
}
[data-theme="dark"] .report-controls select {
  background: #0e2240;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .report-controls select:focus {
  border-color: #60a5fa;
}
[data-theme="dark"] .btn-generate {
  background: #2563eb;
  color: #fff;
}
[data-theme="dark"] .btn-generate:hover {
  background: #1d4ed8;
}
[data-theme="dark"] .progress-bar-wrapper {
  background: #1a3a5c;
}

/* --- 15. Messages Page --- */
[data-theme="dark"] .msg-card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .msg-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}
[data-theme="dark"] .msg-card.unread {
  background: rgba(59, 130, 246, 0.08);
  border-inline-start-color: #60a5fa;
}
[data-theme="dark"] .msg-name {
  color: #e2e8f0;
}
[data-theme="dark"] .msg-email {
  color: #64748b;
}
[data-theme="dark"] .msg-date {
  color: #64748b;
}
[data-theme="dark"] .msg-preview {
  color: #94a3b8;
}
[data-theme="dark"] .msg-subject {
  color: #e2e8f0;
}
[data-theme="dark"] .msg-body {
  color: #94a3b8;
}
[data-theme="dark"] .msg-tags span,
[data-theme="dark"] .msg-tag {
  background: rgba(100,116,139,0.2);
  color: #94a3b8;
}

/* --- 16. Audit Log --- */
/* Most audit styles already have dark mode, but add detail pills and extra entries */
[data-theme="dark"] .audit-timeline::before {
  background: #1a3a5c;
}
[data-theme="dark"] .timeline-entry {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .timeline-entry::before {
  background: #132e52;
  border-color: #475569;
}
[data-theme="dark"] .timeline-header {
  color: #e2e8f0;
}
[data-theme="dark"] .timeline-time {
  color: #64748b;
}
[data-theme="dark"] .timeline-details {
  background: #0e2240;
  color: #94a3b8;
  border-color: #1a3a5c;
}
/* Inline style detail pills */
[data-theme="dark"] .timeline-details span[style*="background:#f1f5f9"],
[data-theme="dark"] .timeline-details span[style*="background: #f1f5f9"],
[data-theme="dark"] .timeline-details span[style*="background:#F1F5F9"] {
  background: #233556 !important;
  color: #e2e8f0 !important;
}
[data-theme="dark"] .audit-stat-card {
  background: #132e52;
  border-color: #1a3a5c;
}
[data-theme="dark"] .audit-stat-card .stat-value {
  color: #e2d5c0;
}
[data-theme="dark"] .audit-stat-card .stat-label {
  color: #94a3b8;
}
[data-theme="dark"] .audit-stat-card .stat-sub {
  color: #64748b;
}
[data-theme="dark"] .audit-filters input,
[data-theme="dark"] .audit-filters select {
  background: #0e2240;
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] .audit-filters input::placeholder {
  color: #64748b;
}
[data-theme="dark"] .audit-filters label {
  color: #94a3b8;
}
[data-theme="dark"] .audit-filters input:focus,
[data-theme="dark"] .audit-filters select:focus {
  border-color: #60a5fa;
}

/* --- 17. Settings Page --- */
[data-theme="dark"] .settings-tabs {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .settings-tab {
  color: #94a3b8;
}
[data-theme="dark"] .settings-tab:hover {
  color: #e2e8f0;
}
[data-theme="dark"] .settings-tab.active {
  color: #5eead4;
  border-bottom-color: #5eead4;
}
[data-theme="dark"] .role-matrix th {
  background: #0a1e3a;
  color: #e2e8f0;
}
[data-theme="dark"] .role-matrix td {
  color: #e2e8f0;
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .role-matrix tr:hover td {
  background: #0e2240;
}
[data-theme="dark"] .role-matrix .cross {
  color: #475569;
}

/* Profile card area */
[data-theme="dark"] .profile-card h3,
[data-theme="dark"] #profileName {
  color: #f1f5f9 !important;
}
[data-theme="dark"] .profile-card span[style*="color:var(--gray-500)"],
[data-theme="dark"] .profile-card .text-muted,
[data-theme="dark"] #profileRole {
  color: #94a3b8 !important;
}

/* --- 18. Notifications dropdown on dark mode --- */
/* Already covered at line 2158+ */

/* --- 19. Demo/Live banner buttons in dark mode --- */
[data-theme="dark"] .demo-banner button {
  background: #1a2a10 !important;
  color: #fbbf24 !important;
  border-color: #2d4a1a !important;
}
[data-theme="dark"] .live-banner button {
  background: none !important;
  color: #86efac !important;
  border-color: #86efac !important;
}

/* --- 20. Generic inline style overrides for dark mode --- */
/* Override hardcoded backgrounds that many pages use inline */
[data-theme="dark"] [style*="background:#F5F0E8"],
[data-theme="dark"] [style*="background: #F5F0E8"],
[data-theme="dark"] [style*="background:#f5f0e8"],
[data-theme="dark"] [style*="background: #f5f0e8"] {
  background: #0e2240 !important;
}
[data-theme="dark"] [style*="background:#fff"],
[data-theme="dark"] [style*="background: #fff"],
[data-theme="dark"] [style*="background:white"],
[data-theme="dark"] [style*="background: white"] {
  background: #132e52 !important;
}
[data-theme="dark"] [style*="color:#1B2A4A"],
[data-theme="dark"] [style*="color: #1B2A4A"],
[data-theme="dark"] [style*="color:#003468"],
[data-theme="dark"] [style*="color: #003468"] {
  color: #e2e8f0 !important;
}

/* --- 21. Modal close button dark mode --- */
[data-theme="dark"] .modal-close {
  background: #1a3a5c;
  color: #94a3b8;
}
[data-theme="dark"] .modal-close:hover {
  background: #233556;
  color: #e2e8f0;
}

/* --- 22. Property detail tab styles in dark mode --- */
[data-theme="dark"] .tabs {
  border-bottom-color: #1a3a5c;
}
[data-theme="dark"] .tab {
  color: #94a3b8;
}
[data-theme="dark"] .tab:hover {
  color: #e2e8f0;
}
[data-theme="dark"] .tab.active {
  color: #5eead4;
  border-bottom-color: #5eead4;
}

/* --- 23. Compliance items in dark mode --- */
[data-theme="dark"] .compliance-item {
  background: #132e52;
  border-color: #1a3a5c;
  color: #e2e8f0;
}
[data-theme="dark"] .compliance-item .check-label {
  color: #e2e8f0;
}

/* --- 24. Select dropdowns inside page styles (not just .form-control) --- */
[data-theme="dark"] select {
  background-color: #0e2240;
  color: #e2e8f0;
  border-color: #1a3a5c;
}
[data-theme="dark"] select option {
  background: #0e2240;
  color: #e2e8f0;
}

/* --- 25. General text and paragraph overrides --- */
[data-theme="dark"] p {
  color: #e2e8f0;
}
[data-theme="dark"] span {
  color: inherit;
}
[data-theme="dark"] .text-muted {
  color: #94a3b8 !important;
}
[data-theme="dark"] .text-center {
  color: inherit;
}
[data-theme="dark"] label {
  color: #94a3b8;
}
[data-theme="dark"] small {
  color: #94a3b8;
}

/* --- 26. Inline style overrides for mode selector card backgrounds --- */
[data-theme="dark"] div[style*="background:var(--white"] {
  background: #132e52 !important;
}
[data-theme="dark"] div[style*="background: var(--white"] {
  background: #132e52 !important;
}

/* --- 27. Sidebar overlay on mobile --- */
[data-theme="dark"] .sidebar-overlay {
  background: rgba(0,0,0,0.6);
}

/* --- 28. Mobile card header button icon colors in dark mode --- */
[data-theme="dark"] .btn-mobile-menu {
  color: #e2e8f0 !important;
}
[data-theme="dark"] .btn-mobile-menu i {
  color: #e2e8f0 !important;
}

/* ============================================================
   LARGE READABLE NUMBERS — across entire app
   ============================================================ */

/* KPI card values — large and bold */
.kpi-card .kpi-value { font-size: 2rem !important; font-weight: 700 !important; }
.stat-value, .stat-number { font-size: 1.8rem !important; font-weight: 700 !important; }

/* Table numbers — amounts, counts, IDs */
table td { font-size: 0.9rem; }

/* Badge numbers — counts on badges */
.badge { font-size: 0.8rem !important; font-weight: 600 !important; min-width: 22px; }

/* Finance amounts */
.riyal-symbol + span, .amount, .price { font-size: 1rem !important; font-weight: 600 !important; }

/* Phone numbers */
.ltr-text { font-size: 0.9rem !important; }

/* Audit stat cards */
.audit-stat-card .stat-value { font-size: 1.8rem !important; }

/* Dashboard bottom cards — overdue amounts, maintenance counts */
.card-body strong { font-size: 0.95rem; }

/* Mobile — slightly smaller but still readable */
@media (max-width: 480px) {
  .kpi-card .kpi-value { font-size: 1.5rem !important; }
  .stat-value, .stat-number { font-size: 1.4rem !important; }
  .audit-stat-card .stat-value { font-size: 1.4rem !important; }
}
