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

:root {
  /* Core palette — dark tactical */
  --bg:          #050508;
  --bg-1:        #0a0a0f;
  --bg-2:        #10101a;
  --bg-3:        #16161f;
  --surface:     #1a1a28;
  --surface-2:   #1f1f30;
  --surface-3:   #252538;

  /* Borders */
  --border:      rgba(255,255,255,.07);
  --border-2:    rgba(255,255,255,.12);
  --border-3:    rgba(255,255,255,.18);

  /* Brand */
  --blue:        #1d6bdb;
  --blue-dim:    #1050a8;
  --blue-glow:   rgba(29,107,219,.18);
  --blue-light:  #60a5fa;
  --green:       #14b869;
  --green-dim:   rgba(20,184,105,.15);
  --green-glow:  rgba(20,184,105,.25);
  --amber:       #f59e0b;
  --amber-dim:   rgba(245,158,11,.15);
  --red:         #ef4444;
  --red-dim:     rgba(239,68,68,.15);
  --red-glow:    rgba(239,68,68,.3);
  --cyan:        #06b6d4;
  --cyan-dim:    rgba(6,182,212,.12);

  /* Text */
  --text:        #e8e8f0;
  --text-2:      #9898b0;
  --text-3:      #55556a;
  --text-accent: #60a5fa;

  /* Typography */
  --font:        'Inter', system-ui, sans-serif;
  --font-head:   'Space Grotesk', sans-serif;
  --font-mono:   'JetBrains Mono', monospace;

  /* Radii */
  --r-xs: 3px; --r-sm: 6px; --r-md: 10px; --r-lg: 16px; --r-xl: 22px;

  /* Shadows */
  --sh-sm: 0 1px 6px rgba(0,0,0,.4);
  --sh-md: 0 4px 20px rgba(0,0,0,.5);
  --sh-lg: 0 12px 48px rgba(0,0,0,.6);
  --sh-blue: 0 0 24px rgba(29,107,219,.25);
  --sh-green: 0 0 20px rgba(20,184,105,.2);

  /* Transitions */
  --t: all .2s cubic-bezier(.4,0,.2,1);
  --t-fast: all .12s ease;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}

h1,h2,h3,h4,h5 { font-family: var(--font-head); line-height: 1.15; color: var(--text); }
a { color: var(--blue-light); text-decoration: none; }
a:hover { text-decoration: underline; }
code, .mono { font-family: var(--font-mono); font-size: .875em; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg-2); }
::-webkit-scrollbar-thumb { background: var(--surface-3); border-radius: 2px; }

/* ── Layout ── */
.container { max-width: 1180px; margin: 0 auto; padding: 0 28px; }
.section { padding: 80px 0; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.grid-3 { display: grid; grid-template-columns: repeat(3,1fr); gap: 20px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 16px; }

/* ── Navbar ── */
.navbar {
  position: sticky; top: 0; z-index: 200;
  background: rgba(5,5,8,.88);
  backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border);
  height: 64px;
}
.navbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0 28px;
  display: flex; align-items: center; justify-content: space-between; height: 100%;
}
.nav-logo { height: 36px; width: auto; }
.nav-links { display: flex; gap: 32px; list-style: none; }
.nav-links a { color: var(--text-2); font-size: 13px; font-weight: 500; letter-spacing: .2px; transition: var(--t); }
.nav-links a:hover, .nav-links a.active { color: var(--text); text-decoration: none; }
.nav-right { display: flex; gap: 10px; align-items: center; }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  font-family: var(--font); font-weight: 600; cursor: pointer;
  border: none; border-radius: var(--r-sm); transition: var(--t);
  text-decoration: none; white-space: nowrap; letter-spacing: .2px;
}
.btn:active { transform: scale(.97); }
.btn:hover { text-decoration: none; }

.btn-primary {
  background: var(--blue); color: #fff;
  padding: 10px 22px; font-size: 14px;
  box-shadow: 0 0 20px var(--blue-glow);
}
.btn-primary:hover { background: #2578f0; box-shadow: 0 0 28px rgba(29,107,219,.4); }

.btn-outline {
  background: transparent; color: var(--text);
  padding: 9px 20px; font-size: 14px;
  border: 1px solid var(--border-2);
}
.btn-outline:hover { border-color: var(--border-3); background: var(--surface); }

.btn-ghost {
  background: transparent; color: var(--text-2);
  padding: 8px 14px; font-size: 13px;
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--border-2); background: var(--bg-3); }

