/* =========================
   IMPORTS
========================= */
@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;500;600;700;800&family=DM+Sans:ital,opsz,wght@0,9..40,300;0,9..40,400;0,9..40,500;0,9..40,600;1,9..40,300&display=swap');

/* =========================
   CSS VARIABLES
========================= */
:root {
  --bg: #F7F6F3;
  --surface: #FFFFFF;
  --surface-2: #F2F1EE;
  --border: #E8E6E1;
  --border-strong: #D4D1CB;
  --text-primary: #1C1B18;
  --text-secondary: #6B6860;
  --text-muted: #A09D97;
  --accent: #2A5BF5;
  --accent-hover: #1E4AE0;
  --accent-light: #EEF2FF;
  --danger: #E5333D;
  --danger-hover: #C92830;
  --danger-light: #FEF2F2;
  --success: #16A35A;
  --success-light: #ECFDF5;
  --warning: #D97706;
  --warning-light: #FFFBEB;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.07), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.09), 0 4px 12px rgba(0,0,0,0.05);
  --radius: 14px;
  --radius-sm: 8px;
  --radius-lg: 20px;
}

/* =========================
   GLOBAL RESET
========================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  padding: 48px 24px 80px;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* =========================
   CONTAINER
========================= */
.container {
  max-width: 860px;
  margin: 0 auto;
}

/* =========================
   TYPOGRAPHY
========================= */
h1 {
  font-family: 'Syne', sans-serif;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

h2 {
  font-family: 'Syne', sans-serif;
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.1px;
  color: var(--text-primary);
  line-height: 1.4;
}

h3 {
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  line-height: 1.4;
}

p {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.subtitle {
  font-size: 15px;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 300;
}

/* =========================
   PAGE HEADER
========================= */
.page-header {
  margin-bottom: 36px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header-left {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.page-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: 'DM Sans', sans-serif;
  font-size: 12px;
  font-weight: 500;
  color: var(--accent);
  background: var(--accent-light);
  padding: 4px 10px;
  border-radius: 100px;
  margin-bottom: 8px;
  width: fit-content;
}

.page-badge::before {
  content: '';
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
}

/* =========================
   CARD
========================= */
.card {
  background: var(--surface);
  padding: 28px 30px;
  margin: 18px 0;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-strong);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-icon {
  width: 32px;
  height: 32px;
  background: var(--accent-light);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
}

/* =========================
   BUTTONS
========================= */
button,
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  border: none;
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.18s ease;
  white-space: nowrap;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 1px 3px rgba(42, 91, 245, 0.25);
}

button:hover,
.btn:hover {
  background: var(--accent-hover);
  transform: translateY(-1px);
  box-shadow: 0 3px 10px rgba(42, 91, 245, 0.3);
}

button:active,
.btn:active {
  transform: translateY(0);
}

/* Danger (Stop) */
button.stop {
  background: var(--danger);
  box-shadow: 0 1px 3px rgba(229, 51, 61, 0.25);
}

button.stop:hover {
  background: var(--danger-hover);
  box-shadow: 0 3px 10px rgba(229, 51, 61, 0.3);
}

/* Secondary */
.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
  box-shadow: none;
}

.btn-secondary:hover {
  background: var(--surface-2);
  color: var(--text-primary);
  border-color: var(--border-strong);
  box-shadow: none;
  transform: none;
}

/* Ghost / small */
.btn-ghost {
  background: transparent;
  color: var(--accent);
  padding: 6px 12px;
  font-size: 13px;
  box-shadow: none;
}

.btn-ghost:hover {
  background: var(--accent-light);
  box-shadow: none;
  transform: none;
}

/* =========================
   FORM ELEMENTS
========================= */
input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

input[type="text"]:focus,
input[type="password"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(42, 91, 245, 0.1);
  background: var(--surface);
}

input[type="file"] {
  display: block;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  font-family: 'DM Sans', sans-serif;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface-2);
  width: 100%;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

input[type="file"]:hover {
  border-color: var(--accent);
  background: var(--accent-light);
}

label {
  font-size: 14px;
  color: var(--text-secondary);
  font-weight: 400;
  cursor: pointer;
}

input[type="radio"] {
  accent-color: var(--accent);
  cursor: pointer;
}

/* Radio group */
.radio-group {
  display: flex;
  gap: 20px;
  margin-top: 14px;
  padding: 12px 16px;
  background: var(--surface-2);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.radio-group label {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 14px;
  color: var(--text-secondary);
  cursor: pointer;
}

/* =========================
   STATUS INDICATORS
========================= */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 10px;
  border-radius: 100px;
}

.status-pill::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  flex-shrink: 0;
}

