/* tasteskill deal (software / fintech): palette warm-black-gold, type funnel, radius soft.
   One dark theme: a near-black ground with a gold accent; no violet anywhere. */
:root {
  --bg: #0c0a08;
  --surface: #181512;
  --surface-2: #221e19;
  --ink: #ffffff;
  --muted: #a39d95;
  --border: #2e2923;
  --line-strong: #4a4239;
  --accent: #c9a45a;
  --accent-ink: #0c0a08;
  --accent-soft: rgb(201 164 90 / 0.14);
  --lime: #c9a45a;
  --ok: #6fcf8e;
  --ok-soft: #142a1c;
  --warn: #e8b45a;
  --warn-soft: #33270f;
  --bad: #ff8a80;
  --bad-soft: #3a1714;
  --info: #9db8ef;
  --info-soft: #18213a;
  --shadow: 0 1px 0 rgb(255 255 255 / 0.03) inset, 0 12px 32px rgb(0 0 0 / 0.35);
  --radius: 14px;
  --font: "Funnel Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Funnel Display", system-ui, sans-serif;
  --mono: "DM Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  /* Motion numbers from the skill's motion reference */
  --ease: cubic-bezier(.2, .8, .2, 1);
  --ease-enter: cubic-bezier(.22, 1, .36, 1);
  --m-in: 150ms;
  --m-out: 120ms;
  --m-press: 90ms;
  --m-cycle: 3.2s;
  --nav-h: 56px;
  --section-pad: 72px;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body { margin: 0; }
html { scroll-padding-top: var(--nav-h); }

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.55 var(--font);
  -webkit-font-smoothing: antialiased;
}

svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 500; letter-spacing: -0.02em; }
p { margin: 0; }
.muted { color: var(--muted); }
.num, .kpi strong, .total strong, .aging-value, .plan-amount { font-family: var(--mono); font-feature-settings: "tnum"; letter-spacing: -0.01em; }

/* ---------- Top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 10;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  height: var(--nav-h);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-inner { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 12px; height: 100%; }
.brand { display: flex; min-height: 44px; align-items: center; gap: 10px; font: 500 18px var(--display); letter-spacing: -0.02em; color: var(--ink); text-decoration: none; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px; font-size: 12.5px; font-weight: 500;
  background: var(--surface); border: 1px solid var(--border); color: var(--muted); white-space: nowrap;
}
.chip i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }
.chip.demo i { background: var(--warn); }

.wrap { max-width: 1240px; margin: 0 auto; padding-inline: 16px; }
main.wrap > section.create, main.wrap > section.receivables { padding-bottom: var(--section-pad); }

/* ---------- Hero: the first screen alone, the product's own UI as the picture ---------- */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.05fr); gap: 56px; align-items: center;
  min-height: 100svh; padding: calc(var(--nav-h) + 32px) 0 var(--section-pad);
}
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px; border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 35%, var(--border)); color: var(--accent);
  font-size: 13px; font-weight: 500; margin-bottom: 22px;
}
.eyebrow i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); animation: pulse 2.4s infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 5.4vw, 70px); line-height: 1.02; letter-spacing: -0.04em; }
.hero h1 .h1-line { display: block; }
.hero h1 em { font-style: normal; color: var(--accent); }
.hero-lead { margin-top: 20px; color: var(--muted); font-size: 17.5px; line-height: 1.55; max-width: 540px; }
.hero-points { list-style: none; padding: 0; margin: 22px 0 0; display: grid; gap: 10px; max-width: 540px; }
.hero-points li { position: relative; padding-left: 26px; font-size: 15px; color: var(--muted); }
.hero-points li::before {
  content: ""; position: absolute; left: 0; top: 4px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-soft) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 12.5l4 4 8-9' fill='none' stroke='%23c9a45a' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 11px no-repeat;
}
.hero-points b { color: var(--ink); font-weight: 500; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 30px; }


.built-on { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 28px; font-size: 13px; color: var(--muted); }
.logo-tile {
  display: inline-flex; align-items: center; gap: 7px; height: 32px; padding: 0 12px; border-radius: 9px;
  background: #f4f1ec; color: #1a1714; font-size: 12.5px; font-weight: 600;
}
.logo-tile img { display: block; }

