:root {
  --bg: #07111f;
  --sidebar: #0a1624;
  --panel: #0f1f31;
  --panel-soft: #13273b;
  --border: #28445e;
  --text: #f4f8fb;
  --muted: #afbfcb;
  --accent: #35d7f4;
  --accent-2: #33e3be;
  --green: #43dda2;
  --yellow: #f5c451;
  --red: #ff6f7d;
  --shadow: 0 18px 50px rgba(0,0,0,.22);
  --radius: 16px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html { color-scheme: dark; font-size: 17px; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
button, input, textarea, select { font: inherit; }
button { cursor: pointer; }
a { color: inherit; }

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 20px;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 26px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--border);
}
.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #031017;
  font-weight: 950;
  font-size: 1.2rem;
}
.brand h1 { margin: 0; font-size: 1.05rem; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: .9rem; }

nav { display: grid; gap: 8px; }
.nav-link {
  width: 100%;
  border: 0;
  border-radius: 11px;
  padding: 13px 14px;
  background: transparent;
  color: var(--muted);
  text-align: left;
  font-size: 1rem;
  font-weight: 750;
}
.nav-link:hover,
.nav-link.active {
  background: rgba(53,215,244,.12);
  color: var(--text);
}

.system-card {
  margin-top: auto;
  display: flex;
  gap: 11px;
  align-items: center;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255,255,255,.025);
}
.system-card strong { display: block; font-size: .95rem; }
.system-card small { display: block; margin-top: 2px; color: var(--muted); font-size: .88rem; }
.live-dot {
  width: 11px;
  height: 11px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 14px rgba(67,221,162,.7);
}
.live-dot.bad { background: var(--red); box-shadow: 0 0 14px rgba(255,111,125,.65); }

