/* AutoGrub Command — epic operations console
   Cyberpunk-industrial. High contrast. Layered depth. */

:root {
  --bg: #050709;
  --bg2: #0a0c11;
  --panel: rgba(12, 15, 22, 0.92);
  --panel-solid: #0c0f16;
  --panel-hi: #111520;
  --sidebar: #080a10;
  --line: #1a1f2e;
  --line-hard: #222940;
  --line-soft: #121620;
  --line-glow: rgba(0, 240, 200, 0.06);
  --ink: #eef0f4;
  --ink-soft: #c8ccd6;
  --mute: #7a8294;
  --mute2: #555d70;
  --accent: #00f0c8;
  --accent-hi: #33ffdd;
  --accent-deep: #00b898;
  --accent-dim: rgba(0, 240, 200, 0.10);
  --accent2: #a855f7;
  --accent2-dim: rgba(168, 85, 247, 0.10);
  --ok: #00e68a;
  --ok-dim: rgba(0, 230, 138, 0.10);
  --bad: #ff4466;
  --bad-dim: rgba(255, 68, 102, 0.10);
  --warn: #ffaa22;
  --warn-dim: rgba(255, 170, 34, 0.10);
  --radius: 10px;
  --radius-sm: 8px;
  --radius-xs: 6px;
  --sidebar-w: 240px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --control-h: 38px;
  --hit: 42px;
  --shadow-card: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-lift: 0 1px 0 rgba(255, 255, 255, 0.04) inset, 0 12px 32px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 20px rgba(0, 240, 200, 0.06);
  --focus-ring: 0 0 0 2px rgba(0, 240, 200, 0.35);
  --font: "Inter", "SF Pro Text", "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", "SF Mono", ui-monospace, Consolas, monospace;
  font-family: var(--font);
}

*, *::before, *::after { box-sizing: border-box; }
html, body {
  margin: 0;
  min-height: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
}
html { overflow-x: hidden; }
body {
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(0, 240, 200, 0.04), transparent),
    radial-gradient(ellipse 60% 40% at 80% 110%, rgba(168, 85, 247, 0.03), transparent);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
.hide { display: none !important; }
::selection { background: rgba(0, 240, 200, 0.22); color: #fff; }
* { scrollbar-color: #252d40 #080a10; scrollbar-width: thin; }

.glass {
  background: var(--panel);
  border: 1px solid var(--line-hard);
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(12px) saturate(1.3);
  -webkit-backdrop-filter: blur(12px) saturate(1.3);
}

/* ── Login gate ── */
.login-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: var(--space-5);
  background: #050709;
  background-image:
    radial-gradient(ellipse 80% 50% at 50% 40%, rgba(0, 240, 200, 0.05), transparent),
    radial-gradient(ellipse 50% 50% at 20% 80%, rgba(168, 85, 247, 0.04), transparent);
}
.login-card {
  width: min(420px, 100%);
  padding: 36px 32px 30px;
  border-radius: var(--radius);
  background: var(--panel);
  border: 1px solid var(--line-hard);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.04) inset,
    0 0 80px rgba(0, 240, 200, 0.04),
    0 30px 80px rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  position: relative;
  overflow: hidden;
}
.login-card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent2), var(--accent));
  background-size: 200% 100%;
  animation: shimmer 3s ease infinite;
}
@keyframes shimmer {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}
.login-brand { padding-bottom: 4px; }
.login-hint {
  margin: 0 0 2px;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
}
.login-card label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  color: var(--mute);
  font-weight: 650;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.login-card input {
  width: 100%;
  min-height: var(--hit);
}
.login-submit {
  width: 100%;
  margin-top: var(--space-2);
  min-height: var(--hit);
}
.login-error {
  color: var(--bad);
  min-height: 1.2em;
  margin: 0;
  font-weight: 600;
  font-size: 13px;
}

/* ── Shell ── */
#app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  min-height: 100vh;
  min-height: 100dvh;
  width: 100%;
  max-width: 100vw;
  background: var(--bg);
}
#app.hide { display: none !important; }

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  padding: 22px 14px 16px;
  background: var(--sidebar);
  border-right: 1px solid var(--line-hard);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  z-index: 20;
  overflow: hidden;
}
.sidebar::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1px;
  background: linear-gradient(
    to bottom,
    transparent,
    rgba(0, 240, 200, 0.15) 30%,
    rgba(168, 85, 247, 0.10) 70%,
    transparent
  );
  pointer-events: none;
}

.brand {
  display: flex;
  gap: var(--space-3);
  align-items: center;
  padding: 4px 8px 20px;
}
.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  flex: 0 0 auto;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 0 16px rgba(0, 240, 200, 0.2);
  position: relative;
  animation: mark-glow 4s ease-in-out infinite;
}
@keyframes mark-glow {
  0%, 100% { box-shadow: 0 0 16px rgba(0, 240, 200, 0.2); }
  50% { box-shadow: 0 0 24px rgba(0, 240, 200, 0.35), 0 0 8px rgba(168, 85, 247, 0.2); }
}
.brand-mark::after {
  content: "AG";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.5px;
  color: #050709;
}
.brand-title {
  font-weight: 800;
  letter-spacing: -0.5px;
  font-size: 16px;
  color: #fff;
}
.brand-title span {
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-sub {
  font-size: 9px;
  color: var(--mute2);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-top: 2px;
  font-weight: 700;
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.nav-btn {
  text-align: left;
  border: 1px solid transparent;
  background: transparent;
  color: var(--mute);
  border-radius: var(--radius-xs);
  padding: 11px 14px;
  min-height: var(--control-h);
  cursor: pointer;
  font-weight: 550;
  font-size: 13px;
  letter-spacing: 0;
  position: relative;
  transition: all 0.15s ease;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.04);
  color: var(--ink);
  border-color: var(--line);
}
.nav-btn.active {
  background: var(--accent-dim);
  border-color: rgba(0, 240, 200, 0.18);
  color: var(--accent-hi);
  font-weight: 650;
}
.nav-btn.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: linear-gradient(to bottom, var(--accent), var(--accent2));
}
.nav-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: 12px 6px 4px;
  border-top: 1px solid var(--line);
}
#sideMeta::before {
  content: "";
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(0, 230, 138, 0.4);
  animation: beacon 2s ease-in-out infinite;
}
@keyframes beacon {
  0%, 100% { box-shadow: 0 0 8px rgba(0, 230, 138, 0.4); }
  50% { box-shadow: 0 0 14px rgba(0, 230, 138, 0.6); }
}
.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  font-size: 11px;
  font-weight: 600;
  background: var(--panel-solid);
  border: 1px solid var(--line);
  color: var(--mute);
  width: fit-content;
  max-width: 100%;
  font-variant-numeric: tabular-nums;
}
.pill.soft {
  background: var(--accent-dim);
  color: var(--accent-hi);
  border-color: rgba(0, 240, 200, 0.2);
}
.state-pill::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.state-pill.running {
  color: var(--accent-hi);
  border-color: rgba(0, 240, 200, 0.25);
  background: var(--accent-dim);
}
.state-pill.running::before { animation: pulse 1.4s infinite; }
.state-pill.complete {
  color: var(--ink-soft);
  border-color: var(--line-hard);
  background: rgba(255, 255, 255, 0.03);
}

