:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-2: #edf3f0;
  --line: #d8e2dc;
  --text: #18221f;
  --muted: #61716a;
  --accent: #0d8a70;
  --accent-ink: #ffffff;
  --warning: #a9660e;
  --danger: #be3342;
  --info: #226a94;
  --accent-soft: rgba(13, 138, 112, .12);
  --warning-soft: rgba(169, 102, 14, .12);
  --danger-soft: rgba(190, 51, 66, .10);
  --shadow: 0 10px 30px rgba(39, 64, 54, .08);
  --radius: 8px;
  --page: 1320px;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 8% 0%, rgba(13, 138, 112, .08), transparent 34rem),
    var(--bg);
  color: var(--text);
  font: 14px/1.55 "Aptos", "Segoe UI Variable", "Microsoft YaHei", sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input { font: inherit; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--line);
  background: rgba(250, 252, 251, .97);
  box-shadow: 0 2px 12px rgba(39, 64, 54, .05);
}
.topbar-inner {
  max-width: var(--page);
  height: 62px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 28px;
}
.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  letter-spacing: .01em;
}
.brand:hover { text-decoration: none; }
.brand-mark {
  width: 30px;
  height: 30px;
  display: inline-grid;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
}
.brand-mark.large { width: 46px; height: 46px; font-size: 16px; }
.nav { display: flex; align-items: center; gap: 6px; flex: 1; }
.nav a {
  color: var(--muted);
  padding: 7px 10px;
  border-radius: 6px;
}
.nav a:hover, .nav a.active {
  color: var(--text);
  background: var(--surface-2);
  text-decoration: none;
}

.page {
  max-width: var(--page);
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.workspace-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 26px;
}
.workspace-head h1 {
  margin: 0;
  font-family: Georgia, "Noto Serif SC", serif;
  font-size: 38px;
  font-weight: 600;
  letter-spacing: -.02em;
}
.workspace-subtitle { margin: 7px 0 0; color: var(--muted); }
.stat-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .72);
}
.stat-ribbon span {
  padding: 7px 11px;
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.stat-ribbon span + span { border-left: 1px solid var(--line); }
.stat-ribbon strong { color: var(--text); font-size: 16px; margin-right: 3px; }
.publish-panel {
  display: grid;
  grid-template-columns: minmax(220px, .75fr) minmax(0, 1.8fr);
  gap: 18px 28px;
  padding: 24px;
  margin-bottom: 22px;
  border: 1px solid #bdd8ce;
  border-radius: 10px;
  background: linear-gradient(130deg, #effaf6 0%, #fff 62%);
  box-shadow: var(--shadow);
}
.publish-copy h2, .section-intro h2 { margin: 0; font-size: 20px; }
.publish-copy p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.endpoint-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.endpoint-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 11px 13px;
  border: 1px solid #bcd6cd;
  border-radius: 6px;
  background: #fff;
  color: #175d4d;
  font: 12px/1.45 "Cascadia Code", Consolas, monospace;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.publish-meta {
  grid-column: 2;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: -8px;
  color: var(--muted);
  font-size: 12px;
}
.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  font-weight: 700;
}
.live-dot::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.muted-dot { color: var(--warning); }
.origin-form {
  grid-column: 1 / -1;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid rgba(13, 138, 112, .15);
}
.origin-form label { flex: 1; max-width: 600px; }
.format-picker {
  display: grid;
  grid-template-columns: 185px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
  padding: 20px 0 24px;
  border-bottom: 1px solid var(--line);
}
.section-intro h2 { font-size: 18px; }
.format-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.format-tabs article {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 12px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, .78);
}
.format-tabs article > div {
  grid-column: 1 / -1;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}
