/* ===== 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;
  padding: 2rem;
  line-height: 1.45;
}

header {
  max-width: 1100px;
  margin: 0 auto 2rem;
}
header h1 { font-size: 1.8rem; font-weight: 600; letter-spacing: -0.02em; }

.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;
}

main { max-width: 1100px; margin: 0 auto; }

/* ===== 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);
}

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(220px, 1fr));
  gap: 1rem;
}

.tile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  transition: border-color .15s;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  position: relative;
}
.tile:hover { border-color: var(--accent); }

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

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

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

.tile__icon {
  flex: 0 0 2.5rem;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 8px;
  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: .2rem;
}

.tile__icon-fallback {
  font-size: 1rem;
  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: .8rem;
  color: var(--text-dim);
  word-break: break-all;
}

.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__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: 2.5rem; }
.dash-section--hosts {
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.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__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;
}

.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 {
  font-size: .85rem;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: .35rem .8rem;
  background: var(--surface);
}

.dialog-wide { width: 100%; }
dialog.dialog--wide,
#users-dialog {
  max-width: 560px;
  width: min(560px, calc(100vw - 2rem));
}

.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: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}
.passkey-login .primary { width: 100%; }
.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) {
  body { padding: 1rem; }
  .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;
}

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

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

.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;
}

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

.rdp-session__display {
  flex: 1 1 auto;
  min-height: 360px;
  height: 100%;
  background: #111;
  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;
}

/* Не задаём 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: .75rem 1rem 1rem;
  background: var(--bg, #0f1419);
}

.rdp-session:fullscreen .rdp-session__display,
.rdp-session:-webkit-full-screen .rdp-session__display {
  min-height: 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,
html.view-standalone body {
  height: 100%;
  overflow: hidden;
}

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

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

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

#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;
}

.browse-session__bar {
  display: flex;
  align-items: center;
  gap: .25rem;
  flex: 0 0 auto;
  min-height: 1.85rem;
  padding: .15rem .3rem .15rem .45rem;
  background: var(--surface, #161b22);
  border-bottom: 1px solid var(--border);
}

.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-session__display {
  flex: 1 1 auto;
  min-height: 0;
  background: #111;
  border: none;
  border-radius: 0;
  overflow: hidden;
  display: flex;
  align-items: stretch;
  justify-content: stretch;
}

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

.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__toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  align-items: center;
}

.sftp__path-form {
  flex: 1 1 12rem;
  min-width: 8rem;
}

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

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

.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: .75rem;
  flex-wrap: wrap;
}

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

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

.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 { background: rgba(88, 166, 255, .08); }
.sftp__tree-item.is-active {
  background: rgba(88, 166, 255, .16);
  color: var(--accent);
}

.ssh-console__cmds {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .35rem;
}

.ssh-console__cmds-list {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  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-run {
  background: transparent;
  border: 0;
  color: var(--text);
  padding: .28rem .55rem;
  font: inherit;
  font-size: .82rem;
  cursor: pointer;
  max-width: 16rem;
  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-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-del:hover {
  color: var(--danger);
  background: rgba(248, 81, 73, .1);
}

.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__monaco {
  flex: 1;
  min-height: 320px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

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