:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --panel: #ffffff;
  --text: #151922;
  --muted: #647084;
  --line: #d9dee7;
  --accent: #16734d;
  --accent-hover: #0f5f3e;
  --danger: #b42318;
  --warning: #a15c07;
  --done: #0f766e;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input {
  font: inherit;
}

.shell {
  width: min(1160px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.login-panel {
  min-height: calc(100vh - 80px);
  display: grid;
  place-items: center;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
}

.panel.compact {
  width: min(420px, 100%);
}

.topbar,
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  margin-bottom: 20px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 16px;
  font-size: 20px;
}

.muted,
.hint {
  color: var(--muted);
}

.hint {
  margin: 8px 0 0;
  font-size: 14px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 18px;
  align-items: start;
}

.stack {
  display: grid;
  gap: 16px;
}

label {
  display: grid;
  gap: 7px;
  font-weight: 650;
}

input[type="text"],
input[type="url"],
input[type="number"],
input[type="password"],
input[type="file"] {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  padding: 10px 12px;
}

input[type="file"] {
  padding: 9px;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0;
  padding: 14px;
}

legend {
  padding: 0 6px;
  font-weight: 750;
}

.source-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}

.choice {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  cursor: pointer;
}

.choice:has(input:checked) {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.choice input,
.checks input {
  accent-color: var(--accent);
}

.source-block {
  margin-top: 8px;
}

.checks {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 14px;
}

.checks label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  font-weight: 600;
}

.range-grid {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.range-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(82px, 0.5fr) minmax(82px, 0.5fr);
  gap: 8px;
  align-items: center;
}

.range-row span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

.range-row input {
  min-height: 38px;
}

button,
.download {
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 11px 16px;
  font-weight: 750;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button:hover,
.download:hover {
  background: var(--accent-hover);
}

button:disabled {
  opacity: 0.58;
  cursor: not-allowed;
}

button.secondary {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}

button.secondary:hover {
  background: #f0f2f5;
}

.error-text {
  min-height: 20px;
  color: var(--danger);
  font-weight: 650;
}

.empty {
  min-height: 130px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.status-line {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--text);
  padding: 4px 10px;
  font-weight: 800;
  text-transform: lowercase;
}

.badge.done {
  background: #e7f6f0;
  color: var(--done);
}

.badge.failed,
.badge.partial_failed {
  background: #fef0ee;
  color: var(--danger);
}

.badge.processing,
.badge.downloading,
.badge.zipping {
  background: #fff4df;
  color: var(--warning);
}

.progress {
  height: 12px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ecf2;
}

#progress-bar {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transition: width 180ms ease;
}

.stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 16px 0;
}

.stats div {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.stats dt {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.stats dd {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
}

.download {
  display: inline-flex;
  margin-top: 2px;
}

.report-links {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 12px;
}

.errors {
  margin-top: 14px;
  color: var(--danger);
  font-size: 14px;
  white-space: pre-wrap;
}

.history-panel {
  margin-top: 18px;
}

.history {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(110px, auto);
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
}

.history-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  color: var(--muted);
  font-size: 14px;
}

.history-actions {
  display: flex;
  justify-content: end;
  gap: 8px;
}

.small-link {
  color: var(--accent);
  font-weight: 750;
  text-decoration: none;
}

[hidden] {
  display: none !important;
}

@media (max-width: 820px) {
  .shell {
    width: min(100% - 20px, 1160px);
    padding-top: 16px;
  }

  .layout,
  .source-grid,
  .checks,
  .range-row,
  .history-item {
    grid-template-columns: 1fr;
  }

  .topbar {
    align-items: start;
  }

  .stats {
    grid-template-columns: 1fr;
  }

  .history-actions {
    justify-content: start;
  }
}
