/* ============================================================
   APP20 SERP Parser — Design System
   Aesthetic: Precision Instrument / Radar Command Center
   Dominant: Deep navy (#1a1a2e) | Accent: Signal crimson (#e94560)
   Typography: Space Grotesk (UI) + JetBrains Mono (data/codes)
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* ─── Design Tokens ────────────────────────────────────────── */
:root {
  /* Colors */
  --bg-void:        #0d0d1a;
  --bg-base:        #1a1a2e;
  --bg-card:        #16213e;
  --bg-elevated:    #1e2a4a;
  --bg-input:       #0f1a30;

  --border-dim:     #2a3a5c;
  --border-focus:   #4a6fa5;
  --border-accent:  #e94560;

  --accent-primary: #e94560;
  --accent-secondary: #0f3460;
  --accent-glow:    rgba(233, 69, 96, 0.15);

  --signal-running: #3b82f6;
  --signal-done:    #22c55e;
  --signal-fail:    #ef4444;
  --signal-pending: #6b7280;
  --signal-warn:    #f59e0b;

  --text-primary:   #e8eaf0;
  --text-secondary: #8892aa;
  --text-dim:       #4a5568;
  --text-accent:    #e94560;
  --text-code:      #7dd3fc;

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

  /* Typography */
  --font-ui:   'Space Grotesk', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Courier New', monospace;

  /* Motion */
  --dur-fast:   120ms;
  --dur-normal: 220ms;
  --dur-slow:   400ms;
  --ease-out:   cubic-bezier(0.16, 1, 0.3, 1);

  /* Layout */
  --sidebar-width: 280px;
  --header-height: 52px;
  --panel-height:  200px;
}

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

html, body {
  height: 100%;
  background: var(--bg-void);
  color: var(--text-primary);
  font-family: var(--font-ui);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }
ul { list-style: none; }

/* ─── Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-dim); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-focus); }

/* ═══════════════════════════════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════════════════════════════ */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-void);
  position: relative;
  overflow: hidden;
}

/* Radar grid background */
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(rgba(15, 52, 96, 0.3) 1px, transparent 1px),
    linear-gradient(90deg, rgba(15, 52, 96, 0.3) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 50%, black 40%, transparent 100%);
}

/* Diagonal accent beam */
.login-page::after {
  content: '';
  position: absolute;
  top: -20%;
  right: -10%;
  width: 1px;
  height: 140%;
  background: linear-gradient(to bottom, transparent, var(--accent-primary) 40%, var(--accent-primary) 60%, transparent);
  opacity: 0.15;
  transform: rotate(-15deg);
}

.login-card {
  position: relative;
  z-index: 1;
  width: 380px;
  padding: var(--space-10) var(--space-8);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-top: 2px solid var(--accent-primary);
  clip-path: polygon(0 0, calc(100% - 24px) 0, 100% 24px, 100% 100%, 0 100%);
}

.login-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-primary);
  background: var(--accent-glow);
  border: 1px solid rgba(233, 69, 96, 0.3);
  padding: 3px 10px;
  margin-bottom: var(--space-6);
}

.login-badge::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--accent-primary);
  animation: pulse-dot 2s ease-in-out infinite;
}

.login-title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  line-height: 1.2;
  margin-bottom: var(--space-2);
}

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

.login-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: var(--space-8);
  font-family: var(--font-mono);
}

.login-divider {
  height: 1px;
  background: var(--border-dim);
  margin-bottom: var(--space-8);
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  width: 100%;
  padding: 12px var(--space-5);
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: border-color var(--dur-normal) var(--ease-out),
              background var(--dur-normal) var(--ease-out),
              box-shadow var(--dur-normal) var(--ease-out);
}

.btn-google:hover {
  border-color: var(--accent-primary);
  background: var(--bg-card);
  box-shadow: 0 0 16px var(--accent-glow);
}

.btn-google svg {
  flex-shrink: 0;
}

.login-footer {
  margin-top: var(--space-6);
  font-size: 11px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-align: center;
}

