/* ===== WebLocal Proxy dashboard ===== */

:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface-2: #1c2128;
  --border: #30363d;
  --border-strong: #484f58;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79b8ff;
  --danger: #f85149;
  --success: #3fb950;
  --radius: 12px;
  --radius-sm: 8px;
  --control-h: 2.5rem;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Mono", "SF Mono", Consolas, monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* Явно: иначе любые display:flex/grid на классе перебивают HTML hidden */
[hidden] { display: none !important; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.45;
}

.brand {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.brand__logo {
  width: 2.5rem;
  height: 2.5rem;
  object-fit: contain;
  flex-shrink: 0;
}
.auth-card .brand {
  margin-bottom: .15rem;
}
.auth-card .brand__logo {
  width: 3rem;
  height: 3rem;
}
.auth-card .brand h1 {
  margin-bottom: 0;
}
.hint { color: var(--text-dim); margin-top: .35rem; font-size: .92rem; }
.hint code {
  font-family: var(--mono);
  font-size: .85em;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: .1em .35em;
}

/* ===== App shell (sidebar layout) ===== */

.app-shell {
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  --sidebar-w: 240px;
  flex: 0 0 var(--sidebar-w);
  width: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.15rem 0.85rem 1rem;
  background: var(--surface);
  border-right: 1px solid var(--border);
  min-height: 100vh;
  position: sticky;
  top: 0;
  align-self: flex-start;
  z-index: 12;
}

.sidebar__brand {
  padding: 0.15rem 0.4rem 0.5rem;
  gap: 0.65rem;
}
.sidebar__brand h1 {
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 0;
}
.sidebar__brand .brand__logo {
  width: 2rem;
  height: 2rem;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.nav-item {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--text-dim);
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.55rem 0.75rem;
  cursor: pointer;
  position: relative;
  transition: color 0.12s, background 0.12s;
  flex-shrink: 0;
}
.nav-item:hover {
  color: var(--text);
  background: var(--surface-2);
}
.nav-item[aria-current="page"] {
  color: var(--text);
  background: rgba(88, 166, 255, 0.12);
}
.nav-item[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.4rem;
  bottom: 0.4rem;
  width: 3px;
  border-radius: 0 2px 2px 0;
  background: var(--accent);
}

/* ===== Sidebar hosts/apps tree ===== */

.sidebar-tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin-top: 0.45rem;
  padding-top: 0.45rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.sidebar-tree__empty {
  padding: 0.5rem 0.75rem;
  font-size: 0.82rem;
  color: var(--text-dim);
}

.sidebar-tree__host {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
}

.sidebar-tree__row {
  display: flex;
  align-items: center;
  gap: 0.15rem;
  min-width: 0;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
}
.sidebar-tree__row:hover {
  background: var(--surface-2);
  color: var(--text);
}
.sidebar-tree__row.is-active {
  background: rgba(88, 166, 255, 0.12);
  color: var(--text);
}

.sidebar-tree__toggle {
  flex: 0 0 1.35rem;
  width: 1.35rem;
  height: 1.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.65rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  opacity: 0.75;
}
.sidebar-tree__toggle:hover {
  opacity: 1;
  background: rgba(88, 166, 255, 0.12);
}
.sidebar-tree__toggle.is-leaf {
  visibility: hidden;
  pointer-events: none;
}

.sidebar-tree__label {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 500;
  text-align: left;
  padding: 0.32rem 0.4rem 0.32rem 0;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
.sidebar-tree__label--app {
  font-weight: 400;
  padding-left: 0;
  font-size: 0.82rem;
}

.sidebar-tree__icon {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  object-fit: contain;
  background: var(--surface-2);
}
.sidebar-tree__icon-fallback {
  flex: 0 0 1.15rem;
  width: 1.15rem;
  height: 1.15rem;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-dim);
}

.sidebar-tree__name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-tree__badge {
  flex-shrink: 0;
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.02em;
  opacity: 0.85;
}

.sidebar-tree__apps {
  display: flex;
  flex-direction: column;
  gap: 0.02rem;
  padding-left: 0.35rem;
}

.sidebar-tree__row--app {
  padding-left: 0.15rem;
}

.sidebar-tree__label--tool {
  color: var(--text-dim);
}
.sidebar-tree__row--tool:hover .sidebar-tree__label--tool {
  color: var(--text);
}
.sidebar-tree__tool-glyph {
  font-family: var(--mono);
  font-size: 0.62rem;
}

.dash-ctx {
  position: fixed;
  z-index: 10000;
  margin: 0;
  padding: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  min-width: 11.5rem;
}
.dash-ctx[hidden] {
  display: none !important;
}
.dash-ctx button {
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: 0.4rem 0.55rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
  font-size: 0.88rem;
}
.dash-ctx button:hover {
  background: rgba(88, 166, 255, 0.12);
}
.dash-ctx button.is-danger {
  color: var(--danger);
}
.dash-ctx button.is-danger:hover {
  background: rgba(248, 81, 73, 0.12);
}
.dash-ctx__sep {
  height: 1px;
  margin: 0.25rem 0.35rem;
  background: var(--border);
  border: 0;
  padding: 0;
}

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  margin-top: auto;
}

.sidebar__account {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.sidebar__link.ghost {
  width: 100%;
  justify-content: flex-start;
  text-align: left;
  padding: 0.4rem 0.65rem;
  font-size: 0.85rem;
  min-height: 0;
  border-color: transparent;
  background: transparent;
  color: var(--text-dim);
}
.sidebar__link.ghost:hover {
  color: var(--text);
  background: var(--surface-2);
  border-color: transparent;
}

.sidebar__install {
  width: 100%;
  justify-content: center;
}

.sidebar-backdrop {
  display: none;
}

.dash-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.dash-topbar {
  display: none;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  position: sticky;
  top: 0;
  z-index: 8;
}

.dash-main > main {
  flex: 1 1 auto;
  padding: 1.5rem 1.75rem 2rem;
  width: 100%;
}

@media (max-width: 800px) {
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
    min-height: 100%;
    height: 100%;
  }
  .app-layout.is-sidebar-open .sidebar {
    transform: translateX(0);
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 11;
    background: rgba(1, 4, 9, 0.55);
    border: none;
    padding: 0;
    cursor: pointer;
  }
  .sidebar-backdrop[hidden] {
    display: none !important;
  }
  .dash-topbar {
    display: flex;
  }
  .dash-main > main {
    padding: 1.15rem 1rem 1.75rem;
  }
}

