:root {
  --bg: #0e1420;
  --bg-elevated: #141b2b;
  --border: #232b3d;
  --text: #e4e9f2;
  --text-dim: #8792a8;
  --accent: #4fd1c5;
  --accent-dim: #235a54;
  --warn: #f2b84b;
  --danger: #f2685b;
  --success: #4fd18c;
  --font-ui: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'SF Mono', 'JetBrains Mono', Consolas, monospace;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
}

.hidden { display: none !important; }

/* ---------- Animated background scene ---------- */
.bg-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

#auth-screen, .app { position: relative; z-index: 1; }

.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.35;
  will-change: transform;
}
.bg-orb-1 {
  width: 420px; height: 420px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  top: -10%; left: -5%;
  animation: drift1 22s ease-in-out infinite;
}
.bg-orb-2 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, #4f7dd1 0%, transparent 70%);
  bottom: -15%; right: -10%;
  animation: drift2 26s ease-in-out infinite;
}
.bg-orb-3 {
  width: 320px; height: 320px;
  background: radial-gradient(circle, #a24fd1 0%, transparent 70%);
  top: 40%; left: 60%;
  animation: drift3 18s ease-in-out infinite;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(60px, 40px) scale(1.1); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-50px, -30px) scale(1.05); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(-40px, 30px) scale(0.95); }
}

.bg-grid { position: absolute; inset: 0; opacity: 0.6; }
.bg-pulses { position: absolute; inset: 0; }

.pulse-node {
  fill: var(--accent);
  opacity: 0.5;
  animation: nodePulse 3s ease-in-out infinite;
}
.pulse-node:nth-child(2) { animation-delay: 0.6s; }
.pulse-node:nth-child(3) { animation-delay: 1.2s; }
.pulse-node:nth-child(4) { animation-delay: 1.8s; }
.pulse-node:nth-child(5) { animation-delay: 2.4s; }

@keyframes nodePulse {
  0%, 100% { r: 2; opacity: 0.4; }
  50% { r: 5; opacity: 0.9; }
}

.pulse-line {
  stroke: var(--accent);
  stroke-width: 1;
  opacity: 0.12;
  stroke-dasharray: 6 10;
  animation: flowLine 6s linear infinite;
}
@keyframes flowLine { to { stroke-dashoffset: -160; } }

@media (prefers-reduced-motion: reduce) {
  .bg-orb, .pulse-node, .pulse-line, .status-dot-pulse,
  .badge-running, .badge-claimed, .badge-retrying { animation: none !important; }
}

/* ---------- Site header (login screen only) ---------- */
.site-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 56px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  background: rgba(20, 27, 43, 0.5);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.site-header-brand { display: flex; align-items: center; gap: 8px; }
.site-header-brand .brand-mark { color: var(--accent); font-size: 18px; }
.site-header-brand .brand-name { font-weight: 600; letter-spacing: 0.02em; }
.site-header-tagline { font-size: 12px; color: var(--text-dim); letter-spacing: 0.02em; }
@media (max-width: 640px) { .site-header-tagline { display: none; } }

/* ---------- Auth screen ---------- */
.auth-screen {
  height: 100vh;
  box-sizing: border-box;
  padding-top: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
}

.auth-card {
  width: 380px;
  border-radius: 22px;
  padding: 32px;
  position: relative;
  overflow: hidden;
  transition: all 0.35s ease;
}

.brand { display: flex; align-items: center; gap: 8px; margin-bottom: 24px; }
.brand-mark { color: var(--accent); font-size: 20px; }
.brand-name { font-weight: 600; letter-spacing: 0.02em; }

.tabs { display: flex; gap: 4px; margin-bottom: 20px; background: var(--bg); border-radius: 8px; padding: 4px; }
.tab-btn {
  flex: 1; padding: 8px; background: transparent; border: none; color: var(--text-dim);
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.tab-btn.active {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.auth-form { display: flex; flex-direction: column; gap: 14px; }
.auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); }
.auth-form input {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 9px 10px; color: var(--text); font-size: 13px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}
.auth-form input:hover { border-color: var(--accent-dim); }
.auth-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.06);
}
.auth-form button[type="submit"] {
  margin-top: 6px; background: var(--accent); color: #052421; border: none;
  border-radius: 6px; padding: 10px; font-weight: 600; cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.auth-form button[type="submit"]:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(79, 209, 197, 0.35);
}
.hint { font-size: 11px; color: var(--text-dim); margin-top: 8px; }
.error { color: var(--danger); font-size: 12px; margin-top: 12px; }

