/* =====================================================================
   SWM Portal - Main Stylesheet
   Design System: Navy #1a2332, Blue #1e88e5, Teal #00acc1, Amber #ffb300
   ===================================================================== */

:root {
  --navy:        #1a2332;
  --navy-light:  #243447;
  --navy-dark:   #111827;
  --blue:        #1e88e5;
  --blue-light:  #42a5f5;
  --blue-dark:   #1565c0;
  --teal:        #00acc1;
  --teal-light:  #26c6da;
  --amber:       #ffb300;
  --amber-light: #ffc107;
  --white:       #ffffff;
  --gray-50:     #f8fafc;
  --gray-100:    #f1f5f9;
  --gray-200:    #e2e8f0;
  --gray-300:    #cbd5e1;
  --gray-400:    #94a3b8;
  --gray-500:    #64748b;
  --gray-600:    #475569;
  --gray-700:    #334155;
  --gray-800:    #1e293b;
  --gray-900:    #0f172a;
  --success:     #22c55e;
  --danger:      #ef4444;
  --warning:     #f59e0b;
  --info:        #06b6d4;
  --sidebar-w:   260px;
  --topbar-h:    60px;
  --radius:      8px;
  --radius-lg:   12px;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow:      0 4px 12px rgba(0,0,0,.15);
  --shadow-lg:   0 8px 24px rgba(0,0,0,.18);
  --transition:  all .2s ease;
}

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

html { font-size: 14px; scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--blue); text-decoration: none; }
a:hover { color: var(--blue-dark); }

/* ── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--gray-100); }
::-webkit-scrollbar-thumb { background: var(--gray-300); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--gray-400); }

/* ── Layout ─────────────────────────────────────── */
.app-layout { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--sidebar-w);
  background: var(--navy);
  color: var(--white);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 100;
  transition: transform .2s ease, width .2s ease;
  overflow: hidden;
}

/* ── Sidebar Collapsed (icons only, no text) ── */
.sidebar.sidebar-collapsed {
  width: 64px;
}
.sidebar.sidebar-collapsed .sidebar-brand-text,
.sidebar.sidebar-collapsed .sidebar-tenant,
.sidebar.sidebar-collapsed .nav-item span,
.sidebar.sidebar-collapsed .nav-section-title,
.sidebar.sidebar-collapsed .sidebar-user > div:last-child,
.sidebar.sidebar-collapsed .sidebar-brand-sub {
  display: none;
}
.sidebar.sidebar-collapsed .sidebar-brand {
  padding: 16px 14px;
  justify-content: center;
}
.sidebar.sidebar-collapsed .sidebar-brand-logo {
  margin: 0;
}
.sidebar.sidebar-collapsed .sidebar-footer {
  padding: 12px 14px;
  display: flex;
  justify-content: center;
}
.sidebar.sidebar-collapsed .sidebar-user {
  justify-content: center;
}
.sidebar.sidebar-collapsed .nav-item {
  justify-content: center;
  padding: 10px 14px;
}
.sidebar.sidebar-collapsed .nav-item svg {
  width: 20px;
  height: 20px;
}
.sidebar.sidebar-collapsed .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 8px;
  min-width: 14px;
  padding: 0 4px;
  line-height: 14px;
}
.sidebar.sidebar-collapsed ~ .main-content {
  margin-left: 64px;
}

/* ── Sidebar Expanded (always full width) ── */
.sidebar.sidebar-expanded {
  width: var(--sidebar-w);
}
.sidebar.sidebar-expanded ~ .main-content {
  margin-left: var(--sidebar-w);
}

/* ── Sidebar Hover Mode (collapsed by default, expands on hover) ── */
.sidebar.sidebar-hover-mode {
  width: 64px;
  transition: width .2s ease, transform .2s ease;
}
.sidebar.sidebar-hover-mode .sidebar-brand-text,
.sidebar.sidebar-hover-mode .sidebar-tenant,
.sidebar.sidebar-hover-mode .nav-item span,
.sidebar.sidebar-hover-mode .nav-section-title,
.sidebar.sidebar-hover-mode .sidebar-user > div:last-child,
.sidebar.sidebar-hover-mode .sidebar-brand-sub {
  display: none;
}
.sidebar.sidebar-hover-mode .sidebar-brand {
  padding: 16px 14px;
  justify-content: center;
}
.sidebar.sidebar-hover-mode .sidebar-brand-logo {
  margin: 0;
}
.sidebar.sidebar-hover-mode .sidebar-footer {
  padding: 12px 14px;
  display: flex;
  justify-content: center;
}
.sidebar.sidebar-hover-mode .sidebar-user {
  justify-content: center;
}
.sidebar.sidebar-hover-mode .nav-item {
  justify-content: center;
  padding: 10px 14px;
}
.sidebar.sidebar-hover-mode .nav-item svg {
  width: 20px;
  height: 20px;
}
.sidebar.sidebar-hover-mode .nav-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  font-size: 8px;
  min-width: 14px;
  padding: 0 4px;
  line-height: 14px;
}
.sidebar.sidebar-hover-mode ~ .main-content {
  margin-left: 64px;
}

