:root {
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;

  /* Color Palette (Clean, Light Theme) */
  --bg-app: #f4f6f9;
  --bg-card: #ffffff;
  --bg-input: #f8fafc;
  --border: #e2e8f0;
  --border-focus: #a5b4fc;
  
  --primary: #4f46e5;
  --primary-light: #6366f1;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #3b82f6 100%);
  
  --text-main: #0f172a;
  --text-sub: #475569;
  --text-muted: #94a3b8;

  --success: #10b981;
  --success-bg: #ecfdf5;
  --success-border: #a7f3d0;
  
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --warning-border: #fde68a;
  
  --danger: #ef4444;
  
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.05);
  --shadow-md: 0 4px 20px rgba(15, 23, 42, 0.05);
  --shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);
}

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

body {
  background-color: var(--bg-app);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  padding: 40px 20px;
  overflow-y: auto;
  line-height: 1.5;
  background-image: radial-gradient(circle at 90% 10%, rgba(99, 102, 241, 0.03) 0%, transparent 60%),
                    radial-gradient(circle at 10% 90%, rgba(59, 130, 246, 0.02) 0%, transparent 50%);
}

.portal-container {
  max-width: 850px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* Header */
.portal-header {
  text-align: center;
  margin-bottom: 8px;
}

.logo-wrapper {
  font-size: 36px;
  margin-bottom: 12px;
  display: inline-block;
  animation: bounce 2s infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.portal-header h1 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 34px;
  letter-spacing: -0.8px;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.subtitle {
  color: var(--text-sub);
  font-size: 15px;
  font-weight: 400;
  max-width: 580px;
  margin: 0 auto;
}

/* Cards */
.portal-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  box-shadow: var(--shadow-md);
  transition: box-shadow 0.3s ease;
}

.portal-card:hover {
  box-shadow: var(--shadow-lg);
}

.section-title {
  margin-bottom: 24px;
}

.section-title h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-title p {
  font-size: 14px;
  color: var(--text-sub);
}

/* Upload Area Split */
.upload-area {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  gap: 24px;
  margin-bottom: 24px;
}

@media (max-width: 768px) {
  .upload-area {
    grid-template-columns: 1fr;
  }
}

.dropzone {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.dropzone:hover, .dropzone.active {
  border-color: var(--primary-light);
  background: #f5f3ff;
}

.dropzone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.upload-icon {
  font-size: 32px;
}

.upload-text {
  font-size: 13px;
  color: var(--text-sub);
}

.browse-btn {
  font-size: 12px;
  color: var(--primary);
  font-weight: 600;
  text-decoration: underline;
}

.textarea-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.textarea-wrapper label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.textarea-wrapper textarea {
  background-color: var(--bg-input);
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 12px;
  border-radius: 10px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
  width: 100%;
  height: 130px;
  resize: none;
  transition: border-color 0.2s ease;
}

.textarea-wrapper textarea:focus {
  border-color: var(--primary-light);
  background: #ffffff;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

/* Action Bar */
.action-bar {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
  padding-top: 20px;
}

/* Progress bar styling */
.progress-bar-wrapper {
  margin-bottom: 20px;
  display: none;
}

.progress-bar-wrapper span {
  font-size: 12px;
  color: var(--text-sub);
  font-weight: 500;
  display: block;
  margin-bottom: 6px;
}

.progress-bar-track {
  background: #e2e8f0;
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  background: var(--primary-gradient);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

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

.btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.2);
}

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

.btn-secondary {
  background: #ffffff;
  color: var(--text-sub);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

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

.btn-sm {
  font-size: 12px;
  padding: 6px 12px;
  border-radius: 6px;
}

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

.icon-refresh {
  width: 14px;
  height: 14px;
}

/* Status Banner (Active Scraping) */
.status-banner {
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

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

.banner-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
}

.spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(79, 70, 229, 0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

.banner-text h3 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
}

.banner-text p {
  font-size: 12px;
  color: var(--text-sub);
}

.banner-stats {
  display: flex;
  gap: 10px;
}

.stat-pill {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  font-size: 11px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 20px;
  color: var(--text-sub);
  box-shadow: var(--shadow-sm);
}

.stat-pill span {
  color: var(--primary);
  font-weight: 700;
}

/* Matches Feed */
.matches-section .matches-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 18px;
  margin-bottom: 24px;
}

.matches-header h2 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 4px;
}

.matches-header p {
  font-size: 13px;
  color: var(--text-sub);
}

.matches-feed {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-sub);
}