/* ---------- App shell ---------- */
.app { display: flex; height: 100vh; }

.sidebar {
  width: 220px; min-width: 220px; flex-shrink: 1;
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  display: flex; flex-direction: column; padding: 20px 14px 46px;
  overflow-y: auto;
  min-height: 0;
  height: 100vh;
}
.sidebar nav { display: flex; flex-direction: column; gap: 2px; margin-top: 28px; }
.nav-btn {
  text-align: left; background: transparent; border: none; color: var(--text-dim);
  padding: 10px 12px; border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 500;
  transition: background 0.18s ease, color 0.18s ease, padding-left 0.18s ease;
  border-left: 2px solid transparent;
}
.nav-btn:hover:not(.active) {
  background: rgba(255, 255, 255, 0.03);
  color: var(--text);
  border-left-color: var(--accent-dim);
  padding-left: 16px;
}
.nav-btn.active {
  background: rgba(79, 209, 197, 0.12);
  color: var(--accent);
  border-left-color: var(--accent);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}
.sidebar-footer {
  margin-top: auto; padding-top: 12px; display: flex; flex-direction: column;
  gap: 6px; font-size: 12px; color: var(--text-dim); flex-shrink: 0;
}
#current-user { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.sidebar-footer button {
  background: transparent; border: 1px solid var(--border); color: var(--text-dim);
  border-radius: 6px; padding: 6px; cursor: pointer;
}

.content {
  flex: 1; padding: 32px 40px 88px; overflow-y: auto;
  height: 100vh; box-sizing: border-box;
}
.view { display: none; }
.view.active { display: block; }

h1 { font-size: 20px; font-weight: 600; margin: 0 0 20px; }
h2 { font-size: 14px; font-weight: 600; color: var(--text-dim); text-transform: uppercase; letter-spacing: 0.04em; margin: 0 0 14px; }

.view-header { display: flex; align-items: center; justify-content: flex-end; margin-bottom: 4px; }

/* ---------- Dashboard topbar ---------- */
.topbar {
  
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: -32px -40px 32px;
  padding: 18px 40px;
  background: rgba(14, 20, 32, 0.85);
  -webkit-backdrop-filter: blur(14px) saturate(140%);
  backdrop-filter: blur(14px) saturate(140%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}
.topbar-title {
  font-size: 17px;
  font-weight: 700;
}
.topbar-status {
  display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-dim);
  padding: 5px 12px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
}
.status-dot-pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--success);
  animation: statusPulse 2s ease-out infinite;
}
.status-dot-pulse.status-warn { background: var(--warn); }
.status-dot-pulse.status-danger { background: var(--danger); }
@keyframes statusPulse {
  0%   { box-shadow: 0 0 0 0 rgba(79, 209, 140, 0.5); }
  70%  { box-shadow: 0 0 0 8px rgba(79, 209, 140, 0); }
  100% { box-shadow: 0 0 0 0 rgba(79, 209, 140, 0); }
}

/* ---------- Buttons ---------- */
.primary-btn, .secondary-btn { position: relative; overflow: hidden; --mx: 50%; --my: 50%; }

.primary-btn {
  background: rgba(79, 209, 197, 0.18);
  border: 1px solid rgba(79, 209, 197, 0.5);
  color: var(--accent);
  border-radius: 6px; padding: 8px 14px; font-weight: 600; cursor: pointer; font-size: 13px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.primary-btn:hover {
  background: var(--accent);
  color: #052421;
  transform: translateY(-1px);
  box-shadow: 0 4px 20px rgba(79, 209, 197, 0.45);
}

.secondary-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text);
  border-radius: 6px; padding: 6px 10px; cursor: pointer; font-size: 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: transform 0.15s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.secondary-btn:hover {
  background: rgba(79, 209, 197, 0.1);
  border-color: var(--accent);
  color: var(--accent);
  transform: translateY(-1px);
}

.danger-btn { color: var(--danger); border-color: var(--danger); }
.danger-btn:hover { background: rgba(242, 104, 91, 0.12); transform: translateY(-1px); }

