/* ═══════════════════════════════════════════════════════════════════════════
   SSHOS — Design System
   Dark terminal-inspired theme with glassmorphism, Inter + JetBrains Mono
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Custom Properties ─────────────────────────────────────────────────────── */

:root {
  /* Palette */
  --bg-base:       #0a0e1a;
  --bg-surface:    #0f1525;
  --bg-elevated:   #141c30;
  --bg-card:       #192038;
  --bg-input:      #0d1220;
  --bg-hover:      #1e2840;
  --bg-active:     #243050;

  /* Accent — Electric cyan */
  --accent:        #00d4ff;
  --accent-dim:    #0099bb;
  --accent-glow:   rgba(0, 212, 255, 0.15);
  --accent-subtle: rgba(0, 212, 255, 0.08);

  /* Text */
  --text-primary:   #e8edf8;
  --text-secondary: #8899bb;
  --text-muted:     #4a5a7a;
  --text-accent:    #00d4ff;

  /* Status */
  --green:         #22c55e;
  --green-dim:     rgba(34, 197, 94, 0.15);
  --yellow:        #f59e0b;
  --yellow-dim:    rgba(245, 158, 11, 0.15);
  --red:           #ef4444;
  --red-dim:       rgba(239, 68, 68, 0.15);
  --blue:          #3b82f6;
  --blue-dim:      rgba(59, 130, 246, 0.15);

  /* Borders */
  --border:        rgba(255, 255, 255, 0.07);
  --border-accent: rgba(0, 212, 255, 0.3);
  --border-focus:  rgba(0, 212, 255, 0.6);

  /* Typography */
  --font-ui:       'Inter', system-ui, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', 'Consolas', monospace;

  /* Sizing */
  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  16px;
  --radius-xl:  24px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow:     0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-accent: 0 0 24px rgba(0, 212, 255, 0.15);

  /* Transitions */
  --t-fast:   120ms ease;
  --t-normal: 200ms ease;
  --t-slow:   350ms ease;

  /* Layout */
  --sidebar-width:   260px;
  --topbar-height:   52px;
}

/* ── Reset ─────────────────────────────────────────────────────────────────── */

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

html { height: 100%; font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-ui);
  background: var(--bg-base);
  color: var(--text-primary);
  height: 100%;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* ── Scrollbar ─────────────────────────────────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-base); }
::-webkit-scrollbar-thumb { background: var(--bg-active); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ── Typography ────────────────────────────────────────────────────────────── */

h1, h2, h3, h4 { font-weight: 600; line-height: 1.3; }
h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.1rem; }

a { color: var(--accent); text-decoration: none; transition: opacity var(--t-fast); }
a:hover { opacity: 0.8; }

code, pre, .mono { font-family: var(--font-mono); }

/* ── Flash Messages ────────────────────────────────────────────────────────── */

.flash {
  position: fixed;
  top: 16px; right: 16px; z-index: 9999;
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  backdrop-filter: blur(12px);
  animation: slideIn var(--t-slow) ease;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.flash--success { background: rgba(34,197,94,0.15); border: 1px solid var(--green); color: var(--green); }
.flash--error   { background: rgba(239,68,68,0.15); border: 1px solid var(--red);   color: var(--red); }
.flash--info    { background: rgba(0,212,255,0.1);  border: 1px solid var(--accent); color: var(--accent); }
.flash button   { background: none; border: none; cursor: pointer; color: inherit; font-size: 1.2rem; line-height: 1; margin-left: auto; }

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* ── Auth Layout ───────────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-base);
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -20%, rgba(0,212,255,0.08) 0%, transparent 60%),
    radial-gradient(ellipse 50% 40% at 80% 100%, rgba(59,130,246,0.06) 0%, transparent 50%);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg);
  animation: fadeUp 0.4s ease;
}

