/* ============================================================== tokens === */
:root {
  --bg: #05070e;
  --panel: rgba(15, 20, 31, 0.65);
  --panel-solid: #0f141f;
  --border: #283548;
  --border-light: #3a4b61;
  --cyan: #00e5ff;
  --purple: #c050ff;
  --green: #00f076;
  --red: #ff2a6d;
  --orange: #ff9e00;
  --text: #9baec4;
  --hi: #f1f5f9;
  --mono: 'Fira Code', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --sans: 'Rajdhani', 'Segoe UI', system-ui, sans-serif;
  --r-sm: 8px;
  --r-md: 14px;
  --r-lg: 22px;
  --r-full: 999px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background-color: var(--bg);
  background-image: radial-gradient(rgba(0, 229, 255, 0.08) 1px, transparent 1px);
  background-size: 30px 30px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

::selection { background: var(--cyan); color: #000; }

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: var(--cyan); }

button { font-family: inherit; cursor: pointer; border: none; background: none; color: inherit; }
table { border-collapse: collapse; }

.mono { font-family: var(--mono); }
.hidden { display: none !important; }

/* ============================================================== shells === */
.glass {
  background: var(--panel);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(40, 53, 72, 0.8);
  box-shadow: 0 4px 24px -4px rgba(0, 0, 0, 0.5);
}

.scanlines { position: relative; overflow: hidden; }
.scanlines::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.15) 50%);
  background-size: 100% 3px;
  pointer-events: none;
  z-index: 3;
}

/* ================================================================= nav === */
.topbar {
  position: sticky;
  top: 12px;
  z-index: 40;
  width: 100%;
  max-width: 1800px;
  margin: 12px auto 24px;
  padding: 0 20px;
}
.topbar-inner {
  border-radius: var(--r-full);
  padding: 10px 22px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--panel-solid);
  border: 2px solid var(--cyan);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.25), inset 0 0 10px rgba(0, 229, 255, 0.05);
  display: grid; place-items: center;
  position: relative; overflow: hidden;
  flex-shrink: 0;
}
.brand-mark::before { content: ''; position: absolute; inset: 0; background: var(--cyan); opacity: 0.2; }
.brand-mark svg { position: relative; z-index: 1; }
.brand-name { font-size: 21px; font-weight: 700; letter-spacing: 0.06em; color: var(--hi); line-height: 1; }
.brand-name span { color: var(--cyan); font-weight: 300; }
.brand-sub { font-family: var(--mono); font-size: 10px; letter-spacing: 0.22em; margin-top: 4px; display: block; }

.status-cluster { display: flex; align-items: center; gap: 18px; }
.seg {
  display: flex; align-items: center; gap: 10px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 4px;
}
.seg-item {
  display: flex; align-items: center; gap: 8px;
  padding: 4px 13px;
  border-radius: var(--r-full);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.06em;
  white-space: nowrap;
}
.seg-item.live { background: rgba(0, 229, 255, 0.1); border: 1px solid rgba(0, 229, 255, 0.3); color: var(--cyan); }
.seg-item.down { background: rgba(255, 42, 109, 0.1); border: 1px solid rgba(255, 42, 109, 0.35); color: var(--red); }
.seg-item b { color: var(--hi); }

.pulse-dot { position: relative; width: 8px; height: 8px; flex-shrink: 0; }
.pulse-dot i, .pulse-dot em {
  position: absolute; inset: 0; border-radius: 50%; background: currentColor;
}
.pulse-dot i { animation: ping 1.6s cubic-bezier(0, 0, 0.2, 1) infinite; opacity: 0.75; }
@keyframes ping { 75%, 100% { transform: scale(2.2); opacity: 0; } }

.clock {
  font-family: var(--mono);
  font-size: 13px;
  border: 1px solid var(--border);
  padding: 8px 16px;
  border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; gap: 8px;
}
.clock b { color: var(--cyan); font-weight: 500; }

/* ================================================================ main === */
main { flex: 1; width: 100%; max-width: 1800px; margin: 0 auto; padding: 0 20px 48px; }

.page-head {
  display: flex; flex-wrap: wrap; gap: 16px;
  justify-content: space-between; align-items: flex-end;
  margin-bottom: 26px; padding: 0 6px;
}
.page-head h1 {
  margin: 0;
  font-size: 28px; font-weight: 700; letter-spacing: 0.03em;
  color: var(--hi);
  display: flex; align-items: center; gap: 12px;
}
.page-head h1 svg { color: var(--cyan); }
.page-sub { font-family: var(--mono); font-size: 13px; margin: 8px 0 0; display: flex; align-items: center; gap: 9px; }

.toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tb-btn {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.4);
  color: var(--text); padding: 9px 16px; border-radius: var(--r-full);
  transition: all 0.25s; display: flex; align-items: center; gap: 8px;
}
.tb-btn:hover { color: var(--hi); border-color: var(--border-light); }
.tb-btn.on { color: var(--cyan); border-color: rgba(0, 229, 255, 0.45); background: rgba(0, 229, 255, 0.1); }
.tb-search {
  font-family: var(--mono); font-size: 12px;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border);
  border-radius: var(--r-full); padding: 9px 18px; color: var(--hi); min-width: 200px; outline: none;
}
.tb-search:focus { border-color: rgba(0, 229, 255, 0.5); }
.tb-search::placeholder { color: rgba(155, 174, 196, 0.45); }

/* ================================================================ grid === */
.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(380px, 1fr));
  gap: 22px;
}
.grid.dense { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }

.card {
  border-radius: var(--r-lg);
  display: flex; flex-direction: column;
  overflow: hidden;
  cursor: pointer;
  border-top: 2px solid var(--border-light);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.35s, border-color 0.35s;
}
.card:hover {
  border-color: rgba(0, 229, 255, 0.5);
  box-shadow: 0 10px 30px -10px rgba(0, 229, 255, 0.18), inset 0 0 20px rgba(0, 229, 255, 0.05);
  transform: translateY(-4px);
}
.card:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }
.card.s-online { border-top-color: var(--green); }
.card.s-warning { border-top-color: var(--orange); }
.card.s-error { border-top-color: var(--red); }
.card.s-offline { border-top-color: var(--border-light); opacity: 0.62; }
.card.s-offline:hover { opacity: 1; }

.card-head {
  padding: 16px 18px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0.05), transparent);
  border-bottom: 1px solid rgba(40, 53, 72, 0.5);
}
.card-name { font-size: 17px; font-weight: 700; letter-spacing: 0.04em; color: var(--hi); display: block; }
.card-task {
  font-family: var(--mono); font-size: 11px; color: var(--purple);
  background: rgba(192, 80, 255, 0.1); padding: 2px 8px; border-radius: var(--r-sm);
  display: inline-block; margin-top: 6px;
}
.card-head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 8px; flex-shrink: 0; }
.card-os { opacity: 0.6; display: flex; }

.pill {
  font-family: var(--mono); font-size: 10px; font-weight: 700; letter-spacing: 0.16em;
  padding: 4px 10px; border-radius: var(--r-full); border: 1px solid; white-space: nowrap;
}
.pill.s-online { color: var(--green); border-color: var(--green); background: rgba(0, 240, 118, 0.1); }
.pill.s-warning { color: var(--orange); border-color: var(--orange); background: rgba(255, 158, 0, 0.1); }
.pill.s-error { color: var(--red); border-color: var(--red); background: rgba(255, 42, 109, 0.1); }
.pill.s-offline { color: var(--text); border-color: var(--border-light); background: rgba(0, 0, 0, 0.4); }

.card-body { display: flex; flex: 1; min-height: 148px; background: rgba(0, 0, 0, 0.2); }
.card-stats {
  flex: 1; padding: 16px 18px; display: flex; flex-direction: column; justify-content: space-between;
  border-right: 1px solid rgba(40, 53, 72, 0.5); min-width: 0;
}
.card-ip {
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.1em;
  background: rgba(0, 0, 0, 0.4); padding: 4px 8px; border-radius: var(--r-sm);
  width: fit-content; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.card-ip b { color: var(--hi); font-weight: 500; }
.card-bars { margin-top: auto; padding-top: 14px; display: flex; flex-direction: column; gap: 13px; }

.bar-row { display: flex; justify-content: space-between; font-family: var(--mono); font-size: 11px; margin-bottom: 5px; }
.bar-row b { font-weight: 700; }
.bar-track {
  width: 100%; height: 6px; background: #000;
  border: 1px solid rgba(40, 53, 72, 0.8); border-radius: var(--r-full); overflow: hidden;
}
.bar-fill { height: 100%; border-radius: var(--r-full); transition: width 0.4s ease, background-color 0.4s; }

.card-screen {
  width: 148px; flex-shrink: 0; background: #000; position: relative; overflow: hidden;
  display: grid; place-items: center;
}
.card-screen img { width: 100%; height: 100%; object-fit: cover; object-position: top left; display: block; }
.card-screen .noscreen {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.14em; text-align: center;
  color: rgba(155, 174, 196, 0.4); padding: 8px; line-height: 1.6;
}

.card-foot {
  padding: 10px 18px;
  border-top: 1px solid rgba(40, 53, 72, 0.5);
  background: rgba(0, 0, 0, 0.4);
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.08em;
}
.card-foot .net { display: flex; gap: 10px; }
.chip { display: flex; align-items: center; gap: 5px; padding: 2px 8px; border-radius: var(--r-sm); }
.chip.rx { color: var(--cyan); background: rgba(0, 229, 255, 0.1); }
.chip.tx { color: var(--purple); background: rgba(192, 80, 255, 0.1); }
.chip.rtt { background: rgba(0, 0, 0, 0.4); }
.chip.rtt.bad { color: var(--red); background: rgba(255, 42, 109, 0.1); }

.empty {
  grid-column: 1 / -1;
  border-radius: var(--r-lg); padding: 64px 32px; text-align: center;
  border: 1px dashed var(--border);
}
.empty h2 { color: var(--hi); font-size: 20px; margin: 0 0 10px; letter-spacing: 0.05em; }
.empty p { font-family: var(--mono); font-size: 13px; margin: 6px 0; line-height: 1.7; }
.empty code {
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--border);
  padding: 2px 8px; border-radius: 6px; color: var(--cyan);
}