.primary-btn::after, .secondary-btn::after {
  content: "";
  position: absolute; inset: 0;
  background: radial-gradient(80px circle at var(--mx) var(--my), rgba(255,255,255,0.25), transparent 70%);
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.primary-btn:hover::after, .secondary-btn:hover::after { opacity: 1; }

/* ---------- Glass surfaces (overview cards, panels, tables, modals) ---------- */
.auth-card,
.sidebar,
.panel,
.stat-card,
.worker-card,
.data-table,
.modal {
  background: rgba(20, 27, 43, 0.55);
  -webkit-backdrop-filter: blur(16px) saturate(140%);
  backdrop-filter: blur(16px) saturate(140%);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}
.sidebar { background: rgba(20, 27, 43, 0.4); }

.auth-card::before,
.panel::before,
.stat-card::before,
.worker-card::before,
.modal::before {
  content: "";
  position: absolute;
  top: 0; left: 12px; right: 12px;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
}
.panel, .stat-card, .worker-card, .modal { position: relative; overflow: hidden; }

/* ---------- Overview ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 28px; }
.stat-card {
  border-radius: 10px; padding: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  --mx: 50%; --my: 50%;
}
.stat-card:hover { transform: translateY(-2px); border-color: rgba(79, 209, 197, 0.35); }
.stat-card .value { font-size: 26px; font-weight: 700; font-family: var(--font-mono); }
.stat-card .label { font-size: 12px; color: var(--text-dim); margin-top: 4px; }

.panel { border-radius: 10px; padding: 20px; margin-bottom: 20px; --mx: 50%; --my: 50%; }

.stat-card::after, .worker-card::after, .panel::after {
  content: "";
  position: absolute; inset: 0; border-radius: inherit;
  background: radial-gradient(280px circle at var(--mx) var(--my), rgba(79, 209, 197, 0.15), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.stat-card:hover::after, .worker-card:hover::after, .panel:hover::after { opacity: 1; }

.status-bars { display: flex; flex-direction: column; gap: 10px; }
.status-row { display: flex; align-items: center; gap: 10px; font-size: 12px; }
.status-row .status-label { width: 100px; color: var(--text-dim); text-transform: capitalize; }
.status-row .bar-track { flex: 1; height: 8px; background: var(--bg); border-radius: 4px; overflow: hidden; }
.status-row .bar-fill { height: 100%; border-radius: 4px; }
.status-row .count { width: 40px; text-align: right; font-family: var(--font-mono); }

.throughput-chart { display: flex; align-items: flex-end; gap: 4px; height: 100px; }
.throughput-bar { flex: 1; background: var(--accent-dim); border-radius: 2px 2px 0 0; min-height: 2px; }
.empty-note { color: var(--text-dim); font-size: 12px; }

/* ---------- Tables ---------- */
.data-table { width: 100%; border-collapse: collapse; border-radius: 10px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); font-size: 12px; }
.data-table th {
  color: var(--text-dim); font-weight: 600; text-transform: uppercase; font-size: 11px; letter-spacing: 0.03em;
  background: rgba(255, 255, 255, 0.03);
}
.data-table td.mono { font-family: var(--font-mono); }
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr { transition: background 0.15s ease; }
.data-table tbody tr:hover td { background: rgba(79, 209, 197, 0.08); }

