:root {
  --bg: #08090d;
  --panel: #0e1016;
  --panel-2: #11141c;
  --stage: #05060a;
  --ink: #e9edf5;
  --dim: #8b97ab;
  --faint: #576174;
  --line: #1a2030;
  --line-bright: #2b3548;
  --accent: #3b82f6;
  --accent-dim: #1d3f7a;
  --live: #37d39b;
  --warn: #f0a132;
  --dead: #e8484f;
  --sans: 'Exo', 'Segoe UI Variable', 'Segoe UI', sans-serif;
  --mono: 'Roboto Mono', 'Cascadia Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 13px;
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent-dim); color: #fff; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #1b2231; border: 2px solid var(--bg); }
::-webkit-scrollbar-thumb:hover { background: var(--line-bright); }

.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }

/* ---------------- shell ---------------- */

.app {
  height: 100dvh;
  display: grid;
  grid-template-columns: 264px minmax(0, 1fr) 312px;
  grid-template-rows: 52px minmax(0, 1fr) 26px;
  grid-template-areas:
    "top  top   top"
    "rail stage insp"
    "stat stat  stat";
}

/* ---------------- top ---------------- */

.top {
  grid-area: top;
  position: relative;
  display: flex;
  align-items: center;
  gap: 28px;
  padding: 0 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 9px; min-width: 236px; }
.mark { width: 19px; height: 19px; fill: none; stroke: var(--accent); stroke-width: 1.5; }
.brand-text { display: flex; flex-direction: column; line-height: 1; }
.word { font-size: 14px; font-weight: 600; letter-spacing: .26em; }
.sub { margin-top: 3px; font-size: 8px; letter-spacing: .22em; text-transform: uppercase; color: var(--faint); }

.top-mid { display: flex; align-items: center; gap: 26px; flex: 1; min-width: 0; }
.stat { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.stat .k { font-size: 9px; letter-spacing: .16em; text-transform: uppercase; color: var(--faint); }
.stat .v {
  font-family: var(--mono);
  font-size: 11px;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
}
.stat .v.on { color: var(--ink); }

.top-right { display: flex; align-items: center; gap: 12px; }
.clock { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: .06em; }

.dot { width: 6px; height: 6px; border-radius: 50%; background: var(--faint); box-shadow: none; }
.dot.on { background: var(--live); animation: pulse 2.4s ease-in-out infinite; }
.dot.off { background: var(--dead); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.lease { position: absolute; left: 0; right: 0; bottom: -1px; height: 1px; background: transparent; }
.lease i {
  display: block; height: 1px; width: 100%;
  background: var(--live);
  transform: scaleX(var(--lease, 0));
  transform-origin: left;
  transition: transform .3s linear, background .3s linear;
}

/* ---------------- rail ---------------- */

.rail {
  grid-area: rail;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--panel);
  border-right: 1px solid var(--line);
}

.rail-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 34px; padding: 0 12px;
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint);
  border-bottom: 1px solid var(--line);
}

.badge {
  font-family: var(--mono); font-size: 10px; letter-spacing: 0;
  color: var(--dim); border: 1px solid var(--line); padding: 1px 5px;
}

.agents { flex: 1; overflow-y: auto; min-height: 0; }

