:root {
  color-scheme: light;
  --bg: #f5f7f8;
  --panel: #ffffff;
  --text: #182027;
  --muted: #66737f;
  --line: #dce3e7;
  --accent: #0f7b6c;
  --accent-dark: #0a6156;
  --danger: #b42318;
  --warn: #a05a00;
  --ok: #147a3f;
  --shadow: 0 14px 36px rgba(25, 39, 52, 0.08);
}

* {
  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;
  letter-spacing: 0;
}

button,
textarea,
select,
input {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.workspace {
  display: grid;
  gap: 20px;
}

.app-area {
  display: grid;
  gap: 20px;
}

[hidden] {
  display: none !important;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.08;
  font-weight: 760;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 15px;
}

.user-badge {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 8px;
  color: var(--muted);
  font-size: 13px;
}

#userEmail {
  min-width: 0;
  max-width: 280px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seo-copy {
  display: grid;
  gap: 6px;
  color: var(--muted);
}

.seo-copy h2 {
  font-size: 16px;
  line-height: 1.3;
  color: var(--text);
  font-weight: 700;
}

.seo-copy p {
  font-size: 14px;
  line-height: 1.55;
}

.auth-panel,
.download-form,
.jobs-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.auth-panel {
  padding: 20px;
  display: grid;
  grid-template-columns: minmax(220px, 0.8fr) minmax(280px, 1fr);
  gap: 22px;
  align-items: start;
}

.auth-panel h2 {
  font-size: 20px;
  line-height: 1.25;
}

.auth-panel p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.auth-form {
  display: grid;
  gap: 14px;
}

.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: flex-end;
}

.form-message {
  min-height: 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.form-message[data-tone="ok"] {
  color: var(--ok);
}

.form-message[data-tone="error"] {
  color: var(--danger);
}

.download-form {
  padding: 20px;
  display: grid;
  gap: 16px;
}

.retention-notice {
  border: 1px solid #f1d6a8;
  border-radius: 6px;
  background: #fff8ed;
  color: #7a4300;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

label {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

textarea,
select,
input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
}

textarea {
  min-height: 132px;
  resize: vertical;
  padding: 13px 14px;
  line-height: 1.5;
}

select {
  height: 42px;
  padding: 0 10px;
}

textarea:focus,
select:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 123, 108, 0.13);
}

.controls {
  display: grid;
  grid-template-columns: auto;
  gap: 12px;
  justify-content: end;
  align-items: center;
}

button {
  border: 0;
  border-radius: 6px;
  min-height: 42px;
  padding: 0 16px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 720;
  white-space: nowrap;
}

button:hover {
  background: var(--accent-dark);
}

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

#refreshButton,
.user-badge button,
.cancel-button {
  background: #edf2f3;
  color: var(--text);
}

#refreshButton:hover,
.user-badge button:hover,
.cancel-button:hover {
  background: #e0e8eb;
}

.jobs-panel {
  overflow: hidden;
}

.panel-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
  padding: 14px 16px;
}

.panel-title h2 {
  font-size: 18px;
}

.jobs-list {
  display: grid;
}

.empty {
  padding: 26px 16px;
  color: var(--muted);
}

.job {
  display: grid;
  gap: 11px;
  padding: 16px;
  border-bottom: 1px solid var(--line);
}

.job:last-child {
  border-bottom: 0;
}

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

.job-url {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 680;
}

.job-meta,
.job-message {
  color: var(--muted);
  font-size: 13px;
}

.state {
  border-radius: 999px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 760;
  background: #eef2f4;
  color: var(--muted);
}

.state.running,
.state.queued {
  background: #eef8f6;
  color: var(--accent-dark);
}

.state.finished {
  background: #edf8f1;
  color: var(--ok);
}

.state.failed {
  background: #fff1ef;
  color: var(--danger);
}

.state.cancelled {
  background: #f1f2f3;
  color: #4f5861;
}

.progress-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #e9eef1;
}

.progress-bar {
  height: 100%;
  width: 0;
  background: var(--accent);
  transition: width 0.2s ease;
}

.job-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.file-link {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  max-width: 100%;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid var(--line);
  color: var(--accent-dark);
  background: #f8fbfb;
  text-decoration: none;
  font-size: 13px;
  font-weight: 680;
  overflow-wrap: anywhere;
}

.error-text {
  white-space: pre-wrap;
  color: var(--danger);
  font-size: 13px;
}

@media (max-width: 800px) {
  .shell {
    width: min(100vw - 20px, 1120px);
    padding: 16px 0;
  }

  .topbar,
  .job-head,
  .auth-panel {
    display: grid;
  }

  .auth-panel {
    grid-template-columns: 1fr;
  }

  .controls,
  .auth-actions {
    grid-template-columns: 1fr;
    justify-content: stretch;
  }

  .auth-actions button {
    width: 100%;
  }
}