.content {
  padding: 24px 28px 36px;
  overflow: auto;
  min-width: 0;
  position: relative;
  background: transparent;
}
.panel {
  display: none;
  position: relative;
  z-index: 1;
}
.panel.active {
  display: block;
  animation: panelIn 0.2s ease;
}
@keyframes panelIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ── Banners ── */
.banner {
  margin-bottom: 14px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--panel);
  border: 1px solid var(--line-hard);
  border-left: 3px solid var(--accent);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.55;
}
.banner strong { color: #fff; font-weight: 700; }
.banner.soft {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--mute2);
  color: var(--mute);
}
.banner.soft b {
  color: var(--ink-soft);
  font-weight: 650;
}

/* ── Topbar ── */
.topbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 18px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.topbar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.topbar h1 {
  margin: 0;
  font-size: clamp(22px, 2.2vw, 28px);
  letter-spacing: -0.8px;
  font-weight: 780;
  color: #fff;
  line-height: 1.15;
}
.sub {
  margin: 4px 0 0;
  color: var(--mute);
  font-size: 12.5px;
  line-height: 1.45;
  max-width: 58ch;
}
.actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}
.field {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--mute);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}
.field input { width: 64px; }

/* ── Run command surface ── */
.run-commandbar {
  display: grid;
  grid-template-columns: 114px minmax(260px, 0.85fr) minmax(420px, 1.3fr);
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius);
  background: var(--line-hard);
  box-shadow: var(--shadow-card);
  position: relative;
}
.run-commandbar::before {
  content: "";
  position: absolute;
  inset: -1px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(0, 240, 200, 0.08), transparent 50%, rgba(168, 85, 247, 0.05));
  pointer-events: none;
  z-index: 0;
}
.run-count-control,
.run-command-group {
  min-width: 0;
  padding: 12px 14px;
  background: var(--panel-solid);
  position: relative;
  z-index: 1;
}
.run-count-control {
  display: grid;
  align-content: center;
  gap: 7px;
  color: var(--mute2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.run-count-control input {
  width: 100%;
  min-height: 40px;
  font-family: var(--mono);
  font-size: 16px;
  font-weight: 700;
  text-align: center;
}
.run-command-group {
  display: grid;
  align-content: center;
  gap: 8px;
}
.control-kicker,
.section-kicker {
  color: var(--mute2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1.2px;
  line-height: 1.2;
  text-transform: uppercase;
}
.control-kicker b {
  margin-left: 5px;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}
.run-command-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.run-command-actions .btn { min-width: 0; }
.btn.paired {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.08);
  color: #c084fc;
}
.btn.paired:hover {
  border-color: rgba(168, 85, 247, 0.65);
  background: rgba(168, 85, 247, 0.14);
  color: #d4a5ff;
}
.operator-note { margin-bottom: 14px; }

/* ── KPI cards ── */
.kpis {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 16px;
}
.kpi {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  padding: 14px 14px 12px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-width: 0;
  transition: all 0.18s ease;
}
.kpi::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.06), transparent);
}
.kpi:hover {
  border-color: rgba(0, 240, 200, 0.15);
  box-shadow: var(--shadow-lift), var(--shadow-glow);
  transform: translateY(-1px);
}
.kpi .lab {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--mute2);
  font-weight: 700;
}
.kpi .val {
  font-size: 26px;
  font-weight: 800;
  margin-top: 7px;
  letter-spacing: -0.8px;
  color: #fff;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
  font-family: var(--mono);
}
.run-result-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 6px;
}
.run-result-values span {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px;
  align-items: baseline;
  min-width: 0;
}
.run-result-values span + span {
  padding-left: 10px;
  border-left: 1px solid var(--line);
}
.run-result-values b {
  color: var(--ok);
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}
.run-result-values span + span b { color: var(--bad); }
.run-result-values small {
  color: var(--mute2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}
.kpi.ok .val { color: var(--ok); }
.kpi.bad .val { color: var(--bad); }
.kpi.live .val { color: var(--accent); text-shadow: 0 0 20px rgba(0, 240, 200, 0.3); }
.kpi.ok::after,
.kpi.bad::after,
.kpi.live::after {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  border-radius: 0 2px 2px 0;
}
.kpi.ok::after { background: var(--ok); box-shadow: 0 0 8px rgba(0, 230, 138, 0.3); }
.kpi.bad::after { background: var(--bad); box-shadow: 0 0 8px rgba(255, 68, 102, 0.3); }
.kpi.live::after { background: var(--accent); box-shadow: 0 0 8px rgba(0, 240, 200, 0.3); }
.kpi.live {
  border-color: rgba(0, 240, 200, 0.18);
  box-shadow: var(--shadow-card), inset 0 0 0 1px rgba(0, 240, 200, 0.06);
}

/* ── Cards / split ── */
.card {
  background: var(--panel);
  border: 1px solid var(--line-hard);
  border-radius: var(--radius);
  padding: var(--space-4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  box-shadow: var(--shadow-card);
  position: relative;
}
.card::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent 10%, rgba(255, 255, 255, 0.05) 50%, transparent 90%);
  border-radius: var(--radius) var(--radius) 0 0;
  pointer-events: none;
}
.card-h {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  gap: var(--space-2);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
.card-h strong {
  font-weight: 700;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.split {
  display: grid;
  grid-template-columns: 1.55fr 0.9fr;
  gap: 12px;
  align-items: stretch;
}
.grow { min-width: 0; }
.side-card { min-height: 320px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: var(--radius-xs);
  border: 1px solid var(--line-hard);
  background: var(--panel-hi);
  color: var(--ink);
  padding: 0 16px;
  min-height: var(--control-h);
  min-width: 80px;
  cursor: pointer;
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 0.2px;
  text-decoration: none;
  line-height: 1;
  position: relative;
  transition: all 0.15s ease;
}
.btn:hover {
  background: #181d2a;
  border-color: #2e3548;
  color: #fff;
  box-shadow: 0 0 12px rgba(0, 0, 0, 0.2);
}
.btn:active {
  background: #0e1218;
  border-color: var(--line-hard);
  transform: scale(0.98);
}
.btn:disabled {
  background: #0a0c10;
  color: #3a4050;
  border-color: var(--line-soft);
  cursor: not-allowed;
  opacity: 1;
  box-shadow: none;
}
.btn[aria-disabled="true"] {
  pointer-events: none;
  border-color: var(--line);
  background: #0c0f14;
  color: #4a5568;
  opacity: 0.6;
  box-shadow: none;
}
.btn.is-busy {
  pointer-events: none;
  color: transparent !important;
  position: relative;
}
.btn.is-busy::after {
  content: "";
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.btn.primary {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  border-color: rgba(0, 240, 200, 0.3);
  color: #050709;
  box-shadow: 0 0 12px rgba(0, 240, 200, 0.12);
  font-weight: 700;
}
.btn.primary:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-hi));
  border-color: rgba(0, 240, 200, 0.5);
  color: #050709;
  box-shadow: 0 0 20px rgba(0, 240, 200, 0.2);
}
.btn.primary:active {
  background: var(--accent-deep);
  border-color: rgba(0, 240, 200, 0.4);
  box-shadow: none;
}
.btn.primary:disabled {
  background: rgba(0, 240, 200, 0.15);
  color: rgba(5, 7, 9, 0.4);
  border-color: transparent;
  box-shadow: none;
}
.btn.danger {
  background: linear-gradient(135deg, #cc3355, var(--bad));
  border-color: rgba(255, 68, 102, 0.35);
  color: #fff;
  box-shadow: 0 0 8px rgba(255, 68, 102, 0.1);
}
.btn.danger.quiet {
  background: transparent;
  border-color: rgba(255, 68, 102, 0.35);
  color: #ff8899;
  box-shadow: none;
}
.btn.danger.quiet:hover {
  background: var(--bad-dim);
  border-color: rgba(255, 68, 102, 0.6);
  color: #ffaabb;
}
.btn.danger:hover {
  background: linear-gradient(135deg, var(--bad), #ff6688);
  border-color: rgba(255, 68, 102, 0.5);
  box-shadow: 0 0 16px rgba(255, 68, 102, 0.15);
}
.btn.danger:active {
  background: #aa2244;
  border-color: #882233;
}
.btn.ok {
  background: linear-gradient(135deg, #00b868, var(--ok));
  border-color: rgba(0, 230, 138, 0.35);
  color: #050709;
  font-weight: 700;
}
.btn.ok:hover {
  background: linear-gradient(135deg, var(--ok), #33ffaa);
  border-color: rgba(0, 230, 138, 0.5);
  box-shadow: 0 0 12px rgba(0, 230, 138, 0.15);
}
.btn.ok:active {
  background: #00996b;
}
.btn.danger:disabled,
.btn.danger.quiet:disabled,
.btn.ok:disabled,
.btn.paired:disabled {
  background: #0a0c10;
  color: #3a4050;
  border-color: var(--line-soft);
  box-shadow: none;
}
.btn.xs {
  min-height: 30px;
  min-width: 0;
  padding: 0 10px;
  font-size: 11.5px;
  border-radius: var(--radius-xs);
}
.btn.ghost {
  background: transparent;
  border-color: transparent;
  color: var(--mute);
  min-width: 0;
}
.btn.ghost:hover {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  color: #fff;
}
.btn.icon-btn {
  width: 32px;
  min-width: 32px;
  padding: 0;
  font-size: 16px;
}
a.btn { color: inherit; }

/* ── Inputs ── */
input, select, textarea {
  background: rgba(5, 7, 9, 0.8);
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-xs);
  padding: 9px 12px;
  min-height: var(--control-h);
  transition: all 0.15s ease;
}
input:hover, select:hover, textarea:hover {
  border-color: #2e3548;
}
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 240, 200, 0.15), 0 0 12px rgba(0, 240, 200, 0.06);
}
textarea {
  width: 100%;
  min-height: 280px;
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.6;
  resize: vertical;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: var(--space-4);
  align-items: end;
}
.form-grid > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 10px;
  color: var(--mute);
  font-weight: 650;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.check {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  min-height: var(--control-h);
  color: var(--ink);
  font-weight: 550;
  text-transform: none;
  letter-spacing: 0;
  font-size: 13px;
}
.check input {
  width: 16px;
  height: 16px;
  min-height: 0;
  accent-color: var(--accent);
}

/* ── Log ── */
.log {
  height: 360px;
  overflow: auto;
  border-radius: var(--radius-xs);
  background: rgba(3, 4, 6, 0.9);
  border: 1px solid var(--line);
  padding: 12px 14px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.6;
  position: relative;
}
.log::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0, 240, 200, 0.008) 2px,
      rgba(0, 240, 200, 0.008) 4px
    );
  pointer-events: none;
  border-radius: var(--radius-xs);
}
.log .info { color: #c8ccd6; }
.log .success { color: var(--ok); text-shadow: 0 0 8px rgba(0, 230, 138, 0.15); }
.log .warning { color: var(--warn); }
.log .error { color: var(--bad); text-shadow: 0 0 8px rgba(255, 68, 102, 0.15); }
.log .debug { color: #4a5060; }

/* ── Session strip ── */
.session-strip {
  display: flex;
  flex-direction: column;
  gap: 7px;
  max-height: 360px;
  overflow: auto;
  padding-right: 2px;
}
.session-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  padding: 11px 13px;
  background: rgba(8, 10, 16, 0.8);
  cursor: pointer;
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}
.session-card:hover {
  border-color: rgba(0, 240, 200, 0.3);
  background: var(--panel-hi);
  box-shadow: var(--shadow-card), 0 0 12px rgba(0, 240, 200, 0.04);
}
.session-card:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}
.session-card.active {
  border-color: rgba(0, 240, 200, 0.4);
  box-shadow: inset 0 0 0 1px rgba(0, 240, 200, 0.08), 0 0 16px rgba(0, 240, 200, 0.06);
  background: var(--accent-dim);
}
.session-card.dismissed { opacity: 1; }
.session-card .t {
  font-weight: 700;
  font-size: 12.5px;
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  color: #fff;
}
.session-card .m {
  color: var(--mute);
  font-size: 11px;
  margin-top: 3px;
  word-break: break-all;
  line-height: 1.4;
  font-family: var(--mono);
}
.session-card.status-running { border-color: rgba(0, 240, 200, 0.3); }
.session-card.status-success { border-color: rgba(0, 230, 138, 0.35); }
.session-card.status-failed { border-color: rgba(255, 68, 102, 0.3); }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #3a4050;
  display: inline-block;
  flex: 0 0 auto;
}
.status-running .dot,
.tab.status-running .dot {
  background: var(--accent);
  box-shadow: 0 0 0 0 rgba(0, 240, 200, 0.5);
  animation: pulse 1.4s infinite;
}
.status-success .dot,
.tab.status-success .dot { background: var(--ok); box-shadow: 0 0 6px rgba(0, 230, 138, 0.3); }
.status-failed .dot,
.tab.status-failed .dot { background: var(--bad); box-shadow: 0 0 6px rgba(255, 68, 102, 0.3); }
.status-starting .dot,
.tab.status-starting .dot {
  background: var(--warn);
  animation: pulse 1.8s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 240, 200, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(0, 240, 200, 0); }
  100% { box-shadow: 0 0 0 0 rgba(0, 240, 200, 0); }
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  line-height: 1.3;
  border: 1px solid transparent;
  font-family: var(--mono);
}
.badge.running {
  background: var(--accent-dim);
  color: var(--accent-hi);
  border-color: rgba(0, 240, 200, 0.2);
}
.badge.success {
  background: var(--ok-dim);
  color: var(--ok);
  border-color: rgba(0, 230, 138, 0.2);
}
.badge.failed,
.badge.closed {
  background: var(--bad-dim);
  color: var(--bad);
  border-color: rgba(255, 68, 102, 0.2);
}
.badge.starting {
  background: var(--warn-dim);
  color: var(--warn);
  border-color: rgba(255, 170, 34, 0.2);
}
.badge.dismissed {
  background: rgba(255, 255, 255, 0.03);
  color: var(--mute);
}

