/* ============================================================
   ERRA Analytics - Clean Light Theme
   ============================================================ */

/* ============================================================
   CSS VARIABLES
   ============================================================ */
:root {
  /* Brand and typography — Madlan-inspired */
  --font-ui: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-data: 'Heebo', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;

  /* Sidebar colors */
  --sidebar-bg: #ffffff;
  --sidebar-bg-hover: #F5F6F8;
  --sidebar-bg-active: rgba(37, 99, 235, 0.08);
  --sidebar-text: #6B7280;
  --sidebar-text-hover: #323434;
  --sidebar-text-active: #2563EB;
  --sidebar-section-title: #9CA3AF;
  --sidebar-border: #F0F0F0;
  --sidebar-width: 240px;

  /* Accent — trust blue */
  --accent: #2563EB;
  --accent-soft: rgba(37, 99, 235, 0.10);
  --accent-warm: #F59E0B;

  /* Content area */
  --content-bg: #F5F6F8;
  --card-bg: #ffffff;
  --card-border: #F0F0F0;
  --text-primary: #323434;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --surface-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);

  /* Global button palette */
  --button-primary: #2563EB;
  --button-primary-hover: #1D4ED8;
  --button-secondary: #323434;
  --button-secondary-hover: #1A1C1C;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);

  /* Border radius */
  --radius-sm: 4px;
  --radius-md: 6px;
  --radius-lg: 8px;
  --radius-xl: 12px;
  --radius-pill: 999px;

  /* Dividers & borders */
  --divider: #F0F0F0;
  --border-default: #D0D7E2;

  /* Spacing scale */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-6: 24px;
  --space-8: 32px;
  --space-12: 48px;

  /* Typography scale */
  --text-xs: 12px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-md: 16px;
  --text-lg: 20px;
  --text-xl: 24px;
  --text-2xl: 32px;
}

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

/* ============================================================
   SIDEBAR - Clean Light Style
   ============================================================ */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(0,0,0,0.08) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.08);
  border-radius: 4px;
}

/* Sidebar Logo */
.sidebar-logo {
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.sidebar-logo a {
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo h2 {
  font-size: 15px;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0;
  letter-spacing: -0.03em;
}

.sidebar-logo small {
  display: none;
}

.sidebar-logo .logo-icon {
  width: 0;
  height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  flex-shrink: 0;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
  overflow: hidden;
}

.sidebar-logo .logo-icon svg {
  width: 0;
  height: 0;
  display: block;
}

.sidebar-logo .brand-mark {
  width: 16px;
  height: 16px;
  display: block;
  flex-shrink: 0;
  color: #2563EB;
  background: transparent !important;
  border-radius: 0 !important;
  box-shadow: none !important;
}

/* Sidebar Navigation */
.sidebar-nav {
  padding: 8px 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

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

.nav-section-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--sidebar-section-title);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 12px 10px 6px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  text-decoration: none;
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: all 0.12s ease;
  margin-bottom: 1px;
  position: relative;
}

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

.nav-link.active {
  background: var(--sidebar-bg-active);
  color: var(--sidebar-text-active);
  font-weight: 600;
  /* clean active: no inset shadow */
}

.nav-link.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 16px;
  background: var(--accent);
  border-radius: 0 2px 2px 0;
}

.nav-link i {
  font-size: 15px;
  width: 18px;
  text-align: center;
  opacity: 0.7;
}

.nav-link.active i {
  opacity: 1;
}

.nav-link .nav-badge {
  margin-inline-start: auto;
  font-size: 10px;
  padding: 1px 6px;
  border-radius: var(--radius-pill);
  font-weight: 600;
}

/* Sidebar Account Section */
.nav-section-account {
  margin-top: auto !important;
  border-top: 1px solid var(--sidebar-border) !important;
  padding-top: 8px !important;
}

/* ============================================================
   MAIN LAYOUT
   ============================================================ */
.main-wrapper {
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background: var(--content-bg);
  position: relative;
}

/* ============================================================
   HEADER - Clean Minimal
   ============================================================ */