/* ═══════════════════════════════════════════════════════════════
   MAIN APP LAYOUT
═══════════════════════════════════════════════════════════════ */
.app-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── Header ────────────────────────────────────────────────── */
.app-header {
  flex-shrink: 0;
  height: var(--header-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-dim);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-5);
  z-index: 100;
}

.header-brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.brand-mark {
  width: 28px; height: 28px;
  position: relative;
  flex-shrink: 0;
}

.brand-mark svg {
  width: 100%; height: 100%;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.brand-name .app-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--accent-primary);
  font-weight: 500;
  margin-right: 6px;
}

.brand-name .app-title {
  color: var(--text-primary);
}

.header-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-done);
  animation: pulse-dot 3s ease-in-out infinite;
}

.header-user {
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.user-email {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-secondary);
}

.btn-logout {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
  font-size: 12px;
  letter-spacing: 0.02em;
  transition: border-color var(--dur-fast), color var(--dur-fast);
}

.btn-logout:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
}

/* ─── Body Layout ───────────────────────────────────────────── */
.app-body {
  flex: 1;
  display: flex;
  overflow: hidden;
}

/* ─── Left Sidebar ──────────────────────────────────────────── */
.sidebar {
  flex-shrink: 0;
  width: var(--sidebar-width);
  background: var(--bg-card);
  border-right: 1px solid var(--border-dim);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.sidebar-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-2) 0;
}

.project-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px var(--space-5);
  cursor: pointer;
  border-left: 2px solid transparent;
  transition: background var(--dur-fast), border-color var(--dur-fast);
  gap: var(--space-3);
}

.project-item:hover {
  background: var(--bg-elevated);
}

.project-item.active {
  background: rgba(233, 69, 96, 0.08);
  border-left-color: var(--accent-primary);
}

.project-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
}

.project-item.active .project-name {
  color: var(--text-primary);
}

.kw-badge {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 7px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-dim);
  border-radius: 2px;
  white-space: nowrap;
}

.project-item.active .kw-badge {
  border-color: rgba(233, 69, 96, 0.4);
  color: var(--accent-primary);
}

/* Sidebar loading / empty */
.sidebar-state {
  padding: var(--space-8) var(--space-5);
  text-align: center;
  color: var(--text-dim);
  font-size: 12px;
  font-family: var(--font-mono);
}

.sidebar-state .state-icon {
  font-size: 20px;
  margin-bottom: var(--space-3);
  display: block;
}

/* Sidebar footer: manual URL button */
.sidebar-footer {
  flex-shrink: 0;
  padding: var(--space-3) var(--space-4);
  border-top: 1px solid var(--border-dim);
}

.btn-add-url {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 8px;
  background: transparent;
  border: 1px dashed var(--border-dim);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: border-color var(--dur-fast), color var(--dur-fast), background var(--dur-fast);
}

.btn-add-url:hover {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-glow);
}

/* ─── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg-base);
}

/* ─── Tabs ──────────────────────────────────────────────────── */
.tabs-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 var(--space-5);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-dim);
}

.tab-btn {
  padding: 14px var(--space-5);
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.01em;
  transition: color var(--dur-fast), border-color var(--dur-fast);
  margin-bottom: -1px;
}

.tab-btn:hover {
  color: var(--text-primary);
}

.tab-btn.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

.tabs-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.context-label {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  padding: 3px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  max-width: 280px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ─── Tab Panels ────────────────────────────────────────────── */
.tab-panel {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: var(--space-5);
}

.tab-panel.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ─── Section header within panels ─────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-3);
}

.panel-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* ═══════════════════════════════════════════════════════════════
   JOB TABLE (Tab 1: Task Status)
═══════════════════════════════════════════════════════════════ */
.job-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  overflow: hidden;
}

.job-table {
  width: 100%;
  border-collapse: collapse;
}

.job-table thead {
  background: var(--bg-elevated);
}

.job-table th {
  padding: 9px var(--space-4);
  text-align: left;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-dim);
  white-space: nowrap;
}

.job-table th:last-child { text-align: right; }

