/* SaleFlow -- a workspace, not a terminal.
   Neutral surfaces, hairline borders, soft radii, one restrained accent used
   for action and state rather than decoration. Mobile first. */
:root {
  --accent: #E2622A;          /* action, active state -- used sparingly */
  --accent-hover: #C9521E;
  --accent-tint: #FDF1EA;     /* selected rows, soft highlights */
  --accent-quiet: #F6E4DA;

  --page: #F6F7F9;            /* app chrome behind the content */
  --surface: #FFFFFF;         /* cards, panels, rows */
  --surface-alt: #FAFBFC;

  --text: #1E2126;
  --text-soft: #5C6270;
  --text-faint: #8A909C;

  --line: #E4E7EC;            /* hairline */
  --line-strong: #D3D8E0;

  --ok: #1B7F55;
  --ok-tint: #E8F5EF;
  --warn: #B4471F;
  --warn-tint: #FCEDE7;
  --info-tint: #EEF1F6;

  --r: 6px;
  --r-lg: 10px;
  --shadow: 0 1px 2px rgba(20, 24, 33, .06), 0 1px 3px rgba(20, 24, 33, .04);
  --shadow-lift: 0 2px 6px rgba(20, 24, 33, .08), 0 6px 16px rgba(20, 24, 33, .06);

  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
          Helvetica, Arial, sans-serif;
  --num: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --code: ui-monospace, SFMono-Regular, 'SF Mono', Menlo, Consolas, monospace;
}
/* Light is the default, always -- this is a workspace people show to customers,
   and it should not follow the OS into a dark theme uninvited. Dark is still
   available deliberately: set data-theme="dark" on <html>. */
:root[data-theme="dark"] {
  --page: #16181D; --surface: #1D2026; --surface-alt: #22262D;
  --text: #E8EAED; --text-soft: #A7AEBB; --text-faint: #7B8494;
  --line: #2C313A; --line-strong: #3A4048;
  --accent: #F0743C; --accent-hover: #FF8A52;
  --accent-tint: #2C2019; --accent-quiet: #3A2519;
  --ok: #4CB98B; --ok-tint: #17281F; --warn: #E8845C; --warn-tint: #2E1E17;
  --info-tint: #242932;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page); color: var(--text);
  font-family: var(--sans); font-size: 15px; line-height: 1.55;
  -webkit-font-smoothing: antialiased; -webkit-text-size-adjust: 100%;
}
a { color: var(--text); text-decoration: none; }
a:hover { color: var(--accent); }
.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px 96px; }

/* --- top bar --- */
header.top {
  background: var(--surface); border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
header.top .bar {
  max-width: 920px; margin: 0 auto; padding: 12px 20px;
  display: flex; align-items: center; gap: 12px;
}
.brand {
  display: flex; align-items: center; gap: 9px;
  font-size: 15px; font-weight: 650; letter-spacing: -0.01em; color: var(--text);
}
.brand .mark {
  width: 22px; height: 22px; border-radius: var(--r); background: var(--accent);
  color: #fff; font-size: 12px; font-weight: 700; display: grid; place-items: center;
  flex: 0 0 auto;
}
.brand:hover { color: var(--text); }
.whoami {
  margin-left: auto; text-align: right; font-size: 12px; color: var(--text-faint);
  line-height: 1.35;
}
.whoami b { display: block; color: var(--text); font-weight: 550; font-size: 13px; }
nav.tabs {
  max-width: 920px; margin: 0 auto; padding: 0 20px; display: flex; gap: 2px;
  overflow-x: auto; scrollbar-width: none;
}
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a {
  font-size: 13.5px; font-weight: 500; padding: 8px 12px 10px; white-space: nowrap;
  color: var(--text-soft); border-bottom: 2px solid transparent; margin-bottom: -1px;
}
nav.tabs a:hover { color: var(--text); }
nav.tabs a.on { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }

/* --- headings --- */
h1.page {
  font-size: 22px; font-weight: 650; letter-spacing: -0.02em; margin: 24px 0 2px;
}
.lede { color: var(--text-soft); margin: 0 0 6px; font-size: 14px; }
h2.sec, h1.sec {
  font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint); margin: 30px 0 10px;
}

