:root {
  --bg-deep: #0a0a0f;
  --bg-base: #0f0f17;
  --bg-elevated: #151520;
  --bg-card: #1a1a28;
  --bg-hover: #222233;
  --border: rgba(168, 85, 247, 0.15);
  --border-strong: rgba(168, 85, 247, 0.35);
  --purple-400: #c084fc;
  --purple-500: #a855f7;
  --purple-600: #9333ea;
  --purple-700: #7c3aed;
  --purple-glow: rgba(168, 85, 247, 0.25);
  --text-primary: #f4f4f8;
  --text-secondary: #9898b0;
  --text-muted: #6b6b82;
  --success: #34d399;
  --danger: #f87171;
  --warning: #fbbf24;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
  --sidebar-width: 260px;
}

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

html, body {
  height: 100%;
}

body {
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  line-height: 1.5;
  overflow: hidden;
}

.view {
  display: none;
  height: 100vh;
}

.view.active {
  display: flex;
}

.hidden {
  display: none !important;
}

/* Login */
#login-view {
  align-items: center;
  justify-content: center;
  position: relative;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, rgba(124, 58, 237, 0.18), transparent),
    radial-gradient(ellipse 50% 40% at 80% 80%, rgba(168, 85, 247, 0.08), transparent),
    var(--bg-deep);
}

.login-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(168, 85, 247, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(168, 85, 247, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

.login-card {
  position: relative;
  width: min(420px, calc(100vw - 32px));
  padding: 40px;
  background: rgba(21, 21, 32, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: 20px;
  backdrop-filter: blur(20px);
  box-shadow: var(--shadow), 0 0 60px var(--purple-glow);
}

.brand {
  text-align: center;
  margin-bottom: 32px;
}

.brand h1 {
  font-size: 1.5rem;
  font-weight: 700;
  background: linear-gradient(135deg, var(--text-primary), var(--purple-400));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.brand p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 4px;
}

#login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#login-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

#login-form label span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-hint {
  text-align: center;
  margin-top: 20px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-family: 'JetBrains Mono', monospace;
}

/* App layout */
#app-view {
  display: none;
}

#app-view.active {
  display: flex;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  height: 100vh;
  background: var(--bg-base);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 8px 10px 24px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}

.sidebar-brand strong {
  display: block;
  font-size: 0.9375rem;
}

.sidebar-brand span {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.sidebar-nav {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: left;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

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

.nav-item.active {
  background: linear-gradient(135deg, rgba(124, 58, 237, 0.25), rgba(168, 85, 247, 0.12));
  color: var(--purple-400);
  border: 1px solid var(--border-strong);
}

.sidebar-footer {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin-bottom: 8px;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--purple-600), var(--purple-700));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.875rem;
}

.user-chip strong {
  display: block;
  font-size: 0.8125rem;
}

.user-chip span {
  font-size: 0.6875rem;
  color: var(--text-muted);
}

.content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-deep);
  padding: 28px 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.topbar h2 {
  font-size: 1.5rem;
  font-weight: 700;
}

.topbar p {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-top: 2px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
}

.status-dot.online {
  background: var(--success);
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.6);
}

.status-text {
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* Stats */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

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

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stat-value.accent {
  color: var(--purple-400);
}

.stat-value.success {
  color: var(--success);
}

/* Toolbar */
.toolbar {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.search-box {
  flex: 1;
  min-width: 220px;
  position: relative;
}

.search-box svg {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

.search-box input {
  padding-left: 42px;
}

/* Table */
.table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: auto;
  max-height: calc(100vh - 340px);
}

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

.data-table th {
  position: sticky;
  top: 0;
  background: var(--bg-elevated);
  text-align: left;
  padding: 12px 14px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  z-index: 1;
}

.data-table td {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(168, 85, 247, 0.06);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.12s ease;
  cursor: context-menu;
}

.data-table tbody tr:hover {
  background: var(--bg-hover);
}

.data-table tbody tr.selected {
  background: rgba(124, 58, 237, 0.15);
  outline: 1px solid var(--border-strong);
}

.data-table tbody tr.blocked {
  opacity: 0.55;
}

.data-table tbody tr.blocked td:first-child::after {
  content: ' · blocked';
  color: var(--danger);
  font-size: 0.6875rem;
  margin-left: 4px;
}

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

.mono {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--purple-400);
}

.country-cell {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}

.country-cell .flag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  min-width: 20px;
}

