:root {
  color-scheme: light;
  --bg: #f6f7f3;
  --panel: #ffffff;
  --text: #18201f;
  --muted: #5f6966;
  --line: #dfe4dd;
  --accent: #c7192e;
  --accent-dark: #9f1223;
  --focus: #0c7c8a;
  --progress: #0c7c8a;
  --progress-done: #137044;
  --shadow: 0 20px 60px rgba(24, 32, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  font-family: Arial, Helvetica, sans-serif;
  background:
    linear-gradient(135deg, rgba(199, 25, 46, 0.08), transparent 42%),
    linear-gradient(225deg, rgba(12, 124, 138, 0.1), transparent 48%),
    var(--bg);
  color: var(--text);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px 18px;
}

.download-panel {
  width: min(760px, 100%);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 5vw, 48px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
}

.top-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 28px;
}

.top-row .brand-row {
  margin-bottom: 0;
}

.brand-mark {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 32px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}

.brand-name {
  font-weight: 800;
  font-size: 18px;
}

h1 {
  margin: 0;
  max-width: 620px;
  font-size: clamp(32px, 6vw, 56px);
  line-height: 1.02;
  letter-spacing: 0;
}

.intro {
  max-width: 620px;
  margin: 18px 0 30px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.55;
}

.download-form label {
  display: block;
  margin-bottom: 10px;
  font-weight: 700;
}

.stacked-label {
  margin-top: 18px;
}

.input-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
}

input {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 16px;
  color: var(--text);
  font-size: 16px;
  outline: none;
}

select {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  color: var(--text);
  background: #fff;
  font-size: 16px;
}

input:focus,
select:focus {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(12, 124, 138, 0.16);
}

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

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

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

.status {
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  font-weight: 700;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.status.error {
  color: var(--accent-dark);
}

.status.success {
  color: #137044;
}

.format-picker {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(92px, 1fr));
  gap: 8px;
  margin: 16px 0 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.format-picker label {
  position: relative;
  margin: 0;
  cursor: pointer;
}

.format-picker input {
  position: absolute;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
}

.format-picker span {
  display: grid;
  min-height: 40px;
  place-items: center;
  border-radius: 6px;
  color: var(--muted);
  font-weight: 800;
}

.format-picker input:checked + span {
  background: var(--accent);
  color: #fff;
}

.job-progress {
  margin-top: 22px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfa;
}

.progress-header,
.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  color: var(--muted);
  font-weight: 800;
}

.progress-track {
  position: relative;
  height: 12px;
  margin: 12px 0 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece7;
}

.progress-bar {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--progress);
  transition: width 0.25s ease;
}

.job-progress.is-complete .progress-bar {
  background: var(--progress-done);
}

.job-progress.is-indeterminate .progress-bar {
  width: 100%;
  background:
    linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.55) 45%, transparent 80%),
    var(--progress);
  background-size: 220px 100%, 100% 100%;
  animation: progress-sweep 1.1s linear infinite;
}

@keyframes progress-sweep {
  from {
    background-position: -220px 0, 0 0;
  }
  to {
    background-position: 220px 0, 0 0;
  }
}

.progress-meta {
  font-size: 13px;
}

.download-ready-link {
  display: none;
  min-height: 44px;
  margin-top: 14px;
  place-items: center;
  border-radius: 6px;
  padding: 0 16px;
  background: #137044;
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.notice {
  margin: 28px 0 0;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.logout-link,
.notice a {
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: none;
}

.logout-link:hover,
.notice a:hover {
  text-decoration: underline;
}

.top-links {
  display: flex;
  gap: 16px;
  align-items: center;
}

.auth-panel {
  max-width: 620px;
}

.wide-panel {
  width: min(1280px, 100%);
}

.stacked-form {
  display: grid;
  gap: 10px;
}

.admin-create-form {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(160px, 0.7fr) auto;
  gap: 12px;
  align-items: end;
  margin-top: 24px;
}

.admin-create-form label {
  display: none;
}

.user-table-wrap {
  margin-top: 28px;
  overflow-x: auto;
}

.user-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

.user-table th,
.user-table td {
  padding: 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.user-table th {
  color: var(--muted);
  font-size: 13px;
  text-transform: uppercase;
}

.table-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.table-actions form,
.reset-form {
  display: flex;
  gap: 8px;
}

.table-actions input {
  min-height: 40px;
  max-width: 170px;
}

.secondary-button {
  min-height: 40px;
  padding: 0 12px;
  background: #e8ece7;
  color: var(--text);
}

.secondary-button:hover {
  background: #dce3db;
}

.danger-button {
  min-height: 40px;
  padding: 0 12px;
  background: #f3d7db;
  color: var(--accent-dark);
}

.danger-button:hover {
  background: #e9c3c9;
}

.secondary-link {
  display: inline-grid;
  min-height: 40px;
  place-items: center;
  border-radius: 6px;
  padding: 0 12px;
  background: #e8ece7;
  color: var(--text);
  font-weight: 800;
  text-decoration: none;
}

.secondary-link:hover {
  background: #dce3db;
}

.log-section {
  margin-top: 34px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.log-section h2 {
  margin: 0;
  font-size: 24px;
}

.log-meta {
  margin: 8px 0 0;
  color: var(--muted);
}

.log-table {
  min-width: 1120px;
  font-size: 12px;
  line-height: 1.25;
}

.log-table th,
.log-table td {
  padding: 7px 8px;
}

.log-table th {
  font-size: 11px;
}

.log-table pre {
  margin: 0;
  max-width: 240px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  line-height: 1.25;
}

.long-cell {
  max-width: 240px;
  overflow-wrap: anywhere;
}

@media (max-width: 680px) {
  .input-row {
    grid-template-columns: 1fr;
  }

  button {
    width: 100%;
  }

  .top-row {
    align-items: stretch;
    flex-direction: column;
  }

  .admin-create-form {
    grid-template-columns: 1fr;
  }

  .admin-create-form label {
    display: block;
  }
}
