:root {
  --bg: #0b1016; --panel: #121a23; --panel2: #18222d; --line: #223040; --text: #d7e1ea; --mute: #8296a9;
  --ok: #3ddc97; --warn: #ffb454; --bad: #ff5d6c; --info: #5aa9ff; --vio: #b58cff;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  --side: 208px; --top: 54px; --bottom: 0px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); font: 14px/1.45 var(--sans); -webkit-text-size-adjust: 100%; }
a { color: var(--info); }
h1, h2, h3, h4 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 18px; } h3 { font-size: 14px; } h4 { font-size: 12px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; }
p { margin: 0 0 8px; }
button, input, select, textarea { font: inherit; color: inherit; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.mute { color: var(--mute); } .ok { color: var(--ok); } .warn { color: var(--warn); } .bad { color: var(--bad); } .info { color: var(--info); } .vio { color: var(--vio); }
.small { font-size: 12px; } .right { text-align: right; } .grow { flex: 1; min-width: 0; } .nowrap { white-space: nowrap; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .row.top { align-items: flex-start; } .between { justify-content: space-between; }
.col { display: flex; flex-direction: column; gap: 8px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--mute); letter-spacing: 0.2em; text-transform: uppercase; }

/* Shell */
.topbar { position: fixed; inset: 0 0 auto 0; height: var(--top); background: #0e151d; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 14px; padding: 0 14px; z-index: 900; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -0.01em; white-space: nowrap; }
.brand img { width: 24px; height: 24px; }
.topbar .kpis { display: flex; gap: 18px; margin-left: auto; align-items: center; }
.kpi { display: flex; flex-direction: column; line-height: 1.15; }
.kpi span { font-size: 10px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.07em; }
.kpi b { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mute); display: inline-block; flex: none; }
.dot.ok { background: var(--ok); box-shadow: 0 0 8px #3ddc9799; } .dot.degraded, .dot.warn { background: var(--warn); } .dot.down, .dot.bad { background: var(--bad); box-shadow: 0 0 8px #ff5d6c99; } .dot.idle { background: #46586a; }
.side { position: fixed; top: var(--top); bottom: 0; left: 0; width: var(--side); background: #0e151d; border-right: 1px solid var(--line); padding: 10px 8px; overflow-y: auto; z-index: 800; display: flex; flex-direction: column; gap: 2px; }
.nav { display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 8px; border: 0; background: none; color: var(--mute); cursor: pointer; text-align: left; width: 100%; }
.nav:hover { background: var(--panel); color: var(--text); }
.nav.on { background: var(--panel2); color: var(--text); box-shadow: inset 2px 0 0 var(--ok); }
.nav svg { width: 18px; height: 18px; flex: none; }
.nav .badge { margin-left: auto; }
.main { padding: calc(var(--top) + 16px) 16px 32px calc(var(--side) + 16px); max-width: 1500px; }
.badge { display: inline-block; font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 999px; background: var(--panel2); border: 1px solid var(--line); color: var(--mute); white-space: nowrap; }
.badge.ok { color: var(--ok); border-color: #1f5b45; background: #10261f; } .badge.warn { color: var(--warn); border-color: #6b4c1c; background: #2a2012; }
.badge.bad { color: var(--bad); border-color: #6d2630; background: #2a1418; } .badge.info { color: var(--info); border-color: #24476f; background: #111f31; } .badge.vio { color: var(--vio); border-color: #48367a; background: #1b1630; }

/* Building blocks */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; }
.panel > h3, .panel > .row > h3 { margin-bottom: 2px; }
.grid { display: grid; gap: 12px; }
.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)); }
.gauto { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); } .gstat { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; min-width: 0; }
.stat span { font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.07em; display: block; }
.stat b { font: 600 20px/1.3 var(--mono); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat i { font-style: normal; font-size: 12px; color: var(--mute); }
.btn { border: 1px solid var(--line); background: var(--panel2); border-radius: 8px; padding: 7px 12px; cursor: pointer; white-space: nowrap; font-weight: 550; }
.btn:hover { border-color: #3a5068; background: #1d2a37; }
.btn.pri { background: #14a06c; border-color: #14a06c; color: #04140d; } .btn.pri:hover { background: #2fc58a; }
.btn.danger { color: var(--bad); } .btn.sm { padding: 3px 9px; font-size: 12px; } .btn.big { padding: 11px 18px; font-size: 15px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
input, select, textarea { background: #0d141b; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; min-width: 0; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .nav:focus-visible { outline: 2px solid #3ddc9788; outline-offset: 1px; }
input[type=number] { width: 90px; font-family: var(--mono); }
textarea { width: 100%; font: 12px/1.4 var(--mono); resize: vertical; }
label.f { display: flex; flex-direction: column; gap: 3px; font-size: 12px; color: var(--mute); }
table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-size: 11px; color: var(--mute); text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 7px 8px; border-bottom: 1px solid #1a2531; vertical-align: middle; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; }
.scroll { overflow-x: auto; }
.tabs { display: flex; gap: 4px; flex-wrap: wrap; }
.tab { border: 1px solid var(--line); background: none; border-radius: 999px; padding: 5px 12px; cursor: pointer; color: var(--mute); white-space: nowrap; }
.tab.on { background: var(--panel2); color: var(--text); border-color: #3a5068; }
.meter { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.meter .lbl { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--mute); }
.meter .lbl b { color: var(--text); font: 500 12px var(--mono); white-space: nowrap; }
.meter .bar { height: 7px; background: #0b1218; border-radius: 99px; overflow: hidden; border: 1px solid #1c2835; }
.meter .bar i { display: block; height: 100%; background: var(--ok); border-radius: 99px; transition: width 0.4s; }
.meter.warn .bar i { background: var(--warn); } .meter.bad .bar i { background: var(--bad); }
.issue { display: flex; gap: 8px; align-items: baseline; padding: 6px 10px; border-radius: 8px; background: #2a1418; border: 1px solid #5a222b; font-size: 13px; }
.issue.major { background: #2a2012; border-color: #5d4318; } .issue.minor { background: var(--panel2); border-color: var(--line); color: var(--mute); }
.feed { display: flex; flex-direction: column; }
.feed div { display: flex; gap: 10px; padding: 6px 0; border-bottom: 1px solid #1a2531; font-size: 13px; }
.feed div:last-child { border: 0; }
.feed time { color: var(--mute); font: 11px var(--mono); white-space: nowrap; padding-top: 2px; }
.empty { color: var(--mute); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 10px; }
.head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }

/* Power / cooling chain */
.chain { display: flex; align-items: stretch; gap: 0; overflow-x: auto; padding-bottom: 4px; }
.node { flex: 1 0 140px; background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; display: flex; flex-direction: column; gap: 5px; min-width: 140px; }
.node h5 { margin: 0; font-size: 11px; text-transform: uppercase; letter-spacing: 0.07em; color: var(--mute); display: flex; justify-content: space-between; }
.node b { font: 600 15px var(--mono); }
.node .meter .lbl span { display: none; } .node .meter .lbl { justify-content: flex-start; } .node .meter .lbl b { font-size: 11px; color: var(--mute); }
.node.bad { border-color: #7d2a35; } .node.warn { border-color: #6b4c1c; } .node.none { border-style: dashed; opacity: 0.75; }
.link { flex: 0 0 22px; display: grid; place-items: center; color: #3a5068; }
.link::before { content: ""; width: 100%; height: 2px; background: currentColor; }
.link.live { color: var(--ok); } .link.cool { color: var(--info); }

/* Rooms and racks */
.room { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.racks { display: grid; grid-template-columns: repeat(auto-fill, 22px); gap: 4px; padding: 10px; background: #0b1218; border-radius: 8px; border: 1px solid #1c2835; max-height: 330px; overflow-y: auto; }
.rack { width: 22px; height: 34px; border-radius: 3px; border: 1px solid #2c3e50; background: #131d27; padding: 0; cursor: pointer; position: relative; overflow: hidden; }
.rack i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--ok); opacity: 0.85; }
.rack.colo { border-color: #6a54ad; } .rack.colo i { background: var(--vio); }
.rack.ordered { border-style: dashed; opacity: 0.6; } .rack.failed { border-color: var(--bad); }
.rack.slot { border-style: dotted; border-color: #1f2c39; background: none; cursor: default; }
.rack:hover:not(.slot) { outline: 2px solid #ffffff55; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--mute); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 4px; vertical-align: -1px; }
.temp { font: 600 20px var(--mono); }

/* Guided mode */
.guide { background: linear-gradient(135deg, #12263a, var(--panel) 60%); border: 1px solid #24476f; border-left: 3px solid var(--info); border-radius: 12px; padding: 14px; display: flex; flex-direction: column; gap: 9px; margin-bottom: 14px; }
.guide h3 { font-size: 16px; }
.gwhy { margin: 0; max-width: 820px; color: #c3d0dc; }
.gtask { display: flex; gap: 8px; align-items: baseline; font-size: 13px; }
.gtask span:first-child { width: 14px; flex: none; color: var(--mute); }
.gtask.done { color: var(--mute); } .gtask.done span:first-child { color: var(--ok); }
.gdots { display: flex; gap: 4px; align-items: center; }
.gdots i { width: 14px; height: 4px; border-radius: 2px; background: #2a3b4d; }
.gdots i.done { background: var(--ok); } .gdots i.cur { background: var(--info); }
.gexplain { font-size: 13px; color: var(--mute); background: #0d141b99; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; }
.gexplain b { color: var(--text); font-weight: 600; }

/* Badges */
.badgegrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.badgecard { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; padding: 14px 10px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel2); cursor: pointer; color: inherit; }
.badgecard:hover { border-color: #3a5068; transform: translateY(-2px); transition: transform 0.15s; }
.badgecard:not(.earned) b { color: var(--mute); }
.medal { border-radius: 50%; display: grid; place-items: center; flex: none; background: radial-gradient(circle at 35% 30%, #fff 0%, var(--lv) 35%, var(--lvd) 100%); box-shadow: 0 0 0 3px #ffffff22, 0 4px 18px color-mix(in srgb, var(--lv) 45%, transparent); }
.medal span { display: grid; place-items: center; width: 76%; height: 76%; border-radius: 50%; background: #0b1016dd; line-height: 1; }
.medal.locked { background: #1d2833; box-shadow: none; filter: grayscale(1); opacity: 0.55; }
.unlock { display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; position: relative; padding: 10px 0; }
.unlock .medal { animation: pop 0.7s cubic-bezier(.2,1.6,.4,1) both; }
.unlock > :not(.burst) { position: relative; z-index: 1; }
.burst { position: absolute; z-index: 0; top: -56px; left: 50%; width: 260px; height: 260px; margin-left: -130px; border-radius: 50%; background: repeating-conic-gradient(#f4c54214 0 10deg, transparent 10deg 20deg); -webkit-mask: radial-gradient(circle, #000 35%, transparent 70%); mask: radial-gradient(circle, #000 35%, transparent 70%); animation: spin 12s linear infinite; pointer-events: none; }
@keyframes pop { 0% { transform: scale(0.2) rotate(-25deg); opacity: 0; } 100% { transform: scale(1) rotate(0); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
.btn.linkedin { background: #0a66c2; border-color: #0a66c2; color: #fff; }
.btn.linkedin:hover { background: #2a7fd6; }

/* Payday and cash runway */
.cashkpi { position: relative; }
.cashkpi.danger b { color: var(--bad); animation: pulse 1s ease-in-out infinite; }
.payfloat { position: absolute; left: 0; top: 100%; font: 700 14px var(--mono); font-style: normal; color: var(--ok); text-shadow: 0 0 10px #3ddc9799; white-space: nowrap; pointer-events: none; animation: payfloat 2.4s ease-out forwards; }
@keyframes payfloat { 0% { opacity: 0; transform: translateY(14px) scale(0.8); } 15% { opacity: 1; transform: translateY(0) scale(1.15); } 70% { opacity: 1; } 100% { opacity: 0; transform: translateY(-22px) scale(1); } }
.runway { display: flex; align-items: center; gap: 6px; border: 1px solid #6d2630; background: #2a1418; color: #ffb3ba; border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.runway b { font-family: var(--mono); color: var(--bad); }
.runway span[aria-hidden] { display: inline-block; animation: hourglass 2s ease-in-out infinite; }
.runway.urgent { background: #4a1219; border-color: var(--bad); color: #fff; animation: pulse 0.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.55; } }
@keyframes hourglass { 0%, 40% { transform: rotate(0); } 50%, 90% { transform: rotate(180deg); } 100% { transform: rotate(360deg); } }

/* Dock: guide and work in progress, fixed on the right */
:root { --dock: 340px; }
.dock { position: fixed; top: var(--top); right: 0; bottom: 0; width: var(--dock); overflow-y: auto; padding: 14px 12px 24px; border-left: 1px solid var(--line); background: #0e151d; z-index: 790; }
.dockbody { display: flex; flex-direction: column; gap: 12px; }
.dock .guide { margin: 0; }
.dockbar { display: none; }
.main.hasdock { padding-right: calc(var(--dock) + 16px); max-width: none; }
.qitem { cursor: pointer; display: flex; flex-direction: column; gap: 5px; padding-bottom: 9px; border-bottom: 1px solid #1a2531; }
.qitem:last-child { border: 0; padding-bottom: 0; }
.qitem:hover b { color: var(--info); }
.qitem b { font-weight: 600; font-size: 13px; }
.qbar { height: 5px; background: #0b1218; border-radius: 99px; overflow: hidden; border: 1px solid #1c2835; }
.qbar i { display: block; height: 100%; background: var(--info); border-radius: 99px; transition: width 0.5s linear; }
.qbar.warn i { background: var(--warn); }
@media (max-width: 1180px) {
  .main.hasdock { padding-right: 16px; }
  .dock { position: sticky; top: var(--top); width: auto; bottom: auto; padding: 0; margin: -16px -16px 14px; border-left: 0; border-bottom: 1px solid var(--line); max-height: 72vh; box-shadow: 0 8px 20px #0006; }
  .dockbar { display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 14px; background: none; border: 0; cursor: pointer; text-align: left; font-weight: 550; }
  .dock:not(.open) .dockbody { display: none; }
  .dock.open .dockbody { padding: 4px 12px 14px; }
}
@media (max-width: 900px) { .main.hasdock { padding-right: 10px; } .dock { margin: -12px -10px 12px; } }

/* Isometric view */
.iso { position: relative; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: radial-gradient(900px 420px at 50% 0%, #14222c 0%, #0a1015 70%); }
.iso canvas { display: block; width: 100%; height: 460px; touch-action: pan-y; }
.isoctl { position: absolute; top: 10px; right: 10px; display: flex; gap: 4px; }
.isoctl .btn { width: 30px; padding: 3px 0; text-align: center; font-size: 15px; }
.isoleg { position: absolute; left: 12px; bottom: 9px; pointer-events: none; }
.isotip { position: absolute; pointer-events: none; background: #1b2733; border: 1px solid var(--line); border-radius: 6px; padding: 4px 8px; font-size: 12px; max-width: 220px; z-index: 5; box-shadow: 0 6px 18px #0008; }

/* Modal, toast */
.overlay { position: fixed; inset: 0; background: #05080ccc; z-index: 2000; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 12px; overflow-y: auto; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; width: min(860px, 100%); box-shadow: 0 20px 60px #000a; }
.modal.narrow { width: min(520px, 100%); }
.modal > header { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--panel); border-radius: 14px 14px 0 0; z-index: 1; }
.modal > .body { padding: 16px; display: flex; flex-direction: column; gap: 12px; }
.x { border: 0; background: none; font-size: 22px; line-height: 1; cursor: pointer; color: var(--mute); padding: 4px 8px; }
.toasts { position: fixed; right: 14px; bottom: calc(var(--bottom) + 14px); z-index: 3000; display: flex; flex-direction: column; gap: 8px; max-width: min(420px, calc(100vw - 28px)); }
.toast { background: #1b2733; border: 1px solid var(--line); border-left: 3px solid var(--info); border-radius: 8px; padding: 10px 12px; box-shadow: 0 8px 24px #0008; }
.toast.bad { border-left-color: var(--bad); } .toast.good { border-left-color: var(--ok); }
.item { display: flex; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1px solid #1a2531; }
.item:last-child { border: 0; }
.item .specs { font: 12px var(--mono); color: var(--mute); }
.locked { opacity: 0.55; }

/* Map */
.mapwrap { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 12px; height: calc(100vh - var(--top) - 100px); min-height: 420px; }
#map { border-radius: 12px; border: 1px solid var(--line); background: #0b1218; min-height: 300px; }
.leaflet-tile-pane { filter: invert(1) hue-rotate(180deg) brightness(0.9) contrast(0.9) saturate(0.6); }
.leaflet-container { background: #0b1218; font: inherit; }
.leaflet-popup-content-wrapper, .leaflet-popup-tip { background: var(--panel); color: var(--text); border: 1px solid var(--line); }
.leaflet-control-attribution { background: #0b1016cc !important; color: var(--mute); } .leaflet-control-attribution a { color: var(--mute); }
.leaflet-bar a { background: var(--panel); color: var(--text); border-color: var(--line); } .leaflet-bar a:hover { background: var(--panel2); color: var(--text); }
.mapside { overflow-y: auto; }
.heatbar { height: 8px; border-radius: 99px; background: linear-gradient(90deg, rgb(43,108,255), rgb(255,210,61), rgb(255,61,77)); margin-bottom: 3px; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(900px 500px at 50% -10%, #12352b 0%, transparent 60%), var(--bg); }
.login .card { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 28px; display: flex; flex-direction: column; gap: 14px; }
.login h1 { font-size: 26px; } .login input { padding: 11px 12px; font-size: 16px; }
.login ul { margin: 0; padding-left: 18px; color: var(--mute); font-size: 13px; }
.hero { background: linear-gradient(135deg, #12352b, var(--panel) 55%); }
.tech { background: var(--panel2); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.tech.done { border-color: #1f5b45; } .tech.locked { opacity: 0.55; }
.bottom { display: none; }

@media (max-width: 900px) {
  :root { --side: 0px; --bottom: 58px; }
  .side { display: none; }
  .main { padding: calc(var(--top) + 12px) 10px calc(var(--bottom) + 24px); }
  .bottom { display: flex; position: fixed; inset: auto 0 0 0; height: var(--bottom); background: #0e151d; border-top: 1px solid var(--line); z-index: 900; padding-bottom: env(safe-area-inset-bottom); }
  .bottom .nav { flex: 1; flex-direction: column; gap: 2px; font-size: 10px; padding: 7px 2px; justify-content: center; align-items: center; border-radius: 0; position: relative; }
  .bottom .nav.on { box-shadow: inset 0 2px 0 var(--ok); }
  .bottom .nav .badge { position: absolute; top: 4px; left: calc(50% + 6px); margin: 0; }
  .topbar .kpis { gap: 12px; } .topbar .hide-m { display: none; }
  .brand span { display: none; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .gstat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .mapwrap { grid-template-columns: 1fr; height: auto; } #map { height: 52vh; }
  .overlay { padding: 0; align-items: stretch; } .modal, .modal.narrow { width: 100%; border-radius: 0; min-height: 100%; border: 0; } .modal > header { border-radius: 0; }
  .item { flex-wrap: wrap; }
  .iso canvas { height: 320px; } .isoleg .hide-m { display: none; }
  .sheet { position: fixed; inset: auto 0 var(--bottom) 0; background: #0e151d; border-top: 1px solid var(--line); padding: 8px; z-index: 850; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
}
@media (min-width: 901px) { .sheet { display: none; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