header {
  background: #ffffff;
  border-bottom: 1px solid var(--divider);
  padding: 0 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

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

.header-breadcrumb {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.header-breadcrumb strong {
  color: var(--text-primary);
  letter-spacing: -0.015em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Language Switcher - Pill Style */
.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #d6dee8;
  border-radius: 6px;
  background: #f6f8fb;
}

.language-switcher-icon {
  display: none;
}

.language-pill {
  border: none;
  border-radius: 4px;
  padding: 4px 10px;
  min-width: auto;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: #6b7280;
  background: transparent;
  cursor: pointer;
  transition: all 0.12s ease;
}

.language-pill:hover {
  color: #374151;
}

.language-pill:focus {
  outline: none;
}

.language-pill.active {
  color: #0f172a;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.1);
}

/* Header Icon Buttons */
.header-icon-btn {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: pointer;
  border: none;
  background: transparent;
  transition: all 0.12s ease;
  position: relative;
}

.header-icon-btn:hover {
  background: #eef2f7;
  color: #374151;
}

.notification-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: #ef4444;
  color: white;
  border-radius: 50%;
  width: 14px;
  height: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: 700;
}

/* User Avatar in Header */
.user-menu {
  display: flex;
  align-items: center;
}

.user-profile-dropdown {
  position: relative;
}

.user-profile-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.12s ease;
}

.user-profile-toggle:hover {
  background: #eef2f7;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: #2563EB;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  font-size: 12px;
  overflow: hidden;
}

.user-avatar-img {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: cover;
}

.user-info {
  display: flex;
  flex-direction: column;
}

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
  line-height: 1.2;
}

.user-role {
  font-size: 10px;
  color: #9ca3af;
  line-height: 1.2;
}

/* User Dropdown — all styles moved to base.html <style> block */

/* ============================================================
   MAIN CONTENT AREA
   ============================================================ */
main {
  flex: 1;
  padding: 0 24px 24px;
  position: relative;
  z-index: 1;
  overflow-x: hidden;
}

/* ============================================================
   NOTIFICATION STYLES
   ============================================================ */
.header-notifications {
  position: relative;
  display: flex;
  align-items: center;
}

.notification-toggle {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #6b7280;
  cursor: pointer;
  transition: all 0.12s ease;
  position: relative;
}

.notification-toggle:hover {
  background: #eef2f7;
  color: #374151;
}

.header-notifications.active .notification-toggle {
  color: var(--accent);
  background: var(--accent-soft);
}

.notification-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  width: 340px;
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--surface-shadow);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: all 0.12s ease;
  display: none;
}

.header-notifications.active .notification-dropdown-menu {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
  display: block;
}

.notification-dropdown-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
}

.notification-dropdown-title {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
}

.notification-full-link {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
}

.notification-preview-list {
  max-height: 280px;
  overflow-y: auto;
}

.notification-preview-item {
  display: block;
  text-decoration: none;
  padding: 10px 12px;
  border-bottom: 1px solid var(--divider);
  transition: background 0.12s ease;
  color: #374151;
  position: relative;
  padding-right: 32px;
}

.notification-preview-link {
  display: block;
  text-decoration: none;
  color: inherit;
}

.notification-dismiss-form {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 2;
}

.notification-dismiss-btn {
  width: 18px;
  height: 18px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: #9ca3af;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
}

.notification-dismiss-btn:hover {
  color: #ef4444;
  background: #fee2e2;
}

.notification-preview-item:hover {
  background: #F5F6F8;
}

.notification-preview-item.unread {
  background: rgba(37, 99, 235, 0.06);
}

.notification-preview-item.unread:hover {
  background: #e5eef9;
}

.notification-preview-title {
  font-size: 12px;
  font-weight: 600;
  color: #111827;
  margin-bottom: 2px;
}

.notification-preview-text {
  font-size: 11px;
  color: #6b7280;
  line-height: 1.35;
  margin-bottom: 3px;
}

.notification-preview-time {
  font-size: 10px;
  color: #9ca3af;
}

.notification-preview-empty {
  padding: 16px 12px;
  font-size: 12px;
  color: #9ca3af;
  text-align: center;
}

/* ============================================================
   FOOTER - Minimal
   ============================================================ */
footer {
  background: #ffffff;
  color: #6b7280;
  padding: 24px 32px;
  margin-top: 24px;
  border-top: 1px solid var(--divider);
}