.country-cell .flag-local {
  width: 22px;
  height: 15px;
  border-radius: 3px;
  background: linear-gradient(180deg, #7b8494 0%, #4b5563 100%);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge-admin {
  background: rgba(168, 85, 247, 0.2);
  color: var(--purple-400);
  border: 1px solid rgba(168, 85, 247, 0.3);
}

.badge-user {
  background: rgba(152, 152, 176, 0.15);
  color: var(--text-secondary);
  border: 1px solid rgba(152, 152, 176, 0.2);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
}

.status-badge::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.status-badge.online::before {
  background: var(--success);
  box-shadow: 0 0 6px rgba(52, 211, 153, 0.5);
}

.status-badge.offline::before {
  background: var(--text-muted);
}

.table-footer {
  margin-top: 12px;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Forms */
input[type="text"],
input[type="password"],
input[type="url"],
input[type="number"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.875rem;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus,
select:focus {
  border-color: var(--purple-500);
  box-shadow: 0 0 0 3px var(--purple-glow);
}

.select {
  width: auto;
  min-width: 140px;
  cursor: pointer;
}

.select.full {
  width: 100%;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-primary {
  background: linear-gradient(135deg, var(--purple-600), var(--purple-700));
  color: white;
  box-shadow: 0 4px 16px var(--purple-glow);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text-primary);
  border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--border-strong);
}

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

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

.btn-sm {
  padding: 7px 14px;
  font-size: 0.8125rem;
}

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

.form-error {
  color: var(--danger);
  font-size: 0.8125rem;
}

.form-success {
  color: var(--success);
  font-size: 0.8125rem;
  margin-top: 10px;
}

.field-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.field-hint {
  display: block;
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 4px;
}

.turnstile-field {
  display: block;
}

.turnstile-wrap {
  display: flex;
  justify-content: center;
  margin: 8px 0 4px;
  min-height: 70px;
}

#login-submit:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

/* Cards & settings */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}

.card h3 {
  font-size: 1rem;
  margin-bottom: 16px;
}

.card h4 {
  font-size: 0.9375rem;
  margin-bottom: 12px;
}

.card-desc {
  color: var(--text-secondary);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.field span {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.toggle-field {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.toggle-field input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--purple-500);
  cursor: pointer;
}

.toggle-field small {
  display: block;
  width: 100%;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: -8px;
}

/* Builder */
.builder-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.checkbox-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 16px;
}

.checkbox-group legend {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0 6px;
}

.checkbox-group label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
  font-size: 0.875rem;
  color: var(--text-primary);
  cursor: pointer;
}

.checkbox-group input {
  accent-color: var(--purple-500);
}

.builder-type-group {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin: 0 0 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.builder-type-group legend {
  padding: 0 6px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
}

.builder-type-option {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.875rem;
}

.builder-type-option .hint {
  color: var(--text-muted);
  font-size: 0.8125rem;
}

#builder-exe-options.hidden {
  display: none;
}

.builder-cert-info {
  margin-top: 12px;
  font-size: 0.8125rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  white-space: pre-wrap;
}

.builder-builds {
  margin-top: 16px;
}

.builder-builds-list {
  max-height: 220px;
  overflow: auto;
  font-size: 0.8125rem;
}

.builder-build-item {
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.builder-build-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.builder-revoke-btn {
  flex-shrink: 0;
}

.builder-actions {
  display: flex;
  gap: 10px;
}

.builder-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.input-with-btn {
  display: flex;
  gap: 8px;
}

.input-with-btn input {
  flex: 1;
}

.user-chip .sidebar-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.sidebar-meta {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
}

  margin: 8px 0 16px;
  padding: 10px 12px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-deep);
  font-family: var(--font-mono, monospace);
}

.builder-status {
  margin-top: 12px;
  font-size: 0.8125rem;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--bg-deep);
  white-space: pre-wrap;
}

.builder-status.info {
  color: var(--text-secondary);
}

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

.builder-status.error {
  color: var(--danger);
  border-color: rgba(248, 113, 113, 0.35);
}

@media (max-width: 700px) {
  .builder-grid-2 {
    grid-template-columns: 1fr;
  }
}

.preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.code-block {
  background: var(--bg-deep);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--purple-400);
  overflow: auto;
  max-height: 420px;
  white-space: pre-wrap;
  word-break: break-all;
}

