/* ═══════════════════════════════════════════════════════════════
   NEXGEN MONITOR — Dark Telemetry UI  v3
   ═══════════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ── Tokens ─────────────────────────────────────────────────── */
:root {
  --bg-void:       #070b12;
  --bg-surface:    #111827;
  --bg-elevated:   #1a2235;
  --bg-glass:      rgba(255,255,255,0.035);
  --glass-border:  rgba(255,255,255,0.08);

  --ok:            #22d3a4;
  --ok-glow:       rgba(34,211,164,0.22);
  --ok-dim:        rgba(34,211,164,0.12);
  --warn:          #f59e0b;
  --warn-glow:     rgba(245,158,11,0.22);
  --warn-dim:      rgba(245,158,11,0.12);
  --crit:          #f43f5e;
  --crit-glow:     rgba(244,63,94,0.24);
  --crit-dim:      rgba(244,63,94,0.12);

  --accent:        #6366f1;
  --accent-glow:   rgba(99,102,241,0.28);
  --sky:           #38bdf8;

  --text:          #f1f5f9;
  --text-2:        #94a3b8;
  --text-3:        #475569;

  --radius-sm:     8px;
  --radius-md:     12px;
  --radius-lg:     16px;
  --ease-spring:   cubic-bezier(0.16, 1, 0.3, 1);
  --transition:    200ms var(--ease-spring);

  /* Legacy compat */
  --border: var(--glass-border);
  --panel:  var(--bg-surface);
  --muted:  var(--text-2);
}

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

html { scroll-behavior: smooth; }

body {
  background: var(--bg-void);
  background-image:
    radial-gradient(ellipse 100% 55% at 50% -5%, rgba(30,45,100,0.70) 0%, transparent 65%),
    radial-gradient(ellipse 60% 40% at 80% 80%, rgba(99,102,241,0.06) 0%, transparent 60%),
    radial-gradient(ellipse 50% 30% at 10% 90%, rgba(34,211,164,0.05) 0%, transparent 55%);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  /* Noise texture overlay */
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.04'/%3E%3C/svg%3E");
  background-size: 200px 200px;
  opacity: 0.35;
  pointer-events: none;
  z-index: 0;
}

body > * { position: relative; z-index: 1; }

.dashboard-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.22;
  animation: orbFloat 16s ease-in-out infinite;
}

.orb-1 {
  width: 520px;
  height: 520px;
  left: -120px;
  top: -120px;
  background: radial-gradient(circle at 30% 30%, rgba(56,189,248,0.75), rgba(56,189,248,0.06) 65%, transparent 80%);
}

.orb-2 {
  width: 560px;
  height: 560px;
  right: -140px;
  bottom: -140px;
  animation-delay: -6s;
  background: radial-gradient(circle at 60% 40%, rgba(99,102,241,0.75), rgba(99,102,241,0.08) 65%, transparent 80%);
}

.bg-grid {
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(148,163,184,0.07) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148,163,184,0.07) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: radial-gradient(circle at center, rgba(0,0,0,0.75), transparent 90%);
}

.bg-scan {
  position: absolute;
  inset: -30% 0 auto 0;
  height: 35%;
  background: linear-gradient(180deg, transparent, rgba(34,211,164,0.09), transparent);
  animation: scanMove 7s linear infinite;
}

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20px, -16px) scale(1.06); }
}

@keyframes scanMove {
  0% { transform: translateY(-120%); }
  100% { transform: translateY(340%); }
}

a { color: var(--sky); text-decoration: none; transition: color var(--transition); }
a:hover { color: #7dd3fc; text-decoration: underline; }

/* ── Page entrance ───────────────────────────────────────────── */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes fadeUp {
  from { opacity: 0; transform: translateY(18px); }
  to   { opacity: 1; transform: translateY(0); }
}

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

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  padding: 18px 32px 0;
  backdrop-filter: blur(20px) saturate(1.4);
  background: rgba(7,11,18,0.85);
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 16px;
  animation: slideDown 400ms var(--ease-spring) both;
  /* Gradient bottom border */
  border-bottom: 1px solid transparent;
  background-clip: padding-box;
}

/* Animated gradient line at the bottom of topbar */
.topbar::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(99,102,241,0.6) 20%,
    rgba(34,211,164,0.5) 45%,
    rgba(56,189,248,0.5) 65%,
    rgba(99,102,241,0.6) 80%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: gradientShift 6s linear infinite;
}

