:root {
  --brand: #013C9E;
  --accent: #F4BC00;
  --ink: #2b2a2c;
  --ink-2: #414042;
  --muted: #6b6d70;
  --line: #e6e7ea;
  --bg: #f4f4f5;
  --card: #ffffff;
  --ok: #157f3b;
  --ok-bg: #e7f6ec;
  --warn: #8a5a00;
  --warn-bg: #fff4d6;
  --bad: #b42318;
  --bad-bg: #fdecea;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); color: var(--ink-2); background: var(--bg); line-height: 1.45; }
a { color: var(--brand); }
img { max-width: 100%; }
h1, h2, h3 { color: var(--ink); line-height: 1.2; }
button, input, select, textarea { font: inherit; color: inherit; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted, .sub { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ---------- buttons & forms ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--brand); color: #fff; border: 2px solid var(--brand); border-radius: 8px;
  padding: 10px 16px; font-weight: 700; font-size: 15px; text-decoration: none; cursor: pointer;
  min-height: 44px; transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.alt { background: #fff; color: var(--brand); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--brand); padding-inline: 10px; }
.btn.danger { background: #fff; color: var(--bad); border-color: #f1c4bf; }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #111; }
.btn.sm { min-height: 34px; padding: 6px 10px; font-size: 14px; }
.btn.block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

label { display: block; font-size: 14px; font-weight: 600; margin: 12px 0 4px; color: var(--ink-2); }
label.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
label.check input { width: auto; }
input, select, textarea {
  width: 100%; padding: 10px 12px; border: 1px solid #cfd1d5; border-radius: 8px; font-size: 16px;
  background: #fff; min-height: 44px;
}
textarea { min-height: 80px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible { outline: 3px solid color-mix(in srgb, var(--brand) 30%, transparent); outline-offset: 1px; border-color: var(--brand); }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 12px; }
.grid3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0 12px; }
@media (max-width: 640px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 420px) { .grid2.stack-sm, .grid3 { grid-template-columns: 1fr; } }

.notice { padding: 12px 14px; border-radius: 8px; margin: 10px 0; font-size: 15px; }
.notice.ok { background: var(--ok-bg); color: var(--ok); }
.notice.warn { background: var(--warn-bg); color: var(--warn); }
.notice.bad { background: var(--bad-bg); color: var(--bad); }

.pill { display: inline-block; font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; background: #eceef1; color: var(--ink-2); text-transform: capitalize; }
.pill.published { background: var(--ok-bg); color: var(--ok); }
.pill.draft { background: #eceef1; color: var(--muted); }
.pill.sold { background: var(--bad-bg); color: var(--bad); }
.pill.new { background: #e5edfb; color: var(--brand); }
.pill.contacted { background: var(--warn-bg); color: var(--warn); }
.pill.closed { background: #eceef1; color: var(--muted); }

.card { background: var(--card); border-radius: var(--radius); padding: 16px; margin-bottom: 14px; box-shadow: var(--shadow); }
.card > h2:first-child, .section-title { font-size: 18px; margin: 0 0 12px; border-left: 4px solid var(--accent); padding-left: 9px; }

#toast { position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%); z-index: 100; display: grid; gap: 8px; width: min(92vw, 420px); pointer-events: none; }
#toast div { background: #222; color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); font-size: 15px; animation: pop .2s ease; }
#toast div.bad { background: var(--bad); }
@keyframes pop { from { opacity: 0; transform: translateY(8px); } }

.loading { padding: 60px 16px; text-align: center; color: var(--muted); }
.spinner { width: 28px; height: 28px; border: 3px solid #dfe1e5; border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; margin: 0 auto 10px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- public site ---------- */
.site-header { background: #fff; padding: 10px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px; border-bottom: 3px solid var(--accent); position: sticky; top: 0; z-index: 20; }
.site-header .logo img { height: 44px; display: block; }
.site-header .logo { text-decoration: none; color: var(--ink); font-weight: 800; font-size: 18px; }
.site-header .phone { color: var(--brand); font-weight: 700; text-decoration: none; white-space: nowrap; }
.site-main { max-width: 880px; margin: auto; padding: 16px 16px 110px; }
.site-footer { text-align: center; color: var(--muted); font-size: 13px; padding: 20px 16px 100px; }
.site-footer a { color: inherit; }

.hero-title { margin: 2px 0 4px; font-size: 26px; }
.price { font-size: 30px; font-weight: 800; color: var(--ink); margin: 10px 0 2px; }
.price .sub { font-size: 14px; font-weight: 500; }
.greeting { background: color-mix(in srgb, var(--accent) 22%, #fff); border-radius: 10px; padding: 10px 14px; margin-bottom: 14px; font-size: 15px; }
.sold-banner { background: var(--bad); color: #fff; text-align: center; font-weight: 800; padding: 10px; border-radius: 10px; margin-bottom: 14px; }

.gallery-main { position: relative; border-radius: 10px; overflow: hidden; background: #e5e7eb; aspect-ratio: 4 / 3; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.gallery-main .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 44px; height: 44px; border-radius: 50%; border: 0; background: rgba(0,0,0,.45); color: #fff; font-size: 22px; cursor: pointer; }
.gallery-main .prev { left: 8px; } .gallery-main .next { right: 8px; }
.gallery-main .count { position: absolute; right: 10px; bottom: 10px; background: rgba(0,0,0,.6); color: #fff; font-size: 13px; padding: 3px 9px; border-radius: 999px; }
.thumbs { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scroll-snap-type: x proximity; }
.thumbs button { flex: 0 0 76px; height: 57px; padding: 0; border: 2px solid transparent; border-radius: 6px; overflow: hidden; cursor: pointer; background: #ddd; scroll-snap-align: start; }
.thumbs button.on { border-color: var(--accent); }
.thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.94); z-index: 200; display: flex; align-items: center; justify-content: center; touch-action: pan-y; }
.lightbox img { max-width: 100vw; max-height: 88vh; object-fit: contain; }
.lightbox button { position: absolute; background: rgba(255,255,255,.15); color: #fff; border: 0; width: 48px; height: 48px; border-radius: 50%; font-size: 24px; cursor: pointer; }
.lightbox .close { top: 12px; right: 12px; }
.lightbox .prev { left: 10px; top: 50%; } .lightbox .next { right: 10px; top: 50%; }
.lightbox .count { position: absolute; bottom: 14px; color: #ddd; font-size: 14px; }

.specs { width: 100%; border-collapse: collapse; font-size: 15px; }
.specs td { padding: 9px 4px; border-bottom: 1px solid #eee; vertical-align: top; }
.specs td:first-child { color: var(--muted); width: 42%; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; padding: 0; margin: 0; }
.chips li { background: #f0f2f5; border-radius: 999px; padding: 5px 11px; font-size: 14px; }
.doc-row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #eee; text-decoration: none; color: inherit; }
.doc-row:last-child { border-bottom: 0; }
.doc-row .open { color: var(--brand); font-weight: 700; white-space: nowrap; }
.recall { border-left: 3px solid var(--bad); padding: 6px 0 6px 12px; margin: 10px 0; }
.recall summary { cursor: pointer; font-weight: 600; }
.person { display: flex; gap: 14px; align-items: center; margin-bottom: 14px; }
.person img, .person .avatar { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 3px solid var(--accent); flex: none; }
.person .avatar { display: grid; place-items: center; background: var(--brand); color: #fff; font-weight: 800; font-size: 24px; }
.desc { white-space: pre-line; }
.form-ok { background: var(--ok-bg); color: var(--ok); padding: 14px; border-radius: 8px; margin-top: 10px; font-weight: 600; }

.action-bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line); padding: 10px 12px calc(10px + env(safe-area-inset-bottom)); display: grid; grid-template-columns: 1fr 1fr 1.4fr; gap: 8px; box-shadow: 0 -4px 16px rgba(0,0,0,.06); }
@media (min-width: 900px) { .action-bar { left: 50%; transform: translateX(-50%); width: 880px; border-radius: 14px 14px 0 0; } }

.inv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.inv-card { background: #fff; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); text-decoration: none; color: inherit; display: flex; flex-direction: column; }
.inv-card img, .inv-card .noimg { width: 100%; aspect-ratio: 4/3; object-fit: cover; background: #e5e7eb; display: block; }
.inv-card .body { padding: 12px 14px 14px; }
.inv-card h3 { font-size: 16px; margin: 0 0 4px; }
.inv-card .p { font-weight: 800; font-size: 18px; color: var(--ink); margin-top: 6px; }

/* ---------- admin ---------- */
.admin-top { background: var(--ink); color: #fff; position: sticky; top: 0; z-index: 40; }
.admin-top .in { max-width: 1180px; margin: auto; display: flex; align-items: center; gap: 6px; padding: 8px 12px; }
.admin-top .brand { font-weight: 800; color: #fff; text-decoration: none; margin-right: 10px; display: flex; gap: 8px; align-items: center; white-space: nowrap; }
.admin-top .brand small { font-weight: 500; opacity: .7; }
.admin-top nav { display: flex; gap: 2px; overflow-x: auto; flex: 1; scrollbar-width: none; }
.admin-top nav a { color: #d6d7da; text-decoration: none; padding: 8px 11px; border-radius: 7px; font-weight: 600; font-size: 15px; white-space: nowrap; }
.admin-top nav a.on, .admin-top nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.admin-top .me { color: #d6d7da; font-size: 14px; text-decoration: none; white-space: nowrap; }
.admin-main { max-width: 1180px; margin: auto; padding: 18px 14px 90px; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; font-size: 24px; }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.toolbar input[type=search] { flex: 1 1 220px; }
.toolbar select { width: auto; }

.vlist { display: grid; gap: 10px; }
.vrow { display: grid; grid-template-columns: 96px 1fr auto; gap: 14px; align-items: center; background: #fff; padding: 10px; border-radius: 10px; box-shadow: var(--shadow); text-decoration: none; color: inherit; }
.vrow img, .vrow .noimg { width: 96px; height: 72px; object-fit: cover; border-radius: 7px; background: #e5e7eb; display: block; }
.vrow h3 { margin: 0 0 3px; font-size: 16px; }
.vrow .meta { font-size: 13px; color: var(--muted); }
.vrow .stats { text-align: right; font-size: 13px; color: var(--muted); white-space: nowrap; }
.vrow .stats strong { color: var(--ink); font-size: 15px; }
@media (max-width: 560px) { .vrow { grid-template-columns: 76px 1fr; } .vrow img, .vrow .noimg { width: 76px; height: 57px; } .vrow .stats { grid-column: 2; text-align: left; } }

.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs button { background: none; border: 0; padding: 10px 14px; font-weight: 700; color: var(--muted); cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -2px; white-space: nowrap; }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.tabs .badge { background: var(--accent); color: #111; border-radius: 999px; font-size: 11px; padding: 1px 6px; margin-left: 4px; }

.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.photo-tile { position: relative; background: #fff; border-radius: 8px; overflow: hidden; box-shadow: var(--shadow); }
.photo-tile img { width: 100%; aspect-ratio: 4/3; object-fit: cover; display: block; }
.photo-tile .bar { display: flex; justify-content: space-between; padding: 4px; }
.photo-tile .bar button { background: none; border: 0; cursor: pointer; padding: 6px 8px; border-radius: 6px; font-size: 15px; }
.photo-tile .bar button:hover { background: #f0f2f5; }
.photo-tile .cover { position: absolute; left: 6px; top: 6px; background: var(--accent); color: #111; font-size: 11px; font-weight: 800; padding: 2px 7px; border-radius: 999px; }
.dropzone { border: 2px dashed #c6c9ce; border-radius: 10px; padding: 22px; text-align: center; background: #fafbfc; margin-bottom: 14px; }
.dropzone.over { border-color: var(--brand); background: #eef3fc; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; background: #fff; }
table.data th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); padding: 8px; border-bottom: 2px solid var(--line); }
table.data td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 10px; box-shadow: var(--shadow); }

.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin-bottom: 14px; }
.kpi { background: #fff; border-radius: 10px; padding: 12px 14px; box-shadow: var(--shadow); }
.kpi .n { font-size: 24px; font-weight: 800; color: var(--ink); }
.kpi .l { font-size: 13px; color: var(--muted); }

.share-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.share-item:last-child { border-bottom: 0; }
.opened { color: var(--ok); font-weight: 700; }
.not-opened { color: var(--muted); }

.lead { background: #fff; border-radius: 10px; box-shadow: var(--shadow); padding: 14px; margin-bottom: 10px; display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; }
.lead h3 { margin: 0; font-size: 17px; }
.lead .contact a { margin-right: 14px; font-weight: 600; }
@media (max-width: 560px) { .lead { grid-template-columns: 1fr; } }

.auth-wrap { max-width: 400px; margin: 8vh auto; padding: 0 16px; }
.auth-wrap .card { padding: 24px; }
.copy-field { display: flex; gap: 6px; }
.copy-field input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
code { background: #f0f2f5; padding: 1px 5px; border-radius: 4px; font-size: 13px; }

@media print {
  .no-print { display: none !important; }
  body { background: #fff; }
}

/* small-screen + desktop refinements */
@media (max-width: 600px) {
  .admin-top .brand { display: none; }
  .admin-top nav a { padding: 8px 9px; }
}
@media (min-width: 900px) {
  .action-bar { display: none; }
  .site-main { padding-bottom: 40px; }
  .site-footer { padding-bottom: 30px; }
}

/* ---------- messaging ---------- */
.nav-badge { background: var(--accent); color: #111; border-radius: 999px; font-size: 11px; font-weight: 800; padding: 1px 6px; margin-left: 5px; }
.inbox { display: grid; grid-template-columns: 320px 1fr; gap: 14px; min-height: 70vh; }
.convos { background: #fff; border-radius: 10px; box-shadow: var(--shadow); overflow: auto; max-height: 78vh; }
.convo { display: block; padding: 12px 14px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.convo.on { background: #eef3fc; }
.convo .top { display: flex; justify-content: space-between; gap: 8px; }
.convo .snip { font-size: 13px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.convo .unread { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.thread { background: #fff; border-radius: 10px; box-shadow: var(--shadow); display: flex; flex-direction: column; min-height: 70vh; }
.thread-head { padding: 12px 16px; border-bottom: 1px solid var(--line); display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap; align-items: center; }
.bubbles { flex: 1; overflow: auto; padding: 16px; display: flex; flex-direction: column; gap: 8px; max-height: 56vh; }
.bubble { max-width: 78%; padding: 9px 13px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.bubble.in { background: #eef0f3; align-self: flex-start; border-bottom-left-radius: 4px; }
.bubble.out { background: var(--brand); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.bubble.out.failed { background: var(--bad-bg); color: var(--bad); }
.bubble.sys { align-self: center; background: none; color: var(--muted); font-size: 12px; padding: 2px; }
.bubble .meta { display: block; font-size: 11px; opacity: .75; margin-top: 3px; }
.composer { border-top: 1px solid var(--line); padding: 12px; }
.composer textarea { min-height: 64px; }
.consent-pill { font-size: 12px; font-weight: 700; border-radius: 999px; padding: 2px 9px; }
.consent-pill.opted_in { background: var(--ok-bg); color: var(--ok); }
.consent-pill.opted_out { background: var(--bad-bg); color: var(--bad); }
.consent-pill.unknown { background: #eceef1; color: var(--muted); }
@media (max-width: 760px) { .inbox { grid-template-columns: 1fr; } .inbox.has-thread .convos { display: none; } .inbox:not(.has-thread) .thread { display: none; } }
.meter { height: 10px; background: #eceef1; border-radius: 999px; overflow: hidden; margin: 6px 0; }
.meter > div { height: 100%; background: var(--brand); }
.meter.over > div { background: var(--bad); }
.steps { list-style: none; padding: 0; margin: 0; columns: 2; column-gap: 24px; }
.steps li { padding: 4px 0; font-size: 14px; break-inside: avoid; }
.steps li.done::before { content: '✓ '; color: var(--ok); font-weight: 800; }
.steps li.now::before { content: '→ '; color: var(--brand); font-weight: 800; }
.steps li.todo { color: var(--muted); }
.steps li.todo::before { content: '○ '; }
@media (max-width: 640px) { .steps { columns: 1; } }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
