/* ==========================================================================
   V4 Property Search — Design System
   Trust Teal (default) | Data Blue | Navy Pro | Classic Purple
   Typography: Cinzel (headings) + Josefin Sans (body)
   ========================================================================== */

/* --- Reset & Base -------------------------------------------------------- */

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

/* === THEME: Trust Teal (DEFAULT — Real Estate Authority) === */
:root,
[data-theme="teal"] {
  /* Core palette */
  --color-primary: #0F766E;
  --color-secondary: #14B8A6;
  --color-accent: #0369A1;
  --color-background: #F0FDFA;
  --color-foreground: #134E4A;
  --color-card: #FFFFFF;
  --color-muted: #E8F0F3;
  --color-border: #99F6E4;
  --color-destructive: #DC2626;
  --color-ring: #0F766E;

  /* Semantic mapping */
  --accent-50: #F0FDFA;
  --accent-100: #CCFBF1;
  --accent-200: #99F6E4;
  --accent-500: #14B8A6;
  --accent-600: #0F766E;
  --accent-700: #0D6B63;
  --accent-hover: #0D6B63;

  --bg-body: #F0FDFA;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-surface: #E8F0F3;
  --bg-input: #FFFFFF;

  --text-primary: #134E4A;
  --text-secondary: #3B6B67;
  --text-muted: #64748B;
  --text-on-accent: #FFFFFF;

  --border-color: #99F6E4;
  --border-subtle: #CCFBF1;

  --sidebar-active-bg: #CCFBF1;
  --sidebar-active-text: #0F766E;
  --sidebar-border: #99F6E4;
  --header-border: #99F6E4;

  --table-stripe: #F0FDFA;
  --table-hover: #CCFBF1;

  --shadow-card: 0 1px 3px rgba(15, 118, 110, 0.08), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 2px rgba(15, 118, 110, 0.06);
  --shadow-md: 0 4px 12px rgba(15, 118, 110, 0.1), 0 2px 4px rgba(0, 0, 0, 0.04);
  --shadow-lg: 0 10px 30px rgba(15, 118, 110, 0.12), 0 4px 8px rgba(0, 0, 0, 0.06);

  /* Color scale aliases */
  --purple-50: #F0FDFA;
  --purple-100: #CCFBF1;
  --purple-200: #99F6E4;
  --purple-300: #5EEAD4;
  --purple-400: #2DD4BF;
  --purple-500: #14B8A6;
  --purple-600: #0F766E;
  --purple-700: #0D6B63;
  --purple-800: #115E59;
  --purple-900: #042F2E;

  --gray-50: #F0FDFA;
  --gray-100: #E8F0F3;
  --gray-200: #99F6E4;
  --gray-300: #5EEAD4;
  --gray-400: #64748B;
  --gray-500: #475569;
  --gray-600: #334155;
  --gray-700: #1E293B;
  --gray-800: #134E4A;
  --gray-900: #042F2E;

  --green-500: #22c55e;
  --green-600: #16a34a;
  --red-500: #ef4444;
  --red-600: #DC2626;
  --blue-500: #3b82f6;
  --blue-600: #0369A1;
  --amber-500: #f59e0b;

  /* Layout tokens */
  --sidebar-collapsed: 72px;
  --sidebar-expanded: 240px;
  --header-height: 56px;
  --radius: 8px;
  --radius-lg: 10px;
  --radius-xl: 12px;
  --transition: 200ms ease;

  /* Typography */
  --font-heading: "Cinzel", "Georgia", serif;
  --font-body: "Josefin Sans", "Segoe UI", system-ui, -apple-system, sans-serif;
}

/* === THEME: Data Blue (DARK — Analytics Dashboard) === */
[data-theme="blue"] {
  --color-primary: #3B82F6;
  --color-secondary: #60A5FA;
  --color-accent: #F59E0B;
  --color-background: #0B1120;
  --color-foreground: #E2E8F0;
  --color-card: #131B2E;
  --color-muted: #1E293B;
  --color-border: #1E3050;
  --color-destructive: #EF4444;
  --color-ring: #3B82F6;

  --accent-50: rgba(59,130,246,0.08);
  --accent-100: rgba(59,130,246,0.15);
  --accent-200: rgba(59,130,246,0.25);
  --accent-500: #60A5FA;
  --accent-600: #3B82F6;
  --accent-700: #93BBFD;
  --accent-hover: #93BBFD;

  --bg-body: #0B1120;
  --bg-sidebar: #070D1A;
  --bg-header: #0E1629;
  --bg-card: #131B2E;
  --bg-surface: #1A2340;
  --bg-input: #1A2340;

  --text-primary: #E2E8F0;
  --text-secondary: #94A3B8;
  --text-muted: #64748B;
  --text-on-accent: #FFFFFF;

  --border-color: #1E3050;
  --border-subtle: rgba(59,130,246,0.1);
  --sidebar-active-bg: rgba(59,130,246,0.15);
  --sidebar-active-text: #60A5FA;
  --sidebar-border: #1E293B;
  --header-border: #1E3050;
  --table-stripe: rgba(255,255,255,0.02);
  --table-hover: rgba(59,130,246,0.08);

  --shadow-card: 0 1px 3px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.5);

  --purple-50: #070D1A;
  --purple-100: #0E1629;
  --purple-200: #1E3050;
  --purple-300: #2A4070;
  --purple-400: #64748B;
  --purple-500: #94A3B8;
  --purple-600: #3B82F6;
  --purple-700: #60A5FA;
  --purple-800: #E2E8F0;
  --purple-900: #F8FAFC;

  --gray-50: #070D1A;
  --gray-100: #0E1629;
  --gray-200: #1E3050;
  --gray-300: #2A4070;
  --gray-400: #64748B;
  --gray-500: #94A3B8;
  --gray-600: #CBD5E1;
  --gray-700: #E2E8F0;
  --gray-800: #F1F5F9;
  --gray-900: #F8FAFC;
}