@keyframes gradientShift {
  0%   { background-position: 0% 0%; }
  100% { background-position: 200% 0%; }
}

/* Live pulse dot */
.topbar::before {
  content: '';
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 12px 3px var(--ok-glow);
  flex-shrink: 0;
  animation: livePulse 2.8s ease-in-out infinite;
  margin-bottom: -18px; /* align with text vertically inside padded bar */
  align-self: center;
  margin-top: -18px;
}

/* Fix — topbar has bottom padding via pb */
.topbar { padding-bottom: 18px; }
.topbar::before { margin: 0; }

@keyframes livePulse {
  0%   { transform: scale(1);   opacity: 0.95; box-shadow: 0 0 0 0 rgba(34,211,164,0.55); }
  14%  { transform: scale(1.22); opacity: 1;   box-shadow: 0 0 0 7px rgba(34,211,164,0); }
  22%  { transform: scale(1);   opacity: 0.92; }
  30%  { transform: scale(1.16); opacity: 1;   box-shadow: 0 0 0 5px rgba(34,211,164,0); }
  44%  { transform: scale(1);   opacity: 0.9; }
  100% { transform: scale(1);   opacity: 0.75; box-shadow: 0 0 0 0 rgba(34,211,164,0); }
}

.site-logo {
  width: 120px;
  height: auto;
  border-radius: 8px;
  border: none;
  box-shadow: none;
}

.topbar h1 {
  font-size: 40px;
  font-weight: 700;
  letter-spacing: -0.03em;
  background: linear-gradient(100deg, #f1f5f9 0%, #94a3b8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.subtitle {
  font-size: 11px;
  color: var(--text-3);
  font-weight: 500;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.subtitle::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--ok);
  animation: livePulse 2.8s ease-in-out infinite;
  animation-delay: 1.4s;
}

/* ── Layout ──────────────────────────────────────────────────── */
.layout {
  padding: 22px 32px 48px;
  display: grid;
  gap: 18px;
  animation: fadeUp 500ms var(--ease-spring) 100ms both;
}

/* ── Glass card ──────────────────────────────────────────────── */
.card {
  background: var(--bg-glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px) saturate(1.2);
}

/* ── Summary cards ───────────────────────────────────────────── */
.summary {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 14px;
}

.summary-card {
  background: var(--bg-glass);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 20px 22px 18px;
  min-height: 118px;
  position: relative;
  overflow: hidden;
  cursor: default;
  /* stagger animation via --card-i set by JS */
  animation: slideInCard 500ms var(--ease-spring) calc(var(--card-i, 0) * 60ms) both;
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
}

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

.summary-card:hover {
  transform: translateY(-4px) scale(1.01);
  box-shadow: 0 16px 48px rgba(0,0,0,0.50), 0 0 0 1px var(--card-color, rgba(99,102,241,0.18));
  border-color: var(--card-color, rgba(255,255,255,0.16));
}

/* Top accent bar per card, color driven by --card-color */
.summary-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--card-color, var(--accent));
  opacity: 0.7;
  transition: opacity var(--transition);
}
.summary-card:hover::before { opacity: 1; }

/* Bottom-right decorative glow blob */
.summary-card::after {
  content: '';
  position: absolute;
  bottom: -20px;
  right: -20px;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: var(--card-color, var(--accent));
  opacity: 0.06;
  filter: blur(20px);
  pointer-events: none;
  transition: opacity var(--transition);
}
.summary-card:hover::after { opacity: 0.12; }

/* Per-card CSS colors (matched by data-card attribute set in JS) */
.summary-card[data-card="0"] { --card-color: rgba(99,102,241,0.70); }  /* Total — indigo */
.summary-card[data-card="1"] { --card-color: rgba(34,211,164,0.70); }  /* Healthy — teal */
.summary-card[data-card="2"] { --card-color: rgba(244,63,94,0.70); }   /* Stale/Crit — rose */
.summary-card[data-card="3"] { --card-color: rgba(251,146,60,0.70); }  /* Outdated — orange */
.summary-card[data-card="4"] { --card-color: rgba(245,158,11,0.70); }  /* SQL stale — amber */
.summary-card[data-card="5"] { --card-color: rgba(244,63,94,0.70); }   /* Alerts — rose */

