:root {
  --navy: #082738;
  --teal: #0f4e70;
  --accent: #1777ab;
  --accent-hover: #1a8ac4;
  --orange: #e28436;
  --label: #1777ab;
  --text: #1a1a1a;
  --muted: #5b6b73;
  --line: #d8dee3;
  --bg: #ffffff;
  --status: #f3f3f3;
  --row: #f6f7f8;
  --select: #c5dcea;
  --danger: #b42318;
  --shadow: 0 8px 28px rgba(8, 39, 56, 0.22);
  --chrome-fg: #d7e6ee;
  --input-bg: #ffffff;
  --input-border: #1777ab;
  --footer-bg: #ffffff;
  --footer-line: #cfcfcf;
  --tile-border: #d3dde3;
  --dialog-bg: #ffffff;
  --dialog-border: #9aa4ab;
  --overlay: rgba(20, 28, 34, 0.28);
  --cfg-nav: #f4f6f7;
  --cfg-active: #d5e6f0;
  --hover-row: #f4f8fb;
  --ctx-bg: #ffffff;
  --ctx-hover: #e8f2f8;
  --term-bg: #0b0f12;
  --sftp-bg: #ffffff;
  --pane-nav: #333333;
  --focus-ring: rgba(23, 119, 171, 0.18);
  --btn-bg: #1777ab;
  --btn-text: #ffffff;
  --ghost-bg: #ffffff;
  --ghost-hover: #f3f9fc;
  --tab-active-bg: #0f4e70;
  --tab-active-fg: #ffffff;
  --menu-bg: #0f4e70;
  --menu-fg: #ffffff;
  --menu-sep: rgba(255, 255, 255, 0.15);
  --nav-hover: #eef3f6;
  --font: "Segoe UI", "Ubuntu", "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", "Ubuntu Mono", "Consolas", "Liberation Mono", monospace;
  --radius: 3px;
}

/* Core — Grau / Grün (searchwiki / mycoredesk) */
html[data-theme="core"] {
  --navy: #0a0d0a;
  --teal: #111710;
  --accent: #a2dc02;
  --accent-hover: #c2ff3a;
  --orange: #c2ff3a;
  --label: #a2dc02;
  --text: #e9f1e4;
  --muted: #8fa085;
  --line: #1e281a;
  --bg: #0c110b;
  --status: #111710;
  --row: #0e140d;
  --select: #1e3a12;
  --danger: #ff6b6b;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.5);
  --chrome-fg: #c8dcc0;
  --input-bg: #111710;
  --input-border: #2b3a24;
  --footer-bg: #0a0d0a;
  --footer-line: #1e281a;
  --tile-border: #1e281a;
  --dialog-bg: #111710;
  --dialog-border: #2b3a24;
  --overlay: rgba(4, 8, 4, 0.62);
  --cfg-nav: #0a0d0a;
  --cfg-active: #1a2a12;
  --hover-row: #151d13;
  --ctx-bg: #111710;
  --ctx-hover: #1a2a12;
  --term-bg: #070907;
  --sftp-bg: #0c110b;
  --pane-nav: #e9f1e4;
  --focus-ring: rgba(162, 220, 2, 0.22);
  --btn-bg: #a2dc02;
  --btn-text: #081007;
  --ghost-bg: transparent;
  --ghost-hover: #151d13;
  --tab-active-bg: #a2dc02;
  --tab-active-fg: #081007;
  --menu-bg: #151d13;
  --menu-fg: #e9f1e4;
  --menu-sep: rgba(162, 220, 2, 0.22);
  --nav-hover: #151d13;
}