.footer-content {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.footer-copyright {
  font-size: 12px;
  color: #9ca3af;
}

.footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

.footer-links a {
  font-size: 12px;
  color: #9ca3af;
  text-decoration: none;
  transition: color 0.12s ease;
}

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

/* ============================================================
   PAGE HEADER
   ============================================================ */
.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: clamp(1.45rem, 2vw, 1.75rem);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

.page-header p {
  font-size: 13px;
  color: #6b7280;
}

/* ============================================================
   MOBILE STYLES
   ============================================================ */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #374151;
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
}

.mobile-drawer-close {
  display: none;
}

.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1050;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.mobile-nav-overlay.active {
  display: block;
  opacity: 1;
}

.mobile-bottom-nav {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(56px + env(safe-area-inset-bottom));
  background: var(--sidebar-bg);
  border-top: 1px solid var(--sidebar-border);
  z-index: 1040;
  padding: 0 8px;
  padding-bottom: env(safe-area-inset-bottom);
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 2px;
  align-items: stretch;
  /* Force GPU layer so iOS Safari address-bar collapse doesn't trigger
     a layout-thrash repaint that visually 'jumps' the nav. Pairs with
     viewport-fit=cover in <meta viewport> for proper safe-area support. */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
  will-change: transform;
}

.mobile-bottom-link {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
  border-radius: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 10px;
  font-weight: 600;
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  height: 100%;
  direction: ltr;
  transition: all 0.12s ease;
}

.mobile-bottom-link i {
  display: block;
  font-size: 20px;
  line-height: 1;
  flex-shrink: 0;
  text-align: center;
  width: 100%;
}

.mobile-bottom-link span {
  display: block;
  line-height: 1;
  flex-shrink: 0;
  unicode-bidi: isolate;
}

.mobile-bottom-link.active {
  color: var(--sidebar-text-active);
  background: var(--sidebar-bg-active);
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
    width: 260px;
  }

  .sidebar.mobile-open {
    transform: translateX(0);
  }

  .sidebar-logo {
    display: flex;
    align-items: center;
    justify-content: space-between;
  }

  .mobile-drawer-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border: 1px solid var(--sidebar-border);
    border-radius: 6px;
    background: transparent;
    color: var(--sidebar-text);
    cursor: pointer;
    font-size: 14px;
  }

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

  header {
    padding: 0 12px;
    height: 48px;
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  main {
    padding: 0 12px 12px;
    /* Bottom nav is 56px + the iOS home-indicator safe area, so a flat 76px
       left ~14px of content hidden behind it on notched iPhones. Reserve the
       safe area on top of the gap. */
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  footer {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }

  .mobile-bottom-nav {
    display: grid;
  }

  .header-actions {
    gap: 4px;
  }

  .user-info {
    display: none;
  }

  .user-profile-toggle {
    padding: 4px;
  }

  .language-pill {
    font-size: 10px;
    padding: 3px 8px;
  }
}

/* ============================================================
   RTL SUPPORT
   ============================================================ */
html[dir="rtl"] body {
  direction: rtl;
}

html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
  border-right: none;
  border-left: 1px solid var(--sidebar-border);
}

html[dir="rtl"] .nav-link.active::before {
  left: auto;
  right: -8px;
  border-radius: 2px 0 0 2px;
}

html[dir="rtl"] .main-wrapper {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

html[dir="rtl"] .header-actions {
  margin-left: 0;
}

html[dir="rtl"] .notification-dropdown-menu {
  right: auto;
  left: 0;
}

html[dir="rtl"] button .bi:first-child:not(:only-child),
html[dir="rtl"] a .bi:first-child:not(:only-child),
html[dir="rtl"] .tab-button .bi:first-child:not(:only-child) {
  margin-right: 0 !important;
  margin-left: 0.5rem !important;
}

html[dir="rtl"] button .bi:last-child:not(:only-child),
html[dir="rtl"] a .bi:last-child:not(:only-child),
html[dir="rtl"] .tab-button .bi:last-child:not(:only-child) {
  margin-left: 0 !important;
  margin-right: 0.5rem !important;
}

html[dir="rtl"] .bi.mr-1,
html[dir="rtl"] .bi.mr-2,
html[dir="rtl"] .bi.mr-3 {
  margin-right: 0 !important;
  margin-left: 0.5rem !important;
}

html[dir="rtl"] .bi.ml-1,
html[dir="rtl"] .bi.ml-2,
html[dir="rtl"] .bi.ml-3 {
  margin-left: 0 !important;
  margin-right: 0.5rem !important;
}

@media (max-width: 768px) {
  html[dir="rtl"] .sidebar {
    transform: translateX(100%);
  }

  html[dir="rtl"] .sidebar.mobile-open {
    transform: translateX(0);
  }

  html[dir="rtl"] .main-wrapper {
    margin-left: 0;
    margin-right: 0;
  }
}

/* ============================================================
   DASHBOARD SPECIFIC STYLES
   ============================================================ */

/* Stats Cards */
.ln-stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.ln-stat-card {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  animation: floatIn 0.36s ease both;
}

.ln-stat-card:hover {
  border-color: var(--border-default);
  box-shadow: var(--shadow-sm);
}

.ln-stat-label {
  font-size: 11px;
  font-weight: 500;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}

.ln-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: #111827;
  letter-spacing: -0.02em;
}

