:root {
  color-scheme: light;
  --bg: #eef1f5;
  --panel: #ffffff;
  --text: #172433;
  --muted: #617285;
  --line: #d9e1ea;
  --blue: #1f6bff;
  --green: #179b62;
  --amber: #b26a00;
  --red: #c93636;
  --cyan: #008b98;
  --shadow: 0 8px 22px rgba(23, 36, 51, 0.06);
  --shadow-hover: 0 12px 28px rgba(23, 36, 51, 0.08);
  --radius: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(31, 107, 255, 0.08), transparent 26%),
    linear-gradient(180deg, #f7f9fc 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

button {
  font: inherit;
}

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

.app-shell {
  width: min(1600px, calc(100vw - 64px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

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

.eyebrow {
  display: inline-block;
  margin-bottom: 10px;
  color: var(--blue);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0 0 6px;
  font-size: 28px;
  line-height: 1.2;
}

.topbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  word-break: break-all;
}

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

.top-actions button,
.site-tab {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  border-radius: var(--radius);
  min-height: 38px;
}

.top-actions button {
  padding: 0 16px;
  box-shadow: var(--shadow);
  transition: all 0.2s ease;
}

.top-actions button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: var(--shadow-hover);
}

.hero-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  align-items: start;
  margin-bottom: 24px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.source-panel {
  display: grid;
  grid-template-columns: minmax(150px, 0.22fr) minmax(0, 1fr);
  gap: 12px 14px;
  align-items: center;
  padding: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s ease;
}

.source-panel:hover {
  box-shadow: var(--shadow-hover);
}

.panel-caption {
  display: grid;
  gap: 6px;
}

.panel-caption strong {
  font-size: 16px;
}

.panel-caption span,
.source-tip,
.source-note {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.55;
  word-break: break-word;
}

.source-tip {
  grid-column: 1 / -1;
  padding-top: 8px;
  border-top: 1px dashed var(--line);
  white-space: pre-line;
}

.source-tip a {
  color: var(--blue);
  font-weight: 700;
  text-decoration: none;
}

.source-form,
.inline-form {
  display: grid;
  grid-template-columns: minmax(120px, 0.8fr) minmax(220px, 1.25fr) minmax(160px, 0.9fr) 110px auto;
  gap: 8px;
}

.inline-form {
  grid-template-columns: 1fr 1.2fr auto;
}

.source-form input,
.source-form select,
.inline-form input {
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 0 12px;
  background: var(--panel);
  min-width: 0;
}

.source-form button,
.inline-form button {
  min-height: 38px;
  border: 1px solid var(--blue);
  border-radius: var(--radius);
  background: var(--blue);
  color: white;
  padding: 0 16px;
  font-weight: 700;
  white-space: nowrap;
  transition: all 0.2s ease;
  cursor: pointer;
}

.source-form button:hover,
.inline-form button:hover {
  background: #0056e0;
  border-color: #0056e0;
  box-shadow: 0 4px 12px rgba(31, 107, 255, 0.2);
}

.metric {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 24px;
  box-shadow: var(--shadow);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

.metric-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}

.metric strong {
  font-size: 24px;
  line-height: 1.1;
}

.site-tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 0 0 0 6px;
  margin-top: 4px;
}

.site-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0 20px;
  max-width: 260px;
  border-bottom-color: transparent;
  border-radius: var(--radius) var(--radius) 0 0;
  box-shadow: none;
  transform: translateY(1px);
  transition: all 0.2s ease;
  font-weight: 500;
  background: transparent;
}

.site-tab:hover:not([aria-selected="true"]) {
  background: #f0f4f8;
}

.site-tab[aria-selected="true"] {
  border-color: var(--blue);
  border-bottom-color: var(--panel);
  color: var(--blue);
  background: var(--panel);
}

.site-tab-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.site-tab-count {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: #e4e9f0;
  color: var(--muted);
  font-size: 12px;
}

.site-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  min-height: 400px;
  transition: box-shadow 0.2s ease;
}

.site-panel:hover {
  box-shadow: var(--shadow-hover);
}

.site-heading {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.site-heading-main {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.site-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  word-break: break-all;
}

.site-section-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.site-heading-stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
}

.site-heading-stats span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: #f8fafc;
  font-size: 12px;
  white-space: nowrap;
}

.source-bar {
  display: grid;
  grid-template-columns: 84px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 16px 24px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfd;
}

.source-bar .source-note {
  color: var(--text);
  font-weight: 700;
}

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

.account-table th,
.account-table td {
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: middle;
}

.account-table th {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  background: #fbfcfd;
}

.account-name {
  font-weight: 700;
  font-size: 14px;
}

.account-id {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.status {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border-radius: 999px;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 700;
}

.status-success,
.status-already_checked_in {
  color: var(--green);
  background: #eaf8f1;
}

.status-success {
  color: var(--green);
  background: #eaf8f1;
}

.status-need_login,
.status-need_manual {
  color: var(--amber);
  background: #fff5df;
}

.status-failed {
  color: var(--red);
  background: #fff0f0;
}

.status-unsupported,
.status-skipped {
  color: var(--muted);
  background: #eef1f5;
}

.status-unknown {
  color: var(--cyan);
  background: #e7f8fa;
}

.status-pending_checkin,
.status-pending_backend_session,
.status-browser_logged_in {
  color: var(--cyan);
  background: #e7f8fa;
}

.message {
  color: var(--muted);
  max-width: 520px;
  line-height: 1.5;
}

.account-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: flex-end;
}

.account-actions button {
  min-height: 30px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.account-actions button:hover:not(:disabled) {
  background: #f0f4f8;
}

.account-actions button[data-action="refresh"] {
  border-color: #bfd1ff;
  color: var(--blue);
  background: #f3f7ff;
}

.account-actions button[data-action="refresh"]:hover:not(:disabled) {
  background: #e0e9ff;
}

.account-actions button[data-action="delete"] {
  border-color: #ffd0d0;
  color: var(--red);
  background: #fff7f7;
}

.account-actions button[data-action="delete"]:hover:not(:disabled) {
  background: #ffeaea;
}

.account-actions button:disabled {
  cursor: default;
  opacity: 0.68;
}

.empty {
  padding: 36px 18px;
  color: var(--muted);
}

@media (max-width: 820px) {
  .app-shell {
    width: calc(100vw - 20px);
    padding-top: 16px;
  }

  .topbar,
  .site-heading-main {
    display: grid;
    grid-template-columns: 1fr;
  }

  .hero-grid,
  .summary-grid,
  .source-panel,
  .source-bar {
    grid-template-columns: 1fr;
  }

  .site-heading-stats {
    justify-content: flex-start;
  }

  .source-form,
  .inline-form {
    grid-template-columns: 1fr;
  }

  .account-table,
  .account-table thead,
  .account-table tbody,
  .account-table tr,
  .account-table th,
  .account-table td {
    display: block;
  }

  .account-table thead {
    display: none;
  }

  .account-table tr {
    border-bottom: 1px solid var(--line);
    padding: 12px 0;
  }

  .account-table td {
    border-bottom: 0;
    padding: 6px 14px;
  }
}
