/* NMS Monitor — dark, technical, status-first.
   Palette:
   bg        #0F1417
   panel     #161D22
   panel-2   #1D262C
   border    #263139
   text      #E6EDF0
   muted     #7C8B93
   up        #3FB950
   down      #F85149
   unknown   #D4A72C
   accent    #2EC4B6
*/

:root {
  --bg: #0F1417;
  --panel: #161D22;
  --panel-2: #1D262C;
  --border: #263139;
  --text: #E6EDF0;
  --muted: #7C8B93;
  --up: #3FB950;
  --down: #F85149;
  --unknown: #D4A72C;
  --accent: #2EC4B6;
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 72px; /* room for bottom nav on mobile */
}

a { color: inherit; text-decoration: none; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 10;
}
.brand {
  font-weight: 700;
  font-size: 17px;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: -0.01em;
}
.brand-accent { color: var(--accent); }
.brand-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--up);
  box-shadow: 0 0 0 3px rgba(63,185,80,0.18);
  animation: pulse 2.2s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .brand-dot { animation: none; }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.topnav { display: none; gap: 4px; }
.topnav a {
  padding: 8px 14px;
  border-radius: 8px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14px;
}
.topnav a.active, .topnav a:hover { color: var(--text); background: var(--panel-2); }

@media (min-width: 760px) {
  .topnav { display: flex; }
  .bottomnav { display: none; }
  body { padding-bottom: 0; }
}

/* ---------- Bottom nav (mobile) ---------- */
.bottomnav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 10;
}
.bottomnav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
}
.bottomnav a.active { color: var(--accent); }
.bottomnav .icon { font-size: 17px; line-height: 1; }

/* ---------- Layout ---------- */
/* Diberi nama page-wrap, bukan container: Tailwind punya utility .container
   sendiri, dan base.html memakai class ini untuk membungkus seluruh halaman --
   kalau namanya bertabrakan, lebar semua halaman berubah begitu Tailwind
   dimuat. Modifier .container-wide sengaja tidak diganti nama: 14 template
   masih mengirimkannya lewat {% block container_class %}. */
.page-wrap {
  max-width: 880px;
  margin: 0 auto;
  padding: 16px;
}
.page-wrap.container-wide { max-width: 880px; }
@media (min-width: 1100px) { .page-wrap.container-wide { max-width: 1180px; } }
@media (min-width: 1440px) { .page-wrap.container-wide { max-width: 1500px; } }
@media (min-width: 1800px) { .page-wrap.container-wide { max-width: 1760px; } }

/* Dashboard top summary section: donut stats / category chart / latency chart
   sit side-by-side on wide screens instead of stacking full-width */
.dashboard-summary-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  align-items: start;
  margin-bottom: 16px;
}
@media (min-width: 1100px) {
  .dashboard-summary-grid { grid-template-columns: repeat(3, 1fr); }
  .dashboard-summary-grid > .span-2 { grid-column: span 2; }
}

h1 { font-size: 20px; margin: 4px 0 16px; }
h2 { font-size: 16px; margin: 0 0 12px; }