.workspace {
  min-width: 0;
  padding: 28px clamp(24px, 4vw, 56px) 64px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.topbar h2 { margin: 0; font-size: clamp(1.8rem, 3vw, 2.35rem); }
.topbar p { margin: 7px 0 0; color: var(--muted); font-size: 1rem; }

.view { display: none; }
.view.active { display: block; }

button.primary,
button.secondary,
button.ghost {
  min-height: 46px;
  padding: 11px 16px;
  border-radius: 10px;
  font-size: .98rem;
  font-weight: 850;
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}
button.primary {
  border: 1px solid transparent;
  color: #031017;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
}
button.secondary {
  border: 1px solid var(--border);
  background: #12263a;
  color: var(--text);
}
button.ghost,
a.ghost {
  border: 1px solid #35637f;
  background: rgba(53,215,244,.05);
  color: var(--text);
  text-decoration: none;
}
button:hover,
a.ghost:hover { transform: translateY(-1px); }
button:disabled { opacity: .55; cursor: wait; transform: none; }

.welcome-card {
  margin-top: 26px;
  padding: clamp(24px, 4vw, 42px);
  border: 1px solid var(--border);
  border-radius: 18px;
  background: linear-gradient(135deg, #10253a, #0b1a2a);
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
}
.welcome-card h3 { margin: 7px 0 8px; font-size: clamp(1.65rem, 3vw, 2.6rem); line-height: 1.12; }
.welcome-card p { margin: 0; max-width: 760px; color: var(--muted); font-size: 1.05rem; }
.big-action { min-width: 170px; }

.kicker {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .09em;
  font-size: .88rem;
  font-weight: 900;
}

.metric-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.metric-card {
  min-height: 138px;
  padding: 19px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
}
.metric-card span { display: block; color: var(--muted); font-size: .95rem; font-weight: 750; }
.metric-card strong { display: block; margin: 5px 0; color: var(--accent); font-size: 1.85rem; }
.metric-card small { color: var(--muted); font-size: .9rem; }

.simple-grid,
.section-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.two-one { grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr); }

.card {
  padding: 22px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}
.card h3 { margin: 0 0 10px; font-size: 1.25rem; }
.card-copy { margin: 8px 0 0; color: var(--muted); font-size: 1rem; }

.plain-flow {
  margin: 18px 0 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
.plain-flow span {
  padding: 9px 12px;
  border-radius: 9px;
  border: 1px solid var(--border);
  background: var(--panel-soft);
  font-weight: 800;
}
.plain-flow i { color: var(--accent); font-style: normal; font-size: 1.1rem; }

.section-heading-simple {
  margin-top: 26px;
  margin-bottom: 16px;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 20px;
}
.section-heading-simple h3 { margin: 5px 0 0; font-size: 1.5rem; }
.section-heading-simple p { margin: 7px 0 0; max-width: 780px; color: var(--muted); font-size: 1rem; }

.wide-form { max-width: 980px; margin: 26px auto 0; }
.form-card { padding: 26px; }
.studio-form { display: grid; gap: 18px; margin-top: 18px; }
.studio-form label {
  display: grid;
  gap: 7px;
  color: #e5eef4;
  font-size: 1rem;
  font-weight: 800;
}
.studio-form input,
.studio-form textarea,
.studio-form select {
  width: 100%;
  min-height: 48px;
  padding: 12px 13px;
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  background: #081522;
  color: var(--text);
  font-size: 1rem;
}
.studio-form textarea { min-height: 125px; resize: vertical; line-height: 1.55; }
.studio-form input:focus,
.studio-form textarea:focus,
.studio-form select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(53,215,244,.09);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.studio-form fieldset {
  margin: 0;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
}
.studio-form legend { padding: 0 6px; font-size: 1rem; font-weight: 850; }
.studio-form .check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 7px 18px 7px 0;
  font-size: 1rem;
  font-weight: 650;
}
.studio-form .check input { width: 19px; min-height: 19px; height: 19px; }
.optional { color: var(--muted); font-size: .9rem; font-weight: 600; }
.file-choices { color: var(--muted); font-size: .98rem; line-height: 1.6; }
.form-actions { display: flex; gap: 12px; flex-wrap: wrap; }
.big-actions button { min-width: 150px; min-height: 50px; }

.result-box {
  margin-top: 18px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: #081522;
  color: var(--text);
  font-size: .98rem;
}
.result-box.muted { color: var(--muted); }

.stack-list { display: grid; gap: 14px; margin-top: 16px; }
.stack-item {
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 13px;
  background: var(--panel);
}
.stack-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
}
.stack-top h4 { margin: 0; font-size: 1.15rem; }
.stack-top p { margin: 6px 0 0; color: var(--muted); font-size: .98rem; line-height: 1.5; }
.state-chip {
  flex: 0 0 auto;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: #0b1a29;
  font-size: .9rem;
  font-weight: 850;
}
.state-chip[data-state="failed"] { color: #ffd9dd; border-color: rgba(255,111,125,.5); background: rgba(255,111,125,.08); }
.state-chip[data-state="running"],
.state-chip[data-state="queued"] { color: #dafbff; border-color: rgba(53,215,244,.45); background: rgba(53,215,244,.08); }
.state-chip[data-state="delivered"],
.state-chip[data-state="approved"] { color: #ddfff2; border-color: rgba(67,221,162,.45); background: rgba(67,221,162,.08); }
.stack-meta {
  margin-top: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 9px 14px;
  color: var(--muted);
  font-size: .9rem;
}
.stack-actions { margin-top: 15px; display: flex; flex-wrap: wrap; gap: 10px; }
.stack-actions a.ghost { display: inline-flex; align-items: center; min-height: 44px; padding: 9px 13px; border-radius: 9px; font-weight: 800; }
.project-alert {
  margin-top: 13px;
  padding: 11px 13px;
  border-radius: 9px;
  border: 1px solid rgba(255,111,125,.42);
  background: rgba(255,111,125,.08);
  color: #ffdfe3;
  font-size: .95rem;
}
.empty-state {
  padding: 22px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  color: var(--muted);
  font-size: 1rem;
  text-align: center;
}

.offer-grid {
  margin-top: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.offer-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: #0b1a29;
}
.offer-card.selected { border-color: var(--accent); }
.offer-card h4 { margin: 0 0 12px; font-size: 1rem; }

summary { cursor: pointer; font-weight: 850; font-size: 1rem; }
.large-status { margin: 8px 0 0; color: var(--accent); font-size: 1.2rem; font-weight: 850; }
.top-gap { margin-top: 18px; }
.help-card { align-self: start; }

.toast {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 20;
  max-width: min(520px, calc(100vw - 48px));
  padding: 15px 18px;
  border: 1px solid #35637f;
  border-radius: 11px;
  background: #0b1b2a;
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 1rem;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: .18s ease;
}
.toast.show { opacity: 1; transform: none; }

@media (max-width: 1000px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 16px;
    gap: 14px;
  }
  .brand { padding-bottom: 14px; }
  nav { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .nav-link { text-align: center; padding: 11px 8px; }
  .system-card { margin-top: 0; }
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-one { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  html { font-size: 16px; }
  .workspace { padding: 20px 15px 44px; }
  .topbar,
  .welcome-card,
  .section-heading-simple,
  .stack-top { align-items: stretch; flex-direction: column; }
  nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .metric-grid,
  .simple-grid,
  .section-grid,
  .form-row { grid-template-columns: 1fr; }
  .metric-card { min-height: 112px; }
  .welcome-card { padding: 24px; }
  .form-card,
  .card { padding: 18px; }
  .topbar > button { width: 100%; }
}