/* ===== Shared form controls ===== */

.field {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1rem;
  min-width: 0;
}

.field__label {
  font-size: .82rem;
  font-weight: 500;
  color: var(--text-dim);
  line-height: 1.3;
}

.field > input:not([type="checkbox"]):not([type="radio"]),
.field > select,
.field > textarea,
.auth-card input:not([type="checkbox"]):not([type="radio"]),
.auth-card select,
.auth-card textarea,
dialog input:not([type="checkbox"]):not([type="radio"]),
dialog select,
dialog textarea {
  display: block;
  width: 100%;
  min-width: 0;
  height: var(--control-h);
  padding: 0 .75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: .95rem;
  line-height: 1.25;
  transition: border-color .12s, box-shadow .12s;
}

dialog textarea,
.field > textarea {
  height: auto;
  min-height: 8rem;
  padding: .7rem .75rem;
  font-family: var(--mono);
  font-size: .8rem;
  line-height: 1.4;
  resize: vertical;
}

dialog select,
.field > select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-dim) 50%),
    linear-gradient(135deg, var(--text-dim) 50%, transparent 50%);
  background-position:
    calc(100% - 14px) calc(50% - 2px),
    calc(100% - 9px) calc(50% - 2px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 2rem;
}

dialog input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}
dialog input[type="number"]::-webkit-outer-spin-button,
dialog input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field > input:not([type="checkbox"]):not([type="radio"]):focus,
.field > select:focus,
.field > textarea:focus,
.auth-card input:not([type="checkbox"]):not([type="radio"]):focus,
dialog input:not([type="checkbox"]):not([type="radio"]):focus,
dialog select:focus,
dialog textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.field > input::placeholder,
.auth-card input::placeholder,
dialog input::placeholder,
dialog textarea::placeholder {
  color: #6e7681;
}

.field--check {
  flex-direction: row;
  align-items: flex-start;
  gap: .65rem;
  margin-bottom: 1rem;
}

.field--check input[type="checkbox"],
.field--check input[type="radio"] {
  width: 1.05rem;
  height: 1.05rem;
  margin-top: .15rem;
  flex: 0 0 auto;
  accent-color: var(--accent);
  cursor: pointer;
}

.field--check .field__label {
  color: var(--text);
  font-size: .9rem;
  font-weight: 400;
  cursor: pointer;
}

.row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 7.5rem;
  gap: .75rem;
  margin-bottom: 0;
  align-items: start;
}

.row.target-url-row {
  grid-template-columns: 6.5rem minmax(0, 1fr) 5.5rem;
}

.row .field.target-scheme {
  min-width: 0;
}

/* В форме пользователя оба поля равные */
#user-form > .row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.row .field { margin-bottom: 1rem; }

.field-hint {
  font-size: .8rem;
  color: var(--text-dim);
  margin: -.55rem 0 1rem;
  line-height: 1.35;
}

.probe-results {
  margin: -.25rem 0 1rem;
}

.probe-results__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  max-height: 12rem;
  overflow: auto;
}

.probe-results__list button {
  display: block;
  width: 100%;
  text-align: left;
  font: inherit;
  font-size: .85rem;
  padding: .45rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius, 6px);
  background: transparent;
  color: var(--text);
  cursor: pointer;
}

.probe-results__list button:hover {
  background: var(--border);
}

.probe-results__list .probe-url {
  font-family: var(--mono);
  font-size: .8rem;
}

.probe-results__list .probe-title {
  color: var(--text-dim);
  margin-left: .35rem;
}

.ssh-keygen {
  margin-bottom: 1rem;
}

.ssh-keygen__bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .65rem;
  margin-bottom: .75rem;
}

.ssh-keygen__status {
  font-size: .82rem;
  color: var(--success);
}

.ssh-keygen__pub-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: .5rem;
  align-items: start;
}

.ssh-keygen__pub-row textarea {
  font-family: var(--mono);
  font-size: .78rem;
  resize: vertical;
  min-height: 3.2rem;
}

.ssh-keygen__pub-row button {
  white-space: nowrap;
  height: var(--control-h);
}

.app-icon-row {
  grid-template-columns: auto 1fr auto;
  align-items: center;
}

.app-icon-preview {
  width: 2rem;
  height: 2rem;
  object-fit: contain;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  padding: 2px;
}

details.panel {
  margin-bottom: 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  padding: .15rem .85rem .35rem;
}

details.panel summary {
  cursor: pointer;
  color: var(--accent);
  font-size: .88rem;
  padding: .65rem 0;
  list-style: none;
}
details.panel summary::-webkit-details-marker { display: none; }
details.panel summary::before {
  content: "▸";
  display: inline-block;
  margin-right: .4rem;
  transition: transform .12s;
}
details.panel[open] summary::before { transform: rotate(90deg); }
details.panel .field:last-child { margin-bottom: .65rem; }

fieldset.panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .85rem 1rem 1rem;
  margin: 0 0 1rem;
  background: var(--surface-2);
}
fieldset.panel legend {
  padding: 0 .4rem;
  color: var(--text-dim);
  font-size: .82rem;
}

.apps-checks {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin-top: .15rem;
  max-height: 10rem;
  overflow: auto;
}
.apps-checks .field--check {
  margin-bottom: 0;
}

/* ===== Tiles ===== */

.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1.15rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-height: 7.5rem;
  transition: border-color .15s;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
}
.tile__open {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-width: 0;
  flex: 1 1 auto;
  text-decoration: none;
  color: inherit;
}

.tile__install,
.tile__star,
.tile__edit,
.tile__remove {
  z-index: 2;
}

.tile__name {
  font-size: 1.25rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding-right: 2.2rem;
}

.tile__head {
  display: flex;
  align-items: center;
  gap: .9rem;
  min-width: 0;
}

.tile__head .tile__name {
  padding-right: 2.2rem;
  flex: 1;
  min-width: 0;
}