.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; transition: transform 0.15s ease; }
.badge-queued, .badge-scheduled { background: #2a3550; color: #9db4e8; }
.badge-claimed, .badge-running { background: #2e4f2e; color: var(--success); }
.badge-completed { background: #1c4a3e; color: var(--success); }
.badge-failed, .badge-dead_letter { background: #4a2323; color: var(--danger); }
.badge-retrying { background: #4a3d1c; color: var(--warn); }
.badge-cancelled { background: #2a2a2a; color: var(--text-dim); }
.badge-running, .badge-claimed, .badge-retrying { animation: badgeLive 1.8s ease-in-out infinite; }
@keyframes badgeLive { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.filters { display: flex; gap: 10px; margin-bottom: 16px; }
.filters select, .project-picker select {
  background: rgba(255, 255, 255, 0.04); color: var(--text); border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px; padding: 7px 10px; font-size: 12px;
}
.project-picker { margin-bottom: 16px; }

.pagination { display: flex; gap: 8px; margin-top: 14px; align-items: center; font-size: 12px; color: var(--text-dim); }
.pagination button {
  background: rgba(255, 255, 255, 0.04); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 5px 10px; cursor: pointer;
}
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Workers ---------- */
.worker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.worker-card {
  border-radius: 10px; padding: 16px;
  transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  --mx: 50%; --my: 50%;
}
.worker-card:hover { transform: translateY(-2px); border-color: rgba(79, 209, 197, 0.35); }
.worker-card .name { font-family: var(--font-mono); font-weight: 600; }
.worker-card .meta { font-size: 12px; color: var(--text-dim); margin-top: 6px; }
.worker-status-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 6px; }
.dot-online { background: var(--success); }
.dot-offline { background: var(--text-dim); }
.dot-draining { background: var(--warn); }
.dot-stale { background: var(--danger); }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(10, 14, 22, 0.5);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center; z-index: 50;
}
.modal { border-radius: 10px; padding: 24px; width: 420px; max-height: 80vh; overflow-y: auto; }
.modal-wide { width: 640px; }
.modal h2 { margin-top: 0; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--text-dim); margin-bottom: 12px; }
.modal input, .modal select, .modal textarea {
  background: rgba(255, 255, 255, 0.04); border: 1px solid rgba(255, 255, 255, 0.1); border-radius: 6px;
  padding: 8px 10px; color: var(--text); font-size: 13px; font-family: var(--font-ui);
}
.modal input:focus, .modal select:focus, .modal textarea:focus {
  outline: none; background: rgba(255, 255, 255, 0.06); border-color: var(--accent);
}
.modal textarea { font-family: var(--font-mono); min-height: 80px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.modal-close { position: absolute; top: 16px; right: 20px; }

.log-line { font-family: var(--font-mono); font-size: 11px; padding: 6px 0; border-bottom: 1px solid var(--border); }
.log-line.level-warn { color: var(--warn); }
.log-line.level-error { color: var(--danger); }
.exec-row { display: flex; justify-content: space-between; font-size: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-family: var(--font-mono); }

/* ---------- Click ripple + particle burst ---------- */
.click-fx-layer { position: fixed; inset: 0; z-index: 9999; pointer-events: none; overflow: hidden; }

.click-ripple {
  position: absolute; width: 10px; height: 10px; border-radius: 50%;
  border: 1px solid rgba(79, 209, 197, 0.7);
  background: radial-gradient(circle, rgba(79,209,197,0.25), transparent 70%);
  transform: translate(-50%, -50%);
  animation: rippleExpand 0.7s ease-out forwards;
}
@keyframes rippleExpand {
  0%   { width: 10px; height: 10px; opacity: 0.9; }
  100% { width: 180px; height: 180px; opacity: 0; }
}

.click-particle {
  position: absolute; width: 5px; height: 5px; border-radius: 50%; background: var(--accent);
  transform: translate(-50%, -50%);
  animation: particleBurst 0.6s ease-out forwards;
}
@keyframes particleBurst {
  0%   { transform: translate(-50%, -50%) translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(-50%, -50%) translate(var(--px), var(--py)) scale(0.2); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .click-ripple, .click-particle { animation: none; display: none; }
}

/* ---------- Theme presets ---------- */
[data-theme="aurora"] {
  --bg: #140f1f; --bg-elevated: #1c1530; --border: #2e2347;
  --text: #ece7f7; --text-dim: #a596c4; --accent: #b366e8; --accent-dim: #4a2c66;
  --warn: #f2b84b; --danger: #f2685b; --success: #4fd18c;
}
[data-theme="ember"] {
  --bg: #1a1210; --bg-elevated: #241a17; --border: #3a2823;
  --text: #f3e9e4; --text-dim: #b89a8e; --accent: #f2905b; --accent-dim: #5c3823;
  --warn: #f2d24b; --danger: #f2544b; --success: #8ed14f;
}
[data-theme="solar"] {
  --bg: #faf6ee; --bg-elevated: #ffffff; --border: #e6dfd0;
  --text: #2b2620; --text-dim: #8a8272; --accent: #d97706; --accent-dim: #fce3c2;
  --warn: #b45309; --danger: #dc2626; --success: #15803d;
}
[data-theme="solar"] .auth-card,
[data-theme="solar"] .sidebar,
[data-theme="solar"] .panel,
[data-theme="solar"] .stat-card,
[data-theme="solar"] .worker-card,
[data-theme="solar"] .data-table,
[data-theme="solar"] .modal {
  background: rgba(255, 255, 255, 0.55);
  border-color: rgba(0, 0, 0, 0.08);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.6);
}
[data-theme="solar"] .sidebar { background: rgba(255, 255, 255, 0.45); }
[data-theme="solar"] .modal-backdrop { background: rgba(40, 30, 10, 0.25); }
[data-theme="solar"] .primary-btn { color: #ffffff; background: rgba(217, 119, 6, 0.85); border-color: #d97706; }
[data-theme="solar"] .primary-btn:hover { background: #d97706; }
[data-theme="solar"] .secondary-btn { border-color: rgba(0,0,0,0.15); }
[data-theme="solar"] .auth-form input,
[data-theme="solar"] .modal input,
[data-theme="solar"] .modal select,
[data-theme="solar"] .modal textarea { background: rgba(0,0,0,0.03); border-color: rgba(0,0,0,0.12); }

.theme-switcher { display: flex; gap: 8px; margin-bottom: 10px; }
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2); cursor: pointer; padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}
.theme-dot:hover { transform: scale(1.15); }
.theme-dot.active { border-color: var(--text); }

/* ---------- Footer ---------- */
.app-footer {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  padding: 10px 0;
  background: rgba(14, 20, 32, 0.55);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  z-index: 20;
}

/* ---------- Styled scrollbars ---------- */
.sidebar, .content {
  scrollbar-width: thin;
  scrollbar-color: rgba(79, 209, 197, 0.35) transparent;
}
.sidebar::-webkit-scrollbar, .content::-webkit-scrollbar { width: 6px; }
.sidebar::-webkit-scrollbar-track, .content::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb, .content::-webkit-scrollbar-thumb {
  background: rgba(79, 209, 197, 0.35); border-radius: 3px;
}
.sidebar::-webkit-scrollbar-thumb:hover, .content::-webkit-scrollbar-thumb:hover {
  background: rgba(79, 209, 197, 0.55);
}
/* ---------- Fix native dropdown/select popups showing as white ---------- */
/* color-scheme tells the browser which native UI (checkboxes, dropdown
   popups, scrollbars) to use for form controls we can't fully re-style
   with CSS - without this, the <select> popup ignores our dark colors
   and falls back to the OS default (usually white). */
/* ---------- Fix native dropdown/select popups showing as white ---------- */
select {
  color-scheme: dark;
  background-color: var(--bg-elevated);
  color: var(--text);
}
select option {
  background-color: var(--bg-elevated);
  color: var(--text);
}

[data-theme="solar"] select {
  color-scheme: light;
}
/* ---------- Logout transition ---------- */
#app, #auth-screen {
  transition: opacity 0.35s ease, transform 0.35s ease, filter 0.35s ease;
}

.screen-fade-out {
  opacity: 0;
  transform: scale(0.98);
  filter: blur(4px);
}

.screen-fade-in {
  animation: screenFadeIn 0.5s ease forwards;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: scale(1.02); filter: blur(4px); }
  to   { opacity: 1; transform: scale(1); filter: blur(0); }
}

@media (prefers-reduced-motion: reduce) {
  #app, #auth-screen { transition: none; }
  .screen-fade-in { animation: none; }
}
/* ---------- Password show/hide toggle ---------- */
.password-field {
  position: relative;
  display: flex;
}
.password-field input {
  width: 100%;
  padding-right: 40px;
}
.password-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  padding: 6px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.15s ease, background 0.15s ease;
}
.password-toggle:hover {
  color: var(--accent);
  background: rgba(79, 209, 197, 0.1);
}
/* ---------- Password toggle hover/active polish ---------- */
.password-toggle {
  transition: color 0.15s ease, background 0.15s ease, transform 0.15s ease;
}
.password-toggle:hover {
  color: var(--accent);
  background: rgba(79, 209, 197, 0.12);
  transform: translateY(-50%) scale(1.15);
  box-shadow: 0 0 12px rgba(79, 209, 197, 0.35);
}
.password-toggle:active {
  transform: translateY(-50%) scale(0.9);
}

.password-toggle svg {
  transition: transform 0.25s ease;
}
.password-toggle:hover .icon-eye,
.password-toggle:hover .icon-eye-off {
  transform: scale(1.1);
}
/* ---------- Stronger glassmorphism for the auth card ---------- */
.auth-card {
  background: rgba(20, 27, 43, 0.35);
  -webkit-backdrop-filter: blur(24px) saturate(180%);
  backdrop-filter: blur(24px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.37),
    0 0 0 1px rgba(79, 209, 197, 0.05),
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    inset 0 -1px 0 rgba(0, 0, 0, 0.2);
}

/* Slow light sweep across the card surface - the classic "glass
   catching ambient light" cue, subtle and continuous rather than
   only on hover. */
.auth-card::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 20%,
    rgba(255, 255, 255, 0.06) 35%,
    rgba(255, 255, 255, 0.1) 45%,
    rgba(255, 255, 255, 0.06) 55%,
    transparent 70%
  );
  background-size: 250% 250%;
  animation: glassSheen 8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes glassSheen {
  0%   { background-position: 200% 200%; }
  100% { background-position: -50% -50%; }
}

/* Inputs and tabs inside get a touch more transparency too, so the
   layered-glass depth reads clearly against the card behind them. */
.auth-form input {
  background: rgba(255, 255, 255, 0.03);
  border-color: rgba(255, 255, 255, 0.12);
}
.tabs {
  background: rgba(0, 0, 0, 0.25);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

@media (prefers-reduced-motion: reduce) {
  .auth-card::after { animation: none; }
}
/* ---------- Auth form switch animation ---------- */
.auth-form {
  animation: formSlideIn 0.35s ease;
}

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

.auth-form.form-slide-out {
  animation: formSlideOut 0.2s ease forwards;
}

@keyframes formSlideOut {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-12px); }
}