/* =============================================================== modal === */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  background: rgba(2, 4, 9, 0.55);
  visibility: hidden; opacity: 0; backdrop-filter: blur(0);
  transition: opacity 0.35s ease, backdrop-filter 0.35s ease, visibility 0.35s;
}
.overlay.open { visibility: visible; opacity: 1; backdrop-filter: blur(8px); }

.modal {
  width: 100%; max-width: 1560px; height: 88vh;
  border-radius: var(--r-lg);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.6);
  transform: scale(0.94) translateY(12px);
  opacity: 0;
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1), opacity 0.3s ease;
}
.overlay.open .modal { transform: none; opacity: 1; }

.modal-head {
  padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center; gap: 16px;
  border-bottom: 1px solid rgba(40, 53, 72, 0.8);
  background: linear-gradient(to right, rgba(0, 0, 0, 0.6), transparent);
}
.modal-id { display: flex; align-items: center; gap: 16px; min-width: 0; }
.modal-icon {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border);
  display: grid; place-items: center; flex-shrink: 0;
}
.modal-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-title h2 { margin: 0; font-size: 23px; font-weight: 700; letter-spacing: 0.04em; color: var(--hi); }
.modal-meta {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  font-family: var(--mono); font-size: 12px; margin-top: 6px;
}
.modal-meta .sep { width: 4px; height: 4px; border-radius: 50%; background: var(--border-light); }
.modal-meta b { color: var(--hi); font-weight: 500; }
.modal-meta .os { color: var(--cyan); }
.modal-meta .task { color: var(--purple); background: rgba(192, 80, 255, 0.1); padding: 1px 8px; border-radius: 6px; }

