:root {
  --navy: #0b1f3a;
  --teal: #00c2a8;
  --teal-deep: #00a892;
  --ink: #0b1f3a;
  --muted: #5c6b7a;
  --paper: #f4f7fb;
  --card: #ffffff;
  --line: #e4eaf1;
  --foam: #e7f8f5;
  --copper: #0b1f3a;
  --copper-soft: #e7f3f1;
  --good: #0d7a62;
  --good-soft: #e5f7f3;
  --warn: #8a5a12;
  --warn-soft: #f8efd8;
  --bad: #9b3030;
  --bad-soft: #fdecec;
  --info: #1554a0;
  --info-soft: #e7f0fb;
  --shadow: none;
  --sans: "Segoe UI", "Avenir Next", "Helvetica Neue", sans-serif;
  --radius: 12px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--sans);
  color: var(--ink);
  background: var(--paper);
  line-height: 1.45;
}
button, input, select, textarea { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--teal); outline-offset: 2px; }
.skip {
  position: absolute;
  left: 12px;
  top: -40px;
  background: white;
  padding: 8px 12px;
  z-index: 5;
}
.skip:focus { top: 12px; }

.boot-wrap { min-height: 100vh; display: grid; place-items: center; }
.boot { color: var(--muted); }

.auth {
  min-height: 100vh;
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(340px, 0.95fr);
  background: #fff;
}
.auth-story {
  background: #f7f9fb;
  color: var(--navy);
  padding: 48px 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  gap: 0;
  border-right: 1px solid var(--line);
}
.auth-story-inner {
  width: min(420px, 100%);
  margin: 0;
}
.brand-lockup { display: flex; gap: 12px; align-items: center; color: inherit; text-decoration: none; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-lockup strong { display: block; font-size: 17px; letter-spacing: -0.02em; color: var(--navy); }
.brand-lockup span { color: var(--muted); font-size: 13px; }
.auth-story h1 {
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 40px);
  line-height: 1.12;
  letter-spacing: -0.03em;
  margin: 28px 0 14px;
  max-width: 16ch;
}
.auth-story-inner > p {
  max-width: 38ch;
  color: var(--muted);
  font-size: 16px;
  font-weight: 450;
  margin: 0;
  line-height: 1.5;
}
.roster {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
  border-top: 1px solid var(--line);
}
.roster li {
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  border-radius: 0;
  padding: 14px 0;
  box-shadow: none;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 12px;
}
.roster li:nth-child(even) { padding-left: 0; }
.roster strong { display: block; color: var(--navy); font-size: 14px; font-weight: 650; }
.roster span, .form .roster .muted { color: var(--muted); font-size: 13px; font-weight: 450; }
.form .roster { grid-template-columns: 1fr; }
.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: stretch;
  padding: 48px 56px;
  background: #fff;
}
.auth-panel .panel-card {
  width: min(380px, 100%);
}
.panel-card {
  width: min(380px, 100%);
  margin: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  padding: 0;
}
.panel-card h2 { font-size: 26px; margin: 0 0 8px; letter-spacing: -0.02em; font-weight: 700; }
.lede { color: var(--muted); margin: 0 0 20px; font-size: 15px; }
.auth-panel .form { max-width: 380px; }
.auth-panel .form .primary { width: 100%; border-radius: 10px; }
.auth-foot {
  margin-top: 18px;
  font-size: 13px;
  color: var(--muted);
}

.layout { min-height: 100vh; display: grid; grid-template-columns: 72px 1fr; }
.side, .side.icon-rail {
  background: var(--navy);
  color: #d7e0ea;
  border-right: 0;
  padding: 16px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}
