/* App, sign-in and hosted form styles. --brand is set per account (white label). */
:root {
  --brand: #4338ca;
  --bg: #f8fafc;
  --surface: #fff;
  --ink: #0f172a;
  --text: #1e293b;
  --body: #334155;
  --muted: #64748b;
  --faint: #94a3b8;
  --line: #e2e8f0;
  --line-soft: #eef2f6;
  --input: #cbd5e1;
  --danger: #e11d1d;
  --late: #dc2626;
  --warn: #c2410c;
  --ok: #15803d;
  --radius: 6px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 1px 3px rgba(15, 23, 42, .04);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px; line-height: 1.45; color: var(--text); background: var(--bg);
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0; color: var(--ink); }
code, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- Shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 213px; flex: 0 0 213px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar-inner { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 8px; padding: 10px 14px; height: 50px; border-bottom: 1px solid var(--line-soft); }
.brand-mark {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 6px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 14px; overflow: hidden;
}
.brand-mark img { width: 100%; height: 100%; object-fit: cover; }
.brand-text { min-width: 0; }
.brand-name { font-weight: 600; font-size: 13px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.2; }
.brand-sub { font-size: 10.5px; color: var(--faint); line-height: 1.3; }
.brand-sub.caps { text-transform: uppercase; letter-spacing: .03em; }
.nav { padding: 6px 0; }
.nav a { display: block; padding: 9px 18px; color: #374151; font-size: 13px; line-height: 17.5px; }
.nav a:hover { text-decoration: none; color: var(--ink); background: #f8fafc; }
.nav a.active { color: var(--ink); font-weight: 500; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line-soft); padding: 14px 14px 18px; font-size: 11px; }
.side-foot .who { color: var(--ink); font-size: 11.5px; }
.side-foot .role { color: var(--muted); margin-bottom: 8px; }
.side-foot form { margin: 0 0 14px; }
.side-foot .linkbtn { font-size: 11px; }
.powered { color: var(--faint); font-size: 10px; line-height: 1.25; }
.main { flex: 1; min-width: 0; padding: 22px 28px 40px 29px; }
.imp-bar { background: #fef3c7; color: #78350f; padding: 8px 29px; font-size: 12px; display: flex; gap: 12px; align-items: center; }

/* ---------- Page header ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 20px; }
.page-head h1 { font-size: 21px; font-weight: 600; letter-spacing: -.01em; line-height: 1.3; }
.page-head .sub { color: var(--muted); font-size: 13px; margin-top: 3px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.page-head .actions { display: flex; gap: 8px; margin-top: 16px; }
.flash { padding: 9px 12px; border-radius: var(--radius); margin-bottom: 16px; font-size: 13px; border: 1px solid; }
.flash.ok { background: #f0fdf4; border-color: #bbf7d0; color: #166534; }
.flash.error { background: #fef2f2; border-color: #fecaca; color: #991b1b; }
.flash.info { background: #eff6ff; border-color: #bfdbfe; color: #1e40af; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 32px; padding: 0 12px;
  border-radius: 4px; font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap;
  border: 1px solid var(--brand); background: var(--brand); color: #fff;
}
.btn:hover { text-decoration: none; filter: brightness(.95); }
.btn.secondary { background: #fff; color: var(--text); border-color: var(--input); font-weight: 400; }
.btn.secondary:hover { background: #f8fafc; filter: none; }
.btn.danger { background: var(--danger); border-color: var(--danger); }
.btn.sm { height: 24px; padding: 0 8px; font-size: 11px; font-weight: 400; }
.btn.block { width: 100%; }
.btn.lg { height: 42px; font-size: 15px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--brand); font: inherit; cursor: pointer; }
.linkbtn:hover { text-decoration: underline; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: #1e293b; display: inline-block; }
.dot.off { background: #fff; border: 1.5px solid #94a3b8; }

/* ---------- Grid & cards ---------- */
.grid { display: grid; gap: 14px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; }
.g-dash { grid-template-columns: 322px minmax(0, 1fr); gap: 22px; }
.g-lead { grid-template-columns: minmax(0, 1fr) 322px; gap: 22px; align-items: start; }
.g-tasks { grid-template-columns: minmax(0, 1fr) 322px; gap: 22px; align-items: start; }
.stack { display: grid; gap: 22px; }
.mb { margin-bottom: 22px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); min-width: 0; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; min-height: 40px; border-bottom: 1px solid var(--line-soft); }
.card-head h2, .card-head a { line-height: 19px; }
.card-head h2 { font-size: 13px; font-weight: 600; }
.card-head .meta { color: var(--muted); font-size: 11px; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 14px; }
.card-body.tight { padding: 0 14px; }
.card.danger-zone { border-color: #fca5a5; }
.empty { color: var(--muted); }
.stat { padding: 13px 14px 14px; min-height: 93px; }
.stat .label { text-transform: uppercase; font-size: 11px; color: #475569; letter-spacing: .03em; }
.stat .value { font-size: 21px; font-weight: 500; color: var(--ink); margin-top: 3px; line-height: 1.3; }
.stat .hint { font-size: 11px; color: var(--muted); margin-top: 4px; }
.stat.compact { min-height: 66px; padding: 12px; }
.stat.compact .value { font-size: 16px; font-weight: 600; margin-top: 8px; }

/* ---------- Forms ---------- */
label.f, .f-label { display: block; text-transform: uppercase; font-size: 11px; color: #475569; letter-spacing: .04em; margin-bottom: 4px; }
.field { margin-bottom: 11px; min-width: 0; }
.field .help { font-size: 10.5px; color: var(--faint); margin-top: 4px; line-height: 1.35; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=tel], input[type=url], input[type=date], input[type=datetime-local], input[type=search], select, textarea {
  width: 100%; height: 33px; padding: 6px 11px; border: 1px solid var(--input); border-radius: 4px; background: #fff;
  font: inherit; font-size: 13px; color: var(--ink); box-shadow: 0 1px 1px rgba(15, 23, 42, .04);
}
textarea { height: auto; min-height: 86px; line-height: 1.4; resize: vertical; }
textarea.mono { font-size: 12px; }
select { padding-right: 28px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--brand) 30%, transparent); outline-offset: 0; border-color: var(--brand); }
input[type=checkbox], input[type=radio] { accent-color: var(--brand); width: 13px; height: 13px; margin: 0; }
input[type=color] { width: 100%; height: 34px; padding: 4px 5px; border: 1px solid var(--input); border-radius: 4px; background: #fff; }
.row { display: grid; gap: 0 14px; }
.r2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.r3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.r4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; }
.span3 { grid-column: span 3; }
.check { display: flex; gap: 7px; align-items: flex-start; font-size: 13px; color: var(--text); line-height: 1.35; }
.check input { margin-top: 2px; }
.check small { display: block; color: var(--faint); font-size: 10.5px; }
.checks { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 9px 14px; }
.checks.c3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.inline { display: flex; gap: 8px; align-items: center; }
.inline > input, .inline > select { flex: 1; }
.code-box { background: #f1f5f9; border-radius: 4px; padding: 8px; font-size: 10.5px; line-height: 1.4; white-space: pre-wrap; word-break: break-all; color: #1e293b; margin: 0; }
details > summary { cursor: pointer; color: var(--brand); list-style: none; font-size: 13px; }
details > summary::before { content: '▸ '; font-size: 10px; }
details[open] > summary::before { content: '▾ '; }
details > summary u { text-underline-offset: 2px; }

/* ---------- Tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; font-size: 13px; }
.t th { text-align: left; text-transform: uppercase; font-size: 11px; font-weight: 500; color: #475569; letter-spacing: .04em; padding: 10px 11px; background: #f8fafc; border-bottom: 1px solid var(--line); white-space: nowrap; }
.t td { padding: 12px 11px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.t tr:last-child td { border-bottom: 0; }
.t td.small, .t .small { font-size: 11px; }
.t .sub { display: block; color: var(--muted); font-size: 11px; }
.t .num { text-align: right; }
.t.inner th { background: #f8fafc; }
.t.plain th { background: none; }
.t.compact td { padding: 9px 11px; }
.t.report td { padding: 8px 11px 7px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.late { color: var(--late); }
.warn-text { color: var(--warn); }
.small { font-size: 11px; }
.right { text-align: right; }
.nowrap { white-space: nowrap; }
.bar-cell { display: block; height: 3px; background: #e2e8f0; border-radius: 2px; margin-top: 6px; }
.bar-cell i { display: block; height: 3px; background: var(--brand); border-radius: 2px; }
.kv { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 12px; font-size: 13px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; color: var(--ink); }

/* ---------- Badges ---------- */
.pill { display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 11px; font-weight: 500; line-height: 16px; color: #fff; white-space: nowrap; }
.chip { display: inline-block; padding: 1px 7px; border-radius: 999px; font-size: 11px; line-height: 16px; white-space: nowrap; background: #f1f5f9; color: #334155; }
.chip.green { background: #dcfce7; color: #166534; }
.chip.yellow { background: #fef3c7; color: #92400e; }
.chip.red { background: #fee2e2; color: #b91c1c; }
.chip.purple { background: #f3e8ff; color: #7e22ce; }
.chip.blue { background: #dbeafe; color: #1e40af; }
.chip.caps { text-transform: uppercase; letter-spacing: .03em; font-weight: 500; }
.chips { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 3px; }
.seg { display: flex; gap: 7px; margin-bottom: 14px; }
.seg a { display: inline-block; padding: 3px 9px; font-size: 11.5px; border: 1px solid var(--input); border-radius: 4px; color: var(--text); background: #fff; }
.seg a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.seg a:hover { text-decoration: none; }

/* ---------- Dashboard pieces ---------- */
.pipe-row { margin-bottom: 9px; }
.pipe-row .top { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink); }
.track { height: 5px; background: #f1f5f9; border-radius: 3px; margin-top: 2px; }
.track i { display: block; height: 5px; border-radius: 3px; }
.newest td { padding: 8px 11px 9px; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
.task-line { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; font-size: 13px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 114px; }
.bars i { flex: 1; background: #6d63d9; border-radius: 1px; min-height: 2px; }
.funnel-row { display: grid; grid-template-columns: 167px 1fr 60px; align-items: center; gap: 0; font-size: 13px; margin-bottom: 7px; }
.funnel-row .track { margin: 0; height: 9px; border-radius: 5px; }
.funnel-row .track i { height: 9px; border-radius: 5px; }

/* ---------- Lead record ---------- */
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { display: flex; gap: 10px; padding: 7px 0 8px; }
.timeline .ico { width: 16px; height: 16px; flex: 0 0 16px; border-radius: 50%; background: #f1f5f9; display: grid; place-items: center; font-size: 9px; color: #334155; margin-top: 2px; }
.timeline .what { font-size: 13px; color: var(--ink); }
.timeline .by { font-size: 11px; color: var(--faint); }
.status-row { display: grid; grid-template-columns: 1fr auto; gap: 8px; }
.task-item { display: flex; gap: 8px; padding: 6px 0 10px; }
.task-item .t1 { font-size: 13px; color: var(--ink); }
.task-item .t2 { font-size: 11px; color: var(--faint); }
.task-check { width: 13px; height: 13px; border: 1px solid var(--input); border-radius: 3px; background: #fff; padding: 0; cursor: pointer; margin-top: 2px; }
.task-box { width: 18px; height: 18px; border: 1px solid var(--input); border-radius: 3px; background: #fff; padding: 0; cursor: pointer; }
.task-box.done { background: var(--brand); border-color: var(--brand); }

/* ---------- Leads table ---------- */
.filters { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr 1fr auto auto; gap: 8px; align-items: center; }
.filters .dates { grid-column: 1 / span 3; display: grid; grid-template-columns: auto 1fr auto 1fr; gap: 8px; align-items: center; color: var(--muted); font-size: 12px; }
.leads-table td { padding: 12px 11px 9px; }
.leads-table td:first-child, .leads-table th:first-child { width: 36px; padding-right: 0; }
.bulk { display: flex; align-items: center; gap: 8px; padding: 11px; color: var(--muted); font-size: 13px; }
.bulk select { width: 170px; height: 26px; padding-top: 2px; padding-bottom: 2px; }
.bulk .btn { height: 23px; }
tr.dnc td { opacity: .55; }

/* ---------- Auth & hosted form ---------- */
.center-page { min-height: 100vh; display: flex; flex-direction: column; align-items: center; padding: 220px 16px 40px; }
.center-page .mark { width: 42px; height: 42px; border-radius: 9px; background: var(--brand); color: #fff; display: grid; place-items: center; font-weight: 600; font-size: 17px; margin-bottom: 14px; overflow: hidden; }
.center-page .mark img { width: 100%; height: 100%; object-fit: cover; }
.center-page h1 { font-size: 17.5px; font-weight: 600; }
.center-page .lead { color: var(--muted); font-size: 13px; margin: 3px 0 18px; }
.auth-card { width: 341px; max-width: 100%; padding: 22px 21px 21px; }
.auth-card .field { margin-bottom: 14px; }
.auth-foot { margin-top: 14px; color: var(--muted); font-size: 13px; }
.auth-foot.faint { color: var(--faint); font-size: 11.5px; margin-top: 12px; }
.signup { max-width: 686px; margin: 0 auto; padding: 42px 16px 60px; }
.signup h1 { font-size: 21px; font-weight: 600; }
.signup .lead { color: var(--muted); margin: 2px 0 18px; }
.plan-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-bottom: 22px; }
.plan-opt { display: flex; gap: 10px; align-items: center; padding: 14px 14px 12px 14px; cursor: pointer; }
.plan-opt:has(input:checked) { border-color: var(--brand); box-shadow: 0 0 0 1px var(--brand); }
.plan-opt b { font-size: 14px; font-weight: 600; color: var(--ink); display: block; margin-bottom: 2px; }
.plan-opt .p { font-size: 13px; color: var(--body); }
.plan-opt .d { font-size: 11px; color: var(--faint); }
.hosted { max-width: 630px; margin: 0 auto; padding: 36px 16px 40px; text-align: center; }
.hosted .company { font-weight: 600; font-size: 15.5px; color: var(--ink); }
.hosted h1 { font-size: 23px; font-weight: 600; margin-top: 12px; }
.hosted .lead { color: var(--muted); font-size: 13px; margin: 3px 0 22px; }
.hosted .card { text-align: left; padding: 22px 21px 21px; }
.hosted .section { font-size: 13px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.hosted .field { margin-bottom: 10px; }
.hosted .checks { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px 14px; margin-bottom: 20px; }
.hosted .consent { font-size: 11px; color: var(--muted); margin: 14px 0 18px; }
.hosted .done { text-align: center; padding: 34px 20px 30px; }
.hosted .done .tick { font-size: 26px; color: var(--ink); line-height: 1; }
.hosted .done h2 { font-size: 17.5px; font-weight: 600; margin-top: 10px; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.embed .hosted { padding-top: 16px; }

/* ---------- Invoice ---------- */
.invoice { max-width: 682px; margin: 14px auto 0; padding: 28px 28px 30px; }
.invoice .head { display: flex; justify-content: space-between; gap: 16px; margin-bottom: 26px; }
.invoice h1 { font-size: 17.5px; font-weight: 600; }
.invoice .t td { padding: 10px; }
.invoice .totals { width: 228px; margin-left: auto; margin-top: 14px; font-size: 13px; }
.invoice .totals div { display: flex; justify-content: space-between; padding: 6px 0; }
.invoice .totals .grand { border-top: 1px solid var(--line); font-weight: 600; font-size: 14.5px; color: var(--ink); }

/* ---------- Status editor ---------- */
.st-row { display: grid; grid-template-columns: 34px 1fr 56px auto auto auto auto; gap: 7px; align-items: center; margin-bottom: 4px; }
.st-row input[type=color] { width: 34px; padding: 3px; }
.st-row .mini { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; color: var(--muted); }
.st-del { width: 28px; height: 22px; border: 1px solid var(--line); border-radius: 4px; background: #fff; color: var(--danger); font-size: 11px; cursor: pointer; margin-bottom: 10px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .g-dash, .g-lead, .g-tasks, .g2 { grid-template-columns: minmax(0, 1fr); }
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .dates { grid-column: 1 / -1; }
}
@media (max-width: 720px) {
  body { font-size: 14px; }
  .shell { display: block; }
  .sidebar { width: auto; border-right: 0; border-bottom: 1px solid var(--line); }
  .sidebar-inner { height: auto; position: static; }
  .brand { height: auto; padding: 12px 16px; }
  .nav { display: flex; overflow-x: auto; padding: 0 8px; border-top: 1px solid var(--line-soft); }
  .nav a { padding: 12px 8px; white-space: nowrap; }
  .side-foot { display: none; }
  .main { padding: 22px 16px 40px; }
  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 24px; }
  .page-head .actions { margin-top: 8px; }
  .g4 { grid-template-columns: minmax(0, 1fr); }
  .row.r2, .row.r3, .row.r4 { grid-template-columns: minmax(0, 1fr); }
  .span2, .span3 { grid-column: auto; }
  .checks, .checks.c3 { grid-template-columns: 1fr 1fr; }
  .hosted .checks { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: 1fr auto; }
  .filters > input, .filters > select, .filters > span { grid-column: 1 / -1; }
  .filters > span:empty { display: none; }
  .filters .dates { grid-template-columns: auto 1fr; }
  .plan-pick { grid-template-columns: 1fr; }
  .center-page { padding-top: 80px; }
  .hosted h1 { font-size: 26px; }
}