/* About */
.about-hero {
  text-align: center;
  padding: 48px 32px;
  margin-bottom: 20px;
  background: linear-gradient(180deg, rgba(124, 58, 237, 0.12), var(--bg-card));
}

.about-hero h3 {
  font-size: 1.5rem;
  margin-bottom: 4px;
}

.version {
  color: var(--purple-400);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  margin-bottom: 16px;
}

.about-text {
  color: var(--text-secondary);
  max-width: 520px;
  margin: 0 auto;
  font-size: 0.9375rem;
}

.about-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.feature-list {
  list-style: none;
}

.feature-list li {
  padding: 8px 0;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid rgba(168, 85, 247, 0.06);
}

.feature-list li:last-child {
  border-bottom: none;
}

.feature-list li::before {
  content: '→';
  color: var(--purple-500);
  margin-right: 8px;
}

/* Responsive */
@media (max-width: 1100px) {
  .stats-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .settings-grid,
  .builder-layout,
  .about-grid {
    grid-template-columns: 1fr;
  }
}

/* Context menu */
.context-menu {
  position: fixed;
  z-index: 1000;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow), 0 0 40px var(--purple-glow);
}

.context-header {
  padding: 10px 12px 8px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.context-header strong {
  display: block;
  font-size: 0.875rem;
}

.context-header span {
  font-size: 0.6875rem;
  font-family: 'JetBrains Mono', monospace;
  color: var(--text-muted);
}

.context-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  transition: background 0.12s ease;
}

.context-menu button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.context-menu button:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--purple-400);
}

.context-menu button:hover:not(:disabled) svg {
  color: var(--purple-400);
}

.context-menu button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.context-menu button.danger {
  color: var(--danger);
}

.context-menu button.danger:hover:not(:disabled) {
  background: rgba(248, 113, 113, 0.12);
  color: var(--danger);
}

.context-divider {
  height: 1px;
  background: var(--border);
  margin: 4px 8px;
}

.ctx-submenu-wrap {
  position: relative;
}

.ctx-submenu-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.ctx-submenu-btn svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.ctx-submenu-label {
  flex: 1;
  min-width: 0;
}

.ctx-submenu-chevron {
  opacity: 0.7;
  font-size: 1rem;
  line-height: 1;
  flex-shrink: 0;
}

.ctx-submenu-btn:hover:not(:disabled) svg,
.ctx-submenu-wrap:hover .ctx-submenu-btn svg,
.ctx-submenu-wrap.submenu-open .ctx-submenu-btn svg {
  color: var(--purple-400);
}

.ctx-submenu-btn:hover:not(:disabled),
.ctx-submenu-wrap:hover .ctx-submenu-btn,
.ctx-submenu-wrap.submenu-open .ctx-submenu-btn {
  background: var(--bg-hover);
  color: var(--purple-400);
}

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

.ctx-submenu-panel {
  display: none;
  position: absolute;
  left: 100%;
  top: 0;
  min-width: 220px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow: var(--shadow);
  z-index: 1001;
}

/* Invisible bridge so hover doesn't break between parent row and flyout */
.ctx-submenu-panel::before {
  content: '';
  position: absolute;
  top: 0;
  right: 100%;
  width: 14px;
  height: 100%;
}

.ctx-submenu-wrap:hover .ctx-submenu-panel,
.ctx-submenu-wrap.submenu-open .ctx-submenu-panel {
  display: block;
}

/* Open to the left when there is no room on the right */
.ctx-submenu-wrap.submenu-flip .ctx-submenu-panel {
  left: auto;
  right: 100%;
}

.ctx-submenu-wrap.submenu-flip .ctx-submenu-panel::before {
  right: auto;
  left: 100%;
}

.ctx-submenu-panel button {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.8125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
}

.ctx-submenu-panel button:hover {
  background: var(--bg-hover);
  color: var(--purple-400);
}

.modal-wide {
  width: min(960px, 100%);
}

.run-file-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}

.run-file-tab {
  padding: 8px 14px;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  background: transparent;
  color: var(--text-secondary, #9ca3af);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.8125rem;
}

.run-file-tab.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.45);
  color: var(--purple-400, #c4b5fd);
}

