/* ═══════════════════════════════════════════════════
   OLT Monitor — White & Blue Casual Theme
   ═══════════════════════════════════════════════════ */

:root {
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --primary-light: #3b82f6;
  --primary-soft: #dbeafe;
  --success: #16a34a;
  --success-soft: #dcfce7;
  --danger: #dc2626;
  --danger-soft: #fee2e2;
  --warning: #d97706;
  --purple: #7c3aed;
  --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;
  --sidebar-w: 260px;
  --sidebar-collapsed: 72px;
  --topbar-h: 60px;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,.1);
  --transition: .25s ease;
}

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

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

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

/* ─── Login ─── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 50%, #bfdbfe 100%);
}
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px 32px;
  box-shadow: var(--shadow-md);
}
.login-header { text-align: center; margin-bottom: 28px; }
.logo-big {
  width: 64px; height: 64px;
  background: var(--primary);
  color: #fff;
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px;
  margin: 0 auto 16px;
}
.login-header h1 { font-size: 1.6rem; color: var(--gray-900); }
.login-header p { color: var(--gray-500); font-size: .9rem; margin-top: 4px; }
.login-form .form-group { margin-bottom: 18px; }
.login-form label {
  display: block; font-size: .85rem; font-weight: 600;
  color: var(--gray-600); margin-bottom: 6px;
}
.login-form label i { margin-right: 6px; color: var(--primary); }
.login-form input {
  width: 100%; padding: 12px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm);
  font-size: .95rem; transition: border var(--transition);
}
.login-form input:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.login-hint {
  margin-top: 24px; padding: 14px;
  background: var(--gray-50); border-radius: var(--radius-sm);
  font-size: .8rem; color: var(--gray-500);
}
.login-hint code {
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 1px 6px; border-radius: 4px; font-size: .8rem;
}
.login-footer {
  text-align: center; margin-top: 20px;
  font-size: .8rem; color: var(--gray-400);
}

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

.sidebar {
  width: var(--sidebar-w);
  background: #fff;
  border-right: 1px solid var(--gray-200);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: width var(--transition);
  overflow: hidden;
}
.sidebar.collapsed { width: var(--sidebar-collapsed); }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-item span,
.sidebar.collapsed .user-meta,
.sidebar.collapsed .logout span { opacity: 0; width: 0; overflow: hidden; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px; height: var(--topbar-h);
  border-bottom: 1px solid var(--gray-100);
}
.logo {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.1rem; color: var(--primary);
  white-space: nowrap;
}
.logo i {
  width: 36px; height: 36px;
  background: var(--primary); color: #fff;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.sidebar-toggle { color: var(--gray-500); }

.sidebar-nav { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px; border-radius: var(--radius-sm);
  color: var(--gray-600); font-weight: 500; font-size: .92rem;
  transition: all var(--transition); white-space: nowrap;
  margin-bottom: 2px;
}
.nav-item i { width: 22px; text-align: center; font-size: 1.05rem; flex-shrink: 0; }
.nav-item:hover { background: var(--primary-soft); color: var(--primary); }
.nav-item.active {
  background: var(--primary); color: #fff;
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.nav-item.logout { color: var(--danger); }
.nav-item.logout:hover { background: var(--danger-soft); }

.sidebar-footer {
  padding: 12px; border-top: 1px solid var(--gray-100);
}
.user-info {
  display: flex; align-items: center; gap: 10px;
  padding: 8px; margin-bottom: 4px;
}
.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; flex-shrink: 0;
}
.user-meta { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; }
.user-role {
  font-size: .7rem; font-weight: 600; text-transform: uppercase;
  padding: 1px 6px; border-radius: 4px; width: fit-content;
}
.badge-admin { background: var(--primary-soft); color: var(--primary-dark); }
.badge-agent { background: var(--success-soft); color: var(--success); }

.main-content {
  flex: 1; margin-left: var(--sidebar-w);
  transition: margin-left var(--transition);
  min-height: 100vh; display: flex; flex-direction: column;
}
.sidebar.collapsed ~ .main-content { margin-left: var(--sidebar-collapsed); }

.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center; gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.page-title { font-size: 1.15rem; font-weight: 700; color: var(--gray-800); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.clock { font-size: .85rem; color: var(--gray-500); font-variant-numeric: tabular-nums; }

/* ─── Live Status Badge ─── */
.live-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
  box-shadow: 0 1px 3px rgba(16, 185, 129, 0.12);
  transition: all var(--transition);
  user-select: none;
}
.live-dot-wrapper {
  position: relative;
  width: 8px;
  height: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.live-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  display: block;
  transition: background-color 0.3s ease;
}
.live-dot-ping {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  opacity: 0.75;
  animation: livePing 1.8s cubic-bezier(0, 0, 0.2, 1) infinite;
}
@keyframes livePing {
  0% { transform: scale(1); opacity: 0.85; }
  75%, 100% { transform: scale(2.6); opacity: 0; }
}

