:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --surface: #ffffff;
  --line: #d9dee7;
  --text: #1f2937;
  --muted: #667085;
  --accent: #1b7f5c;
  --accent-dark: #136246;
  --warning: #b45309;
  --danger: #b42318;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  cursor: pointer;
}

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

.secondary-button,
.secondary-link {
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 14px;
  text-decoration: none;
  font-size: 14px;
}

.primary-button {
  min-width: 104px;
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

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

.layout {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.narrow-layout {
  width: min(880px, calc(100vw - 32px));
}

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

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  font-weight: 700;
}

h2 {
  font-size: 18px;
  margin-bottom: 12px;
}

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

.top-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.login-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  display: grid;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 24px;
}

.login-panel p {
  color: var(--muted);
  font-size: 14px;
}

.login-panel button {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.form-error {
  min-height: 18px;
  color: var(--danger);
  font-size: 13px;
}

.operator-panel {
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 16px;
}

.account-list {
  display: grid;
  gap: 10px;
}

.account-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 10px;
}

.account-row:last-child {
  border-bottom: 0;
  padding-bottom: 0;
}

.needs-login {
  border-color: #f3b4ad;
  background: #fff8f7;
}

.account-status-panel {
  margin: -6px 0 18px;
}

.account-status-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 10px;
}

.account-status-card {
  min-height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 12px;
}

.account-status-card > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.account-status-card p {
  margin-top: 8px;
  color: var(--muted);
  font-size: 13px;
}

.account-status-card small {
  display: block;
  margin-top: 6px;
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-status-badge {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  border-radius: 999px;
  background: #eef2f6;
  padding: 0 9px;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

code {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f8fafc;
  padding: 3px 6px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.download-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.auth-controls {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) 112px 168px;
  gap: 12px;
}

.auth-status {
  margin-top: 12px;
  font-size: 14px;
}

.auth-window-info {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
  font-size: 14px;
}

.popup-hint {
  flex-basis: 100%;
  color: var(--warning);
  font-size: 13px;
}

.download-card {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
}

.plain-list {
  margin: 0;
  padding-left: 22px;
  color: var(--text);
}

.plain-list li {
  margin: 8px 0;
}

.filters {
  display: grid;
  grid-template-columns: 180px 180px 180px minmax(240px, 1fr) 88px;
  gap: 12px;
  align-items: end;
  margin: 18px 0;
}

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

input {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

select {
  width: 100%;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  padding: 0 10px;
}

.summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  margin-bottom: 18px;
}

.summary div {
  background: var(--surface);
  padding: 14px 16px;
}

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

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

.table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
}

table {
  width: 100%;
  min-width: 920px;
  border-collapse: collapse;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  background: #eef2f6;
  color: #344054;
  font-weight: 650;
}

.sort-button {
  display: inline-flex;
  width: 100%;
  min-width: 96px;
  height: auto;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  border: 0;
  background: transparent;
  color: inherit;
  padding: 0;
  font-weight: inherit;
}

.sort-button:hover,
.sort-button.is-active {
  color: var(--accent-dark);
}

.sort-indicator {
  display: inline-flex;
  width: 16px;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  font-variant-numeric: normal;
}

.sort-button.is-active .sort-indicator {
  color: var(--accent-dark);
}

td.number,
th.number {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

tbody tr:hover {
  background: #f1f7f4;
}

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

.pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  margin: 14px 0 26px;
  color: var(--muted);
  font-size: 14px;
}

.runs {
  padding-top: 8px;
}

.runs-list {
  display: grid;
  gap: 10px;
}

.run-item {
  display: grid;
  grid-template-columns: 92px 1fr auto;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  padding: 10px 12px;
  font-size: 14px;
}

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

.account-status-badge.status-success {
  background: #e7f4ee;
}

.status-running {
  color: var(--warning);
}

.account-status-badge.status-running {
  background: #fff4df;
}

.status-failed {
  color: var(--danger);
}

.account-status-badge.status-failed {
  background: #fff0ee;
}

.status-never {
  color: var(--muted);
}

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

@media (max-width: 760px) {
  .layout {
    width: min(100vw - 20px, 1280px);
    padding-top: 16px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .filters,
  .summary {
    grid-template-columns: 1fr;
  }

  .run-item {
    grid-template-columns: 1fr;
  }

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

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

  .account-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .account-status-card > div {
    align-items: flex-start;
    flex-direction: column;
  }
}
