/* Black Fox CRM. One stylesheet, no framework. */

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --surface-2: #f8fafb;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e2e8f0;
  --border-2: #cbd5e1;
  --brand: #6e4a6b;
  --brand-700: #573955;
  --brand-50: #f4edf3;
  --brand-200: #e2d1df;
  --gold: #d4a373;
  --gold-700: #9a6a40;
  --side: #0e0b0f;
  --side-2: #1f1720;
  --side-text: #cdc0cb;
  --side-dim: #8a7a88;
  --danger: #dc2626;
  --danger-50: #fef2f2;
  --warn: #b45309;
  --warn-50: #fffbeb;
  --good: #15803d;
  --good-50: #f0fdf4;
  --wa: #128c4a;
  --call: #1d4ed8;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 1px 3px rgba(15, 23, 42, .06);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, .18);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --side-w: 236px;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 var(--font); color: var(--text); background: var(--bg); }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { line-height: 1.25; margin: 0; }
h3 { font-size: 15px; font-weight: 650; }
p { margin: 0 0 .6em; }
code { font-size: 13px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 4px; padding: 0 4px; }
pre { white-space: pre-wrap; word-break: break-word; font-size: 12.5px; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; max-height: 360px; overflow: auto; }
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 8px 12px; z-index: 100; }
.skip:focus { left: 8px; }
.muted { color: var(--muted); }
.late { color: var(--danger); font-weight: 600; }
.ok { color: var(--good); }
.nowrap { white-space: nowrap; }
.wrap { word-break: break-all; }

.i { width: 18px; height: 18px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; vertical-align: -3px; }
.i.big { width: 40px; height: 40px; stroke-width: 1.4; color: var(--border-2); }