.status-idle,
[id$="Status"]:not([id*="step"]):not([id*="complete"]) {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 10px;
}

p[id$="Status"] {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 12px;
  min-height: 20px;
  font-weight: 400;
}

/* =========================
   LINKS
========================= */
a:not(.btn) {
  color: var(--accent);
  font-size: 14px;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.15s ease;
}

a:not(.btn):hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 32px;
  transition: color 0.15s ease, gap 0.15s ease;
}

.back-link:hover {
  color: var(--text-primary);
  gap: 8px;
  text-decoration: none;
}

/* =========================
   SPACING UTILITIES
========================= */
.mt-10 { margin-top: 10px; }
.mt-14 { margin-top: 14px; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-10 { margin-bottom: 10px; }
.mb-20 { margin-bottom: 20px; }

.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }

/* =========================
   DASHBOARD STATS GRID
========================= */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.stat-box {
  background: var(--surface-2);
  padding: 22px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: all 0.18s ease;
  position: relative;
  overflow: hidden;
}

.stat-box::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.stat-box:hover {
  border-color: var(--border-strong);
  background: var(--surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow-sm);
}

.stat-box:hover::after {
  opacity: 1;
}

.stat-box h3 {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-muted);
  margin-bottom: 10px;
  font-weight: 500;
}

.stat-number {
  font-family: 'Syne', sans-serif;
  font-size: 30px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1;
  letter-spacing: -0.5px;
}

.stat-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.stat-row p {
  font-size: 13px;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.stat-row span {
  font-family: 'Syne', sans-serif;
  font-weight: 600;
  color: var(--text-primary);
  font-size: 15px;
}

/* =========================
   LIVE SCRAPER ROWS
========================= */
.scraper-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.scraper-info {
  flex: 1;
}

.scraper-info h2 {
  font-size: 15px;
  margin-bottom: 2px;
}

.scraper-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

/* =========================
   LOGOUT BUTTON
========================= */
.logout-btn {
  position: fixed;
  right: 24px;
  top: 24px;
  z-index: 10;
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border-strong);
  font-size: 13px;
  padding: 7px 14px;
  box-shadow: none;
}

.logout-btn:hover {
  color: var(--danger);
  border-color: var(--danger);
  background: var(--danger-light);
  transform: none;
  box-shadow: none;
}

/* =========================
   LOGIN PAGE
========================= */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  font-family: 'Syne', sans-serif;
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.login-logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

.login-sub {
  font-size: 14px;
  color: var(--text-muted);
  margin-bottom: 32px;
}

.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 6px;
  text-transform: none;
  letter-spacing: 0;
}

.login-card button[type="submit"] {
  width: 100%;
  padding: 11px;
  margin-top: 8px;
  font-size: 15px;
}

/* =========================
   DIVIDER
========================= */
.divider {
  height: 1px;
  background: var(--border);
  margin: 24px 0;
}

/* =========================
   EXCEL FORM AREA
========================= */
.form-area {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 18px;
  margin-top: 16px;
}

.form-footer {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  flex-wrap: wrap;
}

/* =========================
   ANIMATIONS
========================= */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.card {
  animation: fadeInUp 0.35s ease both;
}

.card:nth-child(1) { animation-delay: 0.05s; }
.card:nth-child(2) { animation-delay: 0.10s; }
.card:nth-child(3) { animation-delay: 0.15s; }
.card:nth-child(4) { animation-delay: 0.20s; }
.card:nth-child(5) { animation-delay: 0.25s; }

/* =========================
   RESPONSIVE
========================= */
@media (max-width: 640px) {
  body {
    padding: 32px 16px 60px;
  }

  h1 {
    font-size: 26px;
  }

  .card {
    padding: 20px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .scraper-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .scraper-actions {
    width: 100%;
  }

  .logout-btn {
    position: static;
    margin-bottom: 24px;
    display: block;
    width: fit-content;
  }

  button,
  .btn {
    width: 100%;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
}