/* App frame: the real flow in miniature. The loop lights a chat phrase and the line it proves. */
.app-frame {
  position: relative; border-radius: 18px; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border);
  box-shadow: 0 40px 90px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.02);
}
.app-frame::before {
  content: ""; position: absolute; inset: -40% -20% auto auto; width: 70%; height: 80%; pointer-events: none;
  background: radial-gradient(closest-side, rgb(201 164 90 / 0.13), transparent);
}
.af-bar { display: flex; align-items: center; gap: 12px; height: 42px; padding: 0 10px 0 14px; border-bottom: 1px solid var(--border); background: #14110e; }
.af-dots { display: inline-flex; gap: 6px; }
.af-dots i { width: 10px; height: 10px; border-radius: 50%; background: #3a332b; }
.af-title { flex: 1; font-size: 12.5px; color: var(--muted); font-weight: 500; }
.af-pause { width: 44px; height: 32px; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer; display: grid; place-items: center; }
.af-pause:hover { color: var(--ink); background: var(--surface-2); }
.af-pause svg { width: 14px; height: 14px; }
.af-pause .i-play { display: none; }
.af-pause[aria-pressed="true"] .i-play { display: block; }
.af-pause[aria-pressed="true"] .i-pause { display: none; }
.af-body { position: relative; display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.05fr); min-height: 360px; }
.af-chat { padding: 18px; display: grid; gap: 10px; align-content: start; border-right: 1px solid var(--border); background: #120f0c; }
.af-who { font-size: 12.5px; font-weight: 600; display: flex; justify-content: space-between; color: var(--ink); padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.af-who span { color: var(--muted); font-weight: 500; }
.af-msg { font-size: 13.5px; line-height: 1.45; padding: 9px 12px; border-radius: 13px; max-width: 92%; }
.af-msg.in { background: var(--surface-2); justify-self: start; border-bottom-left-radius: 4px; }
.af-msg.out { background: #2a2418; justify-self: end; border-bottom-right-radius: 4px; }
.af-msg mark { background: transparent; color: inherit; border-radius: 4px; padding: 0 2px; box-shadow: inset 0 -1px 0 rgb(201 164 90 / 0.45); }
.af-invoice { padding: 18px; display: grid; gap: 8px; align-content: start; }
.af-inv-head { display: flex; justify-content: space-between; align-items: center; font-size: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.af-inv-head img { padding: 4px 5px; border-radius: 6px; background: #f4f1ec; box-sizing: content-box; }
.af-line { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 8px 10px; border-radius: 10px; border: 1px solid transparent; font-size: 13.5px; }
.af-line small { grid-column: 1 / -1; font-size: 12px; color: var(--muted); font-style: italic; }
.af-total { display: flex; justify-content: space-between; padding: 10px 10px 0; margin-top: 2px; border-top: 1px dashed var(--line-strong); font-weight: 600; }
.af-status { justify-self: start; display: inline-flex; align-items: center; gap: 7px; margin-top: 6px; padding: 5px 10px; border-radius: 999px; background: var(--ok-soft); color: var(--ok); font-size: 12.5px; font-weight: 600; }
.af-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); }

/* The evidence loop: 3 steps × 3.2 s, each lights its chat phrase and its invoice line together. */
.app-frame:not(.is-paused) :is(mark, .af-line).q1 { animation: quote var(--m-cycle) linear infinite; animation-delay: 0s; }
.app-frame:not(.is-paused) :is(mark, .af-line).q2 { animation: quote var(--m-cycle) linear infinite; animation-delay: calc(var(--m-cycle) / 3); }
.app-frame:not(.is-paused) :is(mark, .af-line).q3 { animation: quote var(--m-cycle) linear infinite; animation-delay: calc(var(--m-cycle) * 2 / 3); }
@keyframes quote {
  0%, 30% { background-color: rgb(201 164 90 / 0.18); border-color: rgb(201 164 90 / 0.45); }
  36%, 100% { background-color: transparent; border-color: transparent; }
}

/* Hero entrance, once on load: the h1 line by line, then the lead and actions, the frame settling. ~1.1 s */
@media (prefers-reduced-motion: no-preference) {
  .hero[data-enter] .h1-line,
  .hero[data-enter] :is(.eyebrow, .hero-lead, .hero-points, .hero-actions, .built-on) { animation: enter 0.7s var(--ease-enter) both; }
  .hero[data-enter] .h1-line:nth-child(2) { animation-delay: 0.08s; }
  .hero[data-enter] .h1-line:nth-child(3) { animation-delay: 0.16s; }
  .hero[data-enter] .hero-lead { animation-delay: 0.26s; }
  .hero[data-enter] .hero-points { animation-delay: 0.34s; }
  .hero[data-enter] .hero-actions { animation-delay: 0.42s; }
  .hero[data-enter] .built-on { animation-delay: 0.5s; }
  .hero[data-enter] .app-frame { animation: settle 1.1s var(--ease-enter) 0.15s both; }
}
@keyframes enter { from { opacity: 0; transform: translateY(14px); } }
@keyframes settle { from { opacity: 0; transform: translateY(24px) scale(0.985); } }

/* Section heading for the work area */
.section-title { display: grid; gap: 6px; margin-bottom: 4px; grid-column: 1 / -1; }
.section-title h2 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 400; letter-spacing: -0.03em; }
.section-title p { font-size: 16px; }
.create { padding-top: calc(var(--nav-h) + var(--section-pad)); min-height: 100svh; align-content: start; }
.receivables { padding-top: calc(var(--nav-h) + var(--section-pad)); }
.field-label { display: block; font-size: 13px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.search-field { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.search-field input { width: 220px; height: 44px; }

@media (prefers-reduced-motion: reduce) {
  .app-frame :is(mark, .af-line) { animation: none !important; }
  .eyebrow i { animation: none; }
}

/* ---------- Cards ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.card-head h3 { font-size: 17px; font-weight: 500; display: flex; align-items: center; gap: 10px; }
.section-head h2 { font-size: clamp(28px, 3.4vw, 40px); font-weight: 400; letter-spacing: -0.03em; display: flex; align-items: center; gap: 12px; }
.step {
  display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent); font-size: 13px; font-weight: 700;
}

.create { display: grid; grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); gap: 20px; align-items: start; }
.composer, .draft { padding: 20px; }

/* ---------- Buttons & fields ---------- */
/* One button pair (gold primary, outline secondary). Motion per the skill: hover steps the fill
   14% toward the ink and lifts 1px; press sinks 1px below rest at scale .985. 150 / 120 / 90 ms. */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 18px; border-radius: 10px; border: 1px solid transparent;
  font: 500 14px var(--font); cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform var(--m-out) var(--ease), background-color var(--m-out) var(--ease), border-color var(--m-out) var(--ease), opacity var(--m-out);
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.primary, .btn.dark { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
@media (hover: hover) and (pointer: fine) {
  .btn:hover:not(:disabled) { transform: translateY(-1px); transition-duration: var(--m-in); }
  .btn:is(.primary, .dark):hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 86%, var(--ink)); }
  .btn.ghost:hover:not(:disabled) { background: rgb(255 255 255 / 0.05); border-color: color-mix(in srgb, var(--ink) 40%, var(--line-strong)); }
}
.btn:active:not(:disabled) { transform: translateY(1px) scale(0.985); transition-duration: var(--m-press); }
.btn:focus-visible, .tab:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) { .btn, .btn:hover, .btn:active { transform: none !important; } }
.btn.small { height: 40px; padding: 0 14px; font-size: 13px; border-radius: 9px; }
.btn.icon { width: 44px; padding: 0; }

input, textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 11px; width: 100%;
  outline: none; transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; }

.field { display: grid; gap: 6px; min-width: 0; }
.field > span { font-size: 12.5px; font-weight: 600; color: var(--muted); display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.field > span em { font-style: normal; font-weight: 400; }

/* ---------- Composer ---------- */
.samples { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; font-size: 13px; }
.sample-chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sample-chip {
  border: 1px dashed var(--border); background: transparent; color: var(--ink);
  border-radius: 999px; padding: 4px 10px; font: 500 12.5px var(--font); cursor: pointer;
}
.sample-chip:hover { border-color: var(--accent); color: var(--accent); }

.dropzone { position: relative; border-radius: 12px; }
.dropzone textarea { min-height: 270px; font-size: 14px; line-height: 1.55; background: var(--surface-2); border-color: transparent; }
.dropzone.drag textarea { border-color: var(--accent); border-style: dashed; background: var(--accent-soft); }
.thumbs { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.thumbs:empty { display: none; }
.thumb { position: relative; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; border: 1px solid var(--border); }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.thumb button {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 50%;
  border: 0; background: rgb(0 0 0 / 0.65); color: #fff; cursor: pointer; font-size: 12px; line-height: 20px; padding: 0;
}
.composer-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 14px; flex-wrap: wrap; }
.data-notice { font-size: 12px; margin: 8px 2px 0; line-height: 1.4; }
#ocrBtn[hidden], #ocrStatus[hidden] { display: none; }

/* ---------- Draft ---------- */
.empty {
  display: grid; place-items: center; text-align: center; gap: 10px;
  min-height: 330px; padding: 24px; border: 1px dashed var(--border); border-radius: 12px; color: var(--muted);
}
.empty .glyph { width: 52px; height: 52px; border-radius: 14px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); }
.empty .glyph svg { width: 26px; height: 26px; }
.empty b { color: var(--ink); font-weight: 600; }

.thinking { display: grid; gap: 12px; min-height: 330px; align-content: start; }
.thinking .status { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--accent-soft); border-top-color: var(--accent); animation: spin 0.8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.skeleton { height: 38px; border-radius: 10px; background: linear-gradient(90deg, var(--surface-2), var(--border), var(--surface-2)); background-size: 200% 100%; animation: shimmer 1.3s infinite; }
.skeleton.tall { height: 120px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.warnings { display: grid; gap: 6px; margin-bottom: 14px; }
.warning {
  display: flex; gap: 8px; align-items: flex-start; padding: 9px 12px; border-radius: 10px;
  background: var(--warn-soft); color: var(--warn); font-size: 13.5px; font-weight: 500;
}
.warning svg { margin-top: 1px; }

.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.items { margin-top: 16px; }
.items-head, .item-row { display: grid; grid-template-columns: minmax(0, 1fr) 58px 90px 88px 28px; gap: 8px; align-items: center; }
.items-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 0 2px 6px; text-transform: uppercase; letter-spacing: 0.04em; }
.item-row { padding: 6px 0; border-top: 1px solid var(--border); }
.item-row input { padding: 7px 9px; }
.item-row .line-total { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.item-row .num { text-align: right; }
.item-evidence { grid-column: 1 / -1; color: var(--muted); font-size: 12px; line-height: 1.4; overflow-wrap: anywhere; }
.evidence-note { font-size: 12px; margin: 8px 0 0; }
.remove { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); border-radius: 8px; cursor: pointer; display: grid; place-items: center; }
.remove:hover { background: var(--bad-soft); color: var(--bad); }
.add-line { margin-top: 6px; background: none; border: 0; color: var(--accent); font: 600 13px var(--font); cursor: pointer; padding: 6px 0; }

.draft-foot { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px; align-items: end; margin-top: 14px; }
.total { text-align: right; }
.total span { display: block; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.total strong { font-size: 28px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.send-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 16px; flex-wrap: wrap; }
.send-row .muted { font-size: 13px; }

.success { display: grid; gap: 14px; justify-items: start; min-height: 330px; align-content: center; padding: 8px; }
.success .badge { width: 48px; height: 48px; border-radius: 50%; display: grid; place-items: center; background: var(--ok-soft); color: var(--ok); }
.success .badge svg { width: 26px; height: 26px; stroke-width: 2.4; }
.success h3 { font-size: 22px; }
.success .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.linkbox { display: flex; gap: 8px; width: 100%; }
.linkbox input { font-size: 13px; color: var(--muted); }

/* ---------- Receivables ---------- */
.receivables { margin-top: 40px; display: grid; gap: 16px; }
.section-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; flex-wrap: wrap; }
.section-head p { font-size: 13px; margin-top: 4px; }
.section-tools { display: flex; gap: 8px; }
.section-tools input { width: 220px; }

.kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.kpi { padding: 16px 18px; background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.kpi span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.kpi { min-width: 0; }
.kpi strong { display: block; font-size: clamp(18px, 5.4vw, 26px); overflow-wrap: anywhere; font-weight: 500; margin-top: 4px; }
.kpi small { font-size: 12.5px; color: var(--muted); }
.kpi.bad strong { color: var(--bad); }
.kpi.ok strong { color: var(--ok); }

.copilot { padding: 14px; }
.copilot-form { display: flex; align-items: center; gap: 10px; }
.copilot-form > svg { color: var(--accent); margin-left: 4px; }
.copilot-form input { border-color: transparent; background: var(--surface-2); }
.copilot-suggestions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.copilot-answer[hidden] { display: none; }
.copilot-answer { margin-top: 12px; padding: 14px; border-radius: 12px; background: var(--accent-soft); display: grid; gap: 12px; }
.copilot-answer p { font-size: 14.5px; }
.copilot-answer .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Insights: aging chart + activity feed */
.insights { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.2fr); gap: 16px; }
.aging, .activity { padding: 18px; }
.mini-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.mini-head h3 { font-size: 15px; font-weight: 600; }
.mini-head .muted { font-size: 12.5px; }
.aging-chart { display: grid; gap: 12px; }
#clearAging[hidden] { display: none; }
.aging-row { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 12px; align-items: center; font: inherit; font-size: 13px; width: 100%; border: 0; background: transparent; text-align: left; cursor: pointer; border-radius: 6px; padding: 3px; color: inherit; }
.aging-row[aria-pressed="true"] { outline: 2px solid var(--accent); }
.aging-row:focus-visible { outline: 2px solid var(--accent); }
.aging-row .label { color: var(--muted); font-weight: 600; }
.aging-track { position: relative; height: 28px; display: flex; align-items: center; gap: 10px; }
.aging-bar {
  height: 18px; min-width: 4px; border-radius: 0 4px 4px 0; background: var(--bar);
  transform-origin: left; animation: grow 0.7s cubic-bezier(.2,.8,.2,1) both;
}
.aging-value { white-space: nowrap; font-variant-numeric: tabular-nums; font-weight: 600; color: var(--ink); }
.aging-value small { color: var(--muted); font-weight: 500; margin-left: 4px; }
.aging-row:hover .aging-bar { filter: brightness(1.12); }
@keyframes grow { from { transform: scaleX(0); } }
.aging-row[data-bucket="0"] { --bar: color-mix(in srgb, var(--accent) 35%, var(--surface-2)); }
.aging-row[data-bucket="1"] { --bar: color-mix(in srgb, var(--accent) 60%, var(--surface-2)); }
.aging-row[data-bucket="2"] { --bar: color-mix(in srgb, var(--accent) 82%, var(--surface-2)); }
.aging-row[data-bucket="3"] { --bar: var(--accent); }

.live-dot { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ok); }
.live-dot i { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: 0.3; } }
.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; max-height: 236px; overflow-y: auto; }
.feed li { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 7px 4px; border-radius: 8px; font-size: 13.5px; }
.feed li.new { animation: feedIn 0.5s ease both; background: var(--accent-soft); }
.feed .ico { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; }
.feed .ico svg { width: 15px; height: 15px; }
.feed .ico.ai { background: var(--accent-soft); color: var(--accent); }
.feed .ico.agent { background: var(--accent); color: var(--accent-ink); }
.feed .ico.paypal { background: var(--info-soft); color: var(--info); }
.feed .ico.payment { background: var(--ok-soft); color: var(--ok); }
.feed time { font-size: 12px; color: var(--muted); white-space: nowrap; }
.feed .empty-feed { color: var(--muted); font-size: 13px; padding: 8px 4px; }
@keyframes feedIn { from { opacity: 0; transform: translateY(-6px); } }