/* === THEME: Navy Pro (Dark sidebar + warm content — Enterprise) === */
[data-theme="navy"] {
  --color-primary: #0F172A;
  --color-secondary: #0EA5E9;
  --color-accent: #F97316;
  --color-background: #FAFAF9;
  --color-foreground: #0F172A;
  --color-card: #FFFFFF;
  --color-muted: #F5F5F4;
  --color-border: #D6D3D1;
  --color-destructive: #DC2626;
  --color-ring: #0EA5E9;

  --accent-50: #FFF7ED;
  --accent-100: #FFEDD5;
  --accent-200: #FED7AA;
  --accent-500: #F97316;
  --accent-600: #0F172A;
  --accent-700: #020617;
  --accent-hover: #EA580C;

  --bg-body: #FAFAF9;
  --bg-sidebar: #0F172A;
  --bg-header: #0F172A;
  --bg-card: #FFFFFF;
  --bg-surface: #F5F5F4;
  --bg-input: #FFFFFF;

  --text-primary: #1C1917;
  --text-secondary: #44403C;
  --text-muted: #78716C;
  --text-on-accent: #FFFFFF;

  --border-color: #D6D3D1;
  --border-subtle: #E7E5E4;
  --sidebar-active-bg: rgba(249,115,22,0.15);
  --sidebar-active-text: #FB923C;
  --sidebar-border: #1E293B;
  --header-border: #1E293B;
  --table-stripe: #FAFAF9;
  --table-hover: #FFF7ED;

  --shadow-card: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.1), 0 4px 8px rgba(0,0,0,0.06);

  --purple-50: #FFF7ED;
  --purple-100: #FFEDD5;
  --purple-200: #FED7AA;
  --purple-300: #FDBA74;
  --purple-400: #FB923C;
  --purple-500: #F97316;
  --purple-600: #0F172A;
  --purple-700: #020617;
  --purple-800: #1C1917;
  --purple-900: #0C0A09;

  --gray-50: #FAFAF9;
  --gray-100: #F5F5F4;
  --gray-200: #E7E5E4;
  --gray-300: #D6D3D1;
  --gray-400: #A8A29E;
  --gray-500: #78716C;
  --gray-600: #57534E;
  --gray-700: #44403C;
  --gray-800: #1C1917;
  --gray-900: #0C0A09;
}

/* === THEME: Classic Purple (backward compat) === */
[data-theme="classic"] {
  --color-primary: #7c3aed;
  --color-secondary: #8b5cf6;
  --color-accent: #6d28d9;
  --color-background: #f9fafb;
  --color-foreground: #1f2937;
  --color-card: #FFFFFF;
  --color-muted: #f3f4f6;
  --color-border: #e5e7eb;
  --color-destructive: #DC2626;
  --color-ring: #7c3aed;

  --accent-50: #f5f3ff;
  --accent-100: #ede9fe;
  --accent-200: #ddd6fe;
  --accent-500: #8b5cf6;
  --accent-600: #7c3aed;
  --accent-700: #6d28d9;
  --accent-hover: #6d28d9;

  --bg-body: #f9fafb;
  --bg-sidebar: #FFFFFF;
  --bg-header: #FFFFFF;
  --bg-card: #FFFFFF;
  --bg-surface: #f3f4f6;
  --bg-input: #FFFFFF;

  --text-primary: #1f2937;
  --text-secondary: #4b5563;
  --text-muted: #9ca3af;
  --text-on-accent: #FFFFFF;

  --border-color: #e5e7eb;
  --border-subtle: #f3f4f6;
  --sidebar-active-bg: #ede9fe;
  --sidebar-active-text: #7c3aed;
  --sidebar-border: #e5e7eb;
  --header-border: #e5e7eb;
  --table-stripe: #f9fafb;
  --table-hover: #f3f4f6;

  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.15);

  --purple-50: #f5f3ff;
  --purple-100: #ede9fe;
  --purple-200: #ddd6fe;
  --purple-300: #c4b5fd;
  --purple-400: #a78bfa;
  --purple-500: #8b5cf6;
  --purple-600: #7c3aed;
  --purple-700: #6d28d9;
  --purple-800: #5b21b6;
  --purple-900: #4c1d95;

  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;

  --green-500: #22c55e;
  --green-600: #16a34a;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --blue-500: #3b82f6;
  --blue-600: #2563eb;
  --amber-500: #f59e0b;
}

