/* ============================================================
   GoShellBox — Glassmorphism Design System
   Font: Plus Jakarta Sans (UI) + JetBrains Mono (code/terminal)
   ============================================================ */

/* ── Local Fonts ──────────────────────────────────────────── */
@import url('fonts/fonts.css');

/* ── CSS Variables ────────────────────────────────────────── */
:root {
  /* Backgrounds */
  --bg-deep:     #06090f;
  --bg-base:     #0a1628;
  --bg-surface:  rgba(255,255,255,0.04);
  --bg-elevated: rgba(255,255,255,0.07);

  /* Borders */
  --border-glass: rgba(255,255,255,0.06);
  --border-hover: rgba(255,255,255,0.12);

  /* Brand */
  --primary:  #06b6d4;
  --accent:   #a855f7;
  --success:  #34d399;
  --danger:   #ef4444;
  --warning:  #fbbf24;

  /* Text */
  --text-primary:   #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted:     #64748b;

  /* Gradients */
  --grad-primary: linear-gradient(135deg, #06b6d4, #0ea5e9);
  --grad-accent:  linear-gradient(135deg, #a855f7, #7c3aed);
  --grad-mesh:    radial-gradient(ellipse at 20% 50%, rgba(6,182,212,0.08) 0%, transparent 60%),
                  radial-gradient(ellipse at 80% 20%, rgba(168,85,247,0.07) 0%, transparent 55%),
                  radial-gradient(ellipse at 50% 90%, rgba(14,165,233,0.05) 0%, transparent 50%);

  /* Spacing */
  --sp-1:  4px;
  --sp-2:  8px;
  --sp-3:  12px;
  --sp-4:  16px;
  --sp-5:  20px;
  --sp-6:  24px;
  --sp-8:  32px;
  --sp-10: 40px;

  /* Radius */
  --r-sm:  6px;
  --r-md:  10px;
  --r-lg:  14px;
  --r-xl:  20px;
  --r-2xl: 28px;

  /* Shadows */
  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow-primary: 0 0 20px rgba(6,182,212,0.25);
  --shadow-glow-accent:  0 0 20px rgba(168,85,247,0.25);

  /* Transitions */
  --t-fast:   0.15s ease;
  --t-normal: 0.25s ease;
  --t-slow:   0.4s ease;

  /* Sidebar */
  --sidebar-w:           240px;
  --sidebar-w-collapsed: 64px;
}

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

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Plus Jakarta Sans', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-deep);
  background-image: var(--grad-mesh);
  background-attachment: fixed;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
}

img, svg {
  display: block;
}

/* ── App Layout ───────────────────────────────────────────── */
#app {
  display: flex;
  min-height: 100vh;
  position: relative;
}

/* ============================================================
   SECTION 2 — Sidebar
   ============================================================ */

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: var(--sidebar-w);
  background: rgba(10,22,40,0.85);
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-right: 1px solid var(--border-glass);
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: width var(--t-normal);
  overflow: hidden;
}

.sidebar.collapsed {
  width: var(--sidebar-w-collapsed);
}

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-5) var(--sp-4);
  border-bottom: 1px solid var(--border-glass);
  min-height: 64px;
  overflow: hidden;
  white-space: nowrap;
}

.sidebar-brand-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--r-sm);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: var(--shadow-glow-primary);
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.sidebar-brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  transition: opacity var(--t-normal);
}

.sidebar.collapsed .sidebar-brand-name {
  opacity: 0;
  pointer-events: none;
}

/* Toggle button */
.sidebar-toggle {
  position: absolute;
  top: 18px;
  right: -12px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), color var(--t-fast), transform var(--t-normal);
  z-index: 10;
  font-size: 10px;
}

.sidebar-toggle:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

.sidebar.collapsed .sidebar-toggle {
  transform: rotate(180deg);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: var(--sp-4) var(--sp-2);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
  background: var(--border-hover);
  border-radius: 2px;
}

.sidebar-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  padding: var(--sp-3) var(--sp-3) var(--sp-2);
  transition: opacity var(--t-normal);
  white-space: nowrap;
}

.sidebar.collapsed .sidebar-section-label {
  opacity: 0;
}

.sidebar-nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-3);
  border-radius: var(--r-md);
  cursor: pointer;
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast);
  white-space: nowrap;
  margin-bottom: 2px;
  user-select: none;
}

.sidebar-nav-item:hover {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

.sidebar-nav-item.active {
  background: rgba(6,182,212,0.12);
  color: var(--primary);
}

.sidebar-nav-item.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}

.sidebar-nav-item .nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.8;
}

.sidebar-nav-item.active .nav-icon {
  opacity: 1;
}

/* Chevron flyout button — currently only on the Plexes nav item. Opens a
   popover with the user's plexes for quick switching. Hidden when sidebar
   is collapsed (only icons visible) since there's no room for it. */
.sidebar-nav-item .sidebar-nav-flyout {
  margin-left: auto;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted, #64748b);
  width: 22px;
  height: 22px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background var(--t-fast), border-color var(--t-fast), color var(--t-fast);
}
.sidebar-nav-item .sidebar-nav-flyout:hover {
  background: var(--bg-elevated);
  border-color: var(--border-glass, #334155);
  color: var(--primary, #67e8f9);
}
.sidebar.collapsed .sidebar-nav-flyout,
.terminal-sidebar .sidebar-nav-flyout { display: none; }

.sidebar-nav-item .nav-label {
  font-size: 13.5px;
  font-weight: 500;
  transition: opacity var(--t-normal);
}

.sidebar.collapsed .sidebar-nav-item .nav-label {
  opacity: 0;
  pointer-events: none;
}

/* Tooltip for collapsed state */
.sidebar.collapsed .sidebar-nav-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: calc(var(--sidebar-w-collapsed) + 8px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--bg-elevated);
  border: 1px solid var(--border-hover);
  color: var(--text-primary);
  font-size: 12px;
  font-weight: 500;
  padding: 6px 10px;
  border-radius: var(--r-sm);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--t-fast);
  z-index: 500;
  box-shadow: var(--shadow-md);
}

.sidebar.collapsed .sidebar-nav-item:hover::after {
  opacity: 1;
}

/* Bottom section */
.sidebar-bottom {
  padding: var(--sp-4) var(--sp-2);
  border-top: 1px solid var(--border-glass);
  overflow: hidden;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  border-radius: var(--r-md);
  white-space: nowrap;
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  transition: opacity var(--t-normal);
}

.sidebar.collapsed .sidebar-user-name {
  opacity: 0;
}

/* ============================================================
   SECTION 3 — Main Content & Top Bar
   ============================================================ */

.main-content {
  flex: 1;
  min-width: 0; /* prevent flex item from expanding beyond container due to wide content */
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left var(--t-normal);
}

.main-content.sidebar-collapsed {
  margin-left: var(--sidebar-w-collapsed);
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: 64px;
  padding: 0 var(--sp-6);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(10,22,40,0.75);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-bottom: 1px solid var(--border-glass);
  gap: var(--sp-4);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  flex: 1;
  min-width: 0;
}

/* Hamburger menu button in topbar — hidden on desktop, visible on mobile */
.topbar-menu-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
}

.topbar-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--grad-accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  border: 2px solid var(--border-hover);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.topbar-avatar:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow-accent);
}

.topbar-logout-btn {
  display: none;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--r-md);
  background: transparent;
  border: 1px solid var(--border-glass);
  color: var(--text-secondary);
  cursor: pointer;
  flex-shrink: 0;
}

.topbar-logout-btn:hover {
  background: rgba(239,68,68,0.1);
  border-color: var(--danger);
  color: var(--danger);
}

/* Main content area */
.content-area {
  flex: 1;
  min-width: 0; /* prevent flex item from expanding beyond main-content */
  padding: var(--sp-6);
  overflow-y: auto;
}

/* Page header */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.page-header-info h1 {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.page-header-info p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.page-header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-shrink: 0;
}

/* ============================================================
   SECTION 4 — Glass Card & Stats
   ============================================================ */

.glass-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--sp-5) var(--sp-6);
}

.glass-card-hoverable {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-xl);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: var(--sp-5) var(--sp-6);
  transition: border-color var(--t-normal), background var(--t-normal), transform var(--t-normal), box-shadow var(--t-normal);
  cursor: pointer;
}

.glass-card-hoverable:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--sp-4);
  margin-bottom: var(--sp-6);
}

.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  position: relative;
  overflow: hidden;
  transition: border-color var(--t-normal), background var(--t-normal);
}

.stat-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--grad-primary);
  opacity: 0.6;
}

.stat-card.accent::before {
  background: var(--grad-accent);
}