.summary-title {
  color: var(--text-3);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  margin-bottom: 16px;
}

.summary-value {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 500;
  font-size: 38px;
  color: var(--text);
  line-height: 1;
  letter-spacing: -0.03em;
  font-feature-settings: "tnum";
  transition: color 300ms ease;
}

/* ── Controls ────────────────────────────────────────────────── */
.controls {
  padding: 14px 16px;
  background: rgba(255,255,255,0.025);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.04), inset 0 -1px 0 rgba(0,0,0,0.15);
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(140px, 1fr));
  gap: 10px;
  align-items: center;
}

input, select {
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition), background var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

input::placeholder { color: var(--text-3); }

input:focus, select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
  background: rgba(255,255,255,0.06);
}

input:hover:not(:focus), select:hover:not(:focus) {
  border-color: rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.05);
}

/* Custom select arrow */
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  cursor: pointer;
}

select option { background: var(--bg-elevated); color: var(--text); }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  background: rgba(255,255,255,0.05);
  color: var(--text-2);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  transition: background var(--transition), border-color var(--transition),
              color var(--transition), transform var(--transition), box-shadow var(--transition);
  white-space: nowrap;
}

.btn:hover {
  background: rgba(255,255,255,0.10);
  border-color: rgba(255,255,255,0.20);
  color: var(--text);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.30);
}

.btn:active {
  transform: translateY(0) scale(0.97);
  box-shadow: none;
  transition-duration: 80ms;
}

.btn-light {
  background: rgba(255,255,255,0.04);
  border-color: rgba(255,255,255,0.08);
  color: var(--text-2);
  font-size: 13px;
  padding: 7px 13px;
}

.btn-light:hover {
  background: rgba(255,255,255,0.09);
  border-color: rgba(255,255,255,0.16);
  color: var(--text);
}

/* ── Table wrapper ───────────────────────────────────────────── */
.grid-wrap {
  padding: 0;
  overflow: auto;
  border-radius: var(--radius-md);
  -webkit-overflow-scrolling: touch;
}

/* Skeleton shimmer loading state */
.state {
  padding: 48px 20px;
  color: var(--text-3);
  text-align: center;
  font-size: 14px;
  position: relative;
  overflow: hidden;
}

.state::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.03) 40%,
    rgba(255,255,255,0.06) 50%,
    rgba(255,255,255,0.03) 60%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.hidden { display: none !important; }

/* ── Table ───────────────────────────────────────────────────── */
table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  position: sticky;
  top: 0;
  background: rgba(7,11,18,0.96);
  backdrop-filter: blur(16px) saturate(1.3);
  z-index: 2;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  padding: 14px 18px;
  border-bottom: 1px solid var(--glass-border);
  /* subtle gradient right-to-left on header */
  background: linear-gradient(180deg, rgba(15,20,30,0.98) 0%, rgba(10,14,22,0.95) 100%);
}

th, td {
  border-bottom: 1px solid rgba(255,255,255,0.05);
  padding: 15px 18px;
  vertical-align: middle;
}

td { font-size: 14px; }

/* ── Row entrance stagger ────────────────────────────────────── */
@keyframes rowFadeIn {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}

tbody tr {
  cursor: pointer;
  animation: rowFadeIn 350ms var(--ease-spring) calc(var(--row-i, 0) * 30ms) both;
  transition: background var(--transition), box-shadow var(--transition);
}

tbody tr:hover {
  background: rgba(99,102,241,0.09);
  box-shadow: inset 3px 0 0 var(--accent);
}

tbody tr.selected {
  background: rgba(99,102,241,0.15);
  box-shadow: inset 3px 0 0 var(--accent);
}

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

/* ── Status-aware row coloring ───────────────────────────────── */
tbody tr[data-health="Critical"] {
  background: rgba(244,63,94,0.04);
}
tbody tr[data-health="Critical"]:hover {
  background: rgba(244,63,94,0.09);
  box-shadow: inset 3px 0 0 var(--crit);
}
tbody tr[data-health="Critical"].selected {
  background: rgba(244,63,94,0.12);
  box-shadow: inset 3px 0 0 var(--crit);
}

tbody tr[data-health="Stale"] {
  background: rgba(245,158,11,0.03);
}
tbody tr[data-health="Stale"]:hover {
  background: rgba(245,158,11,0.08);
  box-shadow: inset 3px 0 0 var(--warn);
}
tbody tr[data-health="Stale"].selected {
  background: rgba(245,158,11,0.11);
  box-shadow: inset 3px 0 0 var(--warn);
}

