:root {
  color-scheme: light;
  --ink: #202426;
  --muted: #667076;
  --line: #d8dddf;
  --surface: #ffffff;
  --canvas: #f3f5f4;
  --charcoal: #24292b;
  --green: #1f7a4c;
  --green-soft: #e3f2e9;
  --amber: #a65f00;
  --amber-soft: #fff0d4;
  --red: #b72d38;
  --red-soft: #fae7e9;
  --blue: #235f9a;
  --blue-soft: #e8f0f8;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: var(--canvas);
  color: var(--ink);
  font-family: "Microsoft YaHei UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  letter-spacing: 0;
}

button, select, input, textarea { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.5; }

.topbar {
  min-height: 58px;
  padding: 0 24px;
  background: var(--charcoal);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.brand-block, .session-block, .toolbar, .command-group, .dialog-actions {
  display: flex;
  align-items: center;
}

.brand-block { gap: 12px; }
.brand-block strong { font-size: 19px; }
.brand-block span { color: #c8ced0; }
.session-block { gap: 12px; min-width: 0; }
.session-subject { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: #d9dddf; }

.status-dot { display: inline-flex; align-items: center; gap: 7px; white-space: nowrap; }
.status-dot::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #8b9295; }
.status-dot[data-state="online"]::before { background: #50bd7a; }
.status-dot[data-state="warning"]::before { background: #f0aa38; }

.section-tabs {
  height: 46px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: end;
  gap: 4px;
}

.tab-button {
  height: 46px;
  min-width: 86px;
  padding: 0 16px;
  border: 0;
  border-bottom: 3px solid transparent;
  background: transparent;
  color: var(--muted);
}
.tab-button.is-active { color: var(--ink); border-bottom-color: var(--green); font-weight: 700; }

main { width: min(1500px, 100%); margin: 0 auto; }
.view-section { padding: 24px; }

.section-heading, .control-band-heading, .data-section-heading, .dialog-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}
.section-heading { margin-bottom: 18px; }
h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: 24px; line-height: 1.25; }
h2 { margin-bottom: 0; font-size: 17px; line-height: 1.35; }
.eyebrow { margin-bottom: 5px; color: var(--green); font-size: 11px; font-weight: 700; }

.metrics-band {
  display: grid;
  grid-template-columns: repeat(6, minmax(128px, 1fr));
  background: var(--surface);
  border: 1px solid var(--line);
}
.metric { min-height: 104px; padding: 20px; border-right: 1px solid var(--line); display: flex; flex-direction: column; justify-content: space-between; }
.metric:last-child { border-right: 0; }
.metric span { color: var(--muted); }
.metric strong { font-size: 30px; line-height: 1; }

.monitoring-band { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); }
.monitoring-summary { min-height: 52px; padding: 10px 18px; display: flex; align-items: center; gap: 18px; flex-wrap: wrap; color: var(--muted); border-bottom: 1px solid var(--line); }
.monitoring-table { max-height: 220px; }
.backup-table { min-width: 980px; }

.control-band { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); }
.control-band-heading { min-height: 74px; padding: 15px 18px; border-bottom: 1px solid var(--line); }
.control-band-heading p { margin: 5px 0 0; color: var(--muted); }
.command-group, .toolbar, .dialog-actions { gap: 8px; }
.breaker-rows { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.breaker-row { min-height: 92px; padding: 16px 18px; display: grid; grid-template-columns: 1fr auto; gap: 8px 20px; align-items: center; border-right: 1px solid var(--line); }
.breaker-row:last-child { border-right: 0; }
.breaker-copy strong { display: block; margin-bottom: 5px; }
.breaker-copy span { display: block; color: var(--muted); line-height: 1.45; overflow-wrap: anywhere; }
.breaker-meta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }

.switch { position: relative; width: 44px; height: 24px; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch span { position: absolute; inset: 0; border-radius: 12px; background: #aeb5b8; transition: background 150ms ease; }
.switch span::after { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; border-radius: 50%; background: #fff; transition: transform 150ms ease; }
.switch input:checked + span { background: var(--red); }
.switch input:checked + span::after { transform: translateX(20px); }
.switch input:focus-visible + span { outline: 3px solid #9fc2e2; outline-offset: 2px; }

.data-section { margin-top: 18px; background: var(--surface); border: 1px solid var(--line); }
.data-section-heading { min-height: 54px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.table-viewport { width: 100%; overflow: auto; }
.tall-table { max-height: calc(100vh - 172px); background: var(--surface); border: 1px solid var(--line); }
#instancesView table { min-width: 1780px; }
table { width: 100%; border-collapse: collapse; min-width: 760px; }
th, td { padding: 11px 12px; border-bottom: 1px solid #e5e8e9; text-align: left; vertical-align: middle; line-height: 1.4; }
th { position: sticky; top: 0; z-index: 1; background: #edf0ef; color: #4b5458; font-size: 12px; white-space: nowrap; }
td { max-width: 320px; overflow-wrap: anywhere; }
tbody tr:hover { background: #f7f9f8; }
.empty-row td { height: 86px; text-align: center; color: var(--muted); }

.host-summary-band {
  min-height: 48px;
  margin-bottom: 14px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--muted);
}
.host-summary-band span:first-child,
.host-summary-band span:nth-child(2) { color: var(--ink); font-weight: 700; }
.deployment-host-table { min-width: 1420px; }
.product-service-table { min-width: 1480px; }
.image-version-table { min-width: 1180px; }
.image-rollout-table { min-width: 1260px; }
.tall-image-rollout-table { max-height: 42vh; }
.image-management-section { margin-top: 14px; }
.rollout-progress-actions { margin-top: 9px; display: flex; gap: 8px; flex-wrap: wrap; }
.host-actions { min-width: 184px; white-space: nowrap; }
.host-actions button + button { margin-left: 8px; }

.state-chip { display: inline-block; min-width: 66px; padding: 3px 7px; border-radius: 4px; text-align: center; white-space: nowrap; background: #ecefef; color: #4d5559; }
.state-chip.good { background: var(--green-soft); color: var(--green); }
.state-chip.warn { background: var(--amber-soft); color: var(--amber); }
.state-chip.bad { background: var(--red-soft); color: var(--red); }
.state-chip.info { background: var(--blue-soft); color: var(--blue); }

.primary-button, .secondary-button, .danger-button, .quiet-button, .quiet-light-button, .text-button, .icon-button {
  min-height: 34px;
  border-radius: 5px;
  border: 1px solid transparent;
  padding: 0 13px;
}
.primary-button { background: var(--green); color: #fff; border-color: var(--green); }
.secondary-button { background: #fff; color: var(--ink); border-color: #bfc6c9; }
.danger-button { background: var(--red); color: #fff; border-color: var(--red); }
.quiet-button { background: transparent; color: inherit; border-color: #747c80; }
.quiet-light-button { background: transparent; color: var(--ink); border-color: #bfc6c9; }
.text-button { min-height: 28px; padding: 0 4px; background: transparent; color: var(--blue); }
.icon-button { width: 34px; padding: 0; background: transparent; color: var(--muted); border-color: transparent; font-size: 23px; }

.toolbar label { color: var(--muted); }
select, input { min-height: 34px; min-width: 130px; border: 1px solid #bfc6c9; border-radius: 5px; padding: 0 9px; background: #fff; }
select { padding-right: 30px; }

.filter-band {
  margin-bottom: 14px;
  padding: 14px;
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--line);
}
.filter-band label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; }
.filter-band input, .filter-band select { min-width: 160px; color: var(--ink); font-size: 14px; }
.audit-page-table { max-height: calc(100vh - 285px); background: var(--surface); border: 1px solid var(--line); }
.audit-page-table table { min-width: 1080px; }
.pagination-band { min-height: 52px; padding: 9px 0; display: flex; align-items: center; justify-content: space-between; gap: 16px; color: var(--muted); }

.login-view { min-height: calc(100vh - 58px); display: grid; place-items: center; padding: 24px; }
.login-panel { width: min(420px, 100%); padding: 34px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--green); }
.login-panel h1 { margin-bottom: 18px; }
.login-status { min-height: 44px; color: var(--muted); line-height: 1.55; }
.login-form { display: grid; gap: 10px; }
.login-form label { color: var(--ink); font-weight: 700; }
.login-form input { width: 100%; min-height: 42px; }
.login-panel .primary-button { width: 100%; min-height: 42px; }

dialog { border: 1px solid var(--line); border-radius: 8px; padding: 0; box-shadow: 0 18px 50px rgba(25, 30, 32, 0.22); }
dialog::backdrop { background: rgba(25, 30, 32, 0.45); }
.reason-dialog { width: min(520px, calc(100% - 32px)); }
.reason-dialog form { padding: 20px; }
.reason-dialog label { display: block; margin: 20px 0 7px; font-weight: 700; }
.reason-dialog input { width: 100%; }
.account-dialog { width: min(720px, calc(100% - 32px)); }
.account-dialog form { padding: 20px; }
.account-dialog label { display: grid; gap: 7px; margin: 14px 0; font-weight: 700; }
.account-dialog input { width: 100%; }
.plain-help { margin: 7px 0 0; color: var(--muted); line-height: 1.65; }
.image-rollout-confirmation { margin: 18px 0 0; border-top: 1px solid var(--line); }
.image-rollout-confirmation > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.image-rollout-confirmation dt { color: var(--muted); }
.image-rollout-confirmation dd { margin: 0; overflow-wrap: anywhere; }
textarea { width: 100%; resize: vertical; border: 1px solid #bfc6c9; border-radius: 5px; padding: 10px; line-height: 1.5; }
.dialog-actions { justify-content: flex-end; margin-top: 18px; }
.field-error { min-height: 18px; margin: 5px 0 0; color: var(--red); font-size: 12px; }
.audit-dialog { width: min(980px, calc(100% - 32px)); max-height: calc(100vh - 48px); }
.audit-dialog > .dialog-heading { padding: 16px 18px; border-bottom: 1px solid var(--line); }
.audit-table { max-height: calc(100vh - 150px); }

.toast { position: fixed; right: 20px; bottom: 20px; max-width: min(420px, calc(100% - 40px)); padding: 12px 15px; border-radius: 6px; background: var(--charcoal); color: #fff; box-shadow: 0 8px 24px rgba(25, 30, 32, 0.2); }
.toast.is-error { background: var(--red); }

@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .brand-block span, .session-subject { display: none; }
  .section-tabs { max-width: 100%; padding: 0 4px; gap: 0; overflow-x: auto; }
  .tab-button { flex: 0 0 auto; min-width: 76px; padding: 0 8px; font-size: 13px; white-space: nowrap; }
  .view-section { padding: 16px 12px; }
  .section-heading, .control-band-heading { align-items: flex-start; flex-direction: column; }
  .metrics-band { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric:nth-child(even) { border-right: 0; }
  .metric:nth-child(-n+4) { border-bottom: 1px solid var(--line); }
  .breaker-rows { grid-template-columns: 1fr; }
  .breaker-row { border-right: 0; border-bottom: 1px solid var(--line); }
  .breaker-row:last-child { border-bottom: 0; }
  .toolbar { width: 100%; flex-wrap: wrap; }
  .toolbar select { flex: 1; }
  .filter-band { align-items: stretch; }
  .filter-band label, .filter-band input, .filter-band select { width: 100%; }
  .host-summary-band { align-items: flex-start; flex-direction: column; gap: 6px; }
}
