:root {
  --primary: #c91818;
  --primary-dark: #980f0f;
  --primary-soft: #fff0f0;
  --text: #181818;
  --muted: #6b7280;
  --border: #edd7d7;
  --white: #ffffff;
  --shadow: 0 18px 50px rgba(168, 24, 24, 0.10);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }
.hidden { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  font-family: 'Inter', sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #fff8f8 0%, #ffffff 35%, #fff7f7 100%);
}
a { text-decoration: none; color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
.container { width: min(1180px, calc(100% - 32px)); margin: 0 auto; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(201, 24, 24, 0.08);
}
.nav-wrap, .footer-wrap {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 0;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 48px; height: 48px; border-radius: 16px;
  display: grid; place-items: center;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.brand-name { font-size: 1rem; font-weight: 800; letter-spacing: 0.08em; }
.brand-sub { font-size: 0.82rem; color: var(--muted); }
.nav-links { display: flex; align-items: center; gap: 22px; color: #3b3b3b; font-weight: 600; }
.nav-links a:hover { color: var(--primary); }

.hero { padding: 64px 0 42px; }
.hero-grid {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  gap: 34px;
  align-items: center;
}
.eyebrow, .section-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 700;
  font-size: 0.85rem;
}
.hero-copy h1 {
  margin: 16px 0 14px;
  font-size: clamp(2.3rem, 6vw, 4.2rem);
  line-height: 1.02;
}
.hero-copy p, .section-grid p, .feature-card p, .step-card p, .auth-panel p, .info-card p {
  color: var(--muted);
  line-height: 1.7;
}
.hero-actions { display: flex; gap: 14px; margin: 28px 0; flex-wrap: wrap; }
.btn {
  border: 0;
  border-radius: 16px;
  padding: 14px 22px;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.btn:hover { transform: translateY(-1px); }
.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--primary), #ef4444);
  box-shadow: var(--shadow);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--primary-dark), #dc2626); }
.btn-secondary {
  background: white;
  color: var(--primary);
  border: 1px solid rgba(201, 24, 24, 0.18);
}
.btn-block { width: 100%; }
.stats-row, .mock-grid, .feature-grid, .steps-grid, .metric-grid, .dashboard-grid, .alert-grid, .profile-info-grid {
  display: grid;
  gap: 16px;
}
.stats-row { grid-template-columns: repeat(3, 1fr); }
.mini, .feature-card, .step-card, .metric-card, .panel-card, .table-card, .profile-card-large, .auth-panel, .info-card, .mock-card {
  background: white;
  border: 1px solid rgba(201, 24, 24, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.stat-card, .feature-card, .step-card, .metric-card, .panel-card, .table-card, .profile-card-large, .auth-panel, .info-card { padding: 22px; }
.stat-card strong { display: block; margin-bottom: 8px; }
.stat-card span { color: var(--muted); font-size: 0.92rem; }

.hero-panel .mock-card { padding: 22px; }
.mock-top, .panel-head, .section-head, .profile-top, .feed-item, .profile-mini, .tab-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.mock-pill, .badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 12px;
  font-size: 0.78rem;
  font-weight: 700;
}
.online, .badge-danger { background: rgba(201, 24, 24, 0.10); color: var(--primary); }
.badge-warning { background: #fff4db; color: #9a6700; }
.badge-success { background: #e8f8ee; color: #0f8b45; }
.badge-muted { background: #f1f5f9; color: #64748b; }
.mock-version, .muted { color: var(--muted); }
.mock-grid { grid-template-columns: repeat(2, 1fr); margin: 16px 0; }
.metric-box {
  padding: 18px;
  border-radius: 20px;
  background: linear-gradient(180deg, #fff7f7 0%, #ffffff 100%);
  border: 1px solid var(--border);
}
.metric-box h3 { margin: 0; font-size: 1.8rem; color: var(--primary); }
.metric-box p { margin: 8px 0 0; color: var(--muted); font-size: 0.93rem; }
.landing-map, .dashboard-map { width: 100%; border-radius: 22px; min-height: 300px; isolation: isolate; overflow: hidden; }
.feed-preview, .list-stack { display: grid; gap: 12px; margin-top: 14px; }
.feed-item {
  padding: 14px 16px;
  border-radius: 18px;
  background: #fffafa;
  border: 1px solid var(--border);
  justify-content: flex-start;
}
.feed-item > div p, .alert-card p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

.section { padding: 70px 0; }
.section-soft { background: linear-gradient(180deg, #fff7f7 0%, #fffdfd 100%); }
.section-grid.two-col { display: grid; grid-template-columns: 1fr 0.9fr; gap: 28px; align-items: center; }
.section-title { margin: 14px 0 26px; font-size: clamp(1.9rem, 4vw, 2.8rem); }
.stack-list { display: grid; gap: 14px; }
.stack-list > div {
  display: flex; justify-content: space-between; gap: 18px; padding: 16px 18px;
  border: 1px solid var(--border); border-radius: 18px; background: #fffafa;
}
.stack-list span { color: var(--muted); }
.feature-grid { grid-template-columns: repeat(4, 1fr); }
.feature-card h3, .step-card h3 { margin-top: 0; }
.steps-grid { grid-template-columns: repeat(4, 1fr); }
.step-card span {
  width: 42px; height: 42px; display: grid; place-items: center;
  border-radius: 14px; background: var(--primary-soft); color: var(--primary); font-weight: 800;
}

.auth-section { background: var(--primary-soft); }

.tab-buttons {
  background: #fff7f7;
  border: 1px solid var(--border);
  padding: 6px;
  border-radius: 18px;
  margin: 24px 0 18px;
}
.tab-btn {
  flex: 1;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: transparent;
  font-weight: 700;
}
.tab-btn.active { background: white; color: var(--primary); box-shadow: 0 6px 20px rgba(201, 24, 24, 0.10); }
.auth-form { display: none; gap: 14px; }
.auth-form.active-form { display: grid; }
.auth-form label { display: grid; gap: 8px; font-weight: 600; color: #333; }
.auth-form input, .auth-form select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  outline: none;
  background: #fffdfd;
}
.auth-form input:focus, .auth-form select:focus { border-color: rgba(201,24,24,0.35); box-shadow: 0 0 0 4px rgba(201,24,24,0.08); }
.split-two { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.message { margin-top: 16px; min-height: 24px; font-weight: 600; }

/* ── Password show/hide ── */
.pw-wrap { position: relative; }
.pw-wrap input { padding-right: 44px; }
.pw-toggle {
  position: absolute; right: 12px; top: 50%;
  transform: translateY(-50%);
  border: 0; background: transparent;
  color: #9ca3af; padding: 4px;
  display: flex; align-items: center;
}
.pw-toggle:hover { color: #374151; }
.pw-toggle svg { width: 18px; height: 18px; }
.message.error { color: var(--primary); }
.message.success { color: #0f8b45; }
code { background: #fff1f1; padding: 3px 6px; border-radius: 8px; }
.site-footer { padding: 28px 0; border-top: 1px solid rgba(201,24,24,0.08); background: white; }
.site-footer p { margin: 6px 0 0; color: var(--muted); }

/* ── Modal ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.45);
  align-items: center;
  justify-content: center;
  padding: 20px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  opacity: 0;
  transition: opacity 0.22s ease;
}
.modal-overlay.modal-open {
  display: flex;
  opacity: 1;
}
.modal-box {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 80px rgba(100, 10, 10, 0.22);
  padding: 36px;
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  transform: translateY(12px);
  transition: transform 0.22s ease;
}
.modal-overlay.modal-open .modal-box { transform: translateY(0); }
.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff7f7;
  color: var(--muted);
  font-size: 1.2rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s, color 0.15s;
}
.modal-close:hover { background: var(--primary-soft); color: var(--primary); }

/* ── Dashboard layout ── */
.dashboard-body { background: #fff8f8; }
.dashboard-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  height: 100vh;
  overflow: hidden;
}
.sidebar {
  padding: 24px;
  border-right: 1px solid rgba(201,24,24,0.08);
  background: linear-gradient(180deg, #fffefe 0%, #fff6f6 100%);
  display: flex;
  flex-direction: column;
  gap: 22px;
  height: 100vh;
  overflow-y: auto;
  position: sticky;
  top: 0;
}
.sidebar-brand { margin-bottom: 8px; }
.sidebar-nav { display: grid; gap: 10px; }
.nav-item {
  text-align: left;
  border: 1px solid transparent;
  border-radius: 16px;
  padding: 14px 16px;
  background: transparent;
  font-weight: 700;
  color: #313131;
}
.nav-item.active, .nav-item:hover {
  background: white;
  color: var(--primary);
  border-color: rgba(201,24,24,0.12);
  box-shadow: 0 10px 24px rgba(201, 24, 24, 0.08);
}
.nav-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--primary);
  color: white;
  font-size: 0.7rem;
  font-weight: 800;
  margin-left: 6px;
  vertical-align: middle;
}
.nav-item.active .nav-badge { background: var(--primary-dark); }

/* ── Live Alerts filter tabs ── */
.alerts-filter-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}
.alerts-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  font-weight: 600;
  font-size: 0.88rem;
  transition: border-color 0.15s, color 0.15s, background 0.15s, box-shadow 0.15s;
}
.alerts-filter-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
}
.alerts-filter-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  box-shadow: 0 4px 14px rgba(201,24,24,0.18);
}
.alerts-filter-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: rgba(0,0,0,0.10);
  font-size: 0.7rem;
  font-weight: 800;
}
.alerts-filter-btn.active .alerts-filter-count { background: rgba(255,255,255,0.25); }
.alerts-filter-count--zero { opacity: 0.45; }
.profile-mini {
  margin-top: auto;
  padding: 16px;
  border-radius: 20px;
  background: white;
  border: 1px solid var(--border);
  justify-content: flex-start;
}
.profile-mini span { display: block; color: var(--muted); margin-top: 6px; }
.profile-avatar {
  width: 48px; height: 48px; border-radius: 16px; display: grid; place-items: center;
  background: linear-gradient(135deg, var(--primary), #ff6a6a); color: white; font-weight: 800;
}
.profile-avatar.large { width: 74px; height: 74px; font-size: 1.6rem; border-radius: 24px; }
.dashboard-main { padding: 28px; height: 100vh; overflow-y: auto; }
.dash-section { display: none; }
.dash-section.active-section { display: block; }
.section-head h1, .section-head h2, .profile-top h3 { margin: 0; }
.section-head p { color: var(--muted); margin: 8px 0 0; }
.compact-head { margin-bottom: 20px; }
.clock-box {
  min-width: 160px;
  text-align: center;
  padding: 16px 20px;
  border-radius: 18px;
  background: white;
  border: 1px solid var(--border);
  font-weight: 800;
  color: var(--primary);
}
.metric-grid { grid-template-columns: repeat(4, 1fr); margin: 22px 0; }
.metric-card span, .profile-info-grid span { color: var(--muted); font-size: 0.92rem; }
.metric-card h2 { margin: 10px 0 6px; font-size: 2rem; }
.metric-card p { margin: 0; color: var(--muted); }
.dashboard-grid { grid-template-columns: 0.95fr 1.05fr; align-items: start; }
.map-panel { min-height: 100%; }
.alert-grid { grid-template-columns: 1fr; }
.alert-card {
  display: flex;
  flex-direction: row;
  padding: 0;
  overflow: hidden;
  border-radius: 24px;
  background: white;
  border: 1px solid rgba(201,24,24,0.08);
  box-shadow: var(--shadow);
}

/* ── Left: square photo panel ── */
.alert-card__photo-wrap {
  flex: 0 0 50%;
  position: relative;
  overflow: hidden;
  background: #f1f5f9;
  cursor: pointer;
}
.alert-card__photo-wrap img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.18s ease;
}
.alert-card__photo-wrap:hover img { opacity: 0.84; }
.alert-card__photo-wrap--empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #b0b8c8;
  font-size: 0.78rem;
  cursor: default;
  background: #f8fafc;
}

/* ── Right: body (minimap + info) ── */
.alert-card__body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.alert-card__minimap {
  height: 130px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  position: relative;
  background: #eef2f8;
}
.alert-card__minimap .leaflet-control-zoom { margin: 6px; }
.alert-card__minimap .leaflet-control-zoom a { width: 24px; height: 24px; line-height: 24px; font-size: 14px; }
.alert-mini__no-loc {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  color: #9ca3af;
}

.alert-card__info {
  padding: 12px 16px;
}
.alert-card__info h3 { margin: 4px 0 2px; font-size: 1rem; }
.alert-card__info > p { margin: 0; color: var(--muted); font-size: 0.85rem; }
.alert-card__info .alert-actions { margin-top: 10px; }

.alert-meta {
  display: grid;
  grid-template-columns: max-content 1fr;
  column-gap: 6px;
  row-gap: 3px;
  color: #333;
  font-size: 0.85rem;
  margin-top: 8px;
}

@media (max-width: 640px) {
  .alert-card { flex-direction: column; }
  .alert-card__photo-wrap { flex: 0 0 auto; width: 100%; min-height: 200px; }
}
.table-card { overflow: hidden; }
.table-scroll { overflow-x: auto; }
.table-scroll table { width: 100%; border-collapse: collapse; min-width: 760px; }
.table-scroll th, .table-scroll td {
  padding: 9px 14px;
  border-bottom: 1px solid #f2dede;
  text-align: left;
  font-size: 0.9rem;
}
.table-scroll thead th { background: #fff6f6; color: var(--primary-dark); }

/* History section — fills remaining viewport so pagination stays at bottom */
#historySection.active-section {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 56px); /* 28px top + 28px bottom padding from dashboard-main */
}
#historySection .table-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#historySection .table-scroll {
  flex: 1;
  overflow: auto;
  min-height: 0;
}
#historySection .history-pagination {
  flex-shrink: 0;
}
.profile-card-large { padding: 26px; }
.alert-banner {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin: 22px 0 8px;
  padding: 24px;
  border-radius: 28px;
  background: linear-gradient(135deg, #fff0f0 0%, #ffffff 100%);
  border: 1px solid rgba(201, 24, 24, 0.10);
  box-shadow: var(--shadow);
}
.alert-banner__content {
  flex: 1;
  display: grid;
  gap: 10px;
  align-content: start;
}
.alert-banner__content h2 { margin: 0; font-size: clamp(1.4rem, 2.6vw, 2rem); line-height: 1.1; }
.alert-banner__content p { margin: 0; color: var(--muted); line-height: 1.6; }
.alert-banner__media { width: min(360px, 100%); display: grid; }
.alert-banner__capture {
  display: grid;
  gap: 0;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: white;
  color: inherit;
  box-shadow: 0 18px 36px rgba(168, 24, 24, 0.10);
}
.alert-banner__capture img { width: 100%; height: 220px; object-fit: cover; display: block; }
.alert-banner__capture span { padding: 14px 16px; font-weight: 800; color: var(--primary); }
.alert-banner-empty { min-height: 220px; display: grid; place-items: center; text-align: center; }

/* ── Alert photo thumbnail ── */
.alert-photo { margin-top: 14px; }
.alert-photo img {
  width: 100%;
  display: block;
  max-height: 240px;
  object-fit: cover;
  border-radius: 20px;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: opacity 0.18s ease;
}
.alert-photo img:hover { opacity: 0.85; }

/* ── Device tag chip ── */
.device-tag {
  display: inline-flex;
  align-items: center;
  margin-left: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: 0.75rem;
  font-weight: 700;
}

.evidence-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: inherit;
  text-decoration: none;
}
.evidence-link:hover span { color: var(--primary); }
.evidence-thumb {
  width: 56px; height: 56px;
  object-fit: cover;
  border-radius: 12px;
  border: 1px solid var(--border);
}
.evidence-empty { color: var(--muted); font-style: italic; }

/* ── Photo lightbox modal ── */
.photo-modal {
  position: fixed;
  inset: 0;
  z-index: 10080;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.photo-modal.open { display: flex; }
.photo-modal-backdrop { position: absolute; inset: 0; }
.photo-modal-content {
  position: relative;
  z-index: 1;
  width: min(920px, 100%);
  background: white;
  border-radius: 26px;
  padding: 18px;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.25);
}
.photo-modal-content img {
  width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 20px;
  display: block;
  background: #111;
}
.photo-modal-close {
  position: absolute;
  top: 10px; right: 10px;
  width: 38px; height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: white;
  font-size: 1.2rem;
  display: grid;
  place-items: center;
}

/* ── Profile ── */
.profile-top { justify-content: flex-start; margin-bottom: 24px; }
.profile-top p { color: var(--muted); margin: 7px 0; }
.profile-info-grid { grid-template-columns: repeat(2, 1fr); }
.profile-info-grid > div {
  padding: 18px;
  border-radius: 18px;
  background: #fffafa;
  border: 1px solid var(--border);
  display: grid;
  gap: 8px;
}

.empty-state {
  padding: 18px;
  border-radius: 18px;
  border: 1px dashed rgba(201,24,24,0.2);
  color: var(--muted);
  background: #fffdfd;
}

/* ── Devices section ── */
.devices-hero { margin-bottom: 32px; }
.devices-hero__copy { margin-bottom: 24px; }
.devices-hero__note {
  padding: 20px;
  background: var(--primary-soft);
  border-radius: var(--radius-md);
  border: 1px solid rgba(201, 24, 24, 0.1);
}
.devices-metric-grid { margin-bottom: 32px; }
.devices-toolbar {
  margin-bottom: 32px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 24px;
}
.devices-toolbar__filters { display: flex; gap: 16px; align-items: center; }
.devices-toolbar__filters label { display: flex; flex-direction: column; gap: 8px; }
.devices-toolbar__filters label span { font-size: 0.875rem; font-weight: 600; color: var(--text); }
.devices-toolbar__filters select,
.devices-toolbar__filters input {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: white;
  font-size: 0.875rem;
}
.devices-toolbar__filters input { min-width: 280px; }

.devices-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 24px;
}
.device-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}
.device-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 60px rgba(168, 24, 24, 0.15);
}
.device-card--online { border-color: rgba(34, 197, 94, 0.2); }
.device-card--offline { border-color: rgba(239, 68, 68, 0.2); opacity: 0.8; }
.device-card__top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.device-chip {
  display: inline-block;
  padding: 4px 12px;
  background: var(--primary-soft);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  margin-bottom: 8px;
}
.device-card h3 { margin: 0; font-size: 1.125rem; font-weight: 700; }
.device-status {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.device-status--online { background: rgba(34, 197, 94, 0.1); color: #16a34a; }
.device-status--offline { background: rgba(239, 68, 68, 0.1); color: #dc2626; }
.device-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 24px;
}
.device-card__meta > div { display: flex; flex-direction: column; gap: 4px; }
.device-card__meta span { font-size: 0.75rem; color: var(--muted); font-weight: 600; }
.device-card__meta strong { font-size: 0.875rem; color: var(--text); }
.device-card__wifi-panel {
  display: grid;
  gap: 16px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.device-card__wifi-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.device-card__wifi-head span {
  display: block;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  margin-bottom: 4px;
}

.device-card__wifi-head strong {
  display: block;
  font-size: 0.92rem;
  color: var(--text);
}

.device-wifi-empty-state {
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px dashed rgba(201, 24, 24, 0.22);
  background: #fffdfd;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

.wifi-network-chips {
  display: grid;
  gap: 10px;
}

.wifi-network-chip {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 12px 14px;
  background: #fffdfd;
  text-align: left;
  display: grid;
  gap: 4px;
  transition: border-color 0.18s ease, background 0.18s ease, transform 0.18s ease;
}

.wifi-network-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(201, 24, 24, 0.22);
  background: #fff7f7;
}

.wifi-network-chip--active {
  border-color: rgba(201, 24, 24, 0.35);
  background: linear-gradient(180deg, #fff0f0 0%, #ffffff 100%);
}

.wifi-network-chip strong {
  font-size: 0.92rem;
  color: var(--text);
}

.wifi-network-chip span {
  font-size: 0.8rem;
  color: var(--muted);
}

.device-card__wifi-panel .wifi-device-card__fields {
  margin: 0;
}

.device-card__wifi-panel .wifi-device-card__actions {
  margin-bottom: 0;
}

.device-card__footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.device-wifi {
  font-size: 0.875rem;
  color: var(--muted);
}

.device-wifi--empty {
  font-style: italic;
}

.device-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 48px 24px;
}

/* ── Shared device/camera tab polish ── */
.control-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.clock-box--small {
  min-width: 132px;
  padding: 12px 16px;
  font-size: 0.92rem;
}

.section-note {
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.devices-grid,
.camera-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
  gap: 24px;
}

.device-card,
.camera-card {
  padding: 24px;
  border-radius: var(--radius-lg);
  background: white;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.device-card {
  display: grid;
  gap: 18px;
}

.device-card:hover,
.camera-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 24px 60px rgba(168, 24, 24, 0.15);
}

.device-card--online,
.camera-card--online {
  border-color: rgba(34, 197, 94, 0.2);
}

.device-card--offline,
.camera-card--offline {
  border-color: rgba(239, 68, 68, 0.2);
  opacity: 0.92;
}

.camera-card {
  display: grid;
  gap: 18px;
}

.camera-card__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}

.camera-card__head h3 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

.camera-preview {
  position: relative;
  overflow: hidden;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: #fff7f7;
  box-shadow: 0 14px 30px rgba(168, 24, 24, 0.08);
}

.camera-preview img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  display: block;
}

.camera-preview__badge {
  position: absolute;
  left: 14px;
  top: 14px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(24, 24, 24, 0.78);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  backdrop-filter: blur(8px);
}

.camera-preview--empty {
  min-height: 280px;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  background: linear-gradient(180deg, #fff3f3 0%, #ffffff 100%);
}

.camera-preview--empty p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.6;
}

.camera-card__meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.camera-card__meta > div {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px 16px;
  border-radius: 18px;
  background: #fffafa;
  border: 1px solid var(--border);
}

.camera-card__meta span {
  font-size: 0.75rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.camera-card__meta strong {
  font-size: 0.9rem;
  color: var(--text);
  line-height: 1.4;
}

.camera-card__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.camera-card__actions .btn {
  flex: 1 1 140px;
}

.wifi-device-card__fields {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.wifi-field {
  display: grid;
  gap: 8px;
}

.wifi-field span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.wifi-field input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px 16px;
  background: #fffdfd;
  color: var(--text);
  outline: none;
  box-shadow: none;
}

.wifi-field input:focus {
  border-color: rgba(201, 24, 24, 0.35);
  box-shadow: 0 0 0 4px rgba(201, 24, 24, 0.08);
}

.wifi-device-card__actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.wifi-device-card__actions .btn {
  flex: 1 1 140px;
}

@media (max-width: 1100px) {
  .dashboard-layout {
    grid-template-columns: 250px 1fr;
  }

  .devices-grid,
  .camera-grid {
    grid-template-columns: 1fr;
  }

  .wifi-device-card__fields,
  .camera-card__meta {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .dashboard-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(201, 24, 24, 0.08);
    height: auto;
    overflow-y: visible;
    position: static;
  }

  .profile-mini {
    margin-top: 0;
  }

  .dashboard-main {
    padding: 20px;
    height: auto;
    overflow-y: visible;
  }

  .control-actions {
    width: 100%;
    justify-content: flex-start;
  }

  .clock-box--small {
    width: 100%;
  }

  .camera-card__actions .btn,
  .wifi-device-card__actions .btn {
    flex: 1 1 100%;
  }
}
/* ============================================================
   SAFETAP style additions (v5)
   Append these rules to the bottom of style.css
   ============================================================ */

/* ── device-ip-row (devices.js IP config row) ── */
.device-ip-row {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 12px;
  align-items: end;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.device-ip-label {
  display: grid;
  gap: 8px;
}
.device-ip-label span {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}
.device-ip-label input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fffdfd;
  outline: none;
}
.device-ip-label input:focus {
  border-color: rgba(201,24,24,0.35);
  box-shadow: 0 0 0 4px rgba(201,24,24,0.08);
}
.device-save-btn { align-self: end; white-space: nowrap; }
.device-card__hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.5;
}
.device-wifi-input {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 12px 14px;
  background: #fffdfd;
  outline: none;
}
.device-wifi-input:focus {
  border-color: rgba(201,24,24,0.35);
  box-shadow: 0 0 0 4px rgba(201,24,24,0.08);
}

/* ── Camera live stream ── */
.camera-stream-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 24px;
  overflow: hidden;
  border: 1px solid var(--border);
  background: #0d0d0d;
}