.empty-icon {
  font-size: 40px;
  display: block;
  margin-bottom: 16px;
}

.empty-state h3 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.empty-state p {
  font-size: 13px;
  max-width: 340px;
  margin: 0 auto;
}

/* Match Card styling */
.match-card {
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  transition: all 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.match-card:hover {
  border-color: #cbd5e1;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.match-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex-grow: 1;
}

.match-title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.match-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  transition: color 0.15s ease;
}

.match-title:hover {
  color: var(--primary-light);
  text-decoration: underline;
}

.match-company {
  font-size: 14px;
  color: var(--text-main);
  font-weight: 600;
}

.badge {
  font-size: 9px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge-startup {
  background: #faf5ff;
  color: #a855f7;
  border: 1px solid #f3e8ff;
}

.badge-source {
  background: #f1f5f9;
  color: #64748b;
  border: 1px solid #e2e8f0;
}

.match-details {
  font-size: 12px;
  color: var(--text-sub);
  display: flex;
  gap: 14px;
}

/* acceptance possibility reasoning box */
.match-summary {
  font-size: 13px;
  color: #312e81; /* Indigo-900 */
  line-height: 1.5;
  background: #f5f3ff; /* Indigo-50 */
  padding: 12px 16px;
  border-radius: 8px;
  border-left: 4px solid var(--primary-light);
  margin: 6px 0;
}

.match-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.tag {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
}

.tag.match {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #d1fae5;
}

.tag.miss {
  background: #fef2f2;
  color: #dc2626;
  border: 1px solid #fee2e2;
}

.match-score-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-left: 20px;
  border-left: 1px solid var(--border);
  min-width: 90px;
  align-self: center;
}

.score {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 800;
}

.score.high { color: var(--success); }
.score.mid { color: var(--warning); }
.score.low { color: var(--primary-light); }

.score-lbl {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}

/* Collapsible Settings Panel (Advanced Details) */
.advanced-settings {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 20px;
  font-size: 13px;
  margin-top: 10px;
  transition: all 0.3s ease;
}

.advanced-settings[open] {
  background: #ffffff;
  box-shadow: var(--shadow-md);
}

.advanced-settings summary {
  font-weight: 600;
  color: var(--text-sub);
  cursor: pointer;
  outline: none;
  user-select: none;
}

.advanced-settings summary:hover {
  color: var(--text-main);
}

.settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

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

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-group label {
  font-size: 10px;
  font-weight: 700;
  color: var(--text-sub);
  text-transform: uppercase;
}

.form-group input {
  background: #ffffff;
  border: 1px solid var(--border);
  color: var(--text-main);
  padding: 8px 12px;
  border-radius: 6px;
  font-family: var(--font-body);
  font-size: 13px;
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.settings-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.status-dot-badge {
  font-size: 11px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-sub);
}

.status-dot-badge::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.status-dot-badge.online::before { background: var(--success); }
.status-dot-badge.offline::before { background: #94a3b8; }
.status-dot-badge.checking::before { background: var(--warning); }

.mini-logs-panel {
  margin-top: 16px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.mini-logs-panel h4 {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-sub);
  margin-bottom: 6px;
}

.mini-log-output {
  background: #0f172a;
  color: #10b981;
  font-family: monospace;
  font-size: 11px;
  padding: 10px;
  border-radius: 6px;
  height: 100px;
  overflow-y: auto;
  line-height: 1.4;
}

/* Footers */
.portal-footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 12px;
}

/* Toast popup */
.toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background-color: var(--text-main);
  color: var(--bg-card);
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  z-index: 2000;
}

.toast-popup.show {
  transform: translateY(0);
  opacity: 1;
}

/* Pagination controls */
.pagination-controls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}

.page-btn {
  min-width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
}

.page-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  background-color: var(--border);
  color: var(--text-muted);
  border-color: var(--border);
}

.pagination-ellipsis {
  color: var(--text-muted);
  font-weight: 600;
  padding: 0 4px;
}

/* Responsive adjustments for Mobile */
@media (max-width: 600px) {
  body {
    padding: 16px 10px;
  }
  .portal-container {
    gap: 16px;
  }
  .portal-header h1 {
    font-size: 26px;
  }
  .portal-card {
    padding: 16px;
  }
  .match-card {
    flex-direction: column;
    align-items: stretch;
    gap: 16px;
    padding: 16px;
  }
  .match-score-badge {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 16px;
    width: 100%;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    min-width: 0;
    align-self: stretch;
  }
  .match-score-badge .score {
    font-size: 24px;
  }
}