/* ── Segmented control ── */
.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: var(--radius-xs);
  background: rgba(5, 7, 9, 0.8);
  border: 1px solid var(--line-hard);
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--mute);
  padding: 7px 14px;
  min-height: 32px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 650;
  font-size: 12px;
  transition: all 0.15s ease;
}
.seg-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}
.seg-btn.active {
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  color: #050709;
  box-shadow: 0 0 8px rgba(0, 240, 200, 0.15);
}
.seg-btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

/* ── Theater ── */
.theater-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 14px;
  min-height: 34px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}
.tab {
  border: 1px solid var(--line-hard);
  background: rgba(8, 10, 16, 0.8);
  color: var(--ink-soft);
  border-radius: var(--radius-xs);
  padding: 7px 14px;
  min-height: 32px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 650;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.15s ease;
  font-family: var(--mono);
}
.tab:hover {
  background: var(--panel-hi);
  color: #fff;
  border-color: #2e3548;
}
.tab.active {
  background: var(--accent-dim);
  border-color: rgba(0, 240, 200, 0.4);
  color: var(--accent-hi);
  box-shadow: inset 0 -2px 0 var(--accent);
}
.tab .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--mute);
  display: inline-block;
}

.theater-stage {
  position: relative;
  min-height: 520px;
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line-hard);
  background: rgba(5, 7, 9, 0.9);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.03) inset,
    0 0 0 3px rgba(10, 12, 17, 0.8),
    0 0 0 4px var(--line),
    0 0 40px rgba(0, 0, 0, 0.3);
}
.theater-frames {
  width: 100%;
  height: min(68vh, 660px);
}
.theater-frames.tabs-mode .vnc-pane {
  display: none;
  width: 100%;
  height: 100%;
}
.theater-frames.tabs-mode .vnc-pane.active {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(0, 240, 200, 0.04);
  animation: fade 0.15s ease;
}
.theater-frames.mosaic-mode {
  display: grid;
  gap: 10px;
  height: auto;
  min-height: 400px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
.theater-frames.mosaic-mode .vnc-pane {
  display: flex;
  flex-direction: column;
  min-height: 240px;
  height: min(42vh, 360px);
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: #000;
  cursor: pointer;
  transition: all 0.15s ease;
}
.theater-frames.mosaic-mode .vnc-pane:hover {
  border-color: rgba(0, 240, 200, 0.3);
}
.theater-frames.mosaic-mode .vnc-pane.active {
  border-color: rgba(0, 240, 200, 0.45);
  box-shadow:
    inset 0 0 0 1px rgba(0, 240, 200, 0.1),
    0 0 20px rgba(0, 240, 200, 0.06);
}
.vnc-pane.status-running { border-color: rgba(0, 240, 200, 0.3); }
.vnc-pane.status-success { border-color: rgba(0, 230, 138, 0.35); }
.vnc-pane.status-failed { border-color: rgba(255, 68, 102, 0.3); }
.vnc-pane iframe {
  width: 100%;
  height: 100%;
  border: 0;
  background: #000;
  flex: 1;
  min-height: 220px;
}
.vnc-pane .pane-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 12px;
  background: rgba(10, 12, 17, 0.95);
  border-bottom: 1px solid var(--line-hard);
  font-size: 12px;
  gap: var(--space-2);
  flex-shrink: 0;
  min-height: 42px;
}
.pane-title {
  font-weight: 650;
  letter-spacing: -0.1px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  min-width: 0;
  font-family: var(--mono);
  font-size: 12px;
}
.pane-title b { color: #fff; }
.pane-actions {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.pane-fallback {
  flex: 1;
  display: grid;
  place-content: center;
  text-align: center;
  gap: var(--space-2);
  padding: var(--space-5);
  background: rgba(5, 7, 9, 0.95);
  min-height: 220px;
}
.pane-fallback p {
  margin: 0;
  color: var(--mute);
  font-size: 13px;
  line-height: 1.5;
  max-width: 36ch;
}
.pane-fallback b { color: var(--ink); }

.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: var(--space-3);
  min-height: 120px;
}
.agent-card {
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: var(--panel);
  box-shadow: var(--shadow-card);
}
.agent-card .agent-h {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: 8px;
  font-size: 13.5px;
}
.agent-card .agent-h .dot { margin-right: 6px; }
.agent-body .m {
  color: var(--mute);
  font-size: 12px;
  margin: 3px 0;
  word-break: break-all;
}
.agent-body .m b {
  color: var(--ink-soft);
  font-weight: 650;
  margin-right: 6px;
}
.agent-card.status-running { border-color: rgba(0, 240, 200, 0.35); }
.agent-card.status-success { border-color: rgba(0, 230, 138, 0.35); }
.agent-card.status-failed { border-color: rgba(255, 68, 102, 0.3); }
#agentsBoard { position: relative; min-height: 280px; }
#theaterEmpty.hide { display: none; }

.empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  text-align: center;
  color: var(--mute);
  padding: 32px 24px;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  margin: 48px 10px 10px;
  background: rgba(5, 7, 9, 0.9);
  gap: 0;
}
.empty-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  margin: 0 auto 16px;
  border: 1px solid var(--line-hard);
  border-radius: 50%;
  background: var(--panel);
  color: var(--mute2);
  font-family: var(--mono);
  font-size: 14px;
  box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
}
.empty h2 {
  margin: 0 0 8px;
  color: #fff;
  letter-spacing: -0.5px;
  font-weight: 780;
  font-size: 20px;
}
.empty p {
  margin: 0 auto;
  max-width: 400px;
  font-size: 13px;
  line-height: 1.55;
}
.empty .btn {
  width: max-content;
  margin: 20px auto 0;
  pointer-events: auto;
}
.empty .hint {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--mute2);
}
.theater-frames:not(:empty) ~ .empty,
.theater-stage:has(.vnc-pane) .empty { display: none; }
#theaterEmpty.hide { display: none; }

