:root {
  color-scheme: dark;
  --bg: #06111b;
  --surface: rgba(12, 29, 42, .82);
  --surface-2: rgba(19, 40, 55, .78);
  --line: rgba(169, 211, 229, .13);
  --text: #edf7fb;
  --muted: #91aebb;
  --cyan: #4de0d2;
  --blue: #53a8ff;
  --green: #59dc9b;
  --amber: #ffc45c;
  --red: #ff7185;
  --shadow: 0 20px 60px rgba(0, 0, 0, .25);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); min-height: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 0%, rgba(45, 169, 196, .15), transparent 34rem),
    linear-gradient(165deg, #071521 0%, #06111b 52%, #091722 100%);
  padding: env(safe-area-inset-top) max(16px, env(safe-area-inset-right)) calc(34px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.ambient { position: fixed; border-radius: 50%; filter: blur(80px); opacity: .16; pointer-events: none; }
.ambient-one { width: 250px; height: 250px; background: var(--cyan); top: -110px; right: -80px; }
.ambient-two { width: 210px; height: 210px; background: var(--blue); bottom: 8%; left: -120px; }

.topbar {
  position: sticky;
  top: env(safe-area-inset-top);
  z-index: 10;
  max-width: 1120px;
  margin: 0 auto;
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  backdrop-filter: blur(22px);
}
.topbar h1, .section-heading h2, .unlock-card h2 { margin: 2px 0 0; letter-spacing: -.035em; }
.topbar h1 { font-size: clamp(1.5rem, 5vw, 2rem); }
.eyebrow { margin: 0; color: var(--cyan); font-size: .64rem; letter-spacing: .18em; font-weight: 750; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.shell { max-width: 1120px; margin: 0 auto; }
.hero-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0 28px; }
.metric-card, .section-block, .unlock-card {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(18, 42, 57, .9), rgba(8, 23, 35, .86));
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}
.metric-card { min-height: 118px; border-radius: 20px; padding: 16px; display: flex; flex-direction: column; }
.metric-card.accent { border-color: rgba(77, 224, 210, .28); background: linear-gradient(145deg, rgba(21, 70, 75, .82), rgba(8, 30, 39, .9)); }
.metric-card span { color: var(--muted); font-size: .76rem; }
.metric-card strong { font-size: clamp(2rem, 9vw, 3.2rem); line-height: 1; margin: auto 0 5px; }
.metric-card small { color: var(--muted); font-size: .67rem; }

.section-block { border-radius: 24px; padding: 18px; margin: 0 0 16px; }
.section-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 14px; }
.section-heading h2 { font-size: 1.2rem; }
.section-heading time, .section-copy { color: var(--muted); font-size: .72rem; }
.section-copy { margin: -6px 0 16px; line-height: 1.6; }