.stat-card.success::before {
  background: linear-gradient(90deg, var(--success), #10b981);
}

.stat-card.warning::before {
  background: linear-gradient(90deg, var(--warning), #f59e0b);
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin-bottom: var(--sp-2);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.03em;
  line-height: 1;
}

.stat-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

/* ============================================================
   SECTION 5 — Buttons
   ============================================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-2);
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--r-md);
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast),
              box-shadow var(--t-fast), transform var(--t-fast), opacity var(--t-fast);
  white-space: nowrap;
  user-select: none;
  text-decoration: none;
  line-height: 1;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* Primary — cyan gradient */
.btn-primary {
  background: var(--grad-primary);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(6,182,212,0.3);
}

.btn-primary:hover {
  box-shadow: 0 4px 20px rgba(6,182,212,0.45);
  filter: brightness(1.1);
}

/* Accent — purple gradient */
.btn-accent {
  background: var(--grad-accent);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 12px rgba(168,85,247,0.3);
}

.btn-accent:hover {
  box-shadow: 0 4px 20px rgba(168,85,247,0.45);
  filter: brightness(1.1);
}

/* Server-card + server-detail header action buttons: more vibrant /
   saturated palette so primary actions pop against the dark card. Scoped
   so other places using btn-primary / btn-accent keep their existing tone. */
.server-card-actions .btn-primary,
.server-detail-actions .btn-primary {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  box-shadow: 0 2px 10px rgba(34,211,238,0.45);
  font-weight: 700;
}
.server-card-actions .btn-primary:hover,
.server-detail-actions .btn-primary:hover {
  box-shadow: 0 4px 18px rgba(34,211,238,0.6);
  filter: brightness(1.12);
}
.server-card-actions .btn-accent,
.server-detail-actions .btn-accent {
  background: linear-gradient(135deg, #c084fc, #a855f7);
  box-shadow: 0 2px 10px rgba(168,85,247,0.4);
  font-weight: 700;
}
.server-card-actions .btn-accent:hover,
.server-detail-actions .btn-accent:hover {
  box-shadow: 0 4px 18px rgba(168,85,247,0.55);
  filter: brightness(1.12);
}

/* Secondary */
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-glass);
}

.btn-secondary:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* Danger */
.btn-danger {
  background: rgba(239,68,68,0.12);
  color: var(--danger);
  border-color: rgba(239,68,68,0.25);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  box-shadow: 0 4px 16px rgba(239,68,68,0.35);
}

/* Danger outline — destructive-but-secondary actions (Clear Metrics,
   Truncate Store, etc.). Softer pink text + subtle tinted background so
   it harmonises with the dark theme instead of standing out as a lonely
   red outline. Hover turns solid red to confirm intent. */
.btn-danger-outline {
  background: rgba(239,68,68,0.08);
  color: #fca5a5;
  border-color: rgba(239,68,68,0.28);
}

.btn-danger-outline:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.55);
  color: #fecaca;
  box-shadow: 0 2px 10px rgba(239,68,68,0.25);
}

/* Ghost */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

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

/* Small variant */
.btn-small {
  padding: 6px 12px;
  font-size: 12px;
  border-radius: var(--r-sm);
}

/* Icon-only */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: var(--r-md);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border-color: var(--border-glass);
}

.btn-icon:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

/* ============================================================
   SECTION 6 — Form Inputs
   ============================================================ */

.form-group {
  margin-bottom: var(--sp-4);
}

.form-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.01em;
}

.form-input,
.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  line-height: 1.5;
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}

/* Exclude checkboxes/radios from the generic text-input width/padding —
   otherwise they stretch to 100% of the label and push their text label
   to the far edge. */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
  width: auto;
  padding: 0;
  background: transparent;
  border: none;
  box-shadow: none;
}

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

.form-input:focus,
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
  background: rgba(255,255,255,0.06);
}

.form-input:disabled,
.form-group input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.form-group textarea {
  resize: vertical;
  min-height: 100px;
}

/* Select custom arrow */
.form-group select,
select {
  width: 100%;
  padding: 10px 36px 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  outline: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364748b' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
}

.form-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--sp-1);
}

.form-error {
  font-size: 12px;
  color: var(--danger);
  margin-top: var(--sp-1);
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: var(--sp-2);
}

/* ============================================================
   SECTION 7 — Badges, Tables, Modals
   ============================================================ */

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

.badge-online,  .badge.online  { background: rgba(52,211,153,0.15); color: var(--success); border: 1px solid rgba(52,211,153,0.25); }
.badge-offline, .badge.offline { background: rgba(239,68,68,0.15); color: var(--danger); border: 1px solid rgba(239,68,68,0.35); }
.badge-revoked, .badge.revoked { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.2); }
.badge-admin,   .badge.admin   { background: rgba(6,182,212,0.12); color: var(--primary); border: 1px solid rgba(6,182,212,0.2); }
.badge-operator,.badge.operator{ background: rgba(168,85,247,0.12); color: var(--accent); border: 1px solid rgba(168,85,247,0.2); }
.badge-viewer,  .badge.viewer  { background: rgba(148,163,184,0.1); color: var(--text-secondary); border: 1px solid rgba(148,163,184,0.15); }
.badge-auditor,    .badge.auditor    { background: rgba(251,191,36,0.10); color: #b45309; border: 1px solid rgba(251,191,36,0.2); }
.badge-superadmin, .badge.superadmin { background: rgba(239,68,68,0.12); color: #dc2626; border: 1px solid rgba(239,68,68,0.25); font-weight:700; }
.badge-warning, .badge.warning { background: rgba(251,191,36,0.12); color: var(--warning); border: 1px solid rgba(251,191,36,0.2); }
.badge-user,    .badge.user    { background: rgba(148,163,184,0.1); color: var(--text-secondary); border: 1px solid rgba(148,163,184,0.15); }
.badge-tenant                  { background: rgba(168,85,247,0.12); color: #c084fc; border: 1px solid rgba(168,85,247,0.2); }

/* Status dot */
.status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-dot.online  { background: var(--success); box-shadow: 0 0 6px rgba(52,211,153,0.6); }
.status-dot.offline { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }
.status-dot.warning { background: var(--warning); box-shadow: 0 0 6px rgba(251,191,36,0.5); }
.status-dot.danger  { background: var(--danger); box-shadow: 0 0 6px rgba(239,68,68,0.5); }

/* Glass table */
.glass-table-wrap {
  overflow-x: auto;
  border-radius: var(--r-xl);
  border: 1px solid var(--border-glass);
  background: var(--bg-surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.glass-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.glass-table thead tr {
  border-bottom: 1px solid var(--border-glass);
}

.glass-table th {
  text-align: left;
  padding: 13px 16px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  background: transparent;
  white-space: nowrap;
}

.glass-table td {
  padding: 13px 16px;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-glass);
  vertical-align: middle;
}

.glass-table tbody tr:last-child td {
  border-bottom: none;
}

.glass-table tbody tr {
  transition: background var(--t-normal);
  border-radius: var(--r-md);
}

.glass-table tbody tr:hover {
  background: var(--bg-elevated);
  box-shadow: inset 0 0 0 1px var(--border-hover);
  border-radius: var(--r-md);
}

.glass-table tbody tr:hover td {
  color: var(--text-primary);
}

/* Responsive table cards (mobile) */
/* .glass-table-responsive collapses a table into a card stack on narrow
   screens (one card per row, th hidden, td with data-label prefix). On
   desktop it stays as a normal table so Tokens / Recordings / etc. read
   as dense lists. */
@media (max-width: 767px) {
  .glass-table-responsive {
    display: block;
  }

  .glass-table-responsive thead {
    display: none;
  }

  .glass-table-responsive tbody,
  .glass-table-responsive tr {
    display: block;
  }

  .glass-table-responsive tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--r-lg);
    margin-bottom: var(--sp-3);
    padding: var(--sp-3) var(--sp-4);
  }

  .glass-table-responsive td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border: none;
    border-bottom: 1px solid var(--border-glass);
    font-size: 13px;
  }

  .glass-table-responsive td:last-child {
    border-bottom: none;
  }

  .glass-table-responsive td::before {
    content: attr(data-label);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    flex-shrink: 0;
    margin-right: var(--sp-3);
  }

  /* Action cell (data-label=""): no label prefix, button floats right */
  .glass-table-responsive td[data-label=""] {
    justify-content: flex-end;
    padding-top: 6px;
  }
  .glass-table-responsive td[data-label=""]::before {
    display: none;
  }
}

/* Modals */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,9,15,0.7);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--sp-4);
  animation: fadeIn var(--t-fast) ease;
}

.modal {
  background: rgba(10,22,40,0.92);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-2xl);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  padding: var(--sp-6) var(--sp-8);
  min-width: 420px;
  max-width: 600px;
  width: 100%;
  box-shadow: var(--shadow-lg), 0 0 60px rgba(0,0,0,0.4);
  animation: scaleIn var(--t-normal) ease;
  max-height: 90vh;
  overflow-y: auto;
}

.modal h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: var(--sp-5);
  letter-spacing: -0.01em;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-5);
}

