/* =====================================================================
   Aurex CRM (Demo) — stylesheet
   Two deliberately distinct themes sharing one structural language:
   - [data-mode="admin"]    ledger-inspired, brass-on-ink, hairline rules
   - [data-mode="employee"] warm green & cream, rounded, mobile-first
===================================================================== */

:root {
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;
  --font-admin-display: 'Archivo', 'Segoe UI', system-ui, sans-serif;
  --font-admin-body: 'IBM Plex Sans', 'Segoe UI', system-ui, sans-serif;
  --font-employee: 'Quicksand', 'Nunito Sans', system-ui, sans-serif;

  --status-new: #5B7DB1;
  --status-contacted: #C08B2E;
  --status-followup: #B9762E;
  --status-sitevisit: #2F7A6E;
  --status-sitevisit-done: #3E7CA6;
  --status-sitevisit-cancelled: #B4704A;
  --status-negotiation: #7A5AA8;
  --status-converted: #3F7D4C;
  --status-notinterested: #8B8B85;
  --status-invalid: #A14B42;

  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
html, body { height: 100%; }

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body-font);
  -webkit-font-smoothing: antialiased;
  transition: background .2s ease, color .2s ease;
}

/* ---------------- Admin theme tokens ----------------
   Aurex's own brand identity (colors sampled directly from the company
   logo), not a generic template. The previous two admin looks (ledger
   light, "Concept D" dark premium) are preserved as full file backups
   outside this project, not as in-app toggle states — ask and they can be
   restored wholesale. The toggle below switches light/dark of THIS one
   brand, the same way any single design normally supports both. */
[data-mode="admin"] {
  --bg: #F7F8FA;
  --surface: #FFFFFF;
  --surface-2: #EEF1F6;
  --ink: #1F2937;
  --muted: #667085;
  --line: #E3E6EC;
  --accent: #1F7A52;        /* deep forest green — links, focus */
  --accent-ink: #0F2E1E;    /* deep forest green — topbar, primary buttons, active nav */
  --brand-red: #BB1313;     /* sampled from the Aurex logo (unchanged — logo itself never changes) */
  --accent-contrast: #FFFFFF;
  --focus: #1F7A52;
  --warn-bg: #FFF3D6; --warn-border: #F0C36D; --warn-text: #7A5300;
  --metric-danger: #BB1313; --metric-warning: #C9821A; --metric-teal: #1D7A6E;
  --metric-green: #2E8B4F; --metric-blue: #2F5AAE; --metric-purple: #7A5AA8;
  --body-font: var(--font-admin-body);
  --display-font: var(--font-admin-display);
}
@media (prefers-color-scheme: dark) {
  [data-mode="admin"]:not([data-theme="light"]) {
    --bg: #0F1420; --surface: #182136; --surface-2: #1F2A45;
    --ink: #E8EBF2; --muted: #8B93A7; --line: #2C3752;
    --accent: #4CAF7C; --accent-ink: #1D5C3D; --brand-red: #E14A4A; --accent-contrast: #FFFFFF;
    --warn-bg: rgba(224,166,79,.14); --warn-border: rgba(224,166,79,.4); --warn-text: #E0A64F;
    --metric-danger: #E14A4A; --metric-warning: #E0A64F; --metric-teal: #4FC3B0;
    --metric-green: #5FD980; --metric-blue: #5B85D6; --metric-purple: #B69AF0;
  }
}
[data-mode="admin"][data-theme="dark"] {
  --bg: #0F1420; --surface: #182136; --surface-2: #1F2A45;
  --ink: #E8EBF2; --muted: #8B93A7; --line: #2C3752;
  --accent: #4CAF7C; --accent-ink: #1D5C3D; --brand-red: #E14A4A; --accent-contrast: #FFFFFF;
  --warn-bg: rgba(224,166,79,.14); --warn-border: rgba(224,166,79,.4); --warn-text: #E0A64F;
  --metric-danger: #E14A4A; --metric-warning: #E0A64F; --metric-teal: #4FC3B0;
  --metric-green: #5FD980; --metric-blue: #5B85D6; --metric-purple: #B69AF0;
}

[data-mode="admin"] .metric-card, [data-mode="admin"] .chart-card, [data-mode="admin"] .table-wrap {
  border-radius: 12px;
}