.job-table td {
  padding: 10px var(--space-4);
  border-bottom: 1px solid rgba(42, 58, 92, 0.5);
  vertical-align: middle;
  font-size: 13px;
}

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

.job-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.url-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-code);
  max-width: 320px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-cell {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-secondary);
  text-align: center;
  width: 48px;
}

.rank-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  font-size: 11px;
  color: var(--text-secondary);
}

.action-cell {
  text-align: right;
  white-space: nowrap;
}

/* ─── Status Badges ─────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border-radius: 2px;
  white-space: nowrap;
}

.badge-pending {
  background: rgba(107, 114, 128, 0.12);
  border: 1px solid rgba(107, 114, 128, 0.3);
  color: var(--signal-pending);
}

.badge-running {
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.4);
  color: var(--signal-running);
}

.badge-completed {
  background: rgba(34, 197, 94, 0.10);
  border: 1px solid rgba(34, 197, 94, 0.35);
  color: var(--signal-done);
}

.badge-failed {
  background: rgba(239, 68, 68, 0.10);
  border: 1px solid rgba(239, 68, 68, 0.35);
  color: var(--signal-fail);
}

/* Pulse indicator before badge text */
.badge-running::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-running);
  animation: signal-pulse 1.4s ease-in-out infinite;
}

.badge-completed::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-done);
}

.badge-failed::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-fail);
  animation: signal-flicker 2s ease-in-out 1;
}

.badge-pending::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--signal-pending);
  opacity: 0.5;
}

/* ─── Spinning indicator ────────────────────────────────────── */
.spinning {
  display: inline-block;
  width: 12px; height: 12px;
  border: 1.5px solid rgba(59, 130, 246, 0.3);
  border-top-color: var(--signal-running);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── Action buttons ────────────────────────────────────────── */
.btn-trigger {
  padding: 5px 12px;
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all var(--dur-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-trigger:hover:not(:disabled) {
  border-color: var(--accent-primary);
  color: var(--accent-primary);
  background: var(--accent-glow);
}

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

.btn-trigger.running {
  border-color: rgba(59, 130, 246, 0.4);
  color: var(--signal-running);
  pointer-events: none;
}

.btn-view {
  padding: 5px 10px;
  background: transparent;
  border: 1px solid rgba(34, 197, 94, 0.3);
  color: var(--signal-done);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: all var(--dur-fast);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-view:hover {
  background: rgba(34, 197, 94, 0.08);
}

.btn-sm {
  padding: 4px 10px;
  font-size: 11px;
  background: transparent;
  border: 1px solid var(--border-dim);
  color: var(--text-secondary);
  letter-spacing: 0.03em;
  transition: all var(--dur-fast);
}

.btn-sm:hover {
  border-color: var(--border-focus);
  color: var(--text-primary);
}

.btn-primary {
  padding: 8px 18px;
  background: var(--accent-primary);
  border: 1px solid var(--accent-primary);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.03em;
  transition: all var(--dur-normal) var(--ease-out);
}

.btn-primary:hover:not(:disabled) {
  background: #c73650;
  border-color: #c73650;
  box-shadow: 0 0 16px var(--accent-glow);
}

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

/* ═══════════════════════════════════════════════════════════════
   RESULTS PANEL (Tab 2: Analysis Results)
═══════════════════════════════════════════════════════════════ */
.results-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-bottom: none;
}

.results-toolbar label {
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.select-job {
  flex: 1;
  max-width: 400px;
  padding: 6px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238892aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 28px;
  transition: border-color var(--dur-fast);
}

.select-job:focus {
  outline: none;
  border-color: var(--border-focus);
}

.blocks-container {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  overflow: hidden;
}

.block-item {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid rgba(42, 58, 92, 0.5);
  display: flex;
  gap: var(--space-4);
  align-items: flex-start;
  transition: background var(--dur-fast);
}

.block-item:last-child { border-bottom: none; }
.block-item:hover { background: rgba(255,255,255,0.015); }

.block-index {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  width: 24px;
  text-align: right;
  padding-top: 1px;
}

.block-body {
  flex: 1;
  min-width: 0;
}

.block-heading {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: var(--space-1);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.block-preview {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.6;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.block-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-2);
  flex-wrap: wrap;
}

.badge-block-type {
  padding: 2px 7px;
  background: rgba(15, 52, 96, 0.6);
  border: 1px solid rgba(74, 111, 165, 0.4);
  color: #7dd3fc;
  font-family: var(--font-mono);
  font-size: 10px;
  border-radius: 2px;
}

.img-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
}

/* ═══════════════════════════════════════════════════════════════
   MANUAL TRIGGER PANEL (Collapsible bottom bar)
═══════════════════════════════════════════════════════════════ */
.trigger-panel {
  flex-shrink: 0;
  background: var(--bg-card);
  border-top: 1px solid var(--border-dim);
}

.trigger-toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px var(--space-5);
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  transition: color var(--dur-fast), background var(--dur-fast);
}

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

.trigger-toggle .chevron {
  font-size: 10px;
  transition: transform var(--dur-normal) var(--ease-out);
}

.trigger-toggle.open .chevron { transform: rotate(180deg); }

.trigger-body {
  display: none;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border-dim);
  gap: var(--space-3);
  align-items: flex-end;
}

.trigger-body.open {
  display: flex;
}

.trigger-field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.trigger-field label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.trigger-field.url-field {
  flex: 1;
}

.input-url {
  padding: 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  width: 100%;
  transition: border-color var(--dur-fast), box-shadow var(--dur-fast);
}

.input-url:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 2px rgba(74, 111, 165, 0.15);
}