/* ── Tables ── */
.table-wrap {
  overflow: auto;
  border-radius: var(--radius-sm);
  -webkit-overflow-scrolling: touch;
  padding: 0 !important;
}
.table-wrap.card::before { display: none; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  font-variant-numeric: tabular-nums;
}
th, td {
  text-align: left;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}
th {
  color: var(--accent);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  background: rgba(8, 10, 16, 0.95);
  position: sticky;
  top: 0;
  z-index: 1;
  box-shadow: 0 1px 0 var(--line);
  border-bottom: 1px solid var(--line-hard);
}
tbody tr { transition: background 0.12s ease; }
tbody tr:hover { background: rgba(0, 240, 200, 0.03); }
tbody tr:nth-child(even) { background: rgba(255, 255, 255, 0.012); }
tbody tr:nth-child(even):hover { background: rgba(0, 240, 200, 0.03); }
tbody tr:last-child td { border-bottom: 0; }
td .btn.xs { vertical-align: middle; }
td { font-family: var(--mono); font-size: 12px; }
td.row-actions {
  white-space: nowrap;
  min-width: 148px;
  width: 1%;
  text-align: right;
  vertical-align: middle;
}
td.row-actions .btn.xs {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  min-width: 64px;
  margin-left: 6px;
  white-space: nowrap;
  vertical-align: middle;
}
td.row-actions .btn.xs:first-child { margin-left: 0; }
table td:first-child {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile-email { color: #fff; font-weight: 650; }
.route-cell {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.route-cell code { color: var(--ink-soft); font-family: var(--mono); font-size: 11px; }
.table-state {
  padding: 28px 16px !important;
  color: var(--mute) !important;
  font-family: var(--font) !important;
  text-align: center !important;
}
.hint {
  color: var(--mute);
  font-size: 12px;
  line-height: 1.45;
}

/* ── Settings ── */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(260px, 0.55fr);
  gap: 14px;
  align-items: start;
}
.settings-card { padding: 20px; }
.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
  position: relative;
}
.section-heading::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 60px;
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}
.section-heading h2,
.settings-note h2 {
  margin: 4px 0 0;
  color: #fff;
  font-size: 17px;
  line-height: 1.25;
  letter-spacing: -0.3px;
  font-weight: 720;
}
.section-heading p {
  max-width: 45ch;
  margin: 0;
  color: var(--mute);
  font-size: 11.5px;
  line-height: 1.5;
}
.settings-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: start;
}
.settings-fields label small {
  min-height: 32px;
  color: var(--mute2);
  font-size: 10.5px;
  font-weight: 500;
  line-height: 1.45;
  letter-spacing: 0;
  text-transform: none;
}
.settings-toggles {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}
.toggle-row {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 3px 10px;
  align-items: center;
  min-height: 64px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: rgba(5, 7, 9, 0.6);
  cursor: pointer;
  transition: all 0.15s ease;
}
.toggle-row:hover { border-color: rgba(0, 240, 200, 0.15); }
.toggle-row input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}
.toggle-control {
  position: relative;
  grid-row: 1;
  width: 36px;
  height: 20px;
  border: 1px solid #333d50;
  border-radius: 999px;
  background: #111822;
  transition: all 0.15s ease;
}
.toggle-control::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mute);
  transition: all 0.15s ease;
}
.toggle-row input:checked + .toggle-control {
  border-color: var(--accent-deep);
  background: linear-gradient(135deg, var(--accent-deep), var(--accent));
  box-shadow: 0 0 8px rgba(0, 240, 200, 0.15);
}
.toggle-row input:checked + .toggle-control::after {
  transform: translateX(16px);
  background: #050709;
}
.toggle-row input:focus-visible + .toggle-control { box-shadow: var(--focus-ring); }
.toggle-row > span:last-child { display: grid; gap: 3px; }
.toggle-row b { color: var(--ink-soft); font-size: 12px; }
.toggle-row small { color: var(--mute2); font-size: 10.5px; line-height: 1.4; }
.fixed-setting {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-xs);
  background: rgba(5, 7, 9, 0.6);
}
.fixed-setting-mark {
  display: grid;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(0, 230, 138, 0.3);
  border-radius: 50%;
  background: rgba(0, 230, 138, 0.08);
  color: var(--ok);
  font-size: 12px;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(0, 230, 138, 0.1);
}
.fixed-setting > span:nth-child(2) { display: grid; gap: 3px; }
.fixed-setting b { color: var(--ink-soft); font-size: 12px; }
.fixed-setting small { color: var(--mute2); font-size: 10.5px; line-height: 1.4; }
.fixed-setting .pill { white-space: nowrap; }
.inline-status {
  min-height: 18px;
  margin: 14px 0 0;
  color: var(--mute);
  font-size: 11.5px;
}
.inline-status.success { color: var(--ok); }
.inline-status.error { color: var(--bad); }
.settings-note { padding: 20px; }
.settings-note dl { margin: 16px 0 0; }
.settings-note dl > div {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 10px;
  padding: 11px 0;
  border-top: 1px solid var(--line);
}
.settings-note dt {
  color: var(--accent);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}