.grid-card { padding: 0; overflow: hidden; }

/* AG Grid toolbar, progress cells, totals */
.grid-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 16px 0; }
.seg { display: inline-flex; gap: 8px; padding: 4px; background: var(--surface-2); border-radius: 10px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; color: var(--muted); font: 500 13.5px var(--font); min-height: 44px; padding: 0 14px; border-radius: 8px; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.seg button:focus-visible { outline: 2px solid var(--accent); }
.cell-progress { display: flex; align-items: center; gap: 8px; height: 100%; }
.cell-progress .bar { position: relative; flex: 1; height: 8px; border-radius: 4px; background: var(--surface-2); overflow: hidden; }
.cell-progress .bar span { position: absolute; inset: 0 auto 0 0; border-radius: 4px; background: var(--accent); }
.cell-progress .bar.full span { background: var(--ok); }
.cell-progress .bar i { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--surface); }
.cell-progress small { width: 34px; text-align: right; font-variant-numeric: tabular-nums; color: var(--muted); font-weight: 600; }
.ag-row-pinned { font-weight: 600; }
.ag-row-pinned .cell-client small { font-weight: 500; }

/* Payment plan dialog */
.plan-why { font-size: 13.5px; margin: 0; }
.plan-schedule { display: grid; gap: 6px; }
.plan-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) minmax(0, 1fr) 28px; gap: 8px; align-items: center; }
.plan-head { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.plan-row .plan-rank { color: var(--accent); font-weight: 700; }
.plan-row input { padding: 7px 9px; }
.plan-check { margin: 0; font-size: 13.5px; font-weight: 600; }
.plan-check.ok { color: var(--ok); }
.plan-check.bad { color: var(--bad); }
.plan-effect { font-size: 12.5px; margin: 0; }
.nudge-btn.plan { border-color: color-mix(in srgb, var(--info) 45%, var(--border)); }
.dialog .ap { overflow-y: auto; }

/* Voice note recording state */
#voiceBtn.recording { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
#voiceBtn.recording svg { animation: blink 1s infinite; }
#voiceBtn[hidden], #audioUpload[hidden] { display: none; }

/* Tabs under the KPIs */
.tabs { display: flex; gap: 8px; padding: 4px; background: var(--surface-2); border-radius: 12px; width: fit-content; max-width: 100%; overflow-x: auto; }
.tab { border: 0; background: transparent; color: var(--muted); font: 500 14px var(--font); min-height: 44px; padding: 0 16px; border-radius: 9px; cursor: pointer; white-space: nowrap; }
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.tab:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.tab-panel { display: grid; gap: 16px; }
.tab-panel[hidden] { display: none; }
.tab-panel .recovery-plan { margin: 0; }
.link-btn { border: 0; background: none; padding: 0; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.recovery-plan { margin: 0 0 20px; padding: 20px; }
.recovery-plan .mini-head { align-items: flex-start; gap: 16px; }
.recovery-plan .mini-head p { margin: 5px 0 0; font-size: 13px; }
.plan-list { display: grid; gap: 8px; margin-top: 14px; }
.plan-item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); }
.plan-item .plan-rank { color: var(--accent); font-weight: 700; min-width: 24px; }
.plan-item .plan-details { flex: 1; min-width: 0; }
.plan-item .plan-details small { display: block; color: var(--muted); margin-top: 3px; }
.plan-item .plan-amount { font-weight: 700; white-space: nowrap; }
.plan-note { margin: 10px 0 0; font-size: 12px; }
@media (max-width: 600px) {
  .recovery-plan .mini-head { flex-wrap: wrap; }
  .plan-item { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 6px 12px; align-items: center; }
  .plan-item .plan-details { grid-column: 2 / -1; }
  .plan-item .plan-amount { grid-column: 2 / -1; }
  .plan-item .btn { grid-column: 1 / -1; width: 100%; }
}
.ag-row.just-paid { animation: paidFlash 2.4s ease; }
@keyframes paidFlash { 0%, 60% { background: var(--ok-soft); } }

