/* ==========================================================================
   ZILLOW INTELLIGENCE ENGINE - CLEAN PREMIUM LIGHT THEME DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-main: #f8fafc;
  --bg-surface: #ffffff;
  --bg-surface-elevated: #f1f5f9;
  --bg-surface-hover: #e2e8f0;

  --border-subtle: #e2e8f0;
  --border-focus: #6366f1;
  --border-glass: 1px solid #e2e8f0;

  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;

  --accent-indigo: #4f46e5;
  --accent-indigo-light: #6366f1;
  --accent-indigo-glow: rgba(79, 70, 229, 0.18);
  --accent-violet: #7c3aed;
  --accent-cyan: #0284c7;
  --accent-emerald: #059669;
  --accent-amber: #d97706;
  --accent-rose: #e11d48;

  --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-pill: 9999px;
  --shadow-card: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
  --shadow-hover: 0 10px 25px -3px rgba(15, 23, 42, 0.08), 0 4px 10px -2px rgba(15, 23, 42, 0.04);
}

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

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

/* Background Soft Ambient Lighting */
.ambient-glow {
  position: fixed;
  width: 600px;
  height: 600px;
  border-radius: 50%;
  filter: blur(140px);
  pointer-events: none;
  z-index: 0;
  opacity: 0.45;
}

.glow-1 {
  top: -200px;
  left: -150px;
  background: radial-gradient(circle, #e0e7ff 0%, transparent 70%);
}

.glow-2 {
  bottom: -200px;
  right: -150px;
  background: radial-gradient(circle, #e0f2fe 0%, transparent 70%);
}

.app-container {
  position: relative;
  z-index: 1;
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 32px 60px;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-surface);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo-mark {
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, var(--accent-indigo), var(--accent-violet));
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.app-title {
  font-size: 19px;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 2px;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  border: 1px solid transparent;
  transition: all 0.25s ease;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-idle {
  background: #f1f5f9;
  color: #64748b;
  border-color: #cbd5e1;
}
.status-idle .status-dot {
  background: #94a3b8;
}

.status-running {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
  animation: pulse-glow 2s infinite;
}
.status-running .status-dot {
  background: #10b981;
  box-shadow: 0 0 8px #10b981;
}

.status-stopping {
  background: #fffbe8;
  color: #b45309;
  border-color: #fde68a;
}
.status-stopping .status-dot {
  background: #f59e0b;
}

.status-completed {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}
.status-completed .status-dot {
  background: #4f46e5;
}

.service-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f8fafc;
  border: var(--border-glass);
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.pill-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
}

.pill-dot.success {
  background: var(--accent-emerald);
  box-shadow: 0 0 6px rgba(5, 150, 105, 0.4);
}

.pill-dot.warning {
  background: var(--accent-amber);
}

/* ==========================================================================
   METRICS GRID
   ========================================================================== */

.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 18px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-surface);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px 22px;
  box-shadow: var(--shadow-card);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

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

.metric-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

.metric-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-purple {
  background: #eef2ff;
  color: var(--accent-indigo);
}
.icon-green {
  background: #ecfdf5;
  color: var(--accent-emerald);
}
.icon-cyan {
  background: #f0f9ff;
  color: var(--accent-cyan);
}
.icon-amber {
  background: #fffbe8;
  color: var(--accent-amber);
}

.metric-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -1px;
  font-family: var(--font-sans);
  color: var(--text-primary);
  margin-bottom: 6px;
}

.metric-footer {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
}

.text-emerald { color: var(--accent-emerald) !important; }
.text-cyan { color: var(--accent-cyan) !important; }
.text-amber { color: var(--accent-amber) !important; }

/* ==========================================================================
   WORKSPACE GRID (FIXED LAYOUT & OVERFLOW)
   ========================================================================== */

.workspace-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 24px;
}

.card {
  background: var(--bg-surface);
  border: var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow-card);
  display: flex;
  flex-direction: column;
}

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

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.2px;
  color: var(--text-primary);
}

.card-title svg {
  color: var(--accent-indigo);
}

.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 3px 10px;
  background: #eef2ff;
  color: var(--accent-indigo);
  border-radius: var(--radius-pill);
  border: 1px solid #c7d2fe;
}

/* Drop Zone */
.drop-zone {
  border: 2px dashed #cbd5e1;
  border-radius: var(--radius-md);
  padding: 28px 16px;
  text-align: center;
  background: #f8fafc;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  margin-bottom: 20px;
}

.drop-zone:hover, .drop-zone.drag-over {
  border-color: var(--accent-indigo);
  background: #f5f3ff;
}