/* --- Navy theme: dark sidebar overrides ---------------------------------- */
/* Navy: dark sidebar + dark header */
[data-theme="navy"] .sidebar { color: #94A3B8; }
[data-theme="navy"] .brand-text { color: #F1F5F9 !important; }
[data-theme="navy"] .brand-icon { background: #F97316 !important; }
[data-theme="navy"] .nav-link { color: #94A3B8; }
[data-theme="navy"] .nav-link:hover { background: rgba(255,255,255,0.05); color: #E2E8F0; }
[data-theme="navy"] .nav-link.active { color: #FB923C; background: rgba(249,115,22,0.15); }
[data-theme="navy"] .nav-section-title { color: #475569; }
[data-theme="navy"] .header { background: #0F172A; color: #E2E8F0; border-bottom-color: #1E293B; }
[data-theme="navy"] .header-title { color: #F1F5F9; }
[data-theme="navy"] .theme-btn { background: #1E293B; border-color: #334155; color: #E2E8F0; }
[data-theme="navy"] .theme-btn:hover { border-color: #F97316; }
[data-theme="navy"] .theme-dropdown { background: #1E293B; border-color: #334155; }
[data-theme="navy"] .theme-option { color: #94A3B8; }
[data-theme="navy"] .theme-option:hover { background: #334155; color: #E2E8F0; }
[data-theme="navy"] .connection-status { color: #94A3B8; }

/* Blue: full dark mode */
[data-theme="blue"] .sidebar { color: #94A3B8; }
[data-theme="blue"] .brand-text { color: #E2E8F0 !important; }
[data-theme="blue"] .brand-icon { background: #3B82F6 !important; }
[data-theme="blue"] .nav-link { color: #64748B; }
[data-theme="blue"] .nav-link:hover { background: rgba(59,130,246,0.08); color: #94A3B8; }
[data-theme="blue"] .nav-link.active { color: #60A5FA; background: rgba(59,130,246,0.15); }
[data-theme="blue"] .nav-section-title { color: #475569; }
[data-theme="blue"] .header { background: #0E1629; color: #E2E8F0; border-bottom-color: #1E3050; }
[data-theme="blue"] .header-title { color: #E2E8F0; }
[data-theme="blue"] .theme-btn { background: #1A2340; border-color: #1E3050; color: #94A3B8; }
[data-theme="blue"] .theme-btn:hover { border-color: #3B82F6; }
[data-theme="blue"] .theme-dropdown { background: #131B2E; border-color: #1E3050; }
[data-theme="blue"] .theme-option { color: #94A3B8; }
[data-theme="blue"] .theme-option:hover { background: #1A2340; color: #E2E8F0; }
[data-theme="blue"] .connection-status { color: #94A3B8; }


/* ==========================================================================
   GLOBAL TYPOGRAPHY
   ========================================================================== */

html {
  font-size: 18px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font-body);
  background: var(--bg-body);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
}

h1, h2, h3, h4, h5, h6,
.heading {
  font-family: var(--font-heading);
  letter-spacing: 0.01em;
}

a {
  color: var(--accent-600);
  text-decoration: none;
  transition: color var(--transition);
}

a:hover {
  color: var(--accent-hover);
}


/* ==========================================================================
   LAYOUT
   ========================================================================== */

.layout {
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar ------------------------------------------------------------- */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: var(--sidebar-expanded);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--sidebar-border);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-brand {
  height: var(--header-height);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 10px;
  border-bottom: 1px solid var(--sidebar-border);
  white-space: nowrap;
  flex-shrink: 0;
}

.sidebar-brand .brand-icon {
  width: 56px;
  height: 56px;
  background: var(--accent-600);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 20px;
  flex-shrink: 0;
  font-family: var(--font-heading);
}

.sidebar-brand .brand-text {
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 8px 0;
}

.nav-section {
  padding: 4px 0;
}

.nav-section-title {
  padding: 8px 16px 4px;
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  white-space: nowrap;
  font-family: var(--font-body);
}

.nav-link {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  gap: 12px;
  color: var(--text-secondary);
  font-size: 16px;
  font-weight: 500;
  white-space: nowrap;
  transition: background var(--transition), color var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
  cursor: pointer;
}

.nav-link:hover {
  background: var(--accent-50);
  color: var(--text-primary);
}

.nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  border-left-color: var(--accent-600);
  font-weight: 600;
}

.nav-link .nav-icon {
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  flex-shrink: 0;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: -0.5px;
}

.nav-link.active .nav-icon {
  color: var(--sidebar-active-text);
}

/* .nav-link .nav-label is always visible — sidebar is always expanded */


/* --- Main Area ----------------------------------------------------------- */

.main-wrapper {
  flex: 1;
  margin-left: var(--sidebar-expanded);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}


/* --- Header -------------------------------------------------------------- */

.header {
  height: var(--header-height);
  background: var(--bg-header);
  border-bottom: 1px solid var(--header-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 30;
}

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

.header-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

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


/* --- Theme Switcher ------------------------------------------------------ */

.theme-switcher {
  position: relative;
}

.theme-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  /* α'' D-004: padding bumped 6px 12px → 10px 14px so total height clears 44px touch-target
     guideline (https://www.w3.org/WAI/WCAG21/Understanding/target-size.html). */
  padding: 10px 14px;
  min-height: 44px;
  cursor: pointer;
  font-size: 16px;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
  font-family: var(--font-body);
}

.theme-btn:hover {
  border-color: var(--accent-600);
  background: var(--accent-50);
}

.theme-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  min-width: 200px;
  z-index: 100;
  display: none;
  overflow: hidden;
}

.theme-dropdown.open {
  display: block;
  animation: slideIn 0.15s ease;
}

.theme-option {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  color: var(--text-secondary);
  transition: background 0.15s ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  font-family: var(--font-body);
}

.theme-option:hover {
  background: var(--bg-surface);
  color: var(--text-primary);
}

.theme-option.active {
  color: var(--accent-600);
  font-weight: 600;
}

.theme-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 2px solid var(--border-color);
}

.theme-option.active .theme-dot {
  border-color: var(--accent-600);
  box-shadow: 0 0 0 2px var(--accent-50);
}


/* --- Connection Status --------------------------------------------------- */

.connection-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 16px;
  color: var(--text-muted);
  font-family: var(--font-body);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green-500);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.offline {
  background: var(--red-500);
  animation: none;
}


/* ==========================================================================
   CONTENT AREA
   ========================================================================== */

.content {
  flex: 1;
  padding: 24px;
  max-width: 1400px;
  width: 100%;
}

.page-header {
  margin-bottom: 24px;
}

.page-title {
  /* α'' D-002: clamp() scales Cinzel page title between 24px (mobile) and 36px (desktop)
     based on viewport width — prevents collision with header-right buttons at <768px. */
  font-size: clamp(1.5rem, 5vw, 2.25rem);
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.page-subtitle {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
  font-family: var(--font-body);
}


/* ==========================================================================
   CARDS
   ========================================================================== */

.card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-card);
  padding: 24px;
  border: 1px solid var(--border-color);
  transition: box-shadow var(--transition);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

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

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

.card-subtitle {
  font-size: 16px;
  color: var(--text-muted);
}


/* ==========================================================================
   STATS CARDS
   ========================================================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-color);
  transition: box-shadow var(--transition), transform var(--transition);
  cursor: default;
}

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

.stat-icon {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  flex-shrink: 0;
  font-weight: 700;
}

.stat-icon.teal,
.stat-icon.purple {
  background: var(--accent-50);
  color: var(--accent-600);
}

.stat-icon.blue {
  background: #EFF6FF;
  color: var(--blue-600);
}

.stat-icon.green {
  background: #f0fdf4;
  color: var(--green-600);
}

.stat-icon.amber {
  background: #fffbeb;
  color: var(--amber-500);
}

.stat-info {
  flex: 1;
  min-width: 0;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  font-family: var(--font-heading);
}

.stat-label {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 500;
}


/* ==========================================================================
   MODULE CARDS
   ========================================================================== */

.module-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}

.module-card {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  border: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

.module-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-3px);
  border-color: var(--accent-200);
  color: inherit;
}

.module-card .module-icon {
  width: 68px;
  height: 68px;
  border-radius: var(--radius);
  background: var(--accent-50);
  color: var(--accent-600);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 30px;
  font-weight: 700;
}

.module-card .module-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  font-family: var(--font-heading);
}

.module-card .module-desc {
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}


/* ==========================================================================
   BAR CHART
   ========================================================================== */

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bar-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.bar-label {
  width: 140px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: right;
  flex-shrink: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  flex: 1;
  height: 24px;
  background: var(--bg-surface);
  border-radius: 6px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-600));
  border-radius: 6px;
  min-width: 2px;
  transition: width 0.6s ease;
}

.bar-value {
  width: 60px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  flex-shrink: 0;
}


/* ==========================================================================
   TABLES
   ========================================================================== */

.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 16px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 5;
}

thead th {
  background: var(--bg-surface);
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: var(--text-secondary);
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border-color);
  white-space: nowrap;
  font-family: var(--font-body);
}

thead th.sortable {
  cursor: pointer;
  user-select: none;
}

thead th.sortable:hover {
  background: var(--accent-50);
  color: var(--accent-600);
}

thead th.sortable::after {
  content: " \25B4\25BE";
  font-size: 16px;
  color: var(--text-muted);
  margin-left: 4px;
}

thead th.sort-asc::after {
  content: " \25B4";
  color: var(--accent-600);
}

thead th.sort-desc::after {
  content: " \25BE";
  color: var(--accent-600);
}

tbody td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

tbody tr:nth-child(even) {
  background: var(--table-stripe);
}

tbody tr:hover {
  background: var(--table-hover);
}

tbody tr {
  transition: background 0.15s ease;
}


/* ==========================================================================
   FORMS
   ========================================================================== */

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  font-size: 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-primary);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
  font-family: var(--font-body);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--color-ring);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

[data-theme="classic"] .form-input:focus,
[data-theme="classic"] .form-select:focus,
[data-theme="classic"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

[data-theme="blue"] .form-input:focus,
[data-theme="blue"] .form-select:focus,
[data-theme="blue"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(30, 64, 175, 0.1);
}

[data-theme="navy"] .form-input:focus,
[data-theme="navy"] .form-select:focus,
[data-theme="navy"] .form-textarea:focus {
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}

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

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: flex;
  gap: 12px;
}

.form-row > * {
  flex: 1;
}

.form-grid {
  display: grid;
  gap: 12px;
}

.form-grid-2 { grid-template-columns: 1fr 1fr; }
.form-grid-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }


/* ==========================================================================
   BUTTONS
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}

.btn:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

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

/* Primary — filled with primary color */
.btn-primary {
  background: var(--accent-600);
  color: var(--text-on-accent);
  border-color: var(--accent-600);
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-700);
  border-color: var(--accent-700);
}

/* Secondary — border only, primary text */
.btn-secondary,
.btn-outline {
  background: var(--bg-card);
  color: var(--accent-600);
  border-color: var(--accent-600);
}

.btn-secondary:hover:not(:disabled),
.btn-outline:hover:not(:disabled) {
  background: var(--accent-50);
  color: var(--accent-700);
}

/* Accent — filled with accent blue */
.btn-accent {
  background: var(--color-accent);
  color: var(--text-on-accent);
  border-color: var(--color-accent);
}

.btn-accent:hover:not(:disabled) {
  background: #024E7C;
  border-color: #024E7C;
}

/* Danger — red destructive */
.btn-danger {
  background: var(--color-destructive);
  color: #fff;
  border-color: var(--color-destructive);
}

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

/* Download */
.btn-download {
  background: var(--green-600);
  color: #fff;
  border-color: var(--green-600);
}

.btn-download:hover:not(:disabled) {
  background: #15803d;
  border-color: #15803d;
}

/* Sizes */
.btn-sm {
  padding: 6px 12px;
  font-size: 16px;
}

.btn-lg {
  padding: 12px 24px;
  font-size: 16px;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}


/* ==========================================================================
   BADGES
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  font-size: 16px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}

.badge-purple,
.badge-teal {
  background: var(--accent-100);
  color: var(--accent-700);
}

.badge-green {
  background: #dcfce7;
  color: #15803d;
}

.badge-red {
  background: #fee2e2;
  color: #b91c1c;
}

.badge-gray {
  background: var(--bg-surface);
  color: var(--text-secondary);
}

.badge-blue {
  background: #dbeafe;
  color: #1d4ed8;
}

.badge-amber {
  background: #fef3c7;
  color: #b45309;
}

.badge-orange {
  background: #ffedd5;
  color: #c2410c;
}


/* ==========================================================================
   PROGRESS BAR
   ========================================================================== */

.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--bg-surface);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-500), var(--accent-600));
  border-radius: 4px;
  transition: width 0.4s ease;
  position: relative;
}

.progress-fill.animated::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 8px,
    rgba(255, 255, 255, 0.15) 8px,
    rgba(255, 255, 255, 0.15) 16px
  );
  animation: progress-stripe 0.8s linear infinite;
}

@keyframes progress-stripe {
  from { background-position: 0 0; }
  to { background-position: 32px 0; }
}

.progress-text {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-top: 6px;
}


/* ==========================================================================
   DROP ZONE
   ========================================================================== */

.drop-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-xl);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-surface);
}

.drop-zone:hover {
  border-color: var(--accent-500);
  background: var(--accent-50);
}

.drop-zone.dragover {
  border-color: var(--accent-600);
  background: var(--accent-100);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1);
}

.drop-zone .drop-icon {
  font-size: 56px;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.drop-zone .drop-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}

.drop-zone .drop-hint {
  font-size: 16px;
  color: var(--text-muted);
  margin-top: 4px;
}


/* ==========================================================================
   LOG PANEL
   ========================================================================== */

.log-panel {
  background: #0F172A;
  border-radius: var(--radius);
  padding: 16px;
  max-height: 300px;
  overflow-y: auto;
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 16px;
  border: 1px solid #1E293B;
  color: #94A3B8;
}

.log-entry {
  color: #CBD5E1;
  padding: 2px 0;
  line-height: 1.6;
}

.log-time {
  color: #475569;
  margin-right: 8px;
}

.log-entry.error { color: #FCA5A5; }
.log-entry.success { color: #86EFAC; }
.log-entry.warning { color: #FCD34D; }


/* ==========================================================================
   STEP TRACKER
   ========================================================================== */

.step-tracker {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.step-badge {
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-muted);
  transition: all var(--transition);
}

.step-badge.active {
  background: var(--accent-600);
  color: var(--text-on-accent);
  border-color: var(--accent-600);
  animation: pulse 2s ease-in-out infinite;
}

.step-badge.done {
  background: var(--green-600);
  color: #fff;
  border-color: var(--green-600);
}


/* ==========================================================================
   PIPELINE STEPS
   ========================================================================== */

.pipeline-steps {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.pipeline-step {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  transition: all 0.2s ease;
}

.pipeline-step.active {
  border-color: var(--accent-500);
  background: var(--accent-50);
}

.pipeline-step.done {
  border-color: var(--green-500);
  background: #f0fdf4;
}

.pipeline-step .step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  font-weight: 700;
  background: var(--bg-surface);
  color: var(--text-muted);
  flex-shrink: 0;
}

.pipeline-step.active .step-num {
  background: var(--accent-600);
  color: #fff;
}

.pipeline-step.done .step-num {
  background: var(--green-600);
  color: #fff;
}

.pipeline-step .step-info { flex: 1; }
.pipeline-step .step-title { font-size: 15px; font-weight: 600; color: var(--text-primary); }
.pipeline-step .step-desc  { font-size: 11px; color: var(--text-muted); margin-top: 2px; }


/* ==========================================================================
   TABS
   ========================================================================== */

.tabs {
  display: flex;
  border-bottom: 2px solid var(--border-color);
  gap: 0;
  margin-bottom: 20px;
}

.tab {
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 500;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-body);
}

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

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


/* ==========================================================================
   SEARCH BOX
   ========================================================================== */

.search-box {
  position: relative;
}

.search-box .search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 16px;
  pointer-events: none;
}

.search-box .form-input {
  padding-left: 38px;
}


/* ==========================================================================
   ALERTS
   ========================================================================== */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-info {
  background: #eff6ff;
  color: #1e40af;
  border: 1px solid #bfdbfe;
}

.alert-success {
  background: #f0fdf4;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.alert-warning {
  background: #fffbeb;
  color: #92400e;
  border: 1px solid #fde68a;
}

.alert-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
}


/* ==========================================================================
   MODAL
   ========================================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
  backdrop-filter: blur(2px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

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

.modal-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 16px;
  font-family: var(--font-heading);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
}


/* ==========================================================================
   EMPTY STATE
   ========================================================================== */

.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.6;
}

.empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 4px;
  font-family: var(--font-heading);
}

.empty-state .empty-desc {
  font-size: 16px;
}


/* ==========================================================================
   PAGINATION
   ========================================================================== */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
}

.pagination .page-btn {
  min-width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  transition: all var(--transition);
}

.pagination .page-btn:hover {
  background: var(--accent-50);
  border-color: var(--accent-500);
  color: var(--accent-600);
}

.pagination .page-btn.active {
  background: var(--accent-600);
  color: var(--text-on-accent);
  border-color: var(--accent-600);
}


/* ==========================================================================
   LOADING / SPINNER
   ========================================================================== */

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border-color);
  border-top-color: var(--accent-600);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.loading-overlay {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px;
  color: var(--text-muted);
  font-size: 16px;
}


