:root {
  color-scheme: light;
  --ink: #17211d;
  --muted: #5c6963;
  --line: #d8ded6;
  --field: #f7f9f5;
  --panel: #ffffff;
  --brand: #1f6f5b;
  --brand-dark: #13483d;
  --accent: #d98b2b;
  --warning: #b86b00;
  --danger: #b83a2f;
  --ok: #207a4b;
  --bg: #eef2ec;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: 6px;
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  font-weight: 700;
}

button:hover {
  background: var(--brand-dark);
}

a {
  color: var(--brand);
  font-weight: 700;
  text-decoration: none;
}

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(16, 33, 28, .86), rgba(16, 33, 28, .38)),
    url("https://images.unsplash.com/photo-1500530855697-b586d89ba3ee?auto=format&fit=crop&w=1800&q=80") center/cover;
}

.login-shell {
  width: min(520px, 100%);
  padding: 32px;
  border-radius: 8px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .22);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-lockup.compact {
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 54px;
  height: 54px;
  place-items: center;
  border-radius: 7px;
  background: var(--brand);
  color: #fff;
  font-weight: 900;
}

.compact .brand-mark {
  width: 42px;
  height: 42px;
  font-size: 14px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 38px;
  line-height: 1;
}

h2 {
  margin-bottom: 8px;
  font-size: 36px;
  line-height: 1.08;
}

h3 {
  margin-bottom: 0;
  font-size: 20px;
}

.login-copy {
  margin: 24px 0;
  color: var(--muted);
  font-size: 17px;
}

.login-form,
.publish-form {
  display: grid;
  gap: 12px;
}

.login-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
}

input {
  min-height: 44px;
  padding: 0 12px;
}

select {
  min-height: 78px;
  padding: 8px;
}

.login-form button,
.publish-form button {
  min-height: 44px;
}