.ln-stat-icon {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}

/* Toggle / Collapsible Sections */
.ln-section-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  cursor: pointer;
  user-select: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.ln-section-toggle h3 {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.ln-section-toggle i {
  font-size: 12px;
  color: #9ca3af;
  transition: transform 0.2s ease;
}

.ln-section-toggle.collapsed i {
  transform: rotate(-90deg);
}

.ln-collapsible {
  overflow: hidden;
  max-height: 5000px;
  opacity: 1;
  transition: max-height 0.4s ease, opacity 0.3s ease;
}

.ln-collapsible.collapsed {
  max-height: 0 !important;
  opacity: 0;
}

/* Charts Grid */
.ln-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}

.ln-chart-card {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: floatIn 0.4s ease both;
}

.ln-chart-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ln-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.ln-chart-body {
  padding: 16px;
}

/* Filters Bar */
.ln-filters-bar {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  margin-bottom: 16px;
  overflow: visible;
  box-shadow: var(--shadow-sm);
  animation: floatIn 0.3s ease both;
}

.ln-filters-header {
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.ln-filters-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ln-filters-body {
  padding: 12px 16px;
  border-top: 1px solid var(--divider);
}

/* Table Styles */
.ln-table-card {
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: floatIn 0.45s ease both;
}

.ln-table-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.ln-table-title {
  font-size: 13px;
  font-weight: 600;
  color: #374151;
}

.ln-table-count {
  font-size: 11px;
  color: #9ca3af;
}

.ln-table {
  width: 100%;
  font-size: 13px;
}

.ln-table thead {
  background: #F5F6F8;
}

.ln-table th {
  padding: 8px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: #6b7280;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--divider);
}

.ln-table td {
  padding: 10px 16px;
  color: #374151;
  border-bottom: 1px solid var(--divider);
}

.ln-table tr:hover td {
  background: #F5F6F8;
}

.ln-table tr:last-child td {
  border-bottom: none;
}

/* Pagination */
.ln-pagination {
  padding: 10px 16px;
  border-top: 1px solid var(--divider);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  color: #6b7280;
}

.ln-pagination a {
  padding: 4px 12px;
  border: 1px solid var(--border-default);
  border-radius: 8px;
  color: #374151;
  text-decoration: none;
  font-size: 12px;
  font-weight: 500;
  transition: all 0.12s ease;
}

.ln-pagination a:hover {
  background: #edf2f8;
}

/* ============================================================
   RESPONSIVE GRID ADJUSTMENTS
   ============================================================ */
@media (max-width: 1024px) {
  .ln-stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .ln-charts-grid {
    grid-template-columns: 1fr;
  }
}

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

/* ============================================================
   AUTOCOMPLETE STYLES (Global)
   ============================================================ */
.global-ac-dropdown {
  border-radius: 10px;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid var(--divider);
  max-height: 220px;
  overflow-y: auto;
  z-index: 40;
  box-shadow: var(--surface-shadow);
}

.global-ac-dropdown.hidden {
  display: none;
}

.global-ac-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 13px;
  color: #374151;
  text-align: left;
}

.global-ac-option:hover {
  background: rgba(37, 99, 235, 0.06);
}

body {
  font-family: var(--font-ui);
  color: var(--text-primary);
  background: var(--content-bg);
}

input, select, textarea, button {
  font-family: var(--font-data);
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.38);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  .ln-stat-card,
  .ln-chart-card,
  .ln-table-card,
  .ln-filters-bar {
    animation: none !important;
  }
}