.camera-stream-iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
  background: #0d0d0d;
}

/* "🔴 Live" badge overlaid on the stream */
.camera-stream-badge {
  position: absolute;
  top: 14px;
  left: 14px;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(201, 24, 24, 0.88);
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  pointer-events: none;
}

/* Offline / unconfigured placeholder */
.camera-stream-offline {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  padding: 28px;
  text-align: center;
  background: linear-gradient(180deg, #fff3f3 0%, #ffffff 100%);
}
.camera-stream-offline strong {
  display: block;
  font-size: 1rem;
  margin-bottom: 8px;
  color: var(--text);
}
.camera-stream-offline p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}

/* ── Captures modal ── */
.captures-modal {
  position: fixed;
  inset: 0;
  z-index: 10060;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.captures-modal.open { display: flex; }

.captures-modal__backdrop {
  position: absolute;
  inset: 0;
}

.captures-modal__panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: 88vh;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 90px rgba(0,0,0,0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.captures-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 26px 26px 18px;
  border-bottom: 1px solid var(--border);
}
.captures-modal__head h3 {
  margin: 0 0 6px;
  font-size: 1.15rem;
}
.captures-modal__head p {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

/* ── Captures list (1 per row) ── */
.captures-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px 26px 8px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

.capture-item {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: white;
  overflow: hidden;
  cursor: pointer;
  min-height: 130px;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  box-shadow: 0 4px 14px rgba(168,24,24,0.06);
}
.capture-item:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 30px rgba(168,24,24,0.13);
}

.capture-item__thumb {
  width: 200px;
  flex-shrink: 0;
  position: relative;
  overflow: hidden;
  background: #f0f0f0;
}
.capture-item__thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 0.22s ease;
}
.capture-item:hover .capture-item__thumb img {
  transform: scale(1.05);
}