@keyframes fadeUp {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.auth-logo .logo-icon {
  width: 40px; height: 40px;
  background: linear-gradient(135deg, var(--accent), #0077cc);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 0 20px rgba(0,212,255,0.3);
}

.auth-logo .logo-text {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(90deg, #fff 60%, var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.auth-title { font-size: 1.3rem; font-weight: 600; margin-bottom: 6px; }
.auth-sub   { color: var(--text-secondary); font-size: 0.9rem; margin-bottom: 28px; }

.auth-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 0.875rem;
  color: var(--text-secondary);
}

/* ── Form Elements ─────────────────────────────────────────────────────────── */

.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.form-input {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 0.95rem;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  outline: none;
}

.form-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.form-input::placeholder { color: var(--text-muted); }

select.form-input {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238899bb' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

textarea.form-input { resize: vertical; min-height: 100px; font-family: var(--font-mono); font-size: 0.85rem; }

.form-hint { font-size: 0.8rem; color: var(--text-muted); margin-top: 6px; }

/* ── Buttons ───────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  text-decoration: none;
  white-space: nowrap;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--accent), #0077ee);
  color: #000;
  font-weight: 600;
  box-shadow: 0 0 20px rgba(0,212,255,0.2);
}
.btn-primary:hover:not(:disabled) { box-shadow: 0 0 28px rgba(0,212,255,0.35); transform: translateY(-1px); opacity: 1; }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { background: var(--bg-hover); border-color: var(--border-accent); opacity: 1; }

.btn-danger {
  background: var(--red-dim);
  color: var(--red);
  border-color: rgba(239,68,68,0.3);
}
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.25); opacity: 1; }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-hover); color: var(--text-primary); opacity: 1; }

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 13px 28px; font-size: 1rem; }
.btn-full { width: 100%; }

.btn-icon {
  width: 36px; height: 36px;
  padding: 0;
  border-radius: var(--radius-sm);
}

/* ── Alerts ────────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert ul { margin: 4px 0 0 16px; }
.alert-error   { background: var(--red-dim);    border: 1px solid rgba(239,68,68,0.3);  color: #fca5a5; }
.alert-success { background: var(--green-dim);  border: 1px solid rgba(34,197,94,0.3);  color: #86efac; }
.alert-warning { background: var(--yellow-dim); border: 1px solid rgba(245,158,11,0.3); color: #fcd34d; }
.alert-info    { background: var(--accent-subtle); border: 1px solid var(--border-accent); color: var(--accent); }

/* ── App Shell ─────────────────────────────────────────────────────────────── */

.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ── Top Bar ───────────────────────────────────────────────────────────────── */

.topbar {
  height: var(--topbar-height);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  flex-shrink: 0;
  z-index: 100;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
}

.topbar-logo .logo-mark {
  width: 30px; height: 30px;
  background: linear-gradient(135deg, var(--accent), #0077cc);
  border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.85rem;
  flex-shrink: 0;
  box-shadow: 0 0 12px rgba(0,212,255,0.25);
}

.topbar-logo .logo-name {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: 8px;
}

.topbar-nav a {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}

.topbar-nav a:hover,
.topbar-nav a.active {
  background: var(--bg-elevated);
  color: var(--text-primary);
  opacity: 1;
}

.topbar-nav a.active { color: var(--accent); }

.topbar-spacer { flex: 1; }

.topbar-user {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}

.user-badge:hover { border-color: var(--border-accent); }

.user-avatar {
  width: 26px; height: 26px;
  background: linear-gradient(135deg, var(--accent), #0055aa);
  border-radius: 6px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
  color: #000;
  flex-shrink: 0;
}

.user-role-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.user-role-badge.admin { background: rgba(245,158,11,0.15); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.user-role-badge.user  { background: var(--accent-subtle); color: var(--accent); border: 1px solid var(--border-accent); }

/* ── User Dropdown ─────────────────────────────────────────────────────────── */

.user-dropdown {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 180px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-8px);
  transition: all var(--t-normal);
  z-index: 1000;
}

.user-badge:focus-within .user-dropdown,
.user-badge.open .user-dropdown {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  cursor: pointer;
}

.dropdown-item:hover { background: var(--bg-hover); color: var(--text-primary); opacity: 1; }
.dropdown-item.danger:hover { background: var(--red-dim); color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ── App Body (sidebar + main) ─────────────────────────────────────────────── */

.app-body {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────────────────────── */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-section {
  padding: 12px 10px 8px;
}

.sidebar-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 0 6px;
  margin-bottom: 4px;
}

.sidebar-list {
  list-style: none;
  flex: 1;
  overflow-y: auto;
}

.sidebar-server {
  margin-bottom: 2px;
}

.sidebar-server-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border: none;
  background: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all var(--t-fast);
  text-align: left;
}

.sidebar-server-btn:hover { background: var(--bg-hover); color: var(--text-primary); }

.server-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
  transition: background var(--t-fast);
}
.server-dot.connected { background: var(--green); box-shadow: 0 0 6px var(--green); }
.server-dot.idle      { background: var(--yellow); }

.server-sessions {
  margin-left: 24px;
  margin-bottom: 4px;
}

.session-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--t-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.session-item:hover { background: var(--bg-hover); color: var(--text-secondary); }
.session-item.active { background: var(--bg-active); color: var(--text-primary); }
.session-item.active::before { content: ''; width: 2px; height: 14px; background: var(--accent); border-radius: 1px; flex-shrink: 0; }

.sidebar-actions {
  padding: 10px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Main Area ─────────────────────────────────────────────────────────────── */

.main-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ── Tab Bar ───────────────────────────────────────────────────────────────── */

.tab-bar {
  height: 38px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  padding: 0 8px;
  gap: 2px;
  overflow-x: auto;
  flex-shrink: 0;
}

.tab-bar::-webkit-scrollbar { height: 3px; }

.terminal-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  border-bottom: none;
  background: none;
  transition: all var(--t-fast);
  white-space: nowrap;
  max-width: 200px;
}

.terminal-tab:hover { background: var(--bg-elevated); color: var(--text-secondary); }

.terminal-tab.active {
  background: var(--bg-base);
  border-color: var(--border);
  color: var(--text-primary);
  position: relative;
}

.terminal-tab.active::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: var(--bg-base);
}

.tab-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted);
  padding: 2px; border-radius: 3px;
  line-height: 1; font-size: 0.9rem;
  transition: all var(--t-fast);
}
.tab-close:hover { background: var(--bg-hover); color: var(--red); }

.tab-add {
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  background: none; cursor: pointer;
  font-size: 1.1rem;
  margin-bottom: 4px;
  transition: all var(--t-fast);
  flex-shrink: 0;
  margin-left: 4px;
}
.tab-add:hover { border-color: var(--accent); color: var(--accent); }

/* ── Terminal Panes ────────────────────────────────────────────────────────── */

.terminal-pane-container {
  flex: 1;
  position: relative;
  overflow: hidden;
}

.terminal-pane {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}

.terminal-pane.active { display: flex; }

.terminal-status-bar {
  height: 24px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  flex-shrink: 0;
}

.status-indicator {
  display: flex; align-items: center; gap: 5px;
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
}
.status-dot.connected { background: var(--green); }
.status-dot.connecting { background: var(--yellow); animation: pulse 1s infinite; }
.status-dot.error { background: var(--red); }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

/* ── Welcome Screen (no terminal) ──────────────────────────────────────────── */

.welcome-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 16px;
  color: var(--text-muted);
}

.welcome-screen .welcome-icon {
  font-size: 3rem;
  opacity: 0.3;
}

.welcome-screen h2 {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.welcome-screen p {
  font-size: 0.875rem;
  text-align: center;
  max-width: 340px;
  line-height: 1.7;
}

/* ── Page Content (servers, keys, settings, admin) ─────────────────────────── */

.page-content {
  flex: 1;
  overflow-y: auto;
  padding: 28px;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  gap: 16px;
}

.page-header h1 { font-size: 1.4rem; }
.page-header p  { color: var(--text-secondary); font-size: 0.875rem; margin-top: 3px; }

/* ── Cards ─────────────────────────────────────────────────────────────────── */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header h2, .card-header h3 { font-size: 1rem; font-weight: 600; }
.card-body { padding: 20px; }

/* ── Tables ────────────────────────────────────────────────────────────────── */

.table-wrap { overflow-x: auto; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--bg-hover); color: var(--text-primary); }
.data-table td:first-child { color: var(--text-primary); font-weight: 500; }

.data-table .mono { font-family: var(--font-mono); font-size: 0.8rem; color: var(--text-muted); }

/* ── Status Badges ─────────────────────────────────────────────────────────── */

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.badge-green  { background: var(--green-dim);  color: var(--green);  border: 1px solid rgba(34,197,94,0.3); }
.badge-yellow { background: var(--yellow-dim); color: var(--yellow); border: 1px solid rgba(245,158,11,0.3); }
.badge-red    { background: var(--red-dim);    color: var(--red);    border: 1px solid rgba(239,68,68,0.3); }
.badge-blue   { background: var(--blue-dim);   color: var(--blue);   border: 1px solid rgba(59,130,246,0.3); }
.badge-muted  { background: rgba(255,255,255,0.05); color: var(--text-muted); border: 1px solid var(--border); }

.session-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  border: 1px solid var(--border-accent);
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 10px;
  padding: 1px 6px;
  line-height: 1;
  min-width: 16px;
  height: 16px;
  margin-right: 4px;
  flex-shrink: 0;
  box-shadow: 0 0 4px var(--accent-glow);
}

