@import url("https://fonts.googleapis.com/css2?family=Golos+Text:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&family=Unbounded:wght@600&display=swap");

:root {
  --ground: #F2F5F4;
  --panel: #FFFFFF;
  --sunk: #F6F9F8;
  --line: #D2DDDB;
  --line-soft: #E4EBEA;
  --ink: #0E1A1C;
  --dim: #5C7072;
  --faint: #8A9A9B;
  --accent: #12787E;
  --accent-hover: #0E676C;
  --accent-ink: #FFFFFF;
  --accent-soft: #12787E17;
  --danger: #B4413C;
  --side: #0F2224;
  --side-ink: #DCE8E6;
  --side-dim: #87A1A0;
  --side-hover: #173133;
  --focus: #12787E66;
  --shadow: 0 1px 2px rgba(14, 26, 28, .04), 0 12px 32px -22px rgba(14, 26, 28, .35);

  --st-lead: #66797B;
  --st-demo: #3E63B8;
  --st-pilot: #A86A12;
  --st-paying: #1C7F46;
  --st-paused: #82653F;
  --st-churned: #B4413C;

  --sans: "Golos Text", -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Unbounded", "Golos Text", -apple-system, sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, Menlo, Consolas, monospace;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0A1212;
    --panel: #111C1C;
    --sunk: #0D1616;
    --line: #243433;
    --line-soft: #1B2928;
    --ink: #E4EDEB;
    --dim: #8FA5A4;
    --faint: #647978;
    --accent: #3FAFAC;
    --accent-hover: #55C2BF;
    --accent-ink: #062021;
    --accent-soft: #3FAFAC1F;
    --danger: #E27771;
    --side: #060D0D;
    --side-ink: #D5E3E1;
    --side-dim: #7A9391;
    --side-hover: #102020;
    --focus: #3FAFAC66;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 36px -24px rgba(0, 0, 0, .9);
    --st-lead: #9AAEAF;
    --st-demo: #86A5EE;
    --st-pilot: #E2AE55;
    --st-paying: #55C585;
    --st-paused: #C8A67C;
    --st-churned: #E27771;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ground: #0A1212;
  --panel: #111C1C;
  --sunk: #0D1616;
  --line: #243433;
  --line-soft: #1B2928;
  --ink: #E4EDEB;
  --dim: #8FA5A4;
  --faint: #647978;
  --accent: #3FAFAC;
  --accent-hover: #55C2BF;
  --accent-ink: #062021;
  --accent-soft: #3FAFAC1F;
  --danger: #E27771;
  --side: #060D0D;
  --side-ink: #D5E3E1;
  --side-dim: #7A9391;
  --side-hover: #102020;
  --focus: #3FAFAC66;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 14px 36px -24px rgba(0, 0, 0, .9);
  --st-lead: #9AAEAF;
  --st-demo: #86A5EE;
  --st-pilot: #E2AE55;
  --st-paying: #55C585;
  --st-paused: #C8A67C;
  --st-churned: #E27771;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--ground);
  color: var(--ink);
  font: 400 14px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 1px; }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); font-size: .93em; }
.num { font-variant-numeric: tabular-nums; }
.dim { color: var(--dim); }
.faint { color: var(--faint); }
.nowrap { white-space: nowrap; }

/* ---------- brand ---------- */
.brand { display: flex; align-items: center; gap: 10px; font: 600 16px/1 var(--display); letter-spacing: .01em; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px; background: var(--accent);
  display: grid; place-items: center; flex: none;
}
.brand-mark svg { width: 18px; height: 18px; }
.brand-mark path { stroke: var(--accent-ink); }
.brand small { display: block; font: 500 11px/1.2 var(--sans); letter-spacing: .08em; text-transform: uppercase; margin-top: 4px; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.side {
  background: var(--side); color: var(--side-ink);
  padding: calc(22px + env(safe-area-inset-top, 0px)) 14px 18px;
  display: flex; flex-direction: column; gap: 26px;
  position: sticky; top: 0; height: 100vh;
}
.side .brand { padding: 0 10px; color: var(--side-ink); }
.side .brand small { color: var(--side-dim); }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav a {
  display: flex; align-items: center; gap: 11px; padding: 9px 10px; border-radius: 9px;
  color: var(--side-dim); font-weight: 500; text-decoration: none;
}
.nav a svg { width: 18px; height: 18px; flex: none; }
.nav a svg * { stroke: currentColor; }
.nav a:hover { background: var(--side-hover); color: var(--side-ink); }
.nav a[aria-current="page"] { background: var(--side-hover); color: var(--side-ink); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: 0 10px; display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--side-dim); }
.side-foot .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.link-btn { background: none; border: 0; padding: 0; color: var(--side-dim); cursor: pointer; text-align: left; font-size: 12px; }
.link-btn:hover { color: var(--side-ink); text-decoration: underline; }