/* --- cards --- */
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 10px; box-shadow: var(--shadow);
}
.card.hot { border-color: var(--accent-quiet); background: var(--accent-tint); }
.card h3 { margin: 0 0 3px; font-size: 15px; font-weight: 600; line-height: 1.35; }
.card .meta { font-size: 12.5px; color: var(--text-faint); }

/* --- the push list --- */
.push-item {
  display: flex; gap: 14px; align-items: flex-start;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  padding: 14px 16px; margin-bottom: 8px; box-shadow: var(--shadow);
  transition: box-shadow .12s ease, transform .12s ease;
}
.push-item:hover { box-shadow: var(--shadow-lift); }
.push-item .n {
  flex: 0 0 auto; width: 24px; height: 24px; border-radius: 50%;
  background: var(--info-tint); color: var(--text-soft);
  font-size: 12.5px; font-weight: 650; display: grid; place-items: center;
}
.push-item:first-of-type .n { background: var(--accent); color: #fff; }
.push-item .body { flex: 1; min-width: 0; }
.push-item .title { font-weight: 570; font-size: 15px; letter-spacing: -0.005em; }
.push-item .why { font-size: 13px; color: var(--text-soft); margin-top: 2px; }

/* --- chips --- */
.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11.5px; font-weight: 550; line-height: 1;
  padding: 4px 8px; border-radius: 100px; margin-right: 5px;
  background: var(--info-tint); color: var(--text-soft);
}
.chip.fixed { background: var(--accent-tint); color: var(--accent); }
.chip.legal { background: var(--info-tint); color: var(--text); font-weight: 600; }
.chip.overdue { background: var(--warn-tint); color: var(--warn); }
.chip.ok { background: var(--ok-tint); color: var(--ok); }

/* a quiet leading dot for live / active statements */
.live { display: flex; gap: 8px; align-items: baseline; color: var(--text-soft); }
.live::before {
  content: ""; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%;
  background: var(--accent); transform: translateY(-1px);
}