/* ---------- Flash messages ---------- */
.flash-stack { margin-bottom: 14px; display: flex; flex-direction: column; gap: 8px; }
.flash {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13.5px;
  border: 1px solid var(--border);
}
.flash-success { background: rgba(63,185,80,0.1); border-color: rgba(63,185,80,0.35); color: #8FE3A0; }
.flash-error { background: rgba(248,81,73,0.1); border-color: rgba(248,81,73,0.35); color: #FF9891; }

/* ---------- Summary stat row ---------- */
.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.stat-card .num { font-family: var(--font-mono); font-size: 22px; font-weight: 700; }
.stat-card .label { font-size: 11.5px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.04em; }
.stat-card.up .num { color: var(--up); }
.stat-card.down .num { color: var(--down); }
.stat-card.unknown .num { color: var(--unknown); }

/* ---------- Device cards ---------- */
.device-list { display: flex; flex-direction: column; gap: 10px; }
.device-card {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--muted);
  border-radius: 10px;
  padding: 12px 14px;
}
.device-card.status-up { border-left-color: var(--up); }
.device-card.status-down { border-left-color: var(--down); }
.device-card.status-unknown { border-left-color: var(--unknown); }
.device-card.disabled { opacity: 0.5; }

.device-main { flex: 1; min-width: 0; }
.device-name-row { display: flex; align-items: center; gap: 8px; }
.device-name { font-weight: 600; font-size: 14.5px; }
.device-host {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.device-meta { display: flex; gap: 10px; margin-top: 4px; font-size: 11.5px; color: var(--muted); flex-wrap: wrap; }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-up { background: rgba(63,185,80,0.15); color: var(--up); }
.badge-down { background: rgba(248,81,73,0.15); color: var(--down); }
.badge-unknown { background: rgba(212,167,44,0.15); color: var(--unknown); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.device-actions { display: flex; gap: 6px; flex-shrink: 0; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}
.btn:hover { border-color: var(--accent); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #06201D; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { color: var(--down); }
.btn-danger:hover { border-color: var(--down); }
.btn-sm { padding: 6px 10px; font-size: 12px; }
.btn-icon { padding: 6px 9px; }

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--muted);
  background: var(--panel);
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.empty-state a { color: var(--accent); font-weight: 600; }

/* ---------- Forms ---------- */
.form-panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 18px;
}
.field { margin-bottom: 16px; }
.field label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.field .hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.hint { font-size: 11.5px; color: var(--muted); }
.field input[type=text], .field input[type=number], .field input[type=password], .field select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  font-family: var(--font-ui);
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(46,196,182,0.18);
}
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 480px) { .field-row { grid-template-columns: 1fr; } }

.toggle-row { display: flex; align-items: center; gap: 10px; }
.toggle-row input { width: 18px; height: 18px; }

.form-actions { display: flex; gap: 10px; margin-top: 20px; }

/* ---------- Detail page ---------- */
.back-link { display: inline-block; margin-bottom: 12px; color: var(--muted); font-size: 13px; }
.back-link:hover { color: var(--accent); }

.detail-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.uptime-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 18px;
}
.uptime-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
}
.uptime-card .pct { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }
.uptime-card .label { font-size: 11px; color: var(--muted); margin-top: 2px; }

.sparkline { display: flex; gap: 2px; margin: 10px 0 18px; }
.spark-bar { flex: 1; height: 26px; border-radius: 2px; }
.spark-up { background: var(--up); }
.spark-down { background: var(--down); }

.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table th, .history-table td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.history-table th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.03em; }
.history-table td.mono { font-family: var(--font-mono); }

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
}

.section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); margin-bottom: 10px; }

.help-text { color: var(--muted); font-size: 13px; line-height: 1.6; }
.help-text code { background: var(--panel-2); padding: 1px 6px; border-radius: 5px; font-family: var(--font-mono); font-size: 12px; }

/* ---------- Brand logo ---------- */
.brand-logo { height: 22px; width: auto; border-radius: 4px; }

/* ---------- Login page ---------- */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 24px;
}
.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin-bottom: 26px;
  font-weight: 700;
  font-size: 17px;
  text-align: center;
}
.login-logo { max-height: 72px; max-width: 220px; width: auto; height: auto; object-fit: contain; }
.login-dot { width: 16px; height: 16px; }
.login-title { letter-spacing: -0.01em; }
.login-card .field { margin-bottom: 14px; }
.login-card .btn { width: 100%; }
.login-hint { text-align: center; margin-top: 14px; font-size: 12px; color: var(--muted); }

/* ---------- Category filter chips ---------- */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #06201D; }

.category-tag {
  font-size: 10.5px;
  padding: 2px 7px;
  border-radius: 5px;
  background: var(--panel-2);
  color: var(--muted);
  border: 1px solid var(--border);
}