/* ==========================================================================
   TOOLTIP
   ========================================================================== */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 10px;
  font-size: 16px;
  background: var(--gray-800);
  color: #fff;
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  margin-bottom: 6px;
}

.tooltip:hover::after {
  opacity: 1;
}


/* ==========================================================================
   SOURCE FILTER BADGES
   ========================================================================== */

.source-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.source-badge {
  padding: 6px 14px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 600;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.source-badge:hover {
  border-color: var(--accent-500);
  color: var(--accent-600);
}

.source-badge.selected {
  background: var(--accent-600);
  color: var(--text-on-accent);
  border-color: var(--accent-600);
}


/* ==========================================================================
   TOGGLE GROUP
   ========================================================================== */

.toggle-group {
  display: inline-flex;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  overflow: hidden;
}

.toggle-btn {
  padding: 8px 20px;
  font-size: 16px;
  font-weight: 600;
  border: none;
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.toggle-btn.active {
  background: var(--accent-600);
  color: var(--text-on-accent);
}

.toggle-btn:not(:last-child) {
  border-right: 1px solid var(--border-color);
}


/* ==========================================================================
   COLUMN CHIPS
   ========================================================================== */

.column-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.column-chip {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}

.column-chip:hover {
  border-color: var(--accent-500);
}

.column-chip.selected {
  background: var(--accent-600);
  color: var(--text-on-accent);
  border-color: var(--accent-600);
}


/* ==========================================================================
   RACE BADGES
   ========================================================================== */

.race-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 16px;
  font-weight: 600;
}

.race-malay       { background: #dcfce7; color: #15803d; }
.race-chinese     { background: #fee2e2; color: #b91c1c; }
.race-indian      { background: #dbeafe; color: #1d4ed8; }
.race-bumiputera  { background: #fef3c7; color: #92400e; }
.race-company     { background: var(--bg-surface); color: var(--text-secondary); }
.race-other       { background: var(--bg-surface); color: var(--text-muted); }


/* ==========================================================================
   STAR / FAVORITE
   ========================================================================== */

.star-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--gray-300);
  font-size: 18px;
  padding: 4px;
  transition: color 0.15s ease;
}

.star-btn:hover { color: var(--amber-500); }
.star-btn.starred { color: var(--amber-500); }


/* ==========================================================================
   KEYFRAME ANIMATIONS
   ========================================================================== */

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

@keyframes shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* Shimmer loading skeleton */
.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-surface) 25%,
    var(--accent-50) 50%,
    var(--bg-surface) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.5s ease infinite;
  border-radius: var(--radius);
}

/* Alert pulse glow */
.alert-pulse {
  animation: alertGlow 2s ease-in-out infinite;
}

@keyframes alertGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(15, 118, 110, 0.2); }
  50% { box-shadow: 0 0 0 8px rgba(15, 118, 110, 0); }
}