/* ── Modal ─────────────────────────────────────────────────────────────────── */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-normal);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: scale(0.96) translateY(8px);
  transition: transform var(--t-normal);
}

.modal-overlay.open .modal { transform: scale(1) translateY(0); }

.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-header h2 { font-size: 1.1rem; }
.modal-close {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.3rem; line-height: 1;
  padding: 4px; border-radius: var(--radius-sm);
  transition: all var(--t-fast);
}
.modal-close:hover { background: var(--bg-hover); color: var(--text-primary); }

.modal-body { padding: 20px 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Code Block ────────────────────────────────────────────────────────────── */

.code-block {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 0.825rem;
  color: var(--accent);
  word-break: break-all;
  position: relative;
  line-height: 1.7;
}

.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  padding: 4px 8px;
  font-size: 0.75rem;
}

/* ── Setup Page ────────────────────────────────────────────────────────────── */

.setup-card { max-width: 520px; }

.setup-steps {
  display: flex;
  gap: 8px;
  margin-bottom: 28px;
}

.setup-step {
  flex: 1;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
}

.setup-step.done { background: var(--accent); }

/* ── Stats Grid ────────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  transition: border-color var(--t-fast);
}

.stat-card:hover { border-color: var(--border-accent); }

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  font-family: var(--font-mono);
  line-height: 1;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--text-primary), var(--accent));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.stat-label { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; }

/* ── Toggle ────────────────────────────────────────────────────────────────── */

