:root{
  --bg:#f6f7fb;
  --card:#ffffff;
  --text:#0f172a;
  --muted:#64748b;
  --line:#e2e8f0;
  --shadow: 0 10px 25px rgba(2,8,23,.06);
  --radius: 14px;
  --pill:#f1f5f9;
  --accent:#2563eb;
  --good:#16a34a;
  --bad:#ef4444;
  --warn:#f59e0b;
}

*{box-sizing:border-box}
html{-webkit-text-size-adjust:100%;}
body{
  margin:0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:var(--bg);
  color:var(--text);
  min-height:100vh;
  display:flex;
  flex-direction:column;
}
a{color:var(--accent); text-decoration:none}
a:hover{text-decoration:underline}

.pageMain{flex:1;}

/* Site header / footer */
.siteHeader{
  position:sticky;
  top:0;
  z-index:20;
  background:rgba(246,247,251,.85);
  backdrop-filter: blur(8px);
  border-bottom:1px solid var(--line);
}
.headerInner{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  padding:12px 0;
}
.brand{display:flex; align-items:center; gap:10px; font-weight:900; color:var(--text); text-decoration:none;}
.brand:hover{text-decoration:none;}
.brandMark{
  width:34px; height:34px;
  border-radius:12px;
  display:flex; align-items:center; justify-content:center;
  background:rgba(37,99,235,.12);
  border:1px solid rgba(37,99,235,.25);
  color:var(--accent);
  font-weight:900;
}
.brandText{font-size:14px; line-height:1.2;}
.nav{display:flex; align-items:center; gap:8px; flex-wrap:wrap; justify-content:flex-end;}
.navLink{
  display:inline-flex;
  align-items:center;
  padding:8px 10px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:999px;
  font-size:13px;
  color:var(--muted);
  text-decoration:none;
  font-weight:900;
}
.navLink:hover{background:var(--pill); text-decoration:none;}
.navPrimary{background: var(--accent); border-color:#1d4ed8; color:#fff;}
.navPrimary:hover{filter:brightness(1.03);}

.siteFooter{
  margin-top:18px;
  border-top:1px solid var(--line);
  background:#fff;
}
.footerInner{display:flex; justify-content:space-between; align-items:center; gap:12px; padding:14px 0; flex-wrap:wrap;}

.container{max-width:1100px; margin:0 auto; padding:18px;}

.card{
  background:var(--card);
  border:1px solid var(--line);
  border-radius:var(--radius);
  box-shadow: var(--shadow);
  padding:14px;
}
.card h4{margin:0 0 8px; font-size:14px;}

.row{display:grid; gap:10px;}
.row.cols2{grid-template-columns: 1fr 1fr;}
.row.cols3{grid-template-columns: repeat(3, minmax(180px, 1fr));}
.row.cols4{grid-template-columns: repeat(4, minmax(180px, 1fr));}

label{display:block; font-size:12px; color:var(--muted); margin-bottom:6px;}
input, select, textarea{
  width:100%;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:#fff;
  color:var(--text);
  outline:none;
}
input:focus, select:focus, textarea:focus{
  border-color:#93c5fd;
  box-shadow:0 0 0 3px rgba(59,130,246,.15);
}

.btnRow{display:flex; gap:10px; flex-wrap:wrap; margin-top:10px;}
button{
  cursor:pointer;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:var(--pill);
  color:var(--text);
  font-weight:800;
}
button:hover{filter:brightness(1.03)}
.btnPrimary{
  background: var(--accent);
  border-color: #1d4ed8;
  color:#fff;
}
.btnSmall{padding:8px 10px; border-radius:10px; font-weight:900;}

.badge{
  display:inline-flex; align-items:center; gap:6px;
  border:1px solid var(--line);
  padding:2px 8px; border-radius:999px;
  font-size:12px;
  background:#fff;
  color:var(--muted);
}
.dot{width:8px; height:8px; border-radius:50%;}
.dot.good{background:var(--good)}
.dot.bad{background:var(--bad)}
.dot.warn{background:var(--warn)}

.msg{
  margin-top:10px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:12px;
  padding:10px 12px;
  color:var(--muted);
  font-size:13px;
}
.msg.ok{border-color:#bbf7d0; background:#f0fdf4; color:#166534;}
.msg.bad{border-color:#fecaca; background:#fef2f2; color:#991b1b;}

.topbar{
  display:flex; gap:12px;
  justify-content:space-between; align-items:flex-start;
  margin-bottom:12px;
}
.topbar h1{margin:0; font-size:18px;}
.sub{margin-top:6px; color:var(--muted); font-size:13px; line-height:1.45;}

.tabs{
  display:flex;
  gap:8px;
  flex-wrap:wrap;
  margin:10px 0 14px;
}
.tabs a{
  display:inline-flex;
  align-items:center;
  padding:8px 10px;
  border:1px solid var(--line);
  background:#fff;
  border-radius:999px;
  font-size:13px;
  color:var(--muted);
  text-decoration:none;
}
.tabs a:hover{background:var(--pill); text-decoration:none;}

.kpis{display:grid; gap:12px; grid-template-columns: repeat(4, minmax(220px, 1fr));}
.kpiVal{font-size:22px; font-weight:900; margin-top:6px;}
.kpiSub{font-size:12px; color:var(--muted); margin-top:4px; line-height:1.35;}

.netBar{display:flex; justify-content:space-between; align-items:center; gap:10px; flex-wrap:wrap; margin-top:10px;}
.netControls{display:flex; gap:8px; flex-wrap:wrap;}

.svgWrap{
  margin-top:10px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
  padding:10px;
  overflow:hidden;
  position:relative;
}
#networkSvg{width:100%; height:440px; display:block; touch-action:none; user-select:none;}

.tableWrap{overflow-x:auto; -webkit-overflow-scrolling:touch;}

table{width:100%; border-collapse:collapse; margin-top:10px; overflow:hidden; border-radius:12px;}
th, td{padding:10px; border-bottom:1px solid var(--line); text-align:left; font-size:13px;}
th{color:var(--muted); font-weight:900; background:#fafafa;}
tr:hover td{background:#fbfdff;}

/* Responsive “cards” table (better UX on mobile) */
@media (max-width: 680px){
  table.tableResponsive{display:block; border-radius:0; overflow:visible;}
  table.tableResponsive thead{display:none;}
  table.tableResponsive tbody{display:block;}
  table.tableResponsive tr{
    display:block;
    border:1px solid var(--line);
    border-radius:12px;
    margin:10px 0;
    overflow:hidden;
    background:#fff;
  }
  table.tableResponsive td{
    display:flex;
    justify-content:space-between;
    gap:12px;
    padding:10px;
    border-bottom:1px solid var(--line);
  }
  table.tableResponsive td:last-child{border-bottom:none;}
  table.tableResponsive td::before{
    content:attr(data-label);
    color:var(--muted);
    font-weight:900;
    font-size:12px;
  }
  table.tableResponsive td b{white-space:nowrap;}
}

.footer{color:var(--muted); font-size:12px; margin-top:14px; line-height:1.45;}
.small{font-size:12px; color:var(--muted);}
hr{border:none; border-top:1px solid var(--line); margin:14px 0;}

/* Breakpoints */
@media (max-width: 980px){
  .kpis{grid-template-columns: repeat(2, minmax(200px, 1fr));}
  .row.cols4{grid-template-columns: 1fr 1fr;}
  .row.cols3{grid-template-columns: 1fr 1fr;}
}

@media (max-width: 680px){
  .container{padding:12px;}
  .headerInner{flex-direction:column; align-items:stretch;}
  .nav{justify-content:flex-start;}
  .topbar{flex-direction:column; align-items:stretch;}
  .kpis{grid-template-columns: 1fr;}
  .row.cols2, .row.cols3, .row.cols4{grid-template-columns: 1fr;}
  .btnRow{flex-direction:column;}
  .btnRow button{width:100%;}
  .tabs{flex-wrap:nowrap; overflow-x:auto; -webkit-overflow-scrolling:touch; padding-bottom:6px;}
  .tabs a{white-space:nowrap;}
  #networkSvg{height:320px;}
  .tableWrap table{min-width:760px;}
}

/* =========================================================
   Admin UI upgrade (colors + organization + notification)
   ========================================================= */

/* Color pills for status badges */
.badgeGood{background:#f0fdf4; border-color:#bbf7d0; color:#166534;}
.badgeWarn{background:#fffbeb; border-color:#fde68a; color:#92400e;}
.badgeBad{background:#fef2f2; border-color:#fecaca; color:#991b1b;}

/* Small count bubble used in nav / admin sidebar */
.navCount{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  font-size:11px;
  font-weight:900;
  background: rgba(245,158,11,.18);
  border:1px solid rgba(245,158,11,.35);
  color:#92400e;
  line-height:1;
}

.countBubble{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:18px;
  height:18px;
  padding:0 6px;
  border-radius:999px;
  font-size:11px;
  font-weight:900;
  line-height:1;
  border:1px solid var(--line);
  background:#fff;
  color:var(--muted);
}
.countBubble.warn{background: rgba(245,158,11,.16); border-color: rgba(245,158,11,.35); color:#92400e;}
.countBubble.good{background: rgba(22,163,74,.12); border-color: rgba(22,163,74,.25); color:#166534;}
.countBubble.bad{background: rgba(239,68,68,.10); border-color: rgba(239,68,68,.25); color:#991b1b;}

/* Admin theme: slightly different accent + background */
body.adminTheme{
  --accent:#7c3aed;
  --bg:#f7f5ff;
  --pill:#f3f4ff;
}

.adminShell{
  display:grid;
  grid-template-columns: 260px 1fr;
  gap:14px;
  align-items:start;
}
.adminSide{
  position:sticky;
  top:72px; /* below sticky header */
  align-self:start;
}
.adminMenuTop{display:flex; flex-direction:column; gap:2px; margin-bottom:10px;}
.adminMenuTitle{font-weight:900; font-size:14px;}
.adminNav{display:flex; flex-direction:column; gap:8px;}
.adminNavLink{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  border:1px solid var(--line);
  border-radius:12px;
  background:#fff;
  color:var(--text);
  text-decoration:none;
  font-weight:900;
  font-size:13px;
}
.adminNavLink:hover{background:var(--pill); text-decoration:none;}
.adminNavLink .left{display:inline-flex; gap:8px; align-items:center;}

.adminTopBadges{display:flex; gap:8px; flex-wrap:wrap; justify-content:flex-end;}

/* Buttons with colors (admin quick actions) */
.btnGood{background: var(--good); border-color:#15803d; color:#fff;}
.btnBad{background: var(--bad); border-color:#b91c1c; color:#fff;}
.btnWarnBtn{background: var(--warn); border-color:#b45309; color:#fff;}
.btnGood:hover, .btnBad:hover, .btnWarnBtn:hover{filter:brightness(1.03);}

/* Highlight pending rows for faster scanning */
tr.rowPending td{background: rgba(245,158,11,.06);}
tr.rowPending:hover td{background: rgba(245,158,11,.10);}

/* On small screens: sidebar becomes horizontal nav */
@media (max-width: 980px){
  .adminShell{grid-template-columns: 1fr;}
  .adminSide{position:static;}
  .adminNav{
    flex-direction:row;
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
    padding-bottom:6px;
  }
  .adminNavLink{white-space:nowrap; min-width:max-content;}
}