.modal-header h3 {
  margin-bottom: 0;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--sp-2);
  margin-top: var(--sp-5);
  padding-top: var(--sp-5);
  border-top: 1px solid var(--border-glass);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@keyframes scaleIn {
  from { opacity: 0; transform: scale(0.95) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

/* ============================================================
   SECTION 8 — Toast, Login, Token Display, Pagination
   ============================================================ */

/* Toast */
.toast-container {
  position: fixed;
  top: var(--sp-5);
  right: var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  z-index: 2000;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 12px 16px;
  border-radius: var(--r-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-hover);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 280px;
  max-width: 380px;
  pointer-events: all;
  box-shadow: var(--shadow-md);
  animation: toastSlideIn 0.3s ease;
  background: rgba(10,22,40,0.9);
}

.toast.success { border-color: rgba(52,211,153,0.35); }
.toast.success .toast-icon { color: var(--success); }

.toast.error   { border-color: rgba(239,68,68,0.35); }
.toast.error   .toast-icon { color: var(--danger); }

.toast.info    { border-color: rgba(6,182,212,0.35); }
.toast.info    .toast-icon { color: var(--primary); }

.toast.warning { border-color: rgba(251,191,36,0.35); }
.toast.warning .toast-icon { color: var(--warning); }

.toast-icon {
  font-size: 16px;
  flex-shrink: 0;
}

.toast-close {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px;
  line-height: 1;
  font-size: 16px;
  transition: color var(--t-fast);
  flex-shrink: 0;
}

.toast-close:hover { color: var(--text-primary); }

@keyframes toastSlideIn {
  from { opacity: 0; transform: translateX(20px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* Login page */
.login-page {
  min-height: 100vh;
  width: 100%;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  background-color: var(--bg-deep);
  background-image: var(--grad-mesh);
}

.login-box {
  background: rgba(10,22,40,0.88);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-2xl);
  backdrop-filter: blur(24px) saturate(180%);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  padding: var(--sp-8) var(--sp-10);
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  animation: scaleIn var(--t-slow) ease;
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--sp-3);
  margin-bottom: var(--sp-8);
  text-align: center;
}

.login-brand-icon {
  width: 52px;
  height: 52px;
  border-radius: var(--r-lg);
  background: var(--grad-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  box-shadow: var(--shadow-glow-primary);
  margin-bottom: var(--sp-2);
}

.login-brand-name {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.login-brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── 3D Cube Logo ── */
.cube-wrapper {
  perspective: 600px;
  width: 110px;
  height: 110px;
  cursor: grab;
  margin-bottom: var(--sp-2);
  position: relative;
}
.cube-wrapper:active { cursor: grabbing; }

.cube-scene {
  width: 110px;
  height: 110px;
  position: relative;
  transform-style: preserve-3d;
}

.cube-face {
  position: absolute;
  width: 110px;
  height: 110px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(6,182,212,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  backface-visibility: visible;
  font-family: 'JetBrains Mono','Cascadia Code','Fira Code',monospace;
  font-size: 40px;
  font-weight: 700;
  color: rgba(255,255,255,0.92);
  letter-spacing: 0;
  user-select: none;
}

.cube-face--front  { background: rgba(6,182,212,0.08);  border-color: rgba(6,182,212,0.2);  text-shadow: 0 0 18px rgba(6,182,212,0.6),  0 0 40px rgba(6,182,212,0.2);  }
.cube-face--back   { background: rgba(168,85,247,0.08); border-color: rgba(168,85,247,0.2); text-shadow: 0 0 18px rgba(168,85,247,0.6), 0 0 40px rgba(168,85,247,0.2); }
.cube-face--right  { background: rgba(14,165,233,0.08); border-color: rgba(14,165,233,0.2); text-shadow: 0 0 18px rgba(14,165,233,0.6), 0 0 40px rgba(14,165,233,0.2); }
.cube-face--left   { background: rgba(139,92,246,0.08); border-color: rgba(139,92,246,0.2); text-shadow: 0 0 18px rgba(139,92,246,0.6), 0 0 40px rgba(139,92,246,0.2); }
.cube-face--top    { background: rgba(34,211,153,0.06); border-color: rgba(34,211,153,0.15); text-shadow: 0 0 18px rgba(34,211,153,0.5), 0 0 40px rgba(34,211,153,0.15); }
.cube-face--bottom { background: rgba(99,102,241,0.06); border-color: rgba(99,102,241,0.15); text-shadow: 0 0 18px rgba(99,102,241,0.5), 0 0 40px rgba(99,102,241,0.15); }

.cube-face--empty::after {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255,255,255,0.12);
  box-shadow: 0 0 10px rgba(255,255,255,0.05);
}

.cube-face--front  { transform: translateZ(55px); }
.cube-face--back   { transform: rotateY(180deg) translateZ(55px); }
.cube-face--right  { transform: rotateY(90deg) translateZ(55px); }
.cube-face--left   { transform: rotateY(-90deg) translateZ(55px); }
.cube-face--top    { transform: rotateX(90deg) translateZ(55px); }
.cube-face--bottom { transform: rotateX(-90deg) translateZ(55px); }

.cube-wrapper::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 16px;
  background: radial-gradient(ellipse, rgba(6,182,212,0.2) 0%, transparent 70%);
  border-radius: 50%;
  animation: cubeGlow 3s ease-in-out infinite alternate;
}

@keyframes cubeGlow {
  0%   { opacity: 0.5; width: 70px; }
  100% { opacity: 1;   width: 90px; }
}

/* Token display */
.token-display {
  background: rgba(0,0,0,0.35);
  border: 1px solid var(--border-hover);
  border-radius: var(--r-md);
  padding: 12px 14px;
  font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', monospace;
  font-size: 12px;
  color: var(--primary);
  word-break: break-all;
  line-height: 1.7;
  margin: var(--sp-3) 0;
  user-select: all;
  letter-spacing: 0.01em;
}

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: 1px solid var(--border-glass);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  transition: background var(--t-fast), color var(--t-fast), border-color var(--t-fast);
}

.pagination-btn:hover {
  background: rgba(255,255,255,0.1);
  color: var(--text-primary);
  border-color: var(--border-hover);
}

.pagination-btn.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

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

/* Server grid */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--sp-4);
}

.server-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-xl);
  padding: var(--sp-5);
  transition: border-color var(--t-normal), background var(--t-normal), transform var(--t-normal), box-shadow var(--t-normal);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.server-card:hover {
  border-color: var(--border-hover);
  background: var(--bg-elevated);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* Offline server card: dim body content (name, badges, status-dot stay vivid) */
.server-card.offline .server-card-info,
.server-card.offline .server-card-actions {
  opacity: 0.55;
  filter: saturate(0.55);
}
.server-card.offline:hover .server-card-info,
.server-card.offline:hover .server-card-actions {
  opacity: 0.8;
  filter: saturate(0.8);
}

.server-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
   instead of snapping. Only the fill transitions — the track stays static. */
.metric-bar-fill {
  transition: width 0.5s ease-out, background-color 0.3s ease;
}

.server-metric-row {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
}

.server-metric-rows {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 8px;
}

/* Metric row: 2-line stack (header + full-width sparkline below).
   Intentionally NOT display:flex on the outer .metric-row — that would
   put the header and sparkline on the same row and shrink the chart. */
.metric-row {
  margin-bottom: 8px;
  font-size: 11px;
}

.metric-row .metric-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.metric-row .sparkline-svg {
  overflow: visible;
  display: block;  /* takes its own line under the header */
  width: 100%;
}

.metric-row .metric-pct {
  font-weight: 600;
  font-size: 13px;
  line-height: 1;
  flex-shrink: 0;
}

.metric-row .metric-used {
  font-size: 10px;
  color: var(--text-muted, #888);
  line-height: 1;
  flex-shrink: 0;
}

/* Server-card top row — server name + status + os/version/update/session/
   tenant badges. Wraps to a second line when any chip would overflow, so a
   long version label or tenant name pushes badges down rather than off the
   card. Name has flex-shrink so it ellipsizes if the user names the agent
   absurdly long. */
.server-card-header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  min-width: 0;
  row-gap: 4px;
}
.server-card-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 0 1 auto;
}
/* Tenant badge can carry long org names — cap with ellipsis. */
.server-card-header .badge-tenant {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  vertical-align: middle;
}
/* Inline OS/version chip + the update button — keep them from blowing
   out the card width when version strings are long. */
.server-card-header > span,
.server-card-header > button {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Star button — appears on resource cards (server today, plex/session
   later) to pin a favorite. Filled amber when active, outline-only gray
   otherwise. Uses currentColor so hover/active transitions are smooth. */
.card-star-btn {
  background: transparent;
  border: none;
  padding: 2px;
  margin-right: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #64748b);
  border-radius: 4px;
  transition: color .12s, background .12s, transform .12s;
  flex-shrink: 0;
}
.card-star-btn:hover {
  color: #fbbf24;
  background: rgba(251, 191, 36, .08);
}
.card-star-btn.is-starred {
  color: #fbbf24;
}
.card-star-btn:active {
  transform: scale(0.9);
}

/* Plex tab strip star — same visual language, smaller footprint. */
.plex-tab-star, .plex-row-star, .session-star-btn {
  background: transparent;
  border: none;
  padding: 1px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
  border-radius: 3px;
  transition: color .12s, background .12s;
  flex-shrink: 0;
  line-height: 0;
}
.plex-tab-star:hover, .plex-row-star:hover, .session-star-btn:hover {
  color: #fbbf24;
  background: rgba(251, 191, 36, .12);
}
.plex-tab-star.is-starred, .plex-row-star.is-starred, .session-star-btn.is-starred {
  color: #fbbf24;
}

/* Group-bookmark button — appears next to the star on resource headers.
   Tinted when the resource belongs to at least one group. */
.card-group-btn {
  background: transparent;
  border: none;
  padding: 2px;
  margin-right: 2px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted, #64748b);
  border-radius: 4px;
  transition: color .12s, background .12s;
  flex-shrink: 0;
}
.card-group-btn:hover {
  color: #67e8f9;
  background: rgba(103, 232, 249, .08);
}
.card-group-btn.is-in-group {
  color: #67e8f9;
}

/* Row view */
.server-row-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
  overflow-x: auto;
  width: 100%;
  box-sizing: border-box;
}
.server-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-surface, rgba(255,255,255,.03));
  border: 1px solid var(--border-glass, rgba(255,255,255,.08));
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  font-size: 11px;
  transition: border-color var(--t-fast, 0.15s), background var(--t-fast, 0.15s);
  position: relative;
}
.server-row:hover {
  border-color: var(--border-hover, rgba(255,255,255,.18));
  background: var(--bg-elevated, rgba(255,255,255,.06));
}
.server-row.offline {
  opacity: 0.65;
}
/* Name column grows to absorb any extra width on wide viewports so the row
   stays balanced (no large gap between Actions and the right edge). */