/* Alphacore — Navy / Azure / Cyan / Violet */
html[data-theme="alphacore"] {
  --navy: #05081a;
  --teal: #0a1030;
  --accent: #4f7cff;
  --accent-hover: #22d3ee;
  --orange: #a855f7;
  --label: #22d3ee;
  --text: #e9edfb;
  --muted: #9aa6cc;
  --line: #1a2250;
  --bg: #070b24;
  --status: #0a1030;
  --row: #0b1030;
  --select: #1a2870;
  --danger: #ff8a8a;
  --shadow: 0 8px 28px rgba(79, 124, 255, 0.22);
  --chrome-fg: #c8d0ee;
  --input-bg: #0b1030;
  --input-border: rgba(255, 255, 255, 0.16);
  --footer-bg: #05081a;
  --footer-line: #1a2250;
  --tile-border: rgba(255, 255, 255, 0.09);
  --dialog-bg: #0b1030;
  --dialog-border: rgba(255, 255, 255, 0.16);
  --overlay: rgba(5, 8, 26, 0.7);
  --cfg-nav: #05081a;
  --cfg-active: #1a2870;
  --hover-row: #0e1440;
  --ctx-bg: #0b1030;
  --ctx-hover: #0e1440;
  --term-bg: #05081a;
  --sftp-bg: #070b24;
  --pane-nav: #e9edfb;
  --focus-ring: rgba(79, 124, 255, 0.28);
  --btn-bg: linear-gradient(135deg, #4f7cff 0%, #a855f7 100%);
  --btn-text: #ffffff;
  --ghost-bg: transparent;
  --ghost-hover: #0e1440;
  --tab-active-bg: linear-gradient(135deg, #4f7cff 0%, #a855f7 100%);
  --tab-active-fg: #ffffff;
  --menu-bg: #0e1440;
  --menu-fg: #e9edfb;
  --menu-sep: rgba(255, 255, 255, 0.12);
  --nav-hover: #0e1440;
  --font: "Space Grotesk", "Inter", "Segoe UI", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--font);
  color: var(--text);
  background: #1b1b1b;
  overflow: hidden;
}
html[data-theme="core"] body { background: #050705; }
html[data-theme="alphacore"] body { background: #030510; }

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg);
}

/* title / tab chrome */
.chrome {
  background: var(--navy);
  min-height: 56px;
  display: flex;
  align-items: flex-end;
  padding: 0 8px 0 10px;
  gap: 4px;
  user-select: none;
  position: relative;
}
html[data-theme="alphacore"] .chrome {
  box-shadow: inset 0 -1px 0 rgba(79, 124, 255, 0.28);
}
.brand {
  display: none;
}
.tabs {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  flex: 0 1 auto;
  min-width: 0;
  overflow-x: auto;
  padding-top: 10px;
}
.tab {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  color: var(--chrome-fg);
  border: 0;
  border-radius: 10px 10px 0 0;
  padding: 9px 14px 10px;
  font: 600 13.5px/1 var(--font);
  cursor: pointer;
  white-space: nowrap;
  max-width: 280px;
}
.tab.active {
  background: var(--tab-active-bg);
  color: var(--tab-active-fg);
}
.tab .x {
  opacity: 0.7;
  font-weight: 400;
  font-size: 15px;
  padding: 0 2px;
}
.tab .x:hover { opacity: 1; }
.tab-add {
  color: var(--chrome-fg);
  background: transparent;
  border: 0;
  font-size: 22px;
  width: 34px;
  height: 36px;
  cursor: pointer;
  margin-bottom: 4px;
  flex: 0 0 auto;
}
.tab-add:hover { color: #fff; }
.chrome-spacer { flex: 1; }
.chrome-right {
  display: flex;
  align-items: center;
  height: 56px;
  padding-bottom: 6px;
  gap: 8px;
}
.icon-btn {
  background: transparent;
  border: 0;
  color: var(--chrome-fg);
  width: 36px;
  height: 36px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 20px;
  letter-spacing: 1px;
}
.icon-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }

.theme-switch {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-right: 4px;
}
.theme-switch .swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.28);
  padding: 0;
  cursor: pointer;
  background: none;
}
.theme-switch .swatch:hover { transform: scale(1.12); }
.theme-switch .swatch.active {
  border-color: #fff;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.22);
}
.theme-switch .swatch[data-theme="tectia"] {
  background: linear-gradient(135deg, #082738 48%, #1777ab 52%);
}
.theme-switch .swatch[data-theme="core"] {
  background: linear-gradient(135deg, #111710 48%, #a2dc02 52%);
}
.theme-switch .swatch[data-theme="alphacore"] {
  background: linear-gradient(135deg, #4f7cff 48%, #a855f7 52%);
}

.subnav {
  background: var(--teal);
  color: #fff;
  display: flex;
  align-items: flex-end;
  gap: 28px;
  padding: 0 22px;
  min-height: 38px;
  font-weight: 600;
  font-size: 14.5px;
}
html[data-theme="core"] .subnav { color: var(--text); }
.subnav button {
  background: none;
  border: 0;
  color: inherit;
  font: inherit;
  padding: 10px 2px 8px;
  cursor: pointer;
  position: relative;
}
.subnav button.active::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: 3px;
  background: var(--orange);
  border-radius: 2px 2px 0 0;
}

.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.page { display: none; flex: 1; min-height: 0; flex-direction: column; }
.page.active { display: flex; }

/* Quick Connect */
.qc-wrap {
  flex: 1;
  padding: 28px 36px 16px;
  overflow: auto;
}
.form-row { display: flex; gap: 28px; max-width: 760px; }
.field { margin: 0 0 18px; }
.field label {
  display: block;
  color: var(--label);
  font-weight: 600;
  font-size: 14.5px;
  margin-bottom: 6px;
}
.field input[type="text"],
.field input[type="number"],
.field input[type="password"],
.field select {
  width: 100%;
  height: 36px;
  border: 1.5px solid var(--input-border);
  border-radius: 2px;
  padding: 4px 10px;
  font: 15px var(--font);
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}
.field input:focus, .field select:focus { box-shadow: 0 0 0 2px var(--focus-ring); }
.field.host { flex: 1; min-width: 280px; }
.field.port { width: 160px; flex: 0 0 160px; }
.field.user, .field.auth { max-width: 420px; }
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0 16px;
  font-size: 14.5px;
}
.check input { width: 16px; height: 16px; accent-color: var(--accent); }
.radios { margin-top: 4px; }
.radios .caption {
  font-size: 14.5px;
  margin-bottom: 8px;
}
.radio {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0;
  font-size: 14.5px;
}
.radio input { accent-color: var(--accent); width: 16px; height: 16px; }

.footer {
  border-top: 1px solid var(--footer-line);
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 18px;
  background: var(--footer-bg);
  gap: 12px;
}
.footer .left {
  color: var(--text);
  font-size: 13.5px;
}
.btn {
  background: var(--btn-bg);
  color: var(--btn-text);
  border: 0;
  border-radius: var(--radius);
  padding: 8px 22px;
  font: 600 14px var(--font);
  cursor: pointer;
  min-width: 108px;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.ghost {
  background: var(--ghost-bg);
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn.ghost:hover { background: var(--ghost-hover); filter: none; }
.btn.danger { background: var(--danger); color: #fff; }
.conn-menu-wrap { position: relative; }
.conn-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--ghost-bg);
  color: var(--accent);
  border: 1.5px solid var(--accent);
  border-radius: var(--radius);
  padding: 7px 14px;
  font: 600 13.5px var(--font);
  cursor: pointer;
}
.conn-toggle::after { content: "▾"; font-size: 11px; }

/* tiles */
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
  padding: 24px 28px;
  overflow: auto;
}
.tile {
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  padding: 16px 16px 14px;
  background: var(--bg);
  cursor: pointer;
  position: relative;
  box-shadow: 0 1px 0 rgba(8,39,56,0.04);
}
.tile:hover { border-color: var(--accent); box-shadow: 0 4px 14px var(--focus-ring); }
.tile h3 { margin: 0 28px 6px 0; font-size: 16px; color: var(--text); }
.tile p { margin: 0; color: var(--muted); font-size: 13px; }
.tile .more {
  position: absolute; top: 8px; right: 6px;
  background: none; border: 0; cursor: pointer; color: var(--accent); font-size: 20px;
}
.empty {
  color: var(--muted);
  padding: 48px 32px;
  font-size: 14.5px;
}

/* recent list */
.recent {
  padding: 8px 0;
  overflow: auto;
}
.recent-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 28px;
  cursor: pointer;
  border-bottom: 1px solid var(--line);
}
.recent-item:hover { background: var(--hover-row); }
.recent-item .dot {
  width: 10px; height: 10px; border-radius: 50%; background: var(--accent);
}
.recent-item .meta { color: var(--muted); font-size: 12.5px; }
.recent-item strong { display: block; font-size: 14.5px; }