/* Syncing State */
.live-status-badge.syncing {
  background: #eff6ff;
  border-color: #bfdbfe;
  color: #1d4ed8;
}
.live-status-badge.syncing .live-dot {
  background: #3b82f6;
  animation: pulseSync 0.6s infinite alternate;
}
.live-status-badge.syncing .live-dot-ping {
  background: #3b82f6;
}
@keyframes pulseSync {
  0% { transform: scale(0.8); }
  100% { transform: scale(1.2); }
}

/* Offline State */
.live-status-badge.offline {
  background: #fef2f2;
  border-color: #fecaca;
  color: #991b1b;
}
.live-status-badge.offline .live-dot {
  background: #ef4444;
}
.live-status-badge.offline .live-dot-ping {
  display: none !important;
  animation: none !important;
}

/* ─── Topbar Alarm Button ─── */
.topbar-alarm-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 11px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.4px;
  background: #f8fafc;
  border: 1px solid var(--gray-300);
  color: var(--gray-700);
  cursor: pointer;
  transition: all var(--transition);
  outline: none;
  user-select: none;
}
.topbar-alarm-btn:hover {
  background: #f1f5f9;
  border-color: var(--gray-400);
  color: var(--gray-900);
}
.topbar-alarm-btn .alarm-down-count {
  background: #ef4444;
  color: #fff;
  font-size: 0.65rem;
  font-weight: 800;
  padding: 1px 6px;
  border-radius: 9999px;
  min-width: 16px;
  text-align: center;
  line-height: 1.2;
}
/* Ringing State (Active Down Alert) */
.topbar-alarm-btn.ringing {
  background: #fef2f2;
  border-color: #f87171;
  color: #b91c1c;
  animation: alarmPulseGlow 1.2s infinite;
}
.topbar-alarm-btn.ringing i {
  color: #dc2626;
  display: inline-block;
  animation: alarmBellShake 0.7s infinite ease-in-out;
}
/* Muted State */
.topbar-alarm-btn.muted {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: #94a3b8;
}
.topbar-alarm-btn.muted i {
  color: #94a3b8;
}

@keyframes alarmPulseGlow {
  0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.45); }
  70% { box-shadow: 0 0 0 8px rgba(239, 68, 68, 0); }
  100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

@keyframes alarmBellShake {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(15deg); }
  40% { transform: rotate(-15deg); }
  60% { transform: rotate(10deg); }
  80% { transform: rotate(-10deg); }
}

.mobile-menu { display: none; }
.alert-bell {
  position: relative; cursor: pointer; color: var(--gray-500);
  font-size: 1.15rem; padding: 6px;
}
.alert-bell .badge {
  position: absolute; top: 0; right: 0;
  background: var(--danger); color: #fff;
  font-size: .65rem; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 4px;
}

.content-area { padding: 24px; flex: 1; }

/* ─── Cards ─── */
.card {
  background: #fff; border-radius: var(--radius);
  box-shadow: var(--shadow); margin-bottom: 20px;
  border: 1px solid var(--gray-100);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
  flex-wrap: wrap; gap: 12px;
}
.card-header h2 {
  font-size: 1rem; font-weight: 700; color: var(--gray-800);
  display: flex; align-items: center; gap: 8px;
}
.card-header h2 i { color: var(--primary); }
.card-body { padding: 20px; }