.agent {
  position: relative;
  display: grid;
  grid-template-columns: 8px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  width: 100%;
  height: 46px;
  padding: 0 12px;
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.agent:hover { background: #12151d; }
.agent:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
.agent.active { background: #10141d; }
.agent.active::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; background: var(--accent);
}
.agent .sd { width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
.agent.offline .sd { background: var(--faint); }
.agent .who { min-width: 0; }
.agent .host {
  display: block; font-size: 12px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.agent .ip { display: block; margin-top: 2px; font-family: var(--mono); font-size: 10px; color: var(--faint); }
.agent .metrics { text-align: right; font-family: var(--mono); font-size: 10px; color: var(--dim); line-height: 1.35; }
.agent .metrics b { font-weight: 500; color: var(--ink); }

.rail-foot { border-top: 1px solid var(--line); padding: 9px 12px; }
.hint { font-family: var(--mono); font-size: 10px; color: var(--dim); line-height: 1.7; }
.hint b { color: var(--ink); font-weight: 500; }

.rail-empty { padding: 18px 12px; font-family: var(--mono); font-size: 10px; line-height: 1.8; color: var(--faint); }

/* ---------------- stage ---------------- */

.stage {
  grid-area: stage;
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0; min-height: 0;
  overflow: hidden;
  background-color: var(--stage);
  background-image:
    linear-gradient(rgba(58, 80, 120, .055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(58, 80, 120, .055) 1px, transparent 1px);
  background-size: 48px 48px;
}

#screen {
  max-width: 100%;
  max-height: 100%;
  display: block;
  outline: none;
  cursor: crosshair;
  box-shadow: 0 0 0 1px #131a26, 0 18px 60px rgba(0, 0, 0, .55);
}
#screen.hidden { display: none; }

.stage.armed::after {
  content: "";
  position: absolute; inset: 0;
  border: 1px solid var(--accent);
  pointer-events: none;
  opacity: .65;
}

.empty {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 7px;
  pointer-events: none;
  text-align: center;
}
.empty svg { width: 30px; height: 30px; fill: none; stroke: var(--line-bright); stroke-width: 1.2; margin-bottom: 6px; }
.empty-title { font-size: 10px; letter-spacing: .24em; text-transform: uppercase; color: var(--dim); }
.empty-sub { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.empty-sub b { color: var(--dim); font-weight: 500; }

.hud {
  position: absolute;
  display: flex; align-items: center; gap: 12px;
  padding: 4px 8px;
  background: rgba(7, 9, 13, .78);
  border: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  pointer-events: none;
  backdrop-filter: blur(2px);
}
.hud.tl { top: 12px; left: 12px; }
.hud.tr { top: 12px; right: 12px; }
.hud.bl { bottom: 12px; left: 12px; transition: color .2s, border-color .2s; }
.hud.br { bottom: 12px; right: 12px; padding: 3px; gap: 3px; pointer-events: auto; }
.stage.armed .hud.bl { color: var(--ink); border-color: var(--accent-dim); }

.live { display: inline-flex; align-items: center; gap: 6px; text-transform: uppercase; letter-spacing: .14em; font-size: 9px; }
.live::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; }
.live.on { color: var(--live); }
.live.quiet { color: var(--dim); }
.live.stale { color: var(--warn); }
.live.off { color: var(--faint); }

/* ---------------- inspector ---------------- */

.inspector {
  grid-area: insp;
  display: flex;
  flex-direction: column;
  min-height: 0;
  /* the launcher pane made the column taller than the viewport: without this
     the stream pane (restore / quit) is clipped out of sight */
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  background: var(--panel);
  border-left: 1px solid var(--line);
}

.pane { border-bottom: 1px solid var(--line); }
.pane-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 32px; padding: 0 12px;
  border-bottom: 1px solid transparent;
}
/* auteur-allow: EYEBROW_EVERYWHERE -- the tracked micro-label is this
   console's brand system (pane heads, HUD, gate), not section kickers */
.label { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }

.clip-meta { display: flex; justify-content: space-between; padding: 0 12px 6px; font-size: 10px; }

#clip-text {
  display: block;
  width: calc(100% - 24px);
  height: 84px;
  margin: 0 12px;
  padding: 8px;
  resize: none;
  background: #0a0c12;
  border: 1px solid var(--line);
  border-radius: 2px;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.5;
  outline: none;
}
#clip-text:focus { border-color: var(--accent-dim); }
#clip-text::placeholder { color: var(--faint); }

.row { display: flex; gap: 6px; padding: 8px 12px 12px; }
.row.four > button { flex: 1; }

/* ---------------- controls ---------------- */

button {
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: lowercase;
  color: var(--ink);
  height: 28px;
  padding: 0 10px;
  background: #12151d;
  border: 1px solid var(--line);
  border-radius: 2px;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, color .15s ease;
}
button:hover { border-color: var(--line-bright); background: #161a24; }
button:active { transform: translateY(1px); }
button:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }
button:disabled { opacity: .38; cursor: not-allowed; }
button:disabled:hover { border-color: var(--line); background: #12151d; }

button.ghost { background: transparent; border-color: transparent; color: var(--dim); }
button.ghost:hover { border-color: var(--line); color: var(--ink); background: #12151d; }
button.tiny { height: 20px; padding: 0 6px; font-size: 9px; }

button.wide { display: block; width: calc(100% - 24px); margin: 4px 12px 12px; }
button.danger { color: var(--dead); border-color: #3a1f24; }
button.danger:hover { border-color: var(--dead); background: #1a1013; }
button.danger[data-armed="1"] { background: var(--dead); border-color: var(--dead); color: #0b0c10; }

button svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

.launch-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1px;
  padding: 0 12px 12px;
}
.launch-grid button {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  height: 52px;
  padding: 0;
  background: #0d1016;
  border-color: var(--line);
  color: var(--dim);
}
.launch-grid button span { font-size: 9px; letter-spacing: .1em; }
.launch-grid button:hover { color: var(--ink); border-color: var(--accent-dim); background: #10141d; }

/* sliders */

.slider { display: block; padding: 4px 12px 10px; }
.slider-top { display: flex; justify-content: space-between; align-items: baseline; font-size: 10px; color: var(--dim); margin-bottom: 6px; }
.slider-top b { font-size: 10px; color: var(--ink); font-weight: 500; }

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 14px;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  background: var(--line-bright);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 9px; height: 13px;
  margin-top: -5.5px;
  background: var(--accent);
  border: 0;
  border-radius: 1px;
}
input[type="range"]:focus-visible { outline: 1px solid var(--accent); outline-offset: 3px; }

.check {
  display: flex; align-items: center; gap: 8px;
  padding: 2px 12px 10px;
  font-size: 10.5px; color: var(--dim); cursor: pointer;
}
.check input { accent-color: var(--accent); width: 12px; height: 12px; }

.switch { position: relative; display: inline-block; width: 28px; height: 14px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch i {
  position: absolute; inset: 0;
  background: #0b0e14;
  border: 1px solid var(--line-bright);
  border-radius: 8px;
  transition: border-color .15s ease, background .15s ease;
}
.switch i::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--faint);
  transition: transform .16s ease, background .16s ease;
}
.switch input:checked + i { border-color: var(--accent-dim); background: #0e1626; }
.switch input:checked + i::after { transform: translateX(14px); background: var(--accent); }
.switch input:focus-visible + i { outline: 1px solid var(--accent); outline-offset: 2px; }

/* ---------------- log ---------------- */

.log-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; border-bottom: 0; }
.log {
  flex: 1;
  min-height: 90px;
  overflow-y: auto;
  padding: 4px 12px 12px;
  font-family: var(--mono);
  font-size: 10px;
  line-height: 1.65;
  color: var(--dim);
}
.log div { white-space: pre-wrap; overflow-wrap: anywhere; }
.log .t { color: var(--faint); }
.log .hi { color: var(--ink); }
.log .err { color: var(--dead); }

/* ---------------- status ---------------- */

.status {
  grid-area: stat;
  display: flex; align-items: center; gap: 18px;
  padding: 0 12px;
  background: var(--panel);
  border-top: 1px solid var(--line);
  font-size: 10px;
  color: var(--dim);
}
.status .spacer { flex: 1; }
.status .mono { font-size: 10px; }

/* ---------------- toast ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 44px;
  transform: translate(-50%, 8px);
  padding: 7px 12px;
  background: #0f131b;
  border: 1px solid var(--line-bright);
  border-left: 2px solid var(--accent);
  font-family: var(--mono);
  font-size: 10.5px;
  color: var(--ink);
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
  z-index: 50;
  max-width: 70vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { border-left-color: var(--dead); }

/* ---------------- responsive ---------------- */

@media (max-width: 1180px) {
  .app { grid-template-columns: 224px minmax(0, 1fr) 284px; }
  .brand { min-width: 196px; }
  .top-mid { gap: 18px; }
}

@media (max-width: 980px) {
  body { overflow: auto; }
  .app {
    height: auto;
    min-height: 100dvh;
    grid-template-columns: 1fr;
    grid-template-rows: 52px auto minmax(52vh, 1fr) auto 26px;
    grid-template-areas: "top" "rail" "stage" "insp" "stat";
  }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .agents { display: flex; overflow-x: auto; }
  .agent { min-width: 220px; border-right: 1px solid var(--line); border-bottom: 0; }
  .rail-foot { display: none; }
  .inspector { border-left: 0; border-top: 1px solid var(--line); }
  .brand { min-width: 0; }
  .stat:nth-child(3) { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* clipboard pane: two switches (pull/push), one viewer, no button row */
.clip-hint {
  padding: 6px 2px 0;
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--dim);
}
#clip-text[readonly] { cursor: default; }

/* launcher: the fixed grid plus everything the Start menu has */
.app-list {
  max-height: 120px;
  overflow-y: auto;
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
}
.app-list:empty { display: none; }
.app-item {
  display: block;
  width: 100%;
  padding: 4px 8px;
  border: 0;
  background: none;
  color: var(--foreground);
  font: 11px/1.4 var(--mono, monospace);
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.app-item:hover { background: color-mix(in srgb, var(--accent) 18%, transparent); }
.app-item.msix { color: var(--dim); cursor: not-allowed; }
.app-item.msix:hover { background: none; }
#app-filter, #run-cmd {
  flex: 1;
  min-width: 0;
  padding: 5px 7px;
  border: 1px solid var(--border);
  border-radius: 3px;
  background: transparent;
  color: var(--foreground);
  font: 11px var(--mono, monospace);
}
#app-filter:focus, #run-cmd:focus { outline: 1px solid var(--accent); }

/* the two destructive actions stay reachable no matter how tall the column gets */
.pane-actions {
  /* direct child of the scrolling inspector, so sticky pins to the visible
     bottom edge instead of to the bottom of a pane that is already off-screen */
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 10px;
  background: linear-gradient(to bottom, transparent, var(--panel) 30%);
}

/* main-desktop view toggle: lit while the stream shows the victim's real
   desktop — impossible to miss next to the restore button */
#desk.hot {
  border-color: var(--accent);
  color: var(--accent);
}


/* ---------------- gate: welcome + login ---------------- */
/* Same motion language as the console: slow fades, thin accent strokes,
   no bounce. The welcome plays first, the login card rises after it. */

.gate {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center;
  transition: opacity .7s ease, visibility .7s;
}
.gate.hide { opacity: 0; visibility: hidden; pointer-events: none; }

.gate-veil {
  position: absolute; inset: 0;
  background:
    radial-gradient(1100px 520px at 50% 38%, rgba(59,130,246,.08), transparent 62%),
    var(--bg);
}

.gate-center {
  position: relative; display: flex; flex-direction: column;
  align-items: center; gap: 14px;
}

.gate-mark { width: 54px; height: 54px; fill: none; stroke: var(--accent);
  stroke-width: 1.4; stroke-linecap: round; stroke-linejoin: round; }

/* Progressive motion: the STATIC state is the correct state. Animations
   decorate it from a hidden start (fill: backwards) — with animations off
   (prefers-reduced-motion) everything stays fully visible instead of
   vanishing behind a keyframe that never runs. */

.gate-mark .draw {
  stroke-dasharray: 90; stroke-dashoffset: 0;
  animation: draw 1.5s cubic-bezier(.22,.61,.36,1) backwards;
}
.gate-mark .draw.d2 { animation-delay: .75s; }

@keyframes draw { from { stroke-dashoffset: 90; } to { stroke-dashoffset: 0; } }

.gate-word {
  font-size: 15px; font-weight: 600; letter-spacing: .42em;
  text-indent: .42em; color: var(--ink);
  animation: rise 1.1s ease .9s backwards;
}

.gate-welcome {
  font-size: 10.5px; letter-spacing: .5em; text-indent: .5em;
  text-transform: uppercase; color: var(--dim);
  animation: rise 1.6s ease 1.6s backwards;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}

.login-card {
  margin-top: 30px; width: 312px;
  border: 1px solid var(--line); border-radius: 2px;
  background: var(--panel);
  opacity: 0; transform: translateY(12px); visibility: hidden;
  transition: opacity .55s ease, transform .55s ease, visibility .55s;
}
.login-card.show {
  opacity: 1; transform: none; visibility: visible;
}

/* the console's own grammar: a pane head over one command row — input and
   action side by side, hairlines and 2px corners, no floating card */
.login-head {
  display: flex; align-items: center; justify-content: space-between;
  height: 32px; padding: 0 12px; border-bottom: 1px solid var(--line);
}
.login-row { display: flex; gap: 6px; padding: 10px 12px; }
.login-row input {
  flex: 1; min-width: 0; height: 28px; padding: 0 10px;
  background: #0a0d13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; letter-spacing: .14em;
  outline: none; transition: border-color .15s ease, box-shadow .15s ease;
}
.login-row input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(59,130,246,.12);
}
.login-row input::placeholder { color: var(--faint); letter-spacing: .3em; }

.login-err {
  padding: 0 12px 6px; min-height: 12px;
  font-family: var(--mono); font-size: 10px;
  color: var(--dead); letter-spacing: .08em;
}

.login-card.shake { animation: shake .4s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  55% { transform: translateX(5px); }
  80% { transform: translateX(-3px); }
}


/* ---------------- clients: sort, detail kv, report ---------------- */

.rail-tools { display: flex; align-items: center; gap: 6px; }

.kv { padding: 4px 12px 10px; }
.kv-row {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 10px; padding: 4px 0;
  border-bottom: 1px solid var(--line);
}
.kv-row:last-child { border-bottom: 0; }
.kv-row .k { flex: 0 0 auto; }
.kv-row .v {
  font-family: var(--mono); font-size: 10.5px; color: var(--ink);
  text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.kv-empty { padding: 8px 0 4px; font-family: var(--mono); font-size: 10px; color: var(--faint); }

/* the report: a document layer, flat like the console, no card theatre */
.report {
  position: fixed; inset: 0; z-index: 80;
  display: grid; place-items: center;
  background: rgba(5,6,10,.72);
}
.report[hidden] { display: none; }
.report-sheet {
  width: min(760px, calc(100vw - 48px));
  max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 2px;
}
.report-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px; border-bottom: 1px solid var(--line);
}
.report-title {
  font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink);
}
.report-sub { font-size: 10px; margin-top: 3px; }
.report-body {
  overflow: auto; padding: 6px 14px 14px;
}
.report-section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.report-section:last-child { border-bottom: 0; }
.report-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0 22px;
}
.report-note {
  font-family: var(--mono); font-size: 11px; line-height: 1.6;
  color: var(--ink); white-space: pre-wrap;
}
.report-note .empty { color: var(--faint); }


/* ---------------- sections: nav, pages ---------------- */

.rail-nav {
  display: flex; gap: 1px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--line);
}
.rail-nav button {
  flex: 1; height: 24px; padding: 0 4px;
  font-size: 9px; letter-spacing: .12em; text-transform: uppercase;
  color: var(--dim); background: transparent;
  border: 1px solid transparent; border-radius: 2px;
}
.rail-nav button:hover { color: var(--ink); border-color: var(--line); }
.rail-nav button.on { color: var(--accent); border-color: var(--accent-dim); background: #101623; }

.rail-search { padding: 8px 12px 6px; }
.rail-search input {
  width: 100%; height: 26px; padding: 0 9px;
  background: #0a0d13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 10.5px;
  outline: none; transition: border-color .15s ease;
}
.rail-search input:focus { border-color: var(--accent-dim); }
.rail-search input::placeholder { color: var(--faint); }

/* ---------------- report overlay ---------------- */
.report { position: fixed; inset: 0; z-index: 80; display: grid; place-items: center; background: rgba(5,6,10,.72); }
.report[hidden] { display: none; }
.report-sheet {
  width: min(760px, calc(100vw - 48px)); max-height: calc(100vh - 64px);
  display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--line); border-radius: 2px;
}
.report-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.report-title { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink); }
.report-sub { margin-top: 4px; font-family: var(--mono); font-size: 11px; color: var(--dim); }
.report-body { overflow: auto; padding: 6px 14px 14px; }
.report-section { padding: 12px 0; border-bottom: 1px solid var(--line); }
.report-section:last-child { border-bottom: 0; }
.report-section > .label { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin-bottom: 4px; }
.report-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 22px; }
.report-note { font-family: var(--mono); font-size: 11px; color: var(--ink); }
.report-note .empty { color: var(--faint); }
.report-body .row { display: flex; gap: 6px; align-items: center; }
.report-body .row input[type="text"] {
  flex: 1; min-width: 0; height: 28px; padding: 0 10px;
  background: #0a0d13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; outline: none;
}
.report-body .row input[type="text"]:focus { border-color: var(--accent-dim); }
/* ---------------- app shell (dashboard / clients / screenshots / settings) ---------------- */
/* shell tokens ride the viewer palette: --bg, --panel, --ink, --dim, --faint,
   --line, --accent, --live, --warn, --dead. nothing new invented. */