.icon-btn {
  background: rgba(0, 0, 0, 0.4); padding: 11px; border-radius: 50%;
  color: var(--text); transition: all 0.25s; display: grid; place-items: center; flex-shrink: 0;
}
.icon-btn:hover { color: #fff; background: rgba(255, 42, 109, 0.8); box-shadow: 0 0 15px rgba(255, 42, 109, 0.35); }

.modal-body { flex: 1; display: flex; min-height: 0; background: rgba(0, 0, 0, 0.3); }
.modal-main {
  flex: 1; display: flex; flex-direction: column; gap: 14px;
  padding: 16px; border-right: 1px solid rgba(40, 53, 72, 0.5); min-width: 0;
}

.tabs {
  display: flex; gap: 2px; background: rgba(0, 0, 0, 0.6); padding: 5px;
  border-radius: var(--r-full); width: fit-content;
  border: 1px solid rgba(40, 53, 72, 0.5); flex-wrap: wrap;
}
.tab {
  padding: 8px 20px; border-radius: var(--r-full);
  font-size: 11px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase;
  color: var(--text); transition: all 0.25s; white-space: nowrap;
}
.tab:hover:not(.on):not(:disabled) { color: var(--hi); }
.tab.on { color: #000; background: var(--cyan); box-shadow: 0 0 15px rgba(0, 229, 255, 0.3); }
.tab:disabled { opacity: 0.32; cursor: not-allowed; }

.viewport {
  flex: 1; position: relative; overflow: hidden;
  border-radius: var(--r-md); border: 1px solid rgba(40, 53, 72, 0.8);
  background: #020202; min-height: 0;
}
.view { position: absolute; inset: 0; display: none; }
.view.on { display: flex; flex-direction: column; }

#view-screen { align-items: center; justify-content: center; background: #000; }
#view-screen img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
/* An Android preview is an input surface, not a picture. touch-action:none
   stops the browser eating drags as scroll gestures before they become swipes. */
#view-screen img.tappable { cursor: pointer; touch-action: none; }

.view-hint {
  position: absolute; inset: 0; display: grid; place-items: center;
  font-family: var(--mono); font-size: 12px; letter-spacing: 0.1em; text-align: center;
  color: var(--text); padding: 32px; line-height: 1.9; z-index: 4;
  background: rgba(2, 4, 9, 0.82);
}
.view-hint b { color: var(--hi); display: block; margin-bottom: 8px; font-size: 14px; letter-spacing: 0.14em; }
.view-hint code { color: var(--cyan); background: rgba(0, 0, 0, 0.6); padding: 2px 8px; border-radius: 6px; }
.view-hint button {
  margin-top: 18px; border: 1px solid rgba(0, 229, 255, 0.5); background: rgba(0, 229, 255, 0.1);
  color: var(--cyan); padding: 10px 22px; border-radius: var(--r-full);
  font-family: var(--mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase;
}
.view-hint button:hover { background: var(--cyan); color: #000; }

#view-shell { padding: 10px; background: #050505; }
#term-host { flex: 1; min-height: 0; }

#vnc-host { flex: 1; min-height: 0; background: #000; overflow: hidden; }

/* Zooming works by growing the host box and letting noVNC's own scaleViewport
   fit the framebuffer to it - the canvas stays noVNC's to size, so pointer
   coordinates keep mapping correctly. The view scrolls to pan. */
#view-control.zoomed { overflow: auto; }
#view-control.zoomed #vnc-host { flex: none; }

.zoombar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  z-index: 6; display: flex; align-items: center; gap: 4px;
  padding: 5px; border-radius: var(--r-full);
  background: rgba(0, 0, 0, 0.72); border: 1px solid rgba(40, 53, 72, 0.9);
  backdrop-filter: blur(6px);
  opacity: 0.35; transition: opacity 0.2s;
}
.zoombar:hover, .zoombar:focus-within { opacity: 1; }
.zoombar button {
  width: 34px; height: 30px; border-radius: var(--r-full);
  background: none; border: none; color: var(--text);
  font-size: 15px; font-weight: 700; line-height: 1; cursor: pointer;
  font-family: var(--mono);
}
.zoombar button:hover { color: var(--cyan); background: rgba(0, 229, 255, 0.12); }
.zoombar #zoom-fit { font-size: 10px; letter-spacing: 0.1em; }
.zoombar #zoom-pct {
  font-family: var(--mono); font-size: 10px; color: var(--cyan);
  min-width: 42px; text-align: center; letter-spacing: 0.06em;
}

/* A thumb needs a bigger target, and the bar must not hide behind a keyboard. */
@media (hover: none) {
  .zoombar { opacity: 1; bottom: 10px; }
  .zoombar button { width: 42px; height: 38px; font-size: 17px; }
}

.stream-badge {
  position: absolute; top: 10px; right: 12px; z-index: 5;
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.14em;
  background: rgba(0, 0, 0, 0.65); border: 1px solid var(--border);
  padding: 4px 10px; border-radius: var(--r-full);
  display: flex; align-items: center; gap: 7px; color: var(--cyan);
}

/* metrics + process views */
.view-pad { padding: 18px; gap: 18px; overflow: auto; }
.chart-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 900px) { .chart-grid { grid-template-columns: 1fr; } }

.chart-box {
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(40, 53, 72, 0.6);
  border-radius: var(--r-md); padding: 16px; display: flex; flex-direction: column; min-height: 168px;
}
.chart-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 12px; }
.chart-label { font-family: var(--mono); font-size: 11px; letter-spacing: 0.16em; display: flex; align-items: center; gap: 9px; }
.chart-label i { width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.chart-val { font-family: var(--mono); font-size: 19px; font-weight: 700; }
.chart-box canvas { flex: 1; width: 100%; min-height: 96px; display: block; }

.data-table { width: 100%; font-family: var(--mono); font-size: 12.5px; text-align: left; }
.data-table thead th {
  position: sticky; top: 0; background: #0a0d14; color: var(--text);
  font-weight: 500; padding: 11px 12px; letter-spacing: 0.08em; z-index: 1;
}
.data-table tbody td { padding: 9px 12px; color: var(--hi); border-top: 1px solid rgba(40, 53, 72, 0.3); }
.data-table tbody tr:hover { background: rgba(255, 255, 255, 0.04); }
.data-table .num { text-align: right; }

.panel-box {
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(40, 53, 72, 0.6);
  border-radius: var(--r-md); display: flex; flex-direction: column; overflow: hidden; min-height: 0;
}
.panel-box > header {
  padding: 13px 16px; border-bottom: 1px solid rgba(40, 53, 72, 0.5);
  background: rgba(15, 20, 31, 0.5);
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
}
.panel-box > header h3 { margin: 0; font-size: 14px; font-weight: 700; letter-spacing: 0.04em; color: var(--hi); }
.panel-box .scroll { overflow: auto; flex: 1; min-height: 0; }

.live-tag {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em;
  padding: 3px 9px; border-radius: var(--r-full);
  background: rgba(0, 229, 255, 0.15); color: var(--cyan);
  display: flex; align-items: center; gap: 7px;
}
.live-tag i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.state-ESTABLISHED { color: var(--green); }
.state-LISTEN { color: var(--cyan); }
.state-SYN_SENT, .state-SYN_RECV { color: var(--orange); }
.state-TIME_WAIT, .state-CLOSE_WAIT { color: var(--text); }

/* =============================================================== aside === */
.modal-aside {
  width: 360px; flex-shrink: 0; overflow-y: auto;
  padding: 18px; background: rgba(0, 0, 0, 0.2);
  display: flex; flex-direction: column; gap: 18px;
}
@media (max-width: 1100px) {
  /* Stacked layout: the whole body becomes one scrolling column.
     .modal-aside keeps flex-shrink:0 from the row layout, so once the axis
     turns vertical it claims its entire content height (~1500px), starves
     .modal-main, and collapses .viewport to 0 - which renders the live
     screen, remote and shell as nothing at all. Both children size to
     content and the body scrolls instead. */
  .modal-body { flex-direction: column; overflow-y: auto; }
  .modal-main { flex: none; border-right: none; }
  .modal-main .viewport { min-height: 46vh; }
  .modal-aside {
    width: 100%; flex: none; overflow-y: visible;
    border-top: 1px solid rgba(40, 53, 72, 0.5);
  }
  .modal { height: 94vh; }
}

.aside-box {
  background: rgba(0, 0, 0, 0.4); border: 1px solid rgba(40, 53, 72, 0.5);
  border-radius: var(--r-md); padding: 16px;
}
.aside-box h3 {
  margin: 0 0 14px; font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--text); font-weight: 500; display: flex; align-items: center; gap: 9px;
}
.spec { margin-bottom: 13px; font-family: var(--mono); }
.spec:last-child { margin-bottom: 0; }
.spec .k { font-size: 10px; letter-spacing: 0.1em; text-transform: uppercase; color: rgba(155, 174, 196, 0.7); display: block; margin-bottom: 3px; }
.spec .v { font-size: 12.5px; display: block; word-break: break-word; line-height: 1.5; }
.spec .v.cyan { color: var(--cyan); }
.spec .v.purple { color: var(--purple); }
.spec .v.green { color: var(--green); }
.spec .v.hi { color: var(--hi); }