/* ─── Stats ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 20px;
}
.stat-card {
  background: #fff; border-radius: var(--radius);
  padding: 20px; display: flex; align-items: center; gap: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--gray-100);
}
.stat-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.3rem; flex-shrink: 0;
}
.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.green { background: var(--success-soft); color: var(--success); }
.stat-icon.orange { background: #ffedd5; color: #ea580c; }
.stat-icon.red { background: var(--danger-soft); color: var(--danger); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; color: var(--gray-900); }
.stat-label { font-size: .8rem; color: var(--gray-500); font-weight: 500; }

/* ─── Map ─── */
.map-card .card-header { border-bottom: none; padding-bottom: 8px; }
.map-container {
  height: 420px; border-radius: 0 0 var(--radius) var(--radius);
  z-index: 1;
}
.map-legend { display: flex; gap: 16px; font-size: .8rem; color: var(--gray-600); }
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
}
.dot.green { background: var(--success); box-shadow: 0 0 0 3px rgba(22,163,74,.25); }
.dot.orange { background: #f97316; box-shadow: 0 0 0 3px rgba(249,115,22,.25); }
.dot.yellow { background: #eab308; box-shadow: 0 0 0 3px rgba(234,179,8,.25); }
.dot.red { background: var(--danger); box-shadow: 0 0 0 3px rgba(220,38,38,.25); }
.dot.gray { background: var(--gray-400); }

/* Leaflet marker custom */
.ont-marker {
  width: 18px; height: 18px; border-radius: 50%;
  border: 3px solid #fff; box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.ont-marker.online { background: var(--success); }
.ont-marker.dying_gasp { background: #ea580c; }
.ont-marker.lose { background: var(--danger); }
.ont-marker.unknown { background: var(--gray-400); }

/* ─── Optical Health Quick Filter Pills ─── */
.rx-filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 24px 14px 24px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--gray-100);
}
.rx-pill-btn {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 9999px;
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--gray-700);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  user-select: none;
}
.rx-pill-btn .dot {
  width: 9px;
  height: 9px;
  flex-shrink: 0;
}
.rx-pill-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-300);
}
.rx-badge-count {
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 0.72rem;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 9999px;
  min-width: 18px;
  text-align: center;
  transition: all 0.2s ease;
}
.rx-pill-btn[data-rx="all"].active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}
.rx-pill-btn[data-rx="all"].active .rx-badge-count {
  background: rgba(255, 255, 255, 0.25);
  color: #fff;
}

.rx-pill-btn.pill-normal {
  border-color: #bbf7d0;
}
.rx-pill-btn.pill-normal .rx-badge-count {
  background: #dcfce7;
  color: #15803d;
}
.rx-pill-btn.pill-normal:hover {
  border-color: #86efac;
  background: #f0fdf4;
}
.rx-pill-btn.pill-normal.active {
  background: #dcfce7;
  border-color: #22c55e;
  color: #15803d;
  box-shadow: 0 2px 6px rgba(34, 197, 94, 0.2);
}
.rx-pill-btn.pill-normal.active .rx-badge-count {
  background: #22c55e;
  color: #fff;
}

.rx-pill-btn.pill-warning {
  border-color: #fef08a;
}
.rx-pill-btn.pill-warning .rx-badge-count {
  background: #fef9c3;
  color: #854d0e;
}
.rx-pill-btn.pill-warning:hover {
  border-color: #fde047;
  background: #fefce8;
}
.rx-pill-btn.pill-warning.active {
  background: #fef9c3;
  border-color: #eab308;
  color: #854d0e;
  box-shadow: 0 2px 6px rgba(234, 179, 8, 0.2);
}
.rx-pill-btn.pill-warning.active .rx-badge-count {
  background: #eab308;
  color: #fff;
}

.rx-pill-btn.pill-critical {
  border-color: #fecaca;
}
.rx-pill-btn.pill-critical .rx-badge-count {
  background: #fee2e2;
  color: #991b1b;
}
.rx-pill-btn.pill-critical:hover {
  border-color: #fca5a5;
  background: #fef2f2;
}
.rx-pill-btn.pill-critical.active {
  background: #fee2e2;
  border-color: #ef4444;
  color: #991b1b;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.2);
}
.rx-pill-btn.pill-critical.active .rx-badge-count {
  background: #ef4444;
  color: #fff;
}

/* ─── Table ─── */
.table-responsive { overflow-x: auto; }
.data-table {
  width: 100%; border-collapse: collapse; font-size: .875rem;
}
.data-table th {
  background: var(--gray-50); padding: 12px 16px;
  text-align: left; font-weight: 600; color: var(--gray-600);
  border-bottom: 1px solid var(--gray-200); white-space: nowrap;
}
.data-table td {
  padding: 12px 16px; border-bottom: 1px solid var(--gray-100);
  vertical-align: middle;
}
.data-table tbody tr:hover { background: var(--gray-50); }
.text-center { text-align: center; }