/* Hover active state - full width */
.sidebar.sidebar-hover-mode.sidebar-hover-active {
  width: var(--sidebar-w);
  z-index: 101;
  box-shadow: 4px 0 16px rgba(0,0,0,0.2);
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-brand-text,
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-tenant,
.sidebar.sidebar-hover-mode.sidebar-hover-active .nav-item span,
.sidebar.sidebar-hover-mode.sidebar-hover-active .nav-section-title,
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-user > div:last-child,
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-brand-sub {
  display: block;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-brand {
  padding: 20px 20px 16px;
  justify-content: flex-start;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-brand-logo {
  margin: 0;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-footer {
  padding: 16px 20px;
  display: block;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .sidebar-user {
  justify-content: flex-start;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .nav-item {
  justify-content: flex-start;
  padding: 9px 20px;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .nav-item svg {
  width: 18px;
  height: 18px;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active .nav-badge {
  position: static;
  font-size: 10px;
  min-width: 18px;
  padding: 1px 6px;
  line-height: 16px;
}
.sidebar.sidebar-hover-mode.sidebar-hover-active ~ .main-content {
  margin-left: 64px;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 36px; height: 36px;
  background: var(--blue);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: white; flex-shrink: 0;
}

.sidebar-brand-text { overflow: hidden; }
.sidebar-brand-name { font-size: 15px; font-weight: 700; letter-spacing: .3px; white-space: nowrap; }
.sidebar-brand-sub  { font-size: 11px; color: var(--gray-400); white-space: nowrap; }

.sidebar-tenant {
  padding: 12px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(255,255,255,.03);
  flex-shrink: 0;
}
.sidebar-tenant-label { font-size: 10px; text-transform: uppercase; letter-spacing: .8px; color: var(--gray-500); margin-bottom: 2px; }
.sidebar-tenant-name  { font-size: 13px; font-weight: 600; color: var(--teal-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

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

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gray-500);
  padding: 16px 20px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: var(--gray-300);
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  cursor: pointer;
  transition: var(--transition);
  border-left: 3px solid transparent;
  text-decoration: none;
  position: relative;
}

.nav-item:hover {
  background: rgba(255,255,255,.07);
  color: var(--white);
  border-left-color: rgba(30,136,229,.5);
}

.nav-item.active {
  background: rgba(30,136,229,.18);
  color: var(--white);
  border-left-color: var(--blue);
}

.nav-item svg, .nav-item .nav-icon {
  width: 18px; height: 18px;
  opacity: .8;
  flex-shrink: 0;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.sidebar-user-name  { font-size: 13px; font-weight: 600; color: var(--gray-100); }
.sidebar-user-role  { font-size: 11px; color: var(--gray-400); }

/* ── Main Content ────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ─────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  gap: 16px;
  box-shadow: var(--shadow-sm);
}

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

.page-title { font-size: 17px; font-weight: 700; color: var(--gray-800); }

/* Search */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px 14px;
  width: 280px;
  transition: var(--transition);
}
.search-box:focus-within { border-color: var(--blue); background: white; box-shadow: 0 0 0 3px rgba(30,136,229,.1); }
.search-box input { background: none; border: none; outline: none; font-size: 13px; flex: 1; color: var(--gray-700); }
.search-box svg   { color: var(--gray-400); width: 16px; height: 16px; flex-shrink: 0; }

.search-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 400px;
  overflow-y: auto;
  z-index: 200;
  display: none;
}
.search-results.open { display: block; }
.search-result-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--gray-100);
  cursor: pointer; transition: var(--transition);
}
.search-result-item:hover { background: var(--gray-50); }
.search-result-item:last-child { border-bottom: none; }
.search-result-type {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  background: var(--gray-100); color: var(--gray-500);
  padding: 2px 6px; border-radius: 4px; flex-shrink: 0;
}
.search-result-label { font-size: 13px; font-weight: 600; color: var(--gray-800); }
.search-result-sub   { font-size: 11px; color: var(--gray-500); }

/* Icon Buttons */
.icon-btn {
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--gray-500);
  transition: var(--transition);
  position: relative;
}
.icon-btn:hover { background: var(--gray-100); color: var(--gray-700); }
.icon-btn svg { width: 18px; height: 18px; }

.alarm-badge {
  position: absolute;
  top: 4px; right: 4px;
  width: 8px; height: 8px;
  background: var(--danger);
  border-radius: 50%;
  border: 2px solid white;
}
.alarm-badge.has-count {
  width: auto; height: auto;
  padding: 1px 4px;
  font-size: 9px;
  font-weight: 700;
  color: white;
  border-radius: 8px;
  top: 2px; right: 2px;
}

/* ── Page Content ─────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

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

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

.breadcrumb {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--gray-500);
  margin-bottom: 4px;
}
.breadcrumb a { color: var(--gray-500); }
.breadcrumb a:hover { color: var(--blue); }
.breadcrumb-sep { color: var(--gray-300); }

.page-heading { font-size: 22px; font-weight: 700; color: var(--gray-900); line-height: 1.2; }
.page-sub     { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ── Cards ──────────────────────────────────────── */
.card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-title {
  font-size: 15px; font-weight: 700; color: var(--gray-800);
  display: flex; align-items: center; gap: 8px;
}
.card-title svg { color: var(--blue); width: 18px; height: 18px; }

.card-body    { padding: 20px; }
.card-footer  { padding: 14px 20px; border-top: 1px solid var(--gray-100); background: var(--gray-50); display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

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

.stat-card {
  background: white;
  border-radius: var(--radius-lg);
  border: 1px solid var(--gray-200);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: var(--transition);
  box-shadow: var(--shadow-sm);
}
.stat-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon.blue  { background: rgba(30,136,229,.12); color: var(--blue); }
.stat-icon.teal  { background: rgba(0,172,193,.12);  color: var(--teal); }
.stat-icon.amber { background: rgba(255,179,0,.12);  color: var(--amber); }
.stat-icon.green { background: rgba(34,197,94,.12);  color: var(--success); }
.stat-icon.red   { background: rgba(239,68,68,.12);  color: var(--danger); }
.stat-icon.navy  { background: rgba(26,35,50,.10);   color: var(--navy); }

.stat-info { flex: 1; min-width: 0; }
.stat-value { font-size: 26px; font-weight: 800; color: var(--gray-900); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--gray-500); font-weight: 500; margin-top: 2px; white-space: nowrap; }
.stat-change { font-size: 11px; margin-top: 4px; display: flex; align-items: center; gap: 3px; }
.stat-change.up   { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ── Tables ─────────────────────────────────────── */
.table-container { overflow-x: auto; }

table { width: 100%; border-collapse: collapse; }

thead tr { background: var(--gray-50); }
thead th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gray-500);
  border-bottom: 2px solid var(--gray-200);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
}
tbody tr:hover { background: var(--gray-50); }
tbody tr:last-child { border-bottom: none; }

tbody td {
  padding: 12px 14px;
  font-size: 13.5px;
  color: var(--gray-700);
  vertical-align: middle;
}

.table-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--gray-400);
}
.table-empty svg { width: 40px; height: 40px; margin: 0 auto 12px; display: block; opacity: .4; }
.table-empty p { font-size: 14px; }

/* ── Badges ─────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .4px;
  white-space: nowrap;
}
.badge-success  { background: rgba(34,197,94,.12);   color: #15803d; }
.badge-danger   { background: rgba(239,68,68,.12);   color: #dc2626; }
.badge-warning  { background: rgba(245,158,11,.12);  color: #d97706; }
.badge-info     { background: rgba(6,182,212,.12);   color: #0891b2; }
.badge-secondary{ background: rgba(100,116,139,.12); color: var(--gray-600); }
.badge-blue     { background: rgba(30,136,229,.12);  color: var(--blue-dark); }
.badge-navy     { background: rgba(26,35,50,.10);    color: var(--navy); }
.badge-teal     { background: rgba(0,172,193,.12);   color: #0e7490; }
.badge-amber    { background: rgba(255,179,0,.12);   color: #92400e; }

/* Online pulse indicator */
.online-dot {
  width: 8px; height: 8px; border-radius: 50%; background: var(--success); flex-shrink: 0;
  animation: pulse 2s infinite;
}
.offline-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray-300); flex-shrink: 0; }

