/* =============================================================
   Prewall Dashboard — Custom Styles
   Dark cybersecurity theme built on top of Tailwind CDN
   ============================================================= */

/* ---- CSS Variables ---- */
:root {
  --bg:         #0f172a;
  --surface:    #1e293b;
  --surface-2:  #263348;
  --border:     #334155;
  --muted:      #475569;
  --text:       #cbd5e1;
  --bright:     #f1f5f9;
  --blue:       #3b82f6;
  --red:        #ef4444;
  --green:      #22c55e;
  --amber:      #f59e0b;
  --purple:     #a855f7;
  --sidebar-w:  240px;
  --topbar-h:   56px;
  --radius:     0.75rem;
  --transition: 200ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ---- Reset & Base ---- */
*, *::before, *::after { box-sizing: border-box; }
html { height: 100%; }
body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', ui-sans-serif, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--surface); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }
* { scrollbar-width: thin; scrollbar-color: var(--border) var(--surface); }

/* ============================================================
   LOGIN PAGE
   ============================================================ */
.login-page {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse 80% 60% at 50% -20%, rgba(59,130,246,0.18) 0%, transparent 70%),
              radial-gradient(ellipse 60% 40% at 80% 110%, rgba(239,68,68,0.10) 0%, transparent 60%),
              var(--bg);
  z-index: 100;
}

.login-page.hidden { display: none; }

.login-canvas {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
}

.login-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 400px;
  margin: 1rem;
  background: linear-gradient(135deg, rgba(30,41,59,0.98) 0%, rgba(15,23,42,0.98) 100%);
  border: 1px solid rgba(51,65,85,0.8);
  border-radius: 1.25rem;
  padding: 2.5rem 2rem;
  box-shadow:
    0 0 0 1px rgba(59,130,246,0.06),
    0 25px 60px -12px rgba(0,0,0,0.8),
    0 0 60px -20px rgba(59,130,246,0.15);
  backdrop-filter: blur(24px);
  animation: card-appear 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes card-appear {
  from { opacity: 0; transform: translateY(24px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.login-logo {
  width: 64px;
  height: 64px;
  border-radius: 1rem;
  background: linear-gradient(135deg, rgba(59,130,246,0.2), rgba(29,78,216,0.3));
  border: 1px solid rgba(59,130,246,0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 24px -6px rgba(59,130,246,0.5);
  margin: 0 auto;
}

/* ---- Forms ---- */
.form-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 0.4rem;
  letter-spacing: 0.01em;
}

.form-input {
  width: 100%;
  padding: 0.625rem 0.875rem;
  background: rgba(15,23,42,0.6);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  color: var(--bright);
  font-size: 0.9rem;
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}

.form-input:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(59,130,246,0.18);
}

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

.form-input.error { border-color: var(--red); }

select.form-input option { background: var(--surface); }

.password-toggle {
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--muted);
  cursor: pointer;
  transition: color var(--transition);
  background: none;
  border: none;
  padding: 0;
}
.password-toggle:hover { color: var(--text); }

/* ---- Buttons ---- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.25rem;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: white;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: 0.5rem;
  border: none;
  cursor: pointer;
  transition: opacity var(--transition), box-shadow var(--transition), transform var(--transition);
  text-decoration: none;
  box-shadow: 0 4px 14px -4px rgba(59,130,246,0.5);
  letter-spacing: 0.01em;
}
.btn-primary:hover { opacity: 0.88; box-shadow: 0 6px 20px -4px rgba(59,130,246,0.6); transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); opacity: 1; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary.btn-sm { padding: 0.375rem 0.75rem; font-size: 0.8125rem; }

.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  background: rgba(239,68,68,0.15);
  color: #f87171;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 0.4rem;
  border: 1px solid rgba(239,68,68,0.3);
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.btn-danger:hover { background: rgba(239,68,68,0.25); box-shadow: 0 0 12px -4px rgba(239,68,68,0.4); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.375rem 0.75rem;
  background: rgba(51,65,85,0.6);
  color: var(--text);
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: background var(--transition);
}
.btn-secondary:hover { background: rgba(71,85,105,0.6); }

.btn-ghost {
  display: inline-flex;
  align-items: center;
  padding: 0.375rem 0.75rem;
  background: transparent;
  color: var(--muted);
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: 0.4rem;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  text-decoration: none;
}
.btn-ghost:hover { color: var(--bright); background: rgba(51,65,85,0.4); }

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: linear-gradient(180deg, #1a2744 0%, #111827 100%);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform var(--transition);
  z-index: 50;
  flex-shrink: 0;
}

@media (max-width: 1023px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0,0,0,0.6);
  }
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
  backdrop-filter: blur(2px);
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 1.125rem 1rem;
  border-bottom: 1px solid rgba(51,65,85,0.6);
}

.sidebar-logo {
  width: 32px;
  height: 32px;
  border-radius: 0.5rem;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand-text {
  font-size: 1rem;
  font-weight: 700;
  color: white;
  letter-spacing: -0.02em;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0.5rem;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  padding: 0.25rem 0.625rem 0.5rem;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.5625rem 0.75rem;
  border-radius: 0.5rem;
  color: #94a3b8;
  font-size: 0.875rem;
  font-weight: 500;
  text-decoration: none;
  transition: background var(--transition), color var(--transition);
  cursor: pointer;
  margin-bottom: 0.125rem;
}

.nav-item:hover {
  background: rgba(59,130,246,0.1);
  color: #cbd5e1;
}

.nav-item.active {
  background: linear-gradient(90deg, rgba(59,130,246,0.2), rgba(59,130,246,0.08));
  color: #93c5fd;
  border-left: 2px solid #3b82f6;
  padding-left: calc(0.75rem - 2px);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-footer {
  padding: 0.75rem 1rem;
  border-top: 1px solid rgba(51,65,85,0.6);
}

.sidebar-version {
  font-size: 0.6875rem;
  color: var(--muted);
}

/* ============================================================
   TOP BAR
   ============================================================ */
.topbar {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0 1rem 0 1.25rem;
  background: rgba(30,41,59,0.95);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar-menu-btn {
  color: var(--muted);
  padding: 0.375rem;
  border-radius: 0.375rem;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
}
.topbar-menu-btn:hover { color: var(--bright); background: rgba(51,65,85,0.5); }

.topbar-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--bright);
  letter-spacing: -0.01em;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 0.625rem;
  padding: 0.3rem 0.75rem 0.3rem 0.3rem;
  background: rgba(51,65,85,0.5);
  border: 1px solid var(--border);
  border-radius: 9999px;
}

.user-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
  text-transform: uppercase;
}

.user-info { line-height: 1.2; }
.user-name { font-size: 0.8125rem; font-weight: 600; color: var(--bright); }
.user-role { font-size: 0.6875rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }

.topbar-logout {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.375rem 0.75rem;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: 0.4rem;
  color: #f87171;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
}
.topbar-logout:hover { background: rgba(239,68,68,0.2); box-shadow: 0 0 10px -4px rgba(239,68,68,0.4); }

/* ============================================================
   PAGE SECTIONS
   ============================================================ */
.page-section {
  display: none;
  animation: page-in 0.25s ease both;
}
.page-section.active { display: block; }

@keyframes page-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition);
}

.card:hover { border-color: #475569; }

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(51,65,85,0.6);
}

.card-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--bright);
  letter-spacing: -0.01em;
}

.card-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-body { padding: 1.25rem; }

/* Glow hover on KPI cards */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  cursor: default;
}
.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 30px -8px rgba(0,0,0,0.5);
}

.kpi-icon {
  width: 44px;
  height: 44px;
  border-radius: 0.625rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.kpi-icon-blue  { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.2); }
.kpi-icon-red   { background: rgba(239,68,68,0.15);  color: #f87171; border: 1px solid rgba(239,68,68,0.2); }
.kpi-icon-green { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.2); }
.kpi-icon-amber { background: rgba(245,158,11,0.15); color: #fbbf24; border: 1px solid rgba(245,158,11,0.2); }

.kpi-body { flex: 1; min-width: 0; }
.kpi-label { font-size: 0.75rem; color: var(--muted); font-weight: 500; margin-bottom: 0.25rem; }
.kpi-value {
  font-size: 1.625rem;
  font-weight: 700;
  color: var(--bright);
  letter-spacing: -0.03em;
  line-height: 1;
  margin-bottom: 0.375rem;
}

.kpi-badge {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.15rem 0.45rem;
  border-radius: 9999px;
  letter-spacing: 0.02em;
}
.kpi-badge.up   { background: rgba(34,197,94,0.15);  color: #4ade80; }
.kpi-badge.down { background: rgba(239,68,68,0.15);  color: #f87171; }
.kpi-badge.flat { background: rgba(71,85,105,0.3);   color: var(--muted); }

.legend-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ============================================================
   CHARTS
   ============================================================ */
.chart-container {
  position: relative;
  width: 100%;
}

/* ============================================================
   MAP
   ============================================================ */
#attack-map {
  background: #0f172a;
  border-radius: 0 0 var(--radius) var(--radius);
  position: relative;   /* needed for absolute children */
  overflow: hidden;
}

/* Override leaflet tiles background */
.leaflet-container {
  background: #0d1b2a !important;
  font-family: 'Inter', sans-serif;
}

/* ── Improved popup styling ──────────────────────────────────── */
.leaflet-popup-content-wrapper,
.map-popup-wrapper .leaflet-popup-content-wrapper {
  background: rgba(15,23,42,0.96) !important;
  border: 1px solid rgba(239,68,68,0.35) !important;
  border-radius: 0.625rem !important;
  box-shadow:
    0 0 0 1px rgba(239,68,68,0.12),
    0 12px 32px rgba(0,0,0,0.7),
    0 0 24px -8px rgba(239,68,68,0.25) !important;
  color: var(--text);
  font-size: 0.8125rem;
  backdrop-filter: blur(8px);
  padding: 0 !important;
}

.leaflet-popup-content {
  margin: 0 !important;
}

.leaflet-popup-tip-container .leaflet-popup-tip,
.map-popup-wrapper .leaflet-popup-tip {
  background: rgba(15,23,42,0.96) !important;
}

.leaflet-popup-close-button {
  color: var(--muted) !important;
  top: 6px !important;
  right: 6px !important;
  font-size: 16px !important;
}
.leaflet-popup-close-button:hover { color: var(--bright) !important; }

/* Popup inner content */
.map-popup {
  padding: 0.75rem 1rem;
  min-width: 140px;
}

.map-popup-header {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}

.map-popup-country {
  font-weight: 700;
  color: var(--bright);
  font-size: 0.875rem;
}

.map-popup-cc {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: rgba(51,65,85,0.5);
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.map-popup-count {
  color: #f87171;
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -0.02em;
  line-height: 1;
}

.map-popup-sub {
  color: var(--muted);
  font-size: 0.6875rem;
  margin-top: 0.1875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* Legacy helpers still exported */
.map-popup-flag    { font-size: 1.25rem; margin-right: 0.25rem; }

/* ── Vignette edge overlay ───────────────────────────────────── */
.map-vignette {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 400;
  border-radius: 0 0 var(--radius) var(--radius);
  background:
    radial-gradient(ellipse at 0% 0%,   rgba(15,23,42,0.55) 0%, transparent 45%),
    radial-gradient(ellipse at 100% 0%, rgba(15,23,42,0.55) 0%, transparent 45%),
    radial-gradient(ellipse at 0% 100%, rgba(15,23,42,0.55) 0%, transparent 45%),
    radial-gradient(ellipse at 100% 100%, rgba(15,23,42,0.55) 0%, transparent 45%);
}

/* ── Threat count overlay (top-right inside map) ─────────────── */
.map-threat-overlay {
  position: absolute;
  top: 12px;
  right: 12px;
  z-index: 500;
  background: rgba(15,23,42,0.88);
  border: 1px solid rgba(239,68,68,0.35);
  border-radius: 0.625rem;
  padding: 0.5rem 0.875rem;
  text-align: right;
  pointer-events: none;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5), 0 0 16px -6px rgba(239,68,68,0.3);
}

.map-threat-label {
  font-size: 0.6rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.125rem;
}

.map-threat-value {
  font-size: 1.375rem;
  font-weight: 800;
  color: #f87171;
  letter-spacing: -0.03em;
  line-height: 1;
  text-shadow: 0 0 12px rgba(239,68,68,0.5);
}

/* ── Map legend (bottom-right inside map) ────────────────────── */
.map-legend {
  position: absolute;
  bottom: 28px;     /* above attribution bar */
  right: 12px;
  z-index: 500;
  background: rgba(15,23,42,0.88);
  border: 1px solid rgba(51,65,85,0.7);
  border-radius: 0.625rem;
  padding: 0.625rem 0.875rem;
  pointer-events: none;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  min-width: 110px;
}

.map-legend-title {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.map-legend-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}

.map-legend-circle {
  display: inline-block;
  border-radius: 50%;
  background: rgba(239,68,68,0.45);
  border: 1px solid rgba(248,113,113,0.7);
  flex-shrink: 0;
}

/* ── Pulse ring animation ────────────────────────────────────── */
@keyframes pulse-ring {
  0%   { transform: scale(0.5); opacity: 0.7; }
  60%  { opacity: 0.25; }
  100% { transform: scale(2.5); opacity: 0; }
}

.pulse-ring {
  border-radius: 50%;
  border: 2px solid rgba(239,68,68,0.75);
  background: rgba(239,68,68,0.08);
  animation: pulse-ring 2.4s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
  will-change: transform, opacity;
}

/* Leaflet removes default icon styles for DivIcons; reset positioning */
.leaflet-marker-icon .pulse-ring {
  position: absolute;
  top: 0;
  left: 0;
}

/* ── Attack trajectory line animation ────────────────────────── */
/*
   The JS sets CSS custom properties:
     --line-length  : total SVG path length in px
     --anim-delay   : per-line stagger delay in ms
*/
@keyframes draw-attack-line {
  0%   { stroke-dashoffset: var(--line-length, 800px); opacity: 0.8; }
  70%  { stroke-dashoffset: 0; opacity: 0.75; }
  85%  { stroke-dashoffset: 0; opacity: 0.6; }
  100% { stroke-dashoffset: 0; opacity: 0; }
}

.attack-trajectory-line {
  /* Base state: hidden until animation kicks in */
  opacity: 0;
}

.attack-trajectory-animate {
  stroke-dasharray: var(--line-length, 800px);
  stroke-dashoffset: var(--line-length, 800px);
  animation:
    draw-attack-line 1.8s cubic-bezier(0.4, 0, 0.2, 1)
    var(--anim-delay, 0ms)
    forwards;
  filter: drop-shadow(0 0 3px rgba(239,68,68,0.6));
}

/* ============================================================
   TABLES
   ============================================================ */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8625rem;
}

.data-table thead tr {
  background: rgba(15,23,42,0.5);
}

.data-table th {
  padding: 0.75rem 1.25rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  border-bottom: 1px solid rgba(51,65,85,0.6);
  white-space: nowrap;
}

.data-table td {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(51,65,85,0.35);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr:hover { background: rgba(51,65,85,0.18); }

/* Bar indicators in credential tables */
.bar-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: flex-end;
}
.bar-track {
  flex: 1;
  max-width: 80px;
  height: 4px;
  background: rgba(51,65,85,0.6);
  border-radius: 9999px;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 9999px;
  background: linear-gradient(90deg, #ef4444, #f97316);
  transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}
.bar-value {
  font-weight: 600;
  color: var(--bright);
  font-size: 0.8rem;
  white-space: nowrap;
}

/* Rank badge */
.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font-size: 0.7rem;
  font-weight: 700;
  background: rgba(51,65,85,0.6);
  color: var(--muted);
}
.rank-badge.rank-1 { background: rgba(245,158,11,0.2); color: #fbbf24; }
.rank-badge.rank-2 { background: rgba(148,163,184,0.2); color: #94a3b8; }
.rank-badge.rank-3 { background: rgba(180,83,9,0.2); color: #d97706; }

/* ============================================================
   STATUS INDICATORS
   ============================================================ */
.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.status-dot.online  { background: var(--green); box-shadow: 0 0 6px rgba(34,197,94,0.6); animation: pulse-green 2s infinite; }
.status-dot.offline { background: var(--muted); }
.status-dot.warning { background: var(--amber); box-shadow: 0 0 6px rgba(245,158,11,0.6); }

@keyframes pulse-green {
  0%, 100% { box-shadow: 0 0 4px rgba(34,197,94,0.6); }
  50%       { box-shadow: 0 0 10px rgba(34,197,94,0.9); }
}

/* ============================================================
   DEVICE CARDS
   ============================================================ */
.device-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: box-shadow var(--transition), border-color var(--transition), transform var(--transition);
  cursor: pointer;
}

.device-card:hover {
  border-color: rgba(59,130,246,0.4);
  box-shadow: 0 0 20px -6px rgba(59,130,246,0.3), 0 8px 24px -8px rgba(0,0,0,0.5);
  transform: translateY(-2px);
}

.device-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.125rem 0.75rem;
  border-bottom: 1px solid rgba(51,65,85,0.5);
}

.device-serial {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--bright);
  font-family: 'Courier New', monospace;
  letter-spacing: 0.02em;
}

.device-body { padding: 1rem 1.125rem; }

/* Circular gauges */
.gauges-row {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.gauge-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.375rem;
}

.gauge-label {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

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

.gauge-bg { fill: none; stroke: rgba(51,65,85,0.6); }
.gauge-fill {
  fill: none;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1),
              stroke 0.4s ease;
}

.gauge-text {
  font-size: 0.7rem;
  font-weight: 700;
  fill: var(--bright);
  text-anchor: middle;
  dominant-baseline: central;
  transform: rotate(90deg);
  transform-origin: center;
}

.device-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.device-stat {
  background: rgba(15,23,42,0.4);
  border: 1px solid rgba(51,65,85,0.4);
  border-radius: 0.5rem;
  padding: 0.5rem 0.625rem;
}

.device-stat-label { font-size: 0.65rem; color: var(--muted); margin-bottom: 0.125rem; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em; }
.device-stat-value { font-size: 0.875rem; font-weight: 700; color: var(--bright); }

.device-footer {
  padding: 0.625rem 1.125rem;
  border-top: 1px solid rgba(51,65,85,0.4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
}

/* Type badge */
.type-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.175rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.type-hwhc      { background: rgba(59,130,246,0.15); color: #60a5fa; border: 1px solid rgba(59,130,246,0.25); }
.type-linuxagent { background: rgba(34,197,94,0.15);  color: #4ade80; border: 1px solid rgba(34,197,94,0.25); }
.type-wg        { background: rgba(168,85,247,0.15); color: #c084fc; border: 1px solid rgba(168,85,247,0.25); }

/* ============================================================
   ADMIN TABS
   ============================================================ */
.admin-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  padding: 0 1rem;
  gap: 0;
  overflow-x: auto;
}

.admin-tab {
  padding: 0.875rem 1.25rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  transition: color var(--transition), border-color var(--transition);
  white-space: nowrap;
  margin-bottom: -1px;
}

.admin-tab:hover { color: var(--text); }
.admin-tab.active { color: #60a5fa; border-bottom-color: #3b82f6; }

.admin-tab-content { display: none; }
.admin-tab-content.active { display: block; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.175rem 0.5rem;
  border-radius: 9999px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.badge-blue   { background: rgba(59,130,246,0.15); color: #60a5fa; }
.badge-red    { background: rgba(239,68,68,0.15);  color: #f87171; }
.badge-green  { background: rgba(34,197,94,0.15);  color: #4ade80; }
.badge-amber  { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-gray   { background: rgba(71,85,105,0.3);   color: var(--muted); }
.badge-purple { background: rgba(168,85,247,0.15); color: #c084fc; }

/* Score badges */
.score-critical { background: rgba(239,68,68,0.2);  color: #f87171; }
.score-high     { background: rgba(249,115,22,0.2); color: #fb923c; }
.score-medium   { background: rgba(245,158,11,0.2); color: #fbbf24; }
.score-low      { background: rgba(34,197,94,0.2);  color: #4ade80; }

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: overlay-in 0.2s ease both;
}

.modal-overlay.hidden { display: none; }

@keyframes overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 1rem;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 25px 60px -12px rgba(0,0,0,0.8);
  animation: modal-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.95) translateY(16px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--bright);
}

.modal-close {
  color: var(--muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 0.375rem;
  background: none;
  border: none;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover { color: var(--bright); background: rgba(51,65,85,0.5); }

.modal-content {
  overflow-y: auto;
  padding: 1.5rem;
  flex: 1;
}

.modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
  background: rgba(15,23,42,0.3);
}

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 500;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1.125rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 0.75rem;
  box-shadow: 0 8px 30px -6px rgba(0,0,0,0.6);
  min-width: 280px;
  max-width: 380px;
  pointer-events: auto;
  animation: toast-in 0.3s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.toast-success { border-left: 3px solid var(--green); }
.toast-error   { border-left: 3px solid var(--red); }
.toast-warning { border-left: 3px solid var(--amber); }
.toast-info    { border-left: 3px solid var(--blue); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(24px); }
  to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); max-height: 100px; margin-bottom: 0; }
  to   { opacity: 0; transform: translateX(24px); max-height: 0; margin-bottom: -12px; }
}

.toast-icon { flex-shrink: 0; width: 18px; height: 18px; margin-top: 0.1rem; }
.toast-success .toast-icon { color: var(--green); }
.toast-error   .toast-icon { color: var(--red); }
.toast-warning .toast-icon { color: var(--amber); }
.toast-info    .toast-icon { color: var(--blue); }

.toast-body { flex: 1; }
.toast-title   { font-size: 0.875rem; font-weight: 600; color: var(--bright); margin-bottom: 0.125rem; }
.toast-message { font-size: 0.8rem; color: var(--muted); line-height: 1.4; }

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes shimmer {
  from { background-position: -400px 0; }
  to   { background-position: 400px 0; }
}

.skeleton-block {
  background: linear-gradient(90deg,
    rgba(51,65,85,0.3) 25%,
    rgba(71,85,105,0.4) 50%,
    rgba(51,65,85,0.3) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
  border-radius: 0.5rem;
}

.skeleton-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  height: 320px;
  overflow: hidden;
  position: relative;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg,
    rgba(51,65,85,0.3) 25%,
    rgba(71,85,105,0.4) 50%,
    rgba(51,65,85,0.3) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
}

/* Inline skeleton text */
.skel-text {
  height: 0.875rem;
  border-radius: 4px;
  background: linear-gradient(90deg,
    rgba(51,65,85,0.4) 25%,
    rgba(71,85,105,0.5) 50%,
    rgba(51,65,85,0.4) 75%
  );
  background-size: 800px 100%;
  animation: shimmer 1.6s infinite linear;
}

/* ============================================================
   EMPTY STATES
   ============================================================ */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--muted);
}
.empty-state p { font-size: 0.9375rem; }

/* ============================================================
   ASSIGNMENTS
   ============================================================ */
.assignment-row {
  background: rgba(15,23,42,0.4);
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  padding: 1rem 1.125rem;
}
.assignment-user {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--bright);
  margin-bottom: 0.625rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.assignment-devices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}
.assignment-device-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.25rem 0.625rem;
  background: rgba(30,41,59,0.8);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 0.75rem;
  color: var(--text);
  font-family: 'Courier New', monospace;
}

/* ============================================================
   API KEY COPY BOX
   ============================================================ */
.apikey-box {
  background: rgba(15,23,42,0.8);
  border: 1px solid rgba(59,130,246,0.3);
  border-radius: 0.5rem;
  padding: 0.875rem 1rem;
  font-family: 'Courier New', monospace;
  font-size: 0.85rem;
  color: #93c5fd;
  word-break: break-all;
  letter-spacing: 0.02em;
}

/* ============================================================
   DEVICE DETAIL
   ============================================================ */
.detail-header {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.detail-icon {
  width: 56px;
  height: 56px;
  border-radius: 0.875rem;
  background: rgba(59,130,246,0.15);
  border: 1px solid rgba(59,130,246,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.detail-serial {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--bright);
  font-family: 'Courier New', monospace;
}

/* ============================================================
   TELEMETRY TABLE
   ============================================================ */
.telemetry-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 640px) {
  .card-body { padding: 1rem; }
  .kpi-value { font-size: 1.375rem; }
  .data-table th, .data-table td { padding: 0.625rem 0.875rem; }
  .modal-box { max-width: 100%; border-radius: 0.75rem; }
  .toast-container { bottom: 1rem; right: 1rem; left: 1rem; }
  .toast { min-width: unset; max-width: unset; }
}

@media (max-width: 768px) {
  .device-stats { grid-template-columns: 1fr; }
  .topbar-title { font-size: 0.9375rem; }
}

/* ============================================================
   MISC UTILITIES
   ============================================================ */
.truncate-cell {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.monospace { font-family: 'Courier New', monospace; font-size: 0.8125rem; }

.text-right { text-align: right; }
.text-center { text-align: center; }

.divider {
  height: 1px;
  background: var(--border);
  margin: 1rem 0;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(59,130,246,0.3);
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* IP / severity coloring */
.ip-cell { font-family: 'Courier New', monospace; font-size: 0.8125rem; color: #93c5fd; }

/* Scroll fade edges on horizontal scroll containers */
.scroll-fade {
  position: relative;
  overflow-x: auto;
}
