:root {
  color-scheme: light dark;
  --bg: #0f172a;
  --card-bg: rgba(15, 23, 42, 0.8);
  --card-bg-light: #ffffff;
  --text: #e2e8f0;
  --text-light: #0f172a;
  --accent: #38bdf8;
  --accent-dark: #0ea5e9;
  --border: rgba(148, 163, 184, 0.3);
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top, #1e293b, #0f172a 60%, #020617);
  color: var(--text);
  display: flex;
  justify-content: center;
  padding: 3rem 1rem 4rem;
}

.app-shell {
  width: min(960px, 100%);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.hero {
  text-align: center;
}

.hero h1 {
  font-size: clamp(2rem, 4vw, 3rem);
  margin-bottom: 0.5rem;
}

.hero p {
  margin: 0;
  color: rgba(226, 232, 240, 0.75);
}

.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: clamp(1.5rem, 5vw, 2rem);
  backdrop-filter: blur(28px);
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.35);
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
}

form label {
  display: block;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.field-group {
  display: flex;
  align-items: stretch;
  gap: 0.75rem;
}

input[type='url'] {
  flex: 1;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  background: rgba(15, 23, 42, 0.55);
  color: var(--text);
  font-size: 1rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type='url']:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.25);
}

button {
  border: none;
  border-radius: 12px;
  padding: 0.85rem 1.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #0f172a;
}

button:disabled {
  opacity: 0.5;
  cursor: wait;
}

button:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px rgba(14, 165, 233, 0.35);
}

.refresh-btn {
  background: rgba(148, 163, 184, 0.15);
  color: var(--text);
  padding: 0.65rem 1.1rem;
}

.refresh-btn:hover {
  box-shadow: none;
  background: rgba(148, 163, 184, 0.25);
}

.hint {
  margin-top: 1rem;
  margin-bottom: 0.5rem;
  color: rgba(226, 232, 240, 0.65);
  font-size: 0.95rem;
}

#form-message {
  min-height: 1.25rem;
  font-size: 0.95rem;
}

.table-wrapper {
  border-radius: 12px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.95rem;
}

th,
td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr.placeholder td {
  text-align: center;
  color: rgba(226, 232, 240, 0.6);
}

.status-chip {
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: capitalize;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.status-chip[data-state='completed'] {
  background: rgba(16, 185, 129, 0.2);
  color: #34d399;
}

.status-chip[data-state='failed'] {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}

.status-chip[data-state='in_progress'],
.status-chip[data-state='pending'] {
  background: rgba(56, 189, 248, 0.2);
  color: #38bdf8;
}

.progress-bar {
  position: relative;
  width: 140px;
  height: 8px;
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar span {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 0%;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  transition: width 0.4s ease;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  font-size: 0.9rem;
  color: rgba(148, 163, 184, 0.7);
}

.footer code {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 6px;
  padding: 0.2rem 0.5rem;
}

a.download-link {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
}

a.download-link:hover {
  text-decoration: underline;
}

@media (max-width: 640px) {
  body {
    padding-top: 2rem;
  }

  .field-group {
    flex-direction: column;
  }

  button,
  input[type='url'] {
    width: 100%;
  }

  table {
    font-size: 0.85rem;
  }

  th,
  td {
    padding: 0.65rem 0.75rem;
  }
}

@media (prefers-color-scheme: light) {
  body {
    background: linear-gradient(180deg, #e0f2fe, #f1f5f9 50%, #e2e8f0);
    color: var(--text-light);
  }

  .card {
    background: var(--card-bg-light);
    border: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 22px 45px rgba(148, 163, 184, 0.25);
  }

  input[type='url'] {
    background: rgba(226, 232, 240, 0.65);
    color: var(--text-light);
  }

  .hint,
  .footer {
    color: rgba(15, 23, 42, 0.65);
  }

  .refresh-btn {
    background: rgba(15, 23, 42, 0.08);
    color: var(--text-light);
  }
}