@keyframes pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(34,197,94,.4); }
  50%       { opacity: .8; box-shadow: 0 0 0 4px rgba(34,197,94,.0); }
}

/* Marker pulse */
@keyframes markerPulse {
  0%   { transform: scale(1); opacity: 1; }
  50%  { transform: scale(1.3); opacity: .7; }
  100% { transform: scale(1); opacity: 1; }
}
.marker-pulse { animation: markerPulse 1.5s infinite; }

/* ── Buttons ─────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 13.5px; font-weight: 600;
  border: none; cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.4;
}
.btn svg { width: 16px; height: 16px; flex-shrink: 0; }

.btn-primary  { background: var(--blue); color: white; }
.btn-primary:hover  { background: var(--blue-dark); color: white; box-shadow: 0 4px 12px rgba(30,136,229,.35); }

.btn-success  { background: var(--success); color: white; }
.btn-success:hover  { background: #16a34a; color: white; }

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

.btn-warning  { background: var(--warning); color: white; }
.btn-warning:hover  { background: #d97706; color: white; }

.btn-secondary{ background: var(--gray-100); color: var(--gray-700); border: 1px solid var(--gray-200); }
.btn-secondary:hover{ background: var(--gray-200); color: var(--gray-800); }

.btn-outline  { background: transparent; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:hover  { background: var(--blue); color: white; }

.btn-sm       { padding: 5px 11px; font-size: 12px; }
.btn-sm svg   { width: 14px; height: 14px; }
.btn-lg       { padding: 11px 22px; font-size: 15px; }
.btn-icon     { padding: 7px; border-radius: var(--radius); }
.btn-icon svg { width: 16px; height: 16px; }

.btn:disabled, .btn[disabled] { opacity: .5; cursor: not-allowed; pointer-events: none; }

/* ── Forms ──────────────────────────────────────── */
.form-group    { margin-bottom: 18px; }
.form-label    { display: block; font-size: 13px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-required { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 13.5px;
  color: var(--gray-800);
  background: white;
  transition: var(--transition);
  outline: none;
  appearance: none;
}
.form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,136,229,.12); }
.form-control::placeholder { color: var(--gray-300); }
.form-control.is-invalid   { border-color: var(--danger); }
.form-control.is-invalid:focus { box-shadow: 0 0 0 3px rgba(239,68,68,.12); }