.tile:has(.tile__edit) .tile__head .tile__name,
.tile:has(.tile__star) .tile__head .tile__name {
  padding-right: 6.8rem;
}

.tile__icon {
  flex: 0 0 3.25rem;
  width: 3.25rem;
  height: 3.25rem;
  border-radius: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  overflow: hidden;
  position: relative;
}

.tile__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  padding: .25rem;
}

.tile__icon-fallback {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--accent);
  line-height: 1;
}

.tile__icon.has-img .tile__icon-fallback { display: none; }
.tile__icon.is-fallback img { display: none; }

.tile__meta {
  font-size: .88rem;
  color: var(--text-dim);
  word-break: break-all;
  line-height: 1.35;
}

.tile__status {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin-top: .15rem;
  font-size: .78rem;
  color: var(--text-dim);
  line-height: 1.2;
}

.tile__status-dot {
  width: .55rem;
  height: .55rem;
  border-radius: 50%;
  background: var(--text-dim);
  opacity: .55;
  flex: 0 0 auto;
}

.tile__status.is-online .tile__status-dot {
  background: var(--success);
  opacity: 1;
}

.tile__status.is-online .tile__status-text {
  color: var(--success);
}

.tile__status.is-offline .tile__status-dot {
  background: var(--danger);
  opacity: 1;
}

.tile__status.is-offline .tile__status-text {
  color: var(--danger);
}

.tile__status.is-unknown .tile__status-dot {
  background: var(--text-dim);
  opacity: .45;
}

.tile__edit,
.tile__remove {
  position: absolute;
  top: .5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  line-height: 1;
  padding: .25rem .4rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.tile__edit { right: 2.1rem; font-size: 1.05rem; }
.tile__remove { right: .5rem; font-size: 1.2rem; }
.tile__install {
  position: absolute;
  top: .5rem;
  right: .5rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: .25rem .35rem;
  border-radius: 4px;
  transition: color .15s, background .15s;
}
.tile:has(.tile__edit) .tile__install,
.tile:has(.tile__star) .tile__install {
  right: 5.3rem;
}
.tile__install:hover {
  color: var(--accent);
  background: rgba(88, 166, 255, .1);
}
.tile__star {
  position: absolute;
  top: .5rem;
  right: 3.7rem;
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 1.05rem;
  padding: .25rem .35rem;
  border-radius: 4px;
}
.tile__star.is-on { color: #e3b341; }
.tile__star:hover { color: #e3b341; background: rgba(227, 179, 65, .12); }

.tile--host {
  text-align: left;
  font: inherit;
  width: 100%;
}

.tile__ssh-tools {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .35rem;
}

.tile__ssh-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .28rem .55rem;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  line-height: 1.2;
  transition: border-color .15s, color .15s, background .15s;
}
.tile__ssh-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(88, 166, 255, .1);
}
.tile__ssh-glyph {
  font-family: var(--mono);
  font-size: .85rem;
  opacity: .9;
}

.dash-section { margin-bottom: 0; }
.dash-section--hosts,
.dash-section--groups {
  padding-top: 0;
  border-top: none;
}
.section-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1rem;
}
.section-head h2 {
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.25;
  margin: 0;
}
.section-head__titles {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: .2rem;
}
.section-head__meta {
  margin: 0;
  word-break: break-all;
}
.header-actions--icons {
  flex-shrink: 0;
  gap: .25rem;
}
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  font: inherit;
  font-size: 1.05rem;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  box-sizing: border-box;
  transition: color .15s, background .15s, border-color .15s;
}
.icon-btn:hover {
  color: var(--accent);
  background: rgba(88, 166, 255, .1);
  border-color: transparent;
}
.icon-btn--close {
  font-size: 1.35rem;
  font-weight: 400;
}
.icon-btn--close:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, .1);
}
.icon-btn--danger:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, .1);
}
.icon-btn__glyph--mono {
  font-family: var(--mono);
  font-size: .78rem;
  letter-spacing: -0.04em;
}
.empty-inline {
  color: var(--text-dim);
  font-size: .95rem;
}

.tile__edit:hover { color: var(--accent); background: rgba(88,166,255,.1); }
.tile__remove:hover { color: var(--danger); background: rgba(248,81,73,.1); }

.add {
  justify-content: center;
  align-items: center;
  font-size: 2.5rem;
  font-weight: 300;
  color: var(--text-dim);
  cursor: pointer;
}
.add:hover { border-color: var(--accent); color: var(--accent); }

.empty {
  text-align: center;
  color: var(--text-dim);
  margin-top: 2rem;
  font-size: 1.1rem;
}
.empty button { margin-top: 1rem; font-size: 1rem; }

/* ===== Dialog ===== */

dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  padding: 0;
  max-width: 520px;
  width: min(520px, calc(100vw - 2rem));
  height: fit-content;
  max-height: calc(100vh - 2rem);
  overflow: hidden;
  box-shadow: 0 16px 48px rgba(0, 0, 0, .45);
}

dialog::backdrop { background: rgba(1, 4, 9, .72); }

dialog > form,
dialog > .dialog-wide {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 2rem);
  padding: 1.5rem 1.5rem 1.25rem;
  overflow: auto;
}

dialog h2 {
  margin-bottom: 1.15rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}

dialog h3 {
  margin: .25rem 0 1rem;
  font-size: 1rem;
  font-weight: 600;
}

#fields-socks5,
#fields-ssh { margin-top: .15rem; }
#direct-hint { margin-top: -.25rem; }

.actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: .6rem;
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

button {
  padding: .55rem 1.1rem;
  min-height: 2.35rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  font-size: .92rem;
  line-height: 1.2;
}
button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}
button.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
button.ghost:hover { background: var(--border); }
button.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.danger-text { color: var(--danger) !important; }

.error {
  color: var(--danger);
  font-size: .85rem;
  margin-bottom: .75rem;
  line-height: 1.35;
}

/* ===== Auth gate ===== */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background:
    radial-gradient(ellipse at 18% 0%, rgba(88, 166, 255, 0.14), transparent 48%),
    radial-gradient(ellipse at 85% 100%, rgba(63, 185, 80, 0.08), transparent 42%),
    var(--bg);
}

/* display:flex выше перебивает UA-стиль [hidden] — без этого «Вход» висит поверх дашборда */
.auth-gate[hidden] {
  display: none !important;
}