.run-file-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.run-file-field span {
  font-size: 0.75rem;
  color: var(--text-muted, #9ca3af);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.run-file-field input[type="url"],
.run-file-field input[type="text"],
.run-file-field input[type="file"] {
  width: 100%;
}

.run-file-status {
  margin: 8px 0 0;
  font-size: 0.8125rem;
  color: var(--text-muted, #9ca3af);
  min-height: 1.2em;
}

.modal-wide .modal-body {
  max-height: calc(100vh - 180px);
  overflow: auto;
}

.rd-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 12px;
}

.rd-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.rd-meta {
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.rd-controls {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rd-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

.rd-screen-wrap {
  background: #000;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  min-height: 280px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: auto;
}

#rd-screen {
  max-width: 100%;
  max-height: 65vh;
  display: block;
  cursor: default;
  user-select: none;
}

.plugin-tool-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}

.plugin-tool-bar {
  display: flex;
  gap: 8px;
  align-items: center;
}

.plugin-tool-bar input {
  flex: 1;
}

.plugin-tool-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.manager-table-wrap {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border: 1px solid var(--border-subtle, rgba(255, 255, 255, 0.08));
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.25);
}

.manager-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.manager-table thead {
  position: sticky;
  top: 0;
  z-index: 1;
  background: rgba(18, 18, 30, 0.98);
}

.manager-table th,
.manager-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  white-space: nowrap;
}

.manager-table th {
  color: var(--text-muted, #9ca3af);
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.manager-table tbody tr {
  cursor: pointer;
}

.manager-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.04);
}

.manager-table tbody tr.selected {
  background: rgba(99, 102, 241, 0.18);
}

.manager-table .col-icon { width: 36px; text-align: center; }
.manager-table .col-size,
.manager-table .col-date,
.manager-table .col-pid,
.manager-table .col-priority,
.manager-table .col-mem,
.manager-table .col-state { width: 120px; }

.manager-table .dir-row td:nth-child(2) {
  color: #c4b5fd;
}

.manager-empty {
  text-align: center;
  color: var(--text-muted, #9ca3af);
  padding: 24px !important;
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.28);
}

.plugin-output {
  max-height: 420px;
  min-height: 200px;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
}

.modal-card {
  position: relative;
  z-index: 1;
  width: min(480px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.modal-header h3 {
  font-size: 1rem;
}

.modal-body {
  padding: 20px;
  display: grid;
  gap: 12px;
}

.detail-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  font-size: 0.875rem;
  padding: 8px 0;
  border-bottom: 1px solid rgba(168, 85, 247, 0.06);
}

.detail-row:last-child {
  border-bottom: none;
}

.detail-row span:first-child {
  color: var(--text-muted);
}

.detail-row span:last-child {
  text-align: right;
  font-weight: 500;
}

.modal-footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

/* Large plugin modals — File Manager, Process Manager, Remote Desktop, etc. */
.modal.modal-large {
  padding: 12px;
  align-items: center;
  justify-content: center;
}

.modal.modal-large > .modal-card {
  width: 92vw;
  max-width: none;
  height: 88vh;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
}

.modal.modal-large .modal-header {
  flex-shrink: 0;
  padding: 12px 16px;
}

.modal.modal-large .modal-header h3 {
  font-size: 1.05rem;
}

.modal.modal-large .modal-body {
  flex: 1;
  min-height: 0;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.modal.modal-large .modal-footer {
  flex-shrink: 0;
  padding: 10px 16px;
}

.modal.modal-large .plugin-tool-body {
  flex: 1;
  min-height: 0;
}

.modal.modal-large .manager-table-wrap {
  max-height: none;
  flex: 1;
}

.modal.modal-large .plugin-output,
.modal.modal-large #plugin-output-body {
  flex: 1;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.modal.modal-large .rd-body {
  flex: 1;
  min-height: 0;
  padding-top: 0;
}

.modal.modal-large .rd-toolbar {
  flex-shrink: 0;
  margin-bottom: 8px;
}

.modal.modal-large .rd-screen-wrap {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  min-height: 0;
}

.modal.modal-large #rd-screen {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: none;
  object-fit: contain;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  padding: 12px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease;
  pointer-events: auto;
}

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

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

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
  color: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  #app-view.active {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    min-width: unset;
    height: auto;
    flex-direction: row;
    flex-wrap: wrap;
    padding: 12px;
  }

  .sidebar-brand {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
  }

  .sidebar-nav {
    flex-direction: row;
    flex-wrap: wrap;
    flex: unset;
  }

  .sidebar-footer {
    display: none;
  }

  .content {
    padding: 16px;
  }

  .stats-row {
    grid-template-columns: 1fr 1fr;
  }
}