select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%2394a3b8'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; background-size: 16px; padding-right: 36px; }

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

.form-hint  { font-size: 11.5px; color: var(--gray-500); margin-top: 4px; }
.form-error { font-size: 11.5px; color: var(--danger);   margin-top: 4px; }

.form-check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.form-check input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--blue); cursor: pointer; }
.form-check-label { font-size: 13px; color: var(--gray-700); cursor: pointer; }

.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }

/* ── Alerts/Flash ────────────────────────────────── */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13.5px;
  display: flex; align-items: flex-start; gap: 10px;
  margin-bottom: 16px;
  border-left: 4px solid;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; margin-top: 1px; }
.alert-success { background: #f0fdf4; border-color: var(--success); color: #166534; }
.alert-danger   { background: #fef2f2; border-color: var(--danger);  color: #991b1b; }
.alert-warning  { background: #fffbeb; border-color: var(--warning); color: #92400e; }
.alert-info     { background: #eff6ff; border-color: var(--blue);    color: #1e40af; }

/* ── Pagination ─────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 4px; }
.pagination-btn {
  padding: 6px 12px;
  border: 1.5px solid var(--gray-200);
  background: white; color: var(--gray-600);
  border-radius: var(--radius); font-size: 13px;
  cursor: pointer; transition: var(--transition);
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 4px;
}
.pagination-btn:hover { border-color: var(--blue); color: var(--blue); }
.pagination-btn.active{ background: var(--blue); border-color: var(--blue); color: white; }
.pagination-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Filter Bar ─────────────────────────────────── */
.filter-bar {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end;
  box-shadow: var(--shadow-sm);
}
.filter-group { display: flex; flex-direction: column; gap: 4px; min-width: 160px; }
.filter-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--gray-500); }

/* ── Map ─────────────────────────────────────────── */
.map-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--gray-200);
  box-shadow: var(--shadow-sm);
}
#tracking-map, #history-map { height: 100% !important; }
#geofence-map, #route-map, .leaflet-map {
  height: 520px;
  background: #e8edf0;
}

/* Leaflet tweaks */
.leaflet-control-zoom { border: none !important; box-shadow: var(--shadow) !important; }
.leaflet-control-zoom a {
  background: white !important; color: var(--gray-700) !important;
  border-bottom: 1px solid var(--gray-200) !important;
  font-size: 16px !important;
}
.leaflet-control-zoom a:hover { background: var(--gray-50) !important; }
.leaflet-popup-content-wrapper { border-radius: var(--radius-lg) !important; box-shadow: var(--shadow-lg) !important; border: 1px solid var(--gray-200) !important; }
.leaflet-popup-content { margin: 14px 16px !important; font-size: 13px !important; }
.vehicle-popup-reg  { font-weight: 700; font-size: 15px; color: var(--gray-900); margin-bottom: 6px; }
.vehicle-popup-info { font-size: 12px; color: var(--gray-600); line-height: 1.6; }

/* Vehicle marker */
.vehicle-marker {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: white;
  border: 3px solid var(--blue);
  display: flex; align-items: center; justify-content: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: var(--transition);
}
.vehicle-marker.online    { border-color: var(--success); }
.vehicle-marker.offline   { border-color: var(--gray-400); opacity: .75; }
.vehicle-marker.alarm     { border-color: var(--danger); }
.vehicle-marker.on-trip   { border-color: var(--teal); }
.vehicle-marker svg       { width: 18px; height: 18px; }