/* Autopilot dialog */
.dialog.wide { width: min(760px, calc(100vw - 32px)); }
.ap { display: grid; gap: 14px; padding: 20px; max-height: min(86vh, 900px); }
.ap header, .ap footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.ap footer { align-items: center; flex-wrap: wrap; padding-top: 4px; }
.ap h3 { font-size: 18px; }
.ap .muted { font-size: 13px; }
.ap-steps { list-style: none; margin: 0; padding: 0; display: flex; gap: 6px; flex-wrap: wrap; }
.ap-steps li { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.ap-steps li.active { background: var(--accent-soft); color: var(--accent); }
.ap-steps li.done { background: var(--ok-soft); color: var(--ok); }
.ap-steps li .spinner { width: 12px; height: 12px; }
.ap-list { display: grid; gap: 10px; overflow-y: auto; min-height: 120px; padding-right: 2px; }
.ap-card { border: 1px solid var(--border); border-radius: 14px; padding: 14px; display: grid; gap: 10px; animation: feedIn 0.4s ease both; }
.ap-card.off { opacity: 0.55; }
.ap-card.sent { border-color: color-mix(in srgb, var(--ok) 50%, var(--border)); background: color-mix(in srgb, var(--ok-soft) 50%, transparent); }
.ap-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ap-top input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--accent); margin: 0; }
.ap-top b { font-size: 15px; }
.ap-top .meta { font-size: 12.5px; color: var(--muted); }
.ap-top .state { margin-left: auto; font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.ap-top .state.ok { color: var(--ok); }
.ap-top .state.err { color: var(--bad); }
.ap-card input.subject { font-weight: 600; }
.ap-card textarea { font-size: 13.5px; line-height: 1.5; }
.ap-card .skeleton { height: 64px; }
.ap-empty { text-align: center; padding: 28px; color: var(--muted); border: 1px dashed var(--border); border-radius: 14px; }

/* Draft entrance + celebration */
.reveal > * { animation: feedIn 0.45s ease both; }
.reveal > *:nth-child(2) { animation-delay: 0.05s; }
.reveal > *:nth-child(3) { animation-delay: 0.1s; }
.reveal > *:nth-child(4) { animation-delay: 0.15s; }
.reveal > *:nth-child(5) { animation-delay: 0.2s; }
#confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 60; }
.toast.paid { background: var(--ok); color: #fff; font-size: 15px; padding: 13px 18px; }
.watching { display: inline-flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.watching i { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); animation: blink 1.4s infinite; }
.grid { width: 100%; }

/* Cell renderers */
.cell-client { display: flex; flex-direction: column; justify-content: center; line-height: 1.3; height: 100%; min-width: 0; }
.cell-client b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; }
.cell-client small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pill { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.4; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.info { background: var(--info-soft); color: var(--info); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.neutral { background: var(--surface-2); color: var(--muted); }
.cell-due { display: flex; flex-direction: column; justify-content: center; line-height: 1.3; height: 100%; }
.cell-due small { font-weight: 600; }
.cell-due small.bad { color: var(--bad); }
.cell-due small.muted { font-weight: 500; }
.cell-actions { display: flex; align-items: center; gap: 6px; height: 100%; }
.nudge-btn { height: 30px; padding: 0 10px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); font: 600 12.5px var(--font); cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
.nudge-btn:hover { border-color: var(--accent); color: var(--accent); }
.nudge-btn.firm { border-color: color-mix(in srgb, var(--warn) 45%, var(--border)); }
.nudge-btn.final { border-color: color-mix(in srgb, var(--bad) 45%, var(--border)); }
.nudge-btn svg { width: 14px; height: 14px; }
.open-link { color: var(--muted); display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px; }
.open-link:hover { background: var(--surface-2); color: var(--ink); }
.open-link svg { width: 16px; height: 16px; }

/* ---------- Dialog ---------- */
.dialog {
  width: min(560px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 18px;
  padding: 0; background: var(--surface); color: var(--ink); box-shadow: 0 30px 80px rgb(0 0 0 / 0.25);
}
.dialog::backdrop { background: rgb(15 16 20 / 0.45); backdrop-filter: blur(2px); }
.dialog form { display: grid; gap: 14px; padding: 20px; }
.dialog header, .dialog footer { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.dialog footer { align-items: center; flex-wrap: wrap; }
.dialog h3 { font-size: 18px; }
.dialog .muted { font-size: 13px; margin-top: 2px; }
.spacer { flex: 1; }
.tone { display: flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 3px; }
.tone label { flex: 1; }
.tone label { position: relative; }
.tone input { position: absolute; inset: 0; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.tone span { display: block; text-align: center; padding: 7px 8px; border-radius: 8px; font-size: 13.5px; font-weight: 600; color: var(--muted); cursor: pointer; }
.tone input:checked + span { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgb(0 0 0 / 0.12); }
.tone input:focus-visible + span { outline: 2px solid var(--accent); }
.dialog textarea.loading, .dialog input.loading { color: var(--muted); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0;
  background: var(--ink); color: var(--bg); padding: 11px 16px; border-radius: 12px; font-weight: 500; font-size: 14px;
  max-width: calc(100vw - 32px); transition: opacity 0.2s ease, transform 0.2s ease; pointer-events: none; z-index: 50;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: #8c1d18; color: #fff; }

.footer { border-top: 1px solid var(--border); font-size: 12.5px; padding: 24px 0 32px; }
.footer-inner { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .create { grid-template-columns: 1fr; }
  .insights { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 36px; min-height: 0; padding: calc(var(--nav-h) + 36px) 0 40px; }
  .create { padding-top: calc(var(--nav-h) + 48px); }
}
@media (max-width: 960px) {
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 600px) {
  .hero { padding-top: 24px; }
  .topbar { position: sticky; }
  .create, .receivables { padding-top: 40px; }
  main.wrap > section.create, main.wrap > section.receivables { padding-bottom: 40px; }
  .form-grid { grid-template-columns: 1fr; }
  .items-head { display: none; }
  .item-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) 28px; }
  .item-row input[data-item="name"] { grid-column: 1 / -1; }
  .item-row .line-total { display: none; }
  .section-tools { width: 100%; flex-wrap: wrap; }
  .section-tools .search-field { flex: 1; min-width: 0; }
  .section-tools .search-field input { flex: 1; width: auto; min-width: 0; }
  .topbar { height: auto; min-height: var(--nav-h); padding-block: 8px; }
  .topbar-inner { flex-wrap: wrap; }
  .tabs { width: 100%; }
  .kpi { padding: 14px 12px; }
  .tabs .tab { flex: 1 1 auto; padding-inline: 8px; font-size: 13px; }
  .section-tools #autopilotBtn { width: 100%; }
  .hero-actions .btn { flex: 1 1 100%; }
  .af-body { grid-template-columns: 1fr; min-height: 0; }
  .af-chat { border-right: 0; border-bottom: 1px solid var(--border); }
  .aging-row { grid-template-columns: 74px minmax(0, 1fr); }
  .composer-actions .btn { flex: 1; }
  .chip.hide-sm { display: none; }
  .draft-foot { grid-template-columns: 1fr; }
  .total { text-align: left; }
}

/* Seller workspace ------------------------------------------------------------------------- */
.chip-btn { cursor: pointer; font: inherit; }
.chip-btn:hover { border-color: var(--line-strong); color: var(--ink); }
.chip-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#sellerDialog .tabs { width: 100%; }
#sellerDialog .tab-panel { gap: 12px; }
.cat-list { display: grid; gap: 6px; }
.cat-row { display: grid; grid-template-columns: minmax(0, 1fr) 110px 72px 36px; gap: 8px; align-items: center; }
.cat-row input { padding: 7px 9px; min-width: 0; }
.cat-head { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.cat-actions, .rec-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.cat-actions .spacer, .rec-actions .spacer { flex: 1; }
.item-catalog { grid-column: 1 / -1; font-size: 12px; color: var(--info); }
.settings-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 8px; background: var(--surface-2); }
.settings-card h4 { margin: 0; font-size: 15px; }
.settings-card .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.code-pill { font-family: var(--mono); font-size: 15px; letter-spacing: .06em; padding: 6px 10px; border-radius: 8px; background: var(--surface); border: 1px solid var(--border); }
@media (max-width: 600px) {
  .cat-row { grid-template-columns: minmax(0, 1fr) 90px 36px; }
  .cat-row > :nth-child(3) { display: none; }
}

/* Approval queue ------------------------------------------------------------------------- */
.approvals-head { justify-content: space-between; align-items: flex-start; flex-wrap: wrap; }
.approvals-list { display: grid; gap: 12px; }
.q-card { border: 1px solid var(--border); border-radius: 12px; padding: 14px; display: grid; gap: 10px; background: var(--surface-2); }
.q-card.is-done { opacity: .72; }
.q-card header, .q-card footer { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.q-card footer { justify-content: flex-end; align-items: center; }
.q-card header p { margin: 2px 0 0; font-size: 13px; }
.q-card header strong { font-family: var(--mono); font-weight: 500; }
.q-items { margin: 0; padding: 0; list-style: none; display: grid; gap: 4px; }
.q-items li { display: flex; justify-content: space-between; gap: 10px; font-size: 14px; }
.q-plan { margin: 0; font-family: var(--mono); font-size: 13px; color: var(--accent); }
.q-status { font-size: 13px; font-weight: 600; color: var(--muted); }
.q-status.approved { color: var(--ok); }
.q-status.failed { color: var(--bad); }
.tab-count { display: inline-grid; place-items: center; min-width: 20px; height: 20px; padding: 0 6px; margin-left: 4px; border-radius: 999px; background: var(--accent); color: var(--accent-ink); font-size: 12px; font-weight: 700; }
.tab-count[hidden] { display: none; }
.rec-list { display: grid; gap: 10px; }
.rec-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.rec-grid .rec-wide { grid-column: span 3; }
.rec-grid input, .rec-grid select { min-width: 0; }
@media (max-width: 600px) { .rec-grid { grid-template-columns: 1fr; } .rec-grid .rec-wide { grid-column: auto; } }

/* Collection metrics ---------------------------------------------------------------------- */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 10px; }
.metric { border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: grid; gap: 4px; background: var(--surface-2); min-width: 0; }
.metric span { font-size: 12.5px; font-weight: 600; color: var(--muted); }
.metric strong { font-family: var(--mono); font-size: 22px; font-weight: 500; overflow-wrap: anywhere; }
.metric strong small { font-size: 13px; color: var(--muted); }
.metric small { font-size: 12px; color: var(--muted); }
.metrics-note { font-size: 12.5px; margin: 10px 0 0; }
