:root {
  --paper: #F0F3F0;
  --surface: #FFFFFF;
  --ink: #11201D;
  --muted: #63736E;
  --line: #E0E6E2;
  --teal: #0E6E68;
  --teal-dark: #0A5450;
  --teal-soft: #DFEDE9;
  --amber: #E8913A;
  --amber-soft: #FBEEDD;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(17, 32, 29, .05), 0 8px 24px -14px rgba(17, 32, 29, .18);
  --display: "Bricolage Grotesque", "Segoe UI", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 var(--body);
}

h1, h2, h3, .brand-name {
  font-family: var(--display);
  font-weight: 700;
  letter-spacing: -.02em;
  line-height: 1.15;
  margin: 0;
}

h1 { font-size: clamp(1.6rem, 1.2rem + 1.5vw, 2.2rem); }
h2 { font-size: 1.12rem; }

a { color: var(--teal-dark); }

code {
  font: 500 .82em/1 ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--teal-soft);
  color: var(--teal-dark);
  padding: .15em .4em;
  border-radius: 5px;
}

.eyebrow {
  margin: 0 0 .35rem;
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--teal);
}

.lede { color: var(--muted); margin: .5rem 0 0; }
.muted { color: var(--muted); }

/* ------------------------------------------------------------- topbar */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .85rem clamp(1rem, 4vw, 2.5rem);
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: .6rem;
  text-decoration: none;
  color: var(--ink);
}

.brand-name { font-size: 1.02rem; }

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 26px;
  padding: 0 7px;
  border-radius: 8px;
  background: var(--teal);
}

.brand-mark i { width: 3px; border-radius: 2px; background: #F5C57B; }
.brand-mark i:nth-child(1) { height: 8px; }
.brand-mark i:nth-child(2) { height: 15px; }
.brand-mark i:nth-child(3) { height: 11px; }
.brand-mark i:nth-child(4) { height: 6px; }

.topbar-nav {
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .93rem;
}

.topbar-nav > a:not(.btn) { color: var(--muted); text-decoration: none; }
.topbar-nav > a:not(.btn):hover { color: var(--ink); }

.menu { position: relative; }

.menu summary {
  list-style: none;
  cursor: pointer;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-weight: 600;
}

.menu summary::-webkit-details-marker { display: none; }

.menu-panel {
  position: absolute;
  right: 0;
  top: calc(100% + .5rem);
  z-index: 20;
  min-width: 210px;
  padding: .9rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.menu-who { margin: 0 0 .6rem; font-size: .85rem; line-height: 1.45; }
.menu-who span { color: var(--muted); }
.menu-panel a { font-size: .9rem; }

/* -------------------------------------------------------------- shell */

.page { padding: clamp(1.25rem, 4vw, 2.5rem); max-width: 1180px; margin: 0 auto; }

.stack { display: grid; gap: 1.25rem; }

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.head-actions { display: flex; gap: .6rem; }

.crumb { margin: 0; font-size: .85rem; color: var(--muted); }

.flash {
  margin: 0;
  padding: .7rem clamp(1rem, 4vw, 2.5rem);
  font-size: .9rem;
  background: var(--teal-soft);
  color: var(--teal-dark);
  border-bottom: 1px solid var(--line);
}

.flash-warn { background: var(--amber-soft); color: #7A4A0E; }

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .68rem 1.15rem;
  border: 1px solid var(--teal);
  border-radius: 999px;
  background: var(--teal);
  color: #fff;
  font: 600 .95rem/1 var(--body);
  text-decoration: none;
  cursor: pointer;
  transition: background .15s ease, transform .12s ease;
}

.btn:hover { background: var(--teal-dark); border-color: var(--teal-dark); }
.btn:active { transform: translateY(1px); }

.btn-ghost { background: transparent; color: var(--teal-dark); border-color: var(--line); }
.btn-ghost:hover { background: var(--teal-soft); border-color: var(--teal-soft); }

.btn-sm { padding: .45rem .85rem; font-size: .85rem; }
.btn-block { width: 100%; }

.btn-link {
  background: none;
  border: 0;
  padding: 0;
  color: #A4483A;
  font: 500 .88rem/1 var(--body);
  cursor: pointer;
  text-decoration: underline;
}

:where(a, button, input, select, textarea, summary):focus-visible {
  outline: 2px solid var(--amber);
  outline-offset: 2px;
}

/* -------------------------------------------------------------- forms */

.field { display: block; margin: 0 0 1rem; }
.field > span { display: block; font-size: .9rem; font-weight: 600; margin-bottom: .35rem; }
.field .opt { font-weight: 400; font-style: normal; color: var(--muted); }

.field input,
.field select,
.field textarea {
  width: 100%;
  padding: .7rem .85rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: 400 .97rem/1.5 var(--body);
}

.field textarea {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: .86rem;
  line-height: 1.7;
  resize: vertical;
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--teal);
  outline: none;
  box-shadow: 0 0 0 3px var(--teal-soft);
}

.field-hint, .field-error {
  display: block;
  margin-top: .35rem;
  font-size: .82rem;
  font-style: normal;
  color: var(--muted);
}

.field-error { color: #A4483A; font-weight: 500; }

.field-error-top {
  margin: 0 0 1rem;
  padding: .6rem .8rem;
  background: #FBEAE7;
  border-radius: 10px;
}

.search { display: block; margin-bottom: 1rem; }

.search input {
  width: 100%;
  padding: .7rem .95rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  font: 400 .95rem/1.4 var(--body);
}

.search input:focus { border-color: var(--teal); outline: none; box-shadow: 0 0 0 3px var(--teal-soft); }

.actions-note { font-size: .9rem; color: var(--muted); }

.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.75rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--line);
}