/* Map controls overlay */
.map-controls {
  position: absolute;
  top: 12px; right: 12px;
  z-index: 500;
  display: flex; flex-direction: column; gap: 8px;
}
.map-control-btn {
  background: white; border: 1px solid var(--gray-200);
  border-radius: var(--radius); padding: 8px 12px;
  font-size: 12.5px; font-weight: 600; color: var(--gray-700);
  cursor: pointer; transition: var(--transition); box-shadow: var(--shadow-sm);
  display: flex; align-items: center; gap: 6px;
}
.map-control-btn:hover { background: var(--gray-50); box-shadow: var(--shadow); }
.map-control-btn svg   { width: 14px; height: 14px; }

/* History playback */
.playback-bar {
  background: white; border-top: 1px solid var(--gray-200);
  padding: 14px 20px;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
}
.playback-slider { flex: 1; min-width: 200px; accent-color: var(--blue); }
.speed-select    { width: 80px; }
.playback-time   { font-size: 12px; color: var(--gray-600); font-weight: 600; min-width: 150px; }

/* ── Detail Panels ───────────────────────────────── */
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.detail-section { margin-bottom: 24px; }
.detail-section-title {
  font-size: 12px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .7px; color: var(--gray-400);
  border-bottom: 1px solid var(--gray-100); padding-bottom: 8px; margin-bottom: 14px;
}
.detail-row { display: flex; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--gray-50); }
.detail-label { font-size: 12.5px; color: var(--gray-500); min-width: 140px; flex-shrink: 0; }
.detail-value { font-size: 13.5px; color: var(--gray-800); font-weight: 500; }

/* ── Tabs ────────────────────────────────────────── */
.tab-nav { display: flex; border-bottom: 2px solid var(--gray-200); margin-bottom: 20px; gap: 0; }
.tab-btn {
  padding: 10px 18px; font-size: 13.5px; font-weight: 600;
  color: var(--gray-500); border: none; background: none; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -2px; transition: var(--transition);
}
.tab-btn:hover  { color: var(--blue); }
.tab-btn.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-content    { display: none; }
.tab-content.active { display: block; }

/* ── Modal ───────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity .2s ease;
  padding: 20px;
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: white; border-radius: var(--radius-lg);
  width: 100%; max-width: 560px; max-height: 90vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
  transform: translateY(10px);
  transition: transform .2s ease;
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-lg { max-width: 800px; }

.modal-header { padding: 18px 20px 14px; border-bottom: 1px solid var(--gray-100); display: flex; align-items: center; justify-content: space-between; }
.modal-title  { font-size: 16px; font-weight: 700; color: var(--gray-800); }
.modal-body   { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--gray-100); display: flex; justify-content: flex-end; gap: 10px; }
.modal-close  { background: none; border: none; cursor: pointer; color: var(--gray-400); line-height: 0; }
.modal-close:hover { color: var(--gray-600); }
.modal-close svg { width: 20px; height: 20px; }

/* ── Alarm indicators ────────────────────────────── */
.alarm-row-critical { background: rgba(239,68,68,.04) !important; }
.alarm-row-high     { background: rgba(245,158,11,.04) !important; }

/* ── Vehicle status indicators ───────────────────── */
.vehicle-card {
  background: white; border-radius: var(--radius-lg); border: 1px solid var(--gray-200);
  padding: 16px; transition: var(--transition); cursor: pointer;
}
.vehicle-card:hover { box-shadow: var(--shadow); border-color: var(--blue); }
.vehicle-card.selected { border-color: var(--blue); box-shadow: 0 0 0 3px rgba(30,136,229,.12); }

/* ── Expiry countdown ────────────────────────────── */
.expiry-critical { color: var(--danger); font-weight: 700; }
.expiry-warning  { color: var(--warning); font-weight: 700; }
.expiry-ok       { color: var(--success); }

/* ── Empty states ────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 24px;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.empty-state-icon { width: 56px; height: 56px; color: var(--gray-300); }
.empty-state-title{ font-size: 17px; font-weight: 700; color: var(--gray-500); }
.empty-state-desc { font-size: 13px; color: var(--gray-400); max-width: 300px; line-height: 1.5; }

/* ── Sidebar slide animation ──────────────────────── */
.sidebar-collapsed { width: 64px; }
.sidebar-collapsed .sidebar-brand-text,
.sidebar-collapsed .sidebar-tenant,
.sidebar-collapsed .nav-section-title,
.sidebar-collapsed .nav-item span,
.sidebar-collapsed .nav-badge,
.sidebar-collapsed .sidebar-user-name,
.sidebar-collapsed .sidebar-user-role { display: none; }
.sidebar-collapsed .nav-item { justify-content: center; padding: 9px; }
.sidebar-collapsed .nav-item svg { margin: 0; }
.sidebar-collapsed ~ .main-content { margin-left: 64px; }

