/* =========================================================
   EstateVault CRM — design system
   Font: Lexend Deca · Light & dark themes · App-like mobile
   ========================================================= */
:root {
  --font: 'Lexend Deca', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --brand: #2563eb;
  --brand-ink: #1d4ed8;
  --brand-soft: #eaf1fe;
  --brand-ring: rgba(37, 99, 235, .16);
  --navy: #0f2747;
  --navy-2: #173a66;
  --wa: #25d366;
  --wa-dark: #128c7e;
  --bg: #f4f6fb;
  --surface: #ffffff;
  --surface-2: #f7f8fc;
  --surface-3: #eef1f8;
  --text: #0f172a;
  --text-2: #334155;
  --muted: #64748b;
  --border: #e6e9f2;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 10px 30px -12px rgba(30, 41, 99, .18);
  --radius: 18px;
  --sidebar-w: 264px;
  --topbar-h: 68px;
  --bottom-h: 68px;
  --chat-bg: #f0f2f5;
  --msg-out: #dcf3e4;
  --msg-in: #ffffff;
}

[data-theme="dark"] {
  --brand: #3b82f6;
  --brand-ink: #60a5fa;
  --brand-soft: rgba(59, 130, 246, .16);
  --navy: #13284a;
  --navy-2: #1b3560;
  --bg: #0b1020;
  --surface: #121933;
  --surface-2: #161f3d;
  --surface-3: #1c2648;
  --text: #e8ecf6;
  --text-2: #cbd5e1;
  --muted: #94a3b8;
  --border: #222c4f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
  --shadow: 0 10px 30px -12px rgba(0, 0, 0, .6);
  --chat-bg: #0e1528;
  --msg-out: #134e3a;
  --msg-in: #1c2648;
}