.status-badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 10px; border-radius: 20px;
  font-size: .75rem; font-weight: 700; text-transform: uppercase;
}
.status-badge.online { background: var(--success-soft); color: var(--success); }
.status-badge.dying_gasp { background: #ffedd5; color: #c2410c; border: 1px solid #fdba74; }
.status-badge.lose { background: var(--danger-soft); color: var(--danger); }
.status-badge.auth_failed { background: #fef3c7; color: #b45309; border: 1px solid #fcd34d; }
.status-badge.unknown, .status-badge.offline {
  background: var(--gray-100); color: var(--gray-500);
}
.status-badge::before {
  content: ''; width: 7px; height: 7px; border-radius: 50%;
  background: currentColor;
}

/* Rx Power Indicator */
.rx-val {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 7px; border-radius: 6px;
  font-size: .8rem; font-weight: 700; font-family: monospace;
}
.rx-val.rx-normal {
  background: var(--success-soft); color: var(--success);
}
.rx-val.rx-warning {
  background: #fef3c7; color: #b45309; border: 1px solid #fcd34d;
  box-shadow: 0 0 4px rgba(245, 158, 11, 0.2);
}
.rx-val.rx-danger {
  background: var(--danger-soft); color: var(--danger);
}
.rx-val.rx-none {
  color: var(--gray-400); font-family: inherit; font-weight: normal;
}

.ont-test-card {
  background: var(--gray-50);
  border: 1.5px dashed var(--primary);
  border-radius: var(--radius-sm);
  padding: 12px 16px;
  font-size: 0.85rem;
  margin-top: 10px;
  margin-bottom: 15px;
}
.ont-test-card .test-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.ont-test-card .test-metric {
  background: #fff;
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--gray-200);
}
.ont-test-card .test-metric-val {
  font-weight: 700;
  color: var(--gray-900);
}

/* ─── Forms & Buttons ─── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .875rem; font-weight: 600; border: none;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray-100); color: var(--gray-700); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-outline {
  background: transparent; border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary-soft); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; padding: 12px; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  padding: 8px; border-radius: 8px; color: var(--gray-500);
  font-size: 1.1rem; transition: all var(--transition);
}
.btn-icon:hover { background: var(--gray-100); color: var(--gray-800); }

.form-group { margin-bottom: 16px; }
.form-group label {
  display: block; font-size: .85rem; font-weight: 600;
  color: var(--gray-600); margin-bottom: 6px;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px;
  border: 1.5px solid var(--gray-200); border-radius: var(--radius-sm);
  font-size: .9rem; transition: border var(--transition);
  background: #fff;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-soft);
}
.form-row {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
}
.form-actions { display: flex; gap: 12px; margin-top: 8px; flex-wrap: wrap; }

.search-input, .select-input {
  padding: 8px 12px; border: 1.5px solid var(--gray-200);
  border-radius: var(--radius-sm); font-size: .85rem;
}
.search-input { min-width: 220px; }
.search-input:focus, .select-input:focus {
  outline: none; border-color: var(--primary);
}
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; }

/* Toggle switch */
.switch {
  position: relative; display: inline-block;
  width: 48px; height: 26px;
}
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background: var(--gray-300); border-radius: 26px;
  transition: .3s;
}
.slider::before {
  content: ''; position: absolute;
  width: 20px; height: 20px; left: 3px; bottom: 3px;
  background: #fff; border-radius: 50%; transition: .3s;
}
.switch input:checked + .slider { background: var(--primary); }
.switch input:checked + .slider::before { transform: translateX(22px); }

/* ─── Modal ─── */
.modal {
  display: none; position: fixed; inset: 0;
  background: rgba(15,23,42,.45); z-index: 200;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal.open { display: flex; }
.modal-content {
  background: #fff; border-radius: 16px;
  width: 100%; max-width: 640px; max-height: 90vh;
  overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.2);
}
.modal-sm { max-width: 420px; }
.modal-lg { max-width: 820px; }

/* History Chart Modal Styles */
.history-pills-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.history-pill {
  background: var(--gray-50);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.history-pill .pill-label {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--gray-500);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.history-pill .pill-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--gray-800);
  font-family: monospace;
}

.history-chart-wrapper {
  position: relative;
  height: 330px;
  width: 100%;
  background: #ffffff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.03);
}

.history-threshold-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 14px;
  padding: 8px 12px;
  background: var(--gray-50);
  border-radius: 8px;
  font-size: 0.75rem;
  color: var(--gray-600);
  align-items: center;
}
.thresh-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.thresh-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}
.thresh-dot.green { background: #16a34a; }
.thresh-dot.yellow { background: #eab308; }
.thresh-dot.red { background: #dc2626; }

.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 24px; border-bottom: 1px solid var(--gray-100);
}
.modal-header h3 { font-size: 1.1rem; font-weight: 700; }
.modal-content form { padding: 20px 24px; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 10px;
  padding-top: 8px; flex-wrap: wrap;
}

/* ─── Alert Panel ─── */
.alert-panel {
  position: fixed; top: 0; right: -360px; width: 340px;
  height: 100vh; background: #fff; z-index: 150;
  box-shadow: -4px 0 20px rgba(0,0,0,.1);
  transition: right var(--transition);
  display: flex; flex-direction: column;
}
.alert-panel.open { right: 0; }
.alert-panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--gray-100);
}
.alert-list { flex: 1; overflow-y: auto; padding: 12px; }
.alert-item {
  padding: 12px; border-radius: var(--radius-sm);
  margin-bottom: 8px; font-size: .85rem;
  border-left: 3px solid var(--warning);
  background: #fffbeb;
}
.alert-item.critical {
  border-left-color: var(--danger); background: var(--danger-soft);
}
.alert-item .time { font-size: .75rem; color: var(--gray-400); margin-top: 4px; }