.shell { height: 100dvh; display: flex; flex-direction: column; background: var(--bg); }
.shell[hidden], .app[hidden] { display: none !important; }
.shell-body { flex: 1; display: flex; flex-direction: column; min-height: 0; }

#view-app .top {
  display: flex; align-items: center; gap: 28px;
  height: 52px; padding: 0 14px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}

.app-nav { flex: 1; display: flex; align-items: center; justify-content: center; gap: 4px; }
.app-nav button {
  display: inline-flex; align-items: center; gap: 7px;
  height: 28px; padding: 0 13px;
  font-size: 10px; letter-spacing: .14em; text-transform: uppercase;
  color: var(--dim); background: transparent;
  border: 1px solid transparent; border-radius: 2px;
}
.app-nav button svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; }
.app-nav button:hover { color: var(--ink); border-color: var(--line); }
.app-nav button.on { color: var(--accent); border-color: var(--accent-dim); background: #101623; }

#view-app .top-right { display: flex; align-items: center; gap: 8px; }

/* page head: the same grammar as the viewer panes */
.page-head {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.page-title { font-size: 11px; letter-spacing: .24em; text-transform: uppercase; color: var(--ink); }
.page-sub { margin-top: 4px; font-size: 11px; color: var(--dim); }
.page-tools { display: flex; align-items: center; gap: 6px; }
.page-body { flex: 1; min-height: 0; overflow: auto; padding: 14px 16px 18px; background: var(--bg); }

/* toolbar controls */
.ctl-search {
  height: 28px; width: 240px; padding: 0 10px;
  background: #0a0d13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; outline: none;
}
.ctl-search:focus { border-color: var(--accent-dim); }
.ctl-search::placeholder { color: var(--faint); }

.chip {
  height: 20px; padding: 0 8px;
  font-family: var(--mono); font-size: 10px; white-space: nowrap;
  color: var(--dim); background: transparent;
  border: 1px solid var(--line); border-radius: 2px;
}
.chip:hover { color: var(--ink); border-color: var(--line-bright); }
.chip.on { color: var(--accent); border-color: var(--accent-dim); background: #101623; }

/* dashboard: one row of flat counters, then three hairline columns */
.dash-row {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px; margin-bottom: 16px;
  background: var(--line); border: 1px solid var(--line);
}
.dash-cell { background: var(--panel); padding: 12px 14px; }
.dash-cell .v { font-family: var(--mono); font-size: 22px; font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
.dash-cell .v.live { color: var(--live); }
.dash-cell .k { margin-top: 5px; font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }

.dash-cols { display: grid; grid-template-columns: 1.15fr 1fr 1fr; gap: 16px; }
@media (max-width: 1180px) { .dash-cols { grid-template-columns: 1fr 1fr; } }
@media (max-width: 860px) { .dash-cols { grid-template-columns: 1fr; } .dash-row { grid-template-columns: repeat(2, 1fr); } }
.dash-block { background: var(--panel); border: 1px solid var(--line); min-width: 0; }
.block-head {
  display: flex; justify-content: space-between; align-items: center;
  height: 32px; padding: 0 12px; border-bottom: 1px solid var(--line);
}
.block-head .label { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.dash-block .kv { padding: 6px 12px 12px; }
.kv-row { position: relative; display: flex; justify-content: space-between; align-items: baseline; gap: 10px; padding: 5px 0; border-bottom: 1px solid var(--line); }
.kv-row:last-child { border-bottom: 0; }
.kv-row .bar { position: absolute; left: 0; bottom: -1px; height: 2px; background: var(--accent); opacity: .7; }
.kv-row:hover { background: #0d1119; }
.kv-row .k {
  flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint);
}
.kv-row .v { font-family: var(--mono); font-size: 11px; color: var(--ink); font-variant-numeric: tabular-nums; }
.kv-row.link { cursor: pointer; }
.dash-empty {
  border: 1px dashed var(--line-bright); padding: 28px;
  font-family: var(--mono); font-size: 11px; color: var(--faint); text-align: center;
}

.act-row {
  display: flex; gap: 10px; align-items: baseline; padding: 5px 0;
  border-bottom: 1px solid var(--line); font-family: var(--mono); font-size: 11px; color: var(--dim);
}
.act-row:last-child { border-bottom: 0; }
.act-row .t { flex: 0 0 auto; color: var(--faint); font-variant-numeric: tabular-nums; }
.act-row .b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* clients table: dense, 56px rows, no action buttons inside */
.tbl-wrap { border: 1px solid var(--line); background: var(--panel); }
.tbl { width: 100%; border-collapse: collapse; }
.tbl thead th {
  position: sticky; top: 0; z-index: 1;
  font-size: 9px; letter-spacing: .2em; text-transform: uppercase; font-weight: 400;
  color: var(--faint); background: var(--panel);
  text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line);
  cursor: pointer; white-space: nowrap; user-select: none;
}
.tbl thead th:hover { color: var(--ink); }
.tbl thead th.sorted { color: var(--accent); }
.tbl thead th.nosort { cursor: default; }
.tbl thead th.nosort:hover { color: var(--faint); }
.tbl tbody tr { height: 56px; cursor: pointer; }
.tbl tbody td {
  font-family: var(--mono); font-size: 12px; color: var(--ink);
  font-variant-numeric: tabular-nums;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  vertical-align: middle;
}
.tbl tbody tr:hover td { background: #0d1119; }
.tbl tbody tr.off td { color: var(--faint); }
.tbl tbody td.num { text-align: right; }
.st { display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--live); }
tr.off .st { background: var(--faint); }
td .geo {
  font-family: var(--mono); font-size: 10px; color: var(--dim);
  border: 1px solid var(--line); border-radius: 2px; padding: 1px 5px; white-space: nowrap;
}
.note-mark { font-style: normal; color: var(--accent); margin-left: 5px; }
td .sub { display: block; font-size: 10px; color: var(--faint); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; }
td.sel, th.sel { width: 30px; text-align: center; padding-left: 12px; }
.sel-box { width: 12px; height: 12px; accent-color: var(--accent); cursor: pointer; vertical-align: middle; }
.cell-note {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  color: var(--dim); font-size: 11px;
}
tr.off .cell-note { color: var(--faint); }
td.dim { color: var(--faint); }
.tbl-empty {
  padding: 24px; font-family: var(--mono); font-size: 11px; color: var(--faint);
  text-align: center; border: 1px dashed var(--line-bright);
}

#bulk-bar {
  display: flex; align-items: center; gap: 8px;
  height: 28px; padding: 0 10px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--dim);
}
#bulk-bar[hidden] { display: none; }
#bulk-bar .n { color: var(--ink); }

/* right-click menu: one instance on body, never inside #page-body */
.ctx {
  position: fixed; z-index: 100; min-width: 200px; max-width: 280px;
  background: #0f131b; border: 1px solid var(--line-bright); border-radius: 2px; padding: 4px;
}
.ctx button {
  display: flex; align-items: center; gap: 8px;
  width: 100%; height: 26px; padding: 0 10px;
  font-size: 11px; text-align: left; color: var(--dim);
  background: transparent; border: 0; border-radius: 2px;
}
.ctx button:hover { background: #161a24; color: var(--ink); }
.ctx button svg { width: 12px; height: 12px; flex: 0 0 auto; fill: none; stroke: currentColor; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.ctx button.on { color: var(--accent); }
.ctx .ctx-sep { height: 1px; background: var(--line); margin: 4px 0; }
.ctx .ctx-label {
  padding: 4px 10px 2px; font-size: 9px; letter-spacing: .2em;
  text-transform: uppercase; color: var(--faint);
}
.ctx input.ctx-note {
  display: block; width: calc(100% - 8px); margin: 2px 4px 4px;
  height: 26px; padding: 0 8px;
  background: #0a0d13; color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; outline: none;
}
.ctx input.ctx-note:focus { border-color: var(--accent-dim); }

/* settings: integrations only, no server screens */
.set-block { max-width: 620px; background: var(--panel); border: 1px solid var(--line); margin-bottom: 16px; }
.set-form { display: flex; flex-direction: column; gap: 10px; padding: 12px; }
.set-field { display: flex; align-items: center; gap: 10px; }
.set-field > .label { flex: 0 0 92px; font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.set-field input[type="text"], .set-field input[type="password"] {
  flex: 1; min-width: 0; height: 28px; padding: 0 10px;
  background: #0a0d13; color: var(--ink); caret-color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; outline: none;
  transition: none;
}
.set-field input:focus { border-color: var(--accent-dim); transition: none; }
.set-field input:-webkit-autofill,
.set-field input:-webkit-autofill:hover,
.set-field input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  -webkit-box-shadow: 0 0 0 40px #0a0d13 inset;
  transition: background-color 0s;
}
.set-actions { display: flex; gap: 6px; padding-top: 2px; }
.set-actions button:first-child {
  height: 28px; padding: 0 14px; font-size: 10px; letter-spacing: .08em; text-transform: lowercase;
  color: #fff; background: #1d4ed8; border: 1px solid #1d4ed8; border-radius: 2px;
}
.set-actions button:first-child:hover { background: #2563eb; border-color: #2563eb; }
.set-note { font-family: var(--mono); font-size: 10.5px; color: var(--faint); }
.soon { font-family: var(--mono); font-size: 9px; color: var(--faint); text-transform: uppercase; letter-spacing: .1em; margin-left: 6px; }

/* screenshots: stub grid, no backend yet */
.shots-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.shot-sk { border: 1px solid var(--line); background: var(--panel); }
.shot-sk-img { aspect-ratio: 16 / 9; background: #0b0e14; animation: pulse 2.4s ease-in-out infinite; }
.shot-sk-meta { display: flex; flex-direction: column; gap: 4px; padding: 8px 10px 10px; }
.shot-sk-meta i { display: block; height: 8px; background: #141926; }
.shot-sk-meta i:last-child { width: 60%; }
.shots-note {
  margin-bottom: 14px; padding: 10px 12px;
  background: var(--panel); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 11px; color: var(--dim); line-height: 1.7;
}
.shots-note b { color: var(--ink); font-weight: 500; }
/* toggles-as-switches (settings), telegram preview, data/globe shells */
.set-tgl {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 7px 0 7px 2px; border-bottom: 1px solid var(--line);
}
.set-tgl:last-of-type { border-bottom: 0; }
.set-tgl-text { display: flex; align-items: baseline; gap: 8px; min-width: 0; flex-wrap: wrap; }
.set-tgl-text span:first-child { font-size: 11px; color: var(--dim); white-space: nowrap; }
.set-tgl-hint { font-family: var(--mono); font-size: 10px; color: var(--faint); }

/* globe block */
.globe-wrap { display: flex; flex-direction: column; align-items: center; padding: 8px 0 4px; }
.globe { width: 300px; height: 300px; cursor: grab; touch-action: none; }
.globe:active { cursor: grabbing; }
.globe-cap { font-size: 10px; color: var(--faint); margin: 2px 0 8px; }
/* settings: config + account left (42%), live preview right (58%) */
.set-cols { display: grid; grid-template-columns: minmax(0, 42fr) minmax(0, 58fr); gap: 16px; align-items: start; margin: 12px 0 16px; }
.set-cols > .set-block { grid-column: 1; grid-row: 1; margin: 0; max-width: none; min-width: 0; }
.set-cols > .acc-block { grid-column: 1; grid-row: 2; margin: 0; max-width: none; min-width: 0; }
.set-cols > .tg-prev { grid-column: 2; grid-row: 1 / span 2; min-width: 0; min-height: 0; }

/* левая колонка — плоская лента без воздушных карманов */
.set-cols > .set-block,
.set-cols > .acc-block { background: transparent; border: 0; border-top: 1px solid var(--line); }
.set-cols > .set-block:first-child { border-top: 0; }
.set-cols > .set-block > .label, .set-cols > .acc-block > .label { padding: 10px 0 0; }

/* правая колонка — плотная, без растяжек */
.tg-prev { padding: 10px 4px 10px 0; gap: 8px; min-height: 0; }
.tg-prev > .label { padding-left: 2px; }
/* recent events: та же строка, что activity на dashboard, без дефолтных отступов */
.tg-log { margin-top: 2px; border-top: 1px solid var(--line); padding: 8px 2px 0; min-width: 0; }
.tg-log-title { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); margin-bottom: 2px; }
#tg-log-lines { min-width: 0; }
#tg-log-lines .ev {
  display: flex; gap: 10px; align-items: baseline; padding: 4px 0;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono); font-size: 10px; color: var(--dim);
}
#tg-log-lines .ev:last-child { border-bottom: 0; }
#tg-log-lines .ev .t { flex: 0 0 auto; color: var(--faint); font-variant-numeric: tabular-nums; }
#tg-log-lines .ev span:last-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (max-width: 1100px) {
  .set-cols { grid-template-columns: minmax(0, 1fr); }
  .set-cols > .set-block, .set-cols > .acc-block, .set-cols > .tg-prev { grid-column: 1; grid-row: auto; }
}
/* settings: telegram config — поля в сетке подпись/ввод, тоглы в сетку с правым краем */
.set-cols > .set-block { display: flex; flex-direction: column; }
.set-form { display: flex; flex-direction: column; gap: 0; padding: 12px; }
.set-grid { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 10px 12px; align-items: center; }
.set-grid > .label { font-size: 9px; letter-spacing: .14em; text-transform: uppercase; color: var(--faint); }
.set-grid input[type="text"], .set-grid input[type="password"] {
  width: 100%; min-width: 0; height: 28px; padding: 0 10px;
  background: #0a0d13; color: var(--ink); caret-color: var(--ink);
  border: 1px solid var(--line); border-radius: 2px;
  font-family: var(--mono); font-size: 11px; outline: none;
  transition: none;
}
.set-grid input:focus { border-color: var(--accent-dim); transition: none; }
.set-tglrow { display: grid; grid-template-columns: minmax(0, 1fr) 28px; gap: 12px; align-items: center; padding: 8px 0 8px 2px; border-top: 1px solid var(--line); }
.set-tglrow .set-tgl-text { min-width: 0; }
/* settings: компактный горизонтальный профиль — аватар / имя / save */
.acc-form { gap: 0; padding: 12px; }
.acc-row { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 12px; align-items: center; }
.acc-row .avatar { width: 36px; height: 36px; font-size: 15px; }
.acc-row .acc-up { padding-left: 8px; padding-right: 8px; }
.acc-meta { display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.acc-name-input {
  width: 100%; min-width: 0; height: 24px; padding: 0;
  background: transparent; border: 0; border-radius: 0;
  color: var(--ink); font: inherit; font-size: 12px; font-weight: 500; outline: none;
}
.acc-name-input::placeholder { color: var(--faint); }
.acc-name-input:hover { background: #10141d; }
.acc-name-input:focus { background: #0a0d13; box-shadow: inset 0 -1px 0 var(--accent-dim); }
.acc-cap { font-family: var(--mono); font-size: 10px; color: var(--faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-hint { margin-top: 8px; }
.set-block > .label { display: block; padding: 12px 12px 0; }
.tg-prev {
  background: var(--panel); border: 1px solid var(--line);
  padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 10px;
  align-self: stretch; min-width: 0; min-height: 100%;
}
.tg-prev > .label { font-size: 9px; letter-spacing: .2em; text-transform: uppercase; color: var(--faint); }
.tg-row { display: flex; min-width: 0; }
.tg-row.off { opacity: .32; filter: saturate(.4); }
.tg-msg { display: flex; min-width: 0; }
/* превью: лента без пустоты, пузырь ужат до контента */
.tg-prev .tg-row { margin: 0; }
.tg-bubble {
  max-width: 360px; width: fit-content; min-width: 0;
  padding: 7px 10px 6px;
  background: #182533; border: 0; border-radius: 12px 12px 12px 4px;
  font-size: 13px; color: #fff; line-height: 1.5;
}
.tg-from {
  font-size: 13px; font-weight: 600; color: #71b8ec;
  margin-bottom: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-text { overflow-wrap: anywhere; }
.tg-l1, .tg-l2, .tg-l3 { text-align: left; }
.tg-l1 { font-weight: 400; }
.tg-l2 { color: #c8d3e0; }
.tg-l3 { color: #9fb0c3; margin-top: 2px; }
/* время в потоке: прижато вправо к последней строке, как в TG */
.tg-time {
  float: right; margin: 6px 0 0 8px;
  font-size: 11px; color: #7f91a4; font-variant-numeric: tabular-nums;
  user-select: none;
}
/* файл-карта: круглая иконка с расширением + имя/размер */
.tg-attach {
  display: flex; align-items: center; gap: 10px; margin-top: 6px; width: 100%;
  min-width: 0;
}
.tg-doc {
  flex: 0 0 auto; width: 40px; height: 40px; border-radius: 50%;
  background: #2b5278; color: #fff;
  display: grid; place-items: center;
  font-size: 10px; font-weight: 600; letter-spacing: .04em;
}
.tg-filemeta { min-width: 0; flex: 1; text-align: left; }
.tg-filename {
  font-size: 13px; color: #fff;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.tg-filesize { font-size: 12px; color: #7f91a4; margin-top: 1px; }
.tg-row.sample .tg-bubble { border: 1px dashed var(--line-bright); }
.acc-block { max-width: 620px; }
.acc-form { gap: 8px; }
.acc-row { display: flex; align-items: center; gap: 12px; }
.avatar {
  width: 44px; height: 44px; flex: 0 0 auto; border-radius: 50%;
  background: #131a26; border: 1px solid var(--line-bright);
  display: grid; place-items: center; overflow: hidden;
  font-size: 18px; font-weight: 600; color: var(--accent);
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.acc-up { cursor: pointer; }
.acc-name { flex: 1; }
.acc-name > .label { flex: 0 0 auto; }