.main { padding: 30px clamp(16px, 3.4vw, 40px) 64px; min-width: 0; }
.page { max-width: 1160px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .side {
    position: sticky; height: auto; z-index: 5; flex-direction: row; align-items: center;
    gap: 14px; padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px; overflow-x: auto;
  }
  .side .brand small, .side-foot .who { display: none; }
  .side .brand { padding: 0; }
  .nav { flex-direction: row; }
  .nav a { padding: 7px 10px; }
  .nav a span { display: none; }
  .nav a[aria-current="page"] { box-shadow: inset 0 -2px 0 var(--accent); }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
  .main { padding-top: 20px; }
}

/* ---------- page head ---------- */
.crumb { font-size: 13px; color: var(--dim); display: inline-flex; gap: 4px; align-items: center; align-self: flex-start; }
.crumb svg * { stroke: currentColor; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.head h1 { margin: 0; font: 600 24px/1.2 var(--display); letter-spacing: -.005em; text-wrap: balance; }
.head .sub { margin: 6px 0 0; color: var(--dim); }
.head-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.venue-id {
  display: inline-block; font: 500 12px/1 var(--mono); color: var(--accent); background: var(--accent-soft);
  padding: 5px 7px; border-radius: 6px; margin-bottom: 10px; letter-spacing: .02em;
}

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 36px; padding: 0 14px; border-radius: 9px; border: 1px solid var(--line);
  background: var(--panel); color: var(--ink); font-weight: 500; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--faint); text-decoration: none; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn.small { height: 30px; padding: 0 10px; font-size: 13px; border-radius: 8px; }
.btn.quiet { border-color: transparent; background: transparent; color: var(--dim); }
.btn.quiet:hover { color: var(--ink); background: var(--sunk); }
.btn.danger:hover { color: var(--danger); }
.btn:disabled { opacity: .55; cursor: default; }
.btn svg { width: 16px; height: 16px; }
.btn svg * { stroke: currentColor; }

.input, .select, .textarea {
  width: 100%; min-height: 36px; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--sunk);
  transition: border-color .12s, background .12s;
}
.textarea { resize: vertical; min-height: 72px; line-height: 1.45; }
.input:hover, .select:hover, .textarea:hover { border-color: var(--faint); }
.input:focus, .select:focus, .textarea:focus { outline: none; border-color: var(--accent); background: var(--panel); box-shadow: 0 0 0 3px var(--accent-soft); }
.input.mono, .textarea.mono { font-family: var(--mono); font-size: 12.5px; }
.textarea.mono { word-break: break-all; }
.input.bare { border-color: transparent; background: transparent; padding-left: 6px; padding-right: 6px; min-height: 30px; }
.input.bare:hover { border-color: var(--line); }
.input.bare:focus { background: var(--panel); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 500; color: var(--dim); }
.field .hint { font-size: 12px; color: var(--faint); }
.field .hint.ok { color: var(--st-paying); }
.field .hint.bad { color: var(--danger); }
.field.saved .input, .field.saved .select, .field.saved .textarea { border-color: var(--st-paying); }
.field.error .input, .field.error .select, .field.error .textarea { border-color: var(--danger); }
.grid-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px 16px; }
.grid-fields .wide { grid-column: 1 / -1; }
@media (max-width: 560px) { .grid-fields { grid-template-columns: 1fr; } }

.search { position: relative; flex: 1 1 240px; max-width: 320px; }
.search svg { position: absolute; left: 10px; top: 50%; width: 16px; height: 16px; transform: translateY(-50%); }
.search svg * { stroke: var(--faint); }
.search .input { padding-left: 34px; background: var(--panel); }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px 0; }
.card-head h2 { margin: 0; font-size: 15px; font-weight: 600; }
.card-head .meta { font-size: 12px; color: var(--faint); }
.card-body { padding: 16px 20px 20px; }
.card-body.flush { padding: 10px 0 6px; }
.split { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(280px, 1fr); gap: 20px; align-items: start; }
.stack { display: flex; flex-direction: column; gap: 20px; min-width: 0; }
@media (max-width: 1020px) { .split { grid-template-columns: 1fr; } }