.btn-danger { background: var(--red); color: #fff; padding: 9px 18px; font-size: 13px; }
.btn-danger:hover { background: #dc2626; }

.btn-green { background: var(--green); color: #000; padding: 9px 18px; font-size: 13px; font-weight: 700; }
.btn-green:hover { background: #10a05d; }

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 13px 30px; font-size: 15px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  box-shadow: var(--sh-sm);
}
.card-p { padding: 22px; }
.card-glow { box-shadow: var(--sh-md), 0 0 40px var(--blue-glow); }

/* ── Panel headers ── */
.panel-head {
  padding: 14px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.panel-head h3 { font-size: 13px; font-weight: 600; color: var(--text); letter-spacing: .3px; text-transform: uppercase; }
.panel-head .meta { font-size: 12px; color: var(--text-3); font-family: var(--font-mono); }

/* ── Forms ── */
.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-label { font-size: 11px; font-weight: 600; color: var(--text-3); text-transform: uppercase; letter-spacing: .8px; }
.form-input, .form-select, .form-textarea {
  width: 100%; padding: 10px 13px;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--r-sm); color: var(--text);
  font-family: var(--font); font-size: 14px;
  transition: var(--t); -webkit-appearance: none;
}
.form-input::placeholder { color: var(--text-3); }
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: var(--blue);
  box-shadow: 0 0 0 2px var(--blue-glow);
}
.form-hint { font-size: 11px; color: var(--text-3); margin-top: 3px; }
.input-icon-wrap { position: relative; }
.input-icon { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); font-size: 14px; pointer-events: none; }
.input-icon-wrap .form-input { padding-left: 36px; }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 2px 9px; border-radius: 100px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.badge-live   { background: var(--green-dim); color: var(--green); border: 1px solid rgba(20,184,105,.3); }
.badge-alert  { background: var(--red-dim); color: var(--red); border: 1px solid rgba(239,68,68,.3); }
.badge-amber  { background: var(--amber-dim); color: var(--amber); border: 1px solid rgba(245,158,11,.3); }
.badge-cyan   { background: var(--cyan-dim); color: var(--cyan); border: 1px solid rgba(6,182,212,.2); }
.badge-muted  { background: var(--bg-3); color: var(--text-3); border: 1px solid var(--border); }
.badge-blue   { background: var(--blue-glow); color: var(--blue-light); border: 1px solid rgba(29,107,219,.3); }
.badge-dot::before { content:''; width:6px; height:6px; border-radius:50%; background:currentColor; animation: pulseBadge 1.8s ease-in-out infinite; }
@keyframes pulseBadge { 0%,100%{opacity:1} 50%{opacity:.35} }

/* ── Dividers ── */
hr.divider { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.section-divider { border: none; border-top: 1px solid var(--border); }

/* ── Telemetry / mono data ── */
.tele-val { font-family: var(--font-mono); font-size: 22px; font-weight: 500; color: var(--text); }
.tele-lbl { font-size: 11px; color: var(--text-3); margin-top: 2px; text-transform: uppercase; letter-spacing: .5px; }
.tele-good { color: var(--green); }
.tele-alert { color: var(--red); }
.tele-amber { color: var(--amber); }

/* ── Progress / TTL bars ── */
.ttl-bar-wrap { height: 4px; background: var(--bg-3); border-radius: 2px; overflow: hidden; }
.ttl-bar-fill { height: 100%; border-radius: 2px; transition: width 1s linear; }
.ttl-fill-green { background: var(--green); }
.ttl-fill-amber { background: var(--amber); }
.ttl-fill-red   { background: var(--red); }

/* ── Tables ── */
.data-table-wrap { overflow-x: auto; }
table.dt { width: 100%; border-collapse: collapse; }
table.dt th { text-align: left; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px; color: var(--text-3); padding: 10px 16px; background: var(--bg-2); border-bottom: 1px solid var(--border); }
table.dt td { padding: 11px 16px; font-size: 13px; border-bottom: 1px solid var(--border); color: var(--text-2); }
table.dt td.primary { color: var(--text); font-weight: 500; }
table.dt tr:last-child td { border-bottom: none; }
table.dt tr:hover td { background: var(--bg-3); }

/* ── Sidebar layout ── */
.sidebar-layout { display: grid; grid-template-columns: 220px 1fr; min-height: calc(100vh - 64px); }
.sidebar { background: var(--bg-1); border-right: 1px solid var(--border); padding: 20px 12px; }
.sb-section-title { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; color: var(--text-3); margin: 18px 0 6px 10px; }
.sb-section-title:first-child { margin-top: 0; }
.sb-item { display: flex; align-items: center; gap: 9px; padding: 9px 12px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; color: var(--text-2); cursor: pointer; transition: var(--t); border: none; background: none; width: 100%; text-align: left; font-family: var(--font); }
.sb-item:hover { background: var(--bg-3); color: var(--text); }
.sb-item.active { background: var(--blue-glow); color: var(--blue-light); border: 1px solid rgba(29,107,219,.2); }
.sb-item .icon { font-size: 14px; flex-shrink: 0; }
.sb-badge { margin-left: auto; background: var(--red); color: #fff; border-radius: 100px; font-size: 10px; font-weight: 700; padding: 1px 6px; }
.admin-main { padding: 24px 28px; overflow-y: auto; }

/* ── Stat cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
.stat-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 16px 18px; }
.stat-card .s-icon { font-size: 18px; margin-bottom: 10px; }
.stat-card .s-val { font-family: var(--font-mono); font-size: 24px; font-weight: 500; color: var(--text); }
.stat-card .s-lbl { font-size: 11px; color: var(--text-3); margin-top: 3px; text-transform: uppercase; letter-spacing: .5px; }
.stat-card.live { border-color: rgba(20,184,105,.3); box-shadow: var(--sh-green); }
.stat-card.alert { border-color: rgba(239,68,68,.3); box-shadow: 0 0 16px var(--red-glow); }

/* ── Modal ── */
.modal-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.7); align-items: center; justify-content: center; z-index: 1000; padding: 20px; backdrop-filter: blur(4px); }
.modal-overlay.open { display: flex; }
.modal-box { background: var(--bg-2); border: 1px solid var(--border-2); border-radius: var(--r-lg); max-width: 480px; width: 100%; box-shadow: var(--sh-lg); max-height: 90vh; overflow-y: auto; }
.modal-head { padding: 16px 22px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-head h3 { font-size: 15px; }
.modal-close { cursor: pointer; font-size: 20px; color: var(--text-3); background: none; border: none; line-height: 1; }
.modal-body { padding: 22px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot { padding: 14px 22px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── Toast ── */
.toast { position: fixed; top: 18px; right: 18px; padding: 12px 18px; border-radius: var(--r-sm); font-size: 13px; font-weight: 500; z-index: 9999; max-width: 360px; box-shadow: var(--sh-lg); display: flex; align-items: center; gap: 9px; animation: toastIn .25s ease-out; border: 1px solid; color: var(--text); }
.toast.success { background: #0a1f12; border-color: rgba(20,184,105,.4); color: var(--green); }
.toast.error   { background: #1f0a0a; border-color: rgba(239,68,68,.4);  color: var(--red); }
.toast.info    { background: #0a0f1f; border-color: rgba(29,107,219,.4); color: var(--blue-light); }
@keyframes toastIn  { from { transform:translateX(110%);opacity:0 } to { transform:translateX(0);opacity:1 } }
@keyframes toastOut { from { transform:translateX(0);opacity:1 } to { transform:translateX(110%);opacity:0 } }

/* ── Code / ID blocks ── */
.id-block { font-family: var(--font-mono); font-size: 12px; color: var(--cyan); background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--r-xs); padding: 3px 7px; letter-spacing: .5px; }

/* ── Scan animation ── */
@keyframes scan { 0%,100%{top:0} 50%{top:calc(100% - 2px)} }
.scan-line { position: absolute; left: 0; right: 0; height: 2px; background: linear-gradient(90deg,transparent,var(--blue),transparent); animation: scan 2.4s ease-in-out infinite; opacity: .6; }
@keyframes pulseRing { 0%{box-shadow:0 0 0 0 var(--green-glow)} 70%{box-shadow:0 0 0 12px transparent} 100%{box-shadow:0 0 0 0 transparent} }
.pulse-ring { animation: pulseRing 2s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.2} }

/* ── SOS styling ── */
.sos-critical { background: #1a0505; border: 1.5px solid rgba(239,68,68,.5); border-radius: var(--r-md); padding: 14px 16px; }
.sos-blink { width: 10px; height: 10px; border-radius: 50%; background: var(--red); flex-shrink: 0; animation: blink 0.8s infinite; }

/* ── Utility ── */
.text-muted  { color: var(--text-2); }
.text-green  { color: var(--green); }
.text-red    { color: var(--red); }
.text-amber  { color: var(--amber); }
.text-cyan   { color: var(--cyan); }
.text-accent { color: var(--blue-light); }
.mono        { font-family: var(--font-mono); }
.fw-600      { font-weight: 600; }
.fs-11       { font-size: 11px; }
.fs-12       { font-size: 12px; }
.fs-13       { font-size: 13px; }
.mt-4        { margin-top: 4px; }
.mt-8        { margin-top: 8px; }
.mt-12       { margin-top: 12px; }
.mt-16       { margin-top: 16px; }
.mt-24       { margin-top: 24px; }
.mb-8        { margin-bottom: 8px; }
.mb-16       { margin-bottom: 16px; }
.mb-24       { margin-bottom: 24px; }
.gap-8       { gap: 8px; }
.gap-12      { gap: 12px; }
.gap-16      { gap: 16px; }
.flex        { display: flex; }
.flex-col    { display: flex; flex-direction: column; }
.items-center{ align-items: center; }
.justify-between { justify-content: space-between; }

/* ── Mobile ── */
@media (max-width: 900px) {
  .container { padding: 0 18px; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .sidebar-layout { grid-template-columns: 1fr; }
  .sidebar { display: flex; overflow-x: auto; padding: 10px 12px; gap: 4px; border-right: none; border-bottom: 1px solid var(--border); }
  .sb-section-title { display: none; }
  .sb-item { white-space: nowrap; }
  .admin-main { padding: 18px 16px; }
  .nav-links { display: none; }
  .section { padding: 52px 0; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .btn-lg { padding: 12px 22px; font-size: 14px; }
}
