:root {
  color-scheme: light;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --line: #d8dee8;
  --line-strong: #b9c4d3;
  --text: #172033;
  --muted: #637083;
  --blue: #1f6feb;
  --blue-deep: #174ea6;
  --green: #217a4a;
  --red: #b42318;
  --amber: #946200;
  --shadow: 0 10px 28px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

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

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 18px 28px;
  border-bottom: 1px solid var(--line);
  background: var(--surface);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 22px;
  font-weight: 720;
}

h2 {
  font-size: 16px;
  font-weight: 700;
}

.app-header p {
  margin-top: 6px;
  color: var(--muted);
}

.account-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
}

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

.login-form {
  display: grid;
  gap: 14px;
  width: min(420px, 100%);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.login-form p {
  color: var(--muted);
  line-height: 1.5;
}

.login-form label {
  display: grid;
  gap: 6px;
  font-weight: 650;
}

.login-form input,
.user-form input,
.user-form select {
  width: 100%;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 0 10px;
}

.login-form input:focus,
.user-form input:focus,
.user-form select:focus {
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.18);
}

.toolbar,
.mini-toolbar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

button,
.button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
  white-space: nowrap;
}

button:hover,
.button:hover {
  border-color: #8da0ba;
}

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

.button.disabled,
.button[aria-disabled="true"] {
  opacity: 0.54;
  cursor: not-allowed;
  pointer-events: none;
}

.primary {
  border-color: var(--blue);
  background: var(--blue);
  color: #fff;
}

.primary:hover {
  border-color: var(--blue-deep);
  background: var(--blue-deep);
}

.secondary {
  background: #f8fafc;
}

.ghost {
  min-height: 32px;
  border-color: transparent;
  background: transparent;
  color: var(--blue);
}

.ghost.danger {
  color: var(--red);
}

main {
  padding: 22px 28px 32px;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 1px;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background: var(--line);
}

.status-strip div {
  min-height: 76px;
  padding: 14px 16px;
  background: var(--surface);
}

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

.status-strip strong {
  display: block;
  margin-top: 8px;
  font-size: 26px;
  line-height: 1;
}