.auth-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem 1.5rem 1.5rem;
  width: min(400px, 100%);
  box-shadow: 0 12px 40px rgba(0, 0, 0, .35);
}
.auth-card h1 {
  margin-bottom: .15rem;
  font-size: 1.55rem;
  letter-spacing: -0.02em;
}
.auth-card form { margin-top: 1.15rem; }
.auth-card .field { margin-bottom: .9rem; }
.auth-card button.primary {
  width: 100%;
  margin-top: .35rem;
}

/* ===== Standalone error page ===== */

.error-page__card {
  text-align: left;
}
.error-page__code {
  margin: 1rem 0 .15rem;
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.error-page__title {
  margin: 0 0 .35rem;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.error-page__detail {
  margin: 0;
  word-break: break-word;
}
.error-page__actions {
  margin: 1.25rem 0 0;
}
.error-page__btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: var(--control-h);
  padding: .55rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--accent);
  background: var(--accent);
  color: #fff;
  font: inherit;
  font-size: .92rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.error-page__btn:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.header-row {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
  flex-wrap: wrap;
}
.header-actions {
  display: flex;
  gap: .5rem;
  align-items: center;
  flex-wrap: wrap;
}
.user-badge {
  display: block;
  font-size: .78rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .35rem .65rem;
  background: var(--bg);
  word-break: break-word;
  line-height: 1.3;
}

.dialog-wide { width: 100%; }
dialog.dialog--wide,
#users-dialog,
#status-dialog {
  max-width: 560px;
  width: min(560px, calc(100vw - 2rem));
}
#status-dialog {
  max-width: 720px;
  width: min(720px, calc(100vw - 2rem));
}
#status-dialog h3 {
  margin: 1rem 0 .55rem;
  font-size: .95rem;
}
#status-dialog h3:first-of-type { margin-top: .35rem; }

.status-meta {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(9.5rem, 1fr));
  gap: .55rem .85rem;
  font-size: .86rem;
}
.status-meta__item {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.status-meta__label {
  color: var(--text-dim);
  font-size: .75rem;
}
.status-meta__value {
  font-variant-numeric: tabular-nums;
  word-break: break-word;
}
.status-meta__value.is-on { color: var(--success); }
.status-meta__value.is-off { color: var(--danger); }

.status-table-wrap {
  margin-bottom: .25rem;
  overflow-x: auto;
}
.status-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .82rem;
}
.status-table th,
.status-table td {
  padding: .45rem .5rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  white-space: nowrap;
}
.status-table th {
  color: var(--text-dim);
  font-weight: 500;
  font-size: .75rem;
}
.status-table td.status-table__wrap {
  white-space: normal;
  word-break: break-word;
  max-width: 12rem;
}
.status-table__empty {
  color: var(--text-dim);
  font-size: .85rem;
  margin: .15rem 0 .35rem;
}
.status-table .ghost {
  padding: .3rem .55rem;
  min-height: 0;
  font-size: .8rem;
}
.status-alive.is-alive { color: var(--success); }
.status-alive.is-dead { color: var(--danger); }

.users-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  margin-bottom: .25rem;
}
.user-row {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem .75rem;
  align-items: flex-start;
  justify-content: space-between;
  padding: .8rem .9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}
.user-row__info {
  display: flex;
  flex-direction: column;
  gap: .2rem;
  min-width: 0;
  flex: 1 1 12rem;
}
.user-row__info .hint { margin: 0; }
.user-row__actions {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  flex-shrink: 0;
}
.user-row .hint { flex: 1 1 100%; margin: 0; }
#user-access-dialog .apps-checks {
  max-height: 14rem;
}
.sep {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.1rem 0;
}
.totp-secret {
  display: block;
  margin: .75rem 0;
  padding: .8rem .9rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  word-break: break-all;
  font-family: var(--mono);
  font-size: .85rem;
}
.totp-qr-wrap {
  display: flex;
  justify-content: center;
  margin: 1rem 0 1.15rem;
  padding: 1rem;
  background: #fff;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.totp-qr {
  display: block;
  width: 200px;
  height: 200px;
}
.break-all { word-break: break-all; }

.passkey-login {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}
.passkey-login .primary { width: 100%; }
#login-form #btn-login-back,
#totp-form #btn-totp-back {
  width: 100%;
  margin-top: .65rem;
}
.actions-stack {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  margin: 1rem 0;
}
.actions-stack .primary,
.actions-stack .ghost {
  width: 100%;
}
#secure-form #btn-secure-continue {
  width: 100%;
  margin-top: .5rem;
}
.account-section {
  margin: 1.25rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.account-section h3 {
  margin: 0 0 .75rem;
  font-size: 1rem;
}
.account-section > .primary,
.account-section > .danger,
.account-section > .ghost {
  margin-top: .5rem;
}
#account-dialog .actions {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.passkey-list {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: .55rem;
}
.passkey-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  padding: .65rem .8rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2, transparent);
}
.passkey-list .passkey-meta {
  display: flex;
  flex-direction: column;
  gap: .15rem;
  min-width: 0;
}
.passkey-list .passkey-name {
  font-weight: 600;
}
.passkey-list .passkey-date {
  font-size: .8rem;
  color: var(--muted, #888);
}

@media (max-width: 520px) {
  .row,
  #user-form > .row { grid-template-columns: 1fr; }
}

/* ===== SSH console + SFTP ===== */

dialog.dialog--fill {
  max-width: min(1200px, calc(100vw - 1.5rem));
  width: min(1200px, calc(100vw - 1.5rem));
  max-height: calc(100vh - 1.5rem);
  height: calc(100vh - 1.5rem);
}

dialog.dialog--fill > .ssh-console,
dialog.dialog--fill > .sftp,
dialog.dialog--fill > .sftp-editor,
dialog.dialog--fill > .rdp-session {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: calc(100vh - 1.5rem);
  padding: 1rem 1.15rem 1.15rem;
  gap: .65rem;
}

dialog.dialog--ssh-console > .ssh-console,
dialog.dialog--sftp > .sftp,
dialog.dialog--sftp-editor > .sftp-editor {
  padding: .4rem .55rem .55rem;
  gap: .35rem;
}

/* RDP: почти на весь viewport, тонкая шапка */
dialog.dialog--rdp {
  max-width: calc(100vw - .5rem);
  width: calc(100vw - .5rem);
  max-height: calc(100vh - .5rem);
  height: calc(100vh - .5rem);
  padding: 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

dialog.dialog--rdp > .rdp-session {
  max-height: none;
  height: 100%;
  padding: .3rem .4rem .4rem;
  gap: .3rem;
  box-sizing: border-box;
}

.rdp-session {
  min-height: 0;
  overflow: hidden;
}

.rdp-session__bar {
  display: flex;
  align-items: center;
  gap: .35rem .45rem;
  flex-shrink: 0;
  min-height: 1.65rem;
}

.rdp-session__title {
  margin: 0;
  font-size: .88rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: min(40vw, 18rem);
  flex: 0 1 auto;
}

.rdp-session__status {
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

.rdp-session__bar-actions {
  display: inline-flex;
  align-items: center;
  gap: .1rem;
  margin-left: auto;
  flex-shrink: 0;
}

.rdp-session__bar-actions .icon-btn {
  width: 1.7rem;
  height: 1.7rem;
  font-size: .9rem;
}

/* Отдельное окно RDP (?rdp=…) */
html.rdp-popout,
html.rdp-popout body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

html.rdp-popout body {
  padding: 0;
  background: var(--bg, #0f1419);
}

html.rdp-popout #app-shell,
html.rdp-popout #pwa-install-page,
html.rdp-popout #browse-page {
  display: none !important;
}

html.rdp-popout #rdp-dialog {
  position: fixed;
  inset: 0;
  max-width: none;
  width: 100%;
  max-height: none;
  height: 100%;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
}

html.rdp-popout #rdp-dialog::backdrop {
  background: transparent;
}

html.rdp-popout #rdp-dialog > .rdp-session {
  height: 100%;
  max-height: none;
  padding: .25rem .35rem .35rem;
}