.server-row-col-name  { flex: 1 1 140px; min-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.server-row-col-os    { width: 72px; flex-shrink: 0; color: var(--text-muted, #888); font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.server-row-col-avg1  { width: 44px; flex-shrink: 0; font-size: 10px; font-family: monospace; text-align: right; color: #2ecc71; }
.server-row-col-net   { width: 96px; flex-shrink: 0; font-size: 10px; font-family: monospace; }
.server-row-col-io    { width: 88px; flex-shrink: 0; font-size: 10px; font-family: monospace; }
.server-row-col-ip    { width: 120px; flex-shrink: 0; font-size: 10px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-family: monospace; }
.server-row-col-ver   { width: 72px; flex-shrink: 0; font-size: 10px; color: var(--text-muted, #888); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; gap: 4px; }
/* Metric columns grow with the viewport (capped at a readable size) so bars
   stay proportional; no more empty space after the Actions column. */
.server-row-col-metric { flex: 1 1 auto; min-width: 56px; max-width: 130px; }
.server-row-col-actions { flex-shrink: 0; display: flex; gap: 3px; min-width: 70px; }

/* ================================================================
   Density toggle — applied as a class on #server-grid.
   Only tunes Row / List layouts; Card view already scales with its
   grid columns and is independent of this setting.
   ================================================================ */
.density-compact .server-row { padding: 4px 10px; font-size: 10.5px; gap: 8px; }
.density-compact .server-row-col-metric { min-width: 50px; max-width: 100px; }
.density-compact .server-list-table td,
.density-compact .server-list-table th { padding: 4px 7px; font-size: 10px; }

/* Normal = default (matches existing base values). Present for completeness
   so switching back from compact/spacious has a deterministic target. */
.density-normal .server-row { padding: 6px 12px; font-size: 11.5px; gap: 10px; }
.density-normal .server-list-table td,
.density-normal .server-list-table th { padding: 6px 8px; font-size: 11px; }

.density-spacious .server-row { padding: 10px 16px; font-size: 13px; gap: 14px; min-height: 44px; }
.density-spacious .server-row-col-metric { min-width: 70px; max-width: 160px; }
.density-spacious .server-row-col-name { font-size: 13px; }
.density-spacious .server-list-table td,
.density-spacious .server-list-table th { padding: 10px 12px; font-size: 12.5px; }
.density-spacious .server-list-table th { padding-top: 12px; padding-bottom: 12px; }

/* Sticky table / list header while scrolling */
.server-row-list-header {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-primary, #0a0e1a);
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,.08));
}
/* Sticky thead needs border-collapse:separate (overridden below) + an opaque
   background on each th so rows don't show through. */
.server-list-table thead th {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg-primary, #0a0e1a);
  box-shadow: 0 1px 0 var(--border-glass, rgba(255,255,255,.08));
}
.server-list-table { border-collapse: separate !important; border-spacing: 0; }
.server-list-table td { border-top: 1px solid rgba(255,255,255,.04); border-bottom: 0 !important; }
.server-list-table tbody tr:first-child td { border-top: 0; }
/* Subtle group separator between online and offline rows */
.server-row-list .server-row.first-offline { margin-top: 12px; position: relative; }
.server-row-list .server-row.first-offline::before {
  content: "offline";
  position: absolute; left: 4px; top: -10px;
  font-size: 9px; color: #475569;
  text-transform: uppercase; letter-spacing: .08em;
  background: var(--bg-primary, #0a0e1a); padding: 0 6px;
}

/* List/table view */
.server-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
}
.server-list-table th {
  text-align: left;
  padding: 6px 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #888);
  border-bottom: 1px solid var(--border-glass, rgba(255,255,255,.08));
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  background: var(--bg-secondary, #1a1a2e);
  position: sticky;
  top: 0;
  z-index: 1;
}
.server-list-table th:hover { color: var(--text-secondary, #aaa); }
.server-list-table .sort-arrow { margin-left: 3px; color: var(--primary, #06b6d4); }
.server-list-table td {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255,255,255,.04);
  vertical-align: middle;
}
.server-list-table tr { cursor: pointer; transition: background var(--t-fast, 0.15s); }
.server-list-table tbody tr:nth-child(even) td { background: rgba(255,255,255,.015); }
.server-list-table tr:hover td { background: rgba(255,255,255,.04); }
.server-list-table tr.offline { opacity: 0.55; }

/* Search bar */
.search-bar {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  flex: 1;
  max-width: 600px;
}

.search-input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md);
  color: var(--text-primary);
  font-size: 13.5px;
  font-family: inherit;
  outline: none;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.35-4.35'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}

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

.search-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(6,182,212,0.15);
}

/* View toggle */
.view-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md, 8px);
  padding: 2px;
}
.view-toggle-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: background var(--t-fast, 0.1s), color var(--t-fast, 0.1s);
}
.view-toggle-btn.active {
  background: var(--bg-elevated, rgba(255,255,255,.08));
  color: var(--text-primary, #ddd);
}
.view-toggle-btn:hover:not(.active) {
  color: var(--text-secondary, #aaa);
}

.time-range-toggle {
  display: flex;
  gap: 2px;
  background: var(--bg-secondary, #1a1a2e);
  border: 1px solid var(--border-glass);
  border-radius: var(--r-md, 8px);
  padding: 2px;
}
.time-range-btn {
  background: transparent;
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted, #888);
  cursor: pointer;
  transition: background var(--t-fast, 0.1s), color var(--t-fast, 0.1s);
  white-space: nowrap;
}
.time-range-btn.active {
  background: var(--primary, #06b6d4);
  color: #fff;
  font-weight: 600;
}
.time-range-btn:hover:not(.active) {
  color: var(--text-secondary, #aaa);
}
/* Dim an entire time-range row when its setting doesn't apply (e.g. time
   range vs bar mode on dashboard). Buttons stay in layout but are muted
   and non-interactive so the user doesn't mis-click. */
.time-range-toggle.mode-disabled {
  opacity: 0.35;
  pointer-events: none;
}

/* ============================================================
   SECTION 9 — Toggle, Skeleton, Inline Edit, File Panel
   ============================================================ */

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  gap: var(--sp-2);
}

.toggle-switch input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  background: rgba(100,116,139,0.3);
  border: 1px solid var(--border-glass);
  border-radius: 11px;
  transition: background var(--t-normal), border-color var(--t-normal);
}

.toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform var(--t-normal), background var(--t-normal);
}

.toggle-switch input:checked ~ .toggle-track {
  background: rgba(6,182,212,0.25);
  border-color: rgba(6,182,212,0.4);
}

.toggle-switch input:checked ~ .toggle-track .toggle-thumb {
  transform: translateX(18px);
  background: var(--primary);
}

/* Skeleton loading */
.skeleton {
  background: linear-gradient(90deg,
    var(--bg-elevated) 25%,
    rgba(255,255,255,0.07) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.6s infinite;
  border-radius: var(--r-sm);
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--sp-2);
}

.skeleton-title {
  height: 20px;
  width: 60%;
  margin-bottom: var(--sp-3);
}

.skeleton-badge {
  width: 70px;
  height: 22px;
  border-radius: 20px;
}

@keyframes shimmer {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* Inline edit */
.inline-edit {
  display: inline-flex;
  align-items: center;
  gap: var(--sp-1);
}

.editable-span {
  padding: 2px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  min-width: 40px;
}

.editable-span:hover {
  background: var(--bg-elevated);
}

/* Primary identifier (entity name/label) — used in list tables to make the
   human-readable name stand out from surrounding metadata columns.
   Matches the treatment of .server-card-name on the dashboard. */
.primary-name {
  color: var(--text-primary);
  font-weight: 600;
}

.editable-span:focus {
  outline: none;
  background: var(--bg-elevated);
  border: 1px solid var(--primary);
  box-shadow: 0 0 0 2px rgba(6,182,212,0.15);
}

/* File panel */
.file-panel {
  width: 350px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: rgba(10,22,40,0.82);
  border-left: 1px solid var(--border-glass);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  overflow: hidden;
  height: 100%;
}

.file-panel-header {
  padding: var(--sp-4) var(--sp-5);
  border-bottom: 1px solid var(--border-glass);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.file-panel-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.file-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-2) var(--sp-3);
  scrollbar-width: thin;
  scrollbar-color: var(--border-hover) transparent;
}

.file-panel-body::-webkit-scrollbar { width: 4px; }
.file-panel-body::-webkit-scrollbar-thumb { background: var(--border-hover); border-radius: 2px; }

.file-entry {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 8px 10px;
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background var(--t-fast);
  user-select: none;
}

.file-entry:hover {
  background: var(--bg-elevated);
}

.file-entry.selected {
  background: rgba(6,182,212,0.1);
  border: 1px solid rgba(6,182,212,0.2);
}

.file-entry-icon {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
}

.file-entry.is-dir .file-entry-icon {
  color: var(--primary);
}

.file-entry-name {
  flex: 1;
  font-size: 13px;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-entry:hover .file-entry-name,
.file-entry.selected .file-entry-name {
  color: var(--text-primary);
}

.file-entry-size {
  font-size: 11px;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}

/* Dropzone */
.file-panel-dropzone {
  margin: var(--sp-3);
  border: 2px dashed var(--border-hover);
  border-radius: var(--r-lg);
  padding: var(--sp-5);
  text-align: center;
  transition: border-color var(--t-normal), background var(--t-normal);
  cursor: pointer;
}

.file-panel-dropzone:hover,
.file-panel-dropzone.drag-over {
  border-color: var(--primary);
  background: rgba(6,182,212,0.05);
}

.file-panel-dropzone-text {
  font-size: 12px;
  color: var(--text-muted);
}

.file-panel-dropzone.drag-over .file-panel-dropzone-text {
  color: var(--primary);
}

/* File panel footer — always visible upload zone */
.file-panel-footer {
  padding: var(--sp-3);
  border-top: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.file-panel-upload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: var(--sp-3) var(--sp-4);
  border: 2px dashed var(--border-hover);
  border-radius: var(--r-lg);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--t-normal);
}

.file-panel-upload-btn:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(6,182,212,0.05);
}

.file-panel-footer.drag-over .file-panel-upload-btn {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(6,182,212,0.08);
}

/* File list scrollable */
.fm-file-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

/* Terminal file panel — scoped layout so emoji icons render at correct size */
#file-panel .fm-entry {
  display: flex;
  align-items: center;
  padding: 3px 4px 3px 6px;
  font-size: 12px;
  gap: 6px;
  cursor: pointer;
  color: #ccc;
}
#file-panel .fm-entry:hover { background: rgba(255,255,255,0.04); }
#file-panel .fm-entry-icon { flex-shrink: 0; font-size: 14px; }
#file-panel .fm-entry-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #ccc; }
#file-panel .fm-entry-size { flex-shrink: 0; color: #64748b; font-size: 11px; margin-left: auto; }
#file-panel .fm-btn { padding: 1px 3px; font-size: 10px; flex-shrink: 0; background: transparent; border: none; color: #666; cursor: pointer; line-height: 1; }
#file-panel .fm-btn:hover { color: #ccc; }

/* File upload progress */
.file-progress {
  margin: var(--sp-2) var(--sp-3);
  padding: var(--sp-3);
  background: var(--bg-elevated);
  border-radius: var(--r-md);
  border: 1px solid var(--border-glass);
}

.file-progress-name {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: var(--sp-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-progress-bar-track {
  height: 4px;
  background: var(--bg-surface);
  border-radius: 2px;
  overflow: hidden;
}

.file-progress-bar-fill {
  height: 100%;
  background: var(--grad-primary);
  border-radius: 2px;
  transition: width 0.3s ease;
}

/* ── Legacy compatibility ─────────────────────────────────── */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: var(--sp-5);
}

.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--sp-4) 0;
  border-bottom: 1px solid var(--border-glass);
  margin-bottom: var(--sp-5);
}

.header h1 {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.nav {
  display: flex;
  gap: var(--sp-4);
  margin-bottom: var(--sp-5);
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-glass);
}

.nav a {
  color: var(--text-muted);
  text-decoration: none;
  padding: 10px 2px;
  border-bottom: 2px solid transparent;
  font-size: 13.5px;
  font-weight: 500;
  transition: color var(--t-fast), border-color var(--t-fast);
  margin-bottom: -1px;
}

.nav a:hover { color: var(--text-primary); }

.nav a.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

/* Terminal */
/* Terminal layout: body.terminal-layout hides sidebar/topbar, full screen */
body.terminal-layout { overflow: hidden; overscroll-behavior: none; }
body.terminal-layout .topbar { display: none; }
body.terminal-layout .content-area { padding: 0; overflow: hidden; height: calc(100vh - var(--vk-offset, 0px)); height: calc(100dvh - var(--vk-offset, 0px)); }
body.terminal-layout #page-content { display: flex; flex-direction: column; height: calc(100vh - var(--vk-offset, 0px)); height: calc(100dvh - var(--vk-offset, 0px)); }

/* Terminal toolbar */
.terminal-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(10,22,40,0.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-glass);
  flex-shrink: 0;
}

