:root {
  color-scheme: dark;
  --bg: #0b0e0d;
  --surface: #111513;
  --surface-2: #161b18;
  --line: #29312d;
  --line-strong: #3b4841;
  --text: #eef3ef;
  --muted: #93a099;
  --faint: #69736d;
  --accent: #d5ef44;
  --accent-ink: #171b08;
  --danger: #ee756a;
  --warning: #d6aa4d;
  --ok: #86c896;
  --radius: 10px;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  --sans: "Segoe UI Variable", "Aptos", "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
  margin: 0;
  min-width: 320px;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 15px;
  line-height: 1.45;
}
button, input, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app-shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100dvh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #0e1210;
  padding: 22px 14px 16px;
}
.brand { display: flex; align-items: center; gap: 12px; padding: 0 8px 26px; }
.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 7px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: var(--mono);
  font-weight: 900;
}
.brand strong, .brand small { display: block; line-height: 1.05; }
.brand strong { letter-spacing: -.03em; }
.brand small { color: var(--muted); font-family: var(--mono); font-size: 10px; letter-spacing: .16em; margin-top: 5px; }
nav { display: grid; gap: 4px; }
.nav-item {
  width: 100%;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted);
  padding: 10px 12px;
  text-align: left;
  cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item.active { background: #20271d; color: var(--accent); font-weight: 650; }
.sidebar-foot { margin-top: auto; display: flex; align-items: center; justify-content: space-between; padding: 12px 8px 0; color: var(--faint); font-family: var(--mono); font-size: 10px; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 0; cursor: pointer; }
.text-button:hover { color: var(--accent); }

.workspace { min-width: 0; padding: 26px 34px 60px; }
.topbar { display: flex; align-items: end; justify-content: space-between; gap: 24px; max-width: 1420px; margin: 0 auto 28px; }
.kicker { margin: 0 0 7px; color: var(--accent); font-family: var(--mono); font-size: 11px; letter-spacing: .12em; }
.topbar h1 { margin: 0; font-size: clamp(30px, 3vw, 44px); line-height: 1; letter-spacing: -.04em; }
.global-state { display: flex; align-items: center; gap: 14px; color: var(--faint); font-family: var(--mono); font-size: 11px; }
.state-chip { border: 1px solid var(--line-strong); border-radius: 999px; padding: 5px 9px; color: var(--muted); }
.state-chip.ok { border-color: color-mix(in srgb, var(--ok), transparent 55%); color: var(--ok); }
.state-chip.bad { border-color: color-mix(in srgb, var(--danger), transparent 55%); color: var(--danger); }
.state-chip.working { border-color: color-mix(in srgb, var(--warning), transparent 55%); color: var(--warning); }

.view { display: none; max-width: 1420px; margin: 0 auto; }
.view.active { display: block; }
.metric-strip { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; margin-bottom: 18px; }
.metric-strip article { min-width: 0; padding: 17px 20px; background: var(--surface); border-right: 1px solid var(--line); }
.metric-strip article:last-child { border: 0; }
.metric-strip span, .form-section-title span, .adapter-controls > span { display: block; color: var(--faint); font-family: var(--mono); font-size: 10px; letter-spacing: .1em; }
.metric-strip strong { display: block; overflow: hidden; text-overflow: ellipsis; margin: 7px 0 2px; font-family: var(--mono); font-size: 21px; white-space: nowrap; }
.metric-strip small { color: var(--muted); }

.overview-grid { display: grid; grid-template-columns: repeat(12, 1fr); gap: 18px; }
.span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; }
.span-7 { grid-column: span 7; }
.span-8 { grid-column: span 8; }
.panel { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 19px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.panel-head h2, .panel h3 { margin: 0; font-size: 15px; letter-spacing: -.01em; }
.panel-head > span { color: var(--faint); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.transport-chain { display: grid; grid-template-columns: 1fr 32px 1fr 32px 1fr 32px 1fr; align-items: center; min-height: 130px; }
.transport-chain div { min-width: 0; padding: 14px 12px; border-left: 2px solid var(--line-strong); }
.transport-chain b, .transport-chain small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.transport-chain b { color: var(--text); font-family: var(--mono); font-size: 12px; }
.transport-chain small { color: var(--muted); margin-top: 8px; }
.transport-chain i { height: 1px; background: var(--line-strong); }
.action-stack { display: grid; gap: 10px; }

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: var(--surface-2);
  color: var(--text);
  padding: 9px 14px;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease, transform .08s ease;
}
.button:hover { border-color: #657369; background: #1d241f; }
.button:active { transform: translateY(1px); }
.button.primary { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); font-weight: 750; }
.button.primary:hover { background: #e1f86a; }
.button.subtle { background: transparent; }
.button.danger { border-color: color-mix(in srgb, var(--danger), transparent 45%); color: var(--danger); background: transparent; }
.button.large { min-height: 48px; padding-inline: 22px; }
.button[disabled] { opacity: .5; cursor: wait; }

.job-list, .service-list, .result-list { display: grid; gap: 1px; background: var(--line); }
.job-row, .service-row, .result-row { display: grid; align-items: center; gap: 12px; min-height: 46px; background: var(--surface); padding: 8px 4px; }
.job-row { grid-template-columns: minmax(120px, 1fr) minmax(100px, 1.5fr) 90px; }
.service-row { grid-template-columns: minmax(100px, 1fr) auto; }
.result-row { grid-template-columns: minmax(160px, 1fr) 130px 100px; }
.job-row b, .service-row b, .result-row b { font-family: var(--mono); font-size: 11px; }
.job-row span, .result-row span { color: var(--muted); }
.row-status { justify-self: end; color: var(--muted); font-family: var(--mono); font-size: 10px; text-transform: uppercase; }
.row-status.succeeded, .row-status.active { color: var(--ok); }
.row-status.failed, .row-status.inactive { color: var(--danger); }
.row-status.running { color: var(--warning); }
.empty-state { color: var(--faint); background: transparent; min-height: 90px; place-content: center; text-align: center; }

.section-intro { margin-bottom: 24px; max-width: 740px; }
.section-intro.with-actions { max-width: none; display: flex; align-items: end; justify-content: space-between; gap: 20px; }
.section-intro h2 { margin: 0 0 8px; font-size: 27px; letter-spacing: -.035em; }
.section-intro p { margin: 0; color: var(--muted); max-width: 68ch; }
.setup-layout { display: grid; gap: 16px; }
.form-section { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; border-top: 1px solid var(--line); padding: 24px 0 10px; }
.form-section-title h3 { margin: 7px 0 0; font-size: 17px; }
.field-grid { display: grid; gap: 16px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
label { display: grid; gap: 7px; color: var(--text); font-size: 13px; font-weight: 650; }
label small { color: var(--faint); font-weight: 400; line-height: 1.35; }
input, select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line-strong);
  border-radius: 7px;
  background: #0d110f;
  color: var(--text);
  padding: 9px 11px;
}
input::placeholder { color: #667169; }
input[type="file"] { padding: 8px; }
.choice-group { grid-column: 2; display: flex; gap: 10px; border: 0; padding: 0; margin: 16px 0 0; }
.choice-group legend { margin-bottom: 8px; color: var(--muted); font-size: 12px; }
.choice { grid-template-columns: auto 1fr; align-items: start; gap: 10px; flex: 1; border: 1px solid var(--line); border-radius: 8px; padding: 12px; cursor: pointer; }
.choice:has(input:checked) { border-color: var(--accent); background: #1a2013; }
.choice input { width: 16px; min-height: auto; margin: 3px 0 0; accent-color: var(--accent); }
.choice b, .choice small { display: block; }
.choice small { margin-top: 3px; }
.conditional-field { grid-column: 2; margin-top: 14px; }
.hidden { display: none !important; }
.form-submit-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; border-top: 1px solid var(--line); padding-top: 20px; }
.form-submit-row p { margin: 0; color: var(--muted); }
.form-error { color: var(--danger); margin: 0; }

.deploy-grid { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(300px, .6fr); gap: 18px; }
.deploy-sequence, .deploy-control { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 22px; }
.deploy-sequence ol { margin: 0; padding: 0; list-style: none; counter-reset: deploy; }
.deploy-sequence li { counter-increment: deploy; display: grid; grid-template-columns: 36px 170px 1fr; gap: 12px; align-items: center; min-height: 58px; border-bottom: 1px solid var(--line); }
.deploy-sequence li:last-child { border: 0; }
.deploy-sequence li::before { content: counter(deploy, decimal-leading-zero); color: var(--accent); font-family: var(--mono); font-size: 11px; }
.deploy-sequence span { color: var(--muted); }
.deploy-control { display: flex; flex-direction: column; justify-content: center; align-items: start; }
.deploy-control h3 { margin: 0; font-size: 24px; letter-spacing: -.03em; }
.deploy-control p { color: var(--muted); }
.deploy-control .button { margin: 10px 0; }
.danger-note { font-size: 12px; }
.job-console { margin-top: 18px; border: 1px solid var(--line-strong); border-radius: var(--radius); overflow: hidden; background: #090c0b; }
.job-console-head { display: flex; align-items: end; justify-content: space-between; padding: 16px 18px; }
.job-console-head span { color: var(--faint); font-family: var(--mono); font-size: 10px; }
.job-console-head h3 { margin: 5px 0 0; }
.job-console-head strong { color: var(--accent); font-family: var(--mono); font-size: 26px; }
.progress-line { height: 2px; background: var(--line); }
.progress-line i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .25s ease; }
.job-console pre, .system-log { margin: 0; max-height: 440px; overflow: auto; background: #080b09; color: #b8c4bc; padding: 17px; font-family: var(--mono); font-size: 11px; line-height: 1.65; white-space: pre-wrap; word-break: break-word; }

.diagnostic-matrix { display: grid; grid-template-columns: repeat(6, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.diagnostic-matrix article { min-width: 0; padding: 18px 14px; border-right: 1px solid var(--line); background: var(--surface); }
.diagnostic-matrix article:last-child { border: 0; }
.diagnostic-matrix span, .diagnostic-matrix strong, .diagnostic-matrix small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.diagnostic-matrix span { color: var(--faint); font-family: var(--mono); font-size: 10px; }
.diagnostic-matrix strong { margin: 10px 0 4px; }
.diagnostic-matrix small { color: var(--muted); }
.diagnostic-matrix article.ok strong { color: var(--ok); }
.diagnostic-matrix article.bad strong { color: var(--danger); }
.diagnostic-notes { margin-top: 18px; }
.diagnostic-notes p { color: var(--muted); max-width: 82ch; margin-bottom: 0; }
.adapter-controls { display: flex; align-items: center; gap: 9px; margin-top: 18px; }
.adapter-controls > span { margin-right: auto; }
.inline-controls { display: flex; gap: 9px; }
.inline-controls select { min-width: 190px; }
.system-log { min-height: 520px; border: 1px solid var(--line); border-radius: var(--radius); }
.result-upload { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 12px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); padding: 18px; margin-bottom: 18px; }
.probe-layout { display: grid; grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); gap: 18px; }
.probe-unavailable p, .probe-steps li { color: var(--muted); }
.probe-share label { margin-top: 4px; }
.probe-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.probe-steps ol { margin: 16px 0 0; padding-left: 22px; }
.probe-steps li { padding: 0 0 12px 5px; }

.toast-region { position: fixed; z-index: 20; right: 22px; top: 22px; display: grid; gap: 8px; max-width: min(420px, calc(100vw - 44px)); }
.toast { border: 1px solid var(--line-strong); border-radius: 8px; background: #171d19; color: var(--text); padding: 12px 14px; box-shadow: 0 18px 44px rgb(0 0 0 / .3); }
.toast.error { border-color: color-mix(in srgb, var(--danger), transparent 30%); }

.login-page { display: grid; place-items: center; padding: 24px; }
.login-shell { display: grid; grid-template-columns: 1.15fr .85fr; width: min(980px, 100%); min-height: 520px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.login-context { display: flex; flex-direction: column; justify-content: center; padding: clamp(34px, 6vw, 72px); background: #0e1310; }
.login-context h1 { max-width: 520px; margin: 0 0 18px; font-size: clamp(36px, 5vw, 64px); line-height: .98; letter-spacing: -.055em; }
.login-context > p:not(.kicker) { max-width: 50ch; color: var(--muted); }
.chain-preview { display: flex; align-items: center; gap: 8px; margin-top: 52px; color: var(--faint); font-family: var(--mono); font-size: 9px; }
.chain-preview i { width: 24px; height: 1px; background: var(--line-strong); }
.login-form-panel { display: flex; flex-direction: column; justify-content: center; padding: clamp(30px, 5vw, 58px); border-left: 1px solid var(--line); }
.login-form { display: grid; gap: 13px; }
.security-note { color: var(--faint); font-size: 12px; margin-top: 18px; }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 190px minmax(0, 1fr); }
  .workspace { padding-inline: 22px; }
  .span-4, .span-5, .span-7, .span-8 { grid-column: span 12; }
  .diagnostic-matrix { grid-template-columns: repeat(3, 1fr); }
  .diagnostic-matrix article:nth-child(3) { border-right: 0; }
  .diagnostic-matrix article:nth-child(-n+3) { border-bottom: 1px solid var(--line); }
}

@media (max-width: 760px) {
  .app-shell { display: block; }
  .sidebar { position: static; width: 100%; height: auto; padding: 12px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { padding-bottom: 12px; }
  .sidebar nav { display: flex; overflow-x: auto; }
  .nav-item { width: auto; white-space: nowrap; }
  .sidebar-foot { display: none; }
  .workspace { padding: 20px 14px 48px; }
  .topbar { align-items: start; }
  .global-state { display: grid; justify-items: end; }
  .metric-strip { grid-template-columns: repeat(2, 1fr); }
  .metric-strip article:nth-child(2) { border-right: 0; }
  .metric-strip article:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .transport-chain { grid-template-columns: 1fr; gap: 8px; }
  .transport-chain i { width: 1px; height: 14px; margin-left: 18px; }
  .form-section { grid-template-columns: 1fr; gap: 16px; }
  .choice-group, .conditional-field { grid-column: 1; }
  .field-grid.two, .deploy-grid, .result-upload, .probe-layout { grid-template-columns: 1fr; }
  .form-submit-row, .section-intro.with-actions { align-items: stretch; flex-direction: column; }
  .deploy-sequence li { grid-template-columns: 30px 1fr; padding-block: 10px; }
  .deploy-sequence li span { grid-column: 2; }
  .diagnostic-matrix { grid-template-columns: repeat(2, 1fr); }
  .diagnostic-matrix article { border-bottom: 1px solid var(--line); }
  .diagnostic-matrix article:nth-child(2n) { border-right: 0; }
  .diagnostic-matrix article:nth-last-child(-n+2) { border-bottom: 0; }
  .adapter-controls { flex-wrap: wrap; }
  .adapter-controls > span { width: 100%; }
  .login-shell { grid-template-columns: 1fr; }
  .login-context { padding: 34px 28px; }
  .chain-preview { margin-top: 26px; flex-wrap: wrap; }
  .login-form-panel { border-left: 0; border-top: 1px solid var(--line); }
}

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