/* NetworkHSPL — NOC/SOC UI. No inline styles anywhere (CSP style-src 'self'). */
:root {
  --bg: #0b1220; --bg2: #0f172a; --panel: #111a2e; --panel2: #16213a; --line: #22304d; --text: #e2e8f0; --muted: #8fa1bd;
  --accent: #38bdf8; --ok: #22c55e; --warn: #f59e0b; --crit: #f97316; --down: #ef4444; --flap: #a855f7; --maint: #64748b; --unk: #94a3b8;
  --radius: 10px; --shadow: 0 1px 2px rgba(0,0,0,.4);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 15px; -webkit-text-size-adjust: 100%; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.45rem; margin: 0 0 .75rem; font-weight: 600; }
h2 { font-size: 1.1rem; margin: 0 0 .6rem; font-weight: 600; }
h3 { font-size: .95rem; margin: 0 0 .5rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
code, pre { font-family: Consolas, "Cascadia Mono", Menlo, monospace; font-size: .85rem; }
pre { background: #060b16; border: 1px solid var(--line); border-radius: 8px; padding: .75rem; overflow: auto; white-space: pre-wrap; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.mt { margin-top: 1rem; } .mb { margin-bottom: 1rem; }
.row { display: flex; gap: .75rem; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

/* ---------- App shell ---------- */
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--bg2); border-right: 1px solid var(--line); padding: 1rem .75rem; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .55rem; font-weight: 700; margin: 0 .25rem 1.25rem; color: var(--text); }
.brand img { width: 30px; height: 30px; border-radius: 7px; }
.brand span { line-height: 1.1; font-size: .95rem; }
.nav a { display: flex; align-items: center; gap: .6rem; padding: .6rem .7rem; border-radius: 8px; color: var(--muted); margin-bottom: 2px; min-height: 42px; }
.nav a:hover, .nav a.active { background: var(--panel2); color: var(--text); text-decoration: none; }
.nav .sep { border-top: 1px solid var(--line); margin: .75rem .25rem; }
.nav .label { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; padding: .25rem .7rem; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; align-items: center; gap: .75rem; padding: .6rem 1.25rem; border-bottom: 1px solid var(--line); background: rgba(11,18,32,.92); position: sticky; top: 0; z-index: 20; backdrop-filter: blur(6px); }
.topbar .who { color: var(--muted); font-size: .85rem; }
.menu-btn { display: none; background: none; border: 1px solid var(--line); color: var(--text); border-radius: 8px; width: 44px; height: 40px; font-size: 1.2rem; cursor: pointer; }
.content { padding: 1.25rem; max-width: 1800px; width: 100%; }
.live-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--unk); display: inline-block; }
.live-dot.on { background: var(--ok); box-shadow: 0 0 8px var(--ok); }
.live-dot.off { background: var(--down); }