/* ---------------- Employee theme tokens ---------------- */
[data-mode="employee"] {
  --bg: #FAF6EC;
  --surface: #FFFFFF;
  --surface-2: #F3EEDD;
  --ink: #2B2B22;
  --muted: #6F7A64;
  --line: #E6DEC4;
  --accent: #2F5233;        /* forest green */
  --accent-ink: #2F5233;
  --accent-contrast: #FFFFFF;
  --accent2: #C98A2E;        /* warm gold CTA */
  --focus: #2F6FED;
  --body-font: var(--font-employee);
  --display-font: var(--font-employee);
}
@media (prefers-color-scheme: dark) {
  [data-mode="employee"]:not([data-theme="light"]) {
    --bg: #16201A; --surface: #1C2A20; --surface-2: #223026;
    --ink: #EFEADB; --muted: #A9B6A0; --line: #33422F;
    --accent: #7BAE7F; --accent2: #E0A64F; --accent-contrast: #12160F;
  }
}
[data-mode="employee"][data-theme="dark"] {
  --bg: #16201A; --surface: #1C2A20; --surface-2: #223026;
  --ink: #EFEADB; --muted: #A9B6A0; --line: #33422F;
  --accent: #7BAE7F; --accent2: #E0A64F; --accent-contrast: #12160F;
}

a { color: inherit; }
button { font-family: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ---------------- App shell ---------------- */
#app { min-height: 100%; height: 100%; display: flex; flex-direction: column; }

.topbar {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-3) var(--space-5);
  padding-top: calc(var(--space-3) + env(safe-area-inset-top, 0px));
  background: var(--accent-ink);
  color: var(--accent-contrast);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
}
[data-mode="employee"] .topbar { background: var(--accent); }
.brand { display: flex; align-items: center; gap: var(--space-2); font-family: var(--display-font); }
.brand-logo { height: 26px; width: auto; display: block; }
.brand-mark { font-weight: 700; font-size: 1.15rem; letter-spacing: .01em; }
.brand-sub { font-size: .78rem; opacity: .78; font-family: var(--body-font); }
.demo-badge {
  font-size: .72rem; padding: 3px 10px; border-radius: 999px;
  background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
  white-space: nowrap;
}
.topbar-spacer { flex: 1; }
.view-switcher { display: flex; align-items: center; gap: var(--space-2); font-size: .85rem; }
.view-switcher select {
  background: rgba(255,255,255,.12); color: inherit; border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius-sm); padding: 6px 10px; font-size: .85rem;
}
.topbar .icon-btn {
  background: transparent; border: 1px solid rgba(255,255,255,.3); color: inherit;
  border-radius: var(--radius-sm); padding: 6px 12px; cursor: pointer; font-size: .82rem;
}
.topbar .icon-btn:hover { background: rgba(255,255,255,.12); }

.shell { flex: 1; display: flex; min-height: 0; }

/* ---------------- Admin sidebar / layout ---------------- */
.sidebar {
  width: 208px; flex-shrink: 0; background: var(--surface); border-right: 1px solid var(--line);
  padding: var(--space-4) var(--space-2);
  display: flex; flex-direction: column; gap: 2px; overflow-y: auto;
}
.side-link {
  display: flex; align-items: center; gap: var(--space-2); padding: 9px 12px; border-radius: var(--radius-sm);
  color: var(--ink); text-decoration: none; font-size: .89rem; cursor: pointer; border: none; background: none;
  width: 100%; text-align: left;
}
.side-link:hover { background: var(--surface-2); }
.side-link.active { background: var(--accent-ink); color: #fff; }
[data-mode="admin"] .side-link.active { background: var(--accent-ink); }
.side-link .count { margin-left: auto; font-size: .72rem; color: var(--muted); }
.side-link.active .count { color: rgba(255,255,255,.75); }

.main {
  flex: 1; overflow-y: auto; padding: var(--space-5);
}
.main-narrow-note { display:none; }

h1, h2, h3 { font-family: var(--display-font); margin: 0 0 var(--space-2); }
h1 { font-size: 1.5rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p { line-height: 1.5; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }

.panel-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-4); margin-bottom: var(--space-4); flex-wrap: wrap; }

/* ---------------- Filter bar ---------------- */
.filterbar {
  display: flex; align-items: center; gap: var(--space-3); flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); margin-bottom: var(--space-5);
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label { font-size: .72rem; color: var(--muted); }
.field select, .field input[type="date"], .field input[type="text"], .field input[type="search"] {
  border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 10px; font-size: .87rem;
  background: var(--surface); color: var(--ink); font-family: inherit;
}
.filterbar .preview-flag { margin-left: auto; font-size: .78rem; color: var(--muted); font-style: italic; }