/* --- tables --- */
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  color: var(--text-faint); text-align: left; padding: 8px 10px 8px 0;
  border-bottom: 1px solid var(--line);
}
td { padding: 10px 10px 10px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.num, th.num { text-align: right; padding-right: 0; font-variant-numeric: tabular-nums; }

/* --- forms --- */
input, select, textarea {
  font-family: var(--sans); font-size: 14px; color: var(--text);
  background: var(--surface); border: 1px solid var(--line-strong);
  border-radius: var(--r); padding: 9px 11px; width: 100%;
  -webkit-appearance: none; appearance: none; transition: border-color .12s, box-shadow .12s;
}
input:hover, select:hover, textarea:hover { border-color: var(--text-faint); }
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
textarea { resize: vertical; min-height: 78px; line-height: 1.5; }
select {
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='none' stroke='%235C6270' stroke-width='1.5' d='M3 4.5L6 7.5L9 4.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px;
}
label {
  display: block; font-size: 12.5px; font-weight: 550; color: var(--text-soft);
  margin: 12px 0 5px;
}
button, .btn {
  font-family: var(--sans); font-size: 13.5px; font-weight: 550; line-height: 1;
  background: var(--accent); color: #fff; border: 1px solid var(--accent);
  border-radius: var(--r); padding: 9px 14px; cursor: pointer;
  width: auto; display: inline-block; text-align: center;
  transition: background .12s, border-color .12s, box-shadow .12s;
}
button:hover, .btn:hover {
  background: var(--accent-hover); border-color: var(--accent-hover); color: #fff;
}
button:focus-visible, .btn:focus-visible {
  outline: none; box-shadow: 0 0 0 3px var(--accent-tint);
}
button.ghost, .btn.ghost {
  background: var(--surface); color: var(--text); border-color: var(--line-strong);
}
button.ghost:hover, .btn.ghost:hover {
  background: var(--surface-alt); border-color: var(--text-faint); color: var(--text);
}
button.danger { background: var(--warn); border-color: var(--warn); }
button.danger:hover { background: #9C3C19; border-color: #9C3C19; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.row > * { flex: 1 1 170px; }
.row > .tight { flex: 0 0 auto; }
form.inline { display: inline-block; margin-right: 6px; }

/* --- disclosure --- */
details { margin: 10px 0; }
summary {
  cursor: pointer; font-size: 13.5px; font-weight: 550; color: var(--text-soft);
  list-style: none; padding: 7px 0; display: flex; align-items: center; gap: 7px;
}
summary::-webkit-details-marker { display: none; }
summary::before {
  content: ""; width: 0; height: 0; flex: 0 0 auto;
  border-left: 5px solid var(--text-faint);
  border-top: 4px solid transparent; border-bottom: 4px solid transparent;
  transition: transform .15s ease;
}
details[open] > summary::before { transform: rotate(90deg); }
summary:hover { color: var(--accent); }

/* --- agent conversation --- */
.turn {
  border-radius: var(--r-lg); padding: 13px 15px; margin-bottom: 10px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.turn.user { background: var(--info-tint); border-color: transparent; box-shadow: none; }
.turn .who {
  font-size: 12px; font-weight: 600; color: var(--text-faint); margin-bottom: 5px;
}
.turn.agent .who { color: var(--accent); }
.turn p, .turn .say {
  margin: 0; font-size: 14.5px; white-space: pre-wrap; word-break: break-word;
}
.readback {
  border: 1px solid var(--line); border-radius: var(--r);
  background: var(--surface-alt); padding: 12px 14px; margin: 10px 0 2px;
}
.readback .cap {
  font-size: 12px; font-weight: 600; color: var(--text-soft); margin-bottom: 6px;
}
.readback ul { margin: 0; padding-left: 18px; }
.readback li { margin-bottom: 4px; font-size: 14px; }

/* --- stage strip --- */
.strip {
  display: flex; overflow-x: auto; gap: 6px; margin-bottom: 14px;
  padding-bottom: 2px; scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.strip .st {
  flex: 1 0 auto; padding: 8px 12px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line);
  font-size: 12px; font-weight: 550; color: var(--text-soft); white-space: nowrap;
}
.strip .st.on {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600;
}
.strip .st b {
  display: block; font-size: 17px; font-weight: 650; color: var(--text);
  font-variant-numeric: tabular-nums; margin-top: 1px;
}
.strip .st.on b { color: #fff; }

/* --- war room canvas --- */
#canvas-shell {
  border: 1px solid var(--line); border-radius: var(--r-lg); height: 72vh;
  overflow: hidden; position: relative; touch-action: none;
  background: var(--surface);
  background-image: radial-gradient(var(--line) 1px, transparent 1px);
  background-size: 22px 22px;
}
#canvas { position: absolute; transform-origin: 0 0; will-change: transform; }
.node {
  position: absolute; width: 280px; padding: 12px 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); box-shadow: var(--shadow); cursor: pointer;
  transition: box-shadow .12s ease;
}
.node:hover { box-shadow: var(--shadow-lift); }
.node.top5 { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }
.node .rank {
  font-size: 11.5px; font-weight: 600; color: var(--text-faint);
  font-variant-numeric: tabular-nums;
}
.node.top5 .rank { color: var(--accent); }
.node h4 { margin: 3px 0 5px; font-size: 14.5px; font-weight: 600; line-height: 1.3; }
.node .amt {
  font-size: 13.5px; color: var(--text-soft); font-variant-numeric: tabular-nums;
}
.col-label {
  position: absolute; font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-faint);
}
.canvas-controls { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.canvas-controls button { flex: 0 0 auto; }
.hint { font-size: 12.5px; color: var(--text-faint); }

/* --- flashes --- */
.flash {
  border-radius: var(--r); padding: 11px 14px; margin: 14px 0; font-size: 14px;
  background: var(--accent-tint); color: var(--text); border: 1px solid var(--accent-quiet);
}
.flash.bad { background: var(--warn-tint); border-color: var(--warn-tint); color: var(--warn); }
.flash.good { background: var(--ok-tint); border-color: var(--ok-tint); color: var(--ok); }

/* --- misc --- */
.muted { color: var(--text-soft); }
.small { font-size: 13px; }
.num { font-variant-numeric: tabular-nums; }
.big-number {
  font-size: 30px; font-weight: 650; letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums; margin-top: 2px;
}
.big-number span { font-size: 17px; font-weight: 500; color: var(--text-faint); }
.stack > * + * { margin-top: 10px; }
hr { border: 0; border-top: 1px solid var(--line); margin: 20px 0; }
.empty {
  background: var(--surface); border: 1px dashed var(--line-strong);
  border-radius: var(--r-lg); padding: 26px 20px; text-align: center;
  color: var(--text-faint); font-size: 13.5px;
}
pre.doc {
  font-family: var(--sans); font-size: 13.5px; line-height: 1.6; white-space: pre-wrap;
  margin: 0; background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; color: var(--text-soft);
}
pre.code {
  font-family: var(--code); font-size: 12px; line-height: 1.55; overflow-x: auto;
  background: var(--surface-alt); border: 1px solid var(--line);
  border-radius: var(--r); padding: 12px 14px; margin: 0;
}
code {
  font-family: var(--code); font-size: 12.5px; background: var(--info-tint);
  padding: 2px 5px; border-radius: 4px;
}

/* --- bottom nav, phone only --- */
.bottom { display: none; }
@media (max-width: 720px) {
  .wrap { padding: 0 16px 80px; }
  .bottom {
    display: flex; position: fixed; bottom: 0; left: 0; right: 0; z-index: 30;
    background: var(--surface); border-top: 1px solid var(--line);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .bottom a {
    flex: 1; text-align: center; padding: 10px 4px 11px;
    font-size: 11px; font-weight: 550; color: var(--text-faint);
  }
  .bottom a.on { color: var(--accent); }
  nav.tabs { display: none; }
  .desktop-only { display: none !important; }
  h1.page { font-size: 20px; }
}
@media (min-width: 721px) { .phone-only { display: none !important; } }

:root { --rail: 380px; }

/* The page shifts left to make room for the docked rail. Padding on <body>
   rather than margins on the inner blocks, so the centred .wrap and the sticky
   header both reflow against the same edge. */
@media (min-width: 1180px) {
  body.has-rail { padding-right: var(--rail); }
}

#agent-rail {
  position: fixed; top: 0; right: 0; bottom: 0; width: var(--rail);
  background: var(--surface); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; z-index: 40;
  transform: translateX(100%); transition: transform .18s ease;
}
#agent-rail.open { transform: translateX(0); }
@media (min-width: 1180px) {
  #agent-rail { transform: translateX(0); box-shadow: none; }
  /* the content region briefly tints when the agent changes something on it */
.wrap.just-updated { animation: sf-updated 1.2s ease; }
@keyframes sf-updated {
  0%   { background: var(--accent-tint); }
  100% { background: transparent; }
}

#rail-toggle { display: none; }
  #agent-rail .rail-close { display: none; }
}
@media (max-width: 1179px) {
  #agent-rail { box-shadow: var(--shadow-lift); max-width: 100vw; }
}
@media (max-width: 460px) { :root { --rail: 100vw; } }

.rail-head {
  display: flex; align-items: center; gap: 8px; padding: 12px 14px;
  border-bottom: 1px solid var(--line); flex: 0 0 auto;
}
.rail-head .title { font-size: 14px; font-weight: 650; letter-spacing: -0.01em; }
.rail-head .where {
  font-size: 11.5px; color: var(--text-faint); margin-left: auto; text-align: right;
}
.rail-close {
  background: none; border: 0; color: var(--text-faint); font-size: 20px;
  line-height: 1; padding: 2px 6px; cursor: pointer; width: auto;
}
.rail-close:hover { background: none; color: var(--accent); }

.rail-tabs { display: flex; gap: 2px; padding: 0 14px; border-bottom: 1px solid var(--line); }
.rail-tabs button {
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--text-soft); font-size: 13px; font-weight: 550; padding: 9px 10px;
  cursor: pointer; width: auto; border-radius: 0;
}
.rail-tabs button:hover { background: none; color: var(--text); }
.rail-tabs button.on { color: var(--accent); border-bottom-color: var(--accent); }

.rail-panel { flex: 1 1 auto; overflow-y: auto; padding: 14px; display: none; }
.rail-panel.on { display: block; }

.rail-msg {
  border-radius: var(--r-lg); padding: 10px 12px; margin-bottom: 8px;
  font-size: 14px; white-space: pre-wrap; word-break: break-word;
}
.rail-msg.user { background: var(--info-tint); }
.rail-msg.agent { background: var(--surface); border: 1px solid var(--line); }
.rail-msg .who {
  font-size: 11px; font-weight: 600; color: var(--text-faint); margin-bottom: 4px;
}
.rail-msg.agent .who { color: var(--accent); }
.rail-msg.pending { opacity: .55; }

.rail-readback {
  border: 1px solid var(--accent-quiet); background: var(--accent-tint);
  border-radius: var(--r); padding: 10px 12px; margin-top: 8px;
}
.rail-readback .cap {
  font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 5px;
}
.rail-readback ul { margin: 0; padding-left: 16px; }
.rail-readback li { font-size: 13px; margin-bottom: 3px; }
.rail-readback a { text-decoration: underline; }

.rail-foot { flex: 0 0 auto; border-top: 1px solid var(--line); padding: 12px 14px; }
.rail-foot textarea { min-height: 56px; font-size: 14px; }
.rail-foot .row { margin-top: 8px; }
.rail-hint { font-size: 11.5px; color: var(--text-faint); margin: 8px 0 0; }
.rail-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.rail-chips button {
  background: var(--surface); border: 1px solid var(--line-strong); color: var(--text-soft);
  font-size: 12px; font-weight: 500; padding: 5px 9px; border-radius: 100px;
  cursor: pointer; width: auto;
}
.rail-chips button:hover {
  border-color: var(--accent); color: var(--accent); background: var(--surface);
}

/* the content region briefly tints when the agent changes something on it */
.wrap.just-updated { animation: sf-updated 1.2s ease; }
@keyframes sf-updated {
  0%   { background: var(--accent-tint); }
  100% { background: transparent; }
}

#rail-toggle {
  position: fixed; right: 16px; bottom: 76px; z-index: 39;
  border-radius: 100px; padding: 11px 16px; box-shadow: var(--shadow-lift);
  display: inline-flex; align-items: center; gap: 7px;
}
@media (min-width: 721px) { /* the content region briefly tints when the agent changes something on it */
.wrap.just-updated { animation: sf-updated 1.2s ease; }
@keyframes sf-updated {
  0%   { background: var(--accent-tint); }
  100% { background: transparent; }
}

#rail-toggle { bottom: 20px; } }

/* --- the ElevenLabs widget, docked inside the rail's Talk panel ---
   The widget renders in shadow DOM and positions itself with fixed, so it would
   normally float over the rail rather than sit in it. A transform on the host
   makes that host the containing block for fixed-position descendants, which
   traps the widget inside this panel. That is the only hook we get: its colors,
   radii and copy are set server-side in the agent's widget config so they match
   the tokens below. */
.rail-voice { display: flex; flex-direction: column; gap: 12px; }
.rail-voice .note { font-size: 13px; color: var(--text-soft); }
.rail-voice .note code {
  font-size: 12px; background: var(--info-tint); padding: 1px 5px; border-radius: 4px;
}

.voice-dock {
  position: relative;
  transform: translateZ(0);          /* containing block for the fixed widget */
  min-height: 260px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-alt);
  overflow: hidden;
}
.voice-dock::before {
  content: "Voice";
  position: absolute; top: 10px; left: 12px; z-index: 0;
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.04em;
  text-transform: uppercase; color: var(--text-faint);
}
elevenlabs-convai { --convai-z-index: 1; }
