/* Light, flat, rectangular. One ink colour, hairline borders, colour only where it carries meaning. */
:root {
  color-scheme: light;
  --bg: #fafafa;
  --surface: #ffffff;
  --subtle: #f4f4f5;
  --border: #e6e6e8;
  --border-strong: #d4d4d8;
  --text: #18181b;
  --muted: #71717a;
  --faint: #a1a1aa;
  --ink: #18181b;
  --accent: #0f766e;
  --accent-soft: #f0f7f6;
  --danger: #b42318;
  --warn: #a15c07;
  --s-new: #a1a1aa; --s-site_visit: #2563eb; --s-negotiation: #d97706;
  --s-agreement: #7c3aed; --s-won: #0f766e; --s-lost: #b42318;
}

* { box-sizing: border-box; border-radius: 0 !important; }
html, body { margin: 0; }
body { font: 14px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--text); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }
h1, h2, h3 { margin: 0; line-height: 1.3; font-weight: 600; letter-spacing: -.01em; }
small { font-size: 12px; }
.muted { color: var(--muted); }
.right { text-align: right; margin-left: auto; }
.nowrap { white-space: nowrap; }
.text-danger { color: var(--danger) !important; }
.text-warn { color: var(--warn) !important; }
.grow { flex: 1; min-width: 0; }

