/* ==========================================================================
   TConnect visual identity — "emerald ink & aurora"
   Signature look: a deep emerald-ink floating sidebar + ink monitor bar over
   a light aurora workspace of floating rounded panels. Not-a-clone by design.
   ========================================================================== */

/* ===== Day (aurora) mode — DEFAULT ===== */
:root {
  --bg: #eef5f1;            /* input/well surface */
  --bg-solid: #eaf3ee;      /* page base under the aurora */
  --term-bg: #ffffff;
  --panel: #ffffff;         /* floating panels/cards */
  --panel2: #f3f8f5;
  --border: #e0eae4;
  --text: #0d1f17;
  --muted: #5f7569;
  --accent: #10b981;        /* emerald */
  --accent-hover: #12d093;
  --accent2: #06b6d4;       /* cyan */
  --grad: linear-gradient(135deg, #10b981, #06b6d4);
  --danger: #e5484d;
  --ok: #16a34a;
  --warn: #c98a00;
  --glowA: rgba(16,185,129,.16);
  --glowB: rgba(6,182,212,.13);
  --glowC: rgba(163,230,53,.10);
  --shadow: 0 18px 50px rgba(8,40,28,.12);
  --card-shadow: 0 2px 10px rgba(8,40,28,.05);
  --lift-shadow: 0 14px 30px rgba(8,40,28,.14);
  /* ink surfaces (sidebar + monitor bar) — constant across themes */
  --ink: #071c15;
  --ink2: #0a2a1f;
  --ink-border: rgba(255,255,255,.08);
  --ink-text: #e9fbf1;
  --ink-muted: #86a396;
  --radius: 18px;
}
/* ===== Dark (ink) mode ===== */
[data-theme="dark"] {
  --bg: #0a1f18;
  --bg-solid: #050d0a;
  --term-bg: #071410;
  --panel: #0b1d16;
  --panel2: #0f2419;
  --border: #1b3a2c;
  --text: #e6f5ec;
  --muted: #84a294;
  --accent: #18c98a;
  --accent-hover: #2fe6a4;
  --accent2: #22c8e6;
  --grad: linear-gradient(135deg, #18c98a, #22c8e6);
  --danger: #ff6b5e;
  --ok: #27d17c;
  --warn: #f3c44b;
  --glowA: rgba(24,201,138,.13);
  --glowB: rgba(34,200,230,.10);
  --glowC: rgba(163,230,53,.06);
  --shadow: 0 18px 50px rgba(0,0,0,.55);
  --card-shadow: 0 2px 10px rgba(0,0,0,.3);
  --lift-shadow: 0 14px 30px rgba(0,0,0,.5);
  --ink: #04120d;
  --ink2: #082019;
}
* { box-sizing: border-box; }
html, body { overscroll-behavior: none; }
body {
  margin: 0;
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  height: 100vh;
  height: 100dvh; /* Android WebView: track keyboard/URL-bar viewport changes */
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  background:
    radial-gradient(900px 480px at 88% -10%, var(--glowA), transparent 62%),
    radial-gradient(800px 460px at -10% 20%, var(--glowB), transparent 58%),
    radial-gradient(700px 500px at 55% 115%, var(--glowC), transparent 60%),
    var(--bg-solid);
}
.hidden { display: none !important; }
button { font-family: inherit; }
a { color: var(--accent); }
.spacer { flex: 1; }
.mono, .ss-title, .ss-sub, .statsbar { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
::selection { background: rgba(16,185,129,.25); }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: rgba(95,117,105,.32); border-radius: 8px; border: 2px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background-color: rgba(95,117,105,.55); }
::-webkit-scrollbar-track { background: transparent; }

/* ===== app shell: floating panels over the aurora (sidebar on the RIGHT) ===== */
.app-shell { display: flex; height: 100vh; height: 100dvh; padding: 12px; gap: 12px; }
.app-shell .main { order: 1; }
.app-shell .sidebar { order: 2; }
.main {
  flex: 1; min-width: 0; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; box-shadow: var(--card-shadow);
}

/* ---- sidebar: deep emerald ink, the brand surface ---- */
.sidebar {
  width: 252px; flex-shrink: 0;
  background: linear-gradient(180deg, var(--ink2) 0%, var(--ink) 55%, var(--ink) 100%);
  border: 1px solid var(--ink-border);
  border-radius: var(--radius);
  display: flex; flex-direction: column; padding: 14px 11px;
  overflow-y: auto; box-shadow: var(--shadow);
  color: var(--ink-text);
}
.side-logo { display: flex; align-items: center; gap: 10px; padding: 2px 8px 16px; }
.logo-tile {
  width: 30px; height: 30px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #04140d;
  font-family: ui-monospace, monospace; font-size: 12px; font-weight: 700; letter-spacing: -1px;
  box-shadow: 0 0 18px rgba(16,185,129,.55);
}
.logo-word { font-weight: 700; font-size: 17.5px; letter-spacing: .3px; color: #fff; }
.logo-word span { background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.side-nav { display: flex; flex-direction: column; gap: 3px; }
.side-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  background: transparent; border: none; border-radius: 11px;
  color: var(--ink-muted); font-size: 13.5px; font-weight: 500; padding: 8px 11px; cursor: pointer; text-align: left;
  transition: background .12s, color .12s;
}
.side-item:hover { background: rgba(255,255,255,.06); color: var(--ink-text); }
.side-item.active {
  background: linear-gradient(270deg, rgba(16,185,129,.28), rgba(6,182,212,.10));
  color: #fff; box-shadow: inset -2px 0 0 var(--accent);
}
.side-item .si-ico { width: 18px; text-align: center; flex-shrink: 0; font-size: 13px; }
.side-item .si-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.si-count {
  font-size: 11px; color: var(--ink-muted); background: rgba(255,255,255,.07);
  border: 1px solid rgba(255,255,255,.09); border-radius: 20px; padding: 0 7px; line-height: 17px;
}
.side-item.active .si-count { color: #baf7dd; border-color: rgba(16,185,129,.6); }
.side-sec { font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--ink-muted); padding: 18px 11px 7px; }
.side-filter { padding: 0 4px 7px; }
.side-filter input {
  padding: 6px 11px; font-size: 12.5px; border-radius: 9px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.10); color: var(--ink-text);
}
.side-filter input::placeholder { color: var(--ink-muted); }
.side-filter input:focus { border-color: var(--accent); outline: none; }
.side-groups { flex: 1; min-height: 60px; overflow-y: auto; display: flex; flex-direction: column; gap: 3px; }
.side-bottom { border-top: 1px solid var(--ink-border); margin-top: 12px; padding-top: 12px; }
/* sidebar AI-credits meter */
.side-ai { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; cursor: pointer;
  background: rgba(255,255,255,.05); border: 1px solid var(--ink-border); border-radius: 11px; padding: 8px 11px; margin-top: 10px; color: var(--ink-text); }
.side-ai:hover { background: rgba(255,255,255,.09); border-color: rgba(16,185,129,.4); }
.side-ai .si-ico { flex-shrink: 0; font-size: 14px; }
.side-ai .sa-body { flex: 1; min-width: 0; }
.side-ai .sa-top { display: flex; justify-content: space-between; font-size: 11.5px; color: var(--ink-muted); margin-bottom: 5px; }
.side-ai .sa-top span:last-child { color: #a7f3d0; font-weight: 600; font-family: ui-monospace, monospace; }
.side-ai .sa-bar { display: block; height: 6px; background: rgba(255,255,255,.10); border-radius: 4px; overflow: hidden; }
.side-ai .sa-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .5s; }
.side-ai .sa-bar.low i { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* mobile floating menu button (immersive session mode) — hidden on desktop */
.menu-fab { display: none; }

.side-foot { border-top: 1px solid var(--ink-border); margin-top: 12px; padding-top: 12px; }
.userbox { display: flex; align-items: center; gap: 9px; font-size: 12.5px; color: var(--ink-muted); padding: 2px 6px; }
.userbox .avatar {
  width: 27px; height: 27px; border-radius: 50%; flex-shrink: 0;
  background: var(--grad); color: #04140d;
  display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700;
  box-shadow: 0 0 12px rgba(16,185,129,.4);
}
.userbox .ub-mail { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbox .iconbtn { background: rgba(255,255,255,.07); border-color: rgba(255,255,255,.12); color: var(--ink-text); }
.side-backdrop { display: none; }

/* ---- topbar (inside the main panel) ---- */
.topbar {
  display: flex; align-items: center; gap: 10px; height: 46px; flex-shrink: 0;
  padding: 0 16px; border-bottom: 1px solid var(--border); background: var(--panel);
}
.top-title { font-size: 14.5px; font-weight: 600; letter-spacing: .2px; }
.menu-btn { display: none; }

/* ---- buttons: gradient primaries + pill ghosts ---- */
.btn {
  background: var(--grad); color: #fff; border: none; border-radius: 12px;
  padding: 9px 16px; font-size: 14px; font-weight: 600; cursor: pointer;
  box-shadow: 0 5px 16px rgba(16,185,129,.30);
  transition: transform .1s, box-shadow .12s, filter .12s;
}
.btn:hover { filter: brightness(1.07); box-shadow: 0 8px 22px rgba(16,185,129,.4); transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.btn.block { width: 100%; padding: 11px; }
.btn.ghost {
  background: var(--panel); border: 1px solid var(--border); color: var(--muted);
  font-weight: 500; box-shadow: none; border-radius: 999px;
}
.btn.ghost:hover { border-color: var(--accent); color: var(--accent); filter: none; transform: none; box-shadow: 0 3px 10px rgba(16,185,129,.14); }
.btn.ghost.active { border-color: var(--accent); color: var(--accent); background: rgba(16,185,129,.08); }
.btn.danger-ghost { background: var(--panel); border: 1px solid var(--border); color: var(--muted); font-weight: 500; box-shadow: none; border-radius: 999px; }
.btn.danger-ghost:hover { border-color: var(--danger); color: var(--danger); filter: none; transform: none; }
.btn.sm { padding: 6px 13px; font-size: 12px; }

/* ---- forms ---- */
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 5px; }
input, textarea, select {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); padding: 9px 12px; font-size: 14px; font-family: inherit;
}
textarea { resize: vertical; min-height: 80px; font-family: ui-monospace, monospace; font-size: 12px; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(16,185,129,.14); }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; }
.err-msg { color: var(--danger); font-size: 13px; margin-top: 10px; min-height: 16px; }
.hint { font-size: 11px; color: var(--muted); margin-top: 14px; line-height: 1.5; }

/* ---- centered card (auth) — glass on the aurora ---- */
.center { height: 100vh; display: flex; align-items: center; justify-content: center; }
.card {
  width: 404px; max-width: 92vw;
  background: color-mix(in srgb, var(--panel) 86%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 20px; padding: 28px;
  box-shadow: var(--shadow);
}
.card h2 { margin: 0 0 4px; font-size: 20px; letter-spacing: .2px; }
.card p.sub { margin: 0 0 18px; color: var(--muted); font-size: 13px; }
.switch { font-size: 13px; color: var(--muted); margin-top: 16px; text-align: center; }
.switch a { cursor: pointer; }
.auth-logo { display: flex; align-items: center; gap: 10px; margin-bottom: 20px; }
.auth-logo .logo-word { color: var(--text); }
.auth-warn {
  margin-top: 16px; padding: 11px 13px; border-radius: 10px; font-size: 12px; line-height: 1.5;
  color: var(--warn); background: color-mix(in srgb, var(--warn) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--warn) 35%, transparent);
}
.auth-warn b { color: var(--text); }

/* ---- status dot ---- */
.status { font-size: 12.5px; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--muted); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px rgba(22,163,74,.7); }
.dot.err { background: var(--danger); box-shadow: 0 0 8px rgba(229,72,77,.6); }

/* ---- dashboard ---- */
.dash { flex: 1; min-height: 0; overflow-y: auto; padding: 26px 30px; }
.dash-head { display: flex; align-items: center; margin-bottom: 20px; gap: 8px; }
.dash-head h1 { font-size: 21px; margin: 0; letter-spacing: .2px; }
.section-title { font-size: 12px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 28px 0 12px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(272px, 1fr)); gap: 16px; }
.server-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 16px;
  padding: 16px; cursor: pointer; position: relative;
  box-shadow: var(--card-shadow);
  transition: border-color .14s, box-shadow .16s, transform .14s;
  overflow: hidden;
}
.server-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--grad); opacity: 0; transition: opacity .16s;
}
.server-card:hover { border-color: rgba(16,185,129,.55); box-shadow: var(--lift-shadow); transform: translateY(-3px); }
.server-card:hover::before { opacity: 1; }
.sc-head { display: flex; align-items: center; gap: 11px; }
.sc-id { min-width: 0; flex: 1; }
.sc-id .name, .sc-id .addr { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srv-ava {
  width: 38px; height: 38px; border-radius: 12px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 15px;
  box-shadow: inset 0 -8px 14px rgba(0,0,0,.18);
}
.server-card .name { font-weight: 600; font-size: 15px; margin-bottom: 2px; }
.server-card .addr { font-size: 11.5px; color: var(--muted); font-family: ui-monospace, monospace; }
.sc-live {
  display: flex; align-items: center; gap: 12px; margin-top: 11px;
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden;
}
.lv-status.up { color: var(--ok); font-weight: 600; text-shadow: 0 0 7px rgba(22,163,74,.5); }
.lv-status.down { color: var(--danger); font-weight: 600; text-shadow: 0 0 7px rgba(229,72,77,.5); }
.lv { display: inline-flex; align-items: center; gap: 5px; }
.lv b { color: var(--text); font-weight: 600; }
.lv-bar { width: 52px; height: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; display: inline-block; }
.lv-bar i { display: block; height: 100%; background: var(--grad); transition: width .5s; }
.lv-bar.hot i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
.lv.dim { color: var(--muted); }
.server-card .badge {
  display: inline-block; margin-top: 11px; font-size: 11px; color: var(--muted);
  background: var(--panel2); border: 1px solid var(--border); border-radius: 20px; padding: 2px 10px;
}
.server-card .card-acts {
  position: absolute; top: 13px; right: 13px; display: flex; gap: 12px;
  opacity: 0; transition: opacity .12s; z-index: 1;
}
.server-card:hover .card-acts { opacity: 1; }
.server-card .card-acts .edit, .server-card .card-acts .del { color: var(--muted); font-size: 14px; cursor: pointer; }
.server-card .card-acts .edit:hover { color: var(--accent); }
.server-card .card-acts .del:hover { color: var(--danger); }
.empty { color: var(--muted); font-size: 14px; padding: 8px 0; }

.rec-row {
  display: flex; align-items: center; gap: 12px; padding: 11px 14px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px;
}
.rec-row .rname { flex: 1; font-size: 14px; }
.rec-row .rmeta { font-size: 12px; color: var(--muted); }

/* ---- modal ---- */
.modal-bg {
  position: fixed; inset: 0; background: rgba(5,18,13,.5); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { width: 440px; max-width: 94vw; }
.modal .card { width: 100%; }
.modal-wide { width: 80vw; height: 78vh; }
.modal-wide .card { width: 100%; height: 100%; display: flex; flex-direction: column; }

/* ===== terminal workspace ===== */
#termView:not(.hidden) { display: flex; flex-direction: column; flex: 1; min-height: 0; }

/* ---- session head ---- */
.session-head {
  display: flex; align-items: center; gap: 12px; padding: 11px 18px;
  background: var(--panel); border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.ss-ico { font-size: 18px; }
.ss-title-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.ss-title { font-size: 15.5px; font-weight: 700; letter-spacing: .2px; }
.ss-sub { font-size: 12px; color: var(--muted); }
.ss-lat { font-size: 12px; color: var(--ok); font-family: ui-monospace, monospace; }
.ss-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---- bottom monitor bar: ink strip with neon readouts (signature) ---- */
.statsbar {
  display: flex; align-items: center; gap: 13px; padding: 6px 16px; font-size: 12px;
  color: var(--ink-muted); background: linear-gradient(90deg, var(--ink), var(--ink2));
  border-top: 1px solid var(--ink-border);
  overflow-x: auto; flex-shrink: 0; white-space: nowrap;
}
.statsbar::-webkit-scrollbar { height: 0; }
.sb-item { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; }
.sb-item b { color: #a7f3d0; font-weight: 600; text-shadow: 0 0 10px rgba(16,185,129,.35); }
.sb-sep { width: 1px; height: 20px; background: rgba(255,255,255,.12); flex-shrink: 0; }
.sb-lbl { font-size: 10.5px; letter-spacing: .5px; color: var(--ink-muted); }
.sb-bar { width: 46px; height: 8px; background: rgba(255,255,255,.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,.10); border-radius: 5px; overflow: hidden; display: inline-block; }
.sb-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .5s; box-shadow: 0 0 8px rgba(16,185,129,.6); }
.sb-bar.warn i { background: linear-gradient(90deg, #f59e0b, #fbbf24); box-shadow: 0 0 8px rgba(245,158,11,.6); }
.sb-bar.crit i { background: linear-gradient(90deg, #ef4444, #f87171); box-shadow: 0 0 8px rgba(239,68,68,.6); }

/* CPU ring gauge (color-coded) */
.sb-ring { width: 26px; height: 26px; flex-shrink: 0; }
.sb-ring .ring-bg { fill: none; stroke: rgba(255,255,255,.14); stroke-width: 3.4; }
.sb-ring .ring-fg { fill: none; stroke: var(--accent); stroke-width: 3.4; stroke-linecap: round; transform: rotate(-90deg); transform-origin: 15px 15px; transition: stroke-dashoffset .5s ease, stroke .3s; filter: drop-shadow(0 0 3px rgba(16,185,129,.7)); }
.sb-ring text { fill: #a7f3d0; font: 700 10px ui-monospace, monospace; text-anchor: middle; }
.sb-ring.warn .ring-fg { stroke: #fbbf24; filter: drop-shadow(0 0 3px rgba(245,158,11,.7)); }
.sb-ring.warn text { fill: #fde68a; }
.sb-ring.crit .ring-fg { stroke: #f87171; filter: drop-shadow(0 0 3px rgba(239,68,68,.7)); }
.sb-ring.crit text { fill: #fecaca; }

/* network activity mini-graph */
.sb-spark { width: 56px; height: 22px; flex-shrink: 0; }
.sb-spark .net-line { fill: none; stroke: var(--accent2); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.sb-spark .net-area { fill: rgba(34,200,230,.14); stroke: none; }
.sb-net { flex-direction: column; align-items: flex-start; gap: 1px; font-size: 11px; line-height: 1.25; }
.sb-disc { background: transparent; border: none; color: #ff8a80; font-size: 12px; cursor: pointer; padding: 2px 4px; flex-shrink: 0; font-family: inherit; }
.sb-disc:hover { text-decoration: underline; }

/* ---- tab strip: pill tabs ---- */
.tabrow { display: flex; align-items: center; background: var(--panel2); border-bottom: 1px solid var(--border); flex-shrink: 0; padding-right: 10px; }
.tabrow .tabbar { border-bottom: none; flex: 1; min-width: 0; background: transparent; }
.tab-search-btn { flex-shrink: 0; margin-left: 6px; }
.term-search { display: flex; align-items: center; gap: 5px; flex-shrink: 0; padding: 0 6px; }
.term-search input { width: 200px; padding: 5px 11px; font-size: 12.5px; border-radius: 999px; }
.tabbar { display: flex; align-items: center; gap: 6px; background: var(--panel2); border-bottom: 1px solid var(--border); padding: 7px 12px; overflow-x: auto; flex-shrink: 0; }
.tabbar::-webkit-scrollbar { height: 0; }
.tab-item {
  display: flex; align-items: center; gap: 8px; background: var(--panel);
  border: 1px solid var(--border); border-radius: 999px; padding: 6px 14px;
  font-size: 13px; cursor: pointer; white-space: nowrap; color: var(--muted);
  transition: color .12s, background .12s, border-color .12s;
}
.tab-item:hover { color: var(--text); border-color: rgba(16,185,129,.4); }
.tab-item.active {
  color: #fff; border-color: transparent;
  background: linear-gradient(90deg, var(--ink2), var(--ink));
  box-shadow: 0 3px 10px rgba(7,28,21,.35);
}
.tab-item.armed { box-shadow: inset 0 -2px 0 var(--warn); }
.tab-item .tx { color: var(--muted); font-size: 13px; }
.tab-item.active .tx { color: #9fc0b1; }
.tab-item .tx:hover { color: var(--danger); }
.tab-item .arm { font-size: 11px; }
.tab-new { background: transparent; border: 1px dashed var(--border); color: var(--muted); border-radius: 999px; padding: 6px 14px; font-size: 13px; cursor: pointer; }
.tab-new:hover { border-color: var(--accent); color: var(--accent); }
.workspace { display: flex; flex: 1; min-height: 0; }
.terminals { flex: 1; position: relative; min-width: 0; background: var(--term-bg); }
.term-pane { position: absolute; inset: 0; padding: 10px; background: var(--term-bg); }
.term-pane.hidden { display: none; }
.fs-placeholder { display: flex; align-items: center; justify-content: center; height: 100%; color: var(--muted); font-size: 14px; text-align: center; padding: 20px; }
#terminal { flex: 1; height: 100%; padding: 8px; min-width: 0; }
#replayTerm { flex: 1; min-height: 0; }

/* ---- SFTP panel ---- */
.files {
  width: 360px; flex-shrink: 0; background: var(--panel);
  border-left: 1px solid var(--border); display: none; flex-direction: column;
}
.files.show { display: flex; }
.files-head { padding: 10px 12px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.files-head .title { font-size: 13px; font-weight: 600; }
.files-actions { margin-left: auto; display: flex; gap: 6px; }
.iconbtn { background: var(--bg); border: 1px solid var(--border); color: var(--text); border-radius: 999px; padding: 4px 11px; font-size: 12px; cursor: pointer; }
.iconbtn:hover { border-color: var(--accent); color: var(--accent); }
.breadcrumb { padding: 8px 12px; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--border); font-family: ui-monospace, monospace; word-break: break-all; }
.breadcrumb a { cursor: pointer; text-decoration: none; }
.file-list { flex: 1; overflow-y: auto; }
.file-row { display: flex; align-items: center; gap: 9px; padding: 7px 12px; font-size: 13px; border-bottom: 1px solid var(--border); }
.file-row:hover { background: var(--panel2); }
.file-row .fi-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-row .fi-name.dir { color: var(--accent); cursor: pointer; }
.file-row .fi-size { color: var(--muted); font-size: 11px; min-width: 60px; text-align: right; }
.file-row .fi-acts { display: none; gap: 8px; }
.file-row:hover .fi-acts { display: flex; }
.fi-act { color: var(--muted); cursor: pointer; font-size: 14px; }
.fi-act:hover { color: var(--text); }
.fi-act.del:hover { color: var(--danger); }
.files-empty, .files-loading { padding: 20px; color: var(--muted); font-size: 13px; text-align: center; }
.files-msg { padding: 8px 12px; font-size: 12px; color: var(--danger); min-height: 0; }
.drop-hint { padding: 8px 12px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); text-align: center; }
.files.dragover { outline: 2px dashed var(--accent); outline-offset: -6px; }

/* ---- Ask AI panel ---- */
.ai-panel {
  width: 380px; flex-shrink: 0; background: var(--panel);
  border-left: 1px solid var(--border); display: none; flex-direction: column;
}
.ai-panel.show { display: flex; }
.ai-log { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.ai-q { align-self: flex-end; max-width: 92%; background: var(--grad); color: #fff; border-radius: 14px 14px 4px 14px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; box-shadow: 0 3px 10px rgba(16,185,129,.25); }
.ai-a { align-self: flex-start; max-width: 95%; background: var(--panel2); border: 1px solid var(--border); border-radius: 14px 14px 14px 4px; padding: 10px 13px; font-size: 13px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.ai-a code, .ai-a pre { font-family: ui-monospace, monospace; font-size: 12px; background: var(--bg); border-radius: 4px; padding: 1px 5px; }
.ai-wait { color: var(--muted); font-style: italic; }
.ai-code { background: var(--ink); border: 1px solid var(--ink-border); border-radius: 10px; margin: 8px 0; overflow: hidden; }
.ai-code pre { margin: 0; padding: 9px 11px; font-family: ui-monospace, monospace; font-size: 12px; overflow-x: auto; white-space: pre; color: #c8f5df; background: transparent; }
.ai-code-acts { display: flex; gap: 6px; padding: 5px 8px; border-top: 1px solid var(--ink-border); background: rgba(255,255,255,.03); }
.ai-code-acts button { background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.12); color: #cfe8db; border-radius: 999px; padding: 3px 12px; font-size: 11.5px; cursor: pointer; }
.ai-code-acts .ai-run { border-color: var(--accent); color: #6ee7b7; font-weight: 600; }
.ai-code-acts .ai-run:hover { background: var(--accent); color: #04140d; }
.ai-code-acts .ai-copy:hover { border-color: var(--accent); color: #6ee7b7; }
.ai-compose { border-top: 1px solid var(--border); padding: 10px 13px; }
.ai-ctx { display: flex; align-items: center; gap: 7px; font-size: 11.5px; color: var(--muted); margin-bottom: 7px; }
.ai-ctx input { width: auto; }
.ai-inrow { display: flex; gap: 8px; align-items: flex-end; }
.ai-inrow textarea { min-height: 40px; font-family: inherit; font-size: 13px; }

/* ---- command palette (⌘K) ---- */
.palette-bg { align-items: flex-start; padding-top: 12vh; }
.palette {
  width: 560px; max-width: 94vw;
  background: color-mix(in srgb, var(--panel) 90%, transparent);
  backdrop-filter: blur(14px);
  border: 1px solid var(--border); border-radius: 18px; box-shadow: var(--shadow); overflow: hidden;
}
.palette input { border: none; border-bottom: 1px solid var(--border); border-radius: 0; padding: 15px 18px; font-size: 15px; background: transparent; box-shadow: none; }
.palette input:focus { border-color: var(--border); border-bottom-color: var(--accent); box-shadow: none; }
.palette-list { max-height: 320px; overflow-y: auto; padding: 6px; }
.pal-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px; cursor: pointer; font-size: 13.5px; }
.pal-item .pi-sub { color: var(--muted); font-size: 12px; font-family: ui-monospace, monospace; margin-left: auto; }
.pal-item.sel, .pal-item:hover { background: var(--panel2); }
.pal-item .pi-kind { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: var(--accent); border: 1px solid var(--border); border-radius: 20px; padding: 1px 7px; flex-shrink: 0; }
.palette-hint { padding: 8px 16px; font-size: 11px; color: var(--muted); border-top: 1px solid var(--border); }

/* note indicator on server cards */
.server-card .note-ind { font-size: 11px; color: var(--muted); margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* reachability dot on server cards (⚡ Check status) */
.srv-dot { font-size: 11px; vertical-align: 1px; }
.srv-dot.ok { color: var(--ok); text-shadow: 0 0 7px rgba(22,163,74,.7); }
.srv-dot.bad { color: var(--danger); text-shadow: 0 0 7px rgba(229,72,77,.6); }

/* unread-activity dot on session tabs */
.tab-dot { color: var(--accent); font-size: 9px; vertical-align: 2px; text-shadow: 0 0 7px rgba(16,185,129,.8); }

/* multi-line paste guard */
.paste-preview {
  max-height: 220px; overflow: auto; background: var(--ink); border: 1px solid var(--ink-border); color: #c8f5df;
  border-radius: 10px; padding: 10px 12px; font-family: ui-monospace, monospace; font-size: 12px;
  white-space: pre; margin: 0 0 14px;
}

/* auth: passkey divider + block ghost button */
.btn.block.ghost, .btn.ghost.block { width: 100%; padding: 11px; }
.auth-or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 14px 0 10px; }
.auth-or::before, .auth-or::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* AI usage meter */
.usage-card { background: var(--panel2); border: 1px solid var(--border); border-radius: 12px; padding: 12px 14px; margin-bottom: 16px; }
.usage-top { display: flex; justify-content: space-between; font-size: 12.5px; color: var(--muted); margin-bottom: 8px; }
.usage-top span:last-child { color: var(--text); font-weight: 600; font-family: ui-monospace, monospace; }
.usage-bar { height: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.usage-bar i { display: block; height: 100%; width: 0; background: var(--grad); transition: width .5s; }
.usage-bar.hot i { background: linear-gradient(90deg, #f59e0b, #ef4444); }

/* admin: user + proxy rows */
.adm-row { display: flex; align-items: center; gap: 12px; padding: 12px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; box-shadow: var(--card-shadow); }
.adm-row .adm-main { flex: 1; min-width: 0; }
.adm-row .adm-title { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.adm-row .adm-sub { font-size: 12px; color: var(--muted); margin-top: 3px; font-family: ui-monospace, monospace; }
.adm-badge { font-size: 10px; text-transform: uppercase; letter-spacing: .5px; border-radius: 20px; padding: 1px 8px; border: 1px solid var(--border); color: var(--muted); }
.adm-badge.admin { color: var(--accent); border-color: var(--accent); }
.adm-badge.locked { color: var(--warn); border-color: var(--warn); }
.adm-usage { min-width: 150px; }
.adm-usage .au-top { display: flex; justify-content: space-between; gap: 10px; font-size: 11px; color: var(--muted); margin-bottom: 4px; font-family: ui-monospace, monospace; }
.adm-usage .au-bar { height: 6px; background: var(--bg); border: 1px solid var(--border); border-radius: 4px; overflow: hidden; }
.adm-usage .au-bar i { display: block; height: 100%; background: var(--grad); }
.adm-usage .au-bar.hot i { background: linear-gradient(90deg, #f59e0b, #ef4444); }
@media (max-width: 760px) { .adm-row { flex-wrap: wrap; } .adm-row .adm-main { flex-basis: 100%; } .adm-usage { flex: 1; } }

/* shared-AI credit request */
.ai-request { background: var(--panel2); border: 1px solid var(--accent); border-radius: 12px; padding: 14px; margin-bottom: 16px; text-align: center; }
.ai-request .ar-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.ai-request .ar-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; line-height: 1.4; }

/* passkey rows */
.pk-row { display: flex; align-items: center; gap: 12px; padding: 11px 14px; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 8px; }
.pk-row .pk-main { flex: 1; min-width: 0; }
.pk-row .pk-title { font-size: 13.5px; font-weight: 600; }
.pk-row .pk-sub { font-size: 11.5px; color: var(--muted); margin-top: 2px; }

/* recording pulse */
.rec-indicator { display: flex; align-items: center; gap: 6px; color: var(--danger); font-size: 13px; }
.rec-indicator .pulse { width: 9px; height: 9px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }

.share-link { display: flex; gap: 8px; margin-top: 8px; }
.share-link input { font-family: ui-monospace, monospace; font-size: 12px; }
.banner { display: block; background: var(--panel2); border-bottom: 1px solid var(--border); padding: 8px 16px; font-size: 13px; color: var(--warn); text-align: center; }

/* ---- dashboard groups (main pane) ---- */
.group-head { font-size: 11.5px; text-transform: uppercase; letter-spacing: 1.2px; color: var(--muted); margin: 18px 0 11px; display: flex; align-items: center; }
.group-head .group-del { opacity: 0; cursor: pointer; font-size: 13px; padding: 0 4px; }
.group-head:hover .group-del { opacity: 1; }
.group-head .group-del:hover { color: var(--danger); }
.bulkbar { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 1px solid var(--accent); border-radius: 12px; padding: 8px 12px; margin-bottom: 14px; font-size: 13px; }
.server-card.selected { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.server-card .sel-check { position: absolute; top: 14px; left: 14px; font-size: 16px; color: var(--accent); z-index: 1; }
#serverGroups.selecting .server-card { padding-left: 42px; cursor: pointer; }
.tags { margin-top: 8px; display: flex; gap: 6px; flex-wrap: wrap; }
.tag { font-size: 10px; color: var(--muted); border: 1px solid var(--border); background: var(--panel2); border-radius: 20px; padding: 1px 8px; }

/* generic list rows */
.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 15px; background: var(--panel); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 9px; box-shadow: var(--card-shadow); }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 14px; font-weight: 600; }
.list-row .lr-sub { font-size: 12px; color: var(--muted); font-family: ui-monospace, monospace; word-break: break-all; margin-top: 3px; }
.list-row code { background: var(--bg); padding: 2px 6px; border-radius: 4px; font-size: 12px; }

.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 8px; max-height: 180px; overflow-y: auto; }
.check-grid label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text); margin: 0; cursor: pointer; }
.check-grid input { width: auto; }
.run-output { margin-top: 14px; overflow-y: auto; flex: 1; min-height: 0; }
.run-block { background: var(--bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 10px; }
.run-block .rb-head { padding: 8px 12px; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); display: flex; gap: 8px; align-items: center; }
.run-block pre { margin: 0; padding: 10px 12px; font-size: 12px; font-family: ui-monospace, monospace; white-space: pre-wrap; word-break: break-all; max-height: 240px; overflow-y: auto; }
.ok-dot { color: var(--ok); } .err-dot { color: var(--danger); }
.fw-row { display: flex; align-items: center; gap: 10px; padding: 8px 12px; background: var(--bg); border: 1px solid var(--border); border-radius: 10px; margin-bottom: 6px; font-size: 13px; }
.fw-row .fw-del { margin-left: auto; color: var(--muted); cursor: pointer; }
.fw-row .fw-del:hover { color: var(--danger); }
.pub-key { font-family: ui-monospace, monospace; font-size: 11px; color: var(--muted); word-break: break-all; }

/* ---- monitor: docked side panel (MobaXterm-style, compact) ---- */
.mon-panel {
  width: 250px; flex-shrink: 0; background: var(--panel);
  border-left: 1px solid var(--border); display: none; flex-direction: column;
}
.mon-panel.show { display: flex; }
.mon-live { font-size: 10px; color: var(--ok); display: inline-flex; align-items: center; gap: 4px; }
.mon-live::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 6px var(--ok); animation: pulse 1.6s infinite; }
.mon-body { overflow-y: auto; flex: 1; min-height: 0; padding: 10px; }
.mon-head { font-size: 11px; color: var(--muted); margin-bottom: 2px; font-family: ui-monospace, monospace; line-height: 1.5; word-break: break-word; }
.mon-head b { color: var(--text); }
.mon-sec { font-size: 9.5px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 12px 0 6px; }
.mon-kpis { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 2px; }
.mon-kpi { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 6px 8px; }
.mon-kpi .k-lbl { font-size: 9.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; }
.mon-kpi .k-val { font-size: 12.5px; font-weight: 700; font-family: ui-monospace, monospace; margin-top: 1px; }
.gauge { margin-bottom: 8px; }
.gauge .glabel { display: flex; font-size: 11px; margin-bottom: 4px; }
.gauge .glabel .gval { margin-left: auto; color: var(--muted); font-family: ui-monospace, monospace; }
.bar { height: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 5px; overflow: hidden; }
.bar > div { height: 100%; background: var(--grad); transition: width .4s; box-shadow: 0 0 6px rgba(16,185,129,.4); }
.bar.warn > div { background: linear-gradient(90deg, var(--warn), #e9a23b); box-shadow: 0 0 6px rgba(201,138,0,.4); }
.bar.crit > div { background: linear-gradient(90deg, var(--danger), #d9433a); box-shadow: 0 0 6px rgba(229,72,77,.4); }
.spark { width: 100%; height: 40px; display: block; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; margin-top: 6px; }
.spark polyline { fill: none; stroke: var(--accent); stroke-width: 2; vector-effect: non-scaling-stroke; }
.spark .fillarea { fill: rgba(16,185,129,.12); stroke: none; }
@media (max-width: 760px) {
  .mon-panel { position: absolute; inset: 0; width: 100%; z-index: 32; border-left: none; }
  .mon-body { padding: 12px; max-width: 380px; margin: 0 auto; }
  .mon-kpi { padding: 8px 10px; }
  .mon-kpi .k-val { font-size: 14px; }
  .bar { height: 10px; }
}

/* ===================== mobile (phones / Android app) ===================== */
@media (max-width: 760px) {
  .app-shell { padding: 0; gap: 0; }
  .main { border-radius: 0; border: none; }

  /* prevent Android/iOS focus-zoom: form controls must be ≥16px */
  input, textarea, select { font-size: 16px; }

  /* comfortable touch targets */
  .btn, .iconbtn { min-height: 40px; }
  .btn.sm { padding: 8px 14px; }
  .iconbtn { padding: 8px 13px; }

  /* safe areas (notch / status bar / gesture bar) */
  .topbar { padding-top: calc(env(safe-area-inset-top, 0px)); height: calc(48px + env(safe-area-inset-top, 0px)); padding-left: 14px; padding-right: 14px; }
  .statsbar { padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px)); }
  .dash { padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px)); }

  /* sidebar becomes an off-canvas ink drawer FROM THE RIGHT */
  .sidebar {
    position: fixed; top: 0; right: 0; left: auto; bottom: 0; z-index: 60;
    transform: translateX(105%); transition: transform .18s ease-out;
    box-shadow: 0 0 50px rgba(0,0,0,.45); width: 286px;
    border-radius: 20px 0 0 20px; border-right: none;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  .sidebar.open { transform: translateX(0); }
  .side-backdrop { position: fixed; inset: 0; background: rgba(5,18,13,.5); z-index: 55; }
  .sidebar.open ~ .side-backdrop, .sidebar.open + .side-backdrop { display: block; }
  .menu-btn { display: inline-block; }

  /* immersive session: while a terminal/SFTP fills the screen, hide the top bar
     and expose a floating menu button so the sidebar can be summoned back. */
  body.session-active .topbar { display: none; }
  body.session-active .menu-fab {
    display: flex; align-items: center; justify-content: center;
    position: fixed; right: 14px; z-index: 45;
    bottom: calc(56px + env(safe-area-inset-bottom, 0px));
    width: 46px; height: 46px; border-radius: 50%; border: none;
    background: var(--grad); color: #fff; font-size: 20px; cursor: pointer;
    box-shadow: 0 6px 18px rgba(7,28,21,.4);
  }
  body.session-active .menu-fab:active { filter: brightness(1.1); }

  .side-item { padding: 12px 12px; font-size: 14.5px; }   /* 44px+ touch rows */
  .side-filter input { padding: 10px 12px; }

  .center { padding: 14px; }
  .card { width: 100%; padding: 20px; }

  /* dashboard */
  .dash { padding: 14px; }
  .grid { grid-template-columns: 1fr; }
  .dash-head { flex-wrap: wrap; gap: 8px; }
  .dash-head h1 { font-size: 18px; }
  #serverSearch { max-width: none !important; width: 100%; }
  .server-card { padding: 17px 16px; }   /* bigger tap target */
  .server-card .card-acts { opacity: 1; gap: 16px; } /* always show on touch, wider spacing */
  .server-card .card-acts .edit, .server-card .card-acts .del { font-size: 17px; padding: 4px; }
  .sc-live { flex-wrap: wrap; white-space: normal; row-gap: 5px; }
  .list-row { flex-wrap: wrap; }
  .list-row .lr-main { flex-basis: 100%; }

  /* session head scrolls horizontally instead of wrapping forever */
  .session-head { flex-wrap: wrap; gap: 8px; padding: 8px 10px; }
  .ss-actions { width: 100%; overflow-x: auto; flex-wrap: nowrap; justify-content: flex-start; -webkit-overflow-scrolling: touch; }
  .ss-actions::-webkit-scrollbar { height: 0; }
  .ss-actions .btn { flex-shrink: 0; }
  .statsbar { padding-left: 10px; padding-right: 10px; gap: 12px; }

  /* terminal: full-width terminal + SFTP/AI as full-screen drawers */
  .workspace { position: relative; }
  .files { position: absolute; inset: 0; width: 100%; z-index: 30; border-left: none; }
  .ai-panel { position: absolute; inset: 0; width: 100%; z-index: 31; border-left: none; }
  .term-search input { width: 130px; font-size: 16px; }
  .file-row { padding: 12px; }             /* taller rows for touch */
  .fi-acts { display: flex !important; gap: 14px; }  /* no hover on touch — always show actions */
  .fi-act { font-size: 17px; padding: 2px; }
  .tabbar { padding: 7px; }
  .tab-item { padding: 9px 14px; }
  .tab-new { padding: 9px 14px; }

  /* modals become bottom sheets */
  .modal-bg { align-items: flex-end; }
  .modal, .modal-wide { width: 100vw !important; max-width: 100vw; height: auto; }
  .modal-wide { height: 92dvh; }
  .modal .card, .modal-wide .card {
    border-radius: 22px 22px 0 0; border-bottom: none;
    max-height: 92dvh; overflow-y: auto;
    padding: 20px 18px calc(18px + env(safe-area-inset-bottom, 0px));
  }
  .palette-bg { align-items: flex-start; padding-top: 8vh; }
  .palette { border-radius: 18px; margin: 0 8px; }
  .check-grid { grid-template-columns: 1fr; }
  .row { flex-wrap: wrap; }
  .row > .field { flex-basis: 100% !important; }
}