/* terminal */
.term-page { background: var(--term-bg); height: 100%; }
.term-host { flex: 1; min-height: 0; height: 100%; padding: 4px 6px 0; position: relative; }
.term-host .xterm, .term-host .xterm-screen { height: 100%; }
.xterm-viewport { overflow-y: auto !important; }
.xterm-helper-textarea {
  opacity: 0 !important;
}
.xterm-accessibility,
.xterm-accessibility-tree {
  position: absolute !important;
  left: -9999px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  opacity: 0 !important;
}

/* SFTP */
.sftp {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: var(--sftp-bg);
}
.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.pane:last-child { border-right: 0; }
.pane-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 10px 6px;
}
.pane-bar .nav {
  background: none; border: 0; cursor: pointer; color: var(--pane-nav);
  width: 26px; height: 26px; border-radius: 3px; font-size: 15px;
}
.pane-bar .nav:hover { background: var(--nav-hover); }
.pane-bar .nav svg { display: block; margin: auto; }
.pane-bar input {
  flex: 1;
  height: 30px;
  border: 1.4px solid var(--input-border);
  border-radius: 3px;
  padding: 0 10px;
  font: 13.5px var(--font);
  outline: none;
  background: var(--input-bg);
  color: var(--text);
}
.pane-tools { display: flex; gap: 2px; }
.list-head, .row {
  display: grid;
  grid-template-columns: 1fr 88px 120px;
  gap: 8px;
  align-items: center;
  padding: 3px 12px;
  font-size: 13px;
}
.list-head {
  color: var(--text);
  font-weight: 600;
  border-bottom: 1px solid var(--line);
  padding-top: 4px;
  padding-bottom: 5px;
}
.list-head span:first-child { display: inline-flex; align-items: center; gap: 4px; }
.rows {
  flex: 1;
  overflow: auto;
  user-select: none;
}
.row { min-height: 24px; cursor: default; }
.row:nth-child(even) { background: var(--row); }
.row.selected { background: var(--select) !important; }
.row .name { display: flex; align-items: center; gap: 7px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row .size, .row .mtime { color: var(--text); text-align: left; white-space: nowrap; }
.ico { width: 14px; height: 14px; flex: 0 0 14px; }
.filter {
  display: none;
}

/* dialogs */
.overlay {
  position: fixed; inset: 0;
  background: var(--overlay);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
}
.overlay.show { display: flex; }
.dialog {
  background: var(--dialog-bg);
  color: var(--text);
  min-width: 420px;
  max-width: 560px;
  width: min(560px, calc(100vw - 32px));
  border: 1px solid var(--dialog-border);
  box-shadow: var(--shadow);
  border-radius: 2px;
}
.dialog.wide { max-width: 860px; width: min(860px, calc(100vw - 32px)); min-width: 640px; }
.dialog-title {
  background: var(--dialog-bg);
  padding: 10px 14px 8px;
  font-size: 13px;
  font-weight: 600;
  border-bottom: 1px solid var(--line);
}
.dialog-body { padding: 14px 18px 8px; font-size: 13.5px; line-height: 1.45; }
.dialog-body p { margin: 0 0 10px; }
.dialog-body code, .dialog-body .mono { font-family: var(--mono); font-size: 12.5px; word-break: break-all; }
.dialog-body .hint { color: var(--muted); font-size: 12.5px; margin: 12px 0 8px; }
.choices label { display: flex; gap: 8px; align-items: flex-start; margin: 6px 0; }
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 12px 14px 14px;
}
.dialog input[type="text"],
.dialog input[type="password"],
.dialog input[type="number"],
.dialog select,
.dialog textarea {
  width: 100%;
  height: 32px;
  border: 1px solid var(--input-border);
  padding: 4px 8px;
  font: 13.5px var(--font);
  margin: 4px 0 10px;
  background: var(--input-bg);
  color: var(--text);
}
.dialog textarea { height: 72px; resize: vertical; }

