/* =====================================================
   Ministry of Energy - Fuel Station Compliance Portal
   Light theme matching ministry design language
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@300;400;500;600;700&family=Cairo:wght@600;700;800;900&display=swap');

:root {
  --primary: #064E36;
  --primary-light: #0B7A50;
  --primary-dark: #033123;
  --primary-soft: #EBF3EF;
  --accent: #D4A62A;
  --accent-light: #E5C158;
  --accent-dark: #A87E15;
  --bg: #F4F6F5;
  --bg-card: #FFFFFF;
  --bg-card2: #F7F8F8;
  --bg-sidebar: #FFFFFF;
  --border: rgba(6, 78, 54, 0.16);
  --border-light: rgba(30, 41, 36, 0.08);
  --text-primary: #1F2A25;
  --text-secondary: #51605A;
  --text-muted: #79857F;
  --success: #16A34A;
  --warning: #D97706;
  --danger: #DC2626;
  --orange: #EA580C;
  --blue: #2563EB;
  --font-display: 'Cairo', 'IBM Plex Sans Arabic', sans-serif;
  --sidebar-width: 280px;
  --header-height: 72px;
  --shadow-sm: 0 1px 3px rgba(20, 35, 28, 0.06), 0 1px 2px rgba(20, 35, 28, 0.04);
  --shadow-md: 0 6px 18px rgba(20, 35, 28, 0.08);
  --shadow-lg: 0 18px 45px rgba(20, 35, 28, 0.16);
}

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

html {
  direction: rtl;
  max-width: 100%;
  overflow-x: hidden;
}

body {
  font-family: 'IBM Plex Sans Arabic', 'Cairo', sans-serif;
  background-color: #043826;
  background-image:
    url("data:image/svg+xml,%3Csvg width='48' height='48' viewBox='0 0 48 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 24 L24 0 L48 24 L24 48 Z' fill='none' stroke='rgba(255,255,255,0.03)' stroke-width='1'/%3E%3C/svg%3E"),
    linear-gradient(170deg, #022218 0%, #043826 45%, #075137 100%);
  color: var(--text-primary);
  min-height: 100vh;
  max-width: 100%;
  overflow-x: hidden;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(6,78,54,0.35); border-radius: 3px; }

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  position: relative;
}

/* soft glow behind the card to lift it off the dark background */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse 70% 55% at 50% 40%, rgba(212, 166, 42, 0.12), transparent 70%);
  pointer-events: none;
}

.login-container {
  background: linear-gradient(180deg, #FFFFFF 0%, #FBFCFB 100%);
  border: 1px solid rgba(6, 78, 54, 0.10);
  border-radius: 26px;
  padding: 2.6rem 2.4rem;
  width: 100%;
  max-width: 430px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(2, 24, 16, 0.45), 0 2px 8px rgba(2, 24, 16, 0.15);
  z-index: 1;
}

/* gold accent bar across the top of the card */
.login-container::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--accent-dark), var(--accent-light), var(--accent-dark));
}

.login-logo {
  text-align: center;
  margin-bottom: 1.75rem;
}

.login-logo img { display: block; margin: 0 auto; }

.login-logo .org-name {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 0.7rem;
  letter-spacing: 0.3px;
}

.login-logo .org-name-en {
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 3.5px;
  color: var(--accent-dark);
  margin-top: 3px;
}

.login-logo .platform-name {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.65;
  margin: 0.95rem auto 0;
  padding-top: 0.9rem;
  max-width: 290px;
  border-top: 1px solid var(--border-light);
}

.login-logo .platform-sub {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 0.35rem;
  letter-spacing: 0.5px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  color: var(--primary);
  font-size: 0.8rem;
  font-weight: 700;
}
.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
}

.form-group .input-wrap {
  position: relative;
}

.form-group .input-wrap .input-icon {
  position: absolute;
  top: 50%;
  right: 1rem;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 1rem;
}

