/* ============ WIRED · app.css ============ */

@font-face {
  font-family: "Pixelify";
  src: url("vendor/fonts/pixelify-latin.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "Pixelify";
  src: url("vendor/fonts/pixelify-cyrillic.woff2") format("woff2");
  font-weight: 400 700;
  font-display: swap;
  unicode-range: U+0400-04FF;
}
@font-face {
  font-family: "JBMono";
  src: url("vendor/fonts/jbmono-latin.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0000-00FF, U+2000-206F;
}
@font-face {
  font-family: "JBMono";
  src: url("vendor/fonts/jbmono-cyrillic.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
  unicode-range: U+0400-04FF;
}

:root {
  --bg: #060607;
  --bg2: #0b0b0d;
  --panel: #0c0c0f;
  --line: rgba(255,255,255,.16);
  --line2: rgba(255,255,255,.32);
  --fg: #ececec;
  --fg2: #a9a9ae;
  --fg3: #6c6c73;
  --accent: #a9a3c4;      /* холодный серо-лиловый */
  --accent-dim: rgba(169,163,196,.35);
  --red: #e0444f;
  --red-dim: rgba(224,68,79,.22);
  --warn: #d7c48a;
  --pixel: "Pixelify", ui-monospace, monospace;
  --mono: "JBMono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 0px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { background: var(--bg); -webkit-text-size-adjust: 100%; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  background:
    radial-gradient(ellipse at 50% -20%, rgba(169,163,196,.07), transparent 60%),
    var(--bg);
  color: var(--fg);
  font-family: var(--mono);
  font-size: 14px;
  line-height: 1.4;
  overflow-x: hidden;
}
[hidden] { display: none !important; }
button, input { font: inherit; color: inherit; }
.pixel { image-rendering: pixelated; image-rendering: crisp-edges; }
.mono-dim { color: var(--fg3); font-family: var(--mono); font-size: 11px; letter-spacing: .08em; }

/* ---------- FX overlays ---------- */
.fx-scan, .fx-noise, .fx-sparks {
  position: fixed; inset: 0; pointer-events: none; z-index: 900;
}
.fx-scan {
  background: repeating-linear-gradient(to bottom,
    rgba(255,255,255,.025) 0, rgba(255,255,255,.025) 1px,
    transparent 1px, transparent 3px);
  mix-blend-mode: screen;
}
.fx-scan::after {
  content: ""; position: absolute; left: 0; right: 0; height: 120px; top: -120px;
  background: linear-gradient(to bottom, transparent, rgba(255,255,255,.035), transparent);
  animation: scanroll 9s linear infinite;
}
@keyframes scanroll { to { transform: translateY(calc(100vh + 240px)); } }
.fx-noise {
  opacity: .055;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='160' height='160'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 1 0'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
  animation: noise .6s steps(3) infinite;
}
@keyframes noise {
  0% { transform: translate(0,0); }
  33% { transform: translate(-12px,8px); }
  66% { transform: translate(9px,-11px); }
  100% { transform: translate(0,0); }
}
.fx-sparks { z-index: 1; }
.fx-sparks span {
  position: absolute; color: rgba(255,255,255,.28); font-size: 14px;
  animation: twinkle 4s ease-in-out infinite;
}
.fx-sparks span:nth-child(2n) { animation-delay: 1.3s; font-size: 10px; }
.fx-sparks span:nth-child(3n) { animation-delay: 2.6s; }
@keyframes twinkle { 0%,100% { opacity: .15; } 50% { opacity: .7; } }

/* ---------- glitch ---------- */
.logo {
  font-family: var(--pixel); font-weight: 700; letter-spacing: .14em;
  margin: 0; position: relative; display: inline-block; color: #fff;
}
.glitch::before, .glitch::after {
  content: attr(data-text); position: absolute; left: 0; top: 0; width: 100%;
  overflow: hidden; opacity: 0; pointer-events: none;
}
.glitch::before { color: #fff; text-shadow: -2px 0 rgba(255,60,80,.75); animation: glitchA 7s infinite steps(1); }
.glitch::after  { color: #fff; text-shadow:  2px 0 rgba(120,200,255,.7); animation: glitchB 7s infinite steps(1); }
@keyframes glitchA {
  0%, 91%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); transform: none; }
  92% { opacity: 1; clip-path: inset(10% 0 60% 0); transform: translate(-3px,0); }
  94% { opacity: 1; clip-path: inset(55% 0 20% 0); transform: translate(3px,0); }
  96% { opacity: 1; clip-path: inset(30% 0 45% 0); transform: translate(-2px,1px); }
  97% { opacity: 0; }
}
@keyframes glitchB {
  0%, 91%, 100% { opacity: 0; clip-path: inset(0 0 100% 0); transform: none; }
  92.5% { opacity: 1; clip-path: inset(65% 0 5% 0); transform: translate(3px,0); }
  95% { opacity: 1; clip-path: inset(5% 0 75% 0); transform: translate(-3px,0); }
  96.5% { opacity: 0; }
}

/* ---------- corners frame ---------- */
.corners { position: relative; border: 1px solid var(--line); background: rgba(12,12,15,.82); }
.corners::before, .corners::after {
  content: ""; position: absolute; width: 12px; height: 12px; pointer-events: none;
  border: 2px solid var(--fg);
}
.corners::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; }
.corners::after  { bottom: -3px; right: -3px; border-left: 0; border-top: 0; }
.corners > .c-tr, .corners > .c-bl {
  position: absolute; width: 12px; height: 12px; border: 2px solid var(--fg); pointer-events: none;
}
.corners > .c-tr { top: -3px; right: -3px; border-left: 0; border-bottom: 0; }
.corners > .c-bl { bottom: -3px; left: -3px; border-right: 0; border-top: 0; }

/* ---------- buttons / inputs ---------- */
.btn {
  min-height: 40px; padding: 8px 14px;
  background: transparent; border: 1px solid var(--line2); color: var(--fg);
  font-family: var(--pixel); font-weight: 600; letter-spacing: .1em; font-size: 13px;
  cursor: pointer; border-radius: var(--r); text-transform: uppercase;
  transition: background .12s, color .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.btn:hover { background: rgba(255,255,255,.08); border-color: var(--fg); }
.btn:active { background: #fff; color: #000; }
.btn:focus-visible, .input:focus-visible, .term-keys button:focus-visible {
  outline: 1px dashed var(--accent); outline-offset: 2px;
}
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-primary { background: #f2f2f2; color: #000; border-color: #f2f2f2; }
.btn-primary:hover { background: #fff; color: #000; }
.btn-ghost { border-color: var(--line); color: var(--fg2); }
.btn-danger { border-color: rgba(224,68,79,.7); color: #ff8a92; }
.btn-danger:hover { background: var(--red-dim); border-color: var(--red); }
.btn-danger:active { background: var(--red); color: #000; }
.btn-wide { width: 100%; }
.btn-sm { min-height: 36px; padding: 6px 10px; font-size: 12px; }

.input {
  width: 100%; min-height: 44px; padding: 10px 12px;
  background: #050506; border: 1px solid var(--line2); color: var(--fg);
  font-family: var(--mono); font-size: 16px; border-radius: var(--r);
}
.input:focus { border-color: var(--fg); outline: none; box-shadow: 0 0 0 1px var(--accent-dim); }
.lbl { display: block; font-family: var(--pixel); font-size: 12px; letter-spacing: .12em; color: var(--fg2); margin-bottom: 6px; }
.form-err { min-height: 1.4em; margin: 10px 0 0; color: #ff8a92; font-size: 13px; }

/* ---------- views ---------- */
.view { position: relative; z-index: 2; }
.view-boot { min-height: 100vh; display: flex; align-items: center; justify-content: center; }
.boot-text { font-family: var(--pixel); letter-spacing: .15em; color: var(--fg2); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- login ---------- */
.view-login {
  min-height: 100vh; min-height: 100dvh;
  display: flex; align-items: center; justify-content: center; padding: 24px 14px;
}
.login-box { width: 100%; max-width: 400px; padding: 22px 22px 18px; text-align: center; }
.login-top { display: flex; justify-content: space-between; margin-bottom: 8px; }
.login-sig { display: block; width: 100%; max-width: 260px; height: auto; margin: 4px auto 6px; }
.login-box .logo { font-size: 46px; line-height: 1; margin: 6px 0 4px; padding-left: .14em; }
.login-sub { margin: 4px 0 18px; font-family: var(--pixel); font-size: 12px; letter-spacing: .12em; color: var(--fg2); }
.login-form { text-align: left; }
.login-form .btn { margin-top: 12px; min-height: 46px; font-size: 15px; }
.login-bottom { margin-top: 8px; }

/* ---------- topbar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  background: rgba(6,6,7,.92); backdrop-filter: blur(4px);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-ico { width: 32px; height: 32px; border: 1px solid var(--line); }
.logo-sm { font-size: 24px; }
.clock {
  flex: 1 1 auto; display: flex; justify-content: center; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 13px;
}
.clock-lbl { font-family: var(--pixel); color: var(--fg3); letter-spacing: .12em; font-size: 11px; }
.clock-val { color: var(--fg); font-variant-numeric: tabular-nums; }
.clock-sep { color: var(--fg3); }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.conn { display: flex; align-items: center; gap: 8px; font-family: var(--pixel); font-size: 12px; letter-spacing: .12em; color: var(--fg2); white-space: nowrap; }
.conn-dot { width: 9px; height: 9px; background: var(--fg3); box-shadow: 0 0 0 1px rgba(255,255,255,.2); }
.conn[data-state="live"] .conn-dot { background: #fff; animation: pulse 2s infinite; }
.conn[data-state="live"] { color: var(--fg); }
.conn[data-state="connecting"] .conn-dot { background: var(--accent); animation: blink 1s steps(1) infinite; }
.conn[data-state="lost"] .conn-dot { background: var(--red); animation: blink .6s steps(1) infinite; }
.conn[data-state="lost"] { color: #ff8a92; }
.conn[data-state="paused"] .conn-dot { background: var(--fg3); }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 1px rgba(255,255,255,.3); } 50% { box-shadow: 0 0 0 4px rgba(255,255,255,.06); } }

.demo-banner {
  position: relative; z-index: 2;
  text-align: center; padding: 6px 10px; font-family: var(--pixel); font-size: 11px; letter-spacing: .12em;
  color: var(--accent); border-bottom: 1px dashed var(--accent-dim);
}

/* ---------- grid ---------- */
.grid {
  display: grid; gap: 22px; padding: 22px 18px 10px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 420px), 1fr));
  max-width: 1800px; margin: 0 auto; align-items: start;
}
.empty { grid-column: 1 / -1; text-align: center; color: var(--fg3); padding: 40px 0; font-family: var(--pixel); letter-spacing: .12em; }

/* ---------- node card ---------- */
.card { padding: 14px 14px 12px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card[data-alert="1"] { border-color: rgba(224,68,79,.45); }
.card[data-alert="1"]::before, .card[data-alert="1"]::after,
.card[data-alert="1"] > .c-tr, .card[data-alert="1"] > .c-bl { border-color: var(--red); }

.card-head { display: flex; gap: 12px; align-items: flex-start; min-width: 0; }
.avatar {
  flex: 0 0 auto; width: 84px; height: 84px; border: 1px solid var(--line); background: #000;
  position: relative; overflow: hidden;
}
.avatar img { width: 100%; height: 100%; display: block; }
.avatar::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: repeating-linear-gradient(to bottom, rgba(0,0,0,.18) 0 1px, transparent 1px 3px);
}
.head-main { flex: 1 1 auto; min-width: 0; }
.head-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-width: 0; }
.node-name {
  font-family: var(--pixel); font-weight: 700; font-size: 20px; letter-spacing: .06em; margin: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%;
}
.tag {
  font-family: var(--pixel); font-size: 10px; letter-spacing: .14em; padding: 2px 6px;
  border: 1px solid var(--line2); color: var(--fg2);
}
.tag-lock { border-color: var(--accent-dim); color: var(--accent); }
.status { display: inline-flex; align-items: center; gap: 6px; font-family: var(--pixel); font-size: 11px; letter-spacing: .14em; color: var(--fg2); }
.status::before { content: ""; width: 8px; height: 8px; background: var(--fg3); }
.status[data-s="online"] { color: var(--fg); }
.status[data-s="online"]::before { background: #fff; }
.status[data-s="connecting"] { color: var(--accent); }
.status[data-s="connecting"]::before { background: var(--accent); animation: blink 1s steps(1) infinite; }
.status[data-s="offline"] { color: #ff8a92; }
.status[data-s="offline"]::before { background: var(--red); }
.head-meta { margin-top: 6px; font-size: 11px; color: var(--fg3); line-height: 1.5; word-break: break-word; }
.head-meta b { color: var(--fg2); font-weight: 400; }

.layer-lbl { font-family: var(--mono); font-size: 10px; color: var(--fg3); letter-spacing: .1em; }

/* metric blocks */
.metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.blk { border: 1px solid var(--line); padding: 10px; min-width: 0; background: rgba(0,0,0,.25); }
.blk-wide { grid-column: 1 / -1; }
.blk-title {
  display: flex; justify-content: space-between; align-items: baseline; gap: 8px;
  font-family: var(--pixel); font-size: 12px; letter-spacing: .16em; color: var(--fg2); margin-bottom: 6px;
}
.blk-title .spark { color: var(--fg3); font-size: 10px; }
.big { font-family: var(--mono); font-size: 22px; line-height: 1.1; font-variant-numeric: tabular-nums; color: #fff; white-space: nowrap; }
.big small { font-size: 12px; color: var(--fg3); margin-left: 2px; }
.kv { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--fg2); font-variant-numeric: tabular-nums; flex-wrap: wrap; }
.kv span:last-child { color: var(--fg); text-align: right; }
.kv + .kv { margin-top: 2px; }
.sub { font-size: 11px; color: var(--fg3); margin-top: 4px; font-variant-numeric: tabular-nums; word-break: break-word; }
.hot { color: #ff8a92 !important; }

.bar { position: relative; height: 8px; margin: 7px 0 6px; border: 1px solid var(--line2); background:
  repeating-linear-gradient(90deg, transparent 0 7px, rgba(255,255,255,.06) 7px 8px); }
.bar > i { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: var(--fg); transition: width .5s steps(8); }
.bar[data-hot="1"] > i { background: var(--red); }
.bar[data-warn="1"] > i { background: var(--warn); }

.spark-cv { display: block; width: 100%; height: 42px; margin-top: 6px; border-top: 1px dashed rgba(255,255,255,.08); }
.cores { display: grid; grid-template-columns: repeat(auto-fill, minmax(14px, 1fr)); gap: 3px; margin-top: 6px; }
.core { height: 18px; border: 1px solid var(--line); position: relative; background: #050506; }
.core > i { position: absolute; left: 0; right: 0; bottom: 0; height: 0; background: var(--fg2); transition: height .5s steps(6); }
.core[data-hot="1"] > i { background: var(--red); }

.disk + .disk { margin-top: 8px; padding-top: 8px; border-top: 1px dashed rgba(255,255,255,.08); }
.disk-mount { font-family: var(--mono); color: var(--fg); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.net-now { display: flex; gap: 18px; flex-wrap: wrap; }
.net-now .big { font-size: 19px; }
.legend { display: flex; gap: 12px; font-size: 10px; color: var(--fg3); margin-top: 2px; }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 4px; }
.lg-rx { background: #fff; }
.lg-tx { background: var(--accent); }

/* status / locked placeholders */
.placeholder {
  border: 1px dashed var(--line2); padding: 16px 14px; text-align: center;
  display: flex; flex-direction: column; gap: 10px; align-items: center;
}
.ph-title { font-family: var(--pixel); font-size: 15px; letter-spacing: .16em; color: var(--fg); }
.ph-text { color: var(--fg2); font-size: 12px; max-width: 100%; word-break: break-word; }
.ph-err { color: #ff8a92; font-size: 12px; word-break: break-word; font-family: var(--mono); }
.unlock-form { display: flex; gap: 8px; width: 100%; max-width: 360px; }
.unlock-form .input { flex: 1 1 auto; min-width: 0; }
.unlock-form .btn { flex: 0 0 auto; }
.unlock-err { min-height: 1.2em; margin: 0; color: #ff8a92; font-size: 12px; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.actions .btn { flex: 1 1 auto; }
.actions:empty { display: none; }

/* ---------- footer ---------- */
.footer {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  padding: 24px 16px 30px; color: var(--fg2); font-family: var(--pixel); font-size: 11px; letter-spacing: .14em;
  text-align: left;
}
.footer-sig { width: 64px; height: 64px; opacity: .85; border: 1px solid var(--line); }

/* ---------- modal ---------- */
.modal-back {
  position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.78);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal { width: 100%; max-width: 440px; padding: 20px; background: #0a0a0c; max-height: calc(100vh - 32px); overflow: auto; }
.modal h2 { font-family: var(--pixel); font-size: 18px; letter-spacing: .14em; margin: 0 0 12px; }
.modal p { margin: 0 0 10px; color: var(--fg2); }
.modal p strong { color: #fff; font-weight: 400; }
.modal .warn {
  border: 1px solid rgba(224,68,79,.6); background: var(--red-dim); color: #ffc3c7;
  padding: 10px; margin: 10px 0; font-size: 13px;
}
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; flex-wrap: wrap; }
.modal .row .btn { flex: 1 1 130px; }

/* ---------- toasts ---------- */
.toasts {
  position: fixed; z-index: 1100; right: 14px; bottom: 14px; left: auto;
  display: flex; flex-direction: column; gap: 8px; max-width: min(380px, calc(100vw - 28px));
}
.toast {
  padding: 10px 14px; background: #0d0d10; border: 1px solid var(--line2); color: var(--fg);
  font-size: 13px; animation: toastin .2s steps(3); word-break: break-word;
}
.toast-err { border-color: var(--red); color: #ffc3c7; }
.toast-ok { border-color: var(--accent); }
@keyframes toastin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- terminal ---------- */
.term-overlay {
  position: fixed; inset: 0; z-index: 1000; background: #050505;
  display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.term-head {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px; border-bottom: 1px solid var(--line);
  flex-wrap: wrap; min-width: 0;
}
.term-title { font-family: var(--pixel); font-weight: 700; letter-spacing: .12em; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.term-status { font-family: var(--pixel); font-size: 11px; letter-spacing: .14em; color: var(--fg2); }
.term-status[data-state="ready"] { color: #fff; }
.term-status[data-state="closed"] { color: #ff8a92; }
.term-status[data-state="connecting"] { color: var(--accent); }
.term-spacer { flex: 1 1 auto; }
.term-wrap { flex: 1 1 auto; min-height: 0; padding: 6px 4px 4px 8px; position: relative; }
.term-host { width: 100%; height: 100%; }
.term-host .xterm { height: 100%; }
.term-host .xterm-viewport { background: #050505 !important; }
.term-keys {
  display: none; gap: 4px; padding: 6px; border-top: 1px solid var(--line);
  overflow-x: auto; -webkit-overflow-scrolling: touch; flex-wrap: nowrap;
}
.term-keys button {
  flex: 0 0 auto; min-width: 44px; min-height: 42px; padding: 0 10px;
  background: #0d0d10; border: 1px solid var(--line2); color: var(--fg);
  font-family: var(--mono); font-size: 14px; touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.term-keys button:active { background: #fff; color: #000; }
.term-keys button.mod[aria-pressed="true"] { background: var(--accent); color: #000; border-color: var(--accent); }
body.touch .term-keys { display: flex; }

/* ---------- responsive ---------- */
@media (max-width: 760px) {
  .topbar { padding: 8px 12px; gap: 8px; }
  .clock { order: 3; flex-basis: 100%; justify-content: space-between; font-size: 12px; gap: 6px; }
  .clock-sep { display: none; }
  .topbar-right { margin-left: auto; gap: 8px; }
  .brand-layer { display: none; }
  .grid { padding: 14px 10px 6px; gap: 16px; }
}
@media (max-width: 420px) {
  .metrics { grid-template-columns: 1fr; }
  .avatar { width: 66px; height: 66px; }
  .node-name { font-size: 17px; }
  .big { font-size: 20px; }
  .login-box { padding: 18px 14px 14px; }
  .login-box .logo { font-size: 40px; }
  .conn-text { font-size: 10px; }
  .footer { flex-direction: column; text-align: center; }
  .term-head .btn { flex: 1 1 auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important; transition: none !important;
  }
  .glitch::before, .glitch::after { display: none; }
  .fx-scan::after { display: none; }
}