html.rdp-popout #rdp-popout {
  display: none;
}

html.rdp-popout .rdp-session__title {
  max-width: min(50vw, 22rem);
}

.danger-text { color: var(--danger) !important; }

.ssh-console {
  min-height: 0;
  overflow: hidden;
}

.ssh-console__bar {
  display: flex;
  align-items: center;
  gap: .4rem .5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 1.85rem;
}

.ssh-console__title {
  margin: 0;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 14rem;
  flex: 0 1 auto;
}

.ssh-console__status {
  font-size: .75rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.ssh-console__bar-actions {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  flex-shrink: 0;
}

.ssh-console__bar-actions .icon-btn {
  width: 1.75rem;
  height: 1.75rem;
  font-size: .95rem;
}

.ssh-console__cmd-add {
  padding: .15rem .45rem;
  font-size: .82rem;
  line-height: 1.2;
  min-width: 1.75rem;
}

.ssh-console__term {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 0;
}

/* Отдельное окно консоли (?ssh_console=…) */
html.ssh-console-popout,
html.ssh-console-popout body {
  height: 100%;
  overflow: hidden;
}
html.ssh-console-popout body {
  padding: 0;
  background: var(--bg, #0d1117);
}
html.ssh-console-popout #app-shell,
html.ssh-console-popout #pwa-install-page,
html.ssh-console-popout #browse-page {
  display: none !important;
}
html.ssh-console-popout #ssh-console-dialog {
  position: fixed;
  inset: 0;
  max-width: none;
  width: 100vw;
  max-height: none;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
}
html.ssh-console-popout #ssh-console-dialog::backdrop {
  background: var(--bg, #0d1117);
}
html.ssh-console-popout #ssh-console-dialog > .ssh-console {
  max-height: none;
  height: 100vh;
  padding: .35rem .45rem .45rem;
}
html.ssh-console-popout #ssh-console-popout {
  display: none !important;
}
html.ssh-console-popout .ssh-console__title {
  max-width: min(42vw, 24rem);
}

/* Отдельное окно SFTP (?ssh_sftp=…) */
html.ssh-sftp-popout,
html.ssh-sftp-popout body {
  height: 100%;
  overflow: hidden;
}
html.ssh-sftp-popout body {
  padding: 0;
  background: var(--bg, #0d1117);
}
html.ssh-sftp-popout #app-shell,
html.ssh-sftp-popout #pwa-install-page,
html.ssh-sftp-popout #browse-page {
  display: none !important;
}
html.ssh-sftp-popout #sftp-dialog {
  position: fixed;
  inset: 0;
  max-width: none;
  width: 100vw;
  max-height: none;
  height: 100vh;
  margin: 0;
  border: 0;
  border-radius: 0;
  padding: 0;
}
html.ssh-sftp-popout #sftp-dialog::backdrop {
  background: var(--bg, #0d1117);
}
html.ssh-sftp-popout #sftp-dialog > .sftp {
  max-height: none;
  height: 100vh;
  padding: .35rem .45rem .45rem;
}
html.ssh-sftp-popout #sftp-popout {
  display: none !important;
}
html.ssh-sftp-popout .sftp__title {
  max-width: min(42vw, 24rem);
}

/* Padding на .xterm — FitAddon вычитает его из высоты; на родителе — срезает последнюю строку. */
.ssh-console__term .xterm,
.sftp__console-term .xterm {
  width: 100%;
  height: 100%;
  padding: 4px 6px;
}

.rdp-session__body {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  gap: .35rem;
}

.rdp-session__display {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  background: #0a0c10;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  outline: none;
  /* Системный курсор скрыт — позиция идёт через оверлей Guacamole. */
  cursor: none;
}