.form-group input {
  width: 100%;
  background: #F1F5F3;
  border: 1px solid rgba(6, 78, 54, 0.14);
  border-radius: 12px;
  padding: 0.85rem 2.75rem 0.85rem 1rem;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 16px; /* >=16px prevents iOS zooming/jumping on focus */
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
  text-align: right;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(6,78,54,0.12);
}

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

.btn-login {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  border: none;
  border-radius: 12px;
  padding: 0.9rem;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.25s;
  margin-top: 0.5rem;
}

.btn-login:hover { box-shadow: 0 8px 20px rgba(6,78,54,0.3); transform: translateY(-1px); }
.btn-login:active { transform: translateY(0); }
.btn-login:disabled { opacity: 0.7; cursor: wait; }

.login-footer {
  text-align: center;
  margin-top: 2rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ===== APP LAYOUT ===== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR (off-canvas drawer) ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-left: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  height: 100dvh; /* account for mobile browser toolbars so the footer isn't cut off */
  z-index: 300;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  box-shadow: none;
}

.sidebar.open {
  transform: translateX(0);
  box-shadow: -12px 0 40px rgba(15,40,30,0.18);
}

/* keep scrolling inside the open drawer; don't let it chain to the page */
.sidebar { overscroll-behavior: contain; }

/* lock the page behind the open drawer */
body.sidebar-locked { overflow: hidden; }

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 18, 0.45);
  backdrop-filter: blur(2px);
  z-index: 250;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}

.sidebar-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.sidebar-header {
  position: relative;
  padding: 1.5rem 1.1rem 1.2rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.6rem;
  background: linear-gradient(160deg, var(--primary-dark), var(--primary));
}

.sidebar-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 14px rgba(0,0,0,0.28);
  overflow: hidden;
}

.sidebar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.sidebar-header .brand {
  flex: none;
  max-width: 230px;
}

.sidebar-header .brand-name {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 800;
  color: #fff;
  line-height: 1.5;
}

.sidebar-header .brand-sub {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: rgba(255,255,255,0.78);
  margin-top: 2px;
}