.select-page-type {
  padding: 7px 32px 7px 10px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 12px;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238892aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 200px;
  transition: border-color var(--dur-fast);
}

.select-page-type:focus {
  outline: none;
  border-color: var(--border-focus);
}

/* ═══════════════════════════════════════════════════════════════
   EMPTY & ERROR STATES
═══════════════════════════════════════════════════════════════ */
.state-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-10);
  text-align: center;
  min-height: 200px;
}

.state-icon-lg {
  font-size: 32px;
  opacity: 0.4;
}

.state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
}

.state-subtitle {
  font-size: 12px;
  color: var(--text-dim);
  font-family: var(--font-mono);
  max-width: 320px;
  line-height: 1.6;
}

.state-error {
  padding: var(--space-4) var(--space-5);
  background: rgba(239, 68, 68, 0.08);
  border: 1px solid rgba(239, 68, 68, 0.25);
  color: #fca5a5;
  font-family: var(--font-mono);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.state-error::before { content: '⚠'; font-size: 14px; }

/* ═══════════════════════════════════════════════════════════════
   MODAL — Manual URL input
═══════════════════════════════════════════════════════════════ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(13, 13, 26, 0.85);
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur-normal);
  backdrop-filter: blur(4px);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border-dim);
  border-top: 2px solid var(--accent-primary);
  width: 480px;
  padding: var(--space-6);
  transform: translateY(8px);
  transition: transform var(--dur-normal) var(--ease-out);
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

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

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

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 18px;
  line-height: 1;
  padding: 2px 6px;
  transition: color var(--dur-fast);
}

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

.modal-field {
  margin-bottom: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.modal-field label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.modal-field input,
.modal-field select {
  padding: 8px 12px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  transition: border-color var(--dur-fast);
}

.modal-field input:focus,
.modal-field select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.modal-field select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238892aa'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-color: var(--bg-input);
  padding-right: 28px;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
  margin-top: var(--space-5);
}

/* ═══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
═══════════════════════════════════════════════════════════════ */
.toast-stack {
  position: fixed;
  bottom: var(--space-5);
  right: var(--space-5);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  pointer-events: none;
}

.toast {
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-dim);
  border-left: 3px solid var(--border-focus);
  font-size: 12px;
  color: var(--text-primary);
  max-width: 320px;
  font-family: var(--font-mono);
  animation: toast-in var(--dur-normal) var(--ease-out) forwards;
  pointer-events: all;
}