.terminal-toolbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-toolbar-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.terminal-toolbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.terminal-toolbar-right .btn.active {
  background: rgba(6,182,212,0.15);
  color: var(--primary);
  border-color: rgba(6,182,212,0.3);
}

/* ── Collapsible sidebar toolbar (rbox-style: fixed position, pill handle) ── */
/* Sidebar slides off-screen with translateX; handle is a separate fixed sibling. */
/* CSS ~ sibling selector drives terminal-main margin and handle position.        */
.terminal-sidebar {
  position: fixed;
  left: 0;
  top: calc(50% - var(--vk-offset, 0px) / 2);
  width: 44px;
  z-index: 10010;
  display: flex;
  flex-direction: column;
  background: rgba(24,44,76,0.97);
  border: 1px solid rgba(255,255,255,0.15);
  border-left: none;
  border-radius: 0 8px 8px 0;
  transform: translateX(0) translateY(-50%);
  transition: transform 0.2s ease;
  overflow: hidden;
}
.terminal-sidebar.sidebar-collapsed { transform: translateX(-44px) translateY(-50%); }
.terminal-sidebar.sidebar-right {
  left: auto;
  right: 0;
  border-left: 1px solid var(--border-glass);
  border-right: none;
  border-radius: 8px 0 0 8px;
  transform: translateX(0) translateY(-50%);
}
.terminal-sidebar.sidebar-right.sidebar-collapsed { transform: translateX(44px) translateY(-50%); }

.terminal-sidebar-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 2px;
  overflow-x: hidden;
  scrollbar-width: none;
}
.terminal-sidebar-content::-webkit-scrollbar { display: none; }

/* sb-btn: square icon button for sidebar, overrides btn-ghost padding */
.sb-btn { width: 32px; height: 32px; padding: 0; border-radius: 6px; flex-shrink: 0; }
.sb-btn:hover { background: rgba(255,255,255,0.08); }
.font-size-sel {
  width: 32px; height: 28px; padding: 0; border-radius: 4px; flex-shrink: 0;
  background: transparent; border: 1px solid rgba(255,255,255,0.12);
  color: var(--text-muted); font-size: 10px; font-family: inherit;
  text-align: center; text-align-last: center;
  appearance: none; -webkit-appearance: none;
  cursor: pointer; outline: none;
}
.font-size-sel:hover { border-color: rgba(255,255,255,0.3); color: var(--text-primary); }
.terminal-container.no-scrollbar .xterm-viewport { scrollbar-width: none; }
.terminal-container.no-scrollbar .xterm-viewport::-webkit-scrollbar { display: none; }
.terminal-container.no-scrollbar .xterm-scrollable-element > .scrollbar { display: none !important; }
.terminal-sidebar-content .btn.active {
  background: rgba(6,182,212,0.15);
  color: var(--primary);
  border-color: rgba(6,182,212,0.3);
}

.sidebar-title {
  font-size: 9px;
  color: var(--text-muted);
  text-align: center;
  max-width: 28px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  margin: 2px 0;
}
.sidebar-sep { width: 24px; height: 1px; background: var(--border-glass); flex-shrink: 0; margin: 2px 0; }

/* Session-name chip under the server name in the terminal sidebar. Same
   narrow column as .sidebar-title — clickable to rename the active session. */
.sidebar-session-chip {
  font-size: 9px;
  color: var(--accent-cyan, #67e8f9);
  text-align: center;
  max-width: 36px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
  margin: 1px 0;
  padding: 1px 3px;
  border-radius: 3px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background .12s, border-color .12s;
}
.sidebar-session-chip:hover {
  background: rgba(103, 232, 249, 0.08);
  border-color: rgba(103, 232, 249, 0.4);
}

/* Handle: separate fixed pill button, sibling of .terminal-sidebar */
.terminal-sidebar-handle {
  position: fixed;
  left: 44px;
  top: calc(50% - var(--vk-offset, 0px) / 2);
  transform: translateY(-50%);
  width: 20px;
  height: 44px;
  z-index: 10011;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  background: rgba(24,44,76,0.97);
  border: 1px solid rgba(255,255,255,0.15);
  border-left: none;
  border-radius: 0 8px 8px 0;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: left 0.2s ease, right 0.2s ease, background 0.15s;
}
.terminal-sidebar-handle:hover { background: rgba(30,50,80,0.98); color: var(--text-primary); }

/* When sidebar is collapsed, handle moves to edge */
.terminal-sidebar.sidebar-collapsed ~ .terminal-sidebar-handle { left: 0; }

/* Right-side variants */
.terminal-sidebar.sidebar-right ~ .terminal-sidebar-handle {
  left: auto;
  right: 44px;
  border-left: 1px solid var(--border-glass);
  border-right: none;
  border-radius: 8px 0 0 8px;
}
.terminal-sidebar.sidebar-right.sidebar-collapsed ~ .terminal-sidebar-handle { right: 0; }

/* terminal-main: full area, compensated with margin for fixed sidebar */
.terminal-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  margin-left: 44px;
  transition: margin 0.2s ease;
}
.terminal-sidebar.sidebar-collapsed { pointer-events: none; }
.terminal-sidebar.sidebar-collapsed ~ .terminal-main { margin-left: 0; }
.terminal-sidebar.sidebar-right ~ .terminal-main { margin-left: 0; margin-right: 44px; }
.terminal-sidebar.sidebar-right.sidebar-collapsed ~ .terminal-main { margin-right: 0; }

/* Drop zone: 2 equal halves side by side */
.fp-dropzone-row { display: flex; gap: 6px; }
.fp-dropzone-half {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 4px;
  border: 2px dashed var(--border-hover);
  border-radius: 8px;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
  min-height: 56px;
}
.fp-dropzone-half:hover,
.file-panel-footer.drag-over .fp-dropzone-half {
  border-color: var(--primary);
  color: var(--primary);
  background: rgba(6,182,212,0.06);
}

/* Terminal body: holds terminal + file panel side by side */
.terminal-body {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}

.terminal-container {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  background: #020408;
}

/* Let xterm.js handle its own touch scroll (built-in touchmove handler).
   Do NOT set touch-action:pan-y on .xterm-viewport — browser native pan and
   xterm's handler both run and cause double-scroll / viewport jump.
   overscroll-behavior:none stops rubber-band from propagating to the visual
   viewport and pulling the fixed VK bar up when keyboard is open. */
.xterm-viewport { overscroll-behavior: none; }

#terminal {
  width: 100%;
  height: 100%;
}

.file-panel.hidden { display: none; }

/* ============================================================
   SECTION 10 — Responsive Media Queries
   ============================================================ */