.file-input-hidden {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.drop-icon {
  color: var(--accent-indigo);
  margin-bottom: 12px;
}

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

.drop-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

.drop-browse {
  color: var(--accent-indigo);
  text-decoration: underline;
  cursor: pointer;
  font-weight: 600;
}

.file-details {
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.file-name {
  font-weight: 600;
  color: var(--text-primary);
}

.file-rows {
  color: var(--accent-emerald);
  font-weight: 600;
}

/* Controls - FIX: STACKED CLEAN LAYOUT SO DROPDOWN NEVER OVERFLOWS */
.control-deck {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-row {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  min-width: 0;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-select {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-sans);
  outline: none;
  cursor: pointer;
  transition: all 0.2s ease;
  width: 100%;
  box-sizing: border-box;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.form-select:hover {
  border-color: #94a3b8;
}

.form-select:focus {
  border-color: var(--accent-indigo);
  box-shadow: 0 0 0 3px var(--accent-indigo-glow);
}

.checkbox-row {
  margin-top: 4px;
}

.custom-checkbox {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-secondary);
}

.custom-checkbox input {
  display: none;
}

.checkbox-checkmark {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.custom-checkbox input:checked + .checkbox-checkmark {
  background: var(--accent-indigo);
  border-color: var(--accent-indigo);
}

.custom-checkbox input:checked + .checkbox-checkmark::after {
  content: '✓';
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

.action-buttons {
  display: flex;
  gap: 10px;
  margin-top: 8px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-sans);
  cursor: pointer;
  border: none;
  transition: all 0.2s ease;
  outline: none;
}

.btn-block {
  flex: 1;
}

.btn-sm {
  padding: 8px 14px;
  font-size: 12px;
  border-radius: var(--radius-sm);
}

.btn-xs {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: var(--radius-pill);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-indigo) 0%, var(--accent-indigo-light) 100%);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.25);
}

.btn-primary:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(79, 70, 229, 0.35);
}

.btn-danger {
  background: #fff1f2;
  color: var(--accent-rose);
  border: 1px solid #fecdd3;
}

.btn-danger:hover:not(:disabled) {
  background: #ffe4e6;
  border-color: #fda4af;
}

.btn-secondary {
  background: #ffffff;
  color: var(--text-primary);
  border: 1px solid #cbd5e1;
}

.btn-secondary:hover:not(:disabled) {
  background: #f8fafc;
  border-color: #94a3b8;
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid #e2e8f0;
}

.btn-ghost:hover {
  background: #f8fafc;
  color: var(--text-primary);
  border-color: #cbd5e1;
}

.btn-sf {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
  font-weight: 600;
}

.btn-sf:hover:not(:disabled) {
  opacity: 0.95;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.sf-sync-section {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sf-divider {
  display: flex;
  align-items: center;
  text-align: center;
  margin: 6px 0 2px 0;
}

.sf-divider::before,
.sf-divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px dashed #cbd5e1;
}

.sf-divider span {
  padding: 0 10px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #94a3b8;
}

.sf-caption {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  line-height: 1.35;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
}

/* ==========================================================================
   LIVE CARD & PROGRESS
   ========================================================================== */

.progress-percent {
  font-size: 18px;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--accent-indigo);
}

.progress-track {
  width: 100%;
  height: 10px;
  background: #e2e8f0;
  border-radius: var(--radius-pill);
  overflow: hidden;
  margin-bottom: 14px;
  position: relative;
}

.progress-bar-glow {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-indigo) 0%, var(--accent-cyan) 100%);
  border-radius: var(--radius-pill);
  transition: width 0.35s ease;
  position: relative;
}

.current-task-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 20px;
}

.task-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid #cbd5e1;
  border-top-color: var(--accent-indigo);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}

.task-spinner.active {
  display: inline-block;
}

.task-text-container {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.task-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  color: var(--text-muted);
}

.task-address {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Tabs */
.tab-header {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 1px solid #e2e8f0;
  margin-bottom: 14px;
  padding-bottom: 8px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tab-btn.active {
  background: #f1f5f9;
  color: var(--text-primary);
}

.tab-actions {
  margin-left: auto;
}

.tab-content {
  display: none;
  flex: 1;
}

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

/* Data Table */
.table-wrapper {
  overflow-x: auto;
  max-height: 400px;
  border-radius: var(--radius-sm);
  border: 1px solid #e2e8f0;
  background: #ffffff;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  text-align: left;
}

.data-table th {
  background: #f8fafc;
  color: var(--text-secondary);
  font-weight: 600;
  padding: 10px 14px;
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid #e2e8f0;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: var(--text-primary);
  white-space: nowrap;
}

.data-table tbody tr {
  transition: background 0.15s ease;
}

.data-table tbody tr:hover {
  background: #f8fafc;
}

.row-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  font-size: 11px;
  font-weight: 600;
}

.badge-success {
  background: #ecfdf5;
  color: #047857;
  border: 1px solid #a7f3d0;
}

.badge-warning {
  background: #fffbe8;
  color: #b45309;
  border: 1px solid #fde68a;
}

.val-market {
  font-weight: 700;
  color: #059669;
  font-family: var(--font-mono);
}

.val-lot {
  font-weight: 600;
  color: #0284c7;
}

.empty-row td {
  text-align: center;
  padding: 40px 16px;
  color: var(--text-muted);
}

/* Terminal Log - High contrast developer console */
.terminal-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: var(--radius-sm);
  padding: 14px;
  height: 380px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
}

.log-line {
  color: #cbd5e1;
  word-break: break-all;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 28px;
  right: 28px;
  background: #0f172a;
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 20px;
  font-size: 13px;
  font-weight: 500;
  display: none;
  z-index: 1000;
  animation: slide-up 0.3s ease;
}

.toast.show {
  display: block;
}

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

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(5, 150, 105, 0.2); }
  50% { box-shadow: 0 0 14px rgba(5, 150, 105, 0.4); }
}

@keyframes slide-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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