/* ---------- shell */
.shell { display: flex; min-height: 100vh; }
.sidebar { width: 224px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; padding: 0 20px; height: 64px; border-bottom: 1px solid var(--border); font-weight: 600; font-size: 15px; letter-spacing: -.01em; }
.brand:hover { text-decoration: none; }
.brand-mark { width: 24px; height: 24px; background: var(--ink); display: grid; place-items: center; }
.brand-mark svg { width: 14px; height: 14px; fill: #fff; }
.brand-mark.lg { width: 36px; height: 36px; margin-bottom: 8px; }
.brand-mark.lg svg { width: 20px; height: 20px; }
.sidebar nav { display: flex; flex-direction: column; padding: 12px 0; flex: 1; }
.sidebar nav a { display: flex; align-items: center; gap: 12px; padding: 9px 20px; color: var(--muted); font-weight: 500; border-left: 2px solid transparent; }
.sidebar nav a:hover { color: var(--text); text-decoration: none; background: var(--subtle); }
.sidebar nav a.active { color: var(--text); border-left-color: var(--ink); background: var(--subtle); }
.sidebar nav svg { width: 16px; height: 16px; fill: currentColor; }
.pill-count { margin-left: auto; font-size: 11px; font-weight: 600; color: var(--danger); border: 1px solid currentColor; padding: 0 5px; line-height: 16px; }
.sidebar-foot { padding: 16px 20px; border-top: 1px solid var(--border); }
.me { display: flex; gap: 10px; align-items: center; margin-bottom: 10px; }
.me strong { display: block; font-size: 13px; font-weight: 500; }
.me small { color: var(--muted); }
.logout { color: var(--muted); font-size: 13px; }
.avatar { width: 32px; height: 32px; background: var(--subtle); border: 1px solid var(--border); color: var(--text); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0; }
.avatar.xl { width: 52px; height: 52px; font-size: 20px; }

.main { flex: 1; min-width: 0; }
.topbar { display: flex; align-items: center; gap: 12px; padding: 0 32px; height: 64px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 5; }
.topbar h1 { font-size: 17px; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.menu-btn { display: none; background: none; border: 0; font-size: 20px; color: var(--text); cursor: pointer; padding: 0; }
.content { padding: 28px 32px 56px; max-width: 1400px; }
.flash { margin: 16px 32px 0; padding: 10px 14px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.content .flash, .auth-card .flash, .form .flash { margin: 0 0 16px; }
.flash-err { border-left-color: var(--danger); }
.flash-warn { border-left-color: var(--warn); }
.greeting { margin: 0 0 20px; color: var(--muted); }
.hint { color: var(--faint); font-size: 12px; margin: -8px 0 12px; }

/* ---------- buttons & inputs */
.btn { display: inline-flex; align-items: center; gap: 6px; height: 34px; padding: 0 14px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: var(--ink); text-decoration: none; }
.btn-primary { background: var(--ink); border-color: var(--ink); color: #fff; }
.btn-primary:hover { background: #000; }
.btn-danger { color: var(--danger); border-color: var(--border); }
.btn-danger:hover { border-color: var(--danger); }
.btn-ghost { border-color: transparent; background: transparent; color: var(--muted); }
.btn-ghost:hover { border-color: transparent; color: var(--text); }
.btn-wa { color: #15803d; }
.btn-sm { height: 28px; padding: 0 10px; font-size: 12px; }
.btn-block { width: 100%; justify-content: center; height: 40px; }
.btn.right { margin-left: auto; }

input, select, textarea { font: inherit; color: var(--text); background: var(--surface); border: 1px solid var(--border-strong); padding: 7px 10px; width: 100%; min-height: 36px; }
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
textarea { resize: vertical; }
input[type=checkbox] { accent-color: var(--ink); min-height: 0; }
label { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 12px; color: var(--muted); }
label.check { flex-direction: row; align-items: center; gap: 8px; font-size: 13px; color: var(--text); font-weight: 400; }
label.check input { width: auto; }
label.check.inline { display: inline-flex; margin-left: 10px; }
.money-hint { color: var(--faint); font-weight: 400; font-size: 12px; min-height: 16px; }

/* ---------- cards */
.card { background: var(--surface); border: 1px solid var(--border); padding: 20px 22px; margin-bottom: 20px; }
.card.flush { padding: 0; overflow: hidden; }
.card-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 14px; gap: 12px; }
.card-head h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.card-head a { font-size: 12px; color: var(--muted); }
.card-head a:hover { color: var(--text); }
.empty { color: var(--muted); margin: 4px 0; }
.empty a { text-decoration: underline; text-underline-offset: 3px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 20px; }
.stack { min-width: 0; }

/* Stats: one strip with dividers instead of four floating boxes. */
.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); background: var(--surface); border: 1px solid var(--border); margin-bottom: 20px; }
.stat { padding: 20px 22px; color: var(--text); display: flex; flex-direction: column; gap: 4px; border-left: 1px solid var(--border); }
.stat:first-child { border-left: 0; }
a.stat:hover { text-decoration: none; background: var(--subtle); }
.stat span { color: var(--muted); font-size: 12px; }
.stat strong { font-size: 28px; font-weight: 500; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat small { color: var(--faint); }

.bars { display: flex; flex-direction: column; gap: 12px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr auto; gap: 14px; align-items: center; font-size: 13px; }
.bar-track { height: 6px; background: var(--subtle); overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--ink); }
.bar-val { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; font-size: 12px; }

/* ---------- tags & status: rectangles, colour only as a small square marker */
.tag { display: inline-block; padding: 0 6px; line-height: 18px; border: 1px solid var(--border); font-size: 11px; font-weight: 500; color: var(--muted); background: var(--surface); }
.status, .stage-chip { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--text); }
.status::before, .stage-chip::before { content: ""; width: 7px; height: 7px; background: var(--c, var(--faint)); flex-shrink: 0; }
.status-new { --c: var(--s-new); }
.status-contacted { --c: var(--s-site_visit); }
.status-nurturing { --c: #94a3b8; color: var(--muted); }
.status-converted { --c: var(--s-won); }
.status-lost { --c: var(--s-lost); color: var(--muted); }
.stage-new { --c: var(--s-new); } .stage-site_visit { --c: var(--s-site_visit); } .stage-negotiation { --c: var(--s-negotiation); }
.stage-agreement { --c: var(--s-agreement); } .stage-won { --c: var(--s-won); } .stage-lost { --c: var(--s-lost); }
.bar-fill[class*="stage-"] { background: var(--c); }

/* ---------- tables */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; padding: 12px 16px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 12px 16px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table tbody tr:hover { background: var(--bg); }
.table td a strong { font-weight: 500; }
.table.compact td { padding: 9px 0; }
.table.compact td + td { padding-left: 12px; }
.table tr.inactive { opacity: .5; }
.wa { font-size: 10px; font-weight: 600; color: #15803d; border: 1px solid var(--border); padding: 0 4px; margin-left: 4px; }

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 18px; align-items: center; }
.filters input[type=search] { flex: 1 1 240px; width: auto; }
.filters select { width: auto; }
.pager { display: flex; gap: 12px; align-items: center; justify-content: flex-end; }
.tabs { display: flex; border: 1px solid var(--border-strong); background: var(--surface); }
.tabs a { padding: 0 14px; line-height: 32px; color: var(--muted); font-weight: 500; font-size: 13px; }
.tabs a + a { border-left: 1px solid var(--border-strong); }
.tabs a.active { background: var(--ink); color: #fff; }
.tabs a:hover { text-decoration: none; }

/* ---------- tasks */
.task-list { list-style: none; margin: 0; padding: 0; }
.task-list li { display: flex; gap: 12px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.task-list li:last-child { border-bottom: 0; }
.task-list li > div > a { font-weight: 500; }
.task-list small { display: block; color: var(--muted); margin-top: 2px; }
.task-list small a { color: var(--muted); }
.task-list li.overdue small { color: var(--danger); }
.task-list li.done > div > a { text-decoration: line-through; color: var(--faint); }
.tick { width: 16px; height: 16px; border: 1.5px solid var(--border-strong); background: var(--surface); cursor: pointer; padding: 0; flex-shrink: 0; position: relative; }
.tick:hover { border-color: var(--ink); }
.tick:hover::after, li.done .tick::after { content: ""; position: absolute; left: 4px; top: 1px; width: 4px; height: 8px; border: solid var(--ink); border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); }
li.done .tick { background: var(--ink); border-color: var(--ink); }
li.done .tick::after { border-color: #fff; }
.chip { border: 1px solid var(--border-strong); background: var(--surface); padding: 0 10px; line-height: 26px; font: inherit; font-size: 12px; cursor: pointer; color: var(--text); }
.chip:hover { border-color: var(--ink); }
.quick-dates { display: flex; gap: 6px; flex-wrap: wrap; margin-top: -4px; }

/* ---------- forms */
.form h3 { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 0 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }
.form h3:not(:first-of-type) { margin-top: 28px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.span-2 { grid-column: span 2; }
.form-actions { display: flex; gap: 8px; margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--border); }
.form { max-width: 860px; }
.form.narrow { max-width: 640px; }
.commission { margin: 18px 0 0; padding: 12px 14px; background: var(--accent-soft); border-left: 3px solid var(--accent); }

/* ---------- contact & deal detail */
.detail { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 20px; align-items: start; }
.detail.reverse { grid-template-columns: minmax(0, 1fr) 380px; }
.detail.reverse .form { max-width: none; }
.profile-head { display: flex; gap: 14px; align-items: center; margin-bottom: 18px; }
.profile-head h2 { font-size: 17px; margin-bottom: 6px; }
.profile-head .status { margin-left: 8px; }
.quick { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; margin-bottom: 18px; }
.quick .btn { justify-content: center; }
.quick .btn + .btn { border-left: 0; }
.facts { display: grid; grid-template-columns: 96px 1fr; gap: 10px 12px; margin: 0; font-size: 13px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; word-break: break-word; }
.notes { margin-top: 16px; padding: 12px 14px; background: var(--bg); border: 1px solid var(--border); font-size: 13px; }
.status-quick { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--border); }
.deal-row { display: grid; grid-template-columns: 1fr auto auto; gap: 16px; align-items: center; padding: 11px 0; border-bottom: 1px solid var(--border); }
.deal-row:last-child { border-bottom: 0; }
.deal-row:hover { text-decoration: none; }
.deal-row:hover strong { text-decoration: underline; text-underline-offset: 3px; }
.deal-row strong { font-weight: 500; }
.deal-row small { display: block; }
.log-form { display: grid; grid-template-columns: 120px 1fr auto; gap: 8px; align-items: start; margin-bottom: 20px; }
.timeline { list-style: none; margin: 0; padding: 0 0 0 18px; border-left: 1px solid var(--border); }
.timeline li { position: relative; padding: 0 0 18px 4px; }
.timeline li::before { content: ""; position: absolute; left: -22.5px; top: 6px; width: 8px; height: 8px; background: var(--surface); border: 1px solid var(--faint); }
.timeline li.kind-call::before, .timeline li.kind-whatsapp::before, .timeline li.kind-email::before { border-color: var(--s-site_visit); background: var(--s-site_visit); }
.timeline li.kind-stage::before, .timeline li.kind-status::before { border-color: var(--s-agreement); background: var(--s-agreement); }
.timeline li.kind-site_visit::before, .timeline li.kind-meeting::before { border-color: var(--accent); background: var(--accent); }
.tl-meta { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.tl-meta a { color: var(--muted); }
.tl-meta strong { color: var(--text); font-weight: 500; }

/* ---------- kanban */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(240px, 1fr); border: 1px solid var(--border); background: var(--surface); overflow-x: auto; }
.column { display: flex; flex-direction: column; min-height: 460px; border-left: 1px solid var(--border); }
.column:first-child { border-left: 0; }
.column.drop { background: var(--accent-soft); }
.col-head { padding: 14px 14px 12px; display: flex; gap: 8px; align-items: baseline; border-top: 2px solid var(--c); border-bottom: 1px solid var(--border); font-size: 13px; }
.col-head strong { font-weight: 600; }
.col-head .count { font-size: 12px; color: var(--faint); }
.col-head small { margin-left: auto; color: var(--muted); }
.col-body { padding: 10px; display: flex; flex-direction: column; gap: 8px; flex: 1; background: var(--bg); }
.deal-card { background: var(--surface); border: 1px solid var(--border); padding: 12px; cursor: grab; }
.deal-card:hover { border-color: var(--border-strong); }
.deal-card.dragging { opacity: .4; }
.deal-title { font-weight: 500; display: block; }
.deal-client { color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.deal-meta { display: flex; justify-content: space-between; align-items: center; }
.deal-meta strong { font-weight: 600; font-variant-numeric: tabular-nums; }
.deal-sub { font-size: 12px; color: var(--muted); margin-top: 6px; }
.deal-agent { font-size: 11px; color: var(--faint); margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); }

/* ---------- auth */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); padding: 36px 32px; display: flex; flex-direction: column; gap: 16px; }
.auth-card h1 { font-size: 20px; }
.auth-card p { margin: -8px 0 4px; }

/* ---------- workflow: search, segmented choices, log & next step */
.search { flex: 0 1 300px; }
.search input { min-height: 34px; background: var(--bg); }
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 500; font-size: 12px; color: var(--muted); }
.seg { display: flex; flex-wrap: wrap; }
.seg label { display: block; position: relative; margin: 0 -1px -1px 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; padding: 0 12px; line-height: 32px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; white-space: nowrap; }
.seg label:hover span { background: var(--subtle); }
.seg input:checked + span { background: var(--ink); border-color: var(--ink); color: #fff; position: relative; z-index: 1; }
.seg input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 1px; }

.next-bar { display: flex; align-items: center; gap: 16px; padding: 16px 20px; margin-bottom: 20px; background: var(--surface); border: 1px solid var(--border); border-left: 3px solid var(--accent); }
.next-bar small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; }
.next-bar strong { display: block; font-weight: 600; font-size: 15px; }
.next-bar span { color: var(--muted); font-size: 13px; }
.next-bar.is-overdue { border-left-color: var(--danger); }
.next-bar.is-overdue span { color: var(--danger); }
.next-bar.is-missing { border-left-color: var(--warn); }