.gauge { margin-bottom: 20px; }
.gauge:last-child { margin-bottom: 0; }
.gauge-head { display: flex; justify-content: space-between; align-items: flex-end; font-family: var(--mono); margin-bottom: 7px; }
.gauge-head .k { font-size: 11px; letter-spacing: 0.1em; }
.gauge-head .v { font-size: 17px; font-weight: 700; }
.gauge-track {
  width: 100%; height: 9px; background: #000;
  border: 1px solid rgba(40, 53, 72, 0.8); border-radius: var(--r-full); overflow: hidden;
}
.gauge-sub { font-family: var(--mono); font-size: 10px; margin-top: 5px; color: rgba(155, 174, 196, 0.65); }

.act { display: flex; flex-direction: column; gap: 10px; }
.act button {
  width: 100%; border-radius: var(--r-full); border: 1px solid var(--border);
  background: #000; color: var(--hi);
  padding: 12px 16px; font-family: var(--mono); font-size: 11px; font-weight: 700; letter-spacing: 0.12em;
  transition: all 0.25s; display: flex; align-items: center; justify-content: center; gap: 11px;
}
.act button:hover:not(:disabled) { background: rgba(255, 255, 255, 0.06); border-color: var(--text); }
.act button:disabled { opacity: 0.35; cursor: not-allowed; }
.act button.primary {
  border-color: rgba(0, 229, 255, 0.5); background: rgba(0, 229, 255, 0.1); color: var(--cyan);
  box-shadow: 0 0 15px rgba(0, 229, 255, 0.12);
}
.act button.primary:hover:not(:disabled) { background: var(--cyan); color: #000; box-shadow: 0 0 25px rgba(0, 229, 255, 0.45); }
.act button.danger { border-color: rgba(255, 42, 109, 0.4); background: rgba(255, 42, 109, 0.1); color: var(--red); }
.act button.danger:hover:not(:disabled) { background: var(--red); color: #fff; }
.act .row { display: flex; gap: 10px; }
.act input {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px;
  background: #000; border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 11px 16px; color: var(--hi); outline: none;
}
.act input:focus { border-color: rgba(0, 229, 255, 0.5); }

/* ============================================================== toasts === */
.toasts {
  position: fixed; bottom: 22px; right: 22px; z-index: 60;
  display: flex; flex-direction: column; gap: 11px; pointer-events: none; max-width: min(460px, 90vw);
}
.toast {
  border-radius: var(--r-md); padding: 13px 17px;
  font-family: var(--mono); font-size: 12px; line-height: 1.6;
  border-left: 3px solid var(--cyan); color: var(--hi);
  animation: slidein 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
  word-break: break-word; pointer-events: auto;
}
.toast.err { border-left-color: var(--red); }
.toast.ok { border-left-color: var(--green); }
.toast.warn { border-left-color: var(--orange); }
.toast b { display: block; letter-spacing: 0.1em; margin-bottom: 4px; font-size: 11px; text-transform: uppercase; color: var(--text); }
.toast pre { margin: 6px 0 0; white-space: pre-wrap; font-size: 11px; max-height: 180px; overflow: auto; color: var(--text); }
@keyframes slidein { from { transform: translateX(40px); opacity: 0; } }

/* ================================================================ gate === */
.gate { position: fixed; inset: 0; z-index: 70; display: grid; place-items: center; background: var(--bg); padding: 24px; }
.gate form { border-radius: var(--r-lg); padding: 38px; width: min(440px, 100%); text-align: center; }
.gate h1 { color: var(--hi); font-size: 24px; letter-spacing: 0.06em; margin: 18px 0 8px; }
.gate p { font-family: var(--mono); font-size: 12px; margin: 0 0 24px; line-height: 1.7; }
.gate input {
  width: 100%; font-family: var(--mono); font-size: 13px; text-align: center;
  background: #000; border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 13px 18px; color: var(--hi); outline: none; margin-bottom: 14px;
}
.gate input:focus { border-color: var(--cyan); }
.gate button {
  width: 100%; border: 1px solid rgba(0, 229, 255, 0.5); background: rgba(0, 229, 255, 0.1);
  color: var(--cyan); padding: 13px; border-radius: var(--r-full);
  font-family: var(--mono); font-size: 12px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
}
.gate button:hover { background: var(--cyan); color: #000; }
.gate .err { color: var(--red); min-height: 18px; margin-top: 14px; font-size: 11px; font-family: var(--mono); }

/* ============================================================ xterm fix === */
.xterm .xterm-viewport { background-color: transparent !important; }

/* ============================================================== mobile === */
@media (max-width: 720px) {
  body { font-size: 14px; }
  .topbar { top: 0; margin: 0 0 16px; padding: 10px 10px 0; }
  .topbar-inner { border-radius: var(--r-lg); padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
  .brand-mark { width: 34px; height: 34px; }
  .brand-name { font-size: 18px; }
  .status-cluster { width: 100%; justify-content: space-between; gap: 8px; }
  .seg { flex: 1; justify-content: space-between; overflow-x: auto; }
  .seg-item { padding: 4px 9px; font-size: 10px; }
  .clock { padding: 6px 11px; font-size: 12px; }

  main { padding: 0 12px 32px; }
  .page-head { margin-bottom: 18px; padding: 0; }
  .page-head h1 { font-size: 22px; }
  .toolbar { width: 100%; }
  .tb-search { flex: 1; min-width: 0; }

  .grid, .grid.dense { grid-template-columns: 1fr; gap: 14px; }
  .card-screen { width: 112px; }

  /* Full-bleed modal: a phone has no room for a floating dialog. */
  .overlay { padding: 0; }
  .modal { height: 100dvh; max-width: none; border-radius: 0; }
  /* A backdrop-filter inside another backdrop-filter (.overlay.open) does not
     sample reliably, and at full-bleed there is nothing beside the modal to
     read as a dialog - the grid just shows through it. Opaque on phones. */
  .modal.glass {
    background: #080c14;
    backdrop-filter: none; -webkit-backdrop-filter: none;
    border: none;
  }
  .modal-main .viewport { min-height: 40vh; }
  .modal-head { padding: 12px 14px; }
  .modal-icon { width: 40px; height: 40px; }
  .modal-title h2 { font-size: 19px; }
  .modal-meta { font-size: 11px; gap: 8px; }
  .modal-main { padding: 12px; gap: 10px; }
  .tabs { width: 100%; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; }
  .tab { padding: 8px 14px; font-size: 10px; }
  .modal-aside { width: 100%; padding: 14px; }
  .chart-grid { grid-template-columns: 1fr; }
  .data-table { font-size: 11.5px; }
  .data-table thead th, .data-table tbody td { padding: 8px 9px; }
  .toasts { left: 12px; right: 12px; bottom: 12px; max-width: none; }
}

/* Touch targets: a 2px border is not grabbable with a thumb. */
@media (hover: none) {
  .card:hover { transform: none; }
  .act button { padding: 14px 16px; }
  .tab { padding: 10px 18px; }
}

/* ======================================================= section heads === */
.sec-head {
  display: flex; align-items: center; gap: 11px;
  margin: 30px 0 14px;
}
#pc-section .sec-head { margin-top: 0; }
.sec-head h2 {
  margin: 0; display: flex; align-items: center; gap: 9px;
  font-size: 13px; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--text);
}
.sec-head h2 svg { color: var(--cyan); }
.sec-count {
  font-family: var(--mono); font-size: 10px; color: var(--cyan);
  border: 1px solid rgba(0, 229, 255, 0.3); background: rgba(0, 229, 255, 0.08);
  border-radius: var(--r-full); padding: 2px 9px;
}
/* A rule running to the right edge keeps the three groups visually distinct
   without adding another boxed container around each grid. */
.sec-head::after {
  content: ''; flex: 1; height: 1px;
  background: linear-gradient(90deg, rgba(40, 53, 72, 0.9), transparent);
}

/* ========================================================= phone cards === */
.card-batt .bar-fill { background: var(--green); }
.card-batt.low .bar-fill { background: var(--red); }
.card-batt.mid .bar-fill { background: var(--amber, #ffb300); }
.card-where {
  font-family: var(--mono); font-size: 10.5px; color: var(--text);
  margin-top: 7px; display: flex; align-items: center; gap: 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-where b { color: var(--cyan); font-weight: 500; }

/* ==================================================== network devices === */
.devgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }

.dev {
  border-radius: var(--r-md);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  border-left: 2px solid var(--border-light);
  transition: border-color 0.25s, background 0.25s;
}
.dev.off { opacity: 0.45; }
.dev:hover { border-left-color: var(--cyan); }
.dev-icon {
  width: 34px; height: 34px; flex-shrink: 0;
  border-radius: 9px; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--border);
  color: var(--text);
}
.dev-body { min-width: 0; flex: 1; }
.dev-name {
  font-size: 14px; font-weight: 600; color: var(--hi);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dev-meta {
  font-family: var(--mono); font-size: 10.5px; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px;
}
.dev-ports {
  font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.06em;
  color: var(--cyan); margin-top: 3px;
}
.dev-tag {
  font-family: var(--mono); font-size: 9px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 2px 7px; border-radius: var(--r-full);
  border: 1px solid var(--border); color: var(--text); flex-shrink: 0;
}
.dev.k-router   { border-left-color: var(--orange); }
.dev.k-computer { border-left-color: var(--cyan); }
.dev.k-phone    { border-left-color: var(--purple); }
.dev.k-media    { border-left-color: var(--green); }
.dev.k-console  { border-left-color: var(--purple); }
.dev.k-printer  { border-left-color: var(--text); }
.dev.k-smart-home { border-left-color: var(--green); }
.dev.k-camera   { border-left-color: var(--orange); }
.dev-hint {
  font-family: var(--mono); font-size: 9.5px; color: var(--green);
  margin-top: 3px; cursor: pointer; text-decoration: underline dotted;
}

/* ====================================================== notifications === */
.bell {
  position: relative; width: 38px; height: 38px; flex-shrink: 0;
  border-radius: 50%; display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.4); border: 1px solid var(--border);
  color: var(--text); transition: all 0.25s;
}
.bell:hover { color: var(--cyan); border-color: rgba(0, 229, 255, 0.45); }
.bell.ring { color: var(--cyan); border-color: var(--cyan); animation: bell-ring 0.6s ease; }
@keyframes bell-ring {
  0%, 100% { transform: rotate(0); }
  20% { transform: rotate(14deg); } 40% { transform: rotate(-11deg); }
  60% { transform: rotate(7deg); }  80% { transform: rotate(-5deg); }
}
.bell-badge {
  position: absolute; top: -3px; right: -3px; min-width: 17px; height: 17px;
  padding: 0 4px; border-radius: 9px;
  background: var(--red); color: #fff;
  font-family: var(--mono); font-size: 10px; font-weight: 700;
  display: grid; place-items: center;
  box-shadow: 0 0 10px rgba(255, 42, 109, 0.55);
}

.notif-scrim {
  position: fixed; inset: 0; z-index: 55;
  background: rgba(2, 4, 9, 0.5); backdrop-filter: blur(3px);
  opacity: 0; visibility: hidden; transition: opacity 0.3s, visibility 0.3s;
}
.notif-scrim.open { opacity: 1; visibility: visible; }

.notif {
  position: fixed; top: 0; right: 0; bottom: 0; z-index: 56;
  width: min(460px, 100vw);
  display: flex; flex-direction: column;
  border-left: 1px solid var(--border);
  transform: translateX(102%);
  transition: transform 0.38s cubic-bezier(0.32, 0.9, 0.35, 1);
}
.notif.open { transform: none; }

.notif-head {
  padding: 18px 18px 14px;
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  border-bottom: 1px solid rgba(40, 53, 72, 0.7);
}
.notif-head h2 { margin: 0; font-size: 19px; letter-spacing: 0.05em; color: var(--hi); }
.notif-sub { font-size: 11px; display: block; margin-top: 4px; }
.notif-actions { display: flex; align-items: center; gap: 8px; }
.notif-actions .tb-btn { padding: 7px 13px; }

.notif-filters {
  display: flex; gap: 6px; padding: 12px 18px;
  border-bottom: 1px solid rgba(40, 53, 72, 0.5);
}
.nf {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase;
  padding: 6px 13px; border-radius: var(--r-full);
  border: 1px solid var(--border); background: rgba(0, 0, 0, 0.35); color: var(--text);
  transition: all 0.2s;
}
.nf:hover { color: var(--hi); }
.nf.on { color: var(--cyan); border-color: rgba(0, 229, 255, 0.5); background: rgba(0, 229, 255, 0.1); }

.notif-list { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 9px; }

.nitem {
  border-radius: var(--r-md); padding: 12px 14px;
  background: rgba(0, 0, 0, 0.36);
  border: 1px solid rgba(40, 53, 72, 0.55);
  border-left: 3px solid var(--border-light);
}
.nitem.k-ok   { border-left-color: var(--green); }
.nitem.k-err  { border-left-color: var(--red); }
.nitem.k-warn { border-left-color: var(--orange); }
.nitem.k-info { border-left-color: var(--cyan); }
.nitem.unread { background: rgba(0, 229, 255, 0.05); }

.nitem-top { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.nitem-title { font-size: 13.5px; font-weight: 600; color: var(--hi); }
.nitem-time { font-family: var(--mono); font-size: 10px; color: rgba(155, 174, 196, 0.65); flex-shrink: 0; }
.nitem-node {
  font-family: var(--mono); font-size: 10px; color: var(--purple);
  background: rgba(192, 80, 255, 0.12); padding: 1px 7px; border-radius: var(--r-full);
  display: inline-block; margin-top: 6px;
}
.nitem-body {
  margin: 8px 0 0; font-family: var(--mono); font-size: 11px; line-height: 1.65;
  color: var(--text); white-space: pre-wrap; word-break: break-word;
  max-height: 190px; overflow: auto;
  background: rgba(0, 0, 0, 0.4); border-radius: var(--r-sm); padding: 9px 11px;
}
.nitem-more {
  font-family: var(--mono); font-size: 10px; color: var(--cyan);
  margin-top: 7px; cursor: pointer; text-decoration: underline dotted;
}
.notif-empty {
  text-align: center; padding: 48px 20px;
  font-family: var(--mono); font-size: 12px; color: rgba(155, 174, 196, 0.55); line-height: 1.8;
}

@media (max-width: 720px) {
  .notif { width: 100vw; }
  .bell { width: 34px; height: 34px; }
}

/* ================================================== device detail view === */
.devmodal { max-width: 660px; height: auto; max-height: 88vh; }
.devmodal-body {
  padding: 18px; display: flex; flex-direction: column; gap: 16px;
  overflow-y: auto; background: rgba(0, 0, 0, 0.3);
}
.devmodal-body .panel-box { max-height: 280px; }
.devmodal .dev-hintbox {
  font-family: var(--mono); font-size: 11px; line-height: 1.7;
  background: rgba(0, 0, 0, 0.45); border: 1px solid var(--border);
  border-radius: var(--r-sm); padding: 11px 13px; color: var(--text);
  word-break: break-all; margin-top: 4px;
}
.devmodal .dev-hintbox b { color: var(--cyan); display: block; margin-bottom: 5px; }
.dev { cursor: pointer; }
.dev:focus-visible { outline: 2px solid var(--cyan); outline-offset: 2px; }

.act select {
  flex: 1; min-width: 0; font-family: var(--mono); font-size: 12px;
  background: #000; border: 1px solid var(--border); border-radius: var(--r-full);
  padding: 11px 16px; color: var(--hi); outline: none; cursor: pointer;
}
.act select:focus { border-color: rgba(0, 229, 255, 0.5); }
.name-edit {
  background: none; border: none; color: var(--text); cursor: pointer;
  padding: 2px 5px; border-radius: 5px; font-size: 12px; line-height: 1;
}
.name-edit:hover { color: var(--cyan); background: rgba(0, 229, 255, 0.1); }
.renamed-dot {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--cyan); margin-left: 6px; vertical-align: middle;
}

.card.s-setup { border-top-color: var(--purple); opacity: 0.85; }
.pill.s-setup { color: var(--purple); border-color: var(--purple); background: rgba(192, 80, 255, 0.12); }

/* =================================================== fullscreen remote === */
.fs-btn {
  position: absolute; top: 10px; left: 12px; z-index: 6;
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  background: rgba(0, 0, 0, 0.62); border: 1px solid var(--border);
  color: var(--text); opacity: 0; transition: opacity 0.2s, color 0.2s, border-color 0.2s;
}
.viewport:hover .fs-btn, .fs-btn:focus-visible { opacity: 1; }
.fs-btn:hover { color: var(--cyan); border-color: rgba(0, 229, 255, 0.5); }
/* Two controls share the corner; the pause button sits inboard of fullscreen. */
#btn-live { left: 52px; }
/* Paused is a state worth seeing without hovering to find the button. */
#btn-live.paused { opacity: 1; color: var(--amber, #ffb300); border-color: rgba(255, 179, 0, 0.55); }
@media (hover: none) {
  .fs-btn { opacity: 1; width: 38px; height: 38px; }
  #btn-live { left: 58px; }
}

/* In fullscreen the viewport is the whole screen; let the content fill it. */
.viewport:fullscreen { border-radius: 0; border: 0; background: #000; }
.viewport:fullscreen .fs-btn { opacity: 0; }
.viewport:fullscreen:hover .fs-btn { opacity: 1; }
.viewport:fullscreen #view-screen img { max-width: 100vw; max-height: 100vh; }
.viewport:fullscreen #vnc-host { width: 100vw; height: 100vh; }
.viewport:fullscreen .view { inset: 0; }

/* OS mark stands in for the screen when there is no live frame. */
.card-screen .noscreen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 9px; width: 100%; height: 100%;
}
.card-screen .os-mark { opacity: 0.3; display: flex; line-height: 0; }
.card-screen .os-label {
  font-family: var(--mono); font-size: 8.5px; letter-spacing: 0.16em;
  color: rgba(155, 174, 196, 0.45); text-align: center; padding: 0 6px;
}