/* ── Tablet ≤ 1023px ──────────────────────────────────────── */
@media (max-width: 1023px) {
  /* Disable backdrop-filter on tablets and landscape phones — Firefox Android
     renders them incorrectly on fixed/transformed elements, causing
     full-viewport blur that blocks interaction. */
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  :root {
    --sidebar-w: 220px;
  }

  .content-area {
    padding: var(--sp-5);
  }

  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .server-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  }

  /* Row view: hide IP and Version on tablet to prevent overflow */
  .server-row-col-ver,
  .server-row-col-ip {
    display: none;
  }

  /* List view: hide IP and Version on tablet */
  .server-list-table th:nth-child(7),
  .server-list-table td:nth-child(7),
  .server-list-table th:nth-child(8),
  .server-list-table td:nth-child(8) {
    display: none;
  }

  /* Search bar: narrower on tablet to balance with toggle buttons */
  .search-bar {
    max-width: 380px;
  }

  .file-panel {
    width: 300px;
  }

  .modal {
    padding: var(--sp-5) var(--sp-6);
    min-width: 340px;
  }
}

/* ── Mobile ≤ 767px ───────────────────────────────────────── */
@media (max-width: 767px) {
  /* Disable all backdrop-filter on mobile — Firefox Android renders them
     incorrectly on fixed/transformed elements, causing full-viewport blur
     that blocks interaction. Use opaque backgrounds instead. */
  * {
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
  }

  /* Modal: remove fixed min-width so modals don't overflow narrow screens */
  .modal {
    min-width: 0;
    padding: var(--sp-4);
    border-radius: var(--r-xl);
  }

  .modal-overlay {
    padding: var(--sp-2);
    align-items: flex-end;
  }

  /* Hamburger button (shown on mobile) */
  .mobile-hamburger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    border-radius: var(--r-md);
    background: var(--bg-elevated);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--t-fast), color var(--t-fast);
  }

  .mobile-hamburger:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-primary);
  }

  /* Backdrop for sidebar on mobile — hidden by default, shown via .active */
  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(6,9,15,0.6);
    backdrop-filter: blur(4px);
    z-index: 190;
    animation: fadeIn var(--t-fast) ease;
  }

  .sidebar-backdrop.active {
    display: block;
  }

  /* Sidebar overlays on mobile — use display toggle instead of transform
     to avoid Firefox rendering issues with fixed+transformed elements */
  .sidebar {
    width: var(--sidebar-w) !important;
    display: none;
    background: rgba(10,22,40,0.98);
  }

  .sidebar.mobile-open {
    display: flex;
  }

  /* Main content takes full width */
  .main-content {
    margin-left: 0 !important;
  }

  .topbar {
    padding: 0 var(--sp-4);
  }

  .topbar-menu-btn {
    display: inline-flex;
  }

  .topbar-logout-btn {
    display: inline-flex;
  }

  .content-area {
    padding: var(--sp-4);
  }

  /* Stats single column on small mobile */
  .stats-row {
    grid-template-columns: 1fr 1fr;
    gap: var(--sp-3);
  }

  .stat-value {
    font-size: 22px;
  }

  /* Server grid single column */
  .server-grid {
    grid-template-columns: 1fr;
  }

  /* Responsive table — transform rows into card layout on mobile */
  .glass-table-wrap .glass-table thead {
    display: none;
  }

  .glass-table-wrap .glass-table,
  .glass-table-wrap .glass-table tbody {
    display: block;
    width: 100%;
  }

  .glass-table-wrap .glass-table tr {
    display: block;
    padding: var(--sp-3) var(--sp-4);
    border-bottom: 1px solid var(--border-glass);
  }

  .glass-table-wrap .glass-table tr:last-child {
    border-bottom: none;
  }

  .glass-table-wrap .glass-table td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    border: none;
    font-size: 13px;
  }

  .glass-table-wrap .glass-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--text-secondary);
    margin-right: var(--sp-3);
    flex-shrink: 0;
    font-size: 12px;
  }

  .glass-table-wrap .glass-table td[data-label=""] {
    justify-content: flex-end;
  }

  .glass-table-wrap .glass-table td[data-label=""]::before {
    display: none;
  }

  /* Modal full-screen on mobile */
  .modal-overlay {
    align-items: flex-end;
    padding: 0;
  }

  .modal {
    min-width: 100%;
    max-width: 100%;
    border-radius: var(--r-2xl) var(--r-2xl) 0 0;
    border-bottom: none;
    padding: var(--sp-5) var(--sp-5);
    max-height: 85vh;
    animation: slideUp var(--t-normal) ease;
  }

  /* Terminal mobile: file panel as full overlay */
  .terminal-body .file-panel {
    position: fixed;
    top: 0; right: 0;
    width: 100%; height: 100vh; height: 100dvh;
    z-index: 10001;
    background: rgba(10,22,40,0.98);
    overflow-y: auto;
  }

  /* Row + List view trim — keep status/dot, name, CPU, RAM, actions; drop the
     rest (OS/Net/I/O/Avg1/Swap/Disk) so the row fits a 390 px viewport without
     horizontal scroll. Power users wanting more columns switch to Card view. */
  .server-row-col-name {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    word-break: break-word;
    flex: 1 1 80px;
    min-width: 80px;
  }
  .server-row-col-os,
  .server-row-col-net,
  .server-row-col-io,
  .server-row-col-avg1 {
    display: none;
  }
  .server-row-col-metric.metric-swap,
  .server-row-col-metric.metric-disk {
    display: none;
  }
  /* Tighten remaining metric cells (CPU, RAM) so the row balances. */
  .server-row-col-metric {
    min-width: 44px;
    max-width: 90px;
  }

  /* List-view table: hide secondary columns (Swap=5, Disk=6, IO=9, OS=10,
     IP=11, Version=12). Avg1 (7) + Net (8) already hidden at <=1024 tablet. */
  .server-list-table th:nth-child(5),
  .server-list-table td:nth-child(5),
  .server-list-table th:nth-child(6),
  .server-list-table td:nth-child(6),
  .server-list-table th:nth-child(9),
  .server-list-table td:nth-child(9),
  .server-list-table th:nth-child(10),
  .server-list-table td:nth-child(10),
  .server-list-table th:nth-child(11),
  .server-list-table td:nth-child(11),
  .server-list-table th:nth-child(12),
  .server-list-table td:nth-child(12) {
    display: none;
  }

  /* Page header stacks */
  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .page-header-actions {
    width: 100%;
    justify-content: flex-start;
    flex-wrap: wrap;
  }

  .login-box {
    padding: var(--sp-6);
    border-radius: var(--r-xl);
  }

  .cube-wrapper, .cube-scene, .cube-face {
    width: 90px;
    height: 90px;
  }
  .cube-face { font-size: 32px; }
  .cube-face--front  { transform: translateZ(45px); }
  .cube-face--back   { transform: rotateY(180deg) translateZ(45px); }
  .cube-face--right  { transform: rotateY(90deg) translateZ(45px); }
  .cube-face--left   { transform: rotateY(-90deg) translateZ(45px); }
  .cube-face--top    { transform: rotateX(90deg) translateZ(45px); }
  .cube-face--bottom { transform: rotateX(-90deg) translateZ(45px); }

  .search-bar {
    max-width: 100%;
    flex: 1;
  }

  /* Row view: hide secondary columns on mobile, allow metric flex-shrink */
  .server-row-col-os,
  .server-row-col-ver,
  .server-row-col-ip,
  .metric-disk {
    display: none;
  }
  .server-row-col-net {
    width: 52px;
    font-size: 9px;
    overflow: hidden;
  }
  .server-row-col-name {
    width: 90px;
  }
  .server-row-col-metric {
    min-width: 0;
    overflow: hidden;
  }

  /* List view: hide secondary columns on small screens (keep Actions = last column) */
  .server-list-table th:nth-child(n+6):not(:last-child),
  .server-list-table td:nth-child(n+6):not(:last-child) {
    display: none;
  }

  /* Touch targets: increase action button hit area on mobile */
  .view-toggle-btn {
    min-height: 36px;
    padding: 8px 10px !important;
  }
  /* Card actions only — row action buttons have inline padding already */
  .server-card-actions .btn-small {
    padding: 8px 10px !important;
    font-size: 11px !important;
  }
}

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

/* ── Very small screens ≤ 420px ──────────────────────────── */
@media (max-width: 420px) {
  .stats-row {
    grid-template-columns: 1fr;
  }

  .toast {
    min-width: 240px;
    max-width: calc(100vw - 32px);
  }
}

/* ── Hide hamburger on desktop ────────────────────────────── */
@media (min-width: 768px) {
  .mobile-hamburger {
    display: none;
  }

  .sidebar-backdrop {
    display: none;
  }
}

/* VNC File Panel — mirrors terminal file-panel design */
.noVNC_files_panel {
    min-width: 300px !important;
    max-width: 340px;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    color: #ccc;
    overflow: hidden;
}
.vnc-fm-header {
    padding: 10px 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.vnc-fm-title {
    font-size: 13px;
    font-weight: 700;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}
.vnc-fm-body {
    flex: 1;
    overflow-y: auto;
    padding: 8px 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.vnc-fm-body::-webkit-scrollbar { width: 4px; }
.vnc-fm-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 2px; }
.vnc-fm-input {
    background: rgba(10,22,40,0.6);
    color: #ccc;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    outline: none;
}
.vnc-fm-input:focus {
    border-color: rgba(6,182,212,0.4);
}
.vnc-fm-icon-btn {
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 4px;
    color: #ccc;
    padding: 4px 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
}
.vnc-fm-icon-btn:hover {
    background: rgba(255,255,255,0.12);
}
.vnc-fm-file-list {
    flex: 1;
    overflow-y: auto;
    max-height: 45vh;
    min-height: 80px;
}
.vnc-fm-footer {
    border-top: 1px solid rgba(255,255,255,0.08);
    padding: 8px 10px;
    flex-shrink: 0;
}
.vnc-fm-upload-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px;
    border: 1px dashed rgba(255,255,255,0.15);
    border-radius: 4px;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}