.machine-list { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 1fr)); gap: 12px; }
.machine-card { border: 1px solid var(--line); border-radius: 18px; background: rgba(4, 16, 25, .55); overflow: hidden; }
.machine-head { padding: 15px; display: flex; justify-content: space-between; gap: 10px; align-items: center; border-bottom: 1px solid var(--line); }
.machine-head h3 { margin: 0; font-size: 1rem; }
.machine-head small { display: block; margin-top: 4px; color: var(--muted); }
.workload { padding: 14px 15px; border-bottom: 1px solid var(--line); }
.workload:last-child { border-bottom: 0; }
.workload-title { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.workload-title strong { font-size: .92rem; }
.workload-title code { color: var(--muted); font-size: .68rem; overflow-wrap: anywhere; }
.facet-grid { margin-top: 12px; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
.facet { min-width: 0; border-radius: 10px; padding: 7px 5px; background: rgba(255,255,255,.035); text-align: center; }
.facet span { display: block; color: var(--muted); font-size: .58rem; overflow: hidden; text-overflow: ellipsis; }
.facet b { display: block; margin-top: 3px; font-size: .64rem; overflow: hidden; text-overflow: ellipsis; }

.pill { display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 9px; font-size: .65rem; font-weight: 750; white-space: nowrap; border: 1px solid currentColor; }
.pill.ok { color: var(--green); background: rgba(89, 220, 155, .08); }
.pill.warning { color: var(--amber); background: rgba(255, 196, 92, .08); }
.pill.danger { color: var(--red); background: rgba(255, 113, 133, .08); }
.pill.neutral { color: var(--muted); background: rgba(145, 174, 187, .06); }
.state-ok, .state-running { color: var(--green); }
.state-warning { color: var(--amber); }
.state-blocked, .state-stopped { color: var(--red); }
.state-stale, .state-unknown, .state-not_observed { color: var(--muted); }

.stack-list { display: grid; gap: 9px; }
.stack-item { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(3, 13, 21, .45); }
.stack-item header { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.stack-item h3 { margin: 0; font-size: .84rem; }
.stack-item p, .stack-item small { color: var(--muted); font-size: .69rem; line-height: 1.5; }
.stack-item p { margin: 7px 0 0; }
.dense .stack-item { padding: 10px 12px; }
.diff-list { margin-top: 9px; border-top: 1px solid var(--line); padding-top: 8px; }
.diff-list summary { color: var(--cyan); cursor: pointer; font-size: .7rem; }
.diff-list p { overflow-wrap: anywhere; }
.empty-state { padding: 22px 12px; color: var(--muted); text-align: center; border: 1px dashed var(--line); border-radius: 14px; font-size: .78rem; }

.compact-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(155px, 1fr)); gap: 10px; align-items: end; }
label { display: grid; gap: 6px; color: var(--muted); font-size: .69rem; }
input, select {
  width: 100%; min-height: 44px; border-radius: 12px; border: 1px solid var(--line);
  background: rgba(2, 12, 20, .75); color: var(--text); padding: 10px 11px; outline: none;
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(77, 224, 210, .1); }
.primary-button, .secondary-button, .icon-button, .text-button {
  border: 0; cursor: pointer; color: var(--text); min-height: 44px; border-radius: 12px; padding: 0 14px;
}
.primary-button { background: linear-gradient(135deg, #1ebdb1, #268cea); color: #021216; font-weight: 800; }
.secondary-button { background: rgba(83, 168, 255, .14); border: 1px solid rgba(83, 168, 255, .35); }
.icon-button, .text-button { background: rgba(255,255,255,.055); border: 1px solid var(--line); }
button:disabled { opacity: .38; cursor: not-allowed; }
.form-message, .error-text { min-height: 1.2em; margin: 9px 0; font-size: .72rem; color: var(--muted); }
.error-text { color: var(--red); }
.draft-editor { border: 1px solid var(--line); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.draft-editor summary { cursor: pointer; font-size: .78rem; font-weight: 700; }
.draft-editor form { margin-top: 14px; }

.unlock-card { max-width: 460px; margin: clamp(30px, 12vh, 110px) auto; border-radius: 28px; padding: 28px; text-align: center; }
.unlock-card p { color: var(--muted); line-height: 1.6; font-size: .78rem; }
.unlock-card form { display: grid; gap: 12px; text-align: left; margin-top: 22px; }
.lock-mark { width: 58px; height: 58px; margin: 0 auto 18px; display: grid; place-items: center; border-radius: 18px; font-size: 1.7rem; color: var(--cyan); border: 1px solid rgba(77,224,210,.3); background: rgba(77,224,210,.08); }

@media (max-width: 620px) {
  .topbar { min-height: 74px; }
  .topbar .eyebrow { display: none; }
  .hero-grid { gap: 7px; }
  .metric-card { min-height: 104px; padding: 13px 11px; border-radius: 17px; }
  .metric-card strong { font-size: 2rem; }
  .section-block { padding: 15px; border-radius: 20px; }
  .facet-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; }
  .facet { padding: 6px 3px; }
  .top-actions { gap: 5px; }
  .text-button { min-height: 40px; padding: 0 9px; font-size: .68rem; }
  .icon-button { min-height: 40px; padding: 0 12px; }
}

@media (prefers-reduced-motion: no-preference) {
  .section-block, .metric-card { animation: rise .38s ease both; }
  @keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
}