.side .brand-lockup {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
}
.side .brand-mark { width: 28px; height: 28px; }
.side .brand-lockup strong, .side .brand-lockup span { display: none; }
.workspace-label { display: grid; gap: 6px; font-size: 12px; color: var(--muted); font-weight: 650; }
.top-lead .workspace-label { margin-top: 6px; max-width: 220px; }
.top-lead select.workspace-pick {
  background-color: white;
  color: var(--navy);
  border-color: var(--line);
  font-weight: 500;
  /* keep chevron from select.workspace-pick — never reset background shorthand */
}
.side nav {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}
.side nav a.nav-item,
.side .logout-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #9fb0c3;
  text-decoration: none;
  border-radius: 12px;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  position: relative;
}
.side nav a.nav-item:hover,
.side .logout-btn:hover { background: rgba(255,255,255,0.08); color: #fff; }
.side nav a.nav-item[aria-current="page"] {
  background: rgba(0, 194, 168, 0.18);
  color: var(--teal);
  box-shadow: none;
}
.nav-icon { width: 20px; height: 20px; display: block; }
.nav-label {
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: var(--navy);
  color: #fff;
  font-size: 12px;
  font-weight: 650;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.12s ease;
  z-index: 5;
  box-shadow: 0 4px 14px rgba(11, 31, 58, 0.2);
}
.side nav a.nav-item:hover .nav-label,
.side nav a.nav-item:focus-visible .nav-label { opacity: 1; }
.side-foot {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  color: #9fb0c3;
  font-size: 13px;
  width: 100%;
}
.user-chip {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}
.side-foot button.logout-btn { color: #9fb0c3; }
.main { padding: 28px 32px 48px; min-width: 0; background: var(--paper); }
.top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 20px;
}
.top-lead { display: grid; gap: 4px; min-width: 0; }
.top h1 { font-size: 30px; margin: 0; font-weight: 720; letter-spacing: -0.03em; color: var(--navy); }
.status-pill {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 700;
  background: var(--good-soft);
  color: var(--good);
  border: 1px solid #cfece5;
  white-space: nowrap;
  flex: none;
}
.status-pill.warn { background: var(--warn-soft); color: var(--warn); border-color: #ecd7a8; }
.status-pill.bad { background: var(--bad-soft); color: var(--bad); border-color: #efc7c3; }
.status-pill.good { background: var(--good-soft); color: var(--good); border-color: #cfece5; }
.budget { min-width: 220px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.budget .row { display: flex; justify-content: space-between; font-size: 13px; color: var(--muted); }
.meter { height: 8px; background: var(--foam); border-radius: 99px; overflow: hidden; margin-top: 8px; }
.meter i { display: block; height: 100%; background: var(--teal); width: 0; }
.meter i.warn { background: var(--warn); }
.meter i.bad { background: var(--bad); }

/* Dashboard home */
.metric-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 12px;
}
.metric-card, .dash-panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: none;
  padding: 16px 18px;
}
.metric-card {
  padding: 12px 14px;
  border-radius: 12px;
}
.metric-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.metric-card .muted { margin: 0; font-size: 12px; font-weight: 650; letter-spacing: 0.01em; }
.metric-value {
  margin: 6px 0 4px;
  font-size: 26px;
  font-weight: 750;
  letter-spacing: -0.03em;
  color: var(--navy);
  line-height: 1;
}
.metric-card .help { margin: 0; font-size: 12px; color: var(--muted); }
.metric-ico {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: var(--foam);
  color: var(--teal);
  position: relative;
  flex: none;
}
.metric-ico::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1.5px solid currentColor;
  border-radius: 3px;
}
.metric-ico.ico-team::before { border-radius: 999px; inset: 6px 4px 4px; border-bottom-width: 0; box-shadow: 0 -4px 0 -1px currentColor; }
.metric-ico.ico-shield::before {
  inset: 4px 6px 5px;
  border-radius: 4px 4px 10px 10px;
  clip-path: polygon(50% 0, 100% 18%, 100% 62%, 50% 100%, 0 62%, 0 18%);
  border: 0;
  background: currentColor;
  opacity: 0.85;
}
.dash-split {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 14px;
  align-items: stretch;
  margin-bottom: 8px;
}
.dash-panel h2 {
  margin: 0 0 6px;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: var(--navy);
}
.dash-lede { margin: 0 0 16px; font-size: 13px; }
.pipeline-track {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0;
  overflow-x: auto;
  padding: 4px 0 2px;
}
.pipeline-step {
  display: grid;
  justify-items: center;
  text-align: center;
  gap: 6px;
  min-width: 88px;
  flex: 1;
}
.pipeline-step strong { font-size: 13px; color: var(--navy); }
.pipeline-step .muted { font-size: 12px; }
.pipeline-dot {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: var(--foam);
  color: var(--teal-deep);
  font-weight: 750;
  border: 1px solid #cfece5;
}
.pipeline-step.paused .pipeline-dot {
  background: var(--warn-soft);
  color: var(--warn);
  border-color: #ecd7a8;
}
.pipeline-line {
  flex: 0 0 28px;
  height: 0;
  border-top: 2px dashed #c9d5e2;
  margin-top: 20px;
  align-self: flex-start;
}
.pipeline-pips { display: flex; gap: 4px; }
.pipeline-pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  display: block;
}
.pipeline-step.paused .pipeline-pips i { background: #d0b57a; }
.status-list {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  gap: 0;
}
.status-list li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.status-list li:last-child { border-bottom: 0; }
.status-copy { display: grid; gap: 2px; min-width: 0; }
.status-copy strong { font-size: 14px; color: var(--navy); }
.status-copy .muted { font-size: 12px; }
.panel-link {
  display: inline-block;
  margin-top: 8px;
  color: var(--navy);
  font-weight: 650;
  text-decoration: none;
  font-size: 14px;
}
.panel-link:hover { color: var(--teal-deep); }
.dash-actions { margin: 14px 0 4px; }
.banner {
  background: var(--bad-soft);
  color: var(--bad);
  border: 1px solid #efc7c3;
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 16px;
}
.banner.warn { background: var(--warn-soft); color: var(--warn); border-color: #ecd7a8; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card, .agent, .stack-card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: none;
  padding: 16px;
}
.agent header, .split { display: flex; gap: 12px; align-items: center; }
.agent h2, .card h2, .stack-card h2 { margin: 0; font-size: 20px; }
.avatar {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  color: white; font-weight: 700; flex: none;
}
.muted { color: var(--muted); }
.summary { min-height: 2.8em; }
.stats-line { display: flex; gap: 16px; margin: 8px 0 12px; }
.stats-line div { background: var(--foam); border-radius: 12px; padding: 8px 10px; min-width: 90px; }
.stats-line dt { font-size: 12px; color: var(--muted); }
.stats-line dd { margin: 0; font-weight: 650; }
.actions, .row { display: flex; flex-wrap: wrap; gap: 8px; }
a.button, button, .button {
  border-radius: 999px;
  border: 1px solid var(--line);
  background: white;
  padding: 8px 14px;
  text-decoration: none;
  color: var(--ink);
  cursor: pointer;
}
button.primary, .button.primary { background: var(--teal); color: var(--navy); border-color: var(--teal); font-weight: 700; }
button.primary:hover, .button.primary:hover { background: var(--teal-deep); border-color: var(--teal-deep); }
button.danger, .button.danger { background: var(--bad); color: white; border-color: var(--bad); }
button.ghost { background: transparent; }
button:disabled { opacity: 0.6; cursor: progress; }
label { display: grid; gap: 6px; font-size: 14px; font-weight: 650; }
input, select, textarea {
  width: 100%;
  border: 1px solid #d5d0c6;
  background: white;
  border-radius: 12px;
  padding: 10px 12px;
  font-weight: 450;
}
select,
select.workspace-pick {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230B1F3A' d='M1.1 1.2a1 1 0 0 1 1.4 0L6 4.7l3.5-3.5a1 1 0 1 1 1.4 1.4L6.7 6.9a1 1 0 0 1-1.4 0L1.1 2.6a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
  cursor: pointer;
}
.side select.workspace-pick {
  background-color: white;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%230B1F3A' d='M1.1 1.2a1 1 0 0 1 1.4 0L6 4.7l3.5-3.5a1 1 0 1 1 1.4 1.4L6.7 6.9a1 1 0 0 1-1.4 0L1.1 2.6a1 1 0 0 1 0-1.4z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  background-size: 12px 8px;
}
textarea { min-height: 110px; resize: vertical; }

/* Pill switch checkboxes (settings clear-key / kill / paused) */
label:has(> input[type="checkbox"]) {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  grid-template-columns: none;
}
input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 48px;
  min-width: 48px;
  height: 28px;
  margin: 0;
  padding: 0;
  border: 1px solid #c5d0dc;
  border-radius: 999px;
  background: #e8eef4;
  box-shadow: inset 0 1px 2px rgba(11, 31, 58, 0.06);
  cursor: pointer;
  position: relative;
  flex: none;
  transition: background 0.18s ease, border-color 0.18s ease;
}
input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 1px 4px rgba(11, 31, 58, 0.18);
  transition: transform 0.18s ease;
}
input[type="checkbox"]:checked {
  background: var(--teal);
  border-color: var(--teal-deep);
}
input[type="checkbox"]:checked::after {
  transform: translateX(20px);
}
input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}
.form { display: grid; gap: 12px; }
.form-error { color: var(--bad); margin: 0; }
.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters button[aria-pressed="true"] { background: var(--teal); color: var(--navy); border-color: var(--teal); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; background: var(--card); border-radius: 16px; }
th, td { text-align: left; padding: 12px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: 12px; letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
.pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 3px 8px;
  font-size: 12px; font-weight: 700; background: var(--foam); color: var(--ink);
}
.pill.queued { background: #eceae4; }
.pill.in_progress { background: var(--info-soft); color: var(--info); }
.pill.waiting_human { background: var(--copper-soft); color: var(--copper); }
.pill.blocked { background: var(--bad-soft); color: var(--bad); }
.pill.done { background: var(--good-soft); color: var(--good); }
.pill.cancelled { background: #eceae4; color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.timeline li { border-left: 3px solid var(--line); padding: 4px 0 4px 12px; }
.timeline time { display: block; color: var(--muted); font-size: 12px; }
.thread { display: grid; gap: 10px; margin: 12px 0; }
.bubble { max-width: 70ch; padding: 10px 12px; border-radius: 14px; background: white; border: 1px solid var(--line); }
.bubble.user { background: var(--navy); color: white; border-color: var(--navy); margin-left: auto; }
.layout-chat { display: grid; grid-template-columns: 220px 1fr; gap: 16px; }
.people { display: grid; gap: 6px; align-content: start; }
.people a { text-decoration: none; color: inherit; padding: 8px 10px; border-radius: 12px; border: 1px solid transparent; }
.people a[aria-current="page"] { background: white; border-color: var(--line); }
.mail-block { display: grid; gap: 10px; }
.draft { white-space: pre-wrap; background: var(--paper); border-radius: 12px; padding: 10px; }
.bars { display: grid; gap: 8px; }
.bar-row { display: grid; grid-template-columns: 140px 1fr auto; gap: 8px; align-items: center; }
.bar { height: 10px; background: var(--foam); border-radius: 99px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--info); }
.section-title { margin: 22px 0 10px; font-size: 13px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.price-table input { min-width: 0; }
.help { font-weight: 500; color: #445566; font-size: 14px; }
.empty { padding: 28px 8px; color: var(--muted); }
.mono { font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace; font-size: 13px; }


/* In-app modal + toast (replaces alert/confirm) */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  background: rgba(11, 31, 58, 0.45);
  display: grid;
  place-items: center;
  padding: 20px;
}
.modal {
  width: min(420px, 100%);
  background: white;
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: 0 24px 48px rgba(11, 31, 58, 0.18);
  padding: 22px 20px 18px;
  display: grid;
  gap: 14px;
}
.modal-title { margin: 0; font-size: 20px; letter-spacing: -0.02em; color: var(--navy); }
.modal-body { margin: 0; color: #334455; font-size: 15px; display: grid; gap: 10px; }
.modal-body p { margin: 0; }
.modal-input { width: 100%; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

.toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 50;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  pointer-events: auto;
  background: white;
  border: 1px solid var(--line);
  border-left: 4px solid var(--bad);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 12px 14px;
  color: var(--ink);
  font-size: 14px;
  font-weight: 550;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  cursor: pointer;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast-bad { border-left-color: var(--bad); background: var(--bad-soft); color: var(--bad); }
.toast-warn { border-left-color: var(--warn); background: var(--warn-soft); color: var(--warn); }
.toast-good { border-left-color: var(--good); background: var(--good-soft); color: var(--good); }
.toast-info { border-left-color: var(--info); background: var(--info-soft); color: var(--info); }

@media (max-width: 900px) {
  .auth, .layout-chat, .grid, .two, .metric-row, .dash-split { grid-template-columns: 1fr; }
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }
  .layout, .side, .main, .view, .card, .form, .table-wrap { min-width: 0; max-width: 100%; }
  .auth-story, .auth-panel { padding: 32px 24px; }
  .auth-story { border-right: 0; border-bottom: 1px solid var(--line); }
  .side, .side.icon-rail {
    position: sticky;
    top: 0;
    z-index: 2;
    flex-direction: row;
    align-items: center;
    padding: 8px 10px;
    gap: 4px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .side nav {
    flex-direction: row;
    overflow-x: auto;
    min-width: 0;
    width: auto;
    flex: 1;
    gap: 2px;
  }
  .side nav a.nav-item,
  .side .logout-btn {
    width: 40px;
    height: 40px;
    flex: none;
  }
  .side-foot { flex-direction: row; align-items: center; margin-top: 0; width: auto; gap: 4px; }
  .nav-label { display: none !important; }
  .nav-icon { width: 18px; height: 18px; }
  .main { padding: 18px 14px 36px; }
  .top { flex-direction: column; align-items: stretch; }
  .top h1 { font-size: 26px; }
  .status-pill { align-self: flex-start; }
  .budget { min-width: 0; width: 100%; }
  .stats-line { flex-wrap: wrap; }
  .stats-line div { min-width: 0; flex: 1 1 90px; }
  .bar-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1.4fr) auto; }
  .bubble.user { margin-left: 0; }
  .pipeline-line { flex-basis: 18px; }
}
@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; }
}
