:root {
  color-scheme: dark;
  --canvas: #101416;
  --surface: #181e20;
  --surface-strong: #20272a;
  --control: #111618;
  --ink: #edf1f2;
  --muted: #a4afb3;
  --quiet: #758287;
  --line: #2b3437;
  --line-strong: #3a464a;
  --accent: #68c7c5;
  --accent-ink: #0c1718;
  --good: #69c997;
  --warn: #e0b45d;
  --bad: #de7979;
  --neutral: #859196;
  --radius-panel: 10px;
  --radius-control: 6px;
  --font: "Avenir Next", "Helvetica Neue", Arial, sans-serif;
  --mono: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: var(--font);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
h1, h2, h3, h4, p { margin: 0; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
::selection { color: var(--accent-ink); background: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Corner rule: panels 10px, interactive controls 6px. */
.app {
  min-height: 100dvh;
  display: block;
}

.site-chips {
  overflow-x: auto;
  display: flex;
  flex-direction: row;
  gap: 8px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  scrollbar-width: thin;
}
.chip {
  width: auto;
  min-width: 164px;
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-control);
  color: var(--muted);
  background: transparent;
  text-align: left;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.chip:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface); }
.chip:active { transform: translateY(1px); }
.chip.active { color: var(--ink); border-color: var(--line-strong); background: var(--surface-strong); }
.chip-name { min-width: 0; display: inline-flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; }
.chip-state { color: var(--quiet); font-size: 9px; }
.chip-dot, .dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  display: inline-block;
  border-radius: 50%;
  background: var(--neutral);
}
.chip-dot.operational, .badge.operational .dot { background: var(--good); }
.chip-dot.maintenance, .chip-dot.degraded, .badge.maintenance .dot, .badge.degraded .dot { background: var(--warn); }
.chip-dot.incident, .badge.incident .dot { background: var(--bad); }

.main { min-width: 0; }
.main-inner { width: min(1504px, 100%); margin: 0 auto; padding: 0 32px 48px; }
.topbar {
  min-height: 82px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid var(--line);
}
.page-title h1 { font-size: 19px; letter-spacing: -.035em; }
.page-title p { margin-top: 4px; color: var(--quiet); font-size: 11px; }
.toolbar { display: flex; align-items: center; gap: 14px; }
.sync-copy { color: var(--quiet); font-family: var(--mono); font-size: 9px; }

button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid var(--accent);
  border-radius: var(--radius-control);
  color: var(--accent-ink);
  background: var(--accent);
  white-space: nowrap;
  font-size: 11px;
  font-weight: 750;
  transition: filter .16s ease, transform .16s ease, background .16s ease, border-color .16s ease;
}
button:hover { filter: brightness(1.08); }
button:active { transform: translateY(1px); }
button:disabled { cursor: wait; opacity: .58; filter: none; }
button.secondary { color: var(--ink); border-color: var(--line-strong); background: transparent; }
button.secondary:hover { filter: none; border-color: var(--quiet); background: var(--surface-strong); }

.kpis {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 28px 0 32px;
  border: 1px solid var(--line);
  border-radius: var(--radius-panel);
  overflow: hidden;
}
.kpi {
  min-width: 0;
  min-height: 116px;
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px;
  border-right: 1px solid var(--line);
  background: var(--surface);
}
.kpi:last-child { border-right: 0; }
.kpi > span { color: var(--quiet); font-size: 10px; font-weight: 700; }
.kpi strong { color: var(--ink); font-family: var(--mono); font-size: 27px; line-height: 1.05; font-weight: 500; letter-spacing: -.04em; overflow-wrap: anywhere; }
.kpi p { color: var(--muted); font-size: 10.5px; line-height: 1.45; overflow-wrap: anywhere; }

.workspace { min-width: 0; }
.panel { min-width: 0; }
.panel-head {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 0 4px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 22px; letter-spacing: -.035em; }
.panel-head .hint { margin-top: 4px; color: var(--quiet); font-family: var(--mono); font-size: 9px; }
.badge {
  min-height: 30px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 10px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  color: var(--muted);
  background: var(--surface);
  font-size: 9px;
  font-weight: 700;
}
.badge.operational { color: var(--good); }
.badge.maintenance, .badge.degraded { color: var(--warn); }
.badge.incident { color: var(--bad); }

.detail { display: grid; gap: 28px; padding-top: 24px; }
.product-summary { border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; }
.summary-state {
  display: grid;
  grid-template-columns: minmax(180px, .38fr) minmax(0, 1.62fr);
  gap: 26px;
  align-items: start;
  padding: 20px;
  background: var(--surface);
}
.summary-state strong { font-size: 16px; letter-spacing: -.025em; }
.summary-state p { color: var(--muted); font-size: 12px; line-height: 1.55; }
.summary-state code { display: block; margin-top: 6px; color: var(--quiet); font-family: var(--mono); font-size: 9px; overflow-wrap: anywhere; }