/* ------------------------------------------------------ choices/checks */

.choices, .checks { border: 0; padding: 0; margin: 0 0 1rem; display: grid; gap: .7rem; }

.choices legend, .checks legend {
  padding: 0;
  margin-bottom: .55rem;
  font-size: .9rem;
  font-weight: 600;
}

.choice {
  display: flex;
  gap: .8rem;
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color .15s ease, box-shadow .15s ease;
}

.choice:hover { border-color: var(--teal); }
.choice input { margin-top: .25rem; accent-color: var(--teal); flex: none; }
.choice:has(input:checked) { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }

.choice-body { display: grid; gap: .25rem; }
.choice-body strong { font-size: 1rem; }
.choice-body > span { font-size: .9rem; color: var(--muted); }
.choice-body em { font-size: .78rem; font-style: normal; color: var(--teal); font-weight: 600; }

.checks { grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.check {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .75rem .9rem;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  font-size: .93rem;
  cursor: pointer;
}

.check input { accent-color: var(--teal); }
.check:has(input:checked) { border-color: var(--teal); background: var(--teal-soft); }

/* ------------------------------------------------------------- wizard */

.wizard {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 1.5rem;
  align-items: start;
}

.rail {
  position: sticky;
  top: 1.5rem;
  padding: 1.4rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.rail-head { margin-bottom: 1.2rem; }

.wave {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 42px;
  overflow: hidden;
}

.wave i {
  flex: 1;
  min-width: 2px;
  border-radius: 2px;
  background: var(--line);
  transition: height .35s cubic-bezier(.2, .8, .3, 1), background .35s ease;
}

.wave i.on { background: var(--teal); }
.wave i.on:nth-child(3n) { background: var(--amber); }

.wave-idle i { background: var(--teal-soft); }

.rail-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: .1rem; counter-reset: s; }

.rail-steps li { counter-increment: s; }

.rail-steps li > * {
  display: block;
  padding: .6rem .7rem .6rem 2.2rem;
  position: relative;
  border-radius: 10px;
  text-decoration: none;
  color: var(--muted);
}

.rail-steps li > *::before {
  content: counter(s);
  position: absolute;
  left: .55rem;
  top: .62rem;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  font-size: .7rem;
  font-weight: 600;
  color: var(--muted);
  background: var(--surface);
}

.rail-steps strong { display: block; font-size: .93rem; font-weight: 600; color: var(--ink); }
.rail-steps li > * > span { display: block; font-size: .8rem; line-height: 1.45; margin-top: .15rem; }
.rail-steps li:not(.is-current) strong { font-weight: 500; color: var(--muted); }

.rail-steps .is-current > * { background: var(--teal-soft); }
.rail-steps .is-current strong { color: var(--teal-dark); }
.rail-steps .is-current > *::before { background: var(--teal); border-color: var(--teal); color: #fff; }

.rail-steps .is-done a:hover { background: var(--paper); }
.rail-steps .is-done strong { color: var(--ink); }
.rail-steps .is-done > *::before { content: "✓"; background: var(--teal-soft); border-color: var(--teal-soft); color: var(--teal-dark); }

.rail-out {
  display: inline-block;
  margin-top: 1.1rem;
  font-size: .85rem;
  color: var(--muted);
}

.panel {
  padding: clamp(1.25rem, 3vw, 2rem);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.panel h1 + .lede { margin-bottom: 1.5rem; }

.field-wide { max-width: 640px; }

.callout {
  margin: 0 0 1.25rem;
  padding: .8rem 1rem;
  border-left: 3px solid var(--teal);
  border-radius: 0 10px 10px 0;
  background: var(--teal-soft);
  color: var(--teal-dark);
  font-size: .9rem;
}

.callout-warn { border-left-color: var(--amber); background: var(--amber-soft); color: #7A4A0E; }

/* ---------------------------------------------------------- templates */

.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .8rem; }

.tpl {
  display: grid;
  gap: .3rem;
  align-content: start;
  padding: 1rem;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  font-family: var(--body);
  color: var(--ink);
  transition: border-color .15s ease, box-shadow .15s ease, transform .12s ease;
}

.tpl:hover { border-color: var(--teal); transform: translateY(-2px); }
.tpl strong { font-size: .98rem; }
.tpl > span { font-size: .86rem; line-height: 1.5; color: var(--muted); }
.tpl em { font-size: .76rem; font-style: normal; color: var(--teal); font-weight: 600; }
.tpl.is-picked { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }

.tpl-blank { border-style: dashed; background: #FBFCFB; }

.empty-search { margin-top: 1rem; color: var(--muted); font-size: .9rem; }

/* -------------------------------------------------------- summary/view */

.summary { display: grid; gap: .1rem; margin: 0 0 1.5rem; }

.summary > div {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 1rem;
  padding: .65rem 0;
  border-bottom: 1px solid var(--line);
}

.summary dt { font-size: .85rem; font-weight: 600; color: var(--muted); }
.summary dd { margin: 0; }

.peek summary { cursor: pointer; font-size: .92rem; font-weight: 600; color: var(--teal-dark); }

.prompt-view {
  margin: .8rem 0 0;
  padding: 1rem;
  max-height: 460px;
  overflow: auto;
  background: #F7F9F8;
  border: 1px solid var(--line);
  border-radius: 12px;
  font: 400 .84rem/1.7 ui-monospace, "SF Mono", Menlo, monospace;
  white-space: pre-wrap;
  word-break: break-word;
}

.quote {
  margin: .6rem 0 0;
  padding-left: .9rem;
  border-left: 3px solid var(--amber);
  font-size: 1.05rem;
}

/* ------------------------------------------------------------- cards */

.card {
  padding: 1.5rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
}

.card-flat { box-shadow: none; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.card h2 { margin-bottom: .9rem; }
.card-flat h2 { margin-bottom: .4rem; }
.card-foot { margin: 1.1rem 0 0; font-size: .9rem; color: var(--muted); text-align: center; }

.danger { margin-top: .5rem; }

/* ---------------------------------------------------------- dashboard */

.agent-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .7rem; }

.agent-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .9rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  transition: border-color .15s ease;
}

.agent-row:hover { border-color: var(--teal); }

.agent-main { display: grid; gap: .2rem; text-decoration: none; color: var(--ink); }
.agent-main strong { font-size: 1.05rem; font-family: var(--display); }
.agent-sub { font-size: .87rem; color: var(--muted); }

.agent-side { display: flex; align-items: center; gap: .8rem; flex: none; }
.agent-side time { font-size: .82rem; color: var(--muted); }

.tag {
  display: inline-block;
  padding: .18rem .55rem;
  border-radius: 999px;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .02em;
  width: fit-content;
}

.tag-inbound { background: var(--teal-soft); color: var(--teal-dark); }
.tag-outbound { background: var(--amber-soft); color: #7A4A0E; }

.blank-slate {
  padding: clamp(2rem, 6vw, 3.5rem);
  text-align: center;
  background: var(--surface);
  border: 1px dashed var(--line);
  border-radius: 18px;
}

.blank-slate .wave { justify-content: center; max-width: 220px; margin: 0 auto 1.2rem; }
.blank-slate h2 { font-size: 1.4rem; }
.blank-slate p { max-width: 44ch; margin: .5rem auto 1.4rem; color: var(--muted); }

/* --------------------------------------------------------------- gate */

.gate {
  display: grid;
  grid-template-columns: 1.05fr .95fr;
  gap: clamp(1.5rem, 5vw, 4rem);
  align-items: center;
  min-height: 70vh;
}

.gate-pitch h1 { font-size: clamp(2rem, 1.4rem + 2.4vw, 3.1rem); margin-bottom: .8rem; }
.gate-pitch .lede { font-size: 1.05rem; max-width: 46ch; }

.pitch-list { list-style: none; margin: 2rem 0 0; padding: 0; display: grid; gap: .9rem; }

.pitch-list li {
  display: grid;
  grid-template-columns: 52px 1fr;
  align-items: center;
  gap: .9rem;
  font-size: .93rem;
  color: var(--muted);
}

.pitch-list span {
  display: grid;
  place-items: center;
  height: 40px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--teal);
}

.gate-form .card { max-width: 420px; margin-left: auto; }
.gate-form h2 { font-size: 1.3rem; margin-bottom: 1.2rem; }

/* -------------------------------------------------------------- small */

@media (max-width: 900px) {
  .wizard { grid-template-columns: 1fr; }
  .rail { position: static; }
  .rail-steps { display: none; }
  .gate { grid-template-columns: 1fr; min-height: 0; }
  .gate-form .card { margin-left: 0; max-width: none; }
  .summary > div { grid-template-columns: 1fr; gap: .1rem; }
  .agent-row { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 520px) {
  .brand-name { display: none; }
  .topbar-nav > a:not(.btn) { display: none; }
  .actions-note { font-size: .9rem; color: var(--muted); }

.actions { flex-direction: column-reverse; }
  .actions .btn { width: 100%; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