/* Status indicator blink */
.status-blink {
  animation: blink 1.5s step-end infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}


/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .sidebar {
    transition: none;
  }

  .bar-fill {
    transition: none;
  }

  .progress-fill.animated::after {
    animation: none;
  }
}


/* ==========================================================================
   FOCUS STATES (keyboard nav)
   ========================================================================== */

:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid var(--color-ring);
  outline-offset: 2px;
}


/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.text-primary { color: var(--accent-600); }
.text-purple  { color: var(--accent-600); }
.text-green   { color: var(--green-600); }
.text-red     { color: var(--red-600); }
.text-gray    { color: var(--text-muted); }
.text-blue    { color: var(--blue-600); }
.text-amber   { color: var(--amber-500); }
.text-orange  { color: #f97316; }
.text-sm      { font-size: 12px; }
.text-xs      { font-size: 11px; }
.text-center  { text-align: center; }
.text-right   { text-align: right; }

.font-heading   { font-family: var(--font-heading); }
.font-bold      { font-weight: 700; }
.font-semibold  { font-weight: 600; }
.font-medium    { font-weight: 500; }

.flex            { display: flex; }
.flex-col        { flex-direction: column; }
.flex-wrap       { flex-wrap: wrap; }
.items-center    { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center  { justify-content: center; }
.gap-2           { gap: 8px; }
.gap-3           { gap: 12px; }
.gap-4           { gap: 16px; }

.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

.p-4 { padding: 16px; }
.p-6 { padding: 24px; }

.w-full { width: 100%; }
.hidden { display: none; }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Cursor pointer on all clickable elements */
button,
a,
[role="button"],
[onclick],
.cursor-pointer {
  cursor: pointer;
}


/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 1024px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    width: var(--sidebar-expanded);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .module-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .form-grid-2,
  .form-grid-3,
  .form-grid-4 {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .content {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .module-grid {
    grid-template-columns: 1fr;
  }

  .header {
    padding: 0 16px;
  }

  .header-title {
    font-size: 16px;
  }

  .bar-label {
    width: 100px;
    font-size: 16px;
  }
}


/* ==========================================================================
   TASK 11: Standardized Form Grids + Empty States
   ========================================================================== */

.search-form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 1024px) {
  .search-form-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 640px) {
  .search-form-grid { grid-template-columns: 1fr; }
}

.search-empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
  border: 1px dashed var(--border-color);
  border-radius: var(--radius-lg);
  margin-top: 16px;
}

.search-empty-state .empty-icon {
  font-size: 48px;
  opacity: 0.4;
  margin-bottom: 12px;
}

.search-empty-state .empty-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-secondary);
  font-family: var(--font-heading);
}