.vnc-fm-upload-btn:hover {
    border-color: rgba(6,182,212,0.4);
    color: #aaa;
}
/* File entries inside VNC panel */
.noVNC_files_panel .fm-entry {
    display: flex;
    align-items: center;
    padding: 3px 4px 3px 6px;
    cursor: pointer;
    border-radius: 0;
    font-size: 12px;
    gap: 6px;
    color: #ccc;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    border-left: 2px solid #3b82f6;
}
.noVNC_files_panel .fm-entry.fm-entry-file {
    border-left-color: #f59e0b;
}
.noVNC_files_panel .fm-entry:hover {
    background: rgba(255,255,255,0.04);
}
.noVNC_files_panel .fm-entry-icon {
    flex-shrink: 0;
    font-size: 14px;
}
.noVNC_files_panel .fm-entry-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #ccc;
}
.noVNC_files_panel .fm-entry-size {
    flex-shrink: 0;
    color: #64748b;
    font-size: 11px;
    margin-left: auto;
}
.noVNC_files_panel .fm-btn {
    padding: 1px 3px;
    font-size: 10px;
    flex-shrink: 0;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    line-height: 1;
}
.noVNC_files_panel .fm-btn:hover {
    color: #ccc;
}

/* Deterministic-color name pills used across dashboard (Servers, Recordings,
   Auto Remote Scan). Inline color/border-color come from _serverTag. */
