:root {
  --bg: #f5f7f9;
  --surface: #ffffff;
  --text: #17202a;
  --muted: #647181;
  --line: #d9e0e7;
  --accent: #126c5d;
  --accent-dark: #0d5147;
  --danger: #a4262c;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.45;
}

.page {
  width: min(1100px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 22px;
}

.header-actions {
  display: grid;
  justify-items: end;
  gap: 10px;
}

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

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 32px;
}

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

.config {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.config span {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 6px;
  padding: 7px 9px;
}

.panel,
.notice {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 18px;
}

.form {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

label span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
}

input {
  min-height: 44px;
}

select {
  min-height: 44px;
  background: #ffffff;
}

textarea {
  min-height: 82px;
  resize: vertical;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  outline: 3px solid rgba(18, 108, 93, 0.16);
}

button {
  width: fit-content;
  min-height: 44px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #ffffff;
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  padding: 10px 18px;
}

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

button.state-red {
  background: #a4262c;
}

button.state-red:hover {
  background: #7f1d22;
}

button.state-green {
  background: var(--accent);
}

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

button:disabled {
  background: #aeb8c2;
  cursor: not-allowed;
}

.secondary-button {
  min-height: 38px;
  border: 1px solid var(--line);
  background: #ffffff;
  color: var(--text);
  padding: 8px 14px;
}

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

.link-button {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
  padding: 8px 14px;
  text-decoration: none;
}

.link-button:hover {
  background: #eef2f5;
}

.primary-link {
  border-color: var(--accent);
  background: var(--accent);
  color: #ffffff;
}

.primary-link:hover {
  background: var(--accent-dark);
}

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

.notice.error {
  border-color: rgba(164, 38, 44, 0.35);
  color: var(--danger);
}

.source-detail {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f9fbfc;
  padding: 12px;
  color: var(--muted);
  font-size: 13px;
}

.source-detail strong {
  color: var(--text);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

.summary div,
.stats div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.summary span,
.stats span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.summary strong,
.stats strong {
  display: block;
  margin-top: 6px;
  font-size: 30px;
}

.stats {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 12px;
}

.logs {
  max-height: 320px;
  overflow: auto;
  margin: 0;
  background: #101820;
  color: #e8edf2;
  border-radius: 6px;
  padding: 14px;
  font-size: 13px;
  white-space: pre-wrap;
}

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

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

th {
  color: var(--muted);
  font-size: 13px;
}

.empty {
  color: var(--muted);
  text-align: center;
}

.traffic-light {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: -2px;
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.18);
}

.traffic-light.red {
  background: #a4262c;
}

.traffic-light.green {
  background: var(--accent);
}

.status-cell-complete {
  background: rgba(18, 108, 93, 0.1);
}

.status-cell-pending {
  background: rgba(164, 38, 44, 0.1);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  min-width: 138px;
  border-radius: 6px;
  font-weight: 700;
  padding: 8px 10px;
}

.status-badge.complete {
  background: var(--accent);
  color: #ffffff;
}

.status-badge.pending {
  background: #a4262c;
  color: #ffffff;
}

@media (max-width: 760px) {
  .header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    justify-items: stretch;
    width: 100%;
  }

  .top-actions {
    justify-content: flex-start;
  }

  .config {
    justify-content: flex-start;
  }

  .summary {
    grid-template-columns: repeat(2, 1fr);
  }

  button {
    width: 100%;
  }

  .link-button,
  .top-actions form {
    width: 100%;
  }

  .link-button {
    justify-content: center;
  }

  .actions {
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
}

.login-page {
  width: min(460px, calc(100% - 32px));
  min-height: 100vh;
  display: grid;
  align-items: center;
  margin: 0 auto;
  padding: 32px 0;
}

.login-panel h1 {
  margin-bottom: 22px;
}

@media (max-width: 480px) {
  .summary {
    grid-template-columns: 1fr;
  }

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