.format-tabs article strong { font-size: 14px; }
.format-tabs article span { color: var(--muted); font-size: 11px; }
.format-tabs .copy-link {
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.icon-copy {
  min-width: 44px;
  padding: 2px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 11px;
}
.icon-copy:hover { border-color: var(--accent); color: var(--accent); }
.source-section {
  padding-top: 24px;
}
.source-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}
.source-row {
  display: grid;
  grid-template-columns: minmax(150px, 1.1fr) auto minmax(320px, 2fr) auto;
  align-items: center;
  gap: 18px;
  min-width: 0;
  padding: 16px 17px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--warning);
  border-radius: 7px;
  background: rgba(255, 255, 255, .84);
  transition: border-color .16s, transform .16s;
}
.source-row:hover { border-color: #adc6bd; transform: translateY(-1px); }
.source-row-ok { border-left-color: var(--accent); }
.source-row-error { border-left-color: var(--danger); }
.source-identity { display: flex; align-items: center; gap: 11px; min-width: 0; }
.source-glyph {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  flex: none;
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--accent);
  font-family: Georgia, serif;
  font-size: 18px;
}
.source-identity h3 { margin: 0; font-size: 15px; }
.source-adapter { display: block; margin-top: 1px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.status-pill { padding: 2px 7px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 10px; text-transform: uppercase; }
.status-pill.online { border-color: rgba(13,138,112,.3); background: var(--accent-soft); color: var(--accent); }
.status-pill.pending { border-color: rgba(169,102,14,.3); background: var(--warning-soft); color: var(--warning); }
.source-metrics { display: grid; grid-template-columns: .6fr 1.2fr 1.2fr; gap: 16px; min-width: 0; }
.source-metrics div { min-width: 0; }
.source-metrics span { display: block; color: var(--muted); font-size: 11px; }
.source-metrics strong { display: block; margin-top: 2px; overflow: hidden; font-size: 12px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.source-actions { display: flex; align-items: center; gap: 10px; white-space: nowrap; }
.source-actions form { margin: 0; }
.text-action { padding: 2px 0; border: 0; background: transparent; color: var(--accent); cursor: pointer; font-size: 12px; font-weight: 600; }
.text-action:hover { text-decoration: underline; }
.text-action.muted { color: var(--muted); font-weight: 400; }
.row-error { grid-column: 1 / -1; margin: -4px 0 0 45px; color: var(--danger); font-size: 12px; }
.copy-link, .text-action, .icon-copy, .button { -webkit-tap-highlight-color: transparent; }
.page-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-heading h1, .section-heading h2, .panel h2, .provider-card h2 {
  margin: 0;
  line-height: 1.2;
}
.page-heading h1 { font-size: 28px; }
.eyebrow, .section-label {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
}
.summary-meta {
  display: flex;
  gap: 16px;
  color: var(--muted);
}
.page-heading-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 12px;
}
.page-heading-actions form { margin: 0; }
.muted { color: var(--muted); }
.mono { font-family: "Cascadia Code", Consolas, monospace; font-size: 12px; }
.link { word-break: break-all; }
.copy-link {
  max-width: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: copy;
  text-align: left;
}
.copy-link:hover { text-decoration: underline; }

.merge-strip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 24px;
  padding: 20px 22px;
  margin-bottom: 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.merge-strip p { margin: 5px 0 0; }
.subscription-formats {
  margin-bottom: 24px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.format-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.format-card {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
}
.format-card > div {
  grid-column: 1 / -1;
}
.format-card p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.format-card .copy-link {
  align-self: center;
}
.public-url-form {
  flex: 1 0 100%;
  display: flex;
  align-items: end;
  gap: 10px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.public-url-form label { flex: 1; }

.provider-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}
.provider-card, .panel, .data-section {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 2px 10px rgba(39, 64, 54, .04);
}
.provider-card { padding: 20px; min-width: 0; }
.provider-card.status-error { border-top: 3px solid var(--danger); }
.provider-card.status-ok { border-top: 3px solid var(--accent); }
.provider-card.status-ready,
.provider-card.status-unconfigured { border-top: 3px solid var(--warning); }
.card-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
}
.provider-card h2 { font-size: 19px; margin-top: 2px; }
.status-dot {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
}
.metric-lead {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin: 22px 0 10px;
}
.metric-lead strong { font-size: 26px; line-height: 1; }
.metric-lead span { color: var(--muted); font-size: 12px; }
.quota-bar {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: var(--surface-2);
}
.quota-bar span {
  display: block;
  height: 100%;
  max-width: 100%;
  background: var(--accent);
}
.metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px 18px;
  margin: 20px 0;
}
.metric-grid div, .detail-list div { min-width: 0; }
dt { color: var(--muted); font-size: 12px; }
dd { margin: 3px 0 0; overflow-wrap: anywhere; }
.empty-state {
  min-height: 132px;
  margin: 20px 0;
  display: grid;
  place-items: center;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--muted);
}
.card-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card-actions form { margin: 0; }
.error-text {
  color: var(--danger);
  overflow-wrap: anywhere;
  font-size: 12px;
}

