:root {
  --bg: #0a0b10;
  --card: rgba(20, 22, 32, 0.72);
  --card-solid: #14161f;
  --input: #0c0d13;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #8b5cf6;
  --text: #f3f4f6;
  --muted: #9ca3af;
  --accent: #7c3aed;
  --accent-2: #2563eb;
  --accent-hover: #6d28d9;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --success: #22c55e;
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', monospace;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  padding: 1.25rem;
  position: relative;
  overflow-x: hidden;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(600px circle at 15% 10%, rgba(124, 58, 237, 0.22), transparent 60%),
    radial-gradient(700px circle at 85% 25%, rgba(37, 99, 235, 0.18), transparent 60%),
    radial-gradient(500px circle at 50% 90%, rgba(124, 58, 237, 0.12), transparent 60%);
  animation: drift 18s ease-in-out infinite alternate;
}

@keyframes drift {
  0% { transform: translate(0, 0) scale(1); }
  100% { transform: translate(-2%, 2%) scale(1.05); }
}

.hidden {
  display: none !important;
}

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

.fade-in {
  animation: fadeInUp 0.5s ease both;
  animation-delay: var(--delay, 0s);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 5, 8, 0.88);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
  animation: fadeInUp 0.3s ease both;
}

.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(124, 58, 237, 0.08);
  animation: fadeInUp 0.45s ease both;
}

.brand-mark {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  justify-content: center;
  margin-bottom: 1.5rem;
}

.brand-glyph {
  font-size: 1.4rem;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 8px rgba(124, 58, 237, 0.5));
}

.brand-name {
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.auth-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-header h2 {
  font-size: 1.35rem;
  margin-bottom: 0.35rem;
  font-weight: 700;
}

.auth-header p {
  color: var(--muted);
  font-size: 0.875rem;
}

.google-btn-container {
  display: flex;
  justify-content: center;
  margin-bottom: 0.5rem;
  min-height: 44px;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 0.4rem;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 0.65rem 0.9rem;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-family: var(--font);
  font-size: 0.9rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.55rem 1rem;
  font-size: 0.85rem;
  font-weight: 500;
  border-radius: 8px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-full {
  width: 100%;
}

.btn-sm {
  padding: 0.4rem 0.75rem;
  font-size: 0.775rem;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.btn-primary:hover {
  filter: brightness(1.1);
  box-shadow: 0 4px 18px rgba(124, 58, 237, 0.35);
  transform: translateY(-1px);
}

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

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: translateY(-1px);
}

.btn-danger {
  background: rgba(220, 38, 38, 0.15);
  color: #fca5a5;
  border-color: rgba(220, 38, 38, 0.3);
}

.btn-danger:hover {
  background: var(--danger);
  color: #fff;
  transform: translateY(-1px);
}

.error-banner {
  background: rgba(220, 38, 38, 0.15);
  border: 1px solid rgba(220, 38, 38, 0.3);
  color: #fca5a5;
  padding: 0.65rem 0.8rem;
  border-radius: 8px;
  font-size: 0.8rem;
  margin-top: 0.75rem;
  line-height: 1.4;
}

.error-banner code {
  background: rgba(0, 0, 0, 0.3);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-family: var(--mono);
}

.app-container {
  max-width: 1150px;
  margin: 0 auto;
  animation: fadeInUp 0.4s ease both;
}

.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0.9rem 1.35rem;
  margin-bottom: 1.25rem;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.nav-brand h1 {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.nav-email {
  font-size: 0.8rem;
  color: var(--muted);
  font-family: var(--mono);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.85rem;
  margin-bottom: 1.25rem;
}

.stat-card {
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.1rem 1.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.35);
}

.stat-value {
  font-size: 1.7rem;
  font-weight: 800;
  background: linear-gradient(135deg, #fff, #c4b5fd);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--muted);
}

.dashboard-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.card {
  background: var(--card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.35rem;
  transition: border-color 0.2s ease;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.card-header-actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.card-header h2 {
  font-size: 1.05rem;
  font-weight: 700;
}

.code-editor-container {
  display: flex;
  background: var(--input);
  border: 1px solid var(--border);
  border-radius: 8px;
  height: 360px;
  overflow: hidden;
}

.line-numbers {
  width: 44px;
  background: rgba(255, 255, 255, 0.02);
  border-right: 1px solid var(--border);
  color: #4b5563;
  font-family: var(--mono);
  font-size: 0.825rem;
  line-height: 1.45rem;
  padding: 0.6rem 0.35rem;
  text-align: right;
  user-select: none;
  overflow: hidden;
}

textarea#script-content {
  flex: 1;
  background: transparent;
  border: none;
  color: #a7f3d0;
  font-family: var(--mono);
  font-size: 0.85rem;
  line-height: 1.45rem;
  padding: 0.6rem;
  resize: none;
  white-space: pre;
}

.script-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 0.85rem;
}

.script-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 0.75rem;
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.15s ease;
}

.script-card:hover {
  transform: translateY(-2px);
  border-color: rgba(139, 92, 246, 0.35);
  background: rgba(255, 255, 255, 0.05);
}

.script-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.script-card-title {
  font-family: var(--mono);
  font-size: 0.9rem;
  font-weight: 600;
  color: #a5b4fc;
  overflow-wrap: anywhere;
}

.run-badge {
  font-size: 0.72rem;
  font-family: var(--mono);
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  white-space: nowrap;
}

.script-card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
  grid-column: 1 / -1;
  text-align: center;
  padding: 2rem 1rem;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  color: var(--muted);
  font-size: 0.85rem;
  grid-column: 1 / -1;
  padding: 2rem 1rem;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.security-card {
  border-color: rgba(251, 191, 36, 0.2);
}

.security-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.security-list li {
  font-size: 0.85rem;
  color: var(--muted);
  line-height: 1.5;
  padding-left: 1.1rem;
  position: relative;
}

.security-list li::before {
  content: "›";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-weight: 700;
}

.security-list code {
  background: rgba(255, 255, 255, 0.06);
  padding: 0.1rem 0.35rem;
  border-radius: 4px;
  font-family: var(--mono);
  color: #c4b5fd;
}

.toast-container {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--card-solid);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.65rem 1.1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  animation: slideIn 0.25s ease both;
}

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

.toast-out {
  opacity: 0;
  transform: translateX(40px);
  transition: all 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--accent-2); }

@media (max-width: 640px) {
  .navbar { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .nav-actions { width: 100%; justify-content: space-between; }
}