/* menus */
.menu {
  position: absolute;
  background: var(--menu-bg);
  color: var(--menu-fg);
  min-width: 200px;
  padding: 8px 0;
  box-shadow: var(--shadow);
  z-index: 50;
  display: none;
}
.menu.show { display: block; }
.menu button {
  display: block;
  width: 100%;
  text-align: left;
  background: none;
  border: 0;
  color: var(--menu-fg);
  font: 600 13.5px var(--font);
  padding: 8px 18px;
  cursor: pointer;
}
.menu button:hover { background: rgba(255,255,255,0.08); }
html[data-theme="core"] .menu button:hover { background: rgba(162, 220, 2, 0.12); }
.menu .sep { height: 1px; background: var(--menu-sep); margin: 6px 0; }
.ctx {
  position: fixed;
  background: var(--ctx-bg);
  border: 1px solid var(--dialog-border);
  box-shadow: 0 6px 18px rgba(0,0,0,0.16);
  min-width: 180px;
  z-index: 60;
  padding: 4px 0;
  display: none;
  color: var(--text);
}
.ctx.show { display: block; }
.ctx button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 6px 16px;
  font: 13.5px var(--font); cursor: pointer; color: var(--text);
}
.ctx button:hover { background: var(--ctx-hover); }
.ctx .sep { height: 1px; background: var(--line); margin: 4px 0; }

