:root {
  --ink: #0b0f12; --ink-2: #1b232b; --text: #2a2f35; --muted: #69717b; --line: #e7e2da;
  --tint: #f8f5f0; --peach: #f4a27e; --peach-2: #f7b896; --coral: #b4532f; --leaf: #4f8f4a; --white: #fff;
  --radius: 8px; --shadow: 0 6px 20px rgba(11, 15, 18, .06);
  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--tint); }
a { color: var(--coral); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
h2 { font-size: 1.05rem; }
h3 { font-size: .98rem; }
code { background: var(--white); border: 1px solid var(--line); padding: 1px 5px; border-radius: 4px; font-size: .85em; word-break: break-all; }
.muted { color: var(--muted); }
.mt { margin-top: 22px; }
.pre, .t-body { white-space: pre-wrap; }

.topbar { display: flex; align-items: center; gap: 24px; background: var(--ink); color: var(--white); padding: 10px 22px; position: sticky; top: 0; z-index: 10; flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; color: var(--white); font-weight: 700; letter-spacing: .08em; }
.brand img { height: 34px; width: auto; }
.brand span { border-left: 1px solid rgba(255,255,255,.3); padding-left: 10px; font-size: .8rem; }
.topbar nav { display: flex; gap: 4px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: rgba(255,255,255,.78); padding: 8px 12px; border-radius: 6px; font-weight: 600; }
.topbar nav a:hover { color: var(--white); background: var(--ink-2); text-decoration: none; }
.topbar nav a[aria-current] { color: var(--ink); background: var(--peach); }
.logout { display: flex; align-items: center; gap: 10px; font-size: .85rem; color: rgba(255,255,255,.6); }
.logout .btn-link { color: var(--peach); }

.wrap { max-width: 1240px; margin: 0 auto; padding: 26px 22px 60px; }
.head-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-row p { margin: 0; max-width: 760px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.card.flush { padding: 0; overflow-x: auto; }
details.card summary { cursor: pointer; font-weight: 700; color: var(--ink); }
details.card[open] summary { margin-bottom: 12px; }
.cols { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; align-items: start; }
.cols-wide { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); }
@media (max-width: 900px) { .cols, .cols-wide { grid-template-columns: 1fr; } }

.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.stats > * { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; color: var(--text); box-shadow: var(--shadow); }
.stats a:hover { border-color: var(--peach); text-decoration: none; }
.stats b { display: block; font-size: 1.8rem; color: var(--ink); line-height: 1.1; }
.stats span { color: var(--muted); font-size: .88rem; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } }

table { width: 100%; border-collapse: collapse; }
td, th { padding: 10px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); background: #fcfbf9; }
tr:last-child td { border-bottom: 0; }
.list td .muted { font-size: .85rem; }