.toggle {
  position: relative;
  display: inline-block;
  width: 44px; height: 24px;
}

.toggle input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 24px;
  transition: all var(--t-normal);
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  left: 3px; top: 3px;
  transition: all var(--t-normal);
}

.toggle input:checked + .toggle-slider { background: var(--accent-glow); border-color: var(--accent); }
.toggle input:checked + .toggle-slider::before {
  transform: translateX(20px);
  background: var(--accent);
}

/* ── Empty State ───────────────────────────────────────────────────────────── */

.empty-state {
  text-align: center;
  padding: 48px 20px;
  color: var(--text-muted);
}

.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 12px; opacity: 0.4; }
.empty-state h3 { color: var(--text-secondary); font-weight: 500; margin-bottom: 6px; }
.empty-state p  { font-size: 0.875rem; margin-bottom: 20px; }

/* ── Utilities ─────────────────────────────────────────────────────────────── */

.flex         { display: flex; }
.flex-col     { flex-direction: column; }
.items-center { align-items: center; }
.gap-8        { gap: 8px; }
.gap-12       { gap: 12px; }
.gap-16       { gap: 16px; }
.mt-4  { margin-top: 4px; }
.mt-8  { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-4  { margin-bottom: 4px; }
.mb-8  { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.text-muted   { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-accent  { color: var(--accent); }
.text-danger  { color: var(--red); }
.text-success { color: var(--green); }
.text-sm      { font-size: 0.875rem; }
.text-xs      { font-size: 0.78rem; }
.font-mono    { font-family: var(--font-mono); }
.text-right   { text-align: right; }
.sr-only      { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* ── Responsive ────────────────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .sidebar { width: 200px; }
  .page-content { padding: 16px; }
  .auth-card { padding: 28px 20px; }
}

@media (max-width: 600px) {
  .sidebar { display: none; }
  :root { --sidebar-width: 0px; }
}

/* ── Split Grid Mode ── */
.terminal-pane-container.grid-mode {
  display: grid !important;
  grid-template-columns: repeat(var(--grid-cols, 2), 1fr) !important;
  grid-template-rows: repeat(var(--grid-rows, 2), 1fr) !important;
  gap: 8px !important;
  padding: 8px !important;
  background: var(--bg-base) !important;
}

.terminal-pane-container.grid-mode .terminal-pane {
  position: relative !important;
  inset: auto !important;
  width: 100% !important;
  height: 100% !important;
  border: 1px solid var(--border) !important;
  border-radius: var(--radius-sm) !important;
  overflow: hidden !important;
}

.terminal-pane-container.grid-mode .terminal-pane.grid-visible {
  display: flex !important;
}

.terminal-pane-container.grid-mode .terminal-pane.grid-visible.active {
  border-color: var(--accent) !important;
  box-shadow: 0 0 10px rgba(0, 212, 255, 0.15) !important;
}

/* ── Toggle Control for Sync Input ── */
.toggle-control {
  user-select: none;
  font-family: var(--font-ui);
  color: var(--text-secondary);
}

.toggle-control input[type="checkbox"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* ── Snippet Run Modal Items ── */
.snippet-checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--t-fast);
}

.snippet-checkbox-item:hover {
  border-color: var(--border-accent);
  background: var(--bg-hover);
}

.snippet-checkbox-item input {
  accent-color: var(--accent);
}

/* ── Tab Grid Checkboxes ── */
.tab-grid-chk {
  width: 13px;
  height: 13px;
  margin-right: 6px;
  cursor: pointer;
  accent-color: var(--accent);
  vertical-align: middle;
}

/* ── BYOK Keys Page CSS improvements ── */
.byok-card {
  border: 1px solid var(--border);
  background: var(--bg-surface);
  margin: 0;
  border-radius: var(--radius);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), transform var(--t-fast);
}

.byok-card:hover {
  border-color: var(--border-accent);
  box-shadow: var(--shadow-sm), 0 0 12px rgba(0, 212, 255, 0.06);
  transform: translateY(-1px);
}


