/* ============================================================
   Duxing Release Portal — consolidated stylesheet
   Palette
     brand / active (stable) .. #2f9fdd  (gradient #43a9f1 -> #2bafe3)
     preview ................. #5b7fd4
     historical .............. #8b96a5
   ============================================================ */

:root {
  color-scheme: light;
  --font-sans: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Consolas, "Liberation Mono", monospace;
  --ink: #1f2d40;
  --ink-soft: #55647a;
  --ink-muted: #8290a2;
  --line: #dce3ea;
  --line-soft: #e8edf2;
  --surface: #ffffff;
  --bg: #eef2f6;
  --active: #2f9fdd;
  --active-strong: #1f8ecb;
  --preview: #5b7fd4;
  --historical: #8b96a5;
  --warn: #b96d00;
  --radius: 14px;
  --shadow-sm: 0 2px 10px rgba(31, 58, 79, .06);
  --shadow-md: 0 12px 30px rgba(31, 58, 79, .1);
  font-family: var(--font-sans);
  color: var(--ink);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

button, a { font: inherit; }

.page-shell {
  width: 100%;
  padding: 0 clamp(16px, 4vw, 48px);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.site-header {
  min-height: 56px;
  margin: 0 calc(clamp(16px, 4vw, 48px) * -1);
  padding: 0 clamp(16px, 4vw, 48px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  background: linear-gradient(100deg, #43a9f1 0%, #2bafe3 100%);
  box-shadow: 0 2px 10px rgba(41, 132, 202, .22);
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; }
.brand-logo { display: inline-flex; align-items: center; gap: 6px; height: 34px; }
.brand-logo img { display: block; width: auto; height: 28px; object-fit: contain; }

/* ---------- Layout regions ---------- */
main {
  flex: 1;
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 30px 0 56px;
}
footer {
  width: 100%;
  max-width: 1120px;
  margin: 0 auto;
  padding: 22px 0 32px;
  color: var(--ink-muted);
  font-size: 12px;
  text-align: center;
  line-height: 1.7;
}
footer p { margin: 0; }
footer a { color: var(--ink-soft); text-decoration: none; }
footer a:hover { color: var(--active-strong); text-decoration: underline; }

/* ---------- Shared type ---------- */
.eyebrow {
  margin: 0 0 8px;
  color: var(--active);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .16em;
  text-transform: uppercase;
}
.detail-label {
  display: block;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  text-transform: uppercase;
}

/* ---------- State panels ---------- */
.state-panel {
  max-width: 460px;
  margin: 48px auto;
  padding: 24px 28px;
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: center;
}
.state-error strong { display: block; margin-bottom: 6px; }
.state-error p { color: var(--ink-soft); }
.state-error button { margin-top: 12px; }
.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  margin-right: 10px;
  border: 2px solid #c3d3dc;
  border-top-color: var(--active);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  vertical-align: -2px;
}

/* ---------- Buttons / actions ---------- */
.action, button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 20px;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
  font-weight: 700;
  text-decoration: none;
  transition: transform .16s ease, box-shadow .16s ease, background .16s ease;
}
.action:hover, button:hover { transform: translateY(-1px); }
.action--primary {
  color: #fff;
  background: linear-gradient(135deg, #43a9f1, #2bafe3);
  box-shadow: 0 8px 20px rgba(43, 157, 224, .28);
}
.action--secondary, button { color: #23517a; background: #e2f2fb; }
.action--secondary:hover, button:hover { background: #d5ebf9; }

/* ---------- Environment overview ---------- */
.environment-topbar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  margin-bottom: 26px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
}
.environment-topbar h1 {
  margin: 0;
  color: var(--ink);
  font-size: clamp(26px, 3.4vw, 38px);
  letter-spacing: -.035em;
  line-height: 1.12;
}
.environment-select-title {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin: 30px 0 16px;
  color: var(--ink);
  font-size: clamp(19px, 2.2vw, 24px);
  font-weight: 700;
  letter-spacing: -.02em;
}
.select-arrow {
  flex-shrink: 0;
  padding: 4px;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(135deg, #43a9f1, #2bafe3);
  box-shadow: 0 6px 14px rgba(43, 157, 224, .35);
}

.environment-groups--primary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-items: stretch;
}
.environment-group { display: flex; flex-direction: column; }
.environment-group--historical { margin-top: 30px; }
.group-heading { margin-bottom: 12px; }
.group-heading h2 { margin: 0; color: var(--ink); font-size: 18px; letter-spacing: -.01em; }
.group-heading h2 span { margin-left: 8px; color: var(--ink-muted); font-size: 12px; font-weight: 700; }
.group-heading p { margin: 3px 0 0; color: var(--ink-muted); font-size: 12px; }
.environment-group--active .group-heading h2 { color: var(--active-strong); }

.version-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
  flex: 1;
}
.version-grid .version-card { height: 100%; }

/* ---------- Environment card ---------- */
.version-card {
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--historical);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.version-card--stable {
  border-color: rgba(47, 159, 221, .4);
  border-left-color: var(--active);
  background: linear-gradient(160deg, #f2fbff 0%, #ffffff 60%);
  box-shadow: 0 14px 32px rgba(47, 159, 221, .14);
}
.version-card--preview { border-left-color: var(--preview); background: linear-gradient(160deg, #f6f8ff 0%, #ffffff 60%); }
.version-card--historical { border-left-color: var(--historical); }

.card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.card-titles { min-width: 0; }
.card-label {
  display: block;
  color: var(--ink-muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.version-card--stable .card-label { color: var(--active-strong); }
.version-card--preview .card-label { color: var(--preview); }
.version-card h2 { margin: 5px 0 0; color: var(--ink); font-size: 22px; letter-spacing: -.02em; line-height: 1.2; }
.version-card--stable h2 { font-size: 26px; }
.card-meta { margin: 4px 0 0; color: var(--ink-muted); font-size: 12px; font-family: var(--font-mono); }

/* ---------- Health pill ---------- */
.health {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 11px;
  border-radius: 999px;
  background: rgba(138, 150, 167, .12);
  color: #5c6a7d;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}
.health::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.health[data-tone="good"] { color: #128a68; background: rgba(43, 184, 148, .14); }
.health[data-tone="warn"] { color: #a5701c; background: rgba(216, 145, 47, .16); }
.health[data-tone="bad"] { color: #b84a4a; background: rgba(200, 84, 84, .14); }

/* ---------- Component versions ---------- */
.component-versions { margin-top: 18px; }
.component-list {
  margin: 9px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 6px;
}
.component-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  padding: 7px 11px;
  border-radius: 8px;
  background: rgba(233, 240, 246, .6);
}
.component-name { color: var(--ink-soft); font-size: 12.5px; font-weight: 700; white-space: nowrap; }
.component-version {
  color: var(--ink);
  font-family: var(--font-mono);
  font-size: 12px;
  text-align: right;
  overflow-wrap: anywhere;
}
.component-empty { margin: 8px 0 0; color: var(--ink-muted); font-size: 13px; }

/* ---------- Card detail list ---------- */
.version-card dl { margin: 16px 0 0; }
.version-card dl div {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 9px 0;
  border-top: 1px solid var(--line-soft);
}
.version-card dl div:first-child { border-top: 0; }
.version-card dt { color: var(--ink-muted); font-size: 12.5px; }
.version-card dd { margin: 0; color: var(--ink-soft); font-size: 12.5px; font-weight: 700; text-align: right; }

.version-card .action,
.version-card .card-empty-link { margin-top: auto; padding-top: 0; }
.version-card dl { margin-bottom: 18px; }
.card-empty-link {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  color: var(--ink-muted);
  font-size: 13px;
  font-weight: 700;
}

/* ---------- Preview data warning ---------- */
.preview-data-warning {
  margin: 14px 0 0;
  padding: 10px 13px;
  border: 1px solid #e0b665;
  border-left: 4px solid var(--warn);
  border-radius: 8px;
  color: #744300;
  background: #fff7e6;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.55;
}

/* ---------- Empty group state ---------- */
.group-empty {
  margin: 0;
  padding: 20px;
  border: 1px dashed rgba(89, 108, 128, .3);
  border-radius: var(--radius);
  color: var(--ink-muted);
  background: rgba(255, 255, 255, .5);
}

/* ---------- Branch chips (inside cards & rows) ---------- */
.branch-chip {
  padding: 4px 9px;
  border: 1px solid rgba(80, 105, 130, .18);
  border-radius: 7px;
  color: #38516b;
  background: rgba(232, 240, 246, .8);
  font-family: var(--font-mono);
  font-size: 12px;
  overflow-wrap: anywhere;
}
.detail-branches { align-items: flex-start !important; }
.branch-values-inline { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.env-row .branch-values-inline { justify-content: flex-start; }

/* ---------- Historical horizontal rows ---------- */
.environment-rows { display: grid; gap: 10px; }
.env-row {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(0, 2.6fr) auto;
  align-items: center;
  gap: 22px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--historical);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.env-row-head { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.env-row-head h3 { margin: 0; color: var(--ink); font-size: 16px; letter-spacing: -.01em; }
.env-row-key { color: var(--ink-muted); font-size: 12px; font-family: var(--font-mono); }
.env-row-head .health { align-self: flex-start; margin-top: 4px; }
.env-row-facts {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(0, 1.2fr) minmax(0, 1fr);
  align-items: start;
  gap: 20px;
}
.env-row-fact { min-width: 0; display: flex; flex-direction: column; gap: 5px; }
.env-row-value { color: var(--ink-soft); font-size: 12.5px; line-height: 1.5; overflow-wrap: anywhere; }
.env-row-action { justify-self: end; }
.env-row-action .action { min-width: 110px; }
.env-row--historical .action { color: #4a5769; background: #e6e9ee; box-shadow: none; }
.env-row--historical .action:hover { background: #dbdfe6; }

/* ---------- Environment notes ---------- */
.environment-notes { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.environment-notes h3 { margin: 0 0 16px; color: #34475c; font-size: 18px; letter-spacing: -.02em; }
.note-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
  gap: 14px;
}
.note-card {
  position: relative;
  padding: 18px 20px 18px 22px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--historical);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.note-card h4 {
  margin: 0 0 9px;
  color: #45566b;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .04em;
}
.note-card p { margin: 0; color: var(--ink-soft); font-size: 12.5px; line-height: 1.65; }
.note-card--active { border-left-color: var(--active); }
.note-card--active h4 { color: var(--active-strong); }
.note-card--preview { border-left-color: var(--preview); }
.note-card--preview h4 { color: var(--preview); }
.note-card--policy { border-left-color: #d89a37; }
.note-card--policy h4 { color: #b07d1f; }

/* ---------- Portal context / summary ---------- */
.portal-context { margin-top: 44px; padding-top: 26px; border-top: 1px solid var(--line); }
.portal-stats-title { margin: 0 0 16px; color: #35475c; font-size: 18px; letter-spacing: -.02em; }
.portal-summary {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin: 0;
}
.summary-card {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 22px 24px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
.summary-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--historical);
}
.summary-card::after {
  content: "";
  position: absolute;
  right: -24px;
  bottom: -30px;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: currentColor;
  opacity: .07;
}
.summary-label { color: var(--ink-muted); font-size: 13px; font-weight: 700; letter-spacing: .05em; }
.summary-card strong { margin: 8px 0 0; font-size: 40px; line-height: 1; font-weight: 800; }
.summary-card small { margin-top: 6px; color: var(--ink-muted); font-size: 12px; }
.summary-card--active { color: var(--active-strong); }
.summary-card--active::before { background: var(--active); }
.summary-card--preview { color: var(--preview); }
.summary-card--preview::before { background: var(--preview); }
.summary-card--historical { color: var(--historical); }
.summary-card .summary-label,
.summary-card small { color: var(--ink-muted); }

/* ---------- Utilities ---------- */
[hidden] { display: none !important; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Responsive ---------- */
@media (max-width: 1000px) {
  .env-row { grid-template-columns: minmax(160px, 1fr) minmax(0, 2fr); }
  .env-row-action { grid-column: 1 / -1; justify-self: stretch; }
  .env-row-action .action { width: 100%; }
}
@media (max-width: 900px) {
  .environment-groups--primary { grid-template-columns: 1fr; gap: 26px; }
}
@media (max-width: 760px) {
  .version-grid { grid-template-columns: 1fr; }
  .environment-topbar { flex-direction: column; align-items: stretch; gap: 12px; }
  .env-row { grid-template-columns: 1fr; gap: 14px; }
  .env-row-facts { grid-template-columns: 1fr; gap: 12px; }
  .portal-summary { grid-template-columns: 1fr; max-width: none; }
  .action { width: 100%; }
}
@media (max-width: 560px) {
  .portal-summary { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