/* Пока тянем файл — подсветка зоны сброса */
.rdp-session.is-drop-target .rdp-session__display {
  outline: 2px dashed var(--accent, #3b82f6);
  outline-offset: -4px;
}

.rdp-clipboard-proxy {
  position: fixed;
  left: 0;
  top: 0;
  width: 2px;
  height: 2px;
  opacity: 0;
  border: 0;
  padding: 0;
  margin: 0;
  resize: none;
  z-index: -1;
  overflow: hidden;
}

.rdp-files {
  flex: 0 0 200px;
  max-width: 36%;
  display: flex;
  flex-direction: column;
  gap: .4rem;
  min-height: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .4rem .5rem;
  background: var(--surface, #161b22);
}

.rdp-files__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .35rem;
  font-size: .9rem;
}

.rdp-files__upload {
  width: 100%;
}

.rdp-files__list {
  list-style: none;
  margin: 0;
  padding: 0;
  overflow: auto;
  flex: 1 1 auto;
  min-height: 0;
}

.rdp-files__list li {
  margin: 0;
}

.rdp-files__item {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: inherit;
  padding: .35rem .25rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font: inherit;
}

.rdp-files__item:hover:not(:disabled) {
  background: var(--hover, rgba(255, 255, 255, .06));
}

.rdp-files__item:disabled {
  opacity: .65;
  cursor: default;
}

/* Не задаём position/inset — Guacamole сам ставит width/height слоям. */
.rdp-session__guac {
  flex: 0 0 auto;
  line-height: 0;
  cursor: none;
}

.rdp-session__guac,
.rdp-session__guac * {
  cursor: none !important;
}

.rdp-session__guac canvas {
  image-rendering: auto;
}

.rdp-session:fullscreen,
.rdp-session:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  box-sizing: border-box;
  padding: .25rem .35rem .35rem;
  background: var(--bg, #0f1419);
}

.rdp-session:fullscreen .rdp-session__display,
.rdp-session:-webkit-full-screen .rdp-session__display {
  min-height: 0;
  border: 0;
}

.browse-session {
  min-height: 0;
  overflow: hidden;
}

.browse-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  flex-direction: column;
  background: var(--bg, #0d1117);
}

html.view-standalone #browse-page.is-open,
.browse-page.is-open {
  display: flex;
}

html.view-standalone,
html.view-standalone body {
  height: 100%;
  overflow: hidden;
}

html.view-standalone body {
  padding: 0;
}

html.view-standalone #app-shell {
  display: none !important;
}

.pwa-install-page {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 31;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  box-sizing: border-box;
  background: var(--bg, #0d1117);
}

html.view-standalone #pwa-install-page:not([hidden]) {
  display: flex;
}

.pwa-install-page__card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: min(22rem, 100%);
  padding: 1.75rem 1.5rem 1.35rem;
  text-align: center;
  background: var(--surface, #161b22);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-sizing: border-box;
}