/* ─── Settings ─── */
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
}
.info-list { list-style: none; }
.info-list li {
  padding: 8px 0; border-bottom: 1px solid var(--gray-100);
  font-size: .9rem;
}
.hint {
  font-size: .85rem; color: var(--gray-500);
  margin-bottom: 16px; line-height: 1.6;
}
.hint code {
  background: var(--primary-soft); color: var(--primary-dark);
  padding: 1px 5px; border-radius: 3px; font-size: .8rem;
}

/* ─── Flash ─── */
.flash {
  padding: 12px 16px; border-radius: var(--radius-sm);
  margin-bottom: 16px; font-size: .9rem; font-weight: 500;
}
.flash-error { background: var(--danger-soft); color: var(--danger); }
.flash-success { background: var(--success-soft); color: var(--success); }

/* ─── Responsive ─── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .mobile-menu { display: block; }
  .sidebar-toggle { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .map-container { height: 300px; }
  .content-area { padding: 16px; }
}

/* Leaflet popup */
.leaflet-popup-content-wrapper {
  border-radius: 10px !important;
  box-shadow: var(--shadow-md) !important;
}
.leaflet-popup-content { margin: 12px 14px !important; font-size: .85rem; }
.popup-status { font-weight: 700; }
.popup-status.online { color: var(--success); }
.popup-status.dying_gasp { color: #ea580c; }
.popup-status.lose { color: var(--danger); }

/* ─── Top Progress Bar (Global Loading) ─── */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 3px;
  width: 0%;
  background: linear-gradient(90deg, #0284c7, #38bdf8, #60a5fa, #93c5fd);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.7), 0 0 5px rgba(2, 132, 199, 0.5);
  z-index: 999999;
  opacity: 0;
  transition: width 0.3s ease, opacity 0.3s ease;
  pointer-events: none;
}
.top-progress-bar.active {
  opacity: 1;
  width: 70%;
  animation: progressIndeterminate 1.5s infinite ease-in-out;
}
.top-progress-bar.finish {
  opacity: 1;
  width: 100% !important;
  animation: none !important;
  transition: width 0.15s ease, opacity 0.3s ease 0.15s;
}
@keyframes progressIndeterminate {
  0% { width: 20%; transform: translateX(0); }
  50% { width: 65%; transform: translateX(30%); }
  100% { width: 85%; transform: translateX(15%); }
}

/* ─── Button Loading State ─── */
.btn.btn-loading {
  position: relative;
  pointer-events: none !important;
  opacity: 0.82;
  cursor: not-allowed !important;
  box-shadow: none !important;
}
.btn.btn-loading i.fa-spin {
  margin-right: 6px;
}

/* ─── ONT Diagnostic Realtime Loading Card ─── */
.ont-diagnostic-card {
  background: linear-gradient(135deg, #f0fdf4 0%, #ecfeff 50%, #eff6ff 100%);
  border: 1px solid #bae6fd;
  border-radius: var(--radius-md);
  padding: 16px;
  margin: 14px 0;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.08);
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}
.ont-diagnostic-loading {
  display: flex;
  align-items: center;
  gap: 16px;
}
.diagnostic-radar-icon {
  position: relative;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #e0f2fe;
  color: #0284c7;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.4);
  animation: pulseRadar 1.8s infinite;
}
@keyframes pulseRadar {
  0% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0.6); transform: scale(0.95); }
  70% { box-shadow: 0 0 0 14px rgba(2, 132, 199, 0); transform: scale(1); }
  100% { box-shadow: 0 0 0 0 rgba(2, 132, 199, 0); transform: scale(0.95); }
}
.diagnostic-steps {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
}
.diagnostic-title {
  font-weight: 700;
  color: #0369a1;
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  gap: 8px;
}
.diagnostic-desc {
  color: #0284c7;
  font-size: 0.8rem;
}

/* ─── Table Skeleton Shimmer Loader ─── */
.skeleton-shimmer {
  height: 16px;
  border-radius: 4px;
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  display: inline-block;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