/* ── Responsive ──────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 220px; }
  .form-grid-3 { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .form-grid-2, .form-grid-3 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
  .search-box { width: 200px; }
  #tracking-map, #history-map { height: 360px; }
}

/* ── Utilities ───────────────────────────────────── */
.d-flex    { display: flex; }
.d-none    { display: none; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-8     { gap: 8px; }
.gap-12    { gap: 12px; }
.gap-16    { gap: 16px; }
.gap-24    { gap: 24px; }
.flex-1    { flex: 1; }
.text-right{ text-align: right; }
.text-center{ text-align: center; }
.font-bold { font-weight: 700; }
.text-sm   { font-size: 12px; }
.text-muted{ color: var(--gray-500); }
.text-danger{ color: var(--danger); }
.text-success{ color: var(--success); }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-0  { margin-bottom: 0; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.w-full{ width: 100%; }
.overflow-hidden { overflow: hidden; }
.truncate { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ── App-wide Animations ────────────────────────── */

/* Page content fade-in */
.page-content {
  animation: pageFadeIn .35s ease both;
}
@keyframes pageFadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Stat card counter pulse */
.stat-value {
  transition: transform .2s ease;
}
.stat-card:hover .stat-value {
  transform: scale(1.05);
}

/* Sidebar nav item slide indicator */
.nav-item {
  position: relative;
  transition: all .2s cubic-bezier(.4,0,.2,1);
}
.nav-item::after {
  content: '';
  position: absolute;
  right: 0; top: 50%;
  width: 4px; height: 0;
  background: var(--blue);
  border-radius: 2px 0 0 2px;
  transform: translateY(-50%);
  transition: height .2s ease;
}
.nav-item:hover::after,
.nav-item.active::after {
  height: 60%;
}

/* Sidebar nav icon hover glow */
.nav-item:hover svg {
  filter: drop-shadow(0 0 6px rgba(30,136,229,.3));
}

/* Button hover lift */
.btn {
  transition: all .2s cubic-bezier(.4,0,.2,1), transform .15s ease;
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}

/* Card hover lift */
.stat-card, .card {
  transition: box-shadow .2s ease, transform .2s ease;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Table row staggered fade-in */
tbody tr {
  animation: rowFadeIn .3s ease both;
}
tbody tr:nth-child(1) { animation-delay: 0.03s; }
tbody tr:nth-child(2) { animation-delay: 0.06s; }
tbody tr:nth-child(3) { animation-delay: 0.09s; }
tbody tr:nth-child(4) { animation-delay: 0.12s; }
tbody tr:nth-child(5) { animation-delay: 0.15s; }
tbody tr:nth-child(6) { animation-delay: 0.18s; }
tbody tr:nth-child(7) { animation-delay: 0.21s; }
tbody tr:nth-child(8) { animation-delay: 0.24s; }
tbody tr:nth-child(9) { animation-delay: 0.27s; }
tbody tr:nth-child(10) { animation-delay: 0.30s; }
tbody tr:nth-child(11) { animation-delay: 0.33s; }
tbody tr:nth-child(12) { animation-delay: 0.36s; }
tbody tr:nth-child(13) { animation-delay: 0.39s; }
tbody tr:nth-child(14) { animation-delay: 0.42s; }
tbody tr:nth-child(15) { animation-delay: 0.45s; }
tbody tr:nth-child(16) { animation-delay: 0.48s; }
tbody tr:nth-child(17) { animation-delay: 0.51s; }
tbody tr:nth-child(18) { animation-delay: 0.54s; }
tbody tr:nth-child(19) { animation-delay: 0.57s; }
tbody tr:nth-child(20) { animation-delay: 0.60s; }
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Alert auto-dismiss slide out */
.alert {
  animation: alertSlideIn .3s ease both;
  transition: opacity .3s ease, transform .3s ease;
}
@keyframes alertSlideIn {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Modal enter/exit */
.modal-overlay.open .modal {
  animation: modalIn .25s cubic-bezier(.22,.61,.36,1) both;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* Tab content transition */
.tab-content.active {
  animation: tabFade .25s ease both;
}
@keyframes tabFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Badge pop-in */
.badge {
  animation: badgePop .3s cubic-bezier(.68,-.55,.27,1.55) both;
}
@keyframes badgePop {
  from { opacity: 0; transform: scale(0); }
  to { opacity: 1; transform: scale(1); }
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: skeletonPulse 1.5s ease-in-out infinite;
  border-radius: var(--radius);
}
.skeleton-text { height: 14px; margin-bottom: 8px; }
.skeleton-text:last-child { width: 60%; }
.skeleton-heading { height: 22px; width: 40%; margin-bottom: 16px; }
.skeleton-card { height: 120px; margin-bottom: 16px; }
@keyframes skeletonPulse {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* Glassmorphism card variant */
.card-glass {
  background: rgba(255,255,255,.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.5);
}

/* Gradient accent for primary cards */
.card-accent {
  border-top: 3px solid var(--blue);
}

/* Smooth transitions for form elements */
.form-control {
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

/* ── Print ───────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .btn, .filter-bar, .pagination { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ccc !important; }
}

/* ════════════════════════════════════════════════════
   SWM CUSTOM COMPONENTS (Dropdowns, Map, Reports)
   ════════════════════════════════════════════════════ */

/* ── Global Dropdown Styles ──────────────────────── */
.swm-dropdown {
  position: relative;
  font-size: 13px;
  margin-bottom: 8px;
}
.swm-dropdown-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.swm-dropdown-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: var(--transition);
  min-height: 36px;
}
.swm-dropdown-trigger:hover { border-color: var(--blue); }
.swm-dropdown-trigger-text { flex: 1; color: var(--gray-600); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.swm-dropdown-arrow { width: 14px; height: 14px; color: var(--gray-400); flex-shrink: 0; transition: transform .2s; }
.swm-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  margin-top: 2px;
  max-height: 280px;
  overflow: hidden;
  display: none;
  flex-direction: column;
}
.swm-dropdown.open .swm-dropdown-menu { display: flex; }
.swm-dropdown.open .swm-dropdown-arrow { transform: rotate(180deg); }

.swm-dropdown-search {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.swm-dropdown-search svg { width: 14px; height: 14px; color: var(--gray-400); flex-shrink: 0; }
.swm-dropdown-search-input {
  border: none;
  outline: none;
  font-size: 12.5px;
  flex: 1;
  background: none;
  color: var(--gray-700);
}
.swm-dropdown-search-input::placeholder { color: var(--gray-400); }

.swm-dropdown-options {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.swm-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--gray-700);
  transition: background .1s;
}
.swm-dropdown-option:hover { background: var(--gray-50); }
.swm-dropdown-option.selected { background: rgba(30,136,229,.08); color: var(--blue); font-weight: 600; }

.swm-dropdown-check {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-300);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
  transition: var(--transition);
}
.swm-dropdown-check.checked { background: var(--blue); border-color: var(--blue); }

.swm-dropdown-actions {
  display: flex;
  gap: 4px;
  padding: 4px 10px;
  border-bottom: 1px solid var(--gray-100);
}
.swm-dropdown-action-link {
  font-size: 11px;
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 3px;
}
.swm-dropdown-action-link:hover { background: rgba(30,136,229,.1); }

.swm-dropdown-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  flex: 1;
}
.swm-dropdown-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: rgba(30,136,229,.1);
  color: var(--blue);
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
}
.swm-dropdown-chip-remove {
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--blue);
  opacity: .7;
}
.swm-dropdown-chip-remove:hover { opacity: 1; }
.swm-dropdown-count {
  font-size: 11px;
  font-weight: 700;
  color: var(--gray-500);
  background: var(--gray-100);
  padding: 1px 6px;
  border-radius: 10px;
  min-width: 20px;
  text-align: center;
}

/* ── Tracking Map Styles ─────────────────────────── */
.tm-layer-controls {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tm-btn {
  width: 32px;
  height: 32px;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: var(--transition);
  color: var(--gray-600);
}
.tm-btn:hover { background: var(--gray-50); color: var(--blue); }
.tm-btn.active { background: var(--blue); color: white; border-color: var(--blue); }

.tm-fleet-overlay {
  position: absolute;
  bottom: 16px;
  left: 16px;
  z-index: 500;
  background: white;
  border-radius: var(--radius-lg);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--gray-200);
  min-width: 170px;
  display: none;
}
.tracking-layout:not(.tm-fullscreen) .tm-fleet-overlay { display: none; }
.tm-fleet-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--gray-400); margin-bottom: 8px; }
.tm-fleet-row { display: flex; justify-content: space-between; font-size: 12px; padding: 3px 0; }
.tm-fleet-val { font-weight: 700; }

.tm-last-update {
  position: absolute;
  bottom: 16px;
  right: 16px;
  z-index: 500;
  background: rgba(0,0,0,.6);
  color: white;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 10px;
}

.tm-exit-fullscreen {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 500;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 6px 12px;
  cursor: pointer;
  box-shadow: var(--shadow-lg);
  font-size: 12px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--gray-700);
}
.tm-exit-fullscreen:hover { background: var(--gray-50); }
.tm-exit-fullscreen svg { width: 14px; height: 14px; }