.pwa-install-page__icon {
  width: 5.5rem;
  height: 5.5rem;
  object-fit: contain;
  border-radius: 1rem;
  background: var(--bg, #0d1117);
  border: 1px solid var(--border);
  flex: 0 0 auto;
}

.pwa-install-page__card h2 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.pwa-install-page__card .hint {
  margin: 0;
  line-height: 1.45;
}

.pwa-install-page__status:not([hidden]) {
  color: var(--accent, #58a6ff);
}

.pwa-install-page__actions {
  display: flex;
  flex-direction: column;
  gap: .55rem;
  width: 100%;
  margin-top: .15rem;
}

.pwa-install-page__actions button {
  width: 100%;
  margin: 0;
}

#browse-page > .browse-session {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  height: 100%;
  max-height: none;
  min-height: 0;
  padding: 0;
  gap: 0;
  box-sizing: border-box;
  position: relative;
}

.browse-session__bar {
  display: none !important;
}

.browse-session__title {
  flex: 0 1 auto;
  max-width: 11rem;
  margin: 0;
  font-size: .72rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browse-session__url {
  flex: 1 1 auto;
  min-width: 0;
  font-family: var(--mono, ui-monospace, monospace);
  font-size: .7rem;
  width: auto;
  height: 1.45rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 .4rem;
  background: var(--bg, #0d1117);
  color: var(--text-dim, #8b949e);
}

.browse-session__status {
  flex: 0 0 auto;
  font-size: .65rem;
  white-space: nowrap;
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.browse-session__bar .icon-btn {
  width: 1.55rem;
  height: 1.55rem;
  font-size: .9rem;
}

.browse-session__bar .icon-btn--close {
  font-size: 1.1rem;
}

.browse-install {
  flex: 0 0 auto;
  height: 1.45rem;
  padding: 0 .45rem;
  font-size: .65rem;
  line-height: 1;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg, #0d1117);
  color: var(--text, #e6edf3);
  cursor: pointer;
}

.sidebar__install.browse-install,
header .browse-install {
  height: auto;
  padding: .4rem .7rem;
  font-size: .8rem;
}

.browse-install:hover {
  border-color: var(--text-dim, #8b949e);
}

@media (display-mode: standalone) {
  .browse-install {
    display: none !important;
  }
}

.browse-session__display {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: #111;
  border: none;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  touch-action: none;
}

.browse-ctx {
  position: fixed;
  z-index: 80;
  margin: 0;
  padding: .25rem 0;
  list-style: none;
  min-width: 11.5rem;
  background: var(--surface, #161b22);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .45);
  color: var(--text);
  font-size: .82rem;
}

.browse-ctx li {
  padding: .32rem .9rem;
  cursor: pointer;
}

.browse-ctx li:hover {
  background: rgba(88, 166, 255, .15);
}

.browse-ctx__sep {
  height: 1px;
  padding: 0 !important;
  margin: .25rem 0;
  background: var(--border);
  cursor: default !important;
}

.browse-ctx__sep:hover {
  background: var(--border);
}

.browse-session__canvas {
  width: 100%;
  height: 100%;
  outline: none;
  cursor: default;
  background: #000;
  image-rendering: auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* Невидимое поле для soft-keyboard (iOS/Android). Не display:none — иначе клавиатура не откроется. */
.browse-kb {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 3;
  width: 100%;
  height: 2.5rem;
  margin: 0;
  padding: 0;
  border: 0;
  resize: none;
  opacity: 0.01;
  color: transparent;
  caret-color: transparent;
  background: transparent;
  font-size: 16px; /* без зума iOS при фокусе */
  line-height: 1.2;
  outline: none;
  pointer-events: none;
  -webkit-user-select: text;
  user-select: text;
}

.browse-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  box-sizing: border-box;
  text-align: center;
  font-size: .95rem;
  line-height: 1.4;
  color: var(--text, #e6edf3);
  background: rgba(13, 17, 23, .72);
  pointer-events: none;
}

.browse-overlay[hidden] {
  display: none !important;
}

.browse-overlay.is-error {
  color: #ffb4b0;
}

.browse-session:fullscreen,
.browse-session:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  max-height: none;
  box-sizing: border-box;
  padding: 0;
  background: var(--bg, #0f1419);
}

.browse-session:fullscreen .browse-session__display,
.browse-session:-webkit-full-screen .browse-session__display {
  min-height: 0;
  border-radius: 0;
}

.sftp__bar {
  display: flex;
  align-items: center;
  gap: .35rem .45rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 1.85rem;
}

.sftp__title {
  margin: 0;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 12rem;
  flex: 0 1 auto;
}

.sftp__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .2rem;
  align-items: center;
  flex: 1 1 auto;
  min-width: 0;
}

.sftp__toolbar .icon-btn {
  width: 1.75rem;
  height: 1.75rem;
  font-size: .95rem;
  flex-shrink: 0;
}

.sftp__bar-actions {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  flex-shrink: 0;
}

.sftp__bar-actions .icon-btn {
  width: 1.75rem;
  height: 1.75rem;
  font-size: .95rem;
}

.sftp__path-form {
  flex: 1 1 10rem;
  min-width: 6rem;
  max-width: 28rem;
}

.sftp__path-form input {
  width: 100%;
  height: 1.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 0 .5rem;
  font-family: var(--mono);
  font-size: .82rem;
}

.sftp__crumbs {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .15rem .1rem;
  flex-shrink: 0;
  min-height: 1.35rem;
  font-family: var(--mono);
  font-size: .78rem;
}

.sftp__crumb {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  max-width: 12rem;
}

.sftp__crumb-btn {
  background: transparent;
  border: 0;
  color: var(--accent);
  padding: .1rem .3rem;
  border-radius: 4px;
  font: inherit;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 11rem;
}

.sftp__crumb-btn:hover {
  background: rgba(88, 166, 255, .12);
}

.sftp__crumb-btn.is-current {
  color: var(--text);
  cursor: default;
  font-weight: 600;
}

.sftp__crumb-btn.is-current:hover {
  background: transparent;
}

.sftp__crumb-sep {
  color: var(--text-dim);
  user-select: none;
  padding: 0 .05rem;
}

.sftp__body {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(160px, 220px) 1fr;
  gap: .45rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.sftp__empty {
  margin: 1.25rem 1rem;
  color: var(--text-dim);
  font-size: .9rem;
  text-align: center;
}

.sftp__name-btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  font-family: var(--mono);
  padding: 0;
  cursor: pointer;
  text-align: left;
}

.sftp__name-btn:hover {
  color: var(--accent);
}

.sftp__name-btn.is-dir {
  font-weight: 600;
}

.sftp__name-icon {
  flex-shrink: 0;
  opacity: .9;
}

.sftp__name-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sftp__tree-row {
  display: flex;
  align-items: stretch;
  width: 100%;
}

.sftp__tree-toggle {
  flex: 0 0 1.4rem;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .7rem;
  padding: 0;
}

.sftp__tree-toggle:hover {
  color: var(--accent);
}

.sftp__tree-label {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .3rem .45rem .3rem 0;
  font-size: .85rem;
  cursor: pointer;
  font-family: var(--mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sftp__tree-label:hover {
  color: var(--accent);
}

.sftp__tree-row.is-active .sftp__tree-label {
  color: var(--accent);
  font-weight: 600;
}

.sftp__console {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: .35rem;
  min-height: 0;
}

.sftp__console-bar {
  display: flex;
  align-items: center;
  gap: .45rem .65rem;
  flex-wrap: wrap;
  min-height: 1.4rem;
}

.sftp__console-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text-dim);
}

.sftp__follow {
  margin-left: auto;
  margin-bottom: 0;
  font-size: .75rem;
  color: var(--text-dim);
  gap: .35rem;
}

.sftp__console-term {
  height: min(28vh, 240px);
  min-height: 140px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  padding: 0;
}

.sftp__sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.sftp__favs {
  flex: 0 0 auto;
  border-bottom: 1px solid var(--border);
  padding: .4rem 0 .35rem;
}

.sftp__favs-head {
  padding: 0 .55rem .25rem;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.sftp__favs-list {
  display: flex;
  flex-direction: column;
  gap: .1rem;
  max-height: 9rem;
  overflow: auto;
}

.sftp__favs-empty {
  padding: .2rem .55rem .35rem;
  font-size: .8rem;
  color: var(--text-dim);
}

.sftp__fav-item {
  display: flex;
  align-items: stretch;
  gap: .15rem;
  padding: 0 .25rem 0 .35rem;
}

.sftp__fav-item.is-active .sftp__fav-go {
  background: rgba(88, 166, 255, .16);
  color: var(--accent);
}

.sftp__fav-go {
  flex: 1 1 auto;
  min-width: 0;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .28rem .4rem;
  font-size: .82rem;
  cursor: pointer;
  font-family: var(--mono);
  border-radius: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sftp__fav-go:hover { background: rgba(88, 166, 255, .08); }

.sftp__fav-del {
  flex: 0 0 auto;
  width: 1.6rem;
  background: transparent;
  border: 0;
  color: var(--text-dim);
  cursor: pointer;
  border-radius: 6px;
  font-size: .95rem;
  line-height: 1;
}

.sftp__fav-del:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, .1);
}

.sftp__tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: .35rem 0;
}

.sftp__tree-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .3rem .5rem;
  font-size: .85rem;
  cursor: pointer;
  font-family: var(--mono);
}
.sftp__tree-item:hover,
.sftp__tree-row:hover {
  background: rgba(88, 166, 255, .08);
}
.sftp__tree-item.is-active,
.sftp__tree-row.is-active {
  background: rgba(88, 166, 255, .16);
}

.ssh-console__cmds {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.ssh-console__cmds-list {
  display: flex;
  flex-wrap: wrap;
  gap: .25rem;
  flex: 1 1 auto;
  min-width: 0;
}

.ssh-console__cmd {
  display: inline-flex;
  align-items: stretch;
  max-width: 100%;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  overflow: hidden;
}

.ssh-console__cmd.is-editing {
  border-color: var(--accent);
}

.ssh-console__cmd.is-pending-delete {
  border-color: var(--danger);
}

.ssh-console__cmd-run {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .18rem .45rem;
  font: inherit;
  font-size: .78rem;
  cursor: pointer;
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ssh-console__cmd-run:hover {
  background: rgba(88, 166, 255, .1);
  color: var(--accent);
}

.ssh-console__cmd-edit,
.ssh-console__cmd-del {
  background: transparent;
  border: 0;
  border-left: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0 .4rem;
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
}

.ssh-console__cmd-edit:hover {
  color: var(--accent);
  background: rgba(88, 166, 255, .1);
}

.ssh-console__cmd-del:hover,
.ssh-console__cmd.is-pending-delete .ssh-console__cmd-del {
  color: var(--danger);
  background: rgba(248, 81, 73, .1);
}

.ssh-console__cmd-form {
  display: flex;
  flex-direction: column;
  gap: .45rem;
  margin: 0;
  padding: .55rem .65rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  flex-shrink: 0;
}

.ssh-console__cmd-form[hidden] {
  display: none !important;
}

.ssh-console__cmd-form .field {
  margin-bottom: 0;
}

.ssh-console__cmd-form-hint {
  margin: 0;
}

.ssh-console__cmd-form textarea {
  font-family: var(--mono);
  resize: vertical;
  min-height: 4.2rem;
}

.ssh-console__cmd-form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem;
}

.sftp__main {
  overflow: auto;
  min-width: 0;
}
.sftp__main.is-drop {
  outline: 2px dashed var(--accent);
  outline-offset: -4px;
}

.sftp__table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.sftp__table th,
.sftp__table td {
  padding: .4rem .55rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.sftp__table th {
  position: sticky;
  top: 0;
  background: var(--surface);
  color: var(--text-dim);
  font-weight: 600;
  z-index: 1;
}
.sftp__table tr.is-selected td {
  background: rgba(88, 166, 255, .12);
}
.sftp__table tbody tr:hover td {
  background: rgba(88, 166, 255, .06);
}
.sftp__name { font-family: var(--mono); }
.sftp__check { width: 2rem; }

.sftp__ctx {
  position: fixed;
  z-index: 10000;
  margin: 0;
  padding: .35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: 0 8px 28px rgba(0, 0, 0, .45);
  display: flex;
  flex-direction: column;
  min-width: 11rem;
}
.sftp__ctx[hidden] { display: none !important; }
.sftp__ctx button {
  background: transparent;
  border: 0;
  color: var(--text);
  text-align: left;
  padding: .4rem .55rem;
  border-radius: 6px;
  cursor: pointer;
  font: inherit;
}
.sftp__ctx button:hover { background: rgba(88, 166, 255, .12); }

.sftp-editor {
  min-height: 0;
  overflow: hidden;
}

.sftp-editor__bar {
  display: flex;
  align-items: center;
  gap: .4rem .5rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  min-height: 1.85rem;
}

.sftp-editor__title {
  margin: 0;
  font-size: .92rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  flex: 0 0 auto;
}

.sftp-editor__path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--mono);
  font-size: .78rem;
}

.sftp-editor__bar-actions {
  display: inline-flex;
  align-items: center;
  gap: .15rem;
  margin-left: auto;
  flex-shrink: 0;
}

.sftp-editor__bar-actions .icon-btn {
  width: 1.75rem;
  height: 1.75rem;
  font-size: .95rem;
}

.sftp-editor__body {
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(180px, 240px) 1fr;
  gap: .4rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--surface-2);
}

.sftp-editor__sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
  border-right: 1px solid var(--border);
  background: var(--surface);
  overflow: hidden;
}

.sftp-editor__crumbs {
  padding: .35rem .4rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sftp-editor__tree {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  padding: .25rem 0;
}

.sftp-editor__tree-item {
  display: flex;
  align-items: center;
  gap: .35rem;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .28rem .55rem;
  font-size: .82rem;
  cursor: pointer;
  font-family: var(--mono);
}

.sftp-editor__tree-item:hover {
  background: rgba(88, 166, 255, .08);
  color: var(--accent);
}

.sftp-editor__tree-item.is-active {
  background: rgba(88, 166, 255, .16);
  color: var(--accent);
  font-weight: 600;
}

.sftp-editor__tree-item.is-dir {
  font-weight: 600;
}

.sftp-editor__tree-empty {
  padding: .55rem .65rem;
  color: var(--text-dim);
  font-size: .8rem;
}

.sftp-editor__main {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.sftp-editor__tabs {
  display: flex;
  flex-wrap: nowrap;
  gap: 0;
  overflow-x: auto;
  flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  min-height: 2rem;
}

.sftp-editor__tab {
  display: inline-flex;
  align-items: center;
  gap: .2rem;
  max-width: 14rem;
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  border-right: 1px solid var(--border);
  color: var(--text-dim);
  padding: 0;
  font: inherit;
  font-size: .8rem;
  cursor: pointer;
  position: relative;
}

.sftp-editor__tab:hover {
  background: rgba(88, 166, 255, .06);
  color: var(--text);
}

.sftp-editor__tab.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.sftp-editor__tab.is-active::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 2px;
  background: var(--accent);
}

.sftp-editor__tab-label {
  padding: .4rem .15rem .4rem .65rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 10rem;
}

.sftp-editor__tab.is-dirty .sftp-editor__tab-label::before {
  content: '• ';
  color: var(--accent);
}

.sftp-editor__tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.35rem;
  height: 1.35rem;
  margin-right: .25rem;
  border: 0;
  border-radius: 4px;
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  font-size: .85rem;
  line-height: 1;
  flex-shrink: 0;
}

.sftp-editor__tab-close:hover,
.sftp-editor__tab.is-pending-close .sftp-editor__tab-close {
  color: var(--danger);
  background: rgba(248, 81, 73, .12);
}

.sftp-editor__monaco {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

@media (max-width: 720px) {
  .sftp-editor__body {
    grid-template-columns: 1fr;
  }
  .sftp-editor__sidebar {
    max-height: 160px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 800px) {
  .sftp__body { grid-template-columns: 1fr; }
  .sftp__sidebar {
    max-height: 200px;
    border-right: 0;
    border-bottom: 1px solid var(--border);
  }
}