/* ---------------- Cards / summary ---------------- */
.card-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: var(--space-3); margin-bottom: var(--space-5); }
.metric-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-4); position: relative;
}
.metric-card.clickable { cursor: pointer; transition: border-color .12s ease, transform .06s ease; }
.metric-card.clickable:hover { border-color: var(--accent-ink); }
[data-mode="employee"] .metric-card.clickable:hover { border-color: var(--accent); }
.metric-card.clickable:active { transform: scale(0.98); }
.metric-card .num { font-family: var(--display-font); font-size: 1.7rem; font-weight: 600; line-height: 1; }
.metric-card .label { font-size: .78rem; color: var(--muted); margin-top: 6px; display:flex; align-items:center; gap:5px; }
.metric-card .hint-dot {
  width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); color: var(--muted);
  font-size: .62rem; display: inline-flex; align-items: center; justify-content: center; cursor: help; flex-shrink:0;
}

.charts-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: var(--space-4); margin-bottom: var(--space-5); }
.chart-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); }
.bar-row { display: flex; align-items: center; gap: var(--space-2); margin: 6px 0; font-size: .8rem; }
.bar-label { width: 118px; flex-shrink: 0; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; background: var(--surface-2); border-radius: 4px; height: 14px; overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; }
.bar-value { width: 30px; text-align: right; font-variant-numeric: tabular-nums; }

/* ---------------- Tables ---------------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }

/* ---------------- Leads: list pane + persistent detail pane ---------------- */
.leads-split { display: flex; gap: var(--space-4); align-items: flex-start; height: calc(100vh - 260px); min-height: 420px; }
.leads-list-pane { width: 380px; flex-shrink: 0; display: flex; flex-direction: column; height: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; }
.leads-list-scroll { flex: 1; overflow-y: auto; }
.leads-detail-pane { flex: 1; min-width: 0; height: 100%; overflow-y: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-5); }
.lead-row { display: flex; align-items: flex-start; gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.lead-row:hover { background: var(--surface-2); }
.lead-row.selected { background: var(--surface-2); border-left: 3px solid var(--accent-ink); padding-left: 11px; }
.lead-row-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); border: 1px solid var(--line); flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: .74rem; font-weight: 600; color: var(--muted); }
.lead-row-body { flex: 1; min-width: 0; }
.lead-row-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.lead-row-name { font-weight: 600; font-size: .87rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-row-meta { font-size: .74rem; color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lead-row-date { font-size: .7rem; color: var(--muted); margin-top: 3px; }
.leads-detail-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; height: 100%; color: var(--muted); text-align: center; }

/* ---------------- Reassign tab ---------------- */
.reassign-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); cursor: pointer; }
.reassign-row:hover { background: var(--surface-2); }
.reassign-row input[type="checkbox"] { width: 17px; height: 17px; flex-shrink: 0; }
.reassign-current-owner { text-align: right; flex-shrink: 0; font-size: .82rem; }
.reassign-bar {
  position: sticky; bottom: 0; margin-top: var(--space-3);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4); box-shadow: 0 -4px 16px rgba(0,0,0,.06);
}
.reassign-bar select { max-width: 220px; }
.table-scroll { overflow-x: auto; }
table.leads-table { border-collapse: collapse; width: 100%; font-size: .83rem; min-width: 980px; }
table.leads-table th {
  text-align: left; font-weight: 600; padding: 10px 12px; border-bottom: 1px solid var(--line);
  color: var(--muted); font-size: .74rem; text-transform: none; cursor: pointer; white-space: nowrap;
  background: var(--surface-2); position: sticky; top: 0;
}
table.leads-table th.sorted::after { content: attr(data-arrow); margin-left: 4px; }
table.leads-table td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.leads-table tbody tr { cursor: pointer; }
table.leads-table tbody tr:hover { background: var(--surface-2); }
table.leads-table td.num, table.leads-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.mono-id { font-variant-numeric: tabular-nums; color: var(--muted); font-size: .78rem; }

.status-chip {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 9px; border-radius: 999px;
  font-size: .74rem; color: #fff; white-space: nowrap;
}
.dup-flag { color: var(--status-invalid); font-size: .72rem; margin-left: 6px; }