.log-box { display: flex; flex-direction: column; gap: 18px; }
.log-completing { padding: 10px 14px; background: var(--accent-soft); border-left: 3px solid var(--accent); }
.log-step { display: flex; gap: 14px; }
.step-no { width: 22px; height: 22px; flex-shrink: 0; display: grid; place-items: center; font-size: 11px; font-weight: 600; border: 1px solid var(--border-strong); color: var(--muted); margin-top: 5px; }
.step-label { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 8px; }
.log-step textarea { margin-top: 8px; }
.next-detail { display: grid; grid-template-columns: 140px 1fr; gap: 8px; margin-top: 8px; }
.next-detail input[type=datetime-local] { grid-column: span 2; }
.next-detail.off { display: none; }
.log-actions { padding-left: 36px; }

details.more { margin-top: 20px; border-top: 1px solid var(--border); padding-top: 14px; }
details.more summary { cursor: pointer; font-size: 13px; font-weight: 500; color: var(--muted); list-style: none; }
details.more summary::-webkit-details-marker { display: none; }
details.more summary::before { content: "+"; display: inline-block; width: 16px; }
details.more[open] summary::before { content: "−"; }
details.more[open] summary { margin-bottom: 16px; }

/* ---------- click-to-edit & autosave */
.editable { cursor: text; padding: 1px 4px; margin: -1px -4px; border: 1px dashed transparent; display: inline-block; max-width: 100%; }
.editable:hover, .editable:focus { border-color: var(--border-strong); background: var(--bg); outline: none; }
.editable.is-empty { color: var(--faint); }
.editable.editing { border: 0; padding: 0; margin: 0; display: block; background: none; }
.profile-head .editable.editing { display: inline-block; min-width: 140px; }
.tag .editable, .status .editable { margin: -1px -4px; }
.inline-input { min-height: 30px; padding: 4px 8px; font-size: 13px; }
.notes-dd .editable { white-space: pre-wrap; }
.facts dd .editable:not(.editing) { word-break: break-word; }
.edit-hint { margin: 16px 0 0; padding-top: 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--faint); }
.autosave-note { align-self: center; font-size: 12px; color: var(--faint); margin-left: 4px; }
.field-error { border-color: var(--danger) !important; box-shadow: 0 0 0 1px var(--danger) !important; }
.save-status { position: fixed; right: 20px; bottom: 20px; z-index: 50; padding: 9px 14px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 500; opacity: 0; transform: translateY(6px); transition: opacity .15s, transform .15s; pointer-events: none; max-width: calc(100vw - 40px); }
.save-status.show { opacity: 1; transform: none; }
.save-status.ok::before { content: "✓  "; }
.save-status.error { background: var(--danger); }
.save-status.warn { background: var(--warn); }
[hidden] { display: none !important; }
.cell-name .editable:not(.editing) { font-weight: 500; }
.cell-name .editable.editing, .table .editable.editing { display: inline-block; min-width: 150px; }
.table td small .editable { color: var(--muted); }
.table td small .editable.is-empty, .table .editable.is-empty { color: var(--faint); }
.cell-name { white-space: nowrap; }
.cell-req { min-width: 190px; }
.cell-project { min-width: 150px; }
.table td.agent { white-space: nowrap; }
.open-link { margin-left: 6px; color: var(--faint); font-size: 13px; }
.open-link:hover { color: var(--text); text-decoration: none; }
.plan-link { font-size: 12px; color: var(--muted); }
.table td.text-danger .editable { color: var(--danger); }