/* ---------- Settings tabs ---------- */
.tab-row { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; border-bottom: 1px solid var(--border); }
.tab-link {
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab-link.active { color: var(--accent); border-color: var(--accent); }

/* ---------- Simple data table (users / db admin) ---------- */
.data-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.data-table th, .data-table td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.data-table th { color: var(--muted); font-weight: 600; font-size: 11px; text-transform: uppercase; letter-spacing: 0.03em; }
.data-table td.mono { font-family: var(--font-mono); font-size: 12px; word-break: break-all; }
.data-table tr:hover td { background: var(--panel-2); }
.table-scroll { overflow-x: auto; }
.role-badge { padding: 2px 8px; border-radius: 6px; font-size: 11px; font-weight: 700; }
.role-badge.admin { background: rgba(46,196,182,0.15); color: var(--accent); }
.role-badge.monitor { background: var(--panel-2); color: var(--muted); }

.pagination { display: flex; gap: 8px; margin-top: 14px; align-items: center; font-size: 13px; }

.color-field { display: flex; align-items: center; gap: 10px; }
.color-field input[type=color] { width: 44px; height: 36px; padding: 2px; border-radius: 8px; border: 1px solid var(--border); background: var(--bg); }
.color-field input[type=text] { flex: 1; }

.import-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.import-tab-btn {
  flex: 1;
  padding: 10px;
  text-align: center;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}
.import-tab-btn.active { color: var(--accent); border-color: var(--accent); }

/* ============================================================
   V2: Nav dropdown (desktop) + slide-out mobile nav + misc UI
   ============================================================ */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border, #263139);
  background: var(--panel);
  position: sticky;
  top: 0;
  z-index: 100;
  gap: 12px;
}
.brand {
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  color: var(--menu-text);
}
.brand-logo { height: 26px; width: auto; border-radius: 4px; }

.topnav { display: none; gap: 2px; align-items: center; flex-wrap: nowrap; }
@media (min-width: 900px) { .topnav { display: flex; } }

.nav-link {
  padding: 8px 12px;
  border-radius: 8px;
  color: var(--menu-text);
  opacity: 0.75;
  font-weight: 600;
  font-size: 13.5px;
  white-space: nowrap;
}
.nav-link.active, .nav-link:hover { opacity: 1; background: var(--panel-2); }

.nav-dropdown { position: relative; }
.nav-dropdown-btn {
  padding: 8px 12px;
  border-radius: 8px;
  background: none;
  border: none;
  color: var(--menu-text);
  opacity: 0.85;
  font-weight: 600;
  font-size: 13.5px;
  cursor: pointer;
  font-family: var(--font-ui);
  white-space: nowrap;
}
.nav-dropdown:hover > .nav-dropdown-btn, .nav-dropdown-btn:focus { opacity: 1; background: var(--panel-2); }
.nav-dropdown-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  min-width: 200px;
  background: var(--panel-2);
  border: 1px solid var(--border, #263139);
  border-radius: 10px;
  padding: 6px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.35);
  z-index: 50;
}
.nav-dropdown:hover > .nav-dropdown-menu { display: block; }
.nav-dropdown-menu .nav-link, .nav-dropdown-menu .nav-dropdown-btn {
  display: flex;
  width: 100%;
  text-align: left;
  opacity: 1;
  color: var(--menu-text);
}
.nav-dropdown-menu .nav-dropdown { width: 100%; }
.nav-dropdown-menu .nav-dropdown-menu {
  top: 0;
  left: 100%;
  margin-left: 4px;
}

.hamburger-btn {
  display: inline-flex;
  background: none;
  border: none;
  color: var(--menu-text);
  font-size: 22px;
  cursor: pointer;
  padding: 4px 8px;
}
@media (min-width: 900px) { .hamburger-btn { display: none; } }