.score { display: inline-grid; place-items: center; min-width: 34px; height: 26px; padding: 0 6px; border-radius: 13px; font-weight: 800; font-size: .82rem; }
.score.hot { background: var(--coral); color: var(--white); }
.score.warm { background: var(--peach); color: var(--ink); }
.score.cool { background: #ece8e1; color: var(--muted); }
.pill { display: inline-block; padding: 2px 9px; border-radius: 10px; font-size: .78rem; font-weight: 700; background: #ece8e1; color: var(--ink); white-space: nowrap; }
.stage-new { background: #fde6db; color: var(--coral); }
.stage-appointment, .stage-active_client { background: #e2efdf; color: var(--leaf); }
.stage-under_contract, .stage-closed { background: var(--leaf); color: var(--white); }
.stage-lost { background: #eee; color: #999; }
.ch { display: inline-block; font-size: .72rem; font-weight: 800; padding: 1px 6px; border-radius: 4px; background: #ece8e1; color: var(--ink); }
.ch-web, .ch-tap { background: #fde6db; color: var(--coral); }
.ch-sms { background: #e2efdf; color: var(--leaf); }
.ch-email { background: #e3e9f3; color: #34507a; }
.ch-call { background: var(--ink); color: var(--white); }

input, select, textarea { font: inherit; padding: 9px 11px; border: 1px solid var(--line); border-radius: 6px; background: var(--white); color: var(--text); width: 100%; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--peach); outline-offset: 0; border-color: var(--peach); }
label { display: grid; gap: 4px; font-weight: 600; font-size: .88rem; color: var(--ink); }
label.check { display: flex; align-items: center; gap: 8px; }
label.check input { width: auto; }
.stack { display: grid; gap: 10px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.grid2 .full { grid-column: 1 / -1; }
@media (max-width: 640px) { .grid2 { grid-template-columns: 1fr; } }
.filters { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.filters input { flex: 1; min-width: 220px; }
.filters select { width: auto; }
.row-line { display: flex; gap: 10px; align-items: center; justify-content: space-between; flex-wrap: wrap; }
.row-line input, .row-line select { flex: 1; width: auto; }
.seg { display: flex; gap: 16px; }
.seg label { display: flex; align-items: center; gap: 6px; font-weight: 600; }
.seg input { width: auto; }

.btn, .btn-small { display: inline-flex; align-items: center; justify-content: center; border: 0; cursor: pointer; font: 700 .9rem var(--font); border-radius: 6px; background: var(--ink); color: var(--white); padding: 10px 18px; text-decoration: none; white-space: nowrap; }
.btn:hover, .btn-small:hover { background: var(--ink-2); text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--tint); }
.btn-small { padding: 6px 12px; font-size: .8rem; background: var(--tint); color: var(--ink); border: 1px solid var(--line); }
.btn-small:hover { background: var(--peach); }
.btn-small.danger { color: var(--coral); }
.btn-link { background: none; border: 0; padding: 0; font: inherit; color: var(--coral); cursor: pointer; }

.flash { background: var(--white); border-left: 4px solid var(--leaf); padding: 10px 14px; border-radius: 6px; box-shadow: var(--shadow); }
.flash.err { border-color: var(--coral); }
.flash.warn { border-color: var(--peach); }
.approve { border-left: 4px solid var(--peach); display: grid; gap: 10px; }
.approve h3 { margin: 0; }

.feed { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.clip { color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.timeline { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.timeline li { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: #fcfbf9; }
.timeline li.inbound { border-left: 3px solid var(--peach); background: var(--white); }
.t-head { display: flex; gap: 8px; align-items: baseline; flex-wrap: wrap; font-size: .88rem; margin-bottom: 4px; }
.idents { list-style: none; padding: 0; margin: 0 0 12px; display: grid; gap: 6px; }
.idents li { display: flex; gap: 8px; align-items: baseline; }
.idents form { margin-left: auto; }
.idents .muted { min-width: 66px; font-size: .8rem; text-transform: uppercase; }

.tabs { display: flex; gap: 4px; }
.tabs a { padding: 7px 12px; border-radius: 6px; color: var(--ink); font-weight: 600; border: 1px solid var(--line); background: var(--white); }
.tabs a[aria-current] { background: var(--ink); color: var(--white); border-color: var(--ink); }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: 130px 1fr 40px; align-items: center; gap: 10px; font-size: .88rem; }
.bars i { display: block; height: 12px; background: var(--peach); border-radius: 6px; min-width: 2px; }
.bars b { text-align: right; }
.qr { width: 220px; height: 220px; border: 1px solid var(--line); border-radius: 8px; }

.login { max-width: 380px; margin: 9vh auto 0; background: var(--white); padding: 34px; border-radius: 12px; box-shadow: var(--shadow); text-align: center; }
.login form { text-align: left; margin-top: 16px; }
.login h1 { justify-content: center; font-size: 1.3rem; margin-top: 16px; }
.steps { padding-left: 20px; display: grid; gap: 10px; }
.steps code, .card code { display: inline-block; margin-top: 4px; padding: 2px 6px; background: #f3f0ea; border-radius: 4px; font-size: .82rem; word-break: break-all; }
form.inline { display: inline; }