/* ── Machine cell ────────────────────────────────────────────── */
.machine-primary {
  font-weight: 600;
  color: var(--text);
  font-size: 15px;
  letter-spacing: -0.01em;
}

.machine-secondary {
  color: var(--text-2);
  font-size: 13px;
  margin-top: 3px;
  line-height: 1.4;
}

/* ── Badges ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  transition: box-shadow var(--transition), transform var(--transition);
}

.badge:hover { transform: scale(1.05); }

/* Status dot shared */
.badge.Healthy::before,
.badge.Stale::before,
.badge.Critical::before {
  content: '';
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Healthy */
.badge.Healthy {
  color: var(--ok);
  background: var(--ok-dim);
  border: 1px solid rgba(34,211,164,0.22);
}
.badge.Healthy::before {
  background: var(--ok);
  animation: glowBreath 3s ease-in-out infinite;
}
@keyframes glowBreath {
  0%, 100% { box-shadow: 0 0 4px 1px var(--ok-glow); }
  50%       { box-shadow: 0 0 8px 3px var(--ok-glow); }
}

/* Stale */
.badge.Stale {
  color: var(--warn);
  background: var(--warn-dim);
  border: 1px solid rgba(245,158,11,0.24);
}
.badge.Stale::before {
  background: var(--warn);
  animation: warnPulse 2.5s ease-in-out infinite;
}
@keyframes warnPulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 3px var(--warn-glow); }
  50%       { opacity: 0.5; box-shadow: none; }
}

/* Critical */
.badge.Critical {
  color: var(--crit);
  background: var(--crit-dim);
  border: 1px solid rgba(244,63,94,0.25);
  animation: criticalBadgePulse 2s ease-in-out infinite;
  position: relative;
}
.badge.Critical::before {
  background: var(--crit);
  animation: critDotPulse 1.5s ease-in-out infinite;
}
@keyframes critDotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0.7); }
  50%       { box-shadow: 0 0 0 4px rgba(244,63,94,0); }
}
@keyframes criticalBadgePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(244,63,94,0.25); }
  50%       { box-shadow: 0 0 0 5px rgba(244,63,94,0); }
}

/* Version badges */
.badge.Current {
  color: #34d399;
  background: rgba(52,211,153,0.10);
  border: 1px solid rgba(52,211,153,0.20);
}
.badge.Outdated {
  color: #fb923c;
  background: rgba(251,146,60,0.10);
  border: 1px solid rgba(251,146,60,0.20);
}
.badge.Unknown {
  color: var(--text-3);
  background: rgba(75,85,99,0.20);
  border: 1px solid rgba(75,85,99,0.25);
}

/* ── Time cells ──────────────────────────────────────────────── */
.time-main {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  font-feature-settings: "tnum";
}

.time-sub {
  color: var(--text-3);
  font-size: 12px;
  font-family: 'JetBrains Mono', monospace;
  margin-top: 3px;
  font-feature-settings: "tnum";
}

/* ── Actions cell ────────────────────────────────────────────── */
.actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

tbody .actions .btn-light {
  opacity: 0.82;
  transform: translateY(1px);
}

tbody tr:hover .actions .btn-light {
  opacity: 1;
  transform: translateY(0);
}

/* ── Details panel ───────────────────────────────────────────── */
.panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 6, 12, 0.52);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
  z-index: 25;
}

.panel-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

body.details-open {
  overflow: hidden;
}

.details-panel {
  position: fixed;
  top: 0;
  right: -560px;
  width: 560px;
  max-width: 94vw;
  height: 100%;
  background: rgba(9,13,22,0.97);
  backdrop-filter: blur(28px) saturate(1.3);
  border-left: 1px solid var(--glass-border);
  transition: right 350ms cubic-bezier(0.22, 1, 0.36, 1),
              box-shadow 350ms ease;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.details-panel.open {
  right: 0;
  box-shadow: -24px 0 80px rgba(0,0,0,0.55), -1px 0 0 rgba(255,255,255,0.06);
}

.details-header {
  padding: 20px 22px;
  border-bottom: 1px solid var(--glass-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(180deg, rgba(99,102,241,0.06) 0%, rgba(255,255,255,0.01) 100%);
  flex-shrink: 0;
}

.details-header h2 {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  letter-spacing: -0.02em;
}

.details-body {
  padding: 16px 20px 24px;
  overflow-y: auto;
  flex: 1;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.10) transparent;
}

.details-body::-webkit-scrollbar { width: 4px; }
.details-body::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.10);
  border-radius: 4px;
}
.details-body::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.18); }