.settings-note dd {
  margin: 0;
  color: var(--mute);
  font-size: 11px;
  line-height: 1.45;
}

/* ── Toasts ── */
.toast-region {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1200;
  display: grid;
  gap: 8px;
  width: min(380px, calc(100vw - 24px));
  pointer-events: none;
}
.toast {
  display: grid;
  grid-template-columns: 3px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px 12px 0;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  background: rgba(12, 15, 22, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.5);
  color: var(--ink-soft);
  font-size: 12.5px;
  line-height: 1.45;
  pointer-events: auto;
  animation: toast-in 0.2s ease-out;
}
.toast::before {
  content: "";
  align-self: stretch;
  background: var(--accent);
  border-radius: 2px;
  box-shadow: 0 0 6px rgba(0, 240, 200, 0.3);
}
.toast.success::before { background: var(--ok); box-shadow: 0 0 6px rgba(0, 230, 138, 0.3); }
.toast.error::before { background: var(--bad); box-shadow: 0 0 6px rgba(255, 68, 102, 0.3); }
.toast button {
  border: 0;
  background: transparent;
  color: var(--mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: color 0.1s;
}
.toast button:hover { color: #fff; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Proxy workspace ── */
.proxy-concepts {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}
.proxy-concept {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  min-width: 0;
  padding: 12px 14px;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  background: var(--panel);
  box-shadow: var(--shadow-card);
  transition: all 0.15s ease;
}
.proxy-concept:hover {
  border-color: rgba(0, 240, 200, 0.12);
}
.proxy-concept > div {
  min-width: 0;
  display: grid;
  gap: 4px;
}
.proxy-concept strong {
  color: var(--ink);
  font-size: 12px;
}
.proxy-concept span:not(.proxy-step) {
  color: var(--mute);
  font-size: 11.5px;
  line-height: 1.4;
}
.proxy-concept code,
.proxy-route-row code,
.proxy-preview-row code {
  font-family: var(--mono);
  font-size: 11.5px;
}
.proxy-step {
  display: inline-grid;
  flex: 0 0 26px;
  width: 26px;
  height: 26px;
  place-items: center;
  border: 1px solid rgba(0, 240, 200, 0.3);
  border-radius: 50%;
  background: var(--accent-dim);
  color: var(--accent);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  box-shadow: 0 0 8px rgba(0, 240, 200, 0.06);
}
.proxy-workspace { margin-bottom: 14px; }
.proxy-mode-seg { flex: 0 0 auto; }
.proxy-mode-notice {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 10px 12px;
  margin-bottom: 12px;
  border: 1px solid rgba(0, 240, 200, 0.2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-xs);
  background: var(--accent-dim);
}
.proxy-mode-notice.append {
  border-color: rgba(0, 230, 138, 0.2);
  border-left-color: var(--ok);
  background: var(--ok-dim);
}
.proxy-mode-notice strong { color: var(--ink); font-size: 12px; white-space: nowrap; }
.proxy-mode-notice span { color: var(--mute); font-size: 11.5px; line-height: 1.35; }
.proxy-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  margin-bottom: 14px;
  overflow: hidden;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-xs);
  background: var(--line-hard);
}
.proxy-summary > div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
  padding: 10px 12px;
  background: rgba(8, 10, 16, 0.95);
}
.proxy-summary span {
  color: var(--mute2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.proxy-summary strong {
  color: #fff;
  font-family: var(--mono);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.proxy-editor-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(250px, 0.75fr);
  gap: 14px;
  align-items: stretch;
}
.proxy-editor { min-width: 0; }
.proxy-editor > label {
  display: block;
  margin-bottom: 7px;
  color: var(--mute2);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.proxy-editor textarea { min-height: 330px; }
.proxy-editor .hint { margin: 8px 0 0; }
.proxy-preview {
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--line-hard);
  border-radius: var(--radius-sm);
  background: rgba(5, 7, 9, 0.8);
}
.proxy-preview .card-h { margin-bottom: 6px; }
.proxy-preview > .hint { margin: 10px 2px 0; }
.proxy-preview-rows {
  display: grid;
  max-height: 330px;
  overflow: auto;
  scrollbar-width: thin;
}
.proxy-preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 4px 8px;
  align-items: center;
  padding: 8px 4px;
  border-bottom: 1px solid var(--line-soft);
}
.proxy-preview-row code {
  overflow: hidden;
  color: var(--ink-soft);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proxy-preview-row small {
  grid-column: 1 / -1;
  color: var(--mute2);
  font-size: 9px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
}
.proxy-preview-row.invalid { color: var(--bad); }
.proxy-preview-empty,
.proxy-preview-more,
.proxy-routes-empty {
  padding: 18px 8px;
  color: var(--mute);
  font-size: 11.5px;
  line-height: 1.5;
  text-align: center;
}
.proxy-preview-more { padding: 10px 4px 3px; color: var(--accent); }
.scheme-chip {
  display: inline-flex;
  align-items: center;
  width: max-content;
  max-width: 100%;
  padding: 3px 7px;
  border: 1px solid var(--line-hard);
  border-radius: 999px;
  background: var(--panel-hi);
  color: var(--mute);
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.3px;
  white-space: nowrap;
}
.scheme-chip.explicit {
  border-color: rgba(0, 230, 138, 0.25);
  background: var(--ok-dim);
  color: var(--ok);
}
.scheme-chip.automatic {
  border-color: rgba(0, 240, 200, 0.25);
  background: var(--accent-dim);
  color: var(--accent);
}
.proxy-save-status {
  min-height: 18px;
  padding-left: 10px;
  border-left: 2px solid transparent;
}
.proxy-save-status.pending { border-left-color: var(--accent); color: var(--accent); }
.proxy-save-status.success { border-left-color: var(--ok); color: var(--ok); }
.proxy-save-status.error { border-left-color: var(--bad); color: var(--bad); }
.proxy-routes-card { padding: 14px 16px; }
.proxy-routes-card .card-h > div { min-width: 0; }
.proxy-routes-card .card-h .hint { margin: 3px 0 0; }
.proxy-route-head,
.proxy-route-row {
  display: grid;
  grid-template-columns: minmax(110px, 0.7fr) minmax(150px, 1.2fr) minmax(105px, 0.65fr) minmax(120px, 0.75fr) 86px;
  gap: 10px;
  align-items: center;
}
.proxy-route-head {
  padding: 4px 8px 8px;
  color: var(--accent);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
}
.proxy-route-row {
  min-height: 48px;
  padding: 9px 8px;
  border-top: 1px solid var(--line-soft);
  font-size: 11.5px;
}
.proxy-route-row > span:first-child { display: grid; gap: 2px; min-width: 0; }
.proxy-route-row b,
.proxy-route-row small,
.proxy-route-row code {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.proxy-route-row b { color: var(--ink); }
.proxy-route-row small { color: var(--mute2); font-size: 10px; }
.proxy-route-row code { color: var(--ink-soft); }
.vnc-input-note {
  margin: -4px 0 14px;
  padding: 9px 12px;
  border-left: 2px solid var(--accent);
  background: var(--accent-dim);
  color: var(--mute);
  font-size: 11.5px;
  line-height: 1.45;
  border-radius: 0 var(--radius-xs) var(--radius-xs) 0;
}
.vnc-input-note strong { color: var(--ink-soft); }
.session-card .proxy-pair {
  display: grid;
  gap: 2px;
  font-family: var(--mono);
  font-size: 10.5px;
}

/* ══════ Responsive ══════ */
@media (max-width: 1440px) {
  .content { padding: 20px 22px 28px; }
  .kpis { gap: 8px; }
  .kpi .val { font-size: 24px; }
}

@media (max-width: 1100px) {
  :root { --sidebar-w: 210px; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .split { grid-template-columns: 1fr; }
  .side-card { min-height: 0; }
  .content { padding: 16px 16px 24px; }
  .topbar h1 { font-size: 22px; }
  .theater-frames { height: min(60vh, 540px); }
  .proxy-editor-grid { grid-template-columns: minmax(0, 1fr) minmax(230px, 0.65fr); }
  .run-commandbar { grid-template-columns: 100px minmax(250px, 0.85fr) minmax(360px, 1.15fr); }
  .settings-layout { grid-template-columns: minmax(0, 1.3fr) minmax(230px, 0.7fr); }
}

@media (max-width: 1024px) {
  #app { grid-template-columns: 1fr; }
  .sidebar {
    height: auto;
    position: relative;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 14px 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line-hard);
  }
  .sidebar::after { display: none; }
  .brand { padding: 0 8px 0 0; }
  .brand-sub { display: none; }
  .nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: 1;
    gap: 4px;
  }
  .nav-btn {
    padding: 10px 12px;
    min-height: var(--hit);
  }
  .nav-btn.active {
    box-shadow: inset 0 -2px 0 var(--accent);
  }
  .nav-btn.active::before { display: none; }
  .side-foot {
    width: auto;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    margin: 0 0 0 auto;
    padding: 0;
    border-top: 0;
  }
  .side-foot > .hint { display: none; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .theater-stage { min-height: 420px; }
  .theater-frames.mosaic-mode {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .content,
  .panel,
  .card,
  .theater-stage,
  .split,
  .kpis { max-width: 100%; }
  .session-card .m,
  .pane-title { overflow-wrap: anywhere; }
}

@media (max-width: 768px) {
  .sidebar {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    grid-template-areas: "brand foot" "nav nav";
    gap: 8px 10px;
    padding: 10px 12px 8px;
  }
  .sidebar .brand { grid-area: brand; }
  .sidebar .nav {
    grid-area: nav;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    width: 100%;
    gap: 3px;
  }
  .sidebar .side-foot {
    grid-area: foot;
    justify-self: end;
    min-width: 0;
  }
  .sidebar .side-foot .pill { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sidebar .nav-btn { padding: 8px 5px; text-align: center; font-size: 11.5px; }
  .sidebar .nav-btn.active { box-shadow: inset 0 -2px 0 var(--accent); }
  .content { padding: 14px 12px 22px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .kpi { padding: 11px 11px 10px; }
  .kpi .val { font-size: 20px; }
  .topbar { margin-bottom: 12px; gap: 10px; padding-bottom: 12px; }
  .topbar h1 { font-size: 20px; letter-spacing: -0.4px; }
  .actions { width: 100%; }
  .actions .btn,
  .actions .seg-btn,
  .field input {
    min-height: var(--hit);
  }
  .seg-btn { padding: 10px 14px; }
  .btn.xs { min-height: 36px; padding: 0 12px; }
  .theater-frames { height: min(56vh, 500px); }
  .theater-frames.mosaic-mode {
    grid-template-columns: 1fr;
  }
  .theater-frames.mosaic-mode .vnc-pane {
    height: min(48vh, 320px);
  }
  .theater-stage { min-height: 380px; padding: 10px; }
  .pane-h { min-height: 44px; }
  .log { height: 260px; }
  .session-strip { max-height: 260px; }
  .form-grid { grid-template-columns: 1fr; }
  .card { padding: 12px; }
  .banner { padding: 10px 12px; }
  th, td { padding: 10px 10px; white-space: nowrap; }
  .table-wrap { margin: 0 -2px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .actions { gap: 8px; }
  .actions .btn { flex: 1 1 auto; }
  .run-commandbar { grid-template-columns: 86px minmax(0, 1fr); }
  .run-engine-group { grid-column: 1 / -1; }
  .run-command-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .run-command-actions .btn { width: 100%; }
  .run-primary-group .run-command-actions { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .settings-layout { grid-template-columns: 1fr; }
  .settings-fields { grid-template-columns: 1fr; }
  .settings-toggles { grid-template-columns: 1fr; }
  .section-heading { display: grid; gap: 8px; }
  #panel-profiles .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
    box-shadow: none;
  }
  #panel-profiles table,
  #panel-profiles tbody { display: block; }
  #panel-profiles thead { display: none; }
  #panel-profiles tbody { display: grid; gap: 8px; }
  #panel-profiles tbody tr {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 12px;
    border: 1px solid var(--line-hard);
    border-radius: var(--radius-sm);
    background: var(--panel);
  }
  #panel-profiles tbody tr:has(.table-state) { display: block; }
  #panel-profiles tbody .table-state { display: block; }
  #panel-profiles tbody .table-state::before { display: none; }
  #panel-profiles tbody td {
    display: grid;
    gap: 3px;
    min-width: 0;
    padding: 8px;
    border: 0;
    white-space: normal;
  }
  #panel-profiles tbody td::before {
    content: attr(data-label);
    color: var(--mute2);
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.6px;
    text-transform: uppercase;
  }
  #panel-profiles tbody td:first-child {
    grid-column: 1 / -1;
    max-width: none;
  }
  #panel-profiles td.row-actions {
    grid-column: 1 / -1;
    display: flex;
    width: 100%;
    padding-top: 10px;
    border-top: 1px solid var(--line-soft);
  }
  #panel-profiles td.row-actions::before { display: none; }
  #panel-profiles td.row-actions .btn { flex: 1; }
  .proxy-mode-seg { flex: 1 1 100%; }
  .proxy-mode-seg .seg-btn { flex: 1 1 50%; }
  .proxy-concepts { grid-template-columns: 1fr; gap: 7px; }
  .proxy-concept { padding: 9px 10px; }
  .proxy-summary { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .proxy-editor-grid { grid-template-columns: 1fr; }
  .proxy-editor textarea { min-height: 260px; }
  .proxy-preview-rows { max-height: 240px; }
  .proxy-mode-notice { align-items: flex-start; flex-direction: column; gap: 3px; }
  .proxy-route-head { display: none; }
  .proxy-route-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 9px 12px;
    padding: 11px 4px;
  }
  .proxy-route-row > * {
    display: grid;
    gap: 3px;
    min-width: 0;
  }
  .proxy-route-row > *::before {
    content: attr(data-label);
    color: var(--mute2);
    font-family: var(--font);
    font-size: 9px;
    font-weight: 700;
    letter-spacing: 0.55px;
    text-transform: uppercase;
  }
}

@media (max-width: 390px) {
  .content { padding: 10px 8px 18px; }
  .brand-title { font-size: 14px; }
  .brand-mark { width: 26px; height: 26px; }
  .sidebar { padding-inline: 8px; }
  .sidebar .side-foot .pill { display: none; }
  .sidebar .nav-btn { padding-inline: 2px; font-size: 10.5px; }
  .nav-btn {
    padding: 9px 10px;
    font-size: 12px;
    min-height: var(--hit);
  }
  .kpis { grid-template-columns: 1fr 1fr; gap: 6px; }
  .kpi .lab { font-size: 9px; }
  .kpi .val { font-size: 18px; }
  .topbar h1 { font-size: 18px; }
  .sub { font-size: 12px; }
  .login-card { padding: 24px 16px 18px; border-radius: var(--radius); }
  .login-card input,
  .login-submit { min-height: var(--hit); }
  .empty {
    margin: 44px 4px 4px;
    padding: 20px 10px;
  }
  .empty h2 { font-size: 16px; }
  .theater-tabs { gap: 4px; }
  .tab {
    padding: 8px 10px;
    min-height: var(--hit);
    font-size: 11.5px;
  }
  .btn,
  .btn.xs,
  .seg-btn {
    min-height: var(--hit);
    padding: 0 12px;
  }
  .btn.xs { padding: 0 10px; }
  .field { width: 100%; }
  .field input { flex: 1; width: auto; min-width: 64px; }
  .run-commandbar { grid-template-columns: 72px minmax(0, 1fr); }
  .run-count-control,
  .run-command-group { padding: 9px; }
  .run-primary-group .run-command-actions { grid-template-columns: 1fr; }
  .run-engine-group .run-command-actions { grid-template-columns: 1fr 1fr; }
  .proxy-summary { grid-template-columns: 1fr 1fr; }
  .proxy-summary > div { padding: 8px; }
  .proxy-summary span { font-size: 8.5px; }
  .proxy-route-row { grid-template-columns: 1fr; }
  .proxy-routes-card { padding: 10px; }
  .vnc-input-note { margin-top: 0; }
  .fixed-setting { grid-template-columns: 28px minmax(0, 1fr); }
  .fixed-setting .pill { grid-column: 2; justify-self: start; }
  .toast-region { right: 8px; bottom: 8px; width: calc(100vw - 16px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
  .panel.active,
  .theater-frames.tabs-mode .vnc-pane.active {
    animation: none !important;
  }
  .kpi:hover,
  .session-card:hover,
  .theater-frames.mosaic-mode .vnc-pane:hover {
    transform: none !important;
  }
}