.toast.success { border-left-color: var(--signal-done); }
.toast.error   { border-left-color: var(--signal-fail); }
.toast.info    { border-left-color: var(--signal-running); }
.toast.fade-out { animation: toast-out var(--dur-normal) var(--ease-out) forwards; }

/* ═══════════════════════════════════════════════════════════════
   KEYFRAME ANIMATIONS
═══════════════════════════════════════════════════════════════ */
@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%       { opacity: 0.5; transform: scale(0.7); }
}

@keyframes signal-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); }
  50%       { opacity: 0.7; box-shadow: 0 0 0 4px rgba(59, 130, 246, 0); }
}

@keyframes signal-flicker {
  0%, 100% { opacity: 1; }
  20%       { opacity: 0.2; }
  40%       { opacity: 0.9; }
  60%       { opacity: 0.3; }
  80%       { opacity: 0.8; }
}

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

@keyframes toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(16px); }
}

@keyframes row-highlight {
  0%   { background: rgba(233, 69, 96, 0.12); }
  100% { background: transparent; }
}

.row-new td { animation: row-highlight 1.5s ease-out forwards; }

/* ═══════════════════════════════════════════════════════════════
   SKELETON LOADING
═══════════════════════════════════════════════════════════════ */
@keyframes skeleton-shimmer {
  0%   { background-position: -400px 0; }
  100% { background-position: 400px 0; }
}

.skeleton {
  background: linear-gradient(
    90deg,
    var(--bg-elevated) 25%,
    rgba(74, 111, 165, 0.12) 50%,
    var(--bg-elevated) 75%
  );
  background-size: 800px 100%;
  animation: skeleton-shimmer 1.5s infinite;
  border-radius: 2px;
  display: inline-block;
}

.skeleton-row td { padding: 12px 16px; }

/* ═══════════════════════════════════════════════════════════════
   POLL INDICATOR
═══════════════════════════════════════════════════════════════ */
.poll-indicator {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-dim);
  padding: 3px 8px;
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
}

.poll-indicator .poll-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--signal-running);
  animation: signal-pulse 1.4s ease-in-out infinite;
}

.poll-indicator.idle .poll-dot {
  background: var(--text-dim);
  animation: none;
}

/* ═══════════════════════════════════════════════════════════════
   RESPONSIVE — min 1024px, scale down gracefully
═══════════════════════════════════════════════════════════════ */
@media (max-width: 1280px) {
  :root { --sidebar-width: 240px; }
  .url-cell { max-width: 220px; }
}

@media (max-width: 1024px) {
  :root { --sidebar-width: 200px; }

  .brand-name .app-title { display: none; }

  .trigger-body.open {
    flex-wrap: wrap;
  }

  .trigger-field.url-field { width: 100%; }
}

/* Print: hide interactive chrome */
@media print {
  .app-header, .sidebar, .trigger-panel { display: none; }
  .main-content { width: 100%; }
}


/* ═══════════════════════════════════════════════════════════════
   KEYWORDS TAB — panel-keywords, kw-table, batch buttons
═══════════════════════════════════════════════════════════════ */
.kw-filters {
  display: flex;
  gap: 8px;
  align-items: center;
}

.select-sm {
  background: var(--bg-input);
  border: 1px solid var(--border-dim);
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 8px;
  height: 26px;
  cursor: pointer;
}

.select-sm:focus {
  outline: none;
  border-color: var(--accent-blue);
}

.kw-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 16px;
  background: rgba(42, 58, 92, 0.3);
  border-bottom: 1px solid var(--border-dim);
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}

.btn-batch-all {
  background: var(--accent-blue);
  color: #fff;
  border: none;
  padding: 4px 12px;
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font-mono);
}

.btn-batch-all:hover {
  background: #2a65c0;
}

.kw-table .kw-cell {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-mono);
  font-size: 12px;
}

.kw-table .group-cell {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-dim);
  font-size: 11px;
}