.facts-panel { border-top: 1px solid var(--line); }
.facts-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fact {
  min-width: 0;
  min-height: 116px;
  display: grid;
  align-content: start;
  gap: 7px;
  padding: 16px;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: var(--surface-strong);
}
.fact:nth-child(4n) { border-right: 0; }
.fact:nth-last-child(-n + 4) { border-bottom: 0; }
.fact span { color: var(--quiet); font-size: 9px; font-weight: 700; }
.fact strong { color: var(--ink); font-family: var(--mono); font-size: 17px; line-height: 1.2; font-weight: 500; overflow-wrap: anywhere; }
.fact p { color: var(--muted); font-size: 9.5px; line-height: 1.45; overflow-wrap: anywhere; }

.command-grid { display: grid; grid-template-columns: minmax(0, .86fr) minmax(0, 1.14fr); gap: 16px; align-items: start; }
.update-section { min-width: 0; border: 1px solid var(--line); border-radius: var(--radius-panel); overflow: hidden; background: var(--surface); }
.section-head { min-height: 68px; padding: 15px 17px; border-bottom: 1px solid var(--line); }
.section-head h4 { font-size: 13px; letter-spacing: -.015em; }
.section-head .hint { max-width: 66ch; margin-top: 5px; color: var(--quiet); font-size: 10px; line-height: 1.45; }
form { display: grid; gap: 14px; padding: 17px; }
.form-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(150px, .72fr); gap: 12px; }
label { display: grid; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; }
select, input, textarea {
  width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 10px 11px;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--control);
  outline: none;
  font-size: 12px;
}
select:focus, input:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 2px rgb(104 199 197 / .18); }
input::placeholder, textarea::placeholder { color: #77858a; opacity: 1; }
select { appearance: none; padding-right: 32px; background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%); background-position: calc(100% - 15px) 17px, calc(100% - 10px) 17px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding-top: 4px; }
.info-strip { padding: 12px 13px; border: 1px solid var(--line); border-radius: var(--radius-control); color: var(--muted); background: var(--control); font-family: var(--mono); font-size: 9px; line-height: 1.55; overflow-wrap: anywhere; }