/* configuration */
.cfg {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 520px;
  max-height: 78vh;
}
.cfg-nav {
  background: var(--cfg-nav);
  border-right: 1px solid var(--line);
  padding: 10px 0;
  overflow: auto;
}
.cfg-nav button {
  display: block; width: 100%; text-align: left;
  background: none; border: 0; padding: 8px 16px;
  font: 13.5px var(--font); cursor: pointer; color: var(--text);
}
.cfg-nav button.active { background: var(--cfg-active); color: var(--text); font-weight: 600; }
.cfg-pane { padding: 16px 20px; overflow: auto; }
.cfg-pane h3 { margin: 0 0 12px; font-size: 16px; color: var(--text); }
.cfg-pane h4 { margin: 16px 0 8px; font-size: 13.5px; color: var(--accent); }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 8px 12px; align-items: center; margin-bottom: 8px; }
.kv label { font-size: 13px; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th, .table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.table tr:hover td { background: var(--hover-row); }

.toast {
  position: fixed;
  bottom: 70px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--navy);
  color: #fff;
  padding: 8px 16px;
  border-radius: 4px;
  font-size: 13px;
  display: none;
  z-index: 80;
}
html[data-theme="core"] .toast { color: var(--btn-text); background: var(--accent); }
.toast.show { display: block; }

.props-preview {
  margin-top: 10px;
  background: var(--row);
  min-height: 140px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
  max-height: 240px;
}
.props-preview pre {
  margin: 0; padding: 10px; width: 100%;
  font: 11.5px var(--mono); white-space: pre-wrap;
}
.props-preview img { max-width: 180px; max-height: 180px; }
.perms { display: grid; grid-template-columns: 70px repeat(3, 1fr); gap: 4px 8px; align-items: center; font-size: 13px; margin: 8px 0; }

.auth-btn {
  background: transparent;
  color: var(--chrome-fg);
  border: 1.5px solid rgba(255, 255, 255, 0.38);
  border-radius: 3px;
  padding: 0 12px;
  height: 32px;
  font: 600 12.5px var(--font);
  cursor: pointer;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.auth-btn:hover { color: #fff; border-color: #fff; }
.auth-btn.in {
  border-color: var(--accent);
  color: #fff;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin: 0 0 12px;
  border-bottom: 1px solid var(--line);
}
.auth-tabs button {
  flex: 1;
  background: none;
  border: 0;
  border-bottom: 3px solid transparent;
  color: var(--muted);
  font: 600 13.5px var(--font);
  padding: 8px 6px 10px;
  cursor: pointer;
}
.auth-tabs button.active { color: var(--text); border-bottom-color: var(--accent); }
.form-err {
  display: none;
  background: rgba(180, 35, 24, 0.12);
  color: var(--danger);
  border: 1px solid var(--danger);
  border-radius: 4px;
  padding: 8px 10px;
  font-size: 13px;
  margin-bottom: 10px;
}
.form-err.show { display: block; }
.users-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.users-add {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto auto;
  gap: 8px;
  align-items: end;
  margin: 12px 0 4px;
}
.users-add .field { margin: 0; }
.btn.tiny { font-size: 12px; padding: 4px 8px; min-width: 0; }

.hidden { display: none !important; }