/* ── Detail blocks with stagger animation ────────────────────── */
@keyframes blockSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

.block {
  margin-bottom: 10px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 16px 18px;
  background: var(--bg-glass);
  transition: border-color var(--transition), box-shadow var(--transition);
  animation: blockSlideIn 400ms var(--ease-spring) calc(var(--block-i, 0) * 50ms) both;
}

.block:hover {
  border-color: rgba(255,255,255,0.13);
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
}

.block h3 {
  margin: 0 0 12px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 8px;
}

.block h3::before {
  content: '';
  display: inline-block;
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--accent) 0%, rgba(99,102,241,0.3) 100%);
  opacity: 0.8;
  flex-shrink: 0;
}

.kv {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.85;
}

.kv b { color: var(--text); font-weight: 500; }

/* ── Details lists ───────────────────────────────────────────── */
.details-body ul { list-style: none; padding: 0; margin: 0; }

.details-body li {
  padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.6;
  transition: color var(--transition);
}

.details-body li:hover { color: var(--text); }
.details-body li:last-child { border-bottom: none; }

/* ── Pre / JSON ──────────────────────────────────────────────── */
pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  background: rgba(0,0,0,0.45);
  border: 1px solid rgba(255,255,255,0.06);
  color: #94a3b8;
  padding: 14px;
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11.5px;
  line-height: 1.65;
}

/* ── <details> summary ───────────────────────────────────────── */
details summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--text-3);
  font-weight: 500;
  user-select: none;
  padding: 4px 0;
  outline: none;
  transition: color var(--transition);
  display: flex;
  align-items: center;
  gap: 6px;
}
details summary::before {
  content: '▶';
  font-size: 9px;
  transition: transform var(--transition);
  display: inline-block;
}
details[open] summary::before { transform: rotate(90deg); }
details summary:hover { color: var(--text-2); }

/* ── Photo task slider ───────────────────────────────────────── */
input[type="range"] {
  flex: 1;
  border: none;
  padding: 0;
  accent-color: var(--accent);
  background: transparent;
  cursor: pointer;
}

/* ── Photo library overlay ───────────────────────────────────── */
.photo-library-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.78);
  backdrop-filter: blur(8px) saturate(1.2);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 220ms ease-out;
}

.photo-library-modal {
  width: min(1200px, 96vw);
  height: min(85vh, 900px);
  background: rgba(10,14,22,0.98);
  backdrop-filter: blur(24px) saturate(1.3);
  border-radius: var(--radius-lg);
  border: 1px solid var(--glass-border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 40px 100px rgba(0,0,0,0.70), 0 0 0 1px rgba(255,255,255,0.05);
  animation: slideUpModal 280ms cubic-bezier(0.22,1,0.36,1);
}

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

.photo-library-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--glass-border);
  flex-shrink: 0;
  background: rgba(255,255,255,0.02);
}

.photo-library-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.photo-library-grid {
  padding: 16px;
  overflow: auto;
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.10) transparent;
}

.photo-card {
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
  padding: 8px;
  background: var(--bg-glass);
  transition: border-color var(--transition), transform var(--transition), box-shadow var(--transition);
  cursor: pointer;
}

.photo-card:hover {
  border-color: rgba(255,255,255,0.18);
  transform: translateY(-3px) scale(1.01);
  box-shadow: 0 12px 32px rgba(0,0,0,0.40);
}

.photo-card img {
  width: 100%;
  height: 160px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  cursor: zoom-in;
  display: block;
  transition: opacity var(--transition);
}

.photo-card:hover img { opacity: 0.90; }

.photo-card-meta {
  margin-top: 8px;
  font-size: 11px;
  color: var(--text-3);
  font-family: 'JetBrains Mono', monospace;
}

/* ── Lightbox ────────────────────────────────────────────────── */
.photo-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 1200;
}

.photo-lightbox.hidden { display: none !important; }