.capture-item__zoom-hint {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.42);
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.18s ease;
  pointer-events: none;
  text-align: center;
}
.capture-item:hover .capture-item__zoom-hint { opacity: 1; }

.capture-item__latest-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  background: #0f8b45;
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  z-index: 1;
}

.capture-item__info {
  flex: 1;
  min-width: 0;
  padding: 14px 18px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  justify-content: flex-start;
}

.capture-item__num {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.capture-item__date {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.capture-item__time {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

.capture-item__place {
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.4;
  margin-top: 2px;
}

.capture-item__tags {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 4px;
}

/* ── Captures pagination ── */
.captures-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 26px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  flex-wrap: wrap;
}

.captures-pag-info {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 500;
}

.captures-pag-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

.captures-pag-count {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text);
  min-width: 70px;
  text-align: center;
}

.captures-pag-btn {
  padding: 8px 16px;
  font-size: 0.82rem;
}

/* ── Responsive adjustments ── */
@media (max-width: 820px) {
  .device-ip-row {
    grid-template-columns: 1fr;
  }
  .captures-grid {
    padding: 14px 16px 6px;
    gap: 10px;
  }
  .capture-item__thumb {
    width: 130px;
  }
  .capture-item__info {
    padding: 12px 14px;
  }
  .captures-pagination {
    padding: 12px 16px 16px;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }
  .captures-modal__head {
    padding: 18px 16px 14px;
  }
  .captures-modal__panel {
    max-height: 94vh;
  }
}

/* ============================================================
   SAFETAP v6 — Responder system additions
   ============================================================ */

/* ── New status badge colours ── */
.badge-assigned   { background: #eff6ff; color: #1d4ed8; }
.badge-responding { background: #fff4db; color: #9a6700; }
.badge-arrived    { background: #f0fdf4; color: #15803d; }
.badge-closed     { background: #f3f4f6; color: #6b7280; }
.badge-overdue    { background: #fff0e6; color: #c45400; font-weight: 700; }

/* ── Incident type tag (alert cards + history table) ── */
.incident-type-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(29,78,216,0.08);
  color: #1d4ed8;
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.btn-success {
  color: #fff;
  background: linear-gradient(135deg, #0f8b45, #16a34a);
  box-shadow: 0 4px 14px rgba(15,139,69,0.20);
}
.btn-success:hover { background: linear-gradient(135deg, #0a6f37, #15803d); }

.btn-muted {
  background: transparent;
  color: var(--muted);
  border: 1px solid #e5e7eb;
}
.btn-muted:hover { background: #f3f4f6; color: var(--text); }

.alert-card__badges {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}

.alert-card--overdue {
  border-top: 3px solid #f97316;
  box-shadow: 0 0 0 1px rgba(249,115,22,0.18), var(--shadow);
}

/* ── Alert action row (Assign / Reassign buttons on alert cards) ── */
.alert-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.alert-actions .btn { flex: 1 1 100px; padding: 8px 12px; font-size: 0.8rem; border-radius: 12px; }

/* ── Assign Responder Modal ── */
.assign-modal {
  position: fixed;
  inset: 0;
  z-index: 10070;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.50);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.assign-modal.open { display: flex; }

.assign-modal__backdrop { position: absolute; inset: 0; }

.assign-modal__panel {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.20);
  padding: 28px;
  display: grid;
  gap: 20px;
}

.assign-modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}
.assign-modal__head h3 { margin: 0; font-size: 1.1rem; }
.assign-modal__head p  { margin: 6px 0 0; color: var(--muted); font-size: 0.88rem; }

.assign-modal__body { display: grid; gap: 14px; }
.assign-modal__body select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 13px 15px;
  font-family: inherit;
  font-size: 0.95rem;
  outline: none;
  background: #fffdfd;
  color: var(--text);
}
.assign-modal__body select:focus {
  border-color: rgba(201, 24, 24, 0.35);
  box-shadow: 0 0 0 4px rgba(201, 24, 24, 0.08);
}

.assign-modal__footer {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.assign-modal__footer .btn { flex: 1; }

/* ── Map filter bar ── */
.map-filter-bar {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 10px 0 8px;
}

.map-filter-btn {
  padding: 5px 13px;
  border-radius: 999px;
  border: 1.5px solid #e5e7eb;
  background: white;
  font-size: 0.75rem;
  font-weight: 700;
  color: #6b7280;
  transition: transform 0.15s ease, border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.map-filter-btn:hover {
  transform: translateY(-1px);
  border-color: #d1d5db;
  color: #374151;
}

.map-filter-btn--all.active       { background: #1e293b; color: white; border-color: #1e293b; }
.map-filter-btn--active.active    { background: #dc2626; color: white; border-color: #dc2626; }
.map-filter-btn--assigned.active  { background: #1d4ed8; color: white; border-color: #1d4ed8; }
.map-filter-btn--responding.active{ background: #f59e0b; color: white; border-color: #f59e0b; }
.map-filter-btn--arrived.active   { background: #f97316; color: white; border-color: #f97316; }
.map-filter-btn--resolved.active  { background: #16a34a; color: white; border-color: #16a34a; }

/* ── Custom Leaflet map pin (L.divIcon) ── */
.map-pin-icon { background: none !important; border: none !important; }

/* ============================================================
   History logs — date filter + pagination
   ============================================================ */

/* Filter button */
.history-date-wrap {
  position: relative;
  flex-shrink: 0;
}

.history-filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 16px;
  font-size: 0.85rem;
  font-weight: 700;
  border-radius: 12px;
  white-space: nowrap;
}

.history-filter-btn.active {
  background: var(--primary-soft);
  color: var(--primary-dark);
  border-color: rgba(201, 24, 24, 0.30);
}

/* Calendar popup */
.history-calendar-popup {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 500;
  background: white;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.13);
  padding: 16px;
  width: 280px;
  animation: calFadeIn 0.15s ease;
}
.history-calendar-popup.open { display: block; }

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

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

.hcal-month-lbl {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--text);
}

.hcal-nav {
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 28px;
  height: 28px;
  font-size: 1rem;
  line-height: 1;
  color: var(--muted);
  display: grid;
  place-items: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.hcal-nav:hover { background: var(--primary-soft); color: var(--primary); border-color: var(--border); }

.hcal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.hcal-dn {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 6px;
}

.hcal-day {
  background: none;
  border: none;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
  height: 32px;
  display: grid;
  place-items: center;
  transition: background 0.12s ease, color 0.12s ease;
}
.hcal-day:not(.hcal-day--empty):hover { background: var(--primary-soft); color: var(--primary); cursor: pointer; }
.hcal-day--empty { pointer-events: none; }
.hcal-day--today { color: var(--primary); font-weight: 800; }
.hcal-day--selected { background: var(--primary) !important; color: white !important; box-shadow: 0 2px 8px rgba(201,24,24,0.30); }

.hcal-clear-btn {
  display: block;
  width: 100%;
  margin-top: 10px;
  padding: 8px 0;
  background: none;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease;
}
.hcal-clear-btn:hover { background: #fef2f2; color: var(--primary); border-color: rgba(201,24,24,0.20); }

/* Pagination bar */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-top: 1px solid #f2dede;
}

.hist-pag-info {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 600;
}

.hist-pag-center {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.hist-pag-nav {
  padding: 6px 13px;
  font-size: 0.8rem;
  font-weight: 700;
  background: white;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.hist-pag-nav:hover:not(:disabled) { background: var(--primary-soft); color: var(--primary); border-color: rgba(201,24,24,0.25); }
.hist-pag-nav:disabled { opacity: 0.35; cursor: default; }

.hist-page-btn {
  min-width: 32px;
  height: 32px;
  padding: 0 6px;
  font-size: 0.8rem;
  font-weight: 700;
  background: white;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--muted);
  transition: background 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.hist-page-btn:hover { background: var(--primary-soft); color: var(--primary); border-color: rgba(201,24,24,0.25); }
.hist-page-btn.active { background: var(--primary); color: white; border-color: var(--primary); box-shadow: 0 2px 8px rgba(201,24,24,0.25); }

.hist-ellipsis {
  font-size: 0.8rem;
  color: var(--muted);
  padding: 0 4px;
  line-height: 32px;
}

.hist-page-size {
  padding: 6px 10px;
  font-size: 0.8rem;
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 9px;
  color: var(--text);
  background: white;
  cursor: pointer;
}
.hist-page-size:focus { outline: none; border-color: rgba(201,24,24,0.30); }

@media (max-width: 600px) {
  .history-pagination { flex-direction: column; align-items: flex-start; gap: 10px; }
  .history-calendar-popup { right: auto; left: 0; width: min(280px, 92vw); }
}

/* ── Skeleton + Pulse loading ─────────────────────────── */
@keyframes skeletonShimmer {
  0%   { background-position: -600px 0; }
  100% { background-position:  600px 0; }
}
@keyframes skeletonPulse {
  0%, 100% { box-shadow: 0 2px 12px rgba(201,24,24,0.04), var(--shadow, none); }
  50%       { box-shadow: 0 6px 28px rgba(201,24,24,0.13), 0 0 0 4px rgba(201,24,24,0.05); }
}

/* Base shimmer block — applied to individual skeleton shapes */
.skel {
  background: linear-gradient(90deg, #f2eeee 25%, #e8e2e2 50%, #f2eeee 75%);
  background-size: 600px 100%;
  animation: skeletonShimmer 1.5s infinite linear;
  border-radius: 8px;
  display: block;
}

/* Skeleton shape helpers */
.skel-line       { height: 13px; margin-bottom: 0; }
.skel-line--xs   { width: 30%; }
.skel-line--sm   { width: 45%; }
.skel-line--md   { width: 65%; }
.skel-line--full { width: 100%; }
.skel-h2         { height: 36px; width: 55%; }
.skel-badge      { width: 72px; height: 22px; border-radius: 999px; flex-shrink: 0; }
.skel-btn        { height: 36px; width: 130px; border-radius: 12px; }
.skel-rect       { width: 100%; }

/* Pulse glow on dynamically-injected skeleton cards */
.skeleton-card {
  animation: skeletonPulse 2s ease-in-out infinite;
}

/* ── Toast notifications ─────────────────────────────── */
.dashboard-toast-host {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9998;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.dashboard-toast {
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 0.875rem;
  font-weight: 600;
  color: #fff;
  background: #222;
  box-shadow: 0 8px 28px rgba(0,0,0,0.20);
  pointer-events: auto;
  animation: toastSlideIn 0.22s ease;
  max-width: 340px;
  line-height: 1.4;
}

.dashboard-toast--success { background: #0f8b45; }
.dashboard-toast--error   { background: var(--primary); }
.dashboard-toast--info    { background: #1d4ed8; }
.dashboard-toast--fade    { opacity: 0; transition: opacity 0.24s; }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── Confirmation dialog ─────────────────────────────── */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirmFadeIn 0.18s ease;
}

.confirm-box {
  background: #fff;
  border-radius: var(--radius-md);
  padding: 28px 28px 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.22);
  animation: confirmSlideUp 0.2s ease;
}

.confirm-box__title {
  margin: 0 0 10px;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
}

.confirm-box__message {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.confirm-box__actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

@keyframes confirmFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes confirmSlideUp {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Login success overlay ───────────────────────────── */
.login-success-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: confirmFadeIn 0.2s ease;
}

.login-success-box {
  background: #fff;
  border-radius: var(--radius-lg);
  padding: 40px 36px 32px;
  max-width: 360px;
  width: 90%;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0,0,0,0.22);
  animation: confirmSlideUp 0.25s ease;
}

.login-success-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: linear-gradient(135deg, #0f8b45, #16a34a);
  color: #fff;
  font-size: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 20px;
  box-shadow: 0 8px 24px rgba(15,139,69,0.3);
}

.login-success-box h3 {
  margin: 0 0 8px;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--text);
}

.login-success-box p {
  margin: 0 0 24px;
  color: var(--muted);
  font-size: 0.9rem;
}

.login-success-bar {
  height: 4px;
  background: #e5e7eb;
  border-radius: 999px;
  overflow: hidden;
}

.login-success-bar__fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #0f8b45, #16a34a);
  border-radius: 999px;
  animation: loginBarFill 2s linear forwards;
}

@keyframes loginBarFill {
  from { width: 0%; }
  to   { width: 100%; }
}

/* Overlay shimmer + pulse — apply directly to any card element */
.skel-loading {
  position: relative;
  overflow: hidden;
  animation: skeletonPulse 2s ease-in-out infinite;
}
.skel-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(243,239,239,0.93) 25%, rgba(234,227,227,0.93) 50%, rgba(243,239,239,0.93) 75%);
  background-size: 600px 100%;
  animation: skeletonShimmer 1.5s infinite linear;
  pointer-events: none;
  z-index: 2;
}