/* ---------- lead upload */
.template-cols { border: 1px solid var(--border); margin-bottom: 18px; font-size: 13px; }
.template-cols td { color: var(--muted); }
.drop { display: block; position: relative; border: 1px dashed var(--border-strong); background: var(--bg); padding: 28px 16px; text-align: center; cursor: pointer; color: var(--text); font-size: 13px; }
.drop:hover, .drop.has-file { border-color: var(--ink); }
.drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.import-summary { display: flex; gap: 32px; align-items: baseline; padding-bottom: 18px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.import-summary strong { font-size: 26px; font-weight: 500; margin-right: 6px; }
.import-summary span { color: var(--muted); }
.form-grid.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.preview { margin-top: 20px; border: 1px solid var(--border); max-height: 460px; overflow: auto; }
.preview th { position: sticky; top: 0; background: var(--surface); }
.skip-row td { background: var(--bg); color: var(--muted); }

/* ---------- call outcomes, WhatsApp menu, speed-to-lead */
.outcome-bar { background: var(--surface); border: 1px solid var(--border); border-top: 0; padding: 12px 20px; margin: -20px 0 20px; }
.outcomes { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.outcomes-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin-right: 6px; }
.btn-quiet { color: var(--muted); }
.row-actions { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.outcomes.compact { flex-wrap: nowrap; }
.more-menu { position: relative; }
.more-menu summary { list-style: none; }
.more-menu summary::-webkit-details-marker { display: none; }
.more-menu .menu { position: absolute; right: 0; top: calc(100% + 4px); z-index: 30; min-width: 180px; background: var(--surface); border: 1px solid var(--border-strong); box-shadow: 0 8px 24px rgba(0,0,0,.08); display: flex; flex-direction: column; }
.more-menu .menu button, .more-menu .menu .btn { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 12px; font: inherit; font-size: 13px; color: var(--text); cursor: pointer; height: auto; }
.more-menu .menu button:hover { background: var(--subtle); }
.more-menu .menu form + form { border-top: 1px solid var(--border); }
.wa-menu .menu { left: 0; right: auto; min-width: 220px; }
.quick .wa-menu summary { justify-content: center; border-left: 0; width: 100%; }
.quick .wa-menu { display: flex; }
.wait { display: inline-block; font-size: 11px; font-weight: 600; color: var(--accent); margin-bottom: 2px; }
.wait.late { color: var(--danger); }

/* ---------- templates & reports */
.tag-code { font: 12px ui-monospace, Menlo, monospace; background: var(--surface); border: 1px solid var(--border); padding: 0 4px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 0 20px; }
.tpl { max-width: none; display: flex; flex-direction: column; gap: 12px; }
.tpl .form-actions { margin-top: auto; }
.tpl-preview { background: #e7f6ec; border-left: 3px solid #25a35a; padding: 10px 12px; font-size: 13px; }
.tpl-preview small { display: block; color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; margin-bottom: 4px; }
.card-head.pad { padding: 16px 20px 0; margin-bottom: 10px; }
.empty.pad { padding: 0 20px 16px; }
.table.num td + td, .table.num th + th { text-align: right; white-space: nowrap; }

/* ---------- responsive */
@media (max-width: 1100px) {
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stat:nth-child(3) { border-left: 0; }
  .stat:nth-child(n+3) { border-top: 1px solid var(--border); }
  .detail, .detail.reverse { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 820px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 20; transform: translateX(-100%); transition: transform .2s; }
  .sidebar.open { transform: none; box-shadow: 0 0 0 100vmax rgba(0,0,0,.2); }
  .menu-btn { display: block; }
  .topbar { padding: 12px 16px; height: auto; flex-wrap: wrap; }
  .top-actions { width: 100%; }
  .search { order: 3; flex-basis: 100%; }
  .next-detail { grid-template-columns: 1fr; }
  .next-detail input[type=datetime-local] { grid-column: auto; }
  .log-actions { padding-left: 0; }
  .task-list li { flex-wrap: wrap; }
  .row-actions { width: 100%; justify-content: flex-start; padding-left: 28px; }
  .outcome-bar { padding: 12px 16px; }
  .content { padding: 16px 16px 40px; }
  .flash { margin: 12px 16px 0; }
  .grid-2, .form-grid, .form-grid.four { grid-template-columns: minmax(0, 1fr); }
  .span-2 { grid-column: auto; }
  .log-form { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr auto; }
  .board { grid-auto-columns: 82%; }
}
@media (max-width: 480px) {
  .stats { grid-template-columns: minmax(0, 1fr); }
  .stat { border-left: 0; }
  .stat + .stat { border-top: 1px solid var(--border); }
}

/* ================================================================ master panel additions */
.site-switch { flex: 0 1 240px; }
.site-switch select { min-height: 34px; background: var(--bg); }
.dot { display: inline-block; width: 8px; height: 8px; background: var(--faint); flex-shrink: 0; }
.dot-up { background: var(--s-won); } .dot-slow { background: var(--warn); } .dot-down { background: var(--danger); }
.health { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.pub { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; }
.pub::before { content: ""; width: 7px; height: 7px; background: var(--s-won); }
.pub.off { color: var(--muted); } .pub.off::before { background: var(--faint); }
.thumb { width: 56px; height: 40px; object-fit: cover; background: var(--subtle); border: 1px solid var(--border); display: block; }
.cell-thumb { width: 72px; }

/* site cards */
.site-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; margin-bottom: 20px; }
.site-card { background: var(--surface); border: 1px solid var(--border); display: flex; flex-direction: column; }
.site-card-head { display: flex; gap: 12px; align-items: center; padding: 16px 18px; border-bottom: 1px solid var(--border); }
.site-logo { width: 40px; height: 40px; border: 1px solid var(--border); background: var(--subtle); display: grid; place-items: center; font-weight: 600; overflow: hidden; flex-shrink: 0; }
.site-logo img { max-width: 100%; max-height: 100%; object-fit: contain; }
.site-card-head h3 { font-size: 15px; }
.site-card-head small a { color: var(--muted); }
.site-nums { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.site-nums a { padding: 12px 14px; display: flex; flex-direction: column; border-left: 1px solid var(--border); color: var(--text); }
.site-nums a:first-child { border-left: 0; }
.site-nums a:hover { background: var(--subtle); text-decoration: none; }
.site-nums strong { font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; }
.site-nums span { font-size: 11px; color: var(--muted); }
.site-card-foot { padding: 12px 18px; display: flex; gap: 10px; align-items: center; font-size: 12px; color: var(--muted); margin-top: auto; flex-wrap: wrap; }

/* editor */
.editor-layout { display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 20px; align-items: start; }
.editor-layout .form { max-width: none; }
.editor-side { position: sticky; top: 84px; }
.editor-side .card { margin-bottom: 16px; }
.section-nav { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin: -20px -22px 20px; padding: 0 10px; overflow-x: auto; background: var(--surface); position: sticky; top: 64px; z-index: 4; }
.section-nav a { padding: 12px 12px; font-size: 13px; color: var(--muted); font-weight: 500; white-space: nowrap; border-bottom: 2px solid transparent; }
.section-nav a:hover { color: var(--text); text-decoration: none; }
.form textarea.mono, textarea.mono { font: 12px/1.5 ui-monospace, Menlo, monospace; }
.rich { border: 1px solid var(--border-strong); background: var(--surface); }
.rich .ql-toolbar.ql-snow { border: 0; border-bottom: 1px solid var(--border); font-family: inherit; }
.rich .ql-container.ql-snow { border: 0; font: inherit; font-size: 14px; }
.rich .ql-editor { min-height: 220px; }
.rich.tall .ql-editor { min-height: 420px; }
.count-hint { font-weight: 400; color: var(--faint); }
.count-hint.over { color: var(--danger); }
.serp { border: 1px solid var(--border); padding: 12px 14px; background: var(--bg); font-family: Arial, sans-serif; }
.serp .serp-url { font-size: 12px; color: #202124; }
.serp .serp-title { font-size: 18px; color: #1a0dab; line-height: 1.3; margin: 2px 0; }
.serp .serp-desc { font-size: 13px; color: #4d5156; }
.file-field { gap: 6px; }
.file-current { display: flex; align-items: center; gap: 12px; }
.file-current img { max-height: 64px; max-width: 160px; border: 1px solid var(--border); background: var(--subtle); display: block; }

/* media manager */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-item { border: 1px solid var(--border); background: var(--surface); display: flex; flex-direction: column; cursor: grab; }
.media-item.dragging { opacity: .4; }
.media-item.over { outline: 2px solid var(--accent); }
.media-item img { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: var(--subtle); display: block; }
.media-item input { border: 0; border-top: 1px solid var(--border); font-size: 12px; min-height: 30px; padding: 4px 8px; }
.media-item .media-actions { display: flex; justify-content: space-between; align-items: center; padding: 4px 8px; border-top: 1px solid var(--border); font-size: 11px; color: var(--faint); }
.media-item .media-actions button { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; font-size: 12px; padding: 2px 0; }
.drop-zone { display: block; position: relative; border: 1px dashed var(--border-strong); background: var(--bg); padding: 22px 16px; text-align: center; color: var(--muted); font-size: 13px; margin-bottom: 14px; cursor: pointer; }
.drop-zone:hover, .drop-zone.hover { border-color: var(--ink); color: var(--text); }
.drop-zone input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.media-tabs { margin-bottom: 14px; }

/* form builder */
.fb-row { display: grid; grid-template-columns: 22px 1.2fr 1.4fr 120px 1.4fr 70px 28px; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--border); }
.fb-row.head { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; }
.fb-row input, .fb-row select { min-height: 32px; padding: 4px 8px; font-size: 13px; }
.fb-row .handle { cursor: grab; color: var(--faint); text-align: center; user-select: none; }
.fb-row .del { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 18px; }
.fb-row .del:hover { color: var(--danger); }
.fb-row label.check { justify-content: center; }
.code-box { position: relative; }
.code-box pre { margin: 0; background: #18181b; color: #e4e4e7; padding: 14px 16px; font: 12px/1.6 ui-monospace, Menlo, monospace; overflow-x: auto; white-space: pre; }
.code-box .copy { position: absolute; top: 8px; right: 8px; background: #3f3f46; color: #fff; border: 0; font: inherit; font-size: 11px; padding: 3px 8px; cursor: pointer; }
.steps { margin: 0; padding-left: 20px; }
.steps li { margin-bottom: 14px; }
.steps li p { margin: 4px 0 8px; color: var(--muted); }
.key { font: 12px ui-monospace, Menlo, monospace; background: var(--subtle); border: 1px solid var(--border); padding: 2px 6px; word-break: break-all; }

/* leads */
.lead-extra { font-size: 12px; color: var(--muted); }
.lead-msg { max-width: 360px; font-size: 13px; }
.status-qualified { --c: var(--s-won); }
.status-junk { --c: var(--s-lost); color: var(--muted); }
.inline-select { width: auto; min-height: 28px; padding: 2px 6px; font-size: 12px; }
.utm { font-size: 11px; color: var(--faint); }

/* health */
.health-bar { display: flex; gap: 2px; align-items: flex-end; height: 22px; }
.health-bar i { width: 5px; height: 100%; background: var(--s-won); display: block; }
.health-bar i.slow { background: var(--warn); } .health-bar i.down { background: var(--danger); }
.expiry-warn { color: var(--warn); font-weight: 500; }
.expiry-bad { color: var(--danger); font-weight: 500; }
.audit-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.audit-list li { padding: 8px 0; border-bottom: 1px solid var(--border); display: flex; gap: 10px; }
.audit-list li:last-child { border-bottom: 0; }
.audit-list small { color: var(--faint); white-space: nowrap; margin-left: auto; }
.sites-check { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px 16px; }

@media (max-width: 1100px) {
  .editor-layout { grid-template-columns: minmax(0, 1fr); }
  .editor-side { position: static; }
}
@media (max-width: 820px) {
  .fb-row { grid-template-columns: 1fr 1fr; }
  .fb-row.head { display: none; }
  .fb-row .handle { display: none; }
  .section-nav { top: 0; }
  .site-switch { order: 2; flex-basis: 100%; }
}