.photo-lightbox img {
  max-width: min(90vw, 1400px);
  max-height: 85vh;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255,255,255,0.12);
  background: #000;
  box-shadow: 0 0 100px rgba(0,0,0,0.90);
}

/* ── Focus polish (all interactive) ─────────────────────────── */
button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  box-shadow: 0 0 0 4px var(--accent-glow);
}

/* ── Smooth topbar → content transition overlay ──────────────── */
.layout::before {
  content: '';
  position: absolute;
  top: -1px;
  left: 0; right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99,102,241,0.2), transparent);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1280px) {
  .summary      { grid-template-columns: repeat(3, minmax(150px, 1fr)); }
  .control-grid { grid-template-columns: repeat(3, minmax(140px, 1fr)); }
}

@media (max-width: 768px) {
  .layout        { padding: 12px 12px 28px; }
  .topbar        { padding: 12px 12px; }
  .site-logo     { width: 120px; }
  .topbar h1     { font-size: 18px; }
  .subtitle      { font-size: 10px; }
  .summary       { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .summary-card  { min-height: 92px; padding: 12px; }
  .summary-value { font-size: 32px; }
  .control-grid  { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  .grid-wrap { overflow: visible; }
  .grid-wrap::after { display: none; }

  #clientsTable { min-width: 0; border-collapse: separate; border-spacing: 0 10px; }
  #clientsTable thead { display: none; }
  #clientsTable tbody,
  #clientsTable tr,
  #clientsTable td { display: block; width: 100%; }

  #clientsTable tr {
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    background: rgba(255,255,255,0.03);
    padding: 8px;
    margin-bottom: 10px;
  }

  #clientsTable td {
    border-bottom: 1px dashed rgba(255,255,255,0.08);
    padding: 6px 8px;
  }

  #clientsTable td:last-child { border-bottom: none; }

  #clientsTable td::before {
    display: block;
    font-size: 11px;
    color: var(--text-3);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin-bottom: 4px;
    font-weight: 600;
  }

  #clientsTable td:nth-child(1)::before { content: 'Machine'; }
  #clientsTable td:nth-child(2)::before { content: 'Status'; }
  #clientsTable td:nth-child(3)::before { content: 'Core Version'; }
  #clientsTable td:nth-child(4)::before { content: 'Shipsnavo SQL'; }
  #clientsTable td:nth-child(5)::before { content: 'Navomare SQL'; }
  #clientsTable td:nth-child(6)::before { content: 'SOLAS SQL'; }
  #clientsTable td:nth-child(7)::before { content: 'Last Seen'; }
  #clientsTable td:nth-child(8)::before { content: 'System'; }
  #clientsTable td:nth-child(9)::before { content: 'Actions'; }

  /* compact mobile row: keep only critical info in list view */
  #clientsTable td:nth-child(4),
  #clientsTable td:nth-child(5),
  #clientsTable td:nth-child(6) {
    display: none;
  }

  #clientsTable .machine-primary { font-size: 16px; }
  #clientsTable .machine-secondary { font-size: 12px; margin-top: 1px; }
  #clientsTable .badge { font-size: 11px; padding: 3px 9px; }
  #clientsTable .time-main { font-size: 13px; }
  #clientsTable .time-sub { font-size: 11px; }

  /* keep hardware + external IP visible, but compact */
  #clientsTable td:nth-child(8) > div:first-child {
    font-size: 12px;
    line-height: 1.35;
    color: var(--text-2);
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
  }
  #clientsTable td:nth-child(8) .machine-secondary {
    font-size: 12px;
    line-height: 1.35;
    word-break: break-word;
  }

  /* status + core version on same row */
  #clientsTable td:nth-child(2),
  #clientsTable td:nth-child(3) {
    display: inline-block;
    width: calc(50% - 2px);
    vertical-align: top;
  }

  #clientsTable td:nth-child(2) { border-right: 1px dashed rgba(255,255,255,0.08); }

  #clientsTable td:nth-child(9) .actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
  }

  #clientsTable td:nth-child(9) .btn {
    width: 100%;
    padding: 8px 7px;
    font-size: 12px;
  }

  .details-panel { width: 100%; max-width: 100vw; }
}

/* ── Prefers reduced motion ──────────────────────────────────── */
@media (max-width: 480px) {
  .summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .control-grid { grid-template-columns: 1fr; }
  input, select, .btn { font-size: 16px; } /* prevent iOS zoom-in */
  .actions { gap: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