.tm-playback-bar {
  background: white;
  border-top: 1px solid var(--gray-200);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}
.tm-playback-slider { flex: 1; min-width: 120px; accent-color: var(--blue); }
.tm-playback-time { font-size: 11px; color: var(--gray-600); font-weight: 600; min-width: 100px; }
.tm-speed-select { width: 80px; font-size: 11px; padding: 3px 4px; }

.tm-marker { background: none !important; border: none !important; }

/* ── Responsive Grid Table (No Horizontal Scroll) ── */
.rg-table {
  display: flex;
  flex-direction: column;
  font-size: 12.5px;
  width: 100%;
}
.rg-thead {
  display: flex;
  flex-wrap: wrap;
  background: var(--gray-50);
  border-radius: var(--radius) var(--radius) 0 0;
  border: 1px solid var(--gray-200);
  border-bottom: none;
}
.rg-th {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  font-weight: 700;
  font-size: 11px;
  color: var(--gray-600);
  text-transform: uppercase;
  letter-spacing: .3px;
}
.rg-row {
  display: flex;
  flex-wrap: wrap;
  border: 1px solid var(--gray-200);
  border-top: none;
  transition: background .1s;
}
.rg-row:hover { background: var(--gray-50); }
.rg-row:nth-child(even) { background: #fafbfc; }
.rg-row:nth-child(even):hover { background: var(--gray-50); }
.rg-cell {
  flex: 1;
  min-width: 80px;
  padding: 8px 10px;
  font-size: 12.5px;
  color: var(--gray-700);
  word-break: break-word;
}
.rg-cell-bold { font-weight: 700; color: var(--gray-800); }

/* ── Report Summary Cards ────────────────────────── */
.report-summary-cards {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.rsc-item {
  flex: 1;
  min-width: 120px;
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow-sm);
}
.rsc-val { font-size: 24px; font-weight: 800; line-height: 1.2; margin-bottom: 4px; }
.rsc-label { font-size: 11px; color: var(--gray-500); text-transform: uppercase; letter-spacing: .4px; }

/* ── Report Filter Bar ───────────────────────────── */
.report-filters {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  padding: 14px 18px;
  box-shadow: var(--shadow-sm);
}
.rf-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}
.rf-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 140px;
  flex: 1;
}
.rf-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
}
.rf-input {
  font-size: 12px;
  padding: 6px 8px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  color: var(--gray-700);
  outline: none;
  width: 100%;
}
.rf-input:focus { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(30,136,229,.1); }
.rf-input[multiple] { min-height: 60px; }