.server-tag {
    display: inline-block;
    padding: 1px 8px;
    border: 1px solid currentColor;
    border-radius: 4px;
    font-size: 0.85em;
    font-weight: 500;
    line-height: 1.4;
    background: transparent;
}
.server-tag-unknown {
    color: var(--text-muted, #888);
    border-color: var(--text-muted, #888);
}

/* Missing badge variant — used by Recordings page for VNC/RBox type */
.badge-accent, .badge.accent { background: rgba(168,85,247,0.15); color: var(--accent, #a855f7); border: 1px solid rgba(168,85,247,0.3); }

/* ============================================================
   SECTION — Settings → Updates: popover action menu + row buttons
   ============================================================ */

/* Popover action menu anchored to a table row's ⋯ button. */
.popover-menu {
    background: rgba(10,22,40,0.96);
    color: var(--text-primary, #e2e8f0);
    border: 1px solid var(--border-hover, rgba(255,255,255,0.12));
    border-radius: 8px;
    padding: 4px 0;
    position: fixed;
    z-index: 1100;
    box-shadow: 0 4px 14px rgba(0,0,0,0.45);
    min-width: 180px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.popover-menu button {
    display: block;
    width: 100%;
    background: none;
    color: inherit;
    border: none;
    text-align: left;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.875rem;
    line-height: 1.4;
}

.popover-menu button:hover {
    background: rgba(255,255,255,0.06);
}

/* Subtle pill-style action button used in table cells (⋯). */
.btn-action {
    background: transparent;
    border: 1px solid var(--border-hover, rgba(255,255,255,0.12));
    color: var(--text-primary, #e2e8f0);
    cursor: pointer;
    padding: 2px 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    line-height: 1.4;
    transition: background 140ms ease, border-color 140ms ease;
}

.btn-action:hover {
    background: rgba(255,255,255,0.06);
    border-color: var(--border-hover, rgba(255,255,255,0.22));
}

/* Icon-only revoke button (trash). Red text, no frame. */
.btn-revoke {
    background: none;
    border: none;
    color: var(--danger, #ef4444);
    cursor: pointer;
    font-size: 1rem;
    padding: 2px 6px;
    line-height: 1;
    border-radius: 4px;
}

.btn-revoke:hover {
    background: rgba(239,68,68,0.12);
}

/* Tab switcher — used by Tokens page (Enrollment | API Tokens) */
.tab-bar {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border, rgba(148,163,184,0.1));
    margin-bottom: 16px;
}
.tab-btn {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary, #94a3b8);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    padding: 8px 16px;
    margin-bottom: -1px;
    transition: color 0.15s, border-color 0.15s;
}
.tab-btn:hover { color: var(--text-primary, #f1f5f9); }
.tab-btn.active {
    color: var(--primary, #06b6d4);
    border-bottom-color: var(--primary, #06b6d4);
}


/* ─── Plex layout ──────────────────────────────────────────────────── */

/* Server card action buttons — uniform shape, distinct accents. */
.sb-action-btn {
  min-width: 78px;
  height: 28px;
  padding: 0 12px;
  border-radius: 6px;
  border: 1px solid transparent;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: filter 0.12s, transform 0.06s;
}
.sb-action-btn:hover { filter: brightness(1.15); }
.sb-action-btn:active { transform: translateY(1px); }

.sb-action-terminal {
  background: linear-gradient(135deg, #0891b2, #7c3aed);
  border-color: rgba(139, 92, 246, 0.55);
  color: #fff;
  box-shadow: 0 2px 8px rgba(124, 58, 237, 0.35);
}
.sb-action-rbox {
  background: linear-gradient(135deg, #be185d, #7c3aed);
  border-color: rgba(190, 24, 93, 0.55);
  color: #fff;
  box-shadow: 0 2px 8px rgba(190, 24, 93, 0.30);
}
.sb-action-rescan {
  background: linear-gradient(135deg, #fb923c, #f97316);
  border-color: rgba(249, 115, 22, 0.55);
  color: #fff;
  box-shadow: 0 2px 8px rgba(249, 115, 22, 0.30);
}
.sb-action-more {
  min-width: 36px;
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.14);
  color: #94a3b8;
}

#plex-root {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: calc(100dvh - var(--vk-offset, 0px));
  overflow: hidden;
  background: #0f172a;
}

.plex-split {
  display: flex;
  flex: 1;
  overflow: hidden;
}

.plex-split.hsplit { flex-direction: row; }
.plex-split.vsplit { flex-direction: column; }

.plex-pane {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
  min-height: 0;
  position: relative;
  flex: 1 1 0;
  border: 1px solid transparent;
  transition: border-color 0.15s;
}

.plex-pane.focused {
  border-color: #67e8f9;
  box-shadow: inset 0 0 0 1px rgba(103, 232, 249, 0.3);
}

.plex-pane-header {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  background: #1a1a2e;
  border-bottom: 1px solid #2a2a3e;
  font-size: 11px;
  color: #94a3b8;
  flex-shrink: 0;
  user-select: none;
}

.plex-pane-header .pane-title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #cbd5e1;
}

.plex-pane-header button {
  background: transparent;
  border: 1px solid #334155;
  color: #cbd5e1;
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  line-height: 1.2;
  cursor: pointer;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  min-height: 24px;
  transition: background .12s, border-color .12s;
}

.plex-pane-header button:hover {
  background: #1e293b;
  border-color: #475569;
}

/* Larger SVG icons inside header buttons — the 12px versions used to be
   eye-strain small on desktop and untappable on mobile. */
.plex-pane-header button svg { width: 14px; height: 14px; }

/* ──────────────────────────────────────────────────────────────────────────
   Unified action-button system (.btn-act)

   Shared visual language for webterminal, plex, session modals, and any
   future dashboard sub-UIs. Use classes instead of inline style.cssText so
   themes/density tweaks land in one place.

   Anatomy:  .btn-act [size] [variant]
       size:    (default) | sm | icon | icon.sm
       variant: ghost (default) | primary | success | danger | accent

   Example:
       <button class="btn-act primary">Attach</button>
       <button class="btn-act accent sm">↗</button>
       <button class="btn-act danger sm">Kill</button>
       <button class="btn-act icon ghost">[svg]</button>
   ────────────────────────────────────────────────────────────────────────── */
.btn-act {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 12px;
  line-height: 1.2;
  cursor: pointer;
  border: 1px solid #334155;
  background: transparent;
  color: #cbd5e1;
  transition: background .12s, border-color .12s, color .12s;
  font-family: inherit;
  user-select: none;
  text-decoration: none;
  white-space: nowrap;
}
.btn-act:hover { background: #1e293b; border-color: #475569; }
.btn-act:disabled, .btn-act.is-disabled {
  opacity: .5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Sizes */
.btn-act.sm { padding: 2px 7px; font-size: 11px; border-radius: 4px; }
.btn-act.icon { padding: 0; width: 28px; height: 28px; }
.btn-act.icon.sm { width: 22px; height: 22px; }
.btn-act svg { display: block; }

/* Variants */
.btn-act.primary {
  background: #0891b2;
  border-color: #0891b2;
  color: #fff;
}
.btn-act.primary:hover { background: #0e7490; border-color: #0e7490; }

.btn-act.success {
  background: #16a34a;
  border-color: #16a34a;
  color: #fff;
}
.btn-act.success:hover { background: #15803d; border-color: #15803d; }

.btn-act.danger {
  background: #dc2626;
  border-color: #dc2626;
  color: #fff;
}
.btn-act.danger:hover { background: #b91c1c; border-color: #b91c1c; }

.btn-act.accent {
  border-color: #334155;
  color: #67e8f9;
}
.btn-act.accent:hover {
  background: rgba(103,232,249,.10);
  border-color: #67e8f9;
}

.btn-act.ghost {
  border-color: #334155;
  color: #cbd5e1;
}
.btn-act.ghost:hover { background: #1e293b; border-color: #475569; }

/* Row grouping helper — for layouts like the session modal where each item
   has [primary] [accent ↗] [danger]. Adds consistent spacing without per-
   button margins. */
.btn-act-group { display: inline-flex; align-items: center; gap: 4px; }

/* ──────────────────────────────────────────────────────────────────────────
   Modal shell (.app-modal)

   Single template for every centered modal in the dashboard. Backdrop +
   bordered box + header + scrollable body + footer. Replaces the per-call
   inline `position:fixed;inset:0;...` boilerplate that lived in
   promptModal, openServerPickerModal, openSessionPicker, etc.

   Sizes:  .app-modal.sm   (320px min)
           .app-modal.md   (420px min, default)
           .app-modal.lg   (560px min)
   ────────────────────────────────────────────────────────────────────────── */
.app-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.app-modal {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 0;
  color: #eee;
  box-shadow: 0 12px 32px rgba(0, 0, 0, .6);
  display: flex;
  flex-direction: column;
  max-width: 90vw;
  max-height: 90vh;
}
.app-modal.sm { width: 320px; }
.app-modal.md { width: 420px; }
.app-modal.lg { width: 560px; }
.app-modal.tall { height: 60vh; }
.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 10px;
  font-size: 14px;
  font-weight: 600;
  color: #cbd5e1;
  border-bottom: 1px solid #2a2a3e;
  flex-shrink: 0;
  user-select: none;
}
.app-modal-header.draggable { cursor: move; touch-action: none; }
.app-modal-header .app-modal-close {
  background: none;
  border: none;
  color: #718096;
  cursor: pointer;
  font-size: 18px;
  line-height: 1;
  padding: 0 4px;
}
.app-modal-header .app-modal-close:hover { color: #f87171; }
.app-modal-body {
  padding: 12px 16px;
  overflow-y: auto;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  -webkit-overflow-scrolling: touch;
}
.app-modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 10px 16px;
  border-top: 1px solid #2a2a3e;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────────────────────────────────
   App popover (.app-popover) — small floating panel, can be docked to an
   anchor element by JS positioning. Used for menus, quick lists, and any
   contextual UI that's smaller than a full modal.
   ────────────────────────────────────────────────────────────────────────── */
.app-popover {
  position: fixed;
  background: #1a1a2e;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 6px;
  z-index: 9999;
  min-width: 200px;
  max-width: 320px;
  max-height: 60vh;
  display: flex;
  flex-direction: column;
  color: #cbd5e1;
  box-shadow: 0 12px 36px rgba(0, 0, 0, .6);
  font-size: 13px;
}

/* ──────────────────────────────────────────────────────────────────────────
   Tab strip — base tab styling. State (active / deleted) is applied via
   class modifiers so JS doesn't need to know any colors.
   ────────────────────────────────────────────────────────────────────────── */
.plex-tab {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  background: transparent;
  color: #94a3b8;
  border: 1px solid transparent;
  max-width: 180px;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background .12s, color .12s;
}
.plex-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}
.plex-tab-close {
  color: #64748b;
  padding: 0 4px;
  border-radius: 3px;
  line-height: 1;
  font-size: 14px;
  cursor: pointer;
}
.plex-tab-close:hover { color: #f87171; background: #2a2a3e; }
.plex-tab.is-active {
  background: #1e293b;
  color: #67e8f9;
  border-color: #334155;
}
.plex-tab.is-deleted {
  color: #f87171;
  text-decoration: line-through;
  cursor: not-allowed;
}
.plex-tab:not(.is-active):not(.is-deleted):hover {
  background: rgba(30, 41, 59, .5);
  color: #cbd5e1;
}

.plex-pane-xterm {
  flex: 1;
  overflow: hidden;
  min-height: 0;
}

.plex-divider {
  background: #333;
  flex-shrink: 0;
  cursor: col-resize;
  z-index: 1;
  transition: background 0.15s;
}

.plex-split.hsplit > .plex-divider {
  width: 5px;
  cursor: col-resize;
}

.plex-split.vsplit > .plex-divider {
  height: 5px;
  cursor: row-resize;
}

.plex-divider:hover,
.plex-divider.dragging { background: #4a9eff; }

.plex-pane-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.82);
  color: #ccc;
  gap: 10px;
  font-size: 13px;
  z-index: 10;
}

.plex-pane-overlay button {
  padding: 6px 14px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #eee;
  cursor: pointer;
}

.plex-popover {
  position: absolute;
  top: 28px;
  right: 4px;
  background: #1e1e2e;
  border: 1px solid #444;
  border-radius: 6px;
  padding: 8px 12px;
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 160px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}

.plex-popover p { margin: 0; font-size: 12px; color: #ccc; }

.plex-popover .popover-actions {
  display: flex;
  gap: 6px;
}

/* Popover rows — left-aligned menu items used by pane overflow menus. */
.plex-popover-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  border-radius: 5px;
  font-size: 13px;
  text-align: left;
  transition: background .12s;
  font-family: inherit;
}
.plex-popover-row:hover { background: #1e293b; }
.plex-popover-row.is-danger { color: #fca5a5; }
.plex-popover-row.is-danger:hover { background: rgba(239,68,68,0.12); }
.plex-popover-row-icon {
  display: inline-flex;
  width: 16px;
  justify-content: center;
}

/* Drag-and-drop pane reorder. dragstart on the header sets .drag-source on
   the pane; dragover on another pane sets .drag-over; drop swaps the two
   nodes in the layout tree. */
.plex-pane.drag-source { opacity: 0.4; }
.plex-pane.drag-over {
  box-shadow: inset 0 0 0 2px #67e8f9, inset 0 0 24px rgba(103,232,249,0.15);
}
.plex-pane-header[draggable="true"] { cursor: grab; }
.plex-pane-header[draggable="true"]:active { cursor: grabbing; }

/* Mobile responsive — phones get larger touch targets and a compact toolbar.
   The layout itself stays as-is: users can still resize, but on portrait the
   horizontal splits will be very narrow — they can detach unused panes.

   Most plex DOM is built with inline style.cssText (padding/gap/font-size
   set directly on elements). @media rules without !important can't override
   inline styles, so the responsive shrinkage below needs !important to
   actually win against the JS-applied defaults. */
@media (max-width: 768px) {
  /* Force horizontal splits to stack vertically. On a phone, two side-by-side
     terminals at 180px each are unusable — each pane gets the full screen
     width while keeping the layout tree intact (going back to desktop view
     restores the side-by-side rendering). */
  .plex-split.hsplit {
    flex-direction: column !important;
  }
  .plex-split.hsplit > .plex-pane,
  .plex-split.hsplit > .plex-split {
    width: 100% !important;
    height: auto !important;
    flex: 1 1 0 !important;
    min-height: 200px;
  }
  .plex-split.hsplit > .plex-divider {
    width: 100% !important;
    height: 8px !important;
    cursor: row-resize !important;
  }
  .plex-split.vsplit > .plex-divider { height: 8px !important; }

  #plex-toolbar { flex-wrap: wrap !important; padding: 4px 6px !important; gap: 4px !important; }
  #plex-toolbar button { font-size: 11px !important; padding: 2px 5px !important; }
  /* Tab strip: take the full row when the toolbar wraps. Without explicit
     flex-basis, browsers measure on the desktop width and the strip stays
     stretched across two rows. */
  #plex-tab-strip {
    padding: 3px 6px !important;
    flex-basis: 100% !important;
    order: 99 !important;
    margin: 2px 0 !important;
  }
  .plex-tab { font-size: 11px !important; padding: 4px 8px 3px !important; max-width: 120px !important; }

  /* Compact pane header — drop the verbose Detach/Kill text buttons,
     keep only the icon controls (split, change-server). Detach/Kill stay
     reachable via the keyboard shortcuts and overlay buttons on session
     end. Header text shrinks too. */
  .plex-pane-header { padding: 2px 4px; gap: 3px; font-size: 10px; }
  .plex-pane-header .pane-title { font-size: 10px; }
  .plex-pane-header button.hide-on-mobile { display: none !important; }
  .plex-pane-header button { padding: 1px 4px; font-size: 10px; }

  /* Hide the prefix hint on mobile — keyboard shortcuts aren't practical
     without a hardware keyboard, and the badge wastes screen space. */
  #plex-prefix-hint { display: none !important; }

  /* Favorites / Groups widgets — keep them tappable but lighter on small
     screens. Server-card star/group buttons stay at 14px stroke for
     readability; the in-groups popover gets a full-width float. */
  .card-star-btn, .card-group-btn { padding: 4px !important; }
  .app-popover.in-groups {
    left: 8px !important;
    right: 8px !important;
    max-width: calc(100vw - 16px) !important;
    width: auto !important;
  }
}

.plex-popover button {
  flex: 1;
  padding: 4px 8px;
  border-radius: 3px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #eee;
  font-size: 11px;
  cursor: pointer;
}

.plex-popover button.danger { border-color: #c0392b; color: #e74c3c; }
.plex-popover button.danger:hover { background: #3a1010; }

.plex-session-picker {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.plex-session-picker .picker-box {
  background: #1a1a2e;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 16px;
  min-width: 300px;
  max-width: 420px;
  width: 90vw;
}

.plex-session-picker h3 {
  margin: 0 0 12px;
  font-size: 14px;
  color: #eee;
}

.plex-session-picker .picker-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 240px;
  overflow-y: auto;
}

.plex-session-picker .picker-list li {
  padding: 8px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
  color: #ccc;
}

.plex-session-picker .picker-list li:hover { background: #2a2a3e; }

.plex-session-picker .picker-list li.new-session {
  color: #4a9eff;
  font-weight: 500;
}

.plex-session-picker .picker-cancel {
  margin-top: 10px;
  width: 100%;
  padding: 6px;
  border-radius: 4px;
  border: 1px solid #555;
  background: #2a2a2a;
  color: #aaa;
  cursor: pointer;
}