.search-empty-state .empty-desc {
  font-size: 14px;
  margin-top: 4px;
}


/* ==========================================================================
   TASK 12: Results Table Polish
   ========================================================================== */

.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.results-count {
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 500;
}

.results-count strong {
  color: var(--text-primary);
  font-weight: 700;
}

tbody tr.clickable-row {
  cursor: pointer;
}

tbody tr.clickable-row:hover {
  background: var(--table-hover);
}

.price-cell {
  font-weight: 600;
  font-family: var(--font-heading);
  color: var(--text-primary);
  white-space: nowrap;
}

.date-cell {
  white-space: nowrap;
  color: var(--text-secondary);
}

.phone-cell {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.ic-cell {
  font-family: "SF Mono", "Fira Code", "Consolas", monospace;
  font-size: 13px;
}


/* ==========================================================================
   TASK 13: Tool Page Polish
   ========================================================================== */

/* Improved drop zone with pulse animation */
.drop-zone.dragover {
  animation: dropPulse 1s ease-in-out infinite;
}

@keyframes dropPulse {
  0%, 100% { border-color: var(--accent-600); box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.1); }
  50% { border-color: var(--accent-500); box-shadow: 0 0 0 8px rgba(15, 118, 110, 0.05); }
}

/* File info after selection */
.file-info {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--accent-50);
  border-radius: var(--radius);
  border: 1px solid var(--accent-200);
  margin-top: 12px;
}