.button {
  min-height: 34px;
  padding: 7px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 600;
}
.button:hover { border-color: var(--muted); text-decoration: none; }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.button.secondary { background: transparent; }
.button.warning { border-color: rgba(169, 102, 14, .35); background: #fff8ec; }
.button.ghost { min-height: 30px; padding: 4px 10px; background: transparent; color: var(--muted); }
.button.full { width: 100%; }
.button:disabled { cursor: not-allowed; opacity: .65; }
.button:focus-visible, input:focus-visible, summary:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.data-section { padding: 20px; }
.data-section.flush { padding: 0; overflow: hidden; margin-bottom: 20px; }
.data-section.flush .section-heading { padding: 18px 20px 0; }
.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}
.section-heading.compact { margin-bottom: 16px; }
.section-heading h2 { font-size: 18px; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td {
  padding: 11px 12px;
  border-top: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
th { color: var(--muted); font-size: 11px; letter-spacing: .06em; text-transform: uppercase; }
.pill {
  display: inline-flex;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
}
.pill.success, .pill.ok { color: var(--accent); border-color: rgba(13, 138, 112, .30); background: var(--accent-soft); }
.pill.failed, .pill.error { color: var(--danger); border-color: rgba(190, 51, 66, .30); background: var(--danger-soft); }
.pill.running, .pill.pending { color: var(--warning); border-color: rgba(169, 102, 14, .30); background: var(--warning-soft); }
.pill.neutral { color: var(--muted); }
.pill.alive { color: var(--accent); border-color: rgba(13, 138, 112, .30); background: var(--accent-soft); }
.pill.dead { color: var(--danger); border-color: rgba(190, 51, 66, .30); background: var(--danger-soft); }
.pill.unknown { color: var(--muted); background: var(--surface-2); }

.source-tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  margin-bottom: 16px;
  padding-bottom: 2px;
}
.source-tabs a {
  min-width: 150px;
  padding: 11px 14px;
  display: grid;
  gap: 2px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--surface);
  color: var(--text);
}
.source-tabs a:hover { text-decoration: none; border-color: var(--muted); }
.source-tabs a.active {
  border-color: var(--accent);
  box-shadow: inset 0 -3px 0 var(--accent);
}
.source-tabs small { color: var(--muted); }
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  margin-top: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
.panel { padding: 22px; min-width: 0; }
.detail-list { display: grid; gap: 14px; margin: 0 0 20px; }
.form-stack { display: grid; gap: 14px; margin-top: 18px; }
label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 600; }
input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  background: #fbfdfc;
  color: var(--text);
  outline: none;
}
input:focus { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }

.flash-stack { display: grid; gap: 8px; margin-bottom: 18px; }
.flash {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
}
.flash.success { border-color: rgba(13, 138, 112, .30); color: var(--accent); background: #f3fbf8; }
.flash.error { border-color: rgba(190, 51, 66, .30); color: var(--danger); background: #fff6f6; }

.login-panel {
  width: min(420px, 100%);
  margin: 8vh auto 0;
  padding: 28px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow);
}
.login-brand { margin-bottom: 26px; }
.login-brand h1 { margin: 12px 0 0; font-size: 26px; }
.command-hint {
  overflow-x: auto;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface-2);
  font-size: 12px;
}
.settings-panel { margin-top: 16px; }
.settings-form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.settings-submit {
  display: flex;
  align-items: end;
}
.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
}
.checkbox-row input { width: auto; min-height: auto; }

@media (max-width: 980px) {
  .provider-grid { grid-template-columns: 1fr 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .publish-panel { grid-template-columns: 1fr; }
  .publish-meta { grid-column: 1; margin-top: 0; }
  .format-picker { grid-template-columns: 1fr; gap: 14px; }
  .source-row { grid-template-columns: minmax(150px, 1fr) auto minmax(280px, 1.8fr) auto; }
}
@media (max-width: 680px) {
  .topbar-inner { height: auto; min-height: 62px; padding: 10px 16px; flex-wrap: wrap; gap: 10px; }
  .topbar-inner > form { margin-left: auto; }
  .nav {
    order: 3;
    width: 100%;
    flex: 0 0 100%;
    gap: 4px;
    overflow-x: auto;
  }
  .nav a { flex: 0 0 auto; white-space: nowrap; }
  .page { padding: 22px 16px 48px; }
  .workspace-head { align-items: start; flex-direction: column; }
  .workspace-head h1 { font-size: 32px; }
  .stat-ribbon { width: 100%; justify-content: space-between; }
  .stat-ribbon span { padding: 6px 8px; }
  .publish-panel { padding: 18px; gap: 15px; }
  .endpoint-row { align-items: stretch; flex-direction: column; }
  .endpoint-row .button { width: 100%; }
  .origin-form { align-items: stretch; flex-direction: column; }
  .origin-form label { max-width: none; }
  .format-tabs { grid-template-columns: 1fr; }
  .source-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px;
  }
  .source-state { justify-self: end; }
  .source-metrics {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--line);
  }
  .source-actions { grid-column: 1 / -1; justify-content: flex-end; padding-top: 4px; }
  .row-error { margin-left: 0; }
  .page-heading { align-items: start; flex-direction: column; }
  .page-heading-actions { align-items: flex-start; justify-content: flex-start; }
  .provider-grid { grid-template-columns: 1fr; }
  .merge-strip { align-items: stretch; flex-direction: column; }
  .public-url-form { align-items: stretch; flex-direction: column; }
  .metric-grid { grid-template-columns: 1fr; }
  .summary-meta { flex-wrap: wrap; }
  .settings-form-grid { grid-template-columns: 1fr; }
  .format-grid { grid-template-columns: 1fr; }
  .button { min-height: 44px; }
}