.sidebar-close {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.sidebar-close:hover { background: rgba(255,255,255,0.25); }

.sidebar-nav {
  flex: 1 1 auto;
  min-height: 0;
  padding: 1rem 0.85rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

.nav-section-title {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0.5rem 0.75rem;
  margin-top: 1rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s;
  margin-bottom: 3px;
  position: relative;
  cursor: pointer;
}

.nav-item:hover {
  background: var(--primary-soft);
  color: var(--primary);
}

.nav-item.active {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 4px 12px rgba(6,78,54,0.3);
}

.nav-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.nav-icon svg { width: 19px; height: 19px; }

.nav-badge {
  margin-right: auto;
  background: var(--accent);
  color: #fff;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
}

.nav-item.active .nav-badge { background: rgba(255,255,255,0.25); }

.nav-item.coming-soon {
  opacity: 0.45;
  cursor: not-allowed;
}

/* ===== TEAM BOX (sidebar) ===== */
.team-box {
  margin: 1.25rem 0.4rem 0.5rem;
  background: linear-gradient(160deg, var(--primary-soft), #ffffff);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem;
  box-shadow: var(--shadow-sm);
}

.team-box-title {
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 0.7rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.team-box-title svg { width: 15px; height: 15px; flex-shrink: 0; }

.team-members {
  display: flex;
  gap: 0.5rem;
}

.team-member {
  flex: 1;
  background: #fff;
  border: 1px solid var(--border-light);
  border-radius: 11px;
  padding: 0.65rem 0.4rem;
  text-align: center;
}

.team-member .tm-name {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-primary);
}

.team-supervisor {
  margin-top: 0.7rem;
  padding-top: 0.6rem;
  border-top: 1px dashed var(--border);
  font-size: 0.66rem;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
  line-height: 1.6;
}

.sidebar-footer {
  flex-shrink: 0;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--bg-card2);
}

.user-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.user-info .user-name {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-primary);
}

.user-info .user-role {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.btn-logout {
  background: #fff;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  border-radius: 8px;
  padding: 0.35rem 0.7rem;
  cursor: pointer;
  font-size: 0.75rem;
  font-family: inherit;
  font-weight: 600;
  margin-right: auto;
  transition: all 0.2s;
}

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

/* ===== MAIN CONTENT ===== */
.main-content {
  margin-right: 0;
  flex: 1;
  min-height: 100vh;
  min-width: 0;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
}

/* ===== TOP BAR (blends into the green background) ===== */
.topbar {
  min-height: var(--header-height);
  background: rgba(11, 54, 38, 0.75);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  padding: 0.6rem 1.25rem;
  padding-top: calc(0.6rem + env(safe-area-inset-top));
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.menu-btn {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.18);
  color: #fff;
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  font-size: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}

.menu-btn:hover { background: rgba(255,255,255,0.22); }

/* Official ministry logo (used as-is) on a white disc so it reads on the dark bar */
.topbar-logo {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(0,0,0,0.25);
  overflow: hidden;
}

.topbar-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.topbar-title {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 900;
  color: #fff;
  flex: 1;
  min-width: 0;
  line-height: 1.25;
  letter-spacing: -0.2px;
}

.topbar-title span {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  color: rgba(255,255,255,0.78);
  font-weight: 500;
  font-size: 0.84rem;
  display: block;
  letter-spacing: 0;
  margin-top: 1px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.topbar-date {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.85);
  background: rgba(255,255,255,0.1);
  padding: 0.4rem 0.8rem;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.15);
}

/* ===== PAGE CONTENT ===== */
.page-content {
  flex: 1;
  padding: 1.5rem 1.25rem;
  overflow-y: auto;
  max-width: min(1400px, 100vw);
  width: 100%;
  min-width: 0;
  margin: 0 auto;
}

/* ===== STATS CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: linear-gradient(158deg, #FFFFFF 0%, #F5FAF7 100%);
  border: 1px solid rgba(6, 78, 54, 0.09);
  border-radius: 18px;
  padding: 1.15rem 1.3rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.22s ease, box-shadow 0.22s ease;
  box-shadow: 0 1px 3px rgba(2, 24, 16, 0.04), 0 10px 24px rgba(2, 24, 16, 0.05);
}

.stat-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 12px rgba(2, 24, 16, 0.07), 0 18px 38px rgba(2, 24, 16, 0.10);
}

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

.stat-label {
  font-size: 0.74rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 1.7rem;
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.5px;
  white-space: nowrap;
}

.stat-value.green { color: var(--primary-light); }
.stat-value.gold { color: #B45309; }
.stat-value.red { color: var(--danger); }
.stat-value.blue { color: #1D4ED8; }
.stat-value.navy { color: #1E3A8A; }
.stat-value.gray { color: #475569; }

.stat-sub {
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg { width: 24px; height: 24px; }

/* solid gradient badges with white glyphs — each hue matches its value text */
.stat-icon.green { background: linear-gradient(145deg, #0E8C5C, #075137); color: #fff; box-shadow: 0 6px 16px rgba(6, 78, 54, 0.32); }
.stat-icon.gold { background: linear-gradient(145deg, #D9870B, #B45309); color: #fff; box-shadow: 0 6px 16px rgba(180, 83, 9, 0.32); }
.stat-icon.red { background: linear-gradient(145deg, #E8615F, #C0392B); color: #fff; box-shadow: 0 6px 16px rgba(192, 57, 43, 0.30); }
.stat-icon.blue { background: linear-gradient(145deg, #3B6FE5, #1D4ED8); color: #fff; box-shadow: 0 6px 16px rgba(29, 78, 216, 0.30); }
.stat-icon.navy { background: linear-gradient(145deg, #2B4DA0, #15296B); color: #fff; box-shadow: 0 6px 16px rgba(30, 58, 138, 0.30); }
.stat-icon.gray { background: linear-gradient(145deg, #64748B, #334155); color: #fff; box-shadow: 0 6px 16px rgba(71, 85, 105, 0.28); }

/* coloured spine on the start (right in RTL) edge, matching each card */
.stat-card::before {
  content: '';
  position: absolute;
  top: 0; bottom: 0; right: 0;
  width: 5px;
  border-radius: 0 18px 18px 0;
}
.stat-card:has(.stat-icon.green)::before { background: linear-gradient(180deg, #0E8C5C, #075137); }
.stat-card:has(.stat-icon.gold)::before { background: linear-gradient(180deg, #D9870B, #B45309); }
.stat-card:has(.stat-icon.red)::before { background: linear-gradient(180deg, #E8615F, #C0392B); }
.stat-card:has(.stat-icon.blue)::before { background: linear-gradient(180deg, #3B6FE5, #1D4ED8); }
.stat-card:has(.stat-icon.navy)::before { background: linear-gradient(180deg, #2B4DA0, #15296B); }
.stat-card:has(.stat-icon.gray)::before { background: linear-gradient(180deg, #64748B, #334155); }

/* ===== GRID LAYOUTS ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.25rem;
  margin-bottom: 1.25rem;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

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

.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-title-icon {
  width: 30px;
  height: 30px;
  border-radius: 9px;
  background: var(--primary-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--primary);
  font-size: 0.9rem;
  flex-shrink: 0;
}

.card-title-icon svg { width: 16px; height: 16px; }

.card-body {
  padding: 1.25rem;
}

/* ===== CHARTS ===== */
/* LTR keeps Chart.js axis layout correct inside the RTL page (no dead space).
   Hard clamps stop the canvas from ever expanding the page on iOS Safari. */
.chart-container {
  position: relative;
  direction: ltr;
  max-width: 100%;
  overflow: hidden;
}

.chart-container canvas {
  max-width: 100% !important;
}

canvas { max-width: 100%; }

/* ===== COMPANY TABLE ===== */
.company-table {
  width: 100%;
  border-collapse: collapse;
}

.company-table th {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-align: right;
  padding: 0.6rem 0.75rem;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card2);
}

.company-table td {
  padding: 0.7rem 0.75rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.company-table tr:hover td {
  background: var(--primary-soft);
}

.compliance-bar-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.compliance-bar {
  flex: 1;
  height: 6px;
  background: rgba(15,40,30,0.08);
  border-radius: 3px;
  overflow: hidden;
}

.compliance-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 1s ease;
}

.compliance-pct {
  font-size: 0.8rem;
  font-weight: 700;
  min-width: 38px;
  text-align: left;
}

/* ===== BADGE ===== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
}

.badge-success { background: rgba(22,163,74,0.12); color: #15803D; border: 1px solid rgba(22,163,74,0.3); }
.badge-warning { background: rgba(217,119,6,0.12); color: #B45309; border: 1px solid rgba(217,119,6,0.32); }
.badge-danger { background: rgba(220,38,38,0.1); color: #B91C1C; border: 1px solid rgba(220,38,38,0.28); }
.badge-orange { background: rgba(234,88,12,0.12); color: #C2410C; border: 1px solid rgba(234,88,12,0.3); }
.badge-blue { background: rgba(37,99,235,0.1); color: #1D4ED8; border: 1px solid rgba(37,99,235,0.25); }

/* ===== STATIONS TABLE ===== */
.stations-table {
  width: 100%;
  border-collapse: collapse;
}

.stations-table th {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0.6rem 0.75rem;
  text-align: right;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-card2);
  white-space: nowrap;
}

.stations-table td {
  padding: 0.65rem 0.75rem;
  font-size: 0.82rem;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

.stations-table tr:hover td {
  background: var(--primary-soft);
  cursor: pointer;
}

.station-name {
  font-weight: 600;
  color: var(--text-primary);
  max-width: 180px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== MAP PAGE ===== */
#map-container {
  height: 500px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

#heatmap-container {
  height: 600px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border-light);
}

.leaflet-container {
  background: #E8ECEA !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
}

/* ===== STATION POPUP ===== */
.station-popup {
  position: fixed;
  inset: 0;
  background: rgba(10, 25, 18, 0.5);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.station-popup-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 20px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.station-popup-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  background: var(--bg-card);
  z-index: 1;
}

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

.station-popup-company {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

.btn-close {
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: all 0.2s;
  flex-shrink: 0;
}

.btn-close:hover {
  border-color: var(--danger);
  color: var(--danger);
}

.station-popup-body {
  padding: 1.5rem;
}

.compliance-circle-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.compliance-circle {
  position: relative;
  width: 120px;
  height: 120px;
}

.compliance-circle svg {
  transform: rotate(-90deg);
}

.compliance-circle-text {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.compliance-circle-pct {
  font-size: 1.5rem;
  font-weight: 700;
}

.compliance-circle-label {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.score-categories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.score-cat {
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  border-radius: 12px;
  padding: 0.75rem;
}

.score-cat-label {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.score-cat-bar {
  height: 6px;
  background: rgba(15,40,30,0.08);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.3rem;
}

.score-cat-fill {
  height: 100%;
  border-radius: 3px;
}

.score-cat-value {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-primary);
}

.licenses-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-bottom: 1.25rem;
}

.license-item {
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  border-radius: 10px;
  padding: 0.6rem 0.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.license-name {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 600;
}

.license-status {
  font-size: 0.7rem;
  font-weight: 700;
  white-space: nowrap;
}

.status-valid { color: #0C7A4B; }
.status-invalid { color: #C53030; }
.status-expired { color: #9C7314; }

.notes-box {
  background: #FBF6EC;
  border-radius: 12px;
  padding: 0.85rem;
  font-size: 0.82rem;
  color: #6E5A33;
  line-height: 1.6;
  border: 1px solid rgba(212,166,42,0.3);
}

.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: 0.3px;
  margin-bottom: 0.6rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-light);
}

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

.filter-select {
  background: #EEF3F1;
  border: 1px solid rgba(6, 78, 54, 0.22);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  min-width: 160px;
}

.filter-select:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 78, 54, 0.12);
}

.search-input {
  background: #EEF3F1;
  border: 1px solid rgba(6, 78, 54, 0.22);
  border-radius: 10px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.82rem;
  padding: 0.5rem 1rem;
  flex: 1;
  max-width: 280px;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  background: #fff;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6, 78, 54, 0.12);
}

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

/* ===== LEAFLET CUSTOM ===== */
.leaflet-popup-content-wrapper {
  background: #fff !important;
  color: var(--text-primary) !important;
  border: 1px solid var(--border-light) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-lg) !important;
  font-family: 'IBM Plex Sans Arabic', sans-serif !important;
  direction: rtl;
}

.leaflet-popup-tip {
  background: #fff !important;
}

.leaflet-popup-close-button {
  color: var(--text-muted) !important;
  font-size: 18px !important;
  top: 8px !important;
  left: 8px !important;
  right: auto !important;
}

.map-popup {
  padding: 0.25rem;
  min-width: 200px;
}

.map-popup-title {
  font-size: 0.9rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
}

.map-popup-company {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.map-popup-pct {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 0.3rem;
}

.map-popup-city {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.map-popup-btn {
  background: var(--primary);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-family: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  margin-top: 0.5rem;
  width: 100%;
  font-weight: 700;
}

.map-popup-btn:hover { background: var(--primary-light); }

/* ===== LEGEND ===== */
.map-legend {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: 14px;
  padding: 1rem;
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  color: var(--text-secondary);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border-light);
  flex-wrap: wrap;
  gap: 0.5rem;
}

.pagination-info {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.pagination-controls {
  display: flex;
  gap: 0.4rem;
}

.page-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border-light);
  color: var(--text-secondary);
  border-radius: 8px;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: all 0.2s;
}

.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: white; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

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

@media (max-width: 900px) {
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 0.65rem; }
  .page-content { padding: 1rem 0.85rem; }
  .topbar { padding: 0.55rem 0.85rem; padding-top: calc(0.55rem + env(safe-area-inset-top)); }
  .topbar-date, .topbar-chip { display: none !important; }
  .topbar-logo { width: 38px; height: 38px; }
  .topbar-title { font-size: 1.2rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .topbar-title span { font-size: 0.7rem; }
  .menu-btn { width: 38px; height: 38px; }
  .stat-card { padding: 0.85rem 0.9rem; gap: 0.7rem; border-radius: 14px; }
  .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
  .stat-icon svg { width: 20px; height: 20px; }
  .stat-value { font-size: 1.35rem; }
  .stat-label { font-size: 0.68rem; }
  .stat-sub { display: none; }
  .card { border-radius: 14px; }
  .card-header { padding: 0.85rem 1rem; }
  .card-body { padding: 1rem; }
  .card-header .search-input,
  .card-header .filter-select { font-size: 0.78rem; }
}

/* ===== MOBILE OPTIMIZATION ===== */
@media (max-width: 700px) {
  /* Maps smaller */
  #map-container, #heatmap-container { height: 380px !important; }

  /* Card headers stack: title above, filters/search full width below */
  .card-header { flex-direction: column; align-items: stretch; gap: 0.6rem; }
  .card-header .search-input,
  .card-header .filter-select { max-width: 100%; width: 100%; min-width: 0 !important; }
  .card-header > div[style*="display:flex"] { width: 100%; }

  /* Dashboard visits table: keep name / city / compliance / status only */
  .visits-table th:nth-child(1), .visits-table td:nth-child(1),
  .visits-table th:nth-child(3), .visits-table td:nth-child(3),
  .visits-table th:nth-child(5), .visits-table td:nth-child(5),
  .visits-table th:nth-child(6), .visits-table td:nth-child(6),
  .visits-table th:nth-child(7), .visits-table td:nth-child(7),
  .visits-table th:nth-child(8), .visits-table td:nth-child(8),
  .visits-table th:nth-child(11), .visits-table td:nth-child(11) { display: none; }

  /* Company table: hide index and status (bar already shows it) */
  .company-table th:nth-child(1), .company-table td:nth-child(1),
  .company-table th:nth-child(5), .company-table td:nth-child(5) { display: none; }

  /* Companies-map stations list: hide index and date */
  .cmap-table th:nth-child(1), .cmap-table td:nth-child(1),
  .cmap-table th:nth-child(6), .cmap-table td:nth-child(6) { display: none; }

  .station-name { max-width: 130px; }
  .stations-table td, .stations-table th,
  .company-table td, .company-table th { padding: 0.55rem 0.5rem; font-size: 0.78rem; }

  /* Station popup */
  .station-popup { padding: 0.5rem; align-items: flex-end; }
  .station-popup-card { border-radius: 18px 18px 0 0; max-height: 92vh; }
  .station-popup-body { padding: 1rem; }
  .station-popup-header { padding: 1rem; }
  .score-categories, .licenses-grid { grid-template-columns: 1fr 1fr; gap: 0.5rem; }

  /* Pagination centered, wrapping */
  .pagination { justify-content: center; }
  .pagination-info { width: 100%; text-align: center; order: 2; }
  .pagination-controls { flex-wrap: wrap; justify-content: center; }

  /* Compliance bars narrower */
  .compliance-bar-wrap { min-width: 0 !important; }

  /* 16px form controls also block iOS focus auto-zoom */
  input, select, textarea { font-size: 16px !important; }
}

@media (max-width: 380px) {
  .stats-grid { grid-template-columns: 1fr; }
  .score-categories, .licenses-grid { grid-template-columns: 1fr; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeInUp 0.4s ease forwards; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-state-text {
  font-size: 0.9rem;
}