.url-count-num {
  display: inline-block;
  padding: 1px 6px;
  background: rgba(42, 58, 92, 0.5);
  border: 1px solid var(--border-dim);
  border-radius: 2px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--signal-running);
}

.kw-tag {
  display: inline-block;
  padding: 1px 5px;
  background: rgba(14, 52, 96, 0.6);
  border: 1px solid var(--accent-blue);
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-right: 3px;
}

.btn-kw-batch {
  background: transparent;
  border: 1px solid var(--accent-blue);
  color: var(--accent-blue);
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 10px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.btn-kw-batch:hover {
  background: var(--accent-blue);
  color: #fff;
}

/* ─── URL panel ─────────────────────────────────────────────── */
.url-panel {
  border-top: 2px solid var(--accent-blue);
  background: rgba(10, 25, 47, 0.8);
  margin-top: 0;
}
.url-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: rgba(42, 58, 92, 0.4);
  border-bottom: 1px solid var(--border-dim);
}
.url-panel-title { display: flex; align-items: center; gap: 12px; }
.url-panel-kw {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-primary);
  font-weight: 600;
}
.url-panel-count {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
}
.url-panel-actions { display: flex; gap: 8px; align-items: center; }
.url-list-wrap { max-height: 320px; overflow-y: auto; }
.url-list-table .url-domain {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--signal-running);
}
.url-top20 { background: rgba(14, 52, 96, 0.2); }
.rank-top20 {
  background: var(--accent-blue);
  color: #fff;
  padding: 1px 5px;
  border-radius: 2px;
}
.url-title-cell {
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  color: var(--text-secondary);
}
tr.row-selected { background: rgba(42, 58, 92, 0.35) !important; }

.muted { color: var(--text-dim); }

/* ─── URL Autocomplete dropdown ─────────────────────────────── */
.url-suggest-list {
  position: absolute;
  bottom: calc(100% + 4px);   /* dropup — opens above the input */
  top: auto;
  left: 0;
  right: 0;
  z-index: 200;
  background: var(--bg-elevated);
  border: 1px solid var(--border-focus);
  border-radius: 6px;
  list-style: none;
  padding: 4px 0;
  max-height: 300px;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,.5);
}
.suggest-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  transition: background var(--dur-fast);
}
.suggest-item:hover,
.suggest-item.suggest-active { background: var(--bg-card); }
.suggest-rank {
  flex-shrink: 0;
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--accent-primary);
  width: 26px;
}
.suggest-domain {
  flex-shrink: 0;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 12px;
}
.suggest-path {
  flex: 1;
  color: var(--text-dim);
  font-size: 11px;
  font-family: var(--font-mono);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.suggest-kw {
  flex-shrink: 0;
  font-size: 10px;
  color: var(--text-secondary);
  background: var(--bg-void);
  border: 1px solid var(--border-dim);
  padding: 1px 6px;
  border-radius: 8px;
  font-family: var(--font-mono);
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ─── Keyword → URL Picker ──────────────────────────────────── */
.kw-url-picker {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  right: 0;
  z-index: 210;
  background: var(--bg-elevated);
  border: 1px solid #4a6fa5;
  border-radius: 6px;
  list-style: none;
  padding: 4px 0;
  max-height: 320px;
  overflow-y: auto;
  box-shadow: 0 -8px 24px rgba(0,0,0,.55);
}
.kw-picker-header {
  font-size: 10px;
  color: var(--text-dim);
  padding: 4px 10px 6px;
  border-bottom: 1px solid var(--border-dim);
  pointer-events: none;
  font-family: var(--font-mono);
}
.picker-top20 .suggest-rank { color: var(--accent-primary) !important; }
.suggest-title {
  font-size: 10px;
  color: var(--text-dim);
  margin-left: auto;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ─── Job view button (link styled as button) ────────────────── */
a.btn-view {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 4px;
  background: rgba(34,197,94,.1);
  border: 1px solid rgba(34,197,94,.3);
  color: var(--signal-done);
  text-decoration: none;
  transition: background var(--dur-fast);
}
a.btn-view:hover { background: rgba(34,197,94,.2); }