.secret-section { background: var(--surface-strong); }
.secret-head { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.security-note {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  padding: 0 9px;
  border: 1px solid rgb(105 201 151 / .28);
  border-radius: var(--radius-control);
  color: var(--good);
  background: rgb(105 201 151 / .06);
  font-family: var(--mono);
  font-size: 8.5px;
  white-space: nowrap;
}
.secret-console { display: grid; gap: 0; }
.provider-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); border-bottom: 1px solid var(--line); }
.provider-card { min-width: 0; min-height: 112px; display: grid; align-content: start; gap: 8px; padding: 16px 17px; background: var(--surface); }
.provider-card:first-child { border-right: 1px solid var(--line); }
.provider-title { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.provider-title strong { font-size: 12px; }
.provider-title span { display: inline-flex; align-items: center; gap: 6px; color: var(--quiet); font-size: 8.5px; font-weight: 700; }
.provider-dot { width: 6px; height: 6px; display: inline-block; border-radius: 50%; background: var(--neutral); }
.provider-card.connected .provider-dot { background: var(--good); }
.provider-card.disconnected .provider-dot { background: var(--bad); }
.provider-card code { color: var(--muted); font-family: var(--mono); font-size: 10px; overflow-wrap: anywhere; }
.provider-card p { color: var(--quiet); font-size: 9.5px; line-height: 1.45; }
.loading-provider, .secret-loading { color: var(--quiet); font-size: 10px; }
.secret-loading { min-height: 120px; display: grid; place-items: center; padding: 20px; }
.secret-form { gap: 18px; background: var(--surface-strong); }
.secret-fields { display: grid; grid-template-columns: minmax(220px, .78fr) minmax(0, 1.22fr); gap: 12px; }
.secret-target-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
fieldset { min-width: 0; display: grid; gap: 8px; margin: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius-control); }
legend { padding: 0 6px; color: var(--quiet); font-size: 9px; font-weight: 700; }
.check-row { grid-template-columns: 18px minmax(0, 1fr); align-items: start; gap: 9px; padding: 7px 8px; border-radius: 5px; background: var(--control); }
.check-row input, .secret-confirm input { width: 15px; min-width: 15px; min-height: 15px; margin: 1px 0 0; accent-color: var(--accent); }
.check-row span { min-width: 0; display: grid; gap: 3px; }
.check-row strong { color: var(--ink); font-size: 10px; }
.check-row small { color: var(--quiet); font-family: var(--mono); font-size: 8px; overflow-wrap: anywhere; }
.check-row.is-disabled { opacity: .48; }
.environment-options { grid-template-columns: repeat(2, minmax(0, 1fr)); align-content: start; }
.environment-options legend { grid-column: 1 / -1; }
.secret-confirm { grid-template-columns: 18px minmax(0, 1fr); align-items: center; gap: 9px; padding: 11px 12px; border: 1px solid rgb(224 180 93 / .22); border-radius: var(--radius-control); color: var(--muted); background: rgb(224 180 93 / .045); font-size: 9.5px; font-weight: 600; }
.secret-action-row { display: flex; align-items: center; justify-content: space-between; gap: 18px; }
.secret-action-row p { max-width: 62ch; color: var(--quiet); font-size: 9.5px; line-height: 1.45; }
.secret-result { min-height: 40px; display: flex; align-items: center; }
.secret-error { min-height: 150px; display: grid; place-content: center; gap: 6px; padding: 22px; text-align: center; }
.secret-error strong { color: #f2c4c4; }
.secret-error p { color: var(--muted); font-size: 10px; }

.auth-gate { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; padding: 24px; background: rgb(8 12 14 / .88); backdrop-filter: blur(12px); }
.auth-gate[hidden], .auth-card form[hidden] { display: none; }
.auth-card { width: min(420px, 100%); overflow: hidden; border: 1px solid var(--line-strong); border-radius: var(--radius-panel); background: var(--surface); box-shadow: 0 30px 90px rgb(0 0 0 / .44); }
.auth-card > .eyebrow, .auth-card > h2, .auth-card > p { display: block; margin-inline: 22px; }
.auth-card > .eyebrow { margin-top: 22px; color: var(--accent); font-family: var(--mono); font-size: 8px; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; }
.auth-card > h2 { margin-top: 9px; font-size: 20px; letter-spacing: -.035em; }
.auth-card > p { margin-top: 7px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.auth-card form { margin-top: 19px; border-top: 1px solid var(--line); background: var(--surface-strong); }

.loading-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); }
.skeleton {
  min-height: 112px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  position: relative;
  overflow: hidden;
}
.skeleton:last-child { border-right: 0; }
.skeleton::after {
  content: '';
  position: absolute;
  inset: 16px;
  background: linear-gradient(90deg, var(--surface-strong) 0 38%, transparent 38% 48%, var(--surface-strong) 48% 100%);
  opacity: .7;
}
.loading-detail { min-height: 280px; display: grid; place-items: center; border: 1px solid var(--line); border-radius: var(--radius-panel); color: var(--quiet); background: var(--surface); font-size: 11px; }
.error-state { min-height: 220px; display: grid; place-items: center; padding: 28px; border: 1px solid var(--bad); border-radius: var(--radius-panel); color: #f0b1b1; background: rgb(222 121 121 / .08); text-align: center; }
.error-state strong { display: block; margin-bottom: 6px; color: #f2c4c4; }
.error-state p { color: #c99b9b; font-size: 11px; }

.toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 20;
  max-width: min(420px, calc(100vw - 44px));
  display: none;
  padding: 13px 14px;
  border: 1px solid var(--line-strong);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-control);
  color: var(--ink);
  background: var(--surface-strong);
  box-shadow: 0 22px 50px rgb(4 11 13 / .34);
  font-size: 11px;
  line-height: 1.45;
}
.toast.show { display: block; }

@media (prefers-reduced-motion: no-preference) {
  .main-inner { animation: app-in .45s cubic-bezier(.16, 1, .3, 1) both; }
  @keyframes app-in { from { opacity: 0; transform: translateY(10px); } }
}

@media (max-width: 1180px) {
  .main-inner { padding-inline: 22px; }
  .facts-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .fact:nth-child(4n) { border-right: 1px solid var(--line); }
  .fact:nth-child(2n) { border-right: 0; }
  .fact:nth-last-child(-n + 4) { border-bottom: 1px solid var(--line); }
  .fact:nth-last-child(-n + 2) { border-bottom: 0; }
  .command-grid { grid-template-columns: 1fr; }
}

@media (max-width: 820px) {
  .site-chips { padding: 10px 0; }
  .chip { min-width: 156px; }
  .main-inner { padding: 0 16px 36px; }
  .topbar { min-height: 72px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .toolbar .sync-copy { display: none; }
  .environment-options { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .topbar { align-items: flex-start; flex-direction: column; justify-content: center; gap: 12px; padding: 14px 0; }
  .toolbar, .toolbar button { width: 100%; }
  .kpis { grid-template-columns: 1fr; }
  .kpi { border-right: 0; border-bottom: 1px solid var(--line); }
  .kpi:nth-child(2) { border-bottom: 1px solid var(--line); }
  .kpi:last-child { border-bottom: 0; }
  .panel-head { align-items: flex-start; flex-direction: column; padding: 15px 2px; }
  .summary-state { grid-template-columns: 1fr; gap: 10px; }
  .facts-grid, .form-grid { grid-template-columns: 1fr; }
  .fact, .fact:nth-child(2n), .fact:nth-child(4n), .fact:nth-last-child(-n + 2), .fact:nth-last-child(-n + 4) { border-right: 0; border-bottom: 1px solid var(--line); }
  .fact:last-child { border-bottom: 0; }
  .actions { justify-content: stretch; }
  .actions button { flex: 1 1 100%; }
  .secret-head, .secret-action-row { align-items: flex-start; flex-direction: column; }
  .provider-grid, .secret-fields, .secret-target-grid { grid-template-columns: 1fr; }
  .provider-card:first-child { border-right: 0; border-bottom: 1px solid var(--line); }
  .secret-action-row button { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: .001ms !important; }
}