/* ---------- Panels / cards ---------- */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; box-shadow: var(--shadow); min-width: 0; }
.grid { display: grid; gap: 1rem; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.cards { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: .8rem 1rem; border-top: 3px solid var(--unk); }
.card .n { font-size: 1.9rem; font-weight: 700; line-height: 1.1; }
.card .t { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; }
.card.total { border-top-color: var(--accent); } .card.up { border-top-color: var(--ok); } .card.degraded { border-top-color: var(--warn); }
.card.critical { border-top-color: var(--crit); } .card.down { border-top-color: var(--down); } .card.incidents { border-top-color: #e11d48; } .card.maintenance { border-top-color: var(--maint); }
.card.alerting { animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 rgba(239,68,68,0); } 50% { box-shadow: 0 0 18px rgba(239,68,68,.55); } }

/* ---------- Status badges ---------- */
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .15rem .55rem; border-radius: 999px; font-size: .75rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.s-Healthy { color: var(--ok); background: rgba(34,197,94,.12); }
.s-Degraded { color: var(--warn); background: rgba(245,158,11,.12); }
.s-Critical { color: var(--crit); background: rgba(249,115,22,.14); }
.s-Down { color: var(--down); background: rgba(239,68,68,.14); }
.s-Flapping { color: var(--flap); background: rgba(168,85,247,.14); }
.s-Maintenance { color: var(--maint); background: rgba(100,116,139,.2); }
.s-Unknown, .s-Disabled { color: var(--unk); background: rgba(148,163,184,.12); }
.sev-Critical { color: var(--down); } .sev-High { color: var(--crit); } .sev-Medium { color: var(--warn); } .sev-Low { color: var(--muted); }
.lv-down { color: var(--down); } .lv-critical { color: var(--crit); } .lv-warn { color: var(--warn); } .lv-ok { color: var(--ok); } .lv-info { color: var(--muted); }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .88rem; }
th, td { text-align: left; padding: .5rem .6rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { color: var(--muted); font-weight: 600; font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; background: var(--panel); position: sticky; top: 0; }
tr:hover td { background: rgba(56,189,248,.04); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.list { list-style: none; margin: 0; padding: 0; }
.list li { padding: .45rem 0; border-bottom: 1px solid var(--line); display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.list li:last-child { border-bottom: none; }
.empty { color: var(--muted); padding: .75rem 0; }

/* ---------- Forms ---------- */
form .field { margin-bottom: .85rem; }
label { display: block; font-size: .82rem; color: var(--muted); margin-bottom: .3rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=datetime-local], input[type=date], input[type=tel], input[type=search], select, textarea {
  width: 100%; background: #0a1324; color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: .6rem .7rem; font: inherit; min-height: 42px; }
textarea { min-height: 90px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
.check { display: flex; gap: .5rem; align-items: center; color: var(--text); font-size: .9rem; margin-bottom: .6rem; }
.check input { width: 18px; height: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; background: var(--panel2); color: var(--text); border: 1px solid var(--line); border-radius: 8px;
  padding: .55rem .95rem; font: inherit; font-size: .9rem; cursor: pointer; min-height: 40px; text-decoration: none !important; }
.btn:hover { border-color: var(--accent); }
.btn.primary { background: #0369a1; border-color: #0284c7; color: #fff; }
.btn.danger { background: #7f1d1d; border-color: #b91c1c; color: #fff; }
.btn.ok { background: #14532d; border-color: #16a34a; color: #fff; }
.btn.sm { padding: .3rem .6rem; min-height: 32px; font-size: .8rem; }
.btn-row { display: flex; gap: .5rem; flex-wrap: wrap; }
.inline { display: inline; }
.validation, .field-validation-error, .text-danger { color: #fca5a5; font-size: .82rem; }
.alert { padding: .7rem .9rem; border-radius: 8px; margin-bottom: 1rem; border: 1px solid var(--line); }
.alert.ok { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.4); }
.alert.err { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.4); }
.alert.info { background: rgba(56,189,248,.08); border-color: rgba(56,189,248,.35); }
.alert.warn { background: rgba(245,158,11,.1); border-color: rgba(245,158,11,.45); }
.btn:disabled, .btn[disabled] { opacity: .45; cursor: not-allowed; filter: grayscale(.6); }
.code-line { font-family: ui-monospace, Consolas, monospace; background: #0b1324; border: 1px solid var(--line); border-radius: 6px; padding: .45em .7em; overflow-x: auto; white-space: nowrap; }
.tabs { display: flex; gap: .25rem; flex-wrap: wrap; margin-bottom: 1rem; }
.tabs a, .tabs button { padding: .45rem .8rem; border-radius: 8px; border: 1px solid var(--line); color: var(--muted); background: transparent; font: inherit; cursor: pointer; }
.tabs a.active, .tabs button.active { background: var(--panel2); color: var(--text); border-color: var(--accent); }
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .35rem 1rem; font-size: .9rem; }
.kv dt { color: var(--muted); } .kv dd { margin: 0; word-break: break-word; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 1rem; border-left: 2px solid var(--line); }
.timeline li { position: relative; padding: 0 0 .9rem .75rem; }
.timeline li::before { content: ""; position: absolute; left: -1.42rem; top: .35rem; width: 10px; height: 10px; border-radius: 50%; background: var(--accent); }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.admin-grid a { display: block; padding: 1rem; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.admin-grid a:hover { border-color: var(--accent); text-decoration: none; }
.admin-grid a span { display: block; color: var(--muted); font-size: .82rem; margin-top: .3rem; }

/* ---------- Charts (SVG drawn by site.js) ---------- */
.chart { width: 100%; height: 180px; display: block; }
.chart.tall { height: 240px; }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .grid-line { stroke: #1a2742; stroke-width: 1; }
.chart .line-lat { fill: none; stroke: var(--accent); stroke-width: 2; }
.chart .line-max { fill: none; stroke: #7dd3fc; stroke-width: 1; stroke-dasharray: 3 3; }
.chart .line-loss { fill: none; stroke: var(--warn); stroke-width: 2; }
.chart .line-jit { fill: none; stroke: var(--flap); stroke-width: 1.5; }
.chart .area-lat { fill: rgba(56,189,248,.12); }
.chart .lbl { fill: var(--muted); font-size: 10px; }
.chart .dot-down { fill: var(--down); }
.donut-wrap { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; }
.donut { width: 150px; height: 150px; }
.legend { list-style: none; padding: 0; margin: 0; font-size: .85rem; }
.legend li { display: flex; align-items: center; gap: .45rem; margin: .2rem 0; }
.sw { width: 10px; height: 10px; border-radius: 2px; display: inline-block; }
.sw.Healthy { background: var(--ok); } .sw.Degraded { background: var(--warn); } .sw.Critical { background: var(--crit); } .sw.Down { background: var(--down); }
.sw.Flapping { background: var(--flap); } .sw.Maintenance { background: var(--maint); } .sw.Unknown { background: var(--unk); } .sw.Disabled { background: #334155; }
.donut .seg-Healthy { stroke: var(--ok); } .donut .seg-Degraded { stroke: var(--warn); } .donut .seg-Critical { stroke: var(--crit); } .donut .seg-Down { stroke: var(--down); }
.donut .seg-Flapping { stroke: var(--flap); } .donut .seg-Maintenance { stroke: var(--maint); } .donut .seg-Unknown { stroke: var(--unk); } .donut .seg-Disabled { stroke: #334155; }
.donut .center { fill: var(--text); font-size: 8px; font-weight: 700; } .donut .center-sub { fill: var(--muted); font-size: 3px; }
.bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; min-width: 60px; }
.bar > i { display: block; height: 100%; background: var(--ok); width: 0; }
.chip { display: inline-block; padding: .1rem .45rem; border: 1px solid var(--line); border-radius: 6px; font-size: .75rem; color: var(--muted); }
.ticker-feed { max-height: 320px; overflow: auto; }
.ticker-feed li { font-size: .85rem; }

/* ---------- Auth pages ---------- */
.auth { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; background: radial-gradient(ellipse at top, #13213d, var(--bg)); }
.auth .box { width: 100%; max-width: 410px; background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 1.75rem; }
.auth .brand { justify-content: center; margin-bottom: 1.25rem; }
.auth .btn { width: 100%; }
.otp-input { letter-spacing: .5em; text-align: center; font-size: 1.4rem !important; }

/* ---------- PWA install banner ---------- */
.install-banner { position: fixed; left: 1rem; right: 1rem; bottom: 1rem; z-index: 50; background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px; padding: .8rem 1rem; display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1400px) { .cards { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .g3, .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 40; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .menu-btn { display: inline-block; }
  .g2, .g3, .g4, .form-grid { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
  .cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .content { padding: .85rem; }
  .hide-sm { display: none; }
  .card .n { font-size: 1.6rem; }
}
.scrim { display: none; }
@media (max-width: 860px) { .scrim.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 30; } }
@supports (padding: max(0px)) { .topbar { padding-top: max(.6rem, env(safe-area-inset-top)); } .content { padding-bottom: max(1.25rem, env(safe-area-inset-bottom)); } }
.card-n-lg { font-size: 1.8rem; font-weight: 700; }

/* Validation summary renders an inline display:none that CSP blocks */
.validation-summary-valid { display: none; }
.chart circle.pt { stroke-width: 0; } .chart circle.line-lat { fill: var(--accent); } .chart circle.line-loss { fill: var(--warn); } .chart circle.line-max { fill: #7dd3fc; }

/* ---- Down / up alerts: toasts (dashboard and wallboard) ---- */
.alert-stack { position: fixed; top: 4rem; right: .75rem; z-index: 100; display: flex; flex-direction: column; gap: .5rem; width: min(26rem, calc(100vw - 1.5rem)); pointer-events: none; }
.toast { pointer-events: auto; display: flex; gap: .75rem; align-items: flex-start; padding: .8rem 1rem; border-radius: 10px; border: 1px solid var(--line);
  background: #111a2e; box-shadow: 0 10px 30px rgba(0,0,0,.55); border-left: 6px solid var(--unk); cursor: pointer; animation: toast-in .25s ease-out; }
.toast .ic { font-size: 1.6rem; line-height: 1; }
.toast .tt { font-weight: 800; font-size: 1.05rem; }
.toast .tb { color: var(--muted); font-size: .85rem; overflow-wrap: anywhere; }
.toast.down { border-left-color: var(--down); background: #3a1016; }
.toast.down .tt { color: #fecaca; }
.toast.up { border-left-color: var(--ok); background: #0c2a1b; }
.toast.up .tt { color: #bbf7d0; }
.toast.info { border-left-color: var(--accent); }
@keyframes toast-in { from { transform: translateY(-.75rem); opacity: 0; } to { transform: none; opacity: 1; } }
.alerts-btn.on { border-color: var(--ok); color: var(--ok); }
.alerts-btn.blocked { border-color: var(--warn); color: var(--warn); }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(14rem, 1fr)); gap: .25rem .75rem; margin-bottom: .75rem; }
.policy-tabs { display: flex; flex-wrap: wrap; gap: .35rem; }
ol.steps li { margin: .45em 0; }