.table-toolbar { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-3) var(--space-4); flex-wrap: wrap; border-bottom: 1px solid var(--line); }
.chip-filter {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; font-size: .78rem;
  cursor: pointer; color: var(--muted);
}
.chip-filter.active { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
[data-mode="employee"] .chip-filter.active { background: var(--accent); }

.pagination { display: flex; align-items: center; gap: var(--space-2); padding: var(--space-3) var(--space-4); font-size: .82rem; color: var(--muted); }
.pagination button {
  border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm); padding: 4px 10px; cursor: pointer; color: var(--ink);
}
.pagination button:disabled { opacity: .4; cursor: not-allowed; }

/* ---------------- Buttons ---------------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px; border-radius: var(--radius-sm); border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); padding: 8px 14px; font-size: .85rem; cursor: pointer;
}
.btn:hover { background: var(--surface-2); }
.btn-primary { background: var(--accent-ink); color: #fff; border-color: var(--accent-ink); }
[data-mode="employee"] .btn-primary { background: var(--accent2); border-color: var(--accent2); color: #2B2100; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-danger { background: var(--status-invalid); color: #fff; border-color: var(--status-invalid); }
.btn-sm { padding: 5px 10px; font-size: .78rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ---------------- Modal / drawer ---------------- */
.overlay {
  position: fixed; inset: 0; background: rgba(10,12,16,.42); z-index: 40;
  display: flex; justify-content: flex-end;
}
.overlay.centered { justify-content: center; align-items: center; }
.drawer {
  background: var(--bg); width: min(560px, 100%); height: 100%; overflow-y: auto;
  padding: var(--space-5); padding-top: calc(var(--space-5) + env(safe-area-inset-top,0px));
  box-shadow: -8px 0 24px rgba(0,0,0,.12);
}
.modal-box {
  background: var(--bg); width: min(640px, 92vw); max-height: 88vh; overflow-y: auto; border-radius: var(--radius-lg); padding: var(--space-5);
}
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--space-4); gap: var(--space-3); }
.close-x { background: none; border: none; font-size: 1.3rem; cursor: pointer; color: var(--muted); line-height: 1; }

.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--space-3); margin-bottom: var(--space-4); }
.detail-grid .full { grid-column: 1 / -1; }
.detail-item label { display:block; font-size: .72rem; color: var(--muted); margin-bottom: 3px; }
.detail-item input, .detail-item select, .detail-item textarea {
  width: 100%; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 7px 9px; font-size: .85rem;
  background: var(--surface); color: var(--ink); font-family: inherit;
}
.detail-item textarea { min-height: 56px; resize: vertical; }
.detail-item.locked input, .detail-item.locked select { background: var(--surface-2); color: var(--muted); }
.lock-note { font-size: .68rem; color: var(--muted); margin-top: 2px; }

.section-divider { border: none; border-top: 1px solid var(--line); margin: var(--space-5) 0; }
.history-item { font-size: .8rem; padding: 8px 0; border-bottom: 1px dashed var(--line); }
.history-item:last-child { border-bottom: none; }