* { -webkit-tap-highlight-color: transparent; }
html, body { font-family: var(--font); }
body {
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  letter-spacing: -.005em;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: none;
}
a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-ink); }
h1, h2, h3, h4, h5, h6 { font-weight: 600; letter-spacing: -.02em; color: var(--text); }
.text-muted, .muted { color: var(--muted) !important; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.small-2 { font-size: 12px; }
.min-w-0 { min-width: 0; }
.text-truncate-2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
::selection { background: rgba(37, 99, 235, .18); }

/* ---------- Layout ---------- */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w);
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 1045;
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
}
.sidebar-brand { display: flex; align-items: center; gap: 12px; padding: 20px 20px 14px; }
.brand-logo {
  width: 42px; height: 42px; border-radius: 13px; background: var(--brand);
  display: grid; place-items: center; color: #fff; font-size: 20px; flex-shrink: 0; overflow: hidden;
}
.brand-logo img { width: 100%; height: 100%; object-fit: cover; }
.brand-name { font-weight: 600; font-size: 16px; line-height: 1.15; color: var(--text); }
.brand-sub { font-size: 11.5px; color: var(--muted); }
.sidebar-nav { flex: 1; overflow-y: auto; padding: 8px 14px 16px; scrollbar-width: thin; }
.nav-section { font-size: 10.5px; text-transform: uppercase; letter-spacing: .09em; color: var(--muted); padding: 16px 12px 6px; font-weight: 500; }
.nav-item-x {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin: 2px 0;
  border-radius: 12px; color: var(--text-2); font-weight: 400; position: relative; transition: background .15s, color .15s;
}
.nav-item-x i { font-size: 18px; width: 22px; text-align: center; color: var(--muted); transition: color .15s; }
.nav-item-x:hover { background: var(--surface-2); color: var(--text); }
.nav-item-x.active { background: var(--brand-soft); color: var(--brand); font-weight: 500; }
.nav-item-x.active i { color: var(--brand); }
.nav-item-x.active::before { content: ""; position: absolute; left: -14px; top: 9px; bottom: 9px; width: 4px; border-radius: 0 4px 4px 0; background: var(--brand); }
.nav-badge { margin-left: auto; min-width: 22px; height: 20px; padding: 0 7px; border-radius: 999px; background: #ef4444; color: #fff; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.nav-badge.soft { background: var(--surface-3); color: var(--text-2); }
.sidebar-foot { padding: 14px; border-top: 1px solid var(--border); }
.upgrade-card { background: var(--navy); color: #fff; border-radius: 16px; padding: 14px 16px; font-size: 13px; position: relative; overflow: hidden; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; min-width: 0; }
.topbar {
  position: sticky; top: 0; z-index: 1030; height: var(--topbar-h);
  display: flex; align-items: center; gap: 12px; padding: 0 28px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(180%) blur(14px); -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid transparent;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.topbar-title { font-weight: 600; font-size: 17px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-search { position: relative; flex: 1; max-width: 440px; margin-left: 12px; }
.top-search input { padding-left: 42px; background: var(--surface); height: 42px; border-radius: 13px; }
.top-search i { position: absolute; left: 15px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.top-search kbd { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); background: var(--surface-3); color: var(--muted); font-size: 11px; border-radius: 6px; padding: 2px 6px; font-family: var(--font); }
.top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn {
  width: 42px; height: 42px; border-radius: 13px; display: inline-grid; place-items: center;
  background: var(--surface); border: 1px solid var(--border); color: var(--text-2); font-size: 18px; position: relative;
  transition: all .15s;
}
.icon-btn:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 35%, var(--border)); }
.icon-btn .dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: #ef4444; border: 2px solid var(--surface); }
.user-chip { display: flex; align-items: center; gap: 10px; padding: 4px 10px 4px 4px; border-radius: 14px; background: var(--surface); border: 1px solid var(--border); color: var(--text); }
.user-chip .avatar { width: 34px; height: 34px; border-radius: 10px; font-size: 13px; }
.content { padding: 10px 28px 40px; max-width: 1600px; }
.impersonation-bar { background: #fef3c7; color: #92400e; padding: 8px 28px; font-size: 13px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
[data-theme="dark"] .impersonation-bar { background: #3b2f0b; color: #fcd34d; }

.sidebar-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .45); z-index: 1040; opacity: 0; visibility: hidden; transition: opacity .25s; backdrop-filter: blur(2px); }

/* Bottom navigation (mobile app style) */
.bottom-nav {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1035;
  height: calc(var(--bottom-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border); justify-content: space-around; align-items: center;
}
.bottom-nav a, .bottom-nav button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; font-size: 10.5px;
  color: var(--muted); background: none; border: 0; position: relative; padding: 6px 0;
}
.bottom-nav i { font-size: 21px; line-height: 1; }
.bottom-nav .active { color: var(--brand); font-weight: 500; }
.bottom-nav .bn-badge { position: absolute; top: 0; left: 50%; margin-left: 6px; background: #ef4444; color: #fff; font-size: 10px; min-width: 18px; height: 18px; border-radius: 9px; display: grid; place-items: center; padding: 0 5px; font-weight: 600; }
.bottom-nav .bn-fab { flex: 0 0 auto; width: 54px; height: 54px; border-radius: 18px; background: var(--brand); color: #fff; margin-top: -26px; justify-content: center; box-shadow: 0 6px 14px -6px rgba(15, 39, 71, .45); }
.bottom-nav .bn-fab i { font-size: 24px; }

@media (max-width: 991.98px) {
  .sidebar { transform: translateX(-100%); box-shadow: none; }
  body.sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  body.sidebar-open .sidebar-backdrop { opacity: 1; visibility: visible; }
  .main { margin-left: 0; }
  .topbar { padding: 0 16px; height: 60px; }
  .content { padding: 6px 16px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; }
  .top-search { display: none; }
  .impersonation-bar { padding: 8px 16px; }
}
@media (min-width: 992px) { .d-mobile { display: none !important; } }
@media (max-width: 991.98px) { .d-desktop { display: none !important; } }

/* ---------- Page header ---------- */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; margin: 6px 0 20px; }
.page-head h1 { font-size: 24px; margin: 0; }
.page-sub { color: var(--muted); font-size: 13.5px; margin-top: 2px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.breadcrumb-x { font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb-x a { color: var(--muted); }
.breadcrumb-x a:hover { color: var(--brand); }
@media (max-width: 575.98px) {
  .page-head h1 { font-size: 20px; }
  .page-actions .btn-label { display: none; }
}

/* ---------- Cards ---------- */
.card-x { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card-x-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.card-x-head h2, .card-x-head h3, .card-x-head .h6 { font-size: 15.5px; margin: 0; font-weight: 600; }
.card-x-body { padding: 20px; }
.card-x-foot { padding: 14px 20px; border-top: 1px solid var(--border); }
.card-link { display: block; color: inherit; transition: transform .15s, box-shadow .15s, border-color .15s; }
.card-link:hover { color: inherit; transform: translateY(-2px); box-shadow: var(--shadow); border-color: color-mix(in srgb, var(--brand) 25%, var(--border)); }

/* Stat tiles */
.stat { padding: 18px 18px; display: flex; align-items: center; gap: 14px; height: 100%; }
.stat-icon { width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center; font-size: 22px; flex-shrink: 0; }
.stat-value { font-size: 23px; font-weight: 600; line-height: 1.15; letter-spacing: -.03em; }
.stat-label { color: var(--muted); font-size: 12.5px; margin-bottom: 2px; }
.stat-trend { font-size: 11.5px; font-weight: 500; }
.trend-up { color: #059669; }
.trend-down { color: #dc2626; }
.ic-indigo { background: rgba(37, 99, 235, .1); color: #2563eb; }
.ic-violet { background: rgba(139, 92, 246, .14); color: #7c3aed; }
.ic-green { background: rgba(16, 185, 129, .13); color: #059669; }
.ic-amber { background: rgba(245, 158, 11, .15); color: #d97706; }
.ic-rose { background: rgba(244, 63, 94, .12); color: #e11d48; }
.ic-cyan { background: rgba(6, 182, 212, .13); color: #0891b2; }
.ic-blue { background: rgba(59, 130, 246, .13); color: #2563eb; }
.ic-wa { background: rgba(37, 211, 102, .14); color: #16a34a; }
[data-theme="dark"] .ic-indigo { color: #a5b4fc; }
[data-theme="dark"] .ic-violet { color: #c4b5fd; }
[data-theme="dark"] .ic-green { color: #6ee7b7; }
[data-theme="dark"] .ic-amber { color: #fcd34d; }
[data-theme="dark"] .ic-rose { color: #fda4af; }
[data-theme="dark"] .ic-cyan { color: #67e8f9; }
[data-theme="dark"] .ic-blue { color: #93c5fd; }

/* Hero */
.hero {
  background: var(--navy); color: #fff; border-radius: 20px; padding: 26px 28px; position: relative; overflow: hidden;
}
.hero h2 { color: #fff; font-size: 24px; margin-bottom: 4px; }
.hero p { color: rgba(255, 255, 255, .82); margin: 0; }
.hero .hero-actions { position: relative; z-index: 1; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 18px; }
.hero .btn-glass { background: rgba(255, 255, 255, .1); color: #fff; border: 1px solid rgba(255, 255, 255, .22); }
.hero .btn-glass:hover { background: rgba(255, 255, 255, .18); color: #fff; }
.hero-metric { position: relative; z-index: 1; background: var(--navy-2); border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; padding: 12px 16px; min-width: 150px; }
.hero-metric .v { font-size: 22px; font-weight: 600; }
.hero-metric .l { font-size: 12px; color: rgba(255, 255, 255, .72); }
@media (max-width: 575.98px) {
  .hero { padding: 22px 18px; border-radius: 20px; }
  .hero h2 { font-size: 21px; }
  .hero-metric { min-width: 0; flex: 1 1 0; padding: 10px 12px; border-radius: 14px; }
  .hero-metric .v { font-size: 17px; }
  .hero-metric .l { font-size: 10.5px; line-height: 1.25; }
  .stat { flex-direction: column; align-items: flex-start; gap: 10px; padding: 14px; }
  .stat-icon { width: 40px; height: 40px; font-size: 18px; border-radius: 12px; }
  .stat-value { font-size: 20px; }
}

/* ---------- Buttons ---------- */
.btn { font-weight: 500; border-radius: 12px; padding: .56rem 1rem; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; gap: 7px; transition: all .15s; }
.btn-sm { padding: .36rem .75rem; font-size: 13px; border-radius: 10px; }
.btn-lg { padding: .78rem 1.3rem; font-size: 15px; border-radius: 14px; }
.btn-brand { background: var(--brand); color: #fff; border: 0; box-shadow: 0 1px 2px rgba(16, 24, 40, .12); }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-ink); color: #fff; }
.btn-soft { background: var(--surface); color: var(--text-2); border: 1px solid var(--border); }
.btn-soft:hover { background: var(--surface-2); color: var(--text); border-color: color-mix(in srgb, var(--brand) 30%, var(--border)); }
.btn-ghost { background: transparent; border: 0; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-wa { background: #1fa855; color: #fff; border: 0; }
.btn-wa:hover { background: #178f47; color: #fff; }
.btn-danger-soft { background: rgba(239, 68, 68, .1); color: #dc2626; border: 0; }
.btn-danger-soft:hover { background: rgba(239, 68, 68, .18); color: #b91c1c; }
.btn-icon { width: 38px; height: 38px; padding: 0; border-radius: 11px; }
.btn-icon.btn-sm { width: 32px; height: 32px; border-radius: 9px; }

/* ---------- Forms ---------- */
.form-label { font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-control, .form-select {
  border-radius: 12px; border: 1px solid var(--border); background-color: var(--surface); color: var(--text);
  padding: .62rem .9rem; font-size: 14px; font-family: var(--font);
}
.form-select { padding-right: 2.2rem; }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-ring); background-color: var(--surface); color: var(--text); }
.form-control::placeholder { color: #a0aec0; }
.form-control-sm, .form-select-sm { padding: .42rem .75rem; font-size: 13px; border-radius: 10px; }
.input-group-text { background: var(--surface-2); border-color: var(--border); color: var(--muted); border-radius: 12px; }
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-check-input:focus { box-shadow: 0 0 0 4px var(--brand-ring); border-color: var(--brand); }
.form-switch .form-check-input { width: 2.6em; height: 1.4em; }
.form-hint { font-size: 12px; color: var(--muted); margin-top: 5px; }
.text-danger { color: #e11d48 !important; }
.field-validation-error, span.text-danger[data-valmsg-for] { font-size: 12.5px; }
.input-validation-error { border-color: #f43f5e !important; }
.validation-summary-errors ul { margin: 0; padding-left: 18px; }
.validation-summary-valid { display: none !important; }
.form-section { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 600; margin: 8px 0 14px; display: flex; align-items: center; gap: 10px; }
.form-section::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.sticky-actions { position: sticky; bottom: 0; background: color-mix(in srgb, var(--surface) 94%, transparent); backdrop-filter: blur(8px); padding: 14px 20px; border-top: 1px solid var(--border); border-radius: 0 0 var(--radius) var(--radius); display: flex; gap: 10px; justify-content: flex-end; z-index: 5; }
@media (max-width: 991.98px) { .sticky-actions { bottom: calc(var(--bottom-h) + env(safe-area-inset-bottom)); } }
.option-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.option-card input { display: none; }
.option-card label { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 10px; border: 1.5px solid var(--border); border-radius: 14px; cursor: pointer; font-size: 13px; color: var(--text-2); transition: all .15s; text-align: center; }
.option-card label i { font-size: 22px; color: var(--muted); }
.option-card input:checked + label { border-color: var(--brand); background: var(--brand-soft); color: var(--brand); }
.option-card input:checked + label i { color: var(--brand); }

/* ---------- Badges ---------- */
.badge-x { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 11.5px; font-weight: 500; white-space: nowrap; line-height: 1.4; }
.badge-x::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge-x.no-dot::before { display: none; }
.st-blue { background: #e0ebff; color: #1d4ed8; }
.st-cyan { background: #dff7fb; color: #0e7490; }
.st-violet { background: #efe9ff; color: #6d28d9; }
.st-amber { background: #fff3d6; color: #b45309; }
.st-orange { background: #ffeadb; color: #c2410c; }
.st-green { background: #dcfce7; color: #15803d; }
.st-red { background: #ffe4e6; color: #be123c; }
.st-gray { background: var(--surface-3); color: var(--muted); }
[data-theme="dark"] .st-blue { background: rgba(59, 130, 246, .16); color: #93c5fd; }
[data-theme="dark"] .st-cyan { background: rgba(6, 182, 212, .16); color: #67e8f9; }
[data-theme="dark"] .st-violet { background: rgba(139, 92, 246, .18); color: #c4b5fd; }
[data-theme="dark"] .st-amber { background: rgba(245, 158, 11, .16); color: #fcd34d; }
[data-theme="dark"] .st-orange { background: rgba(249, 115, 22, .16); color: #fdba74; }
[data-theme="dark"] .st-green { background: rgba(16, 185, 129, .16); color: #6ee7b7; }
[data-theme="dark"] .st-red { background: rgba(244, 63, 94, .16); color: #fda4af; }
.tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 8px; background: var(--surface-3); color: var(--text-2); font-size: 12px; }

/* ---------- Avatars ---------- */
.avatar { width: 40px; height: 40px; border-radius: 13px; display: inline-grid; place-items: center; font-weight: 600; font-size: 14px; flex-shrink: 0; letter-spacing: 0; }
.avatar-sm { width: 32px; height: 32px; border-radius: 10px; font-size: 12px; }
.avatar-lg { width: 64px; height: 64px; border-radius: 20px; font-size: 22px; }
.av-0 { background: #e0e7ff; color: #4338ca; } .av-1 { background: #fce7f3; color: #be185d; }
.av-2 { background: #dcfce7; color: #15803d; } .av-3 { background: #fef3c7; color: #b45309; }
.av-4 { background: #e0f2fe; color: #0369a1; } .av-5 { background: #ede9fe; color: #6d28d9; }
.av-6 { background: #ffe4e6; color: #be123c; } .av-7 { background: #ccfbf1; color: #0f766e; }
[data-theme="dark"] .avatar[class*="av-"] { background: var(--surface-3); }

/* ---------- Tables (become cards on mobile) ---------- */
.table-x { width: 100%; border-collapse: separate; border-spacing: 0; }
.table-x th { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); font-weight: 500; padding: 12px 16px; background: var(--surface-2); white-space: nowrap; }
.table-x th:first-child { padding-left: 20px; }
.table-x td { padding: 13px 16px; border-top: 1px solid var(--border); vertical-align: middle; color: var(--text-2); }
.table-x td:first-child { padding-left: 20px; }
.table-x tbody tr { transition: background .12s; }
.table-x tbody tr:hover { background: var(--surface-2); }
.table-x tr.row-link { cursor: pointer; }
.cell-main { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-title { font-weight: 500; color: var(--text); }
.cell-sub { font-size: 12.5px; color: var(--muted); }
.td-actions { text-align: right; white-space: nowrap; }
@media (max-width: 767.98px) {
  .table-x thead { display: none; }
  .table-x, .table-x tbody, .table-x tr, .table-x td { display: block; width: 100%; }
  .table-x tr { padding: 14px 16px; border-top: 1px solid var(--border); }
  .table-x tbody tr:first-child { border-top: 0; }
  .table-x td { border: 0; padding: 3px 0 !important; display: flex; justify-content: space-between; align-items: center; gap: 12px; text-align: right; }
  .table-x td[data-label]::before { content: attr(data-label); color: var(--muted); font-size: 12px; text-align: left; flex-shrink: 0; }
  .table-x td.td-main { display: block; text-align: left; padding-bottom: 8px !important; }
  .table-x td.td-actions { justify-content: flex-end; padding-top: 8px !important; }
  .table-x td.td-hide-m { display: none; }
}

/* ---------- Chips / filters ---------- */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text-2); font-size: 13px; white-space: nowrap; transition: all .15s; }
.chip:hover { border-color: var(--brand); color: var(--brand); }
.chip.active { background: var(--text); border-color: var(--text); color: var(--surface); }
.chip .count { background: var(--surface-3); color: var(--muted); border-radius: 999px; padding: 0 7px; font-size: 11px; }
.chip.active .count { background: rgba(255, 255, 255, .2); color: inherit; }
.filter-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.filter-bar .search-input { position: relative; flex: 1 1 240px; }
.filter-bar .search-input i { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.filter-bar .search-input input { padding-left: 38px; }
.filter-bar .form-select { width: auto; flex: 0 1 170px; }
@media (max-width: 575.98px) { .filter-bar .form-select { flex: 1 1 45%; } }
.view-toggle { display: inline-flex; background: var(--surface-3); border-radius: 12px; padding: 3px; }
.view-toggle a { padding: 6px 12px; border-radius: 9px; color: var(--muted); font-size: 13px; display: inline-flex; align-items: center; gap: 6px; }
.view-toggle a.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Pager ---------- */
.pager { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.pager .pages { display: flex; gap: 6px; }
.pager .pages a, .pager .pages span { min-width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; border: 1px solid var(--border); color: var(--text-2); padding: 0 8px; background: var(--surface); }
.pager .pages .current { background: var(--brand); border-color: var(--brand); color: #fff; }
.pager .pages .disabled { opacity: .45; pointer-events: none; }

/* ---------- Progress ---------- */
.progress-x { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-x > span { display: block; height: 100%; border-radius: 999px; background: var(--brand); transition: width .6s ease; }
.progress-x.green > span { background: #16a34a; }

/* ---------- Empty state ---------- */
.empty { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty .empty-icon { width: 84px; height: 84px; border-radius: 26px; display: inline-grid; place-items: center; font-size: 36px; background: var(--brand-soft); color: var(--brand); margin-bottom: 16px; }
.empty h3 { font-size: 17px; margin-bottom: 6px; color: var(--text); }
.empty p { max-width: 380px; margin: 0 auto 18px; font-size: 13.5px; }

/* ---------- Lists ---------- */
.list-x { list-style: none; margin: 0; padding: 0; }
.list-x > li { display: flex; align-items: center; gap: 12px; padding: 12px 20px; border-top: 1px solid var(--border); }
.list-x > li:first-child { border-top: 0; }
.list-x > li > a.stretched { color: inherit; }
.kv { display: grid; grid-template-columns: 140px 1fr; gap: 10px 16px; font-size: 13.5px; }
.kv dt { color: var(--muted); font-weight: 400; }
.kv dd { margin: 0; color: var(--text); font-weight: 500; word-break: break-word; }
@media (max-width: 575.98px) { .kv { grid-template-columns: 110px 1fr; } }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding: 4px 0 0 0; margin: 0; list-style: none; }
.timeline li { position: relative; padding: 0 0 20px 46px; }
.timeline li::before { content: ""; position: absolute; left: 17px; top: 36px; bottom: 0; width: 2px; background: var(--border); }
.timeline li:last-child::before { display: none; }
.timeline .tl-icon { position: absolute; left: 0; top: 0; width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; font-size: 15px; }
.timeline .tl-text { color: var(--text); white-space: pre-line; }
.timeline .tl-meta { font-size: 12px; color: var(--muted); margin-top: 3px; }

/* ---------- Kanban ---------- */
.kanban { display: flex; gap: 14px; overflow-x: auto; padding: 2px 2px 14px; scroll-snap-type: x proximity; }
.kanban-col { flex: 0 0 292px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 18px; display: flex; flex-direction: column; max-height: calc(100vh - 230px); scroll-snap-align: start; }
.kanban-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 10px; font-weight: 600; font-size: 14px; }
.kanban-head .count { background: var(--surface); border: 1px solid var(--border); border-radius: 999px; font-size: 12px; padding: 1px 9px; color: var(--muted); font-weight: 500; }
.kanban-head .bar { height: 3px; border-radius: 3px; margin: 0 16px; }
.kanban-list { flex: 1; overflow-y: auto; padding: 8px 10px 12px; display: flex; flex-direction: column; gap: 10px; min-height: 120px; border-radius: 0 0 18px 18px; transition: background .15s; }
.kanban-list.drag-over { background: var(--brand-soft); outline: 2px dashed color-mix(in srgb, var(--brand) 50%, transparent); outline-offset: -6px; }
.kanban-card { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; padding: 12px 13px; cursor: grab; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.kanban-card:hover { box-shadow: var(--shadow); }
.kanban-card.dragging { opacity: .45; transform: rotate(2deg); }
.kanban-card .kc-name { font-weight: 500; color: var(--text); }
.kanban-card .kc-meta { font-size: 12px; color: var(--muted); display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 6px; }
@media (max-width: 767.98px) { .kanban-col { flex-basis: 84vw; max-height: calc(100dvh - 260px); } }

/* ---------- Property cards ---------- */
.prop-card { overflow: hidden; display: flex; flex-direction: column; height: 100%; }
.prop-media { position: relative; aspect-ratio: 16 / 10; overflow: hidden; background: var(--surface-3); }
.prop-media img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; }
.prop-card:hover .prop-media img { transform: scale(1.04); }
.prop-ph { width: 100%; height: 100%; display: grid; place-items: center; font-size: 52px; }
.ph-0 { background: #e8eefc; color: #2563eb; } .ph-1 { background: #e7f5ee; color: #15803d; }
.ph-2 { background: #fdf3e3; color: #b45309; } .ph-3 { background: #eef2f7; color: #334155; }
.ph-4 { background: #e6f4f8; color: #0e7490; } .ph-5 { background: #f1eefb; color: #5b21b6; }
.ph-6 { background: #fcecee; color: #be123c; } .ph-7 { background: #e9f2fb; color: #0f2747; }
[data-theme="dark"] .prop-ph[class*="ph-"] { background: var(--surface-3); }
.prop-tags { position: absolute; top: 12px; left: 12px; right: 12px; display: flex; gap: 6px; flex-wrap: wrap; }
.prop-tags .badge-x { background: rgba(255, 255, 255, .92); backdrop-filter: blur(6px); }
[data-theme="dark"] .prop-tags .badge-x { background: rgba(18, 25, 51, .85); }
.prop-feat { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; border-radius: 10px; background: rgba(255, 255, 255, .92); display: grid; place-items: center; color: #f59e0b; }
.prop-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.prop-price { font-size: 19px; font-weight: 600; color: var(--text); letter-spacing: -.02em; }
.prop-title { font-weight: 500; color: var(--text); margin: 4px 0 2px; }
.prop-loc { font-size: 12.5px; color: var(--muted); }
.prop-specs { display: flex; gap: 14px; margin-top: auto; padding-top: 12px; border-top: 1px dashed var(--border); font-size: 12.5px; color: var(--text-2); flex-wrap: wrap; }
.prop-specs i { color: var(--muted); margin-right: 3px; }
.prop-hero { border-radius: var(--radius); overflow: hidden; aspect-ratio: 16 / 7; position: relative; }
.prop-hero img { width: 100%; height: 100%; object-fit: cover; }
@media (max-width: 767.98px) { .prop-hero { aspect-ratio: 4 / 3; } }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.spec { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; }
.spec .l { font-size: 12px; color: var(--muted); }
.spec .v { font-weight: 500; color: var(--text); margin-top: 2px; }

/* ---------- Payment schedule ---------- */
.schedule-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-top: 1px solid var(--border); }
.schedule-row:first-child { border-top: 0; }
.sched-dot { width: 40px; height: 40px; border-radius: 13px; display: grid; place-items: center; font-size: 17px; flex-shrink: 0; }
@media (max-width: 575.98px) { .schedule-row { flex-wrap: wrap; } .schedule-row .sched-actions { width: 100%; justify-content: flex-end; } }

/* ---------- Chat ---------- */
.chat-shell { display: grid; grid-template-columns: 350px 1fr; height: calc(100vh - var(--topbar-h) - 40px); min-height: 520px; overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list-head { padding: 16px; border-bottom: 1px solid var(--border); }
.chat-contacts { overflow-y: auto; flex: 1; }
.chat-contact { display: flex; gap: 12px; align-items: center; padding: 12px 16px; color: inherit; border-bottom: 1px solid var(--border); transition: background .12s; }
.chat-contact:hover { background: var(--surface-2); color: inherit; }
.chat-contact.active { background: var(--brand-soft); }
.chat-contact .cc-name { font-weight: 500; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact .cc-last { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-contact .cc-time { font-size: 11px; color: var(--muted); }
.chat-contact .cc-unread { background: var(--wa); color: #fff; font-size: 11px; font-weight: 600; min-width: 20px; height: 20px; border-radius: 10px; display: grid; place-items: center; padding: 0 6px; margin-top: 4px; margin-left: auto; }
.chat-pane { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
.chat-head { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.chat-body {
  flex: 1; overflow-y: auto; padding: 20px 6%; background-color: var(--chat-bg);
}
.msg { max-width: min(76%, 560px); width: fit-content; padding: 8px 12px 6px; border-radius: 14px; margin-bottom: 8px; font-size: 14px; line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; box-shadow: 0 1px 1px rgba(0, 0, 0, .08); position: relative; color: var(--text); }
.msg .msg-meta { white-space: nowrap; }
.chat-shell.with-note { height: calc(100vh - var(--topbar-h) - 40px - 62px); }
.msg.in { background: var(--msg-in); border-top-left-radius: 4px; }
.msg.out { background: var(--msg-out); margin-left: auto; border-top-right-radius: 4px; }
.msg.failed { outline: 1px solid rgba(244, 63, 94, .5); }
.msg-meta { display: flex; justify-content: flex-end; align-items: center; gap: 4px; font-size: 10.5px; color: var(--muted); margin-top: 2px; }
.msg-meta .bi-check2-all.read { color: #34b7f1; }
.msg-meta .bi-exclamation-circle { color: #e11d48; }
.msg-day { text-align: center; margin: 10px 0 14px; }
.msg-day span { background: var(--surface); color: var(--muted); font-size: 11.5px; padding: 4px 12px; border-radius: 8px; box-shadow: var(--shadow-sm); }
.chat-compose { display: flex; gap: 8px; align-items: flex-end; padding: 12px; border-top: 1px solid var(--border); background: var(--surface); }
.chat-compose textarea { resize: none; max-height: 140px; border-radius: 22px; padding: .62rem 1rem; }
.chat-compose .btn-send { width: 44px; height: 44px; border-radius: 50%; padding: 0; flex-shrink: 0; }
.chat-empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--muted); padding: 30px; background: var(--surface-2); }
.window-note { font-size: 12px; background: #fff7e6; color: #92400e; padding: 8px 16px; border-bottom: 1px solid var(--border); }
[data-theme="dark"] .window-note { background: #3b2f0b; color: #fcd34d; }
@media (max-width: 991.98px) {
  .chat-shell { grid-template-columns: 1fr; height: calc(100dvh - 60px - var(--bottom-h) - 24px - env(safe-area-inset-bottom)); border-radius: 16px; }
  .chat-shell.has-active .chat-list { display: none; }
  .chat-shell:not(.has-active) .chat-pane { display: none; }
  .chat-body { padding: 14px 12px; }
  .msg { max-width: 86%; }
}

/* ---------- Login ---------- */
.auth-wrap { min-height: 100vh; display: grid; grid-template-columns: 1.05fr 1fr; background: var(--surface); }
.auth-art { background: var(--navy); color: #fff; padding: 48px 56px; display: flex; flex-direction: column; position: relative; overflow: hidden; }
.auth-art h1 { color: #fff; font-size: 40px; line-height: 1.12; letter-spacing: -.03em; margin: auto 0 16px; position: relative; z-index: 1; max-width: 520px; }
.auth-art p { color: rgba(255, 255, 255, .85); font-size: 16px; max-width: 460px; position: relative; z-index: 1; }
.auth-feats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 30px; position: relative; z-index: 1; max-width: 520px; }
.auth-feat { background: var(--navy-2); border: 1px solid rgba(255, 255, 255, .1); border-radius: 16px; padding: 14px; font-size: 13.5px; }
.auth-feat i { font-size: 20px; display: block; margin-bottom: 6px; }
.auth-form { display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-card { width: 100%; max-width: 410px; }
.auth-card h2 { font-size: 28px; margin-bottom: 6px; }
.pw-toggle { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); }
@media (max-width: 991.98px) {
  .auth-wrap { grid-template-columns: 1fr; }
  .auth-art { padding: 34px 24px 70px; min-height: auto; }
  .auth-art h1 { font-size: 28px; margin-top: 28px; }
  .auth-feats { display: none; }
  .auth-form { margin-top: -44px; padding: 0 16px 32px; align-items: flex-start; }
  .auth-card { background: var(--surface); border-radius: 24px; padding: 28px 22px; box-shadow: var(--shadow); position: relative; z-index: 2; }
}

/* ---------- Misc ---------- */
.dropdown-menu { border-radius: 14px; border: 1px solid var(--border); box-shadow: var(--shadow); padding: 6px; background: var(--surface); font-size: 14px; }
.dropdown-item { border-radius: 9px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; color: var(--text-2); }
.dropdown-item i { color: var(--muted); width: 18px; }
.dropdown-item:hover, .dropdown-item:focus { background: var(--surface-2); color: var(--text); }
.dropdown-divider { border-color: var(--border); }
.modal-content { border-radius: 22px; border: 1px solid var(--border); background: var(--surface); box-shadow: var(--shadow); }
.modal-header, .modal-footer { border-color: var(--border); padding: 16px 22px; }
.modal-body { padding: 20px 22px; }
.modal-title { font-size: 17px; font-weight: 600; }
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-keep) { margin: 0; position: fixed; bottom: 0; left: 0; right: 0; max-width: none; }
  .modal.fade .modal-dialog:not(.modal-keep) { transform: translateY(100%); transition: transform .28s ease-out; }
  .modal.show .modal-dialog:not(.modal-keep) { transform: none; }
  .modal-dialog:not(.modal-keep) .modal-content { border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom); }
}
.toast-container { z-index: 1090; }
.toast-x { background: var(--text); color: var(--surface); border-radius: 14px; padding: 12px 16px; display: flex; align-items: center; gap: 10px; box-shadow: var(--shadow); font-size: 14px; min-width: 260px; max-width: 420px; }
.toast-x i { font-size: 18px; }
.toast-x.success i { color: #34d399; } .toast-x.danger i { color: #fb7185; } .toast-x.warning i { color: #fbbf24; }
.wa-link { color: var(--wa-dark); }
.wa-link:hover { color: var(--wa); }
.divider-dot::before { content: "•"; margin: 0 6px; color: var(--muted); }
.mini-chart { height: 260px; position: relative; }
.legend-dot { width: 9px; height: 9px; border-radius: 3px; display: inline-block; margin-right: 6px; }
.sticky-side { position: sticky; top: calc(var(--topbar-h) + 12px); }
.receipt-sheet { max-width: 780px; margin: 0 auto; }
.placeholder-list { font-size: 12px; }
.placeholder-list code { background: var(--surface-3); color: var(--brand); padding: 2px 7px; border-radius: 6px; cursor: pointer; font-size: 12px; }
.wa-preview { background: var(--chat-bg); border-radius: 16px; padding: 18px; min-height: 140px; }
.wa-preview .msg { max-width: 100%; }
code { color: var(--brand); }
hr { border-color: var(--border); opacity: 1; }
.fade-in { animation: fadeIn .35s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media print {
  .sidebar, .topbar, .bottom-nav, .no-print, .impersonation-bar { display: none !important; }
  .main { margin: 0 !important; }
  .content { padding: 0 !important; }
  body { background: #fff !important; }
  .card-x { box-shadow: none !important; }
}

/* ---------- Property media (gallery, uploads, videos) ---------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.media-tile { position: relative; aspect-ratio: 4 / 3; border-radius: 14px; overflow: hidden; background: var(--surface-3); border: 1px solid var(--border); }
.media-tile img, .media-tile video, .media-tile iframe { width: 100%; height: 100%; object-fit: cover; border: 0; display: block; }
.media-tile.is-removed { opacity: .35; outline: 2px solid #e11d48; outline-offset: -2px; }
.media-remove { position: absolute; top: 8px; right: 8px; width: 30px; height: 30px; border-radius: 9px; background: rgba(255, 255, 255, .95); color: #e11d48; display: grid; place-items: center; cursor: pointer; border: 0; margin: 0; box-shadow: var(--shadow-sm); }
.media-remove input { position: absolute; opacity: 0; pointer-events: none; }
.media-remove:has(input:checked) { background: #e11d48; color: #fff; }
.media-cover { position: absolute; left: 8px; bottom: 8px; margin: 0; cursor: pointer; }
.media-cover input { position: absolute; opacity: 0; pointer-events: none; }
.media-cover span { display: inline-flex; align-items: center; gap: 4px; font-size: 11.5px; font-weight: 500; padding: 3px 9px; border-radius: 8px; background: rgba(255, 255, 255, .92); color: var(--muted); }
.media-cover input:checked + span { background: var(--brand); color: #fff; }
.media-new { position: absolute; left: 8px; bottom: 8px; font-size: 11px; font-weight: 500; padding: 2px 8px; border-radius: 7px; background: var(--brand); color: #fff; }
.upload-drop { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; text-align: center; padding: 22px 16px; border: 1.5px dashed var(--border); border-radius: 16px; background: var(--surface-2); cursor: pointer; transition: border-color .15s, background .15s; margin: 0; }
.upload-drop:hover { border-color: var(--brand); background: var(--brand-soft); }
.upload-drop > i { font-size: 28px; color: var(--brand); }
.gallery-main { position: relative; border-radius: var(--radius); overflow: hidden; background: var(--surface-3); aspect-ratio: 16 / 9; }
.gallery-main img { width: 100%; height: 100%; object-fit: cover; cursor: zoom-in; }
.gallery-main .g-nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255, 255, 255, .92); color: var(--text); display: grid; place-items: center; box-shadow: var(--shadow-sm); }
.gallery-main .g-prev { left: 12px; } .gallery-main .g-next { right: 12px; }
.gallery-main .g-count { position: absolute; right: 12px; bottom: 12px; background: rgba(15, 23, 42, .75); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.gallery-thumbs { display: flex; gap: 8px; overflow-x: auto; padding: 10px 0 2px; scrollbar-width: thin; }
.gallery-thumbs button { flex: 0 0 88px; height: 64px; border-radius: 10px; overflow: hidden; border: 2px solid transparent; padding: 0; background: var(--surface-3); opacity: .7; }
.gallery-thumbs button.active { border-color: var(--brand); opacity: 1; }
.gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; }
.video-frame { border-radius: 14px; overflow: hidden; background: #000; aspect-ratio: 16 / 9; }
.video-frame video, .video-frame iframe { width: 100%; height: 100%; border: 0; display: block; }
.lightbox .modal-content { background: #0b1220; border: 0; border-radius: 0; }
.lightbox img { max-width: 100%; max-height: calc(100vh - 120px); object-fit: contain; }
@media (max-width: 767.98px) { .gallery-main { aspect-ratio: 4 / 3; } .media-grid { grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); } }
.prop-media-count { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 10px; background: rgba(15, 23, 42, .72); color: #fff; font-size: 12px; padding: 4px 10px; border-radius: 8px; }
.media-tile iframe { pointer-events: none; }

/* ---------- Reports ---------- */
.report-tabs { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 6px; }
.report-tabs::-webkit-scrollbar { display: none; }
.report-tab { display: inline-flex; align-items: center; gap: 8px; padding: 10px 16px; border-radius: 11px; color: var(--text-2); font-weight: 500; font-size: 14px; white-space: nowrap; }
.report-tab i { color: var(--muted); font-size: 16px; }
.report-tab:hover { background: var(--surface-2); color: var(--text); }
.report-tab.active { background: var(--brand); color: #fff; }
.report-tab.active i { color: #fff; }
.table-x tfoot .report-total td { font-weight: 600; color: var(--text); background: var(--surface-2); border-top: 2px solid var(--border); }
@media (max-width: 767.98px) { .table-x tfoot .report-total td:empty { display: none; } }
@media print {
  .report-tabs, #rangeForm { display: none !important; }
  .card-x { break-inside: avoid; }
  .table-x td, .table-x th { padding: 6px 10px; font-size: 12px; }
}

/* =========================================================
   App-like mobile experience
   ========================================================= */
body { touch-action: manipulation; }
.main { overflow-x: clip; }
img, video, iframe, canvas { max-width: 100%; }
.sidebar, .bottom-nav, .topbar, .chips, .report-tabs, .view-toggle { -webkit-user-select: none; user-select: none; }

@media (max-width: 991.98px) {
  /* Safe areas (notches) when installed as an app */
  .topbar { padding-top: env(safe-area-inset-top); height: calc(60px + env(safe-area-inset-top)); }
  .sidebar { padding-top: env(safe-area-inset-top); }

  /* Large title pattern: the top-bar title appears once the page heading scrolls away */
  body.has-page-head .topbar-title { opacity: 0; transform: translateY(6px); transition: opacity .2s, transform .2s; }
  body.has-page-head .topbar.show-title .topbar-title { opacity: 1; transform: none; }
  .breadcrumb-x { display: none; }

  /* Press feedback like native apps */
  .btn:active, .icon-btn:active, .chip:active, .card-link:active, .bottom-nav a:active, .bottom-nav button:active,
  .nav-item-x:active, .chat-contact:active, .list-x > li:active, .table-x tbody tr:active, .report-tab:active { transform: scale(.97); }
  .btn, .icon-btn, .chip, .card-link, .nav-item-x, .chat-contact, .report-tab { transition: transform .08s ease, background .15s, color .15s; }

  /* Comfortable touch targets */
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; }
  .btn-icon.btn-sm { min-width: 36px; min-height: 36px; }
  .chip { padding: 8px 15px; }

  /* Cards breathe a little less on small screens */
  .card-x-body { padding: 16px; }
  .card-x-head { padding: 14px 16px; }
  .list-x > li { padding: 12px 16px; }
  .page-head { margin: 2px 0 14px; }
  .page-head h1 { font-size: 22px; }
}

/* Prevent iOS from zooming into focused fields (needs >= 16px) */
@media (max-width: 767.98px) {
  .form-control, .form-select, .input-group-text, textarea { font-size: 16px !important; }
  .row.g-3 { --bs-gutter-y: .85rem; }
  .sticky-actions { padding: 12px 16px; }
  .sticky-actions .btn { flex: 1; }
  .kv { grid-template-columns: 105px 1fr; gap: 8px 12px; }
  .stat-value { word-break: break-word; }
  .hero-metric .v { white-space: nowrap; }
}

/* Collapsible filters on phones */
.filter-toggle { display: none; }
@media (max-width: 575.98px) {
  .filter-bar.collapsible .filter-toggle { display: inline-flex; flex: 0 0 auto; }
  .filter-bar.collapsible > .form-select,
  .filter-bar.collapsible > input[type="number"],
  .filter-bar.collapsible > .btn[type="submit"] { display: none; }
  .filter-bar.collapsible.open > .form-select,
  .filter-bar.collapsible.open > input[type="number"] { display: block; flex: 1 1 100%; width: 100%; }
  .filter-bar.collapsible.open > .btn[type="submit"] { display: inline-flex; flex: 1 1 100%; }
  .filter-bar .search-input { flex: 1 1 0; min-width: 0; }
  .filter-toggle .count { background: var(--brand); color: #fff; border-radius: 999px; font-size: 11px; min-width: 18px; height: 18px; display: inline-grid; place-items: center; padding: 0 5px; }
}

/* Standalone (installed) mode: no browser chrome, so give the content a touch more room at the top */
@media (display-mode: standalone) and (max-width: 991.98px) {
  .content { padding-top: 10px; }
}
