:root {
  color-scheme: light;
  --page: #f5f7f9;
  --surface: #ffffff;
  --surface-soft: #f8fafb;
  --line: #e3e7eb;
  --line-strong: #d4d9df;
  --text: #171a1f;
  --muted: #68717d;
  --quiet: #929aa5;
  --green: #159a62;
  --green-soft: #e9f7f0;
  --amber: #c47a08;
  --amber-soft: #fff5d9;
  --red: #d23f52;
  --red-soft: #fff0f2;
  --blue: #2563b8;
  --blue-soft: #eaf2ff;
  --shadow: 0 4px 16px rgba(19, 28, 38, .05);
}

* { box-sizing: border-box; }
html { background: var(--page); }
body {
  margin: 0;
  background: var(--page);
  color: var(--text);
  font-family: Inter, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  letter-spacing: 0;
}
button, input { font: inherit; }
a { color: inherit; }
.page { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 28px 0 52px; }
.page-narrow { width: min(820px, calc(100% - 32px)); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.page-tools { display: flex; justify-content: flex-end; min-height: 34px; margin-bottom: 18px; }
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 34px; padding: 7px 12px; border: 1px solid var(--line-strong);
  border-radius: 6px; background: var(--surface); color: #343a44;
  text-decoration: none; font-size: 13px; font-weight: 600; cursor: pointer;
}
.button:hover { background: var(--surface-soft); }
.button-primary { border-color: var(--text); background: var(--text); color: #fff; }
.button-primary:hover { background: #30343b; }
.button:disabled { cursor: not-allowed; opacity: .5; }

.overall {
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
  min-height: 76px; padding: 17px 20px; border: 1px solid var(--line);
  border-radius: 8px; margin-bottom: 24px; background: var(--surface);
}
.overall.operational { border-color: #b9e3cf; background: var(--green-soft); }
.overall.degraded { border-color: #efd18a; background: var(--amber-soft); }
.overall.error { border-color: #edbcc4; background: var(--red-soft); }
.overall.stale { background: #eef1f4; }
.overall-main { display: flex; align-items: center; gap: 13px; min-width: 0; }
.signal { width: 11px; height: 11px; flex: 0 0 auto; border-radius: 50%; background: #9ba3ad; box-shadow: 0 0 0 5px rgba(123, 132, 144, .12); }
.operational .signal { background: var(--green); box-shadow: 0 0 0 5px rgba(21, 154, 98, .12); }
.degraded .signal { background: var(--amber); box-shadow: 0 0 0 5px rgba(196, 122, 8, .13); }
.error .signal { background: var(--red); box-shadow: 0 0 0 5px rgba(210, 63, 82, .12); }
.overall-title { font-size: 15px; font-weight: 750; }
.overall-detail { margin-top: 4px; color: var(--muted); font-size: 12px; line-height: 1.45; }
.sync { flex: 0 0 auto; color: var(--muted); font-size: 11px; line-height: 1.55; text-align: right; }

.content-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 13px; }
.content-head h1, .content-head h2 { margin: 0; font-size: 16px; }
.content-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.window-tabs { display: inline-flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #edf0f3; }
.window-tab { min-width: 49px; border: 0; border-radius: 5px; padding: 5px 9px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 650; cursor: pointer; }
.window-tab.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 3px rgba(22, 29, 38, .11); }

.monitor-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 13px; }
.monitor-card {
  display: flex; min-width: 0; min-height: 278px; flex-direction: column;
  padding: 17px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--surface); box-shadow: var(--shadow); text-decoration: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.monitor-card:hover { border-color: #c7cdd4; box-shadow: 0 8px 24px rgba(19, 28, 38, .08); transform: translateY(-1px); }
.card-head { display: flex; align-items: flex-start; gap: 10px; }
.provider-icon {
  display: grid; width: 36px; height: 36px; flex: 0 0 auto; place-items: center;
  border-radius: 7px; color: #fff; font-size: 11px; font-weight: 800;
}
.provider-icon.openai { background: #20242a; }
.provider-icon.anthropic { background: #c7673d; }
.provider-icon.gemini { background: #3176c9; }
.provider-icon.grok { background: #515965; }
.provider-icon.deepseek { background: #315fcd; }
.provider-icon.kimi { background: #6e54b5; }
.provider-icon.zhipu { background: #34739b; }
.provider-icon.antigravity { background: #80549e; }
.provider-icon.default { background: #717984; }
.card-identity { min-width: 0; flex: 1; }
.channel-name { overflow: hidden; font-size: 14px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.channel-meta { display: flex; min-width: 0; align-items: center; gap: 5px; margin-top: 4px; color: var(--muted); font-size: 10px; }
.provider-label { flex: 0 0 auto; border-radius: 4px; padding: 2px 5px; background: #eef1f4; color: #59616c; font-weight: 650; text-transform: uppercase; }
.model-label { overflow: hidden; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; text-overflow: ellipsis; white-space: nowrap; }
.status { flex: 0 0 auto; border-radius: 999px; padding: 5px 8px; background: #edf0f3; color: #646d78; font-size: 11px; font-weight: 700; white-space: nowrap; }
.status.operational { background: var(--green-soft); color: #087447; }
.status.degraded { background: var(--amber-soft); color: #986008; }
.status.error, .status.failed, .status.down { background: var(--red-soft); color: #ae283d; }
.status.unknown, .status.stale { background: #edf0f3; color: #646d78; }
.latency-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 18px; }
.metric-label { display: block; color: var(--muted); font-size: 10px; }
.metric-value { display: block; margin-top: 3px; color: #30353c; font-size: 15px; font-weight: 700; font-variant-numeric: tabular-nums; }
.availability { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-top: 18px; padding-top: 14px; border-top: 1px solid #edf0f2; }
.availability-label { color: var(--quiet); font-size: 10px; font-weight: 650; text-transform: uppercase; }
.availability-value { color: var(--green); font-size: 28px; font-weight: 780; line-height: 1; font-variant-numeric: tabular-nums; }
.availability-value.missing { color: var(--quiet); }
.availability-value.warning { color: var(--amber); }
.availability-value.critical { color: var(--red); }
.availability-unit { font-size: 15px; }

.timeline-wrap { margin-top: auto; padding-top: 17px; }
.timeline-head, .timeline-foot { display: flex; justify-content: space-between; color: var(--quiet); font-size: 9px; }
.timeline-head { margin-bottom: 7px; font-size: 10px; font-weight: 650; }
.timeline { display: flex; height: 22px; align-items: flex-end; gap: 2px; }
.timeline-point { min-width: 0; flex: 1 1 0; border-radius: 2px 2px 1px 1px; background: #d7dce1; }
.timeline-point.operational { height: 100%; background: #32b879; }
.timeline-point.degraded { height: 65%; background: #e7a72e; }
.timeline-point.error, .timeline-point.failed, .timeline-point.down { height: 35%; background: #e25567; }
.timeline-point.empty, .timeline-point.unknown { height: 15%; background: #d7dce1; }
.timeline-foot { margin-top: 5px; }
.empty-state { padding: 46px 20px; border: 1px dashed var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--muted); text-align: center; }

.back-link { display: inline-block; margin-bottom: 20px; color: var(--muted); text-decoration: none; font-size: 13px; }
.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 15px; margin-bottom: 20px; }
.detail-head h1 { margin: 0; font-size: 22px; }
.detail-meta { margin-top: 5px; color: var(--muted); font-size: 12px; }
.metric-strip { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.detail-stat { min-width: 0; padding: 15px; border-right: 1px solid var(--line); }
.detail-stat:last-child { border-right: 0; }
.detail-stat span { color: var(--muted); font-size: 10px; }
.detail-stat strong { display: block; margin-top: 6px; overflow-wrap: anywhere; font-size: 16px; font-variant-numeric: tabular-nums; }
.section-panel { margin-top: 13px; padding: 17px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.section-panel h2 { margin: 0 0 14px; font-size: 14px; }
.table-wrap { overflow: auto; }
.models { width: 100%; min-width: 680px; border-collapse: collapse; }
.models th, .models td { padding: 11px 9px; border-bottom: 1px solid #edf0f2; font-size: 12px; text-align: left; }
.models th { color: var(--muted); font-size: 10px; font-weight: 650; }
.models tr:last-child td { border-bottom: 0; }
.freshness { display: flex; flex-wrap: wrap; gap: 20px; color: var(--muted); font-size: 11px; }

.admin-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.admin-head h1 { margin: 5px 0 0; font-size: 21px; }
.admin-actions { display: flex; gap: 8px; }
.admin-note { margin: 0 0 12px; color: var(--muted); font-size: 12px; }
.admin-maintenance { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; padding: 11px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.admin-maintenance strong { display: block; font-size: 12px; }
.admin-maintenance span { display: block; margin-top: 3px; color: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.admin-panel { overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); box-shadow: var(--shadow); }
.admin-tools { display: flex; align-items: center; gap: 8px; padding: 13px 15px; border-bottom: 1px solid var(--line); }
.search { width: min(260px, 45vw); min-height: 34px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 10px; outline: none; }
.search:focus { border-color: #8fa8c6; box-shadow: 0 0 0 3px rgba(37, 99, 184, .1); }
.selection-count { margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.choices { padding: 4px 15px; }
.choice { display: grid; grid-template-columns: 22px 36px minmax(0, 1fr) minmax(280px, 340px); align-items: center; gap: 10px; padding: 11px 0; border-bottom: 1px solid #edf0f2; }
.choice:last-child { border-bottom: 0; }
.choice[hidden] { display: none; }
.choice > input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--text); }
.choice-identity { min-width: 0; }
.choice-name { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.choice-meta { margin-top: 3px; color: var(--muted); font-size: 10px; }
.alias-editor { display: grid; grid-template-columns: minmax(100px, 1fr) auto auto; gap: 6px; align-items: center; }
.alias-input { width: 100%; min-width: 0; min-height: 34px; border: 1px solid var(--line-strong); border-radius: 6px; padding: 7px 9px; outline: none; font-size: 12px; }
.alias-input:focus { border-color: #8fa8c6; box-shadow: 0 0 0 3px rgba(37, 99, 184, .1); }
.alias-editor .button { padding-right: 9px; padding-left: 9px; font-size: 11px; white-space: nowrap; }
.form-message { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-size: 12px; }
.form-message.error { color: var(--red); }
.form-message.success { color: var(--green); }

@media (max-width: 960px) {
  .monitor-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-strip { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .detail-stat:nth-child(3) { border-right: 0; }
  .detail-stat:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
  .choice { grid-template-columns: 22px 36px minmax(0, 1fr); }
  .alias-editor { grid-column: 3 / -1; width: 100%; }
}

@media (max-width: 620px) {
  .page { width: calc(100% - 22px); padding: 18px 0 38px; }
  .page-tools { margin-bottom: 12px; }
  .overall { align-items: flex-start; padding: 15px; }
  .sync { max-width: 105px; }
  .content-head { align-items: flex-start; flex-direction: column; }
  .monitor-grid { grid-template-columns: 1fr; }
  .monitor-card { min-height: 270px; }
  .channel-name { white-space: normal; }
  .detail-head { margin-bottom: 16px; }
  .metric-strip { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .detail-stat, .detail-stat:nth-child(3) { border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
  .detail-stat:nth-child(even) { border-right: 0; }
  .detail-stat:nth-last-child(-n+2) { border-bottom: 0; }
  .admin-head { align-items: flex-start; }
  .admin-actions { flex-direction: column; }
  .admin-maintenance { align-items: flex-start; }
  .admin-tools { align-items: stretch; flex-wrap: wrap; }
  .search { width: 100%; flex-basis: 100%; }
  .selection-count { margin-left: 0; align-self: center; }
  .alias-editor { grid-template-columns: minmax(0, 1fr) auto; }
  .alias-reset { grid-column: 2; }
  .alias-save { grid-column: 2; grid-row: 1; }
  .alias-reset { grid-row: 2; }
  .timeline { gap: 1px; }
}