.badge-soft { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .7rem; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.badge-resale { background: #EFE6F6; color: #6B3FA0; border-color: #DDCBEF; }
[data-mode="admin"]:not([data-theme="light"]) .badge-resale { background: #2A2140; color: #C9AEEB; border-color: #402F5C; }

.empty-state { text-align: center; padding: var(--space-7) var(--space-4); color: var(--muted); }
.empty-state .glyph { font-size: 2rem; margin-bottom: var(--space-2); }

.toast-stack { position: fixed; bottom: 20px; right: 20px; z-index: 60; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--accent-ink); color: #fff; padding: 10px 16px; border-radius: var(--radius-sm); font-size: .85rem; box-shadow: 0 6px 18px rgba(0,0,0,.2); animation: toastin .18s ease; }
[data-mode="employee"] .toast { background: var(--accent); }
@keyframes toastin { from { opacity:0; transform: translateY(6px);} to {opacity:1; transform:none;} }

/* ---------------- Connector cards ---------------- */
.connector-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px,1fr)); gap: var(--space-4); }
.connector-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); padding: var(--space-4); }
.connector-card h3 { display: flex; align-items: center; gap: 8px; }
.connector-status { font-size: .7rem; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.connector-need { font-size: .8rem; margin: 3px 0; padding-left: 16px; position: relative; color: var(--muted); }
.connector-need::before { content: "–"; position: absolute; left: 0; }

/* ---------------- Import wizard ---------------- */
.stepper-track { display: flex; gap: var(--space-2); margin-bottom: var(--space-4); }
.stepper-track div { flex:1; height: 4px; border-radius: 2px; background: var(--line); }
.stepper-track div.done { background: var(--accent-ink); }
[data-mode="employee"] .stepper-track div.done { background: var(--accent); }
.dropzone { border: 1.5px dashed var(--line); border-radius: var(--radius-md); padding: var(--space-6); text-align: center; color: var(--muted); }
.map-row { display: grid; grid-template-columns: 140px 1fr; gap: var(--space-3); align-items: center; margin-bottom: var(--space-2); font-size: .85rem; }

/* ---------------- Employee (mobile-first) ---------------- */
[data-mode="employee"] .shell { flex-direction: column; }
[data-mode="employee"] .main { padding: var(--space-4); padding-bottom: calc(70px + env(safe-area-inset-bottom,0px)); }
.emp-hello { font-family: var(--display-font); font-size: 1.3rem; font-weight: 700; margin-bottom: 2px; }
.emp-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px,1fr)); gap: var(--space-3); margin: var(--space-4) 0; }
.emp-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg); padding: var(--space-4); text-align: center; }
.emp-card.clickable { cursor: pointer; transition: border-color .12s ease, transform .06s ease; }
.emp-card.clickable:hover { border-color: var(--accent); }
.emp-card.clickable:active { transform: scale(0.98); }
.emp-card .num { font-size: 1.6rem; font-weight: 700; color: var(--accent); font-family: var(--display-font); }
.emp-card .label { font-size: .78rem; color: var(--muted); margin-top: 2px; }