.form-hint {
  margin: 0;
  color: var(--muted, #6b7280);
  font-size: 13px;
}

.form-error {
  min-height: 20px;
  margin: 0;
  color: var(--danger);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px clamp(16px, 4vw, 48px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.topbar h1 {
  font-size: 20px;
}

.topbar nav {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar button {
  min-height: 36px;
  padding: 0 14px;
  background: #26352f;
}

main {
  padding-bottom: 36px;
}

.hero-band {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 430px);
  gap: 28px;
  align-items: stretch;
  padding: 34px clamp(16px, 4vw, 48px);
  background: linear-gradient(135deg, #eaf3ee, #fff8ec);
  border-bottom: 1px solid var(--line);
}

.hero-band > div:first-child {
  align-self: center;
}

.hero-band p {
  color: var(--muted);
}

.publish-panel,
.panel,
.kpi-grid article {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.publish-panel {
  padding: 18px;
}

.publish-panel strong {
  display: block;
  margin-bottom: 14px;
  font-size: 24px;
}

.publish-form {
  grid-template-columns: 1fr 1.3fr 86px;
}

.publish-form select,
.publish-form button {
  grid-column: 1 / -1;
}

.panel-note {
  min-height: 18px;
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 48px);
}

.kpi-grid article {
  min-height: 126px;
  padding: 18px;
}

.kpi-grid span,
.node-meta,
.panel-heading span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.kpi-grid strong {
  display: block;
  margin: 8px 0;
  font-size: 34px;
}

.kpi-grid small {
  color: var(--muted);
  font-weight: 700;
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(310px, .85fr);
  gap: 16px;
  padding: 0 clamp(16px, 4vw, 48px);
}

.panel {
  min-width: 0;
  padding: 18px;
}

.alert-panel {
  grid-column: 1 / -1;
}

.panel-heading {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.rollout-list,
.ranch-list,
.alert-list {
  display: grid;
  gap: 12px;
}

.rollout-item,
.ranch-item,
.alert-item {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
}

.item-row,
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.item-row {
  align-items: start;
}

.item-row strong {
  word-break: break-word;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  background: #dfe8e2;
  color: var(--brand-dark);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.badge.warning {
  background: #ffe6c2;
  color: var(--warning);
}

.badge.danger {
  background: #f7d8d5;
  color: var(--danger);
}

.progress {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dbe2da;
}

.progress span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.node-list {
  display: grid;
  gap: 8px;
}

.node-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding-top: 8px;
  border-top: 1px solid var(--line);
}

.empty-state {
  margin: 0;
  color: var(--muted);
  font-weight: 700;
}

.intel-band {
  display: grid;
  grid-template-columns: minmax(280px, .82fr) minmax(0, 1.18fr);
  gap: 16px;
  padding: 22px clamp(16px, 4vw, 48px) 0;
}

.health-body {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}

.health-score {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.health-score strong {
  font-size: 56px;
  line-height: 1;
  font-weight: 900;
}

.health-score span {
  color: var(--muted);
  font-size: 16px;
  font-weight: 800;
}

.health-spark {
  width: 160px;
  height: 48px;
  flex: none;
}

.spark-line {
  fill: none;
  stroke-width: 2.5;
  stroke-linejoin: round;
  stroke-linecap: round;
  vector-effect: non-scaling-stroke;
}

.spark-area {
  opacity: .14;
  stroke: none;
}

.spark-flat {
  stroke: var(--line);
  stroke-width: 2;
}

.health-factors {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-top: 16px;
}

.factor {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--field);
}

.factor span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.factor strong {
  font-size: 18px;
}

.factor.ok strong { color: var(--ok); }
.factor.warning strong { color: var(--warning); }
.factor.danger strong { color: var(--danger); }

.spotlight-list {
  display: grid;
  gap: 12px;
}

.spotlight-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: start;
  padding: 14px;
  border: 1px solid var(--line);
  border-left-width: 4px;
  border-radius: 7px;
  background: var(--field);
}

.spotlight-item.danger { border-left-color: var(--danger); }
.spotlight-item.warning { border-left-color: var(--warning); }
.spotlight-item.ok { border-left-color: var(--ok); }

.spotlight-rank {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #dfe8e2;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 900;
}

.spotlight-item.danger .spotlight-rank { background: #f7d8d5; color: var(--danger); }
.spotlight-item.warning .spotlight-rank { background: #ffe6c2; color: var(--warning); }
.spotlight-item.ok .spotlight-rank { background: #d3ecdc; color: var(--ok); }

.spotlight-item strong {
  display: block;
  margin-bottom: 3px;
}

.spotlight-item p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.map-band {
  padding: 22px clamp(16px, 4vw, 48px) 0;
}

.map-panel {
  padding: 18px;
}

#fleet-map {
  height: 380px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #dfe6df;
  z-index: 0;
}

.wave-status {
  padding: 4px 12px;
  border-radius: 999px;
  background: #dfe8e2;
  color: var(--brand-dark);
  font-size: 13px;
  font-weight: 800;
  white-space: nowrap;
}

.wave-status.warning {
  background: #ffe6c2;
  color: var(--warning);
}

.wave-status.danger {
  background: #f7d8d5;
  color: var(--danger);
}

.wave-status.ok {
  background: #d3ecdc;
  color: var(--ok);
}

.map-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
}

.wave-counters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--field);
  border: 1px solid var(--line);
  font-size: 13px;
  font-weight: 700;
  color: var(--muted);
}

.chip strong {
  color: var(--ink);
  font-size: 15px;
}

.chip.ok strong {
  color: var(--ok);
}

.chip.danger strong {
  color: var(--danger);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.map-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px var(--line);
}

.dot-ok { background: #207a4b; }
.dot-pending { background: #d98b2b; }
.dot-danger { background: #b83a2f; }
.dot-offline { background: #8a948f; }

.map-popup strong {
  display: block;
  margin-bottom: 4px;
}

.map-popup div {
  color: var(--muted);
  font-size: 12px;
}

.marker-pulse {
  transform-box: fill-box;
  transform-origin: center;
  animation: marker-pulse 0.9s ease-out 1;
}

@keyframes marker-pulse {
  0% { transform: scale(1); }
  40% { transform: scale(1.7); }
  100% { transform: scale(1); }
}

.ranch-focus {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  transition: outline-color 0.3s ease;
}

.chaos-band {
  padding: 22px clamp(16px, 4vw, 48px) 0;
}

.chaos-panel {
  padding: 18px;
}

.chaos-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-top: 14px;
}

.chaos-action {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--field);
}

.chaos-controls {
  display: flex;
  gap: 8px;
}

.chaos-controls select {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.chaos-btn {
  padding: 8px 14px;
  white-space: nowrap;
}

.chaos-btn.danger {
  background: var(--danger);
}

.chaos-btn.danger:hover {
  background: #8f2b22;
}

.chaos-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 900px) {
  .chaos-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px) {
  .hero-band,
  .content-grid,
  .intel-band,
  .kpi-grid {
    grid-template-columns: 1fr;
  }

  .topbar {
    position: static;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar nav {
    width: 100%;
    justify-content: space-between;
  }
}

@media (max-width: 560px) {
  .login-shell {
    padding: 22px;
  }

  h1 {
    font-size: 31px;
  }

  h2 {
    font-size: 28px;
  }

  .publish-form,
  .node-row,
  .item-row,
  .metric-row {
    grid-template-columns: 1fr;
    flex-direction: column;
  }

  .publish-form {
    display: grid;
  }

  .health-factors {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-lockup {
    align-items: flex-start;
  }
}