/* ---------- stats ---------- */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
@media (max-width: 900px) { .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.stat { padding: 16px 18px 18px; display: flex; flex-direction: column; gap: 6px; }
.stat .label { font-size: 12px; color: var(--dim); font-weight: 500; }
.stat .value { font: 600 26px/1.1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat .value small { font-size: 14px; font-weight: 500; color: var(--dim); margin-left: 4px; }
.stat .foot { font-size: 12px; color: var(--faint); }
.stat.accent { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.stat.accent .label, .stat.accent .foot, .stat.accent .value small { color: var(--accent-ink); opacity: .78; }

/* ---------- chips ---------- */
.chip {
  --c: var(--st-lead);
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 9px 0 8px; border-radius: 99px;
  font-size: 12px; font-weight: 500; white-space: nowrap;
  color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent);
}
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.chip.plain::before { display: none; }
.st-lead { --c: var(--st-lead); }
.st-demo { --c: var(--st-demo); }
.st-pilot { --c: var(--st-pilot); }
.st-paying { --c: var(--st-paying); }
.st-paused { --c: var(--st-paused); }
.st-churned { --c: var(--st-churned); }
.ok-c { --c: var(--st-paying); }
.warn-c { --c: var(--st-pilot); }
.muted-c { --c: var(--st-lead); }

/* stage filter & segmented control */
.seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 3px; border-radius: 10px; background: var(--panel); border: 1px solid var(--line); }
.seg button {
  border: 0; background: transparent; height: 30px; padding: 0 11px; border-radius: 7px; cursor: pointer;
  color: var(--dim); font-weight: 500; font-size: 13px; display: inline-flex; align-items: center; gap: 6px;
}
.seg button:hover { color: var(--ink); background: var(--sunk); }
.seg button[aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.seg button .count { font-size: 11px; opacity: .7; font-variant-numeric: tabular-nums; }
.seg.stages button[aria-pressed="true"] { background: color-mix(in srgb, var(--c, var(--ink)) 16%, transparent); color: var(--c, var(--ink)); }
.seg.stages button[data-v="all"][aria-pressed="true"] { background: var(--ink); color: var(--panel); }
.toolbar { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; justify-content: space-between; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.t th {
  text-align: left; font-size: 11.5px; font-weight: 500; color: var(--faint); text-transform: uppercase; letter-spacing: .05em;
  padding: 10px 12px; border-bottom: 1px solid var(--line-soft); white-space: nowrap;
}
.t td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t th:first-child, .t td:first-child { padding-left: 20px; }
.t th:last-child, .t td:last-child { padding-right: 20px; }
.t .r { text-align: right; }
.t tbody tr.link { cursor: pointer; }
.t tbody tr.link:hover td { background: var(--sunk); }
.t .title { font-weight: 500; color: var(--ink); }
.t .title:hover { text-decoration: none; color: var(--accent); }
.t .second { font-size: 12px; color: var(--faint); margin-top: 1px; }
.t tfoot td { font-weight: 600; border-top: 1px solid var(--line); border-bottom: 0; }
.t td.edit { padding-top: 5px; padding-bottom: 5px; }

.empty { padding: 34px 20px; text-align: center; color: var(--dim); display: flex; flex-direction: column; gap: 10px; align-items: center; }
.empty strong { color: var(--ink); font-weight: 600; }

/* ---------- funnel ---------- */
.funnel { display: flex; flex-direction: column; gap: 10px; }
.funnel-row { display: grid; grid-template-columns: 86px minmax(0, 1fr) 34px; gap: 12px; align-items: center; font-size: 13px; }
.funnel-bar { height: 10px; border-radius: 99px; background: var(--line-soft); overflow: hidden; }
.funnel-bar i { display: block; height: 100%; border-radius: 99px; background: var(--c); min-width: 0; }
.funnel-row .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }

/* ---------- lists ---------- */
.list { display: flex; flex-direction: column; }
.list-item { display: flex; gap: 12px; align-items: flex-start; justify-content: space-between; padding: 12px 20px; border-top: 1px solid var(--line-soft); }
.list-item:first-child { border-top: 0; }
.list-item .grow { min-width: 0; flex: 1; }
.list-item .top { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; }
.list-item .name { font-weight: 500; }
.list-item .line { font-size: 13px; color: var(--dim); display: flex; gap: 12px; flex-wrap: wrap; margin-top: 2px; }
.role { font-size: 11.5px; color: var(--faint); text-transform: uppercase; letter-spacing: .05em; }

.note { padding: 12px 20px; border-top: 1px solid var(--line-soft); display: flex; gap: 12px; }
.note .grow { flex: 1; min-width: 0; }
.note .text { white-space: pre-wrap; overflow-wrap: anywhere; }
.note .by { font-size: 12px; color: var(--faint); margin-top: 3px; }
.composer { padding: 14px 20px 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }

details.add { border-top: 1px solid var(--line-soft); }
details.add > summary {
  list-style: none; cursor: pointer; padding: 12px 20px; color: var(--accent); font-weight: 500; font-size: 13.5px;
  display: flex; align-items: center; gap: 8px;
}
details.add > summary::-webkit-details-marker { display: none; }
details.add > summary svg { width: 16px; height: 16px; }
details.add > summary svg * { stroke: currentColor; }
details.add[open] > summary { color: var(--dim); }
details.add form { padding: 0 20px 18px; display: flex; flex-direction: column; gap: 12px; }
.form-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ---------- money card ---------- */
.money { padding: 18px 20px 20px; display: flex; flex-direction: column; gap: 14px; }
.money .amount { font: 600 32px/1 var(--sans); font-variant-numeric: tabular-nums; letter-spacing: -.015em; }
.money .amount small { font-size: 15px; font-weight: 500; color: var(--dim); margin-left: 5px; }
.kv { display: grid; grid-template-columns: 1fr auto; gap: 7px 12px; font-size: 13.5px; }
.kv dt { color: var(--dim); }
.kv dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }
.money .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.monthnav { display: inline-flex; align-items: center; gap: 4px; background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 3px; }
.monthnav span { min-width: 136px; text-align: center; font-weight: 600; font-size: 14px; }
.monthnav .btn { height: 30px; width: 30px; padding: 0; border: 0; }

.bar-mini { display: inline-block; width: 46px; height: 5px; border-radius: 9px; background: var(--line-soft); vertical-align: middle; margin-right: 8px; overflow: hidden; }
.bar-mini i { display: block; height: 100%; background: var(--accent); }
.bar-mini.full i { background: var(--st-paying); }

.switch { position: relative; width: 34px; height: 20px; flex: none; appearance: none; -webkit-appearance: none; margin: 0; border-radius: 99px; background: var(--line); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--panel); transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch:checked { background: var(--accent); }
.switch:checked::after { transform: translateX(14px); }

/* ---------- dialog & toast ---------- */
dialog.modal {
  border: 1px solid var(--line); border-radius: 16px; padding: 0; width: min(440px, calc(100vw - 32px));
  background: var(--panel); color: var(--ink); box-shadow: 0 30px 80px -30px rgba(0,0,0,.55);
}
dialog.modal::backdrop { background: rgba(8, 18, 18, .42); }
dialog.modal form { padding: 22px 22px 20px; display: flex; flex-direction: column; gap: 14px; }
dialog.modal h2 { margin: 0 0 2px; font: 600 18px/1.25 var(--display); }

.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 12px);
  background: var(--ink); color: var(--panel); padding: 10px 16px; border-radius: 10px; font-weight: 500; font-size: 13.5px;
  opacity: 0; pointer-events: none; transition: opacity .18s, transform .18s; z-index: 50; max-width: calc(100vw - 32px);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.bad { background: var(--danger); color: #fff; }

.loading { padding: 60px 0; text-align: center; color: var(--faint); }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }

/* ---------- sign-in ---------- */
.login-page { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background:
  radial-gradient(900px 480px at 85% -10%, var(--accent-soft), transparent 70%), var(--ground); }
.login { width: min(400px, 100%); display: flex; flex-direction: column; gap: 22px; }
.login .brand { font-size: 18px; }
.login .brand small { color: var(--dim); }
.login .card { padding: 26px 24px 24px; display: flex; flex-direction: column; gap: 16px; }
.login h1 { margin: 0; font: 600 20px/1.25 var(--display); }
.login p { margin: 0; color: var(--dim); }
.login .btn { height: 42px; }
.login .input { min-height: 42px; background: var(--panel); }
.code-input { font: 500 26px/1 var(--mono) !important; letter-spacing: .38em; text-align: center; padding-left: .38em !important; }
.login .err { color: var(--danger); font-size: 13px; min-height: 1.2em; }
.login .foot { text-align: center; font-size: 12px; color: var(--faint); }