/* The active-tab underline itself slides too, instead of snapping. */
.tabs {
  position: relative;
}
.tab-btn {
  position: relative;
  z-index: 1;
}
.tab-btn.active {
  transition: background 0.15s ease, color 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  .auth-form, .auth-form.form-slide-out { animation: none; }
}
/* ---------- Logout button hover fill effect ---------- */
.sidebar-footer button {
  position: relative;
  overflow: hidden;
  z-index: 1;
  transition: color 0.3s ease, border-color 0.3s ease;
}

.sidebar-footer button::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.35s ease;
  z-index: -1;
}

.sidebar-footer button:hover {
  color: rgba(0, 0, 0, 0.85);
  border-color: var(--accent);
}
.sidebar-footer button:hover::before {
  transform: scaleX(1);
}
/* ---------- Theme switcher on login screen ---------- */
.theme-switcher-auth {
  position: absolute;
  bottom: 46px; /* clears the fixed footer */
  left: 24px;
  z-index: 10;
}
/* ---------- Mobile responsive ---------- */
.hamburger-btn {
  display: none;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 22px;
  cursor: pointer;
  padding: 6px 10px;
  margin-right: 10px;
  border-radius: 6px;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.06); }

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 90;
}
.sidebar-overlay.active { display: block; }

@media (max-width: 860px) {
  /* Auth screen */
  .site-header { padding: 0 16px; }
  .auth-screen { padding: 72px 16px 24px; height: auto; min-height: 100vh; }
  .auth-card { width: 100%; max-width: 380px; padding: 24px 20px; }
  .theme-switcher-auth { left: 16px; bottom: 70px; }

  /* App shell -> off-canvas sidebar */
  html, body { overflow: auto; }
  .app { position: relative; height: auto; min-height: 100vh; }
  .sidebar {
    position: fixed;
    left: 0; top: 0;
    height: 100vh;
    width: 260px;
    z-index: 100;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
    box-shadow: 8px 0 30px rgba(0,0,0,0.4);
  }
  .hamburger-btn { display: flex; align-items: center; justify-content: center; }

  .content { padding: 16px 16px 100px; height: auto; min-height: 100vh; }
  .topbar {
    margin: -16px -16px 20px;
    padding: 14px 16px;
    position: sticky; top: 0;
  }
  .topbar-title { font-size: 15px; }
  .topbar-status { font-size: 11px; padding: 4px 10px; }
  .topbar-status span:not(.status-dot-pulse) { max-width: 140px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

  /* Bigger tap targets everywhere */
  .nav-btn { padding: 14px 12px; font-size: 14px; }
  .primary-btn { padding: 11px 16px; font-size: 14px; }
  .secondary-btn { padding: 9px 12px; font-size: 13px; }
  .password-toggle { padding: 10px; }

  /* Cards & grids stack */
  .stat-grid { grid-template-columns: repeat(2, 1fr); gap: 10px; }
  .worker-grid { grid-template-columns: 1fr; }
  .panel { padding: 16px; }

  /* Tables scroll horizontally instead of squashing */
  .data-table { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; white-space: nowrap; }
  .data-table th, .data-table td { padding: 10px 12px; }

  .filters { flex-direction: column; gap: 8px; }
  .filters select, .project-picker select { width: 100%; }
  .view-header { flex-wrap: wrap; gap: 8px; }

  /* Modals go near full-screen */
  .modal, .modal-wide {
    width: calc(100% - 24px);
    max-width: 480px;
    max-height: 85vh;
    padding: 20px 16px;
  }

  .app-footer { font-size: 10px; padding: 8px 0; }
}

@media (max-width: 420px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .auth-card { padding: 20px 16px; }
  .topbar-status span:not(.status-dot-pulse) { display: none; }
}