/* ============================================================
   GLOBAL BUTTON COLOR OVERRIDES
   Keep primary CTAs consistent across pages and templates.
   ============================================================ */
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).bg-slate-900,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).bg-slate-700,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).bg-indigo-600,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).bg-blue-600,
.btn-primary,
.db-btn-primary,
.builder-btn-primary {
  background: var(--button-primary) !important;
  border-color: var(--button-primary) !important;
  color: #ffffff !important;
}

:is(button, a, input[type="button"], input[type="submit"], [role="button"]).hover\:bg-black:hover,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).hover\:bg-slate-800:hover,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).hover\:bg-indigo-700:hover,
:is(button, a, input[type="button"], input[type="submit"], [role="button"]).hover\:bg-blue-700:hover,
.btn-primary:hover,
.db-btn-primary:hover,
.builder-btn-primary:hover {
  background: var(--button-primary-hover) !important;
  border-color: var(--button-primary-hover) !important;
}

.btn-secondary,
.db-btn-secondary,
.builder-btn-secondary {
  background: var(--button-secondary) !important;
  border-color: var(--button-secondary) !important;
  color: #ffffff !important;
}

.btn-secondary:hover,
.db-btn-secondary:hover,
.builder-btn-secondary:hover {
  background: var(--button-secondary-hover) !important;
  border-color: var(--button-secondary-hover) !important;
}

/* ============================================================
   MOBILE TABS (scrollable)
   ============================================================ */
.mobile-tabs-nowrap {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  padding-bottom: 2px;
}

.mobile-tabs-nowrap > * {
  flex: 0 0 auto;
}

/* ============================================================
   PAGE INTRO CARD
   ============================================================ */
.ea-page-intro-card {
  margin-bottom: 24px;
  padding: 14px 16px;
  background: #ffffff;
  border: 1px solid var(--divider);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}

.ea-page-intro-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.ea-page-intro-copy {
  min-width: 0;
}

.ea-page-intro-title {
  margin: 0;
  color: #0f172a;
  font-size: 1.65rem;
  line-height: 1.15;
  letter-spacing: -0.02em;
  font-weight: 800;
}

.ea-page-intro-description {
  margin-top: 4px;
  margin-bottom: 0;
  color: #64748b;
  font-size: 0.9rem;
}

.ea-page-intro-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.ea-page-intro-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 8px;
  border: 1px solid transparent;
  padding: 9px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  text-decoration: none;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.ea-page-intro-btn--primary {
  background: var(--button-primary);
  border-color: var(--button-primary);
  color: #ffffff;
}

.ea-page-intro-btn--primary:hover {
  background: var(--button-primary-hover);
  border-color: var(--button-primary-hover);
  color: #ffffff;
}

.ea-page-intro-btn--secondary {
  background: #f1f5f9;
  border-color: #e2e8f0;
  color: #1e293b;
}

.ea-page-intro-btn--secondary:hover {
  background: #e2e8f0;
  border-color: #cbd5e1;
  color: #0f172a;
}

@media (max-width: 768px) {
  .ea-page-intro-card {
    padding: 12px;
    margin-bottom: 18px;
  }

  .ea-page-intro-head {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }

  .ea-page-intro-actions {
    width: 100%;
    order: 2;
  }

  .ea-page-intro-actions .ea-page-intro-btn {
    width: 100%;
  }

  .ea-page-intro-title {
    font-size: 1.25rem;
  }

  .ea-page-intro-description {
    font-size: 0.85rem;
  }
}

/* ============================================================
   PRO MODE: TOP NAVIGATION BAR
   Replaces sidebar + header with single horizontal nav (~56px)
   ============================================================ */

/* --- Hide sidebar & old header in Pro mode --- */
body.pro-ui .sidebar {
  display: none;
}

body.pro-ui .main-wrapper {
  margin-left: 0;
  margin-right: 0;
}

body.pro-ui header {
  display: none;
}

body.pro-ui.non-dashboard-page main {
  padding-top: 12px;
}

/* --- Top Nav Bar (Madlan-style) --- */
.pro-topnav {
  display: none;
  position: sticky;
  top: 0;
  z-index: 1000;
  height: 60px;
  background: #ffffff;
  border-bottom: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
  padding: 0 24px;
  align-items: center;
  gap: 0;
}

body.pro-ui .pro-topnav {
  display: flex;
}

/* Logo */
.pro-topnav-logo {
  flex-shrink: 0;
}

.pro-topnav-logo a {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  white-space: nowrap;
}

.pro-topnav-logo a span {
  font-size: 17px;
  font-weight: 700;
  color: #1a1a2e;
  letter-spacing: -0.02em;
}

.pro-topnav-logo .brand-mark {
  width: 22px;
  height: 22px;
  color: #2563EB;
}

/* Nav links — near logo with breathing room */
.pro-topnav-center {
  display: flex;
  align-items: center;
  gap: 0;
  height: 100%;
  margin-inline-start: 28px;
}

/* Nav links — Madlan style: text-only, bottom-border active */
.pro-topnav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 16px;
  height: 100%;
  font-size: 15px;
  font-weight: 500;
  color: #6b7280;
  text-decoration: none;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: color 0.15s ease, border-color 0.15s ease;
  white-space: nowrap;
  font-family: var(--font-ui);
  position: relative;
}

.pro-topnav-link i {
  font-size: 15px;
  opacity: 0.65;
}

.pro-topnav-link:hover {
  color: #1a1a2e;
  background: transparent;
}

.pro-topnav-link.active {
  color: #2563EB;
  font-weight: 600;
  border-bottom-color: #2563EB;
  background: transparent;
}

.pro-topnav-link.active i {
  opacity: 1;
}

.pro-topnav-chevron {
  font-size: 10px !important;
  opacity: 0.45 !important;
  margin-left: 2px;
  margin-right: 2px;
}

/* Dropdown */
.pro-topnav-dropdown {
  position: relative;
  height: 100%;
  display: flex;
  align-items: center;
}

.pro-topnav-dropdown-menu {
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%);
  min-width: 200px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.08);
  padding: 6px;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease;
  z-index: 1010;
}

.pro-topnav-dropdown:hover .pro-topnav-dropdown-menu,
.pro-topnav-dropdown:focus-within .pro-topnav-dropdown-menu {
  opacity: 1;
  visibility: visible;
}

.pro-topnav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  border-radius: 8px;
  transition: background 0.12s ease;
  font-weight: 500;
}

.pro-topnav-dropdown-item i {
  font-size: 15px;
  opacity: 0.55;
  width: 18px;
  text-align: center;
}

.pro-topnav-dropdown-item:hover {
  background: #f5f7fa;
  color: #1a1a2e;
}

.pro-topnav-dropdown-item.active {
  font-weight: 600;
  color: #2563EB;
  background: rgba(37, 99, 235, 0.06);
}

/* End section */
.pro-topnav-end {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
  margin-inline-start: auto;
}

/* Mode switch (compact) */
.pro-topnav-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  background: #f5f7fa;
}

.pro-topnav-mode-pill {
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #9ca3af;
  text-decoration: none;
  transition: all 0.15s ease;
}

.pro-topnav-mode-pill:hover {
  color: #374151;
}

.pro-topnav-mode-pill.active {
  color: #1a1a2e;
  background: #ffffff;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

/* Hamburger (mobile only) */
.pro-topnav-hamburger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  border-radius: 6px;
  color: #374151;
  font-size: 20px;
  cursor: pointer;
}

.pro-topnav-hamburger:hover {
  background: #eef2f7;
}

/* --- Pro mode mobile --- */
@media (max-width: 768px) {
  body.pro-ui.non-dashboard-page main {
    padding-top: 8px;
  }

  body.pro-ui .pro-topnav {
    padding: 0 12px;
    height: 48px;
    justify-content: space-between;
  }

  .pro-topnav-center,
  .pro-topnav-end {
    display: none;
  }

  .pro-topnav-hamburger {
    display: inline-flex;
  }

  /* In Pro mobile, sidebar is hidden by default but usable as drawer */
  body.pro-ui .sidebar {
    display: flex;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    z-index: 1100;
    width: 260px;
  }

  body.pro-ui .sidebar.mobile-open {
    transform: translateX(0);
  }

  body.pro-ui main {
    padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
}

/* --- Pro mode RTL --- */
html[dir="rtl"] body.pro-ui .main-wrapper {
  margin-left: 0;
  margin-right: 0;
}

@media (max-width: 768px) {
  html[dir="rtl"] body.pro-ui .sidebar {
    transform: translateX(100%);
  }

  html[dir="rtl"] body.pro-ui .sidebar.mobile-open {
    transform: translateX(0);
  }
}