.mobile-nav {
  position: fixed;
  top: 0; right: -320px;
  width: 300px; max-width: 85vw;
  height: 100vh;
  background: var(--panel);
  border-left: 1px solid var(--border, #263139);
  z-index: 200;
  transition: right 0.2s ease;
  display: flex;
  flex-direction: column;
}
.mobile-nav.open { right: 0; }
.mobile-nav-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--border, #263139);
  font-weight: 700; color: var(--menu-text);
}
.mobile-nav-header button { background: none; border: none; color: var(--menu-text); font-size: 18px; cursor: pointer; }
.mobile-nav-body { padding: 10px; overflow-y: auto; }
.mobile-nav-body a {
  display: block; padding: 11px 12px; border-radius: 8px; color: var(--menu-text); font-size: 14px; font-weight: 600;
}
.mobile-nav-body a:hover, .mobile-nav-body a:active { background: var(--panel-2); }
.mobile-nav-body details { margin-bottom: 2px; }
.mobile-nav-body summary {
  padding: 11px 12px; border-radius: 8px; color: var(--menu-text); font-size: 14px; font-weight: 700;
  cursor: pointer; list-style: none;
}
.mobile-nav-body summary::-webkit-details-marker { display: none; }
.mobile-nav-sub { padding-left: 14px; border-left: 2px solid var(--border, #263139); margin: 2px 0 6px 12px; }

/* ============================================================ */

body.btnstyle-outline .btn { background: transparent; border: 1px solid var(--btn-bg, var(--border)); color: var(--text); }
body.btnstyle-outline .btn-primary { background: transparent; border: 1.5px solid var(--accent); color: var(--accent); }
body.btnstyle-solid .btn { background: var(--btn-bg, var(--panel-2)); }

/* ---------- Search bar ---------- */
.search-bar { display: flex; gap: 8px; margin-bottom: 14px; }
.search-bar input {
  flex: 1; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border, #263139);
  background: var(--panel); color: var(--text); font-size: 14px;
}
.search-bar input:focus { outline: none; border-color: var(--accent); }

/* ---------- View mode toggle ---------- */
.view-toggle { display: flex; gap: 4px; }
.view-toggle a {
  padding: 8px 10px; border-radius: 8px; border: 1px solid var(--border, #263139); background: var(--panel);
  color: var(--muted); font-size: 13px;
}
.view-toggle a.active { color: var(--accent); border-color: var(--accent); }

/* ---------- Device grid (boxes view) ---------- */
.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 10px;
}
.device-box {
  background: var(--panel);
  border: 1px solid var(--border, #263139);
  border-top: 3px solid var(--muted);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.device-box.status-up { border-top-color: var(--up); }
.device-box.status-down { border-top-color: var(--down); animation: box-pulse-down 1.6s ease-in-out infinite; }
.device-box.status-unknown { border-top-color: var(--unknown); }
@keyframes box-pulse-down {
  0%, 100% { box-shadow: 0 0 0 0 rgba(248,81,73,0.0); }
  50% { box-shadow: 0 0 0 4px rgba(248,81,73,0.12); }
}
@media (prefers-reduced-motion: reduce) { .device-box.status-down { animation: none; } }

.device-box-top { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.device-box-icon { font-size: 15px; }
.device-box-name { font-weight: 700; font-size: 13.5px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-box-host { font-family: var(--font-mono); font-size: 11.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-box-meta { display: flex; gap: 8px; flex-wrap: wrap; font-size: 10.5px; color: var(--muted); margin-top: 2px; }

/* ---------- Compact list view ---------- */
.device-compact-list { display: flex; flex-direction: column; border: 1px solid var(--border, #263139); border-radius: 10px; overflow: hidden; }
.device-compact-row {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
  background: var(--panel); border-bottom: 1px solid var(--border, #263139); font-size: 12.5px;
}
.device-compact-row:last-child { border-bottom: none; }
.device-compact-row .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.device-compact-row.status-up .dot { background: var(--up); }
.device-compact-row.status-down .dot { background: var(--down); }
.device-compact-row.status-unknown .dot { background: var(--unknown); }
.device-compact-row .name { font-weight: 600; flex: 0 0 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.device-compact-row .host { font-family: var(--font-mono); color: var(--muted); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Animated stat donut (SVG) ---------- */
.stat-charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 16px; }
.donut-card { background: var(--panel); border: 1px solid var(--border, #263139); border-radius: 12px; padding: 14px; display: flex; align-items: center; gap: 12px; }
.donut-ring circle { transition: stroke-dasharray 0.6s ease; }
.donut-label-num { font-family: var(--font-mono); font-size: 20px; font-weight: 700; }

/* ---------- Category chip with icon ---------- */
.chip-icon { margin-right: 4px; }

/* ---------- Batch page ---------- */
.batch-table-wrap { max-height: 60vh; overflow-y: auto; border: 1px solid var(--border, #263139); border-radius: 10px; }
.batch-toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }

/* ---------- Dependency / topology tree ---------- */
.tree-list, .tree-list ul { list-style: none; margin: 0; padding-left: 20px; }
.tree-list { padding-left: 0; }
.tree-node {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 3px 0;
  border-radius: 8px; border: 1px solid var(--border, #263139); background: var(--panel);
  font-size: 13px;
}
.tree-node .dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.tree-children { border-left: 2px dashed var(--border, #263139); margin-left: 10px; }

/* ---------- Server status cards ---------- */
.status-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px,1fr)); gap: 12px; }
.status-card { background: var(--panel); border: 1px solid var(--border, #263139); border-radius: 12px; padding: 16px; }
.status-card .status-title { font-size: 12px; color: var(--muted); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.status-card .status-value { font-family: var(--font-mono); font-size: 26px; font-weight: 700; }
.progress-bar { height: 8px; border-radius: 5px; background: var(--panel-2); overflow: hidden; margin-top: 10px; }
.progress-bar-fill { height: 100%; background: var(--accent); transition: width 0.5s ease; }
.progress-bar-fill.warn { background: var(--unknown); }
.progress-bar-fill.danger { background: var(--down); }

/* ---------- Log table ---------- */
.log-row-login { color: var(--accent); }
.log-row-delete { color: var(--down); }

/* ---------- Topology graph ---------- */
.dot-inline { display:inline-block; width:8px; height:8px; border-radius:50%; margin-right:5px; vertical-align:middle; }
.topo-panel { padding: 4px; overflow: hidden; }
.topo-svg { display: block; background:
  radial-gradient(var(--border, #263139) 1px, transparent 1px);
  background-size: 22px 22px;
  border-radius: 10px;
  cursor: grab;
  touch-action: none;
}

/* ---------- Category breakdown chart (dashboard) ---------- */
.category-chart { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.category-chart-row { display: flex; align-items: center; gap: 10px; font-size: 12.5px; }
.category-chart-label { width: 120px; flex-shrink: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.category-chart-bar { flex: 1; height: 16px; border-radius: 5px; background: var(--panel-2); overflow: hidden; display: flex; }
.category-chart-bar .seg-up { background: var(--up); height: 100%; transition: width 0.6s ease; }
.category-chart-bar .seg-down { background: var(--down); height: 100%; transition: width 0.6s ease; }
.category-chart-bar .seg-rest { background: var(--panel-2); height: 100%; }
.category-chart-count { width: 46px; text-align: right; flex-shrink: 0; color: var(--muted); font-family: var(--font-mono); }

/* ---------- Live status + clock (navbar) ---------- */
.nav-live-wrap {
  display: none;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  margin-right: 8px;
  flex-shrink: 0;
}
@media (min-width: 900px) { .nav-live-wrap { display: flex; } }

.nav-live-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px 5px 8px;
  border-radius: 999px;
  background: rgba(63,185,80,0.12);
  border: 1px solid rgba(63,185,80,0.35);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--up);
}
.nav-live-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--up);
  animation: pulse 1.6s ease-in-out infinite;
}
.nav-live-text { animation: pulse 1.6s ease-in-out infinite; }
@media (prefers-reduced-motion: reduce) { .nav-live-dot, .nav-live-text { animation: none; } }

.nav-clock {
  text-align: right;
  line-height: 1.25;
}
.nav-clock .nav-clock-time {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 700;
  color: var(--menu-text);
}
.nav-clock .nav-clock-date {
  font-size: 10.5px;
  color: var(--muted);
}

/* mobile: show a compact live+clock row inside the slide-out panel */
.mobile-live-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px 14px;
  border-bottom: 1px solid var(--border, #263139);
  margin-bottom: 8px;
}
@media (min-width: 900px) { .mobile-live-row { display: none; } }

/* ---------- Status filter chips (colored) ---------- */
.chip-up.active { background: var(--up); border-color: var(--up); color: #06210C; }
.chip-down.active { background: var(--down); border-color: var(--down); color: #2B0503; }
.chip-disabled.active { background: var(--muted); border-color: var(--muted); color: #0A0A0A; }

/* ---------- Icon preview box (Categories page) ---------- */
.icon-preview-box {
  width: 34px; height: 34px; border-radius: 8px; background: var(--panel-2);
  border: 1px solid var(--border, #263139); display: flex; align-items: center; justify-content: center;
  font-size: 14px; color: var(--accent);
}

/* ---------- Latency trend chart ---------- */
.latency-chart-wrap { position: relative; }
#latency-svg { display: block; }

/* ---------- Avatar grid (new "Compact" dashboard view = contact-initial tiles) ---------- */
.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 8px;
}
.avatar-box {
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  letter-spacing: 0.02em;
  color: #fff;
  cursor: pointer;
  transition: transform 0.12s ease;
}
.avatar-box:hover { transform: scale(1.08); z-index: 2; }
.avatar-box.status-up { background: var(--up); }
.avatar-box.status-down { background: var(--down); animation: box-pulse-down 1.6s ease-in-out infinite; }
.avatar-box.status-unknown { background: var(--muted); }

/* ---------- Latency chart: axis legend + stats header ---------- */
.latency-panel-header { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px; margin-bottom: 10px; }
.latency-stats { display: flex; gap: 12px; font-size: 11.5px; color: var(--muted); }
.latency-stats b { color: var(--text); font-family: var(--font-mono); }
.latency-chart-wrap { position: relative; padding-left: 46px; }
.latency-axis-y {
  position: absolute; left: 0; top: 0; bottom: 18px; width: 42px;
  display: flex; flex-direction: column; justify-content: space-between;
  font-size: 10px; color: var(--muted); text-align: right; padding-right: 6px;
}
.latency-axis-x {
  display: flex; justify-content: space-between; font-size: 10px; color: var(--muted); margin-top: 4px;
}
#latency-svg { display: block; }

/* Dashboard's wide device grid gets a few more columns on very large screens */
@media (min-width: 1440px) {
  .device-grid-wide { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
}

/* ---------- Categories page (rebuilt layout) ---------- */
.category-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}
.category-card {
  background: var(--panel);
  border: 1px solid var(--border, #263139);
  border-top: 3px solid var(--accent);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.category-form-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
}
.category-icon-input {
  width: 88px;
  flex-shrink: 0;
  padding: 8px 8px;
  border-radius: 8px;
  border: 1px solid var(--border, #263139);
  background: var(--bg);
  color: var(--text);
  font-size: 11px;
  font-family: var(--font-mono);
  min-width: 0;
}
.category-name-input {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #263139);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
}
.category-name-display { font-weight: 700; font-size: 14px; }
.category-card-footer { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- Section divider (futuristic, subtle glow) ---------- */
.section-divider {
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(90deg, transparent, var(--accent) 50%, transparent);
  opacity: 0.35;
  position: relative;
}
.section-divider::after {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 8px 2px var(--accent);
  opacity: 0.7;
}

/* ---------- Stat cards: configurable column count ---------- */
.stat-charts.stat-cols-1 { grid-template-columns: 1fr; }
.stat-charts.stat-cols-2 { grid-template-columns: repeat(2, 1fr); }
.stat-charts.stat-cols-3 { grid-template-columns: repeat(3, 1fr); }

/* ---------- Category chip row: horizontal scroll instead of wrapping tall ---------- */
.chip-row-scroll {
  flex-wrap: nowrap;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-width: thin;
}
.chip-row-scroll .chip { flex-shrink: 0; }
.chip-row-scroll::-webkit-scrollbar { height: 5px; }
.chip-row-scroll::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 4px; }

/* ---------- Site footer ---------- */
.site-footer {
  text-align: center;
  padding: 18px 16px 22px;
  font-size: 11.5px;
  color: var(--muted);
  border-top: 1px solid var(--border, #263139);
  margin-top: 30px;
}

/* ---------- Print (Topology export to PDF via browser print) ---------- */
@media print {
  .topbar, .mobile-nav, .hamburger-btn, .site-footer, .batch-toolbar,
  .flash-stack, .back-link, .help-text, .chip-row { display: none !important; }
  body { background: #fff !important; color: #000 !important; }
  .page-wrap { max-width: 100% !important; }
  .topo-panel { border: none !important; background: none !important; }
  .topo-svg { background: none !important; cursor: default !important; height: auto !important; }
  .detail-header .btn { display: none !important; }
}

/* ---------- Collapsible dependency tree ---------- */
.tree-item { margin: 4px 0; }
.tree-details summary.tree-node { cursor: pointer; list-style: none; }
.tree-details summary.tree-node::-webkit-details-marker { display: none; }
.tree-details summary.tree-node::before {
  content: "▸";
  display: inline-block;
  margin-right: 4px;
  color: var(--muted);
  transition: transform 0.15s ease;
}
.tree-details[open] > summary.tree-node::before { transform: rotate(90deg); }

/* ---------- Filter row (Devices list page) ---------- */
.filter-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; align-items: center; }
.filter-search {
  flex: 1; min-width: 180px;
  padding: 9px 12px; border-radius: 8px; border: 1px solid var(--border, #263139);
  background: var(--panel); color: var(--text); font-size: 13px;
}
.filter-select {
  padding: 9px 10px; border-radius: 8px; border: 1px solid var(--border, #263139);
  background: var(--panel); color: var(--text); font-size: 13px;
}

/* ---------- Latency custom time range form (device detail) ---------- */
.latency-range-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.latency-range-form select, .latency-range-form input[type=datetime-local] {
  padding: 7px 10px; border-radius: 8px; border: 1px solid var(--border, #263139);
  background: var(--bg); color: var(--text); font-size: 12.5px;
}
#custom-range-fields { display: flex; }

/* ---------- Repeatable rows (device form: multi-parent, multi-IP backup) ---------- */
.repeatable-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.repeatable-row input, .repeatable-row select {
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border, #263139);
  background: var(--bg);
  color: var(--text);
  font-size: 13px;
  flex: 1;
  min-width: 120px;
}

/* ---------- Dashboard: latency charts per category in a 2-column grid ---------- */
.latency-grid-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}
@media (min-width: 900px) {
  .latency-grid-2col { grid-template-columns: repeat(2, 1fr); }
}
.latency-grid-2col .panel { margin-bottom: 0; }

/* ---------- Dashboard: per-site statistics cards ---------- */
.site-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
}
.site-stat-card {
  background: var(--panel-2);
  border: 1px solid var(--border, #263139);
  border-radius: 10px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.site-stat-card:hover, .site-stat-card.active { border-color: var(--accent); }
.site-stat-name { font-weight: 700; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.site-stat-counts { display: flex; gap: 10px; font-size: 12px; font-family: var(--font-mono); }
.site-stat-up { color: var(--up); }
.site-stat-down { color: var(--down); }
.site-stat-disabled { color: var(--muted); }

/* ---------- Nav notification bell ---------- */
.nav-bell {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px; height: 32px;
  border-radius: 8px;
  color: var(--menu-text);
  opacity: 0.85;
  font-size: 15px;
}
.nav-bell:hover { background: var(--panel-2); opacity: 1; }
.nav-bell-badge {
  position: absolute;
  top: -4px; right: -4px;
  min-width: 16px; height: 16px;
  border-radius: 999px;
  background: var(--down);
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
}

/* ============================================================
   NOC-style dashboard redesign
   ============================================================ */

/* ---------- Status summary cards ---------- */
.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 16px;
}
@media (max-width: 900px) { .summary-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .summary-grid { grid-template-columns: 1fr; } }

.summary-card {
  background: var(--panel);
  border: 1px solid var(--border, #263139);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.summary-card:hover { transform: translateY(-2px); border-color: var(--accent); }
.summary-icon {
  width: 42px; height: 42px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.summary-up .summary-icon { background: rgba(63,185,80,0.15); color: var(--up); }
.summary-down .summary-icon { background: rgba(248,81,73,0.15); color: var(--down); }
.summary-disabled .summary-icon { background: rgba(124,139,147,0.15); color: var(--muted); }
.summary-avail .summary-icon { background: rgba(46,196,182,0.15); color: var(--accent); }
.summary-num { font-family: var(--font-mono); font-size: 26px; font-weight: 800; line-height: 1.1; }
.summary-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; margin-top: 2px; }
.summary-delta { margin-top: 8px; font-size: 11.5px; }
.delta-up { color: var(--up); font-weight: 700; }
.delta-down { color: var(--down); font-weight: 700; }
.delta-flat { color: var(--muted); font-weight: 700; }

/* ---------- Attention panel ---------- */
.attention-panel { border-left: 3px solid var(--unknown); }
.attention-ok { color: var(--up); font-weight: 600; display: flex; align-items: center; gap: 8px; padding: 6px 0; }
.attention-items { display: flex; flex-wrap: wrap; gap: 20px; }
.attention-item { display: flex; gap: 10px; align-items: flex-start; flex: 1; min-width: 220px; }
.attention-item-icon {
  width: 34px; height: 34px; border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.attention-item-icon.down { background: rgba(248,81,73,0.15); color: var(--down); }
.attention-item-icon.warn { background: rgba(212,167,44,0.15); color: var(--unknown); }
.attention-item-title { font-weight: 700; font-size: 13.5px; }

/* ---------- 2-column layout for paired panels ---------- */
.dashboard-2col {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  margin-bottom: 0;
}
@media (min-width: 1100px) {
  .dashboard-2col { grid-template-columns: 1.3fr 1fr; }
}
.dashboard-2col .panel { margin-bottom: 0; }

/* ---------- Health trend controls ---------- */
.health-trend-controls { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.health-tabs { margin-bottom: 0; border-bottom: none; }
.health-trend-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--border, #263139);
}
.health-stat-val { font-family: var(--font-mono); font-size: 17px; font-weight: 700; margin-top: 2px; }

/* ---------- Recent device movement ---------- */
.movement-list { display: flex; flex-direction: column; gap: 2px; max-height: 340px; overflow-y: auto; }
.movement-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 6px;
  border-bottom: 1px solid var(--border, #263139);
  font-size: 12.5px;
}
.movement-row:last-child { border-bottom: none; }
.movement-time { font-family: var(--font-mono); color: var(--muted); font-size: 11px; width: 52px; flex-shrink: 0; }
.movement-badge { font-weight: 700; font-size: 11px; white-space: nowrap; flex-shrink: 0; }
.movement-badge.up { color: var(--up); }
.movement-badge.down { color: var(--down); }
.movement-info { flex: 1; min-width: 0; }
.movement-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@keyframes slideInFade {
  from { opacity: 0; transform: translateX(-6px); background: rgba(46,196,182,0.12); }
  to { opacity: 1; transform: translateX(0); background: transparent; }
}
.movement-new { animation: slideInFade 1.2s ease; }

/* ---------- Site stat list (redesigned rows w/ health bar) ---------- */
.site-stat-list { display: flex; flex-direction: column; gap: 10px; max-height: 400px; overflow-y: auto; }
.site-stat-row {
  display: block;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel-2);
  border: 1px solid transparent;
}
.site-stat-row:hover, .site-stat-row.active { border-color: var(--accent); }
.site-stat-row-top { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.site-stat-row .site-stat-name { font-weight: 700; font-size: 13px; }
.site-stat-health { font-family: var(--font-mono); font-size: 12.5px; color: var(--muted); }
.site-stat-row .progress-bar { margin: 0 0 8px; }
.site-stat-row .site-stat-counts { display: flex; gap: 12px; font-size: 11px; }
.site-stat-row .site-stat-up i, .site-stat-row .site-stat-down i, .site-stat-row .site-stat-disabled i { font-size: 7px; margin-right: 3px; }

/* ---------- Top high latency devices ---------- */
.top-latency-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto 24px;
  align-items: center;
  gap: 10px;
  padding: 9px 4px;
  border-bottom: 1px solid var(--border, #263139);
  font-size: 12.5px;
}
.top-latency-row:last-child { border-bottom: none; }
.top-latency-rank { font-family: var(--font-mono); font-weight: 800; color: var(--muted); text-align: center; }
.top-latency-name { font-weight: 600; }
.top-latency-ms { font-family: var(--font-mono); font-weight: 700; color: var(--unknown); white-space: nowrap; }
.top-latency-trend { text-align: center; }
