:root {
  --bg-main: #0a0b0e;
  --bg-card: rgba(18, 20, 26, 0.82);
  --bg-card-hover: rgba(24, 26, 34, 0.95);
  --bg-input: #111318;
  --border: rgba(255, 255, 255, 0.08);
  --border-focus: #1db954;
  --text-main: #f4f4f6;
  --text-muted: #8b8e9b;
  --primary: #1db954;
  --primary-hover: #1ed760;
  --primary-glow: rgba(29, 185, 84, 0.28);
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  line-height: 1.5;
}

/* Ambient glow blobs */
.ambient-glow {
  position: fixed;
  border-radius: 50%;
  filter: blur(120px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.35;
}

.glow-1 {
  width: 450px;
  height: 450px;
  background: radial-gradient(circle, #1db954 0%, transparent 70%);
  top: -100px;
  right: -50px;
}

.glow-2 {
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, #104323 0%, transparent 70%);
  bottom: -150px;
  left: -100px;
}

.app-layout {
  position: relative;
  z-index: 1;
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 24px 60px;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  flex-wrap: wrap;
  gap: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-icon {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #1db954, #0e632b);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 0 20px var(--primary-glow);
}

.brand-title {
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.brand-title span {
  color: var(--primary);
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.header-badges {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(29, 185, 84, 0.12);
  border: 1px solid rgba(29, 185, 84, 0.3);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--primary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.85); }
}

.domain-badge {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  padding: 6px 14px;
  border-radius: 100px;
  font-size: 0.82rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 18px 20px;
  backdrop-filter: blur(16px);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s, border-color 0.2s;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.16);
}

.metric-label {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  letter-spacing: 0.5px;
}

.metric-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: #fff;
  margin: 6px 0 2px;
  font-family: var(--font-mono);
}

.metric-detail {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 24px;
  align-items: start;
}

@media (max-width: 960px) {
  .workspace-grid {
    grid-template-columns: 1fr;
  }
}

.panel-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  backdrop-filter: blur(16px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
}

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

.panel-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.badge {
  background: rgba(29, 185, 84, 0.15);
  color: var(--primary);
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 6px;
  letter-spacing: 0.4px;
}

/* Generator Form */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #d1d5db;
}

.input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.input-wrapper input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 600;
  font-family: var(--font-mono);
  padding: 12px 64px 12px 16px;
  border-radius: var(--radius-md);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-wrapper input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 12px var(--primary-glow);
}

.input-suffix {
  position: absolute;
  right: 16px;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-weight: 600;
  pointer-events: none;
}

.preset-pills {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.pill {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.82rem;
  font-weight: 600;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.2s;
}

.pill:hover, .pill.active {
  background: rgba(29, 185, 84, 0.15);
  border-color: var(--primary);
  color: var(--primary);
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, #1db954, #1aa34a);
  color: #000;
  border: none;
  padding: 14px 20px;
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  box-shadow: 0 4px 18px var(--primary-glow);
  transition: transform 0.15s, background 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
  background: linear-gradient(135deg, #1ed760, #1db954);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(29, 185, 84, 0.45);
}

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

.action-divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

.control-actions h3 {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 12px;
}

.action-buttons-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.btn-secondary {
  background: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, border-color 0.2s;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  padding: 11px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, border-color 0.2s;
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: var(--danger);
  color: #fff;
}

/* Results panel */
.results-card {
  min-height: 560px;
  display: flex;
  flex-direction: column;
}

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

.results-title-group {
  display: flex;
  align-items: center;
  gap: 12px;
}

.results-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
}

.count-tag {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 6px;
  font-family: var(--font-mono);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: var(--radius-md);
  color: var(--text-muted);
  width: 240px;
}

.search-box input {
  background: transparent;
  border: none;
  outline: none;
  color: #fff;
  font-size: 0.82rem;
  font-family: var(--font-mono);
  width: 100%;
}

.table-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.feed-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.feed-state.hidden {
  display: none;
}

.empty-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  opacity: 0.6;
}

.feed-state h3 {
  font-size: 1rem;
  color: #fff;
  margin-bottom: 6px;
}

.feed-state p {
  font-size: 0.85rem;
  max-width: 320px;
}

.spinner {
  width: 38px;
  height: 38px;
  border: 3px solid rgba(29, 185, 84, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 14px;
}

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

/* Codes Feed List */
.codes-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 520px;
  overflow-y: auto;
  padding-right: 6px;
}

.codes-list::-webkit-scrollbar {
  width: 6px;
}

.codes-list::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.codes-list::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.code-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-input);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius-md);
  transition: all 0.2s;
  gap: 12px;
}

.code-item:hover {
  background: var(--bg-card-hover);
  border-color: rgba(29, 185, 84, 0.35);
}

.code-info {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
  flex: 1;
}

.code-idx {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-family: var(--font-mono);
  min-width: 28px;
}

.code-tag {
  background: rgba(29, 185, 84, 0.12);
  color: var(--primary);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.code-url {
  font-size: 0.82rem;
  color: #9ca3af;
  font-family: var(--font-mono);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.code-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-mini {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 6px 10px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s;
  text-decoration: none;
}

.btn-mini:hover {
  background: var(--primary);
  color: #000;
  border-color: var(--primary);
}

/* Toast notifications */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background: #181920;
  border: 1px solid var(--border);
  color: #fff;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.86rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slideIn 0.25s ease-out;
}

.toast.success {
  border-left: 4px solid var(--primary);
}

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

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