.editor-shell {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.config-shell {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.users-shell {
  margin-top: 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

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

.config-bar {
  align-items: flex-start;
}

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

.config-status {
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.config-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 16px;
  padding: 16px;
}

.config-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.config-field-label {
  font-weight: 650;
  color: #273449;
}

.config-description {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.config-field input {
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #fff;
  padding: 0 10px;
}

.config-field input:focus {
  box-shadow: 0 0 0 2px rgba(31, 111, 235, 0.18);
}

.checkbox-field {
  grid-template-columns: auto 1fr;
  align-items: center;
}

.checkbox-field .config-field-label,
.checkbox-field .config-description {
  grid-column: 2;
}

.checkbox-field input {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 18px;
  height: 18px;
  padding: 0;
}

.config-field input:disabled {
  background: #f1f4f8;
  color: var(--muted);
  cursor: not-allowed;
}

.user-form {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) minmax(120px, 1fr) minmax(180px, 1fr) 140px auto;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

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

.users-table {
  min-width: 720px;
}

.users-table th {
  height: 38px;
}

.users-table td {
  height: 44px;
  padding: 0 10px;
}

.table-wrap {
  max-height: calc(100vh - 304px);
  min-height: 88px;
  overflow: auto;
}

table {
  width: 100%;
  min-width: 1120px;
  border-collapse: separate;
  border-spacing: 0;
  table-layout: fixed;
}

thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  height: 40px;
  border-bottom: 1px solid var(--line-strong);
  background: #eef3f8;
  color: #344154;
  font-size: 12px;
  text-align: left;
}

th,
td {
  border-right: 1px solid var(--line);
}

th:last-child,
td:last-child {
  border-right: 0;
}

tbody td {
  height: 42px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}

tbody tr:nth-child(even) td {
  background: #fbfcfe;
}

.col-id {
  width: 70px;
}

.col-url {
  width: 360px;
}

.col-notes {
  width: 160px;
}

.col-check {
  width: 140px;
}

.col-status {
  width: 220px;
}

.col-action {
  width: 120px;
}

th {
  padding: 0 10px;
}

.th-with-help {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.help-dot {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 17px;
  height: 17px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: #fff;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  cursor: help;
}

td {
  padding: 0;
}

.index-cell {
  padding: 0 10px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

input {
  width: 100%;
  height: 41px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  outline: none;
  padding: 0 10px;
}

input:focus {
  box-shadow: inset 0 0 0 2px var(--blue);
  background: #fff;
}

.check-cell,
.action-cell {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: normal;
}

.status-cell {
  padding: 0 8px;
  color: var(--muted);
  font-size: 12px;
  overflow: visible;
  white-space: nowrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 650;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.badge.ok {
  background: #e8f5ee;
  color: var(--green);
}

.badge.warn {
  background: #fff3cd;
  color: var(--amber);
}

.badge.error {
  background: #fde7e4;
  color: var(--red);
}

.badge.neutral {
  background: #edf1f7;
  color: #475569;
}

.status-stack {
  display: grid;
  align-content: center;
  gap: 5px;
  min-height: 42px;
  padding: 6px 0;
}

.status-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  min-width: 0;
  line-height: 1.2;
}

.route-pill {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 0 6px;
  border-radius: 5px;
  background: #eef6ff;
  color: var(--blue-deep);
  font-size: 11px;
  font-weight: 650;
}

.status-message {
  flex: 1 1 96px;
  min-width: 80px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-progress {
  position: relative;
  flex: 1 1 84px;
  min-width: 64px;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe4f0;
}

.row-progress span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--blue);
}

.progress-text {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
}

.action-stack {
  display: grid;
  justify-items: start;
  align-content: center;
  gap: 4px;
  min-height: 42px;
}

.tooltip-wrap,
.help-dot {
  position: relative;
}

.floating-tooltip {
  position: fixed;
  z-index: 10000;
  width: max-content;
  max-width: min(340px, calc(100vw - 20px));
  padding: 8px 10px;
  border: 1px solid rgba(23, 32, 51, 0.16);
  border-radius: 6px;
  background: #172033;
  color: #fff;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  pointer-events: none;
  white-space: normal;
  word-break: break-word;
  box-shadow: 0 8px 20px rgba(23, 32, 51, 0.18);
}

.floating-tooltip[hidden] {
  display: none;
}

.download-link,
.retry-link {
  color: var(--blue);
  font-weight: 650;
  text-decoration: none;
  cursor: pointer;
}

.download-link:hover,
.retry-link:hover {
  text-decoration: underline;
}

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  max-width: 420px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #162033;
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 160ms ease, transform 160ms ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

.add-row-bar {
  display: flex;
  justify-content: center;
  padding: 14px 16px 16px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.add-row-button {
  width: 36px;
  min-height: 36px;
  padding: 0;
  border-radius: 999px;
  border-color: var(--blue);
  background: #fff;
  color: var(--blue);
  font-size: 24px;
  line-height: 1;
}

.add-row-button:hover {
  background: #eef5ff;
  border-color: var(--blue-deep);
  color: var(--blue-deep);
}

@media (max-width: 1180px) {
  .col-url {
    width: 320px;
  }

  .col-notes {
    width: 140px;
  }
}

@media (max-width: 720px) {
  .app-header,
  main {
    padding-left: 10px;
    padding-right: 10px;
  }

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

  button,
  .button {
    min-height: 34px;
    padding: 0 12px;
  }

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

  table {
    min-width: 0;
  }

  .col-id {
    width: 52px;
  }

  .col-url {
    width: 260px;
  }

  .col-notes {
    width: 90px;
  }

  .col-check {
    width: 90px;
  }

  .col-status,
  .col-action {
    width: 120px;
  }

  .col-status {
    width: 160px;
  }

  th {
    padding: 0 8px;
  }

  input {
    padding: 0 8px;
  }
}