/* ── Modern Multi-Select Dropdown (portal theme) ─── */
.ms-wrap {
  position: relative;
  font-size: 13px;
  min-width: 0;
  width: 100%;
}
.ms-label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-500);
  margin-bottom: 4px;
}
.ms-trigger {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  background: white;
  cursor: pointer;
  transition: var(--transition);
  min-height: 36px;
}
.ms-trigger:hover { border-color: var(--blue); }
.ms-trigger:focus-within { border-color: var(--blue); box-shadow: 0 0 0 2px rgba(30,136,229,.12); }
.ms-trigger.open { border-color: var(--blue); }
.ms-trigger.open .ms-arr { transform: rotate(180deg); color: var(--blue); }
.ms-tags {
  display: flex;
  gap: 3px;
  flex: 1;
  align-items: center;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
  white-space: nowrap;
  min-height: 22px;
  max-height: 22px;
}
.ms-tags::-webkit-scrollbar { display: none; }
.ms-ph {
  color: var(--gray-400);
  font-size: 12.5px;
  user-select: none;
  white-space: nowrap;
}
.ms-chip {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  background: rgba(30,136,229,.1);
  color: var(--blue);
  font-size: 10.5px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  flex-shrink: 0;
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ms-chip.ms-chip-count {
  background: var(--blue);
  color: white;
  font-size: 10px;
  padding: 1px 5px;
}
.ms-chip-x {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13px;
  line-height: 1;
  color: var(--blue);
  opacity: .6;
  padding: 0;
  display: inline-flex;
}
.ms-arr {
  font-size: 9px;
  color: var(--gray-400);
  transition: transform .2s;
  flex-shrink: 0;
  user-select: none;
}
.ms-actions {
  display: flex;
  gap: 8px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--gray-100);
  background: var(--gray-50);
}
.ms-action {
  font-size: 11px;
  cursor: pointer;
  color: var(--blue);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 3px;
  border: 1px solid transparent;
  transition: var(--transition);
}
.ms-action:hover { background: rgba(30,136,229,.1); border-color: rgba(30,136,229,.2); }
.ms-dd {
  display: none;
  position: absolute;
  top: calc(100% + 3px);
  left: 0;
  right: 0;
  background: white;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  z-index: 500;
  max-height: 220px;
  overflow-y: auto;
  padding: 0 0 4px 0;
}
.ms-dd.show { display: block; }
.ms-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  cursor: pointer;
  font-size: 12.5px;
  color: var(--gray-700);
  transition: background .1s;
}
.ms-opt:hover { background: var(--gray-50); }
.ms-opt.on { background: rgba(30,136,229,.06); color: var(--blue); font-weight: 600; }
.ms-cb {
  width: 18px; height: 18px;
  border: 2px solid var(--gray-300);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: white;
  flex-shrink: 0;
  transition: var(--transition);
}
.ms-cb.on { background: var(--blue); border-color: var(--blue); }

/* ── Leaflet Overrides ───────────────────────────── */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: var(--shadow-lg) !important;
  padding: 4px !important;
}
.leaflet-popup-content { margin: 10px 12px !important; font-size: 12px !important; }



