/* Shared layout. Colours come from the brand file (brand-smc.css / brand-bni.css). */
:root {
  --bg: #f5f6f4; --surface: #ffffff; --ink: #16181d; --muted: #5f6672; --line: #e3e6ea;
  --brand: #1f9d3a; --brand-ink: #ffffff; --brand-dark: #137a2b; --accent: #7a2fd1;
  --header-bg: #0f1411; --header-ink: #ffffff;
  --ok: #1f9d3a; --ok-bg: #e7f6ea; --warn: #b26b00; --warn-bg: #fff3dc; --bad: #c62828; --bad-bg: #fde8e8;
  --radius: 12px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 2px 8px rgba(0,0,0,.05);
  --font: 'Segoe UI', system-ui, -apple-system, Roboto, Arial, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font); }
a { color: var(--brand-dark); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.45rem; } h2 { font-size: 1.15rem; } h3 { font-size: 1rem; }
p { margin: 0 0 .7em; }
small, .small { font-size: .85rem; color: var(--muted); }
.muted { color: var(--muted); }

/* Header */
.top { background: var(--header-bg); color: var(--header-ink); padding: 10px 16px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.top .logo { height: 40px; width: auto; border-radius: 6px; background: #fff; }
.top .title { font-weight: 700; font-size: 1.05rem; }
.top .title small { display: block; color: inherit; opacity: .75; font-weight: 400; font-size: .78rem; }
.top .spacer { flex: 1; }
.top select, .top button { font: inherit; font-size: .85rem; padding: 5px 8px; border-radius: 8px; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1); color: inherit; }
.top select { width: auto; max-width: 260px; }
.top select option { color: #000; }
.modebar { background: var(--warn-bg); color: var(--warn); font-size: .82rem; padding: 4px 16px; text-align: center; }

.wrap { max-width: 1080px; margin: 0 auto; padding: 16px; }
.narrow { max-width: 560px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin: 0 0 14px; box-shadow: var(--shadow); }
.grid { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

/* Tabs */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin: 0 0 14px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 10px 14px; font: inherit; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.on { color: var(--ink); font-weight: 600; border-bottom-color: var(--brand); }

/* Buttons and forms */
.btn { display: inline-block; font: inherit; font-weight: 600; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; text-decoration: none; text-align: center; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.btn.primary:hover { background: var(--brand-dark); }
.btn.danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn.big { padding: 14px 20px; font-size: 1.05rem; width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 10px 0 4px; }
input[type=text], input[type=email], input[type=tel], input[type=number], textarea, select { width: 100%; font: inherit; padding: 9px 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; color: var(--ink); }
textarea { min-height: 90px; }
.check { display: flex; gap: 8px; align-items: flex-start; font-weight: 400; }
.check input { margin-top: 4px; }

/* Status pills */
.pill { display: inline-block; font-size: .75rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--line); color: var(--ink); white-space: nowrap; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.brand { background: var(--brand); color: var(--brand-ink); }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.scroll { overflow-x: auto; }

/* Stat tiles */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
.stat b { display: block; font-size: 1.6rem; line-height: 1.1; }
.stat span { font-size: .8rem; color: var(--muted); }

/* Power-team contact card */
.team { display: grid; gap: 8px; margin-top: 10px; }
.tm { display: flex; justify-content: space-between; gap: 10px; align-items: center; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: #fafbfa; }
.tm.amber { background: var(--warn-bg); border-color: #f0c96b; }
.tm.green { background: var(--ok-bg); border-color: #9bd3a7; }
.tm.red { background: var(--bad-bg); border-color: #efa0a0; }
.tm .who b { display: block; }
.notice { padding: 10px 12px; border-radius: 10px; background: var(--warn-bg); color: var(--warn); margin: 8px 0; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

/* Invitation rendering */
.invitation { background: #fff; border: 1px solid var(--line); border-radius: 10px; padding: 18px 20px; max-width: 640px; }
.invitation .intros { padding-left: 18px; }
.invitation .cta { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.invitation .cta .btn { flex: 1; min-width: 160px; }
.qr-block { display: flex; gap: 14px; align-items: center; border: 1px dashed var(--line); padding: 10px; border-radius: 10px; margin: 12px 0; }
.qr canvas, .qr img { width: 120px; height: 120px; }

/* Chat */
.chat { display: flex; flex-direction: column; gap: 8px; min-height: 200px; }
.msg { max-width: 85%; padding: 9px 12px; border-radius: 12px; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); }
.msg.bot { align-self: flex-start; background: #eef0f2; }

.capture-drop { border: 2px dashed var(--brand); border-radius: var(--radius); padding: 26px 16px; text-align: center; cursor: pointer; background: var(--surface); }
.capture-drop img { max-width: 100%; max-height: 260px; border-radius: 8px; }
.hide { display: none !important; }
footer.foot { text-align: center; font-size: .78rem; color: var(--muted); padding: 22px 16px; }
/* Phones with a notch or a home bar (the store apps draw edge to edge). */
.top { padding-top: max(10px, env(safe-area-inset-top)); padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
footer.foot { padding-bottom: max(22px, env(safe-area-inset-bottom)); }

@media (max-width: 600px) {
  .wrap { padding: 12px; }
  .top .logo { height: 32px; }
  th, td { padding: 6px 5px; }
}

/* Talking points on a warm lead: always visible, just above the call/email buttons. */
.talking { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: color-mix(in srgb, var(--accent) 8%, #fff); border-left: 5px solid var(--accent); }
.talking h3 { margin: 0 0 6px; font-size: .95rem; color: var(--accent); }
.talking ul { margin: 0; padding-left: 18px; }
.talking li { margin: 3px 0; }
.talking.about { background: color-mix(in srgb, var(--brand) 8%, #fff); border-left-color: var(--brand); }
.talking.about h3 { color: var(--brand-dark); }

/* LOCAL BUILD view switch: preview at tablet or phone width inside a PC browser. */
html[data-view="tablet"], html[data-view="phone"] { background: #c9ced6; }
html[data-view="tablet"] body, html[data-view="phone"] body { margin: 16px auto; min-height: calc(100vh - 32px); border-radius: 18px; overflow: hidden; box-shadow: 0 6px 30px rgba(0,0,0,.25); }
html[data-view="tablet"] body { max-width: 820px; }
html[data-view="phone"] body { max-width: 390px; }
html[data-view="phone"] .wrap { padding: 12px; }
html[data-view="phone"] .top .logo { height: 32px; }
html[data-view="phone"] .top nav .btn { padding: 4px 8px !important; font-size: .78rem !important; }
html[data-view="phone"] th, html[data-view="phone"] td { padding: 6px 5px; }
html[data-view="phone"] .grid { grid-template-columns: 1fr; }
html[data-view="phone"] .stats { grid-template-columns: 1fr 1fr; }
html[data-view="phone"] .tabs button { padding: 10px 8px; font-size: .88rem; }
@media (max-width: 420px) { .tabs button { padding: 10px 8px; font-size: .88rem; } }

/* Member photos (or initials when there's no photo). */
.avatar { display: inline-block; border-radius: 50%; object-fit: cover; background: #e6e9ee; color: #444; font-weight: 600; text-align: center; flex: none; }
.tm { justify-content: flex-start; }
.tm .who { margin-left: 10px; }
.faces { display: flex; gap: 14px; flex-wrap: wrap; margin: 6px 0 12px; }
.face { display: flex; flex-direction: column; align-items: center; text-align: center; width: 110px; gap: 3px; }
.face b { font-size: .9rem; }

/* Photo crop tool: a round window over the photo. */
.crop-frame { position: relative; margin: 10px auto; overflow: hidden; border-radius: 12px; background: #222; touch-action: none; }
.crop-frame img { position: absolute; left: 0; top: 0; max-width: none; cursor: grab; user-select: none; }
.crop-frame::after { content: ''; position: absolute; inset: 0; border-radius: 50%; box-shadow: 0 0 0 999px rgba(0,0,0,.55); pointer-events: none; }

/* The signed-in member, top right of the header. */
.me-chip { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; font-weight: 600; font-size: .9rem; padding: 3px 10px 3px 3px; border-radius: 999px; background: rgba(255,255,255,.12); order: 99; }
.me-chip:hover { background: rgba(255,255,255,.22); }
html[data-view="phone"] .me-chip span { display: none; }
@media (max-width: 420px) { .me-chip span { display: none; } }
:root .top .me-chip .avatar { border: 2px solid rgba(255,255,255,.7); }

/* Warm leads: one line each when closed, so many fit on a phone screen. */
.card.lead { padding: 0; overflow: hidden; margin-bottom: 8px; }
.lead-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 12px 14px; background: none; border: 0; text-align: left; font: inherit; color: inherit; cursor: pointer; }
.lead-head .lead-title { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lead-head .lead-title b, .lead-head .lead-title .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-head .pill { flex-shrink: 0; }
.lead-head .chev { width: 9px; height: 9px; flex-shrink: 0; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(45deg); margin: 0 4px 4px; transition: transform .15s; opacity: .6; }
.card.lead.open .chev { transform: rotate(-135deg); margin: 4px 4px 0; }
.lead-body { display: none; padding: 10px 14px 14px; border-top: 1px solid var(--line); }
.card.lead.open .lead-body { display: block; }

/* Demo mode: developer extras hidden; a quiet user switch and way back. */
body[data-demo="on"] .dev-only { display: none !important; }
/* Hosted: no developer extras at all. */
body[data-env="production"] .dev-only { display: none !important; }
.signout { font-size: .85rem; padding: 5px 10px; }
.whoswitch { display: inline-flex; align-items: center; justify-content: center; width: 34px; height: 34px; padding: 0; border-radius: 50%; border: 1px solid rgba(255,255,255,.3); background: rgba(255,255,255,.1); color: inherit; cursor: pointer; }
.demo-back { position: fixed; right: 12px; bottom: 12px; z-index: 40; font-size: .8rem; padding: 6px 12px; opacity: .85; }

/* Reach map */
.reachmap { height: 440px; border-radius: 10px; border: 1px solid var(--line); z-index: 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; margin-right: 3px; }
.ring { display: inline-block; width: 10px; height: 10px; border-radius: 50%; border: 2px solid #2b8a3e; background: #2b8a3e; vertical-align: middle; margin-right: 3px; }
.ring.hollow { border-color: #868e96; background: none; }
.leaflet-control-layers label { font-size: .8rem; }