/* ---------- app shell ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar { width: var(--side-w); background: var(--side); color: var(--side-text); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; z-index: 40; }
.brand { display: flex; align-items: center; gap: 10px; padding: 18px 18px 14px; color: #fff; }
.brand:hover { text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; flex: none; }
.brand-mark img { width: 38px; height: auto; display: block; }
.brand-name small { display: block; font-size: 11px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--gold); }
.brand-name { font-weight: 700; font-size: 15px; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; }
.side-nav { flex: 1; overflow-y: auto; padding: 6px 10px; }
.side-nav a, .side-user { display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: var(--radius-sm); color: var(--side-text); font-weight: 500; }
.side-nav a:hover, .side-user:hover { background: var(--side-2); color: #fff; text-decoration: none; }
.side-nav a.active, .side-user.active { background: rgba(212, 163, 115, .14); color: #fff; }
.side-nav a.active .i { color: var(--gold); }
.side-label { margin: 16px 10px 6px; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--side-dim); }
.side-foot { padding: 10px; border-top: 1px solid var(--side-2); display: grid; gap: 8px; }
.side-user span { display: grid; line-height: 1.25; min-width: 0; }
.side-user strong { color: #fff; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-user small { color: var(--side-dim); }
.side-foot .btn-ghost { color: var(--side-text); border-color: var(--side-2); background: transparent; }
.side-foot .btn-ghost:hover { background: var(--side-2); color: #fff; }

.main { flex: 1; margin-left: var(--side-w); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 12px 24px; background: rgba(244, 246, 248, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.page-title { font-size: 19px; font-weight: 700; margin-right: auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search { position: relative; width: min(340px, 34vw); }
.search .i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.search input { padding-left: 34px; background: var(--surface); }
.bell { position: relative; display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; color: var(--text-2); border: 1px solid var(--border); background: var(--surface); }
.bell:hover { text-decoration: none; background: var(--surface-2); }
.badge { position: absolute; top: -5px; right: -5px; min-width: 19px; height: 19px; padding: 0 5px; border-radius: 10px; background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center; }
.content { padding: 20px 24px 40px; max-width: 1280px; width: 100%; }
.content > * + * { margin-top: 16px; }
.tabbar, .scrim { display: none; }

/* ---------- controls ---------- */
input, select, textarea { font: inherit; color: inherit; width: 100%; padding: 9px 11px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--surface); min-height: 40px; }
textarea { resize: vertical; min-height: 64px; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(110, 74, 107, .18); }
input[type="checkbox"], input[type="radio"] { width: auto; min-height: 0; accent-color: var(--brand); }
input[disabled] { background: var(--surface-2); color: var(--muted); }
.field { display: grid; gap: 5px; margin: 0; }
.field > span { font-size: 13px; font-weight: 600; color: var(--text-2); }
.field.has-error input, .field.has-error select { border-color: var(--danger); }
.field-error { color: var(--danger); font-size: 13px; margin: 0; }
.check-line { display: flex; gap: 10px; align-items: flex-start; margin: 10px 0; cursor: pointer; }
.check-line input { margin-top: 4px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; min-height: 40px; border-radius: var(--radius-sm); border: 1px solid transparent; font: inherit; font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; background: var(--surface); color: var(--text); line-height: 1.2; }
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-700); }
.btn-ghost { border-color: var(--border-2); color: var(--text-2); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-call { background: var(--call); color: #fff; }
.btn-call:hover { filter: brightness(.92); }
.btn-wa { background: var(--wa); color: #fff; }
.btn-wa:hover { filter: brightness(.92); }
.btn-danger-ghost { border-color: #fecaca; color: var(--danger); background: var(--surface); }
.btn-danger-ghost:hover { background: var(--danger-50); }
.btn-sm { padding: 6px 11px; min-height: 34px; font-size: 13.5px; }
.btn-block { width: 100%; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; padding: 0; }
.icon-btn:hover { background: var(--surface-2); text-decoration: none; }
.icon-btn.call { color: var(--call); border-color: #bfdbfe; background: #eff6ff; }
.icon-btn.wa { color: var(--wa); border-color: #bbf7d0; background: #f0fdf4; }
.quick { display: flex; gap: 6px; justify-content: flex-end; }
.quick form { margin: 0; }
.link { font-size: 13.5px; font-weight: 600; }

.flash { display: flex; align-items: flex-start; gap: 10px; padding: 11px 14px; border-radius: var(--radius-sm); border: 1px solid; font-weight: 500; }
.flash-ok { background: var(--good-50); border-color: #bbf7d0; color: #14532d; }
.flash-error { background: var(--danger-50); border-color: #fecaca; color: #7f1d1d; }
.flash.toast { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); z-index: 200; width: max-content; max-width: calc(100vw - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }
.call-info { margin: -4px 0 10px; font-weight: 600; color: var(--accent, #d4a373); }
.flash-x { margin-left: auto; background: none; border: 0; font-size: 20px; line-height: 1; cursor: pointer; color: inherit; opacity: .6; }

.pill { display: inline-flex; align-items: center; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; line-height: 1.6; white-space: nowrap; border: 1px solid transparent; }
.pill-blue { background: #eff6ff; color: #1d4ed8; border-color: #dbeafe; }
.pill-amber { background: #fffbeb; color: #a16207; border-color: #fde68a; }
.pill-violet { background: #f5f3ff; color: #6d28d9; border-color: #ede9fe; }
.pill-teal { background: #f0fdfa; color: #0f766e; border-color: #ccfbf1; }
.pill-cyan { background: #ecfeff; color: #0e7490; border-color: #cffafe; }
.pill-orange { background: #fff7ed; color: #c2410c; border-color: #fed7aa; }
.pill-green { background: #f0fdf4; color: #15803d; border-color: #bbf7d0; }
.pill-grey { background: #f1f5f9; color: #475569; border-color: #e2e8f0; }
.pill-red { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.temp { display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; padding: 1px 6px; border-radius: 4px; vertical-align: 1px; }
.temp-hot { background: #fee2e2; color: #b91c1c; }
.temp-cold { background: #e0f2fe; color: #0369a1; }
.avatar { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-50); color: var(--brand); font-weight: 700; font-size: 13px; flex: none; }

/* ---------- cards and layout ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head form { margin: 0; }
.card[id], section[id] { scroll-margin-top: 80px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.empty { color: var(--muted); margin: 6px 0; }
.empty-state { text-align: center; padding: 40px 20px; }
.empty-state h3 { margin: 10px 0 6px; font-size: 17px; }
.eyebrow { font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--muted); margin-bottom: 4px; }
.plain { margin: 8px 0 0; padding-left: 18px; }
.plain li { margin: 4px 0; }
.mono { font-family: ui-monospace, Consolas, monospace; font-size: 13px; }
.stack { display: grid; gap: 14px; }
.toolbar { max-width: 280px; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form select { width: auto; flex: 1; }

.hello h2 { font-size: 22px; }
.kpis { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; }
.kpi { display: grid; gap: 4px; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); color: var(--text); border-top: 3px solid var(--border-2); }
a.kpi:hover { text-decoration: none; border-color: var(--border-2); }
.kpi-n { font-size: 28px; font-weight: 750; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-l { font-size: 13px; color: var(--muted); font-weight: 500; }
.kpi-l small { display: block; }
.kpi-danger { border-top-color: var(--danger); }
.kpi-danger .kpi-n { color: var(--danger); }
.kpi-warn { border-top-color: #f59e0b; }
.kpi-good { border-top-color: #22c55e; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 2px; border-top: 1px solid var(--border); }
.row:first-child { border-top: 0; }
.row.unread { background: var(--brand-50); margin: 0 -16px; padding: 10px 18px; }
.row-main { flex: 1; min-width: 0; display: flex; gap: 12px; align-items: baseline; color: var(--text); }
.row-main:hover { text-decoration: none; }
.row-main:hover .row-title { color: var(--brand); }
.row-text { display: grid; min-width: 0; }
.row-main > .row-title, .row-main > .row-sub { display: block; }
.row-main:not(:has(.row-text)) { flex-direction: column; gap: 1px; }
.row-title { font-weight: 600; }
.row-sub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; }
.row-time { font-variant-numeric: tabular-nums; font-weight: 600; min-width: 74px; color: var(--text-2); font-size: 13.5px; }
.row form { margin: 0; }

.bars { list-style: none; margin: 0; padding: 0; display: grid; gap: 7px; }
.bars a { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; color: var(--text-2); font-size: 13.5px; }
.bars a:hover { text-decoration: none; color: var(--brand); }
.bar { height: 10px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; }
.bar-fill { display: block; height: 100%; border-radius: 5px; min-width: 2px; }
.bar-n { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.fill-blue { background: #3b82f6; } .fill-amber { background: #f59e0b; } .fill-violet { background: #8b5cf6; } .fill-teal { background: #14b8a6; }
.fill-cyan { background: #06b6d4; } .fill-orange { background: #f97316; } .fill-green { background: #22c55e; } .fill-grey { background: #94a3b8; } .fill-red { background: #ef4444; }

.feed { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.feed li { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; }
.feed .muted { display: block; font-size: 13px; }
.feed-icon { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; background: var(--surface-2); color: var(--muted); flex: none; }
.feed-icon .i { width: 15px; height: 15px; }

/* ---------- tables ---------- */
.table-card { padding: 0; overflow: hidden; }
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 650; padding: 10px 12px; background: var(--surface-2); border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr[data-href] { cursor: pointer; }
.table tbody tr:hover { background: #fafcfd; }
.table tfoot th { background: var(--surface-2); border-top: 1px solid var(--border-2); border-bottom: 0; font-size: 14px; text-transform: none; letter-spacing: 0; color: var(--text); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; }
.table .check { width: 36px; }
.table .actions { width: 1%; white-space: nowrap; text-align: right; }
.table tr.is-off td { opacity: .55; }
.leads-table { min-width: 1040px; }
.lead-cell { min-width: 180px; }
.lead-cell .sub { white-space: nowrap; }
.lead-cell .lead-name { font-weight: 650; color: var(--text); }
.lead-cell .lead-name:hover { color: var(--brand); }
.sub { display: block; font-size: 12.5px; color: var(--muted); }
.req { min-width: 200px; max-width: 280px; font-size: 13.5px; }
.map-table td { vertical-align: middle; }
.map-table select { min-width: 200px; }

.tabs { display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; border-bottom: 1px solid var(--border); padding-bottom: 0; }
.tabs::-webkit-scrollbar { display: none; }
.tab { display: inline-flex; align-items: center; gap: 6px; padding: 9px 12px; color: var(--muted); font-weight: 600; font-size: 14px; border-bottom: 2px solid transparent; white-space: nowrap; margin-bottom: -1px; }
.tab:hover { color: var(--text); text-decoration: none; }
.tab.active { color: var(--brand); border-bottom-color: var(--brand); }
.tab .count { font-size: 12px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 0 7px; color: var(--muted); }
.tab.active .count { background: var(--brand-50); border-color: var(--brand-200); color: var(--brand); }
.tab-alert .count { background: #fee2e2; border-color: #fecaca; color: #b91c1c; }

.filters summary { cursor: pointer; font-weight: 600; display: flex; align-items: center; gap: 8px; list-style: none; }
.filters summary::-webkit-details-marker { display: none; }
.filters[open] summary { margin-bottom: 14px; }
.filter-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; align-items: end; }
.filter-actions { display: flex; gap: 8px; align-items: center; }
.list-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.list-head p { margin: 0; }
.list-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.bulk-bar { position: sticky; top: 66px; z-index: 20; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 10px 14px; background: var(--side); color: #fff; border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.bulk-bar select, .bulk-bar input { width: auto; min-height: 34px; padding: 5px 10px; color: var(--text); background: var(--surface); }
.region-seg { display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.region-seg a { padding: 6px 12px; border-radius: var(--radius-sm); color: var(--text-2); font-weight: 600; font-size: 14px; }
.region-seg a:hover { background: var(--surface-2); text-decoration: none; }
.region-seg a.active { background: var(--brand); color: #fff; }
.region-seg .count { font-weight: 500; opacity: .75; margin-left: 2px; }
/* Protected screens (agents): watermark, no selecting or copying, nothing when printed. */
.watermark { position: fixed; inset: 0; z-index: 90; pointer-events: none; background-repeat: repeat; }
body.guard { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
body.guard input, body.guard textarea { -webkit-user-select: text; user-select: text; }
body.guard.guard-away .main { filter: blur(14px); }
@media print { body.guard * { visibility: hidden !important; } body.guard::after { content: "Printing is turned off for your account."; visibility: visible; } }
.perm-box { border-top: 1px solid var(--border); padding-top: 10px; }
.perm-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; align-items: start; }
.perm-group { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 12px 10px; margin: 0; display: grid; gap: 6px; align-content: start; }
.perm-group legend { font-weight: 700; font-size: 13px; padding: 0 4px; color: var(--text-2); }
fieldset.bare { border: 0; margin: 0; padding: 0; min-width: 0; display: grid; gap: 14px; }
fieldset.bare[disabled] input, fieldset.bare[disabled] select, fieldset.bare[disabled] textarea { background: var(--surface-2); color: var(--text); }
.pager { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }

/* ---------- forms ---------- */
.form-card { max-width: 920px; }
.form-card > * + * { margin-top: 14px; }
.form-section { font-size: 16px; font-weight: 700; }
.form-card .form-section:not(:first-of-type) { padding-top: 10px; border-top: 1px solid var(--border); }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.form-actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; padding-top: 4px; }
.tpl-row { display: grid; grid-template-columns: 220px 1fr; gap: 12px; }
.copy-row { display: flex; gap: 8px; margin: 6px 0 14px; }
.copy-row input { font-family: ui-monospace, Consolas, monospace; font-size: 13px; background: var(--surface-2); }
#integrations h3 { margin-top: 18px; }

/* ---------- lead page ---------- */
.lead-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; }
.lead-id { display: flex; gap: 14px; align-items: center; min-width: 0; }
.lead-id .avatar { width: 48px; height: 48px; font-size: 17px; }
.lead-head h2 { font-size: 21px; }
.lead-meta { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin: 6px 0 0; }
.lead-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-start; }
.next-step { display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap; border-left: 4px solid var(--brand); }
.next-step.is-late { border-left-color: var(--danger); background: #fffafa; }
.next-what { font-size: 17px; font-weight: 650; margin: 0; }
.next-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.lead-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); gap: 16px; align-items: start; }
.side-col { display: grid; gap: 16px; }
.facts { display: grid; grid-template-columns: 100px 1fr; gap: 8px 12px; margin: 0; font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; min-width: 0; }
.req-notes { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); font-size: 14px; }
.seg { display: inline-flex; border: 1px solid var(--border-2); border-radius: var(--radius-sm); overflow: hidden; }
.seg-btn { border: 0; background: var(--surface); padding: 4px 12px; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; color: var(--muted); }
.seg-btn + .seg-btn { border-left: 1px solid var(--border-2); }
.seg-hot.on { background: #fee2e2; color: #b91c1c; }
.seg-warm.on { background: #fef3c7; color: #a16207; }
.seg-cold.on { background: #e0f2fe; color: #0369a1; }
.danger-zone { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--border); }
.inline-form + .danger-zone { margin-top: 14px; }

.note-form { display: grid; gap: 8px; margin-bottom: 16px; }
.note-actions { display: flex; justify-content: space-between; gap: 8px; }
.timeline { list-style: none; margin: 0; padding: 0; position: relative; }
.timeline::before { content: ""; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: var(--border); }
.tl { position: relative; display: flex; gap: 12px; padding: 8px 0; }
.tl-icon { position: relative; z-index: 1; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: var(--surface); border: 2px solid var(--border); color: var(--muted); flex: none; }
.tl-icon .i { width: 15px; height: 15px; }
.k-call .tl-icon { color: var(--call); border-color: #bfdbfe; }
.k-whatsapp .tl-icon { color: var(--wa); border-color: #bbf7d0; }
.k-status .tl-icon { color: var(--brand); border-color: var(--brand-200); }
.k-visit .tl-icon { color: var(--gold-700); border-color: #f1d9c2; }
.k-enquiry .tl-icon { color: #7c3aed; border-color: #ddd6fe; }
.k-note .tl-icon { color: #b45309; border-color: #fde68a; }
.tl-body { min-width: 0; flex: 1; padding-top: 4px; }
.tl-title { font-weight: 600; margin: 0; }
.tl-text { margin: 4px 0; font-size: 14px; color: var(--text-2); white-space: normal; word-break: break-word; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 10px; max-height: 260px; overflow: auto; }
.tl-meta { font-size: 12.5px; color: var(--muted); margin: 2px 0 0; }

.matches { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.matches li { display: flex; gap: 10px; align-items: center; }
.matches form { margin: 0; }
.match { flex: 1; display: flex; gap: 10px; align-items: center; color: var(--text); min-width: 0; }
.match:hover { text-decoration: none; }
.match img, .match-ph { width: 56px; height: 44px; object-fit: cover; border-radius: 6px; flex: none; background: var(--surface-2); display: grid; place-items: center; color: var(--muted); }
.match span { display: grid; min-width: 0; }
.match small { color: var(--muted); }

.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: calc(100% + 6px); z-index: 25; width: min(360px, 88vw); background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 6px; display: grid; gap: 2px; }
.menu-list form { margin: 0; }
.menu-item { display: grid; gap: 2px; width: 100%; text-align: left; padding: 8px 10px; border: 0; border-radius: var(--radius-sm); background: none; font: inherit; cursor: pointer; color: var(--text); }
.menu-item:hover { background: var(--surface-2); }
.menu-item small { color: var(--muted); font-size: 12.5px; }
.menu-custom { display: grid; gap: 6px; padding: 8px 6px 4px; border-top: 1px solid var(--border); margin-top: 4px !important; }

/* ---------- dialogs ---------- */
dialog.modal { margin: auto; }
.modal { border: 0; padding: 0; border-radius: 16px; width: min(520px, calc(100vw - 24px)); box-shadow: var(--shadow-lg); color: var(--text); }
.modal::backdrop { background: rgba(15, 23, 42, .45); }
.modal-body { padding: 20px; display: grid; gap: 14px; }
.modal h2 { font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; }
.status-grid, .chips { display: flex; flex-wrap: wrap; gap: 8px; }
.status-opt, .chip { cursor: pointer; }
.status-opt input, .chip input { position: absolute; opacity: 0; pointer-events: none; }
.status-opt .pill { padding: 6px 12px; font-size: 13px; opacity: .75; }
.status-opt input:checked + .pill { opacity: 1; box-shadow: 0 0 0 2px currentColor; }
.status-opt input:focus-visible + .pill, .chip input:focus-visible + span { outline: 2px solid var(--brand); outline-offset: 2px; }
.chip span, .chip-btn { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-2); font-size: 13.5px; font-weight: 600; background: var(--surface); color: var(--text-2); cursor: pointer; font-family: inherit; }
.chip input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-btn:hover { background: var(--surface-2); }

/* ---------- inventory ---------- */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.project-card { color: var(--text); display: grid; gap: 4px; align-content: start; }
.project-card:hover, .prop-card:hover { text-decoration: none; border-color: var(--border-2); box-shadow: 0 4px 14px rgba(15, 23, 42, .08); }
.project-card .card-head { margin-bottom: 2px; }
.project-card p { margin: 0; }
.project-stats { display: flex; gap: 16px; margin-top: 8px !important; color: var(--muted); font-size: 13.5px; }
.project-stats strong { color: var(--text); }
.is-off { opacity: .6; }
.prop-card { padding: 0; overflow: hidden; color: var(--text); display: grid; }
.prop-img { position: relative; display: grid; place-items: center; aspect-ratio: 4 / 3; background: var(--surface-2); }
.prop-img img { width: 100%; height: 100%; object-fit: cover; }
.prop-img .pill { position: absolute; top: 10px; left: 10px; }
.prop-body { display: grid; gap: 2px; padding: 12px 14px 14px; font-size: 14px; }
.prop-price { font-size: 17px; font-weight: 700; }
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-bottom: 14px; }
.photo-grid figure { position: relative; margin: 0; }
.photo-grid img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border-radius: var(--radius-sm); display: block; }
.photo-grid form { position: absolute; top: 6px; right: 6px; margin: 0; }
.upload-form input[type="file"] { min-height: 0; padding: 6px; }
.filter-inline { align-items: end; }
.report-note { margin-top: 8px !important; font-size: 13.5px; }
.log-list { list-style: none; padding: 0; }
.log-list li { padding: 14px 16px; border-top: 1px solid var(--border); }
.log-list li:first-child { border-top: 0; }
.log-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 4px; }
.log-head form { margin: 0 0 0 auto; }
.log-list details summary { cursor: pointer; color: var(--brand); font-size: 13.5px; font-weight: 600; }

/* ---------- auth and public pages ---------- */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 20px; background: var(--side); }
.auth-card { width: min(400px, 100%); background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg); padding: 28px; display: grid; gap: 14px; }
.auth-card h1 { font-size: 22px; }
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 16px; }
.auth-foot { text-align: center; margin: 0; font-size: 14px; }

.share { background: var(--bg); }
.share-wrap { max-width: 720px; margin: 0 auto; background: var(--surface); min-height: 100vh; padding-bottom: 96px; }
.share-top { padding: 14px 18px; border-bottom: 1px solid var(--border); font-size: 16px; }
.gallery { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 4px; background: #000; }
.gallery img { flex: 0 0 100%; aspect-ratio: 4 / 3; object-fit: cover; scroll-snap-align: start; }
.share-body { padding: 18px; display: grid; gap: 10px; }
.share-body h1 { font-size: 22px; }
.share-price { font-size: 24px; font-weight: 750; color: var(--brand); margin: 0; }
.share-desc { color: var(--text-2); }
.share-cta { position: fixed; bottom: 0; left: 50%; transform: translateX(-50%); width: min(720px, 100%); display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--border); box-shadow: 0 -4px 16px rgba(15, 23, 42, .08); }
.share-cta p { margin: 0; font-weight: 600; }
.share-cta div { display: flex; gap: 8px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .scrim { display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 35; }
  .main { margin-left: 0; }
  .topbar { padding: 10px 16px; }
  .content { padding: 16px 16px 96px; }
  .search, .btn-add { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); justify-content: space-around; align-items: center; }
  .tabbar a, .tabbar button { display: grid; justify-items: center; gap: 2px; font: inherit; font-size: 11px; font-weight: 600; color: var(--muted); background: none; border: 0; padding: 4px 10px; cursor: pointer; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar .active { color: var(--brand); }
  .tabbar .i { width: 22px; height: 22px; }
  .tabbar .tab-add { width: 50px; height: 50px; border-radius: 50%; background: var(--brand); color: #fff; place-items: center; box-shadow: 0 6px 16px rgba(110, 74, 107, .4); margin-top: -18px; }
  .lead-grid, .grid-2 { grid-template-columns: minmax(0, 1fr); }
  .bulk-bar { top: 62px; }
}

@media (max-width: 720px) {
  body { font-size: 15px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi { padding: 12px; }
  .kpi-n { font-size: 24px; }
  .form-grid, .tpl-row { grid-template-columns: minmax(0, 1fr); }
  .bars a { grid-template-columns: 110px 1fr 32px; }
  .page-title { font-size: 17px; }
  .lead-head h2 { font-size: 19px; }
  .lead-actions .btn { flex: 1; }
  .lead-actions .menu { flex: 1; }
  .lead-actions .menu summary { width: 100%; }
  .next-actions { width: 100%; }
  .next-actions .btn { flex: 1; }
  .copy-row { flex-direction: column; }
  .menu-list { position: fixed; left: 12px; right: 12px; top: auto; bottom: calc(76px + env(safe-area-inset-bottom)); width: auto; max-height: 70vh; overflow-y: auto; }
  .card { padding: 14px; }

  /* Tables turn into cards on phones. */
  .table-card.as-cards { background: none; border: 0; box-shadow: none; padding: 0; }
  .as-cards .table td[data-label]:empty { display: none; }
  .as-cards .table thead { display: none; }
  .as-cards .table, .as-cards .table tbody { display: block; min-width: 0; }
  .as-cards .table-wrap { overflow: visible; }
  .as-cards .table tr { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; padding: 12px 14px; margin-bottom: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
  .as-cards .table td { display: block; padding: 0; border: 0; font-size: 13.5px; }
  .as-cards .table td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-weight: 500; }
  .as-cards .table td.lead-cell { grid-column: 1; }
  .as-cards .table td.actions { grid-column: 2; grid-row: 1; width: auto; }
  .as-cards .table td.check { grid-column: 2; grid-row: 2; text-align: right; }
  .as-cards .table td[data-label] { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- v2: brand, pick lists, tags, sheets, sync, offline ---------- */
.auth-card { padding: 0; overflow: hidden; }
.auth-card > :not(.auth-logo) { margin-left: 28px; margin-right: 28px; }
.auth-card > :last-child { margin-bottom: 28px; }
.auth-logo { background: #000; display: grid; place-items: center; padding: 26px 20px 20px; }
.auth-logo img { width: 210px; height: auto; }
.auth-logo span { margin-top: 8px; font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--gold); font-weight: 700; }

.pick { display: grid; gap: 6px; }
.pick-other { display: grid; gap: 6px; }
.pick-save { display: inline-flex; gap: 6px; align-items: center; font-size: 13px; color: var(--muted); font-weight: 500; cursor: pointer; }
.tag-picker { display: flex; flex-wrap: wrap; gap: 6px; }
.tag-picker .chip span { padding: 4px 10px; font-size: 13px; }
.tag-new { display: grid; gap: 6px; margin-top: 8px; }
.tag { display: inline-block; font-size: 11.5px; font-weight: 600; padding: 1px 7px; border-radius: 4px; background: var(--brand-50); color: var(--brand); border: 1px solid var(--brand-200); margin: 2px 4px 0 0; white-space: nowrap; }
.tag-nri { background: #fdf3e8; color: var(--gold-700); border-color: #f1d9c2; }
.sub-status { display: block; font-size: 12px; color: var(--muted); margin-top: 3px; }
.details-list { display: grid; grid-template-columns: minmax(90px, 40%) 1fr; gap: 6px 12px; margin: 0; font-size: 14px; }
.details-list dt { color: var(--muted); word-break: break-word; }
.details-list dd { margin: 0; word-break: break-word; }
.sheet-card .card-head { flex-wrap: wrap; }
.sheet-include { margin: 0; }
.att-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.att-grid img { width: 96px; height: 72px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); }
.rule-row { display: grid; grid-template-columns: 150px 1fr 200px; gap: 8px; margin-bottom: 8px; }
.sub-lists { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.install-btn { color: var(--gold) !important; }
.sync-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 600; padding: 4px 10px; border-radius: 999px; background: #fdf3e8; color: var(--gold-700); border: 1px solid #f1d9c2; }
.sync-chip.is-off { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.walkin-card { max-width: 640px; }
.walkin-card input, .walkin-card select { font-size: 17px; min-height: 48px; }

/* Offline app shell */
.off-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 10px; padding: 10px 16px calc(10px); padding-top: calc(10px + env(safe-area-inset-top)); background: var(--side); color: #fff; }
.off-top img { width: 30px; }
.off-top strong { flex: 1; }
.off-banner { padding: 8px 16px; font-size: 13.5px; font-weight: 600; background: #fdf3e8; color: var(--gold-700); border-bottom: 1px solid #f1d9c2; }
.off-banner.is-online { background: var(--good-50); color: #14532d; border-color: #bbf7d0; }
.off-main { padding: 14px 16px 96px; max-width: 760px; margin: 0 auto; display: grid; gap: 14px; }
.off-nav { position: fixed; left: 0; right: 0; bottom: 0; display: flex; justify-content: space-around; background: var(--surface); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); z-index: 30; }
.off-nav a { display: grid; justify-items: center; gap: 2px; font-size: 11px; font-weight: 600; color: var(--muted); padding: 4px 12px; }
.off-nav a.active { color: var(--brand); }
.off-nav .i { width: 22px; height: 22px; }
.off-problems li { color: #7f1d1d; }
.auth-card > :first-child:not(.auth-logo) { margin-top: 28px; }
.form-grid { align-items: start; }

/* Back button on inner pages (a lead, a form, a sub-page) */
.back-btn { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 40px; height: 40px; margin-right: 4px; border-radius: 10px; font-size: 30px; line-height: 1; color: inherit; text-decoration: none; }
.back-btn:hover, .back-btn:focus-visible { background: rgba(127, 127, 127, .15); }

/* Several accounts on one device */
.accounts { display: grid; gap: 8px; }
.accounts form { margin: 0; }
.accounts .muted, .accounts-tip { margin: 0; font-size: 13px; }
.account-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: inherit; font: inherit; text-align: left; cursor: pointer; }
.account-row span { display: grid; flex: 1; min-width: 0; line-height: 1.3; }
.account-row > .avatar { flex: none; display: grid; }
.account-row small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.account-row em { font-style: normal; font-size: 13px; font-weight: 600; color: var(--brand); }
button.account-row:hover, button.account-row:focus-visible { border-color: var(--brand); }
.account-row.is-current { cursor: default; background: var(--surface-2); }
.account-row.is-current em { color: var(--muted); }
