:root {
  --bg: #02050B;
  --panel-top: rgba(10, 22, 40, .92);
  --panel-bottom: rgba(5, 12, 24, .92);
  --line: rgba(34, 211, 238, .28);
  --line-soft: rgba(34, 211, 238, .14);
  --cyan: #22D3EE;
  --blue: #3B82F6;
  --violet: #A78BFA;
  --pink: #E879F9;
  --green: #34D399;
  --amber: #FBBF24;
  --red: #F87171;
  --text: #E0FBFF;
  --text-2: #CFFAFE;
  --muted: #9DB4C6;
  --dim: #7FA0B6;
  --display: 'Orbitron', system-ui, sans-serif;
  --ui: 'Rajdhani', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font: 500 16px/1.4 var(--ui);
  background-color: var(--bg);
  background-image:
    linear-gradient(rgba(34, 211, 238, .035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(34, 211, 238, .035) 1px, transparent 1px),
    radial-gradient(1200px 600px at 70% -10%, rgba(37, 99, 235, .18), transparent 60%);
  background-size: 40px 40px, 40px 40px, 100% 100%;
  background-attachment: fixed;
}
a { color: var(--cyan); }
a:hover { color: #67E8F9; }
button, input { font: inherit; }
:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.mono { font-family: var(--mono); }
.num { font-family: var(--display); font-weight: 700; color: var(--text); text-shadow: 0 0 14px rgba(34, 211, 238, .45); }
.lbl { font: 600 13px var(--ui); letter-spacing: .14em; text-transform: uppercase; color: #8FB3C9; }
.muted { color: var(--muted); }
.dim { color: var(--dim); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- HUD panel ---------- */
.hud {
  position: relative;
  min-width: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: linear-gradient(180deg, var(--panel-top), var(--panel-bottom));
  box-shadow: inset 0 0 30px rgba(34, 211, 238, .05);
}
.hud::before, .hud::after { content: ""; position: absolute; width: 18px; height: 18px; pointer-events: none; }
.hud::before { top: -1px; left: -1px; border-top: 2px solid var(--cyan); border-left: 2px solid var(--cyan); filter: drop-shadow(0 0 4px var(--cyan)); }
.hud::after { bottom: -1px; right: -1px; border-bottom: 2px solid var(--cyan); border-right: 2px solid var(--cyan); filter: drop-shadow(0 0 4px var(--cyan)); }
.ttl { display: flex; align-items: center; gap: 10px; margin: 0; font: 700 15px var(--ui); letter-spacing: .12em; text-transform: uppercase; color: var(--text-2); }
.ttl::before { content: ""; border-left: 7px solid var(--cyan); border-top: 5px solid transparent; border-bottom: 5px solid transparent; filter: drop-shadow(0 0 4px var(--cyan)); }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-body { display: flex; flex-direction: column; gap: 14px; }
.row { display: flex; flex-wrap: wrap; gap: 18px; }
.row > .hud { flex: 1 1 320px; }
.row > .wide { flex: 2 1 520px; }
[hidden] { display: none !important; } /* layout rules (.row, .tab…) must never un-hide a block */
.tab { display: flex; flex-direction: column; gap: 18px; }
.tab[hidden] { display: none; }

/* ---------- layout ---------- */
.shell { display: flex; flex-wrap: wrap; min-height: 100vh; }
.side {
  flex: 1 1 250px; max-width: 100%;
  display: flex; flex-direction: column; gap: 28px;
  padding: 24px 16px;
  background: rgba(2, 6, 14, .85);
  border-right: 1px solid rgba(34, 211, 238, .18);
}
.main { flex: 999 1 560px; min-width: 0; display: flex; flex-direction: column; gap: 18px; padding: 22px clamp(16px, 2.6vw, 36px) 48px; }
@media (max-width: 829.98px) {
  .side { border-right: 0; border-bottom: 1px solid rgba(34, 211, 238, .18); gap: 16px; padding: 16px; }
  .side nav { flex-direction: row !important; overflow-x: auto; }
  .side .navbtn { flex: none; width: auto; }
  .side .side-note { display: none; }
}

.brand { display: flex; align-items: center; gap: 12px; padding: 0 6px; }
.brand svg { filter: drop-shadow(0 0 5px var(--cyan)); flex: none; }
.brand > div { display: flex; flex-direction: column; gap: 2px; }
.brand-name { font: 800 18px var(--display); letter-spacing: .12em; text-shadow: 0 0 12px rgba(34, 211, 238, .6); }
.brand-sub { font-size: 11px; letter-spacing: .42em; color: var(--cyan); }

.navbtn {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 44px; padding: 0 14px;
  border: 1px solid transparent; border-radius: 3px; background: transparent;
  color: var(--muted); font: 600 16px var(--ui); letter-spacing: .04em; text-align: left; text-decoration: none; cursor: pointer;
}
.navbtn:hover { color: var(--text); background: rgba(34, 211, 238, .06); }
.navbtn[aria-current="true"] { background: linear-gradient(90deg, var(--cyan), rgba(34, 211, 238, .35)); color: #02101A; border-color: var(--cyan); box-shadow: 0 0 18px rgba(34, 211, 238, .45); }
.navbtn svg { flex: none; }
.navbtn .count { margin-left: auto; font: 500 12px var(--mono); }
.proj-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.proj-text { display: flex; flex-direction: column; line-height: 1.15; }
.proj-text small { font: 500 11px var(--mono); color: var(--dim); }
.navbtn.proj[aria-current="true"] { background: rgba(34, 211, 238, .08); border-color: rgba(34, 211, 238, .35); color: var(--text); box-shadow: none; }

.side-note { margin-top: auto; padding: 14px; border: 1px dashed rgba(167, 139, 250, .45); border-radius: 3px; font-size: 14px; color: var(--muted); }
.logout { background: none; border: 1px solid var(--line); color: var(--muted); min-height: 44px; padding: 0 14px; border-radius: 3px; cursor: pointer; font: 500 13px var(--mono); width: 100%; }
.logout:hover { color: var(--text); border-color: var(--cyan); }

/* ---------- header ---------- */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 14px; justify-content: space-between; }
.top h1 { margin: 0; font: 700 clamp(22px, 2.6vw, 30px) var(--display); letter-spacing: .06em; text-shadow: 0 0 18px rgba(34, 211, 238, .5); }
.banner {
  padding: 10px 44px; border: 1px solid rgba(34, 211, 238, .5);
  background: linear-gradient(180deg, rgba(34, 211, 238, .16), rgba(37, 99, 235, .06));
  clip-path: polygon(16px 0, calc(100% - 16px) 0, 100% 50%, calc(100% - 16px) 100%, 16px 100%, 0 50%);
  font: 700 16px var(--display); letter-spacing: .24em; text-shadow: 0 0 10px var(--cyan);
}
.status-pill { display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 14px; border-radius: 3px; font: 500 13px var(--mono); border: 1px solid; }
.status-pill .dot { width: 8px; height: 8px; border-radius: 50%; animation: pulse 1.6s infinite; }
.pill-ok { border-color: rgba(52, 211, 153, .5); background: rgba(52, 211, 153, .08); color: #6EE7B7; }
.pill-ok .dot { background: var(--green); box-shadow: 0 0 10px var(--green); }
.pill-bad { border-color: rgba(248, 113, 113, .6); background: rgba(248, 113, 113, .1); color: #FCA5A5; }
.pill-bad .dot { background: var(--red); box-shadow: 0 0 10px var(--red); }
.pill-unknown { border-color: var(--line); color: var(--muted); }
.pill-unknown .dot { background: var(--dim); animation: none; }
.refresh { font: 500 12px var(--mono); color: var(--dim); }

/* ---------- KPIs ---------- */
.kpi { flex: 1 1 180px; display: flex; flex-direction: column; gap: 10px; }
.kpi-top, .kpi-mid { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.kpi-mid .num { font-size: 30px; }
.kpi-mid svg { filter: drop-shadow(0 0 6px rgba(34, 211, 238, .7)); flex: none; }
.kpi-note { font-size: 14px; color: #8FB3C9; }

/* ---------- controls ---------- */
.chip { min-height: 44px; padding: 0 16px; border-radius: 3px; border: 1px solid rgba(34, 211, 238, .3); background: rgba(8, 20, 36, .8); color: var(--muted); font: 500 13px var(--mono); cursor: pointer; }
.chip:hover { border-color: var(--cyan); color: var(--text); }
.chip:disabled { opacity: .45; cursor: not-allowed; }
.act-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.chip.act { border-color: rgba(251, 191, 36, .45); color: #FCD34D; }
.chip.act:hover { border-color: var(--amber, #FBBF24); background: rgba(251, 191, 36, .08); }
.chip.act-go { border-color: rgba(251, 191, 36, .7); color: #FCD34D; background: rgba(251, 191, 36, .1); }
.confirm-input { min-height: 44px; padding: 0 12px; background: rgba(2, 8, 18, .8); border: 1px solid rgba(34, 211, 238, .35); border-radius: 3px; color: var(--text); font: 500 16px var(--mono); width: 100%; }
.confirm-input:focus { outline: 2px solid var(--cyan); outline-offset: 1px; }
button.issue { font: inherit; color: inherit; text-align: left; width: 100%; border-top: 0; border-right: 0; border-bottom: 0; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--cyan); border-color: var(--cyan); color: #02101A; box-shadow: 0 0 14px rgba(34, 211, 238, .5); }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.btn-primary { min-height: 48px; border: 1px solid var(--cyan); background: linear-gradient(90deg, var(--cyan), #3B82F6); color: #02101A; font: 700 15px var(--display); letter-spacing: .2em; cursor: pointer; border-radius: 3px; box-shadow: 0 0 18px rgba(34, 211, 238, .45); }

/* ---------- charts ---------- */
.chart { width: 100%; height: 220px; display: block; }
.legend { display: flex; justify-content: space-between; flex-wrap: wrap; gap: 8px; font: 500 12px var(--mono); color: var(--dim); }
.bar-track { height: 8px; background: rgba(34, 211, 238, .08); border: 1px solid rgba(34, 211, 238, .18); }
.bar-fill { height: 100%; }
.segs { display: flex; gap: 4px; height: 12px; }
.segs span { flex: 1 1 0; background: rgba(34, 211, 238, .08); }
.strip { display: flex; gap: 3px; height: 22px; }
.strip span { flex: 1 1 0; }
.ring-wrap { position: relative; width: 190px; height: 190px; margin: 0 auto; }
.ring-wrap .center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.stats { display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.stats > .stat { display: flex; flex-direction: column; }
a.stat { position: relative; padding: 4px 18px 4px 6px; margin: -4px -6px; border-radius: 3px; text-decoration: none; color: inherit; min-height: 44px; justify-content: center; }
a.stat:hover { background: rgba(34, 211, 238, .08); }
a.stat .go { position: absolute; top: 4px; right: 4px; }

/* ---------- click-through ---------- */
.meta-link { color: inherit; text-decoration: underline dotted rgba(34, 211, 238, .5); text-underline-offset: 3px; display: inline-block; padding: 6px 0; }
.meta-link:hover { color: var(--cyan); }
button.hud, a.hud { font: inherit; color: inherit; text-align: left; text-decoration: none; width: auto; }
a.hud.kpi { position: relative; }
a.hud.kpi > .go { position: absolute; top: 8px; right: 10px; }
.flash { animation: flash 1.2s ease-out; }
@keyframes flash { 0% { box-shadow: 0 0 0 2px var(--cyan), 0 0 24px rgba(34, 211, 238, .6); } 100% { box-shadow: none; } }
.clickable { cursor: pointer; transition: background .15s, box-shadow .15s; }
.clickable:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }
.clickable:hover { box-shadow: 0 0 0 1px rgba(34, 211, 238, .35); }
.go { font: 500 11px var(--mono); color: var(--dim); flex: none; }
.clickable:hover .go { color: var(--cyan); }
.btn-link { display: inline-flex; align-items: center; gap: 8px; align-self: flex-start; min-height: 44px; padding: 0 14px; border: 1px solid rgba(34, 211, 238, .35); border-radius: 3px; color: var(--cyan); text-decoration: none; font: 500 13px var(--mono); }
.btn-link:hover { background: rgba(34, 211, 238, .08); }
.stats .num { font-size: 20px; }

.radar {
  position: relative; width: 210px; height: 210px; margin: 0 auto; border-radius: 50%; overflow: hidden;
  border: 1px solid rgba(34, 211, 238, .5);
  background:
    repeating-radial-gradient(circle, transparent 0 34px, rgba(34, 211, 238, .28) 34px 35px),
    linear-gradient(transparent calc(50% - .5px), rgba(34, 211, 238, .25) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    linear-gradient(90deg, transparent calc(50% - .5px), rgba(34, 211, 238, .25) calc(50% - .5px) calc(50% + .5px), transparent calc(50% + .5px)),
    #03101C;
}
.radar .sweep { position: absolute; inset: 0; border-radius: 50%; background: conic-gradient(from 0deg, rgba(34, 211, 238, .55), rgba(34, 211, 238, 0) 70deg, transparent 360deg); animation: sweep 4s linear infinite; }
.radar .blip { position: absolute; width: 9px; height: 9px; margin: -4px 0 0 -4px; border-radius: 50%; animation: pulse 1.4s infinite; }
.radar-note { text-align: center; font: 500 13px var(--mono); }
.radar .blip-hit { position: absolute; width: 44px; height: 44px; margin: -22px 0 0 -22px; border-radius: 50%; z-index: 1; }
.radar .blip-hit:hover .blip, .radar .blip-hit:focus-visible .blip { width: 14px; height: 14px; margin: -7px 0 0 -7px; }
.radar .blip-hit:focus-visible { outline: 2px solid var(--cyan); }
a.radar-link { display: flex; justify-content: center; gap: 8px; align-items: center; min-height: 44px; text-decoration: none; border-radius: 3px; }
a.radar-link:hover { background: rgba(34, 211, 238, .06); }

.hbar { display: grid; grid-template-columns: 110px minmax(0, 1fr) 44px; gap: 10px; align-items: center; }
.hbar > span:first-child { text-align: right; font-size: 14px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar .track { height: 20px; background: rgba(255, 255, 255, .03); }
.hbar .fill { height: 100%; border: 1px solid; }

.issue { display: flex; gap: 10px; align-items: center; padding: 8px 10px; background: rgba(34, 211, 238, .04); border-left: 2px solid; text-decoration: none; color: inherit; min-height: 44px; }
.issue:hover { background: rgba(34, 211, 238, .09); color: inherit; }
.issue .t { flex: 1; min-width: 0; font: 500 12px var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.goals { display: flex; flex-wrap: wrap; gap: 14px; justify-content: space-around; }
.goal { flex: 1 1 130px; display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; }
.goal .ring { position: relative; width: 120px; height: 120px; }
button.goal { background: none; border: 1px solid transparent; border-radius: 4px; padding: 10px; font: inherit; color: inherit; }
button.goal:hover { border-color: rgba(34, 211, 238, .3); background: rgba(34, 211, 238, .04); }
.goal .ring .num { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 20px; }

.timeline { display: flex; flex-direction: column; gap: 12px; }
.tl-item { display: flex; gap: 14px; align-items: flex-start; }
.tl-item .diamond { margin-top: 6px; width: 10px; height: 10px; transform: rotate(45deg); flex: none; }
.tl-item .body { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.tl-item .head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; }

.board { display: flex; flex-wrap: wrap; gap: 12px; }
.col { flex: 1 1 200px; min-width: 0; display: flex; flex-direction: column; gap: 10px; padding: 12px; background: rgba(2, 8, 18, .7); border: 1px solid var(--line-soft); }
.col-head { display: flex; justify-content: space-between; align-items: center; }
.col-rule { height: 2px; }
.card { padding: 12px; background: rgba(10, 22, 40, .9); border: 1px solid rgba(34, 211, 238, .16); display: flex; flex-direction: column; gap: 8px; }
.card .t { font-size: 15px; line-height: 1.3; }
.card .meta { display: flex; gap: 8px; align-items: center; }
button.card { font: inherit; color: inherit; text-align: left; width: 100%; }
button.card:hover { border-color: rgba(34, 211, 238, .5); }
.more { background: none; border: 1px dashed rgba(34, 211, 238, .3); color: var(--muted); font: 500 12px var(--mono); min-height: 44px; border-radius: 3px; }
.more:hover { color: var(--text); border-color: var(--cyan); }

.chart .day { cursor: pointer; }
.chart .day:hover .bar { opacity: 1; filter: drop-shadow(0 0 6px #22D3EE); }

/* ---------- trends & report ---------- */
.trends { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.trend { display: flex; flex-direction: column; gap: 2px; padding: 10px; background: rgba(2, 8, 18, .6); border: 1px solid var(--line-soft); border-radius: 3px; min-width: 0; }
.trend .num { font-size: 18px; }
.trend .spark { width: 100%; height: 28px; margin-top: 4px; }
#reportBtn[hidden] { display: none; }
@media print {
  body.printing-report .shell { display: none; }
  body.printing-report .detail { position: static; width: auto; max-height: none; box-shadow: none; border: 0; color: #000; background: #fff; }
  body.printing-report .detail * { color: #000 !important; text-shadow: none !important; background: transparent !important; }
  body.printing-report .detail .act-row, body.printing-report #detailClose { display: none; }
  body.printing-report .detail-text { max-height: none; overflow: visible; }
}

.machine-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 18px; }

/* ---------- services ---------- */
.svc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.svc-proj { display: flex; flex-direction: column; gap: 8px; padding: 12px; background: rgba(2, 8, 18, .6); border: 1px solid var(--line-soft); border-radius: 3px; min-width: 0; }
.svc-row { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; flex-wrap: wrap; border-top: 1px solid rgba(34, 211, 238, .08); padding-top: 6px; }
.svc-name { font: 500 14px var(--mono); }
.svc-deps { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.svc-dep { display: flex; gap: 8px; text-decoration: none; min-height: 28px; align-items: center; }
.svc-dep:hover { text-decoration: underline; }
#svcCerts .issue, #svcActions .issue { flex-wrap: wrap; }
#svcCerts .issue .t, #svcActions .issue .t { white-space: normal; overflow-wrap: anywhere; flex-basis: 60%; }

/* ---------- home ---------- */
#nav[hidden] { display: none !important; }
.home-card { display: flex; flex-direction: column; gap: 12px; flex: 1 1 320px; cursor: pointer; }
.home-card .panel-head { margin-bottom: 0; }
.home-card .ttl::before { display: none; }
.home-card:hover { border-color: rgba(34, 211, 238, .5); }
.goal-bar { display: grid; grid-template-columns: 1fr; gap: 6px; }
.goal-bar .track { height: 8px; background: rgba(255, 255, 255, .05); border-radius: 4px; overflow: hidden; }
.goal-bar .fill { height: 100%; border-radius: 4px; }
.att-row { display: flex; gap: 8px; align-items: stretch; }
.att-row .issue { flex: 1; min-width: 0; }
.go-out { display: flex; align-items: center; justify-content: center; min-width: 44px; border: 1px solid rgba(34, 211, 238, .25); border-radius: 3px; color: var(--cyan); text-decoration: none; }
.go-out:hover { background: rgba(34, 211, 238, .08); }

/* ---------- detail panel ---------- */
.detail { width: min(720px, calc(100vw - 32px)); max-height: calc(100vh - 64px); overflow: auto; color: var(--text); padding: 20px; }
.detail::backdrop { background: rgba(0, 4, 10, .72); backdrop-filter: blur(2px); }
.detail-text { margin: 0; white-space: pre-wrap; word-break: break-word; font: 400 13px/1.5 var(--mono); color: var(--text-2); background: rgba(2, 8, 18, .7); border: 1px solid var(--line-soft); padding: 12px; max-height: 50vh; overflow: auto; }
.tag { font: 500 11px var(--mono); padding: 2px 8px; border: 1px solid; }

.log-item { display: flex; flex-direction: column; gap: 6px; padding-bottom: 14px; border-bottom: 1px solid rgba(34, 211, 238, .12); }
.log-item:last-child { border-bottom: 0; padding-bottom: 0; }
a.tl-item, a.log-item { position: relative; text-decoration: none; color: inherit; padding: 6px 22px 6px 6px; margin: -6px; border-radius: 3px; }
a.log-item { padding-bottom: 14px; margin-bottom: 0; }
a.tl-item:hover, a.log-item:hover { background: rgba(34, 211, 238, .06); }
a.tl-item > .go, a.log-item > .go { position: absolute; top: 8px; right: 6px; }
.log-item .head { display: flex; justify-content: space-between; gap: 8px; }
.log-ver { font-size: 15px; color: #E9D5FF; text-shadow: 0 0 12px rgba(232, 121, 249, .5); }

.offline { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; padding: 14px; border: 1px dashed rgba(34, 211, 238, .3); color: var(--muted); font-size: 14px; }
.offline .mono { font-size: 12px; color: var(--amber); }
.offline.err .mono { color: var(--red); }
.skeleton { height: 120px; background: linear-gradient(90deg, rgba(34, 211, 238, .04), rgba(34, 211, 238, .1), rgba(34, 211, 238, .04)); background-size: 200% 100%; animation: shimmer 1.4s infinite; }

/* ---------- login ---------- */
.login-page { display: flex; align-items: center; justify-content: center; padding: 16px; }
.login-card { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 20px; padding: 32px 28px; }
.login-card form { display: flex; flex-direction: column; gap: 12px; }
.login-card input { min-height: 48px; padding: 0 14px; border-radius: 3px; border: 1px solid var(--line); background: rgba(5, 12, 24, .9); color: var(--text); font-size: 16px; }
.login-msg { margin: 0; color: #FCA5A5; font: 500 13px var(--mono); }

@keyframes sweep { to { transform: rotate(360deg); } }
@keyframes pulse { 50% { opacity: .35; } }
@keyframes shimmer { to { background-position: -200% 0; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; scroll-behavior: auto !important; }
}