.lead-tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-lg);
  padding: var(--space-4); margin-bottom: var(--space-3); display: flex; flex-direction: column; gap: 8px;
}
.lead-tile-top { display: flex; justify-content: space-between; align-items: flex-start; gap: var(--space-2); }
.lead-tile-name { font-weight: 700; font-size: 1rem; }
.lead-tile-meta { font-size: .78rem; color: var(--muted); }
.lead-tile-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.tile-btn {
  border: 1px solid var(--line); background: var(--surface-2); border-radius: 999px; padding: 7px 13px; font-size: .8rem; cursor: pointer; color: var(--ink);
  display:flex; align-items:center; gap:5px;
}
.tile-btn.call { background: var(--accent); color: #fff; border-color: var(--accent); }
.tile-btn.primary { background: var(--accent2); color: #2B2100; border-color: var(--accent2); }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; background: var(--surface); border-top: 1px solid var(--line);
  display: flex; z-index: 30; padding-bottom: env(safe-area-inset-bottom, 0px);
}
.bottom-nav button {
  flex: 1; background: none; border: none; padding: 10px 4px 8px; font-size: .68rem; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; gap: 3px; cursor: pointer; font-family: inherit;
}
.bottom-nav button .glyph { font-size: 1.15rem; }
.bottom-nav button.active { color: var(--accent); }

.preview-banner {
  background: rgba(255,255,255,.16); border: 1px dashed rgba(255,255,255,.5); color: inherit;
  font-size: .76rem; padding: 6px 12px; border-radius: var(--radius-sm); margin: 0 0 var(--space-4);
}
[data-mode="admin"] .preview-banner { background: var(--warn-bg); border-color: var(--warn-border); color: var(--warn-text); }
[data-mode="employee"] .preview-banner { background: #EAF3E2; border-color: #C7DDB4; color: #33502C; }

/* ---------------- Utility ---------------- */
.flex { display: flex; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.wrap { flex-wrap: wrap; }
.right { margin-left: auto; }
hr.hair { border: none; border-top: 1px solid var(--line); }
.tag-row { display: flex; gap: 6px; flex-wrap: wrap; }
.link-btn { background: none; border: none; color: var(--accent-ink); text-decoration: underline; cursor: pointer; padding: 0; font-size: .85rem; }
[data-mode="employee"] .link-btn { color: var(--accent); }

@media (max-width: 880px) {
  .sidebar { display: none; }
  .detail-grid { grid-template-columns: 1fr; }
  table.leads-table { font-size: .8rem; }
  .drawer { width: 100%; }
}

@media (max-width: 560px) {
  .topbar { flex-wrap: wrap; row-gap: 8px; padding: 10px 14px; padding-top: calc(10px + env(safe-area-inset-top, 0px)); }
  .brand-sub { display: none; }
  .topbar-spacer { display: none; }
  .demo-badge { font-size: .68rem; padding: 2px 8px; }
  .view-switcher { order: 3; flex-basis: 100%; }
  .view-switcher label { display: none; }
  .view-switcher select { flex: 1; }
  .topbar #theme-toggle { margin-left: auto; order: 2; }
  .brand { order: 1; }
  .demo-badge { order: 1; }
}

/* ---------------- Properties ---------------- */
.prop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: var(--space-4); }
.prop-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius-md); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.prop-card:hover { border-color: var(--accent); }
.prop-photo { position: relative; aspect-ratio: 4 / 3; background: var(--surface-2); }
.prop-photo img { width: 100%; height: 100%; object-fit: cover; display: block; }
.prop-nophoto { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: var(--muted); font-size: .8rem; }
.prop-tag, .prop-status, .prop-count { position: absolute; font-size: .68rem; font-weight: 600; padding: 3px 8px; border-radius: 10px; color: #fff; }
.prop-tag { top: 8px; left: 8px; background: rgba(0,0,0,.62); }
.prop-status { top: 8px; right: 8px; }
.prop-count { bottom: 8px; right: 8px; background: rgba(0,0,0,.62); font-weight: 500; }
.prop-body { padding: 10px 12px 12px; }
.prop-price { font-weight: 700; font-size: 1.05rem; }
.prop-title { font-size: .88rem; margin-top: 2px; }
.prop-meta { font-size: .76rem; color: var(--muted); margin-top: 2px; }
.prop-gallery-main { aspect-ratio: 4 / 3; background: var(--surface-2); border-radius: var(--radius-md); overflow: hidden; display: flex; align-items: center; justify-content: center; color: var(--muted); }
.prop-gallery-main img { width: 100%; height: 100%; object-fit: contain; display: block; background: #000; }
.prop-thumbs { display: flex; gap: 6px; margin-top: 8px; overflow-x: auto; }
.prop-thumbs img { width: 64px; height: 48px; object-fit: cover; border-radius: 6px; border: 2px solid transparent; cursor: pointer; flex-shrink: 0; }
.prop-thumbs img.active { border-color: var(--accent); }
.prop-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin: 14px 0; font-size: .86rem; }
.prop-detail-grid .k { color: var(--muted); font-size: .72rem; }
.prop-form-photos { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 8px; }
.prop-form-photos .thumb { position: relative; width: 72px; height: 54px; }
.prop-form-photos .thumb img { width: 100%; height: 100%; object-fit: cover; border-radius: 6px; }
.prop-form-photos .thumb button { position: absolute; top: -7px; right: -7px; width: 20px; height: 20px; border-radius: 50%; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; line-height: 1; padding: 0; }
.prop-form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------------- Properties: approval workflow ---------------- */
.prop-flag { position: absolute; bottom: 8px; left: 8px; font-size: .68rem; font-weight: 600; padding: 3px 8px; border-radius: 10px; color: #fff; }
.prop-flag-wait { background: #C9821A; }
.prop-flag-rej { background: #A14B42; }
.prop-review-banner { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; background: #FFF3D6; border: 1px solid #F0C36D; color: #7A5300; border-radius: var(--radius-md); padding: 10px 14px; margin-bottom: var(--space-4); font-size: .88rem; }
.prop-note { border-radius: var(--radius-md); padding: 10px 12px; margin-bottom: 12px; font-size: .84rem; line-height: 1.4; }
.prop-note-wait { background: #FFF3D6; border: 1px solid #F0C36D; color: #7A5300; }
.prop-note-rej { background: #F8E4E1; border: 1px solid #E3B3AD; color: #7A2A22; }
.prop-diffs { margin-top: 8px; display: grid; gap: 4px; }
.prop-diff { display: flex; justify-content: space-between; gap: 12px; background: rgba(255,255,255,.55); border-radius: 6px; padding: 5px 8px; }
.prop-diff .k { color: #7A5300; font-size: .72rem; }
.prop-hidden { color: var(--muted); font-size: .84rem; }
.pa-row { display: flex; align-items: center; gap: 10px; padding: 9px 2px; border-bottom: 1px solid var(--line); cursor: pointer; }
.pa-row input { width: 18px; height: 18px; }
.pa-row .small { margin-left: auto; }