.file-info .file-name {
  font-weight: 600;
  color: var(--text-primary);
}

.file-info .file-size {
  font-size: 13px;
  color: var(--text-muted);
}

.file-info .file-remove {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--red-500);
  font-size: 16px;
  cursor: pointer;
}

/* Stats card with colored left border */
.stat-card-bordered {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  border: 1px solid var(--border-color);
  border-left: 4px solid var(--accent-600);
  transition: box-shadow var(--transition), transform var(--transition);
}

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

.stat-card-bordered.green  { border-left-color: var(--green-500); }
.stat-card-bordered.blue   { border-left-color: var(--blue-500); }
.stat-card-bordered.amber  { border-left-color: var(--amber-500); }
.stat-card-bordered.red    { border-left-color: var(--red-500); }
.stat-card-bordered.purple { border-left-color: var(--accent-600); }


/* ==========================================================================
   TASK 14: Dashboard Polish
   ========================================================================== */

/* Stat card gradient backgrounds */
.stat-card.gradient-teal {
  background: linear-gradient(135deg, var(--bg-card) 0%, var(--accent-50) 100%);
}

.stat-card.gradient-blue {
  background: linear-gradient(135deg, var(--bg-card) 0%, #EFF6FF 100%);
}

.stat-card.gradient-green {
  background: linear-gradient(135deg, var(--bg-card) 0%, #f0fdf4 100%);
}

.stat-card.gradient-amber {
  background: linear-gradient(135deg, var(--bg-card) 0%, #fffbeb 100%);
}

/* Module card colored top border */
.module-card {
  border-top: 3px solid transparent;
}

.module-card:nth-child(1) { border-top-color: var(--accent-500); }
.module-card:nth-child(2) { border-top-color: var(--blue-500); }
.module-card:nth-child(3) { border-top-color: var(--green-500); }
.module-card:nth-child(4) { border-top-color: var(--amber-500); }
.module-card:nth-child(5) { border-top-color: #F97316; }
.module-card:nth-child(6) { border-top-color: #EC4899; }
.module-card:nth-child(7) { border-top-color: #8B5CF6; }
.module-card:nth-child(8) { border-top-color: #EF4444; }
.module-card:nth-child(9) { border-top-color: #06B6D4; }
.module-card:nth-child(10) { border-top-color: #84CC16; }

/* Bar chart tooltip */
.bar-row {
  position: relative;
}

.bar-track:hover .bar-fill {
  filter: brightness(1.1);
}

.bar-row:hover .bar-value {
  color: var(--accent-600);
  font-weight: 700;
}

/* Animate bars sliding in */
.bar-fill {
  animation: barSlideIn 0.6s ease both;
}

@keyframes barSlideIn {
  from { width: 0 !important; }
}


/* ==========================================================================
   TASK 15: Login Page
   ========================================================================== */

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-body);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: 40px;
  border: 1px solid var(--border-color);
  text-align: center;
}

.login-brand {
  width: 72px;
  height: 72px;
  background: var(--accent-600);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 28px;
  margin: 0 auto 20px;
  font-family: var(--font-heading);
}

.login-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
  font-family: var(--font-heading);
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-form {
  text-align: left;
}

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

.login-form .form-input {
  padding: 12px 16px;
  font-size: 16px;
}

.login-error {
  background: #fef2f2;
  color: #991b1b;
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 10px 14px;
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.login-footer {
  margin-top: 24px;
  font-size: 13px;
  color: var(--text-muted);
}


/* ==========================================================================
   TASK 16: Cross-Theme Fixes
   ========================================================================== */

/* Blue (dark) theme: badge readability */
[data-theme="blue"] .badge-green  { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="blue"] .badge-red    { background: rgba(239,68,68,0.15); color: #fca5a5; }
[data-theme="blue"] .badge-gray   { background: rgba(255,255,255,0.08); color: #94a3b8; }
[data-theme="blue"] .badge-blue   { background: rgba(59,130,246,0.15); color: #93bbfd; }
[data-theme="blue"] .badge-amber  { background: rgba(245,158,11,0.15); color: #fbbf24; }
[data-theme="blue"] .badge-orange { background: rgba(249,115,22,0.15); color: #fb923c; }
[data-theme="blue"] .badge-purple,
[data-theme="blue"] .badge-teal   { background: rgba(59,130,246,0.15); color: #93bbfd; }

/* Blue theme: race badges */
[data-theme="blue"] .race-malay       { background: rgba(34,197,94,0.15); color: #4ade80; }
[data-theme="blue"] .race-chinese     { background: rgba(239,68,68,0.15); color: #fca5a5; }
[data-theme="blue"] .race-indian      { background: rgba(59,130,246,0.15); color: #93bbfd; }
[data-theme="blue"] .race-bumiputera  { background: rgba(245,158,11,0.15); color: #fbbf24; }

/* Blue theme: stat icon backgrounds */
[data-theme="blue"] .stat-icon.teal,
[data-theme="blue"] .stat-icon.purple { background: rgba(59,130,246,0.15); }
[data-theme="blue"] .stat-icon.blue   { background: rgba(96,165,250,0.15); }
[data-theme="blue"] .stat-icon.green  { background: rgba(34,197,94,0.15); }
[data-theme="blue"] .stat-icon.amber  { background: rgba(245,158,11,0.15); }

/* Blue theme: gradient stat cards */
[data-theme="blue"] .stat-card.gradient-teal  { background: linear-gradient(135deg, #131B2E 0%, rgba(59,130,246,0.08) 100%); }
[data-theme="blue"] .stat-card.gradient-blue  { background: linear-gradient(135deg, #131B2E 0%, rgba(96,165,250,0.08) 100%); }
[data-theme="blue"] .stat-card.gradient-green { background: linear-gradient(135deg, #131B2E 0%, rgba(34,197,94,0.08) 100%); }
[data-theme="blue"] .stat-card.gradient-amber { background: linear-gradient(135deg, #131B2E 0%, rgba(245,158,11,0.08) 100%); }

/* Blue theme: alert, empty state, search empty */
[data-theme="blue"] .alert-info    { background: rgba(59,130,246,0.1); color: #93bbfd; border-color: #1E3050; }
[data-theme="blue"] .alert-success { background: rgba(34,197,94,0.1); color: #4ade80; border-color: #1E3050; }
[data-theme="blue"] .alert-warning { background: rgba(245,158,11,0.1); color: #fbbf24; border-color: #1E3050; }
[data-theme="blue"] .alert-error   { background: rgba(239,68,68,0.1); color: #fca5a5; border-color: #1E3050; }
[data-theme="blue"] .search-empty-state { border-color: #1E3050; }
[data-theme="blue"] .login-error   { background: rgba(239,68,68,0.1); color: #fca5a5; border-color: #1E3050; }

/* Blue theme: drop zone */
[data-theme="blue"] .drop-zone {
  background: #1A2340;
  border-color: #1E3050;
}
[data-theme="blue"] .drop-zone:hover {
  border-color: #3B82F6;
  background: rgba(59,130,246,0.08);
}

/* Blue theme: pipeline steps */
[data-theme="blue"] .pipeline-step.done {
  background: rgba(34,197,94,0.08);
  border-color: rgba(34,197,94,0.3);
}

/* Blue theme: step tracker */
[data-theme="blue"] .step-badge.done {
  background: #16a34a;
}

/* Blue theme: toggle group */
[data-theme="blue"] .toggle-btn {
  background: #1A2340;
  color: #94A3B8;
  border-color: #1E3050;
}

/* Blue theme: file info */
[data-theme="blue"] .file-info {
  background: rgba(59,130,246,0.08);
  border-color: #1E3050;
}

/* Navy theme: ensure content area inputs are readable */
[data-theme="navy"] .form-input,
[data-theme="navy"] .form-select,
[data-theme="navy"] .form-textarea {
  background: #FFFFFF;
  color: #1C1917;
  border-color: #D6D3D1;
}

/* Navy theme: module card top borders */
[data-theme="navy"] .module-card:nth-child(1) { border-top-color: #F97316; }

/* Navy theme: search empty state */
[data-theme="navy"] .search-empty-state { border-color: #D6D3D1; }

/* Logout button in header */
.logout-btn {
  background: none;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  /* α'' D-004: padding bumped 6px 14px → 10px 16px; min-height 44px for touch target. */
  padding: 10px 16px;
  min-height: 44px;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: var(--font-body);
}

.logout-btn:hover {
  color: var(--red-500);
  border-color: var(--red-500);
}

[data-theme="blue"] .logout-btn { border-color: #1E3050; color: #64748B; }
[data-theme="blue"] .logout-btn:hover { color: #fca5a5; border-color: #fca5a5; }
[data-theme="navy"] .logout-btn { border-color: #334155; color: #94A3B8; }
[data-theme="navy"] .logout-btn:hover { color: #fca5a5; border-color: #fca5a5; }

/* ========================================================================
   Modal Backdrop (used by admin_users, admin_teams, listings_batch_detail)
   ======================================================================== */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
}

.modal-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px 32px;
  min-width: 400px;
  max-width: 600px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-card h3 {
  margin-top: 0;
  margin-bottom: 16px;
}

.modal-card .btn-group {
  margin-top: 20px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}


/* ==========================================================================
   α'' D-001 — MOBILE NAV DRAWER (pure CSS, no JS)
   Pattern: hidden checkbox at body root + label triggers in header + backdrop.
   The :checked state + sibling combinator slides .sidebar into view at <=1024px.
   ========================================================================== */

/* Visually hide the checkbox itself — it's an implementation detail.
   Keep it focusable (no display:none) so keyboard users can still toggle nav. */
.nav-toggle-checkbox {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* Hamburger button — hidden on desktop, shown on tablet/mobile. */
.nav-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  /* α'' D-004: ≥44px touch target. */
  min-width: 44px;
  min-height: 44px;
  padding: 0 4px;
  font-size: 24px;
  line-height: 1;
  color: var(--text-primary);
  cursor: pointer;
  user-select: none;
  border-radius: var(--radius);
  transition: background-color 0.15s ease;
}

.nav-toggle-btn:hover,
.nav-toggle-btn:focus-visible {
  background: var(--accent-50);
  outline: none;
}

/* Backdrop overlay — invisible by default; shown only when drawer is open on mobile. */
.nav-backdrop {
  display: none;
}

/* Tablet + mobile breakpoint matches existing .sidebar transform:translateX(-100%) at 1024px. */
@media (max-width: 1024px) {
  .nav-toggle-btn {
    display: inline-flex;
  }

  /* Drawer slides in when the hidden checkbox is checked. The checkbox sits at body root
     (before .layout), so the sibling combinator `~` reaches .layout .sidebar. */
  .nav-toggle-checkbox:checked ~ .layout .sidebar {
    transform: translateX(0);
    /* Z-index above backdrop so the drawer is the click target. */
    z-index: 45;
  }

  .nav-toggle-checkbox:checked ~ .layout .nav-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 35; /* Between header (30) and sidebar (40+) — covers content, allows click-to-close. */
    cursor: pointer;
  }
}
