/* ==========================================================================
   Icka Homes — Rent Desk  ·  Enterprise CRM UI
   ========================================================================== */
:root {
    --navy-900: #0d1730;
    --navy-800: #14213d;
    --navy-700: #1d2d50;
    --navy-600: #2a3b63;
    --navy-300: #8b9bc0;
    --bg: #f3f5f9;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --border: #e3e7ef;
    --border-strong: #cfd6e3;
    --text: #1b2333;
    --text-2: #4a5568;
    --muted: #7a8599;
    --primary: #2459d6;
    --primary-600: #1d4bbb;
    --primary-50: #ebf1ff;
    --success: #12805c;
    --success-50: #e6f6ef;
    --warning: #b25e09;
    --warning-50: #fff4e5;
    --danger: #c42b2b;
    --danger-50: #fdecec;
    --info: #0b6e99;
    --info-50: #e6f4fa;
    --purple: #6b46c1;
    --purple-50: #f1ecfd;
    --radius: 8px;
    --radius-sm: 6px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow: 0 4px 16px rgba(16, 24, 40, .08);
    --shadow-lg: 0 18px 50px rgba(16, 24, 40, .18);
    --sidebar-w: 240px;
    --topbar-h: 60px;
    --font: "Inter", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; overflow-x: hidden; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.45; -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; line-height: 1.25; color: var(--text); }
h1 { font-size: 22px; font-weight: 650; }
h2 { font-size: 17px; font-weight: 620; }
h3 { font-size: 15px; font-weight: 600; }
p { margin: 0 0 10px; }
hr { border: 0; border-top: 1px solid var(--border); margin: 16px 0; }
small, .small { font-size: 12px; }
.muted { color: var(--muted); }
.pad { padding: 14px; }
.mono { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 12.5px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-danger { color: var(--danger); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0 !important; }
.mt-8 { margin-top: 8px; } .mt-12 { margin-top: 12px; } .mt-16 { margin-top: 16px; } .mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; } .mb-12 { margin-bottom: 12px; } .mb-16 { margin-bottom: 16px; }
.flex { display: flex; } .items-center { align-items: center; } .justify-between { justify-content: space-between; }
.gap-6 { gap: 6px; } .gap-8 { gap: 8px; } .gap-12 { gap: 12px; } .gap-16 { gap: 16px; }
.wrap { flex-wrap: wrap; }
.grow { flex: 1; min-width: 0; }
[hidden] { display: none !important; }

.ico { width: 18px; height: 18px; flex-shrink: 0; }
.ico-sm { width: 14px; height: 14px; }
.ico-lg { width: 22px; height: 22px; }

/* ---------------------------------------------------------------- layout */
.app { display: flex; min-height: 100vh; }
.sidebar {
    width: var(--sidebar-w); background: var(--navy-800); color: #c9d3ea; position: fixed; inset: 0 auto 0 0;
    display: flex; flex-direction: column; z-index: 40; transition: transform .2s ease;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 16px 18px; height: var(--topbar-h); border-bottom: 1px solid rgba(255,255,255,.06); }
.brand-mark { width: 34px; height: 34px; border-radius: 9px; background: linear-gradient(135deg, #3b74f0, #2459d6); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 18px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { color: #fff; font-size: 16px; letter-spacing: .2px; }
.brand-text span { font-size: 12.5px; color: #9fb0d6; letter-spacing: .2px; font-weight: 500; }
.nav { flex: 1; overflow-y: auto; padding: 10px 10px; }
.module-switch { border-bottom: 1px solid rgba(255,255,255,.06); }
.module-switch .brand { width: 100%; border: 0; background: transparent; color: inherit; cursor: pointer; text-align: left; font: inherit; border-bottom: 0; }
.module-switch .brand:hover { background: var(--navy-700); }
.module-switch .brand-caret { margin-left: auto; color: var(--navy-300); }
.module-menu { left: 10px; right: 10px; top: calc(100% - 4px); min-width: 0; padding: 6px; }
.module-menu-head { font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); padding: 6px 8px 4px; font-weight: 700; }
.module-menu .module-item { display: flex; align-items: center; gap: 10px; padding: 9px 8px; }
.module-menu .module-item small { display: block; color: var(--muted); font-size: 11.5px; font-weight: 400; }
.module-menu .module-item.active { background: var(--primary-50); }
.module-menu .module-item.locked { opacity: .55; cursor: not-allowed; }
.module-ico { width: 32px; height: 32px; border-radius: 8px; background: var(--navy-800); color: #fff; display: grid; place-items: center; flex-shrink: 0; }
.nav-soon { opacity: .45; cursor: default; }
.nav-soon:hover { background: transparent; color: #b8c3dc; }
.soon-tag { margin-left: auto; font-size: 10px; background: rgba(255,255,255,.12); padding: 1px 7px; border-radius: 10px; font-weight: 600; }
/* ---------------------------------------------------------------- Share Portal (WhatsApp composer + preview) */
.share-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 18px; align-items: start; }
.wa-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.wa-toolbar select { width: auto; padding: 3px 8px; font-size: 12.5px; }
.emoji-menu { display: grid !important; grid-template-columns: repeat(6, 36px); padding: 6px; min-width: 0; }
.dropdown:not(.open) .emoji-menu { display: none !important; }
.emoji-menu button { font-size: 18px; padding: 4px; text-align: center; }
#spBody { font-family: inherit; line-height: 1.5; }
.phone-wrap { position: sticky; top: 76px; }
.phone { border: 10px solid #1d2433; border-radius: 30px; overflow: hidden; background: #e7ddd3; box-shadow: var(--shadow-lg); }
.phone-top { background: #075e54; color: #fff; display: flex; align-items: center; gap: 10px; padding: 10px 12px; }
.phone-top small { display: block; font-size: 11px; color: #cfe9e4; }
.phone-chat { min-height: 520px; max-height: 70vh; overflow-y: auto; padding: 14px 10px; background-color: #e7ddd3;
    background-image: radial-gradient(rgba(0,0,0,.035) 1px, transparent 1px); background-size: 14px 14px; }
.wa-bubble { background: #fff; border-radius: 0 10px 10px 10px; padding: 4px; max-width: 92%; box-shadow: 0 1px 1px rgba(0,0,0,.12); font-size: 13.6px; color: #111b21; }
.wa-media { height: 170px; border-radius: 8px; overflow: hidden; display: grid; gap: 2px; }
.wa-media.multi { grid-template-columns: 1fr 1fr; }
.wa-media > div { background-size: cover; background-position: center; min-height: 84px; }
.wa-media.empty { display: grid; place-items: center; background: #f0f2f5; color: #667781; font-size: 12px; height: 60px; }
.wa-text { padding: 6px 8px 0; word-wrap: break-word; }
.wa-text code { background: #f0f2f5; padding: 1px 4px; border-radius: 4px; }
.wa-text a { color: #027eb5; }
.wa-time { text-align: right; font-size: 11px; color: #667781; padding: 0 8px 4px; }
.wa-buttons > div { border-top: 1px solid #e9edef; text-align: center; color: #027eb5; padding: 8px; font-weight: 500; }
.rc-list { max-height: 280px; overflow-y: auto; border: 1px solid var(--border); border-radius: 8px; }
.rc-item { display: flex; gap: 10px; align-items: flex-start; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; }
.rc-item:last-child { border-bottom: 0; }
.rc-item:hover { background: var(--surface-2); }
.rc-item small { display: block; color: var(--muted); font-size: 12px; }
@media (max-width: 1100px) { .share-grid { grid-template-columns: 1fr; } .phone-wrap { position: static; max-width: 380px; margin: 0 auto; } }

/* Share Portal: Meta approval state of the linked WhatsApp template */
.wa-tpl-state { display: flex; gap: 12px; align-items: flex-start; padding: 10px 16px; border-bottom: 1px solid var(--border); font-size: 13px; }
.wa-tpl-state .small { color: var(--text-2); }
.wa-tpl-state.ok { background: var(--success-50); }
.wa-tpl-state.ok b { color: var(--success); }
.wa-tpl-state.wait { background: var(--warning-50); }
.wa-tpl-state.wait b { color: var(--warning); }
.wa-tpl-state.bad { background: var(--danger-50); }
.wa-tpl-state.bad b { color: var(--danger); }
.wa-tpl-state .btn { flex: none; }

/* Share Portal: property search (name / area / city / code) */
.prop-search { position: relative; width: 440px; max-width: 100%; }
.prop-search-box { display: flex; align-items: center; gap: 8px; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 0 6px 0 12px; height: 44px; color: var(--muted); transition: border-color .15s, box-shadow .15s; }
.prop-search-box:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.prop-search-box input { border: 0 !important; box-shadow: none !important; padding: 0 !important; height: 100%; background: transparent; font-size: 14px; color: var(--text); flex: 1; min-width: 0; }
.prop-search-box .icon-btn { width: 30px; height: 30px; }
.prop-search.has-value .prop-search-box { border-color: var(--primary); background: var(--primary-50); }
.prop-search.has-value .prop-search-box input { font-weight: 600; }
.prop-search-pop { position: absolute; z-index: 60; top: calc(100% + 6px); right: 0; width: min(560px, calc(100vw - 32px)); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow-lg); overflow: hidden; }
.prop-search-filters { padding: 10px 12px; border-bottom: 1px solid var(--border); display: grid; gap: 8px; }
.prop-search-filters .chip { padding: 3px 10px; font-size: 12px; }
.prop-search-areas { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; font-size: 12px; color: var(--muted); }
.prop-search-areas:empty { display: none; }
.prop-search-areas button { border: 0; background: var(--surface-2); color: var(--text-2); border-radius: 12px; padding: 2px 9px; font: inherit; cursor: pointer; }
.prop-search-areas button:hover { background: var(--primary-50); color: var(--primary); }
.prop-search-list { max-height: min(420px, 60vh); overflow-y: auto; }
.prop-opt { display: flex; gap: 12px; align-items: center; padding: 9px 12px; cursor: pointer; border-bottom: 1px solid var(--border); }
.prop-opt:last-child { border-bottom: 0; }
.prop-opt.active, .prop-opt:hover { background: var(--primary-50); }
.prop-opt.selected { box-shadow: inset 3px 0 0 var(--primary); }
.prop-thumb { width: 52px; height: 42px; border-radius: 6px; background: var(--surface-2) center / cover no-repeat; flex: none; display: grid; place-items: center; color: var(--muted); }
.prop-opt-main { flex: 1; min-width: 0; }
.prop-opt-main b { display: block; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-opt-main small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prop-opt-main small .ico, .portal-card-body .loc .ico { width: 12px; height: 12px; vertical-align: -1px; }
.prop-thumb .ico { width: 20px; height: 20px; }
.prop-opt-side { text-align: right; flex: none; font-size: 12.5px; font-weight: 600; display: grid; gap: 3px; justify-items: end; }
.prop-opt mark, .portal-card mark, .bk-row mark { background: #fff1b8; color: inherit; border-radius: 2px; padding: 0 1px; }
.prop-search-empty { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 13px; }
.prop-search-foot { display: flex; justify-content: space-between; gap: 8px; padding: 7px 12px; border-top: 1px solid var(--border); background: var(--surface-2); font-size: 11.5px; color: var(--muted); }

/* Share Portal: Bookings tab */
.bk-stats { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--border); }
.bk-stats > div { padding: 12px 16px; border-right: 1px solid var(--border); }
.bk-stats > div:last-child { border-right: 0; }
.bk-stats b { display: block; font-size: 20px; color: var(--navy-800); }
.bk-stats span { font-size: 12px; color: var(--muted); }
.bk-row { display: flex; gap: 12px; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.bk-row:last-child { border-bottom: 0; }
.bk-row .prop-opt-main b { white-space: normal; }
.bk-meta { flex: none; width: 220px; font-size: 12.5px; color: var(--text-2); }
.bk-meta small { display: block; color: var(--muted); }
.bk-actions { flex: none; display: flex; gap: 6px; }
@media (max-width: 900px) { .bk-stats { grid-template-columns: repeat(2, 1fr); } .bk-stats > div:nth-child(2) { border-right: 0; } .bk-row { flex-wrap: wrap; } .bk-meta { width: auto; flex: 1 1 100%; padding-left: 64px; } .bk-actions { padding-left: 64px; } }

/* Share Portal: Property portal tab */
.portal-toolbar { margin-bottom: 16px; }
.portal-toolbar .prop-search-box { height: 38px; }
.portal-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 16px; }
.portal-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow-sm); transition: box-shadow .15s, transform .15s; }
.portal-card:hover { box-shadow: var(--shadow); transform: translateY(-1px); }
.portal-card-img { position: relative; aspect-ratio: 16 / 10; background: var(--surface-2) center / cover no-repeat; display: grid; place-items: center; color: var(--muted); }
.portal-card-img .badge { position: absolute; top: 10px; left: 10px; box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.portal-card-img .portal-rent { position: absolute; right: 10px; top: 10px; background: rgba(20,33,61,.86); color: #fff; padding: 3px 9px; border-radius: 6px; font-weight: 700; font-size: 13px; }
.portal-card.is-booked .portal-card-img { filter: grayscale(.5); }
.portal-card-body { padding: 12px 14px; flex: 1; }
.portal-card-body h4 { font-size: 14.5px; margin: 0 0 3px; }
.portal-card-body .loc { color: var(--text-2); font-size: 12.5px; display: flex; gap: 4px; align-items: center; }
.portal-card-body .facts { color: var(--muted); font-size: 12px; margin-top: 6px; }
.portal-card-foot { display: flex; gap: 6px; padding: 10px 14px; border-top: 1px solid var(--border); background: var(--surface-2); flex-wrap: wrap; }
.portal-card-foot .btn-primary { flex: 1; justify-content: center; }
.portal-empty { grid-column: 1 / -1; text-align: center; padding: 40px 16px; color: var(--muted); background: var(--surface); border: 1px dashed var(--border-strong); border-radius: 12px; }
@media (max-width: 700px) { .prop-search { width: 100%; } .page-actions:has(.prop-search) { width: 100%; } }

/* Public property page (/p/) */
.booked-banner { background: var(--danger); color: #fff; text-align: center; font-weight: 700; letter-spacing: .4px; padding: 10px; border-radius: 8px; margin-bottom: 12px; }
.pub-gallery.is-booked { filter: grayscale(.6); }
.pub-map { width: 100%; height: 260px; border: 0; border-radius: 8px; }

/* ---------------------------------------------------------------- Tenant portal (mobile-first) */
.portal-body { background: var(--bg, #f4f6fa); min-height: 100vh; display: flex; flex-direction: column; }
.portal-top { position: sticky; top: 0; z-index: 30; display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--navy-800); color: #fff; flex-wrap: wrap; }
.portal-brand { display: flex; align-items: center; gap: 10px; color: #fff !important; text-decoration: none !important; font-weight: 700; }
.portal-brand small { display: block; font-weight: 400; font-size: 11.5px; color: #b8c3dc; }
.portal-nav { display: flex; gap: 4px; margin-left: 12px; }
.portal-nav a { display: flex; align-items: center; gap: 6px; color: #c9d3ea; padding: 7px 11px; border-radius: 7px; text-decoration: none !important; font-size: 13.5px; }
.portal-nav a.active, .portal-nav a:hover { background: var(--navy-600, #24365f); color: #fff; }
.portal-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.portal-actions .icon-btn { color: #fff; }
.portal-main { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 20px 16px; }
.portal-login { max-width: 440px; margin: 24px auto; }
.rent-hero { border-left: 4px solid var(--primary); }
.rent-hero.overdue { border-left-color: var(--danger); }
.rent-hero.paid { border-left-color: var(--success); }
.rent-hero.partial { border-left-color: var(--warning); }
.rent-amount { font-size: 32px; font-weight: 800; letter-spacing: -.5px; margin: 2px 0 4px; }
.pay-now { min-width: 180px; font-size: 17px; padding: 13px 26px; }
.text-up { text-transform: uppercase; letter-spacing: .4px; }
.pay-ok { width: 64px; height: 64px; border-radius: 50%; background: var(--success-50); color: var(--success); font-size: 34px; display: grid; place-items: center; margin: 0 auto 12px; }
@media (max-width: 700px) {
    .portal-nav { order: 3; width: 100%; margin: 0; justify-content: space-around; }
    .portal-nav a { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 10px; }
    .portal-grid { grid-template-columns: 1fr; }
    .pay-now { width: 100%; }
    .hide-xs { display: none; }
}
/* Footer branding (shared component) */
.app-footer { text-align: center; color: #8a94a6; font-size: 12px; letter-spacing: .3px; padding: 14px 16px 18px; border-top: 1px solid var(--border); background: transparent; }
.auth-footer { text-align: center; color: #8a94a6; font-size: 12px; margin-top: 28px; }
.nav-item {
    display: flex; align-items: center; gap: 11px; padding: 9px 12px; border-radius: 7px; color: #b8c3dc; font-size: 13.8px;
    margin-bottom: 2px; position: relative; text-decoration: none !important;
}
.nav-item:hover { background: var(--navy-700); color: #fff; }
.nav-item.active { background: var(--navy-600); color: #fff; font-weight: 550; }
.nav-item.active::before { content: ""; position: absolute; left: -10px; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: #4f86ff; }
.nav-group > summary { list-style: none; cursor: pointer; user-select: none; }
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary .nav-caret { margin-left: auto; transition: transform .15s; }
.nav-group[open] > summary .nav-caret { transform: rotate(180deg); }
.nav-group > summary.active-parent { color: #fff; }
.nav-item.nav-sub { padding-left: 42px; font-size: 13.2px; }
.brand-mark.has-logo { background: transparent; padding: 0; overflow: hidden; }
.brand-mark.has-logo img { width: 100%; height: 100%; object-fit: contain; display: block; }
.agent-mark { width: 52px; height: 52px; margin: 0 auto 10px; }
.portal-brand .brand-mark { width: 34px; height: 34px; }
.nav-badge { margin-left: auto; background: #e5484d; color: #fff; font-size: 11px; border-radius: 10px; padding: 1px 7px; font-weight: 600; }
.sidebar-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,.06); }
.role-pill { font-size: 11.5px; background: rgba(255,255,255,.08); color: #d4dcef; padding: 3px 10px; border-radius: 20px; }
.sidebar-backdrop { display: none; }

.main { flex: 1; margin-left: var(--sidebar-w); min-width: 0; display: flex; flex-direction: column; }
.topbar {
    height: var(--topbar-h); background: var(--surface); border-bottom: 1px solid var(--border); display: flex; align-items: center;
    gap: 14px; padding: 0 22px; position: sticky; top: 0; z-index: 30;
}
.global-search { position: relative; flex: 1; max-width: 520px; display: flex; align-items: center; }
.global-search > .ico { position: absolute; left: 11px; color: var(--muted); }
.global-search input[type=search] { width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); font: inherit; }
.global-search input:focus { outline: none; border-color: var(--primary); background: #fff; box-shadow: 0 0 0 3px var(--primary-50); }
.search-results { position: absolute; top: calc(100% + 6px); left: 0; right: 0; background: #fff; border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow-lg); max-height: 440px; overflow: auto; z-index: 60; }
.search-group { padding: 6px 0; border-bottom: 1px solid var(--border); }
.search-group:last-child { border-bottom: 0; }
.search-group h5 { margin: 0; padding: 4px 14px; font-size: 11px; text-transform: uppercase; letter-spacing: .6px; color: var(--muted); }
.search-group a { display: block; padding: 7px 14px; color: var(--text); text-decoration: none; }
.search-group a:hover, .search-group a.focused { background: var(--primary-50); }
.search-group a small { color: var(--muted); margin-left: 6px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.icon-btn { position: relative; width: 38px; height: 38px; border: 0; background: transparent; border-radius: 8px; display: grid; place-items: center; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.dot-badge { position: absolute; top: 4px; right: 3px; background: #e5484d; color: #fff; font-size: 10px; min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; font-weight: 700; }
.profile-btn { display: flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer; padding: 5px 8px; border-radius: 8px; font: inherit; color: var(--text); }
.profile-btn:hover { background: var(--surface-2); }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--navy-700); color: #fff; display: grid; place-items: center; font-weight: 650; font-size: 13px; flex-shrink: 0; overflow: hidden; }
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.profile-name { display: flex; flex-direction: column; text-align: left; line-height: 1.15; font-size: 13px; font-weight: 550; }
.profile-name small { color: var(--muted); font-weight: 400; font-size: 11.5px; }
.only-mobile { display: none; }
.content { padding: 22px 26px 40px; flex: 1; min-width: 0; }

/* ---------------------------------------------------------------- dropdowns */
.dropdown { position: relative; }
.dropdown-menu {
    position: absolute; right: 0; top: calc(100% + 6px); min-width: 200px; background: #fff; border: 1px solid var(--border);
    border-radius: 8px; box-shadow: var(--shadow-lg); padding: 6px; display: none; z-index: 70;
}
.dropdown.open > .dropdown-menu { display: block; }
.dropdown-menu a, .dropdown-menu button {
    display: flex; align-items: center; gap: 9px; width: 100%; padding: 8px 10px; color: var(--text); border: 0; background: none;
    border-radius: 6px; font: inherit; cursor: pointer; text-align: left; text-decoration: none;
}
.dropdown-menu a:hover, .dropdown-menu button:hover { background: var(--surface-2); text-decoration: none; }
.dropdown-menu .danger { color: var(--danger); }
.dropdown-menu .sep { height: 1px; background: var(--border); margin: 5px 0; }
.dropdown-menu form { margin: 0; }
.dropdown-wide { width: 360px; padding: 0; }
.dropdown-head { display: flex; justify-content: space-between; padding: 11px 14px; border-bottom: 1px solid var(--border); font-weight: 600; }
.dropdown-head a { font-weight: 500; font-size: 12.5px; }
.notif-list { max-height: 380px; overflow: auto; }
.notif-item { display: flex; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); color: var(--text); text-decoration: none !important; }
.notif-item:hover { background: var(--surface-2); }
.notif-item.unread { background: #f6f9ff; }
.notif-item .sev { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-item .t { font-weight: 550; font-size: 13px; }
.notif-item .m { color: var(--muted); font-size: 12px; }

/* ---------------------------------------------------------------- page header */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head .sub { color: var(--muted); margin-top: 3px; font-size: 13px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.breadcrumb { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.breadcrumb a { color: var(--muted); }

/* ---------------------------------------------------------------- buttons */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 8px 14px; border-radius: 7px; border: 1px solid var(--border-strong);
    background: #fff; color: var(--text); font: inherit; font-weight: 550; font-size: 13.5px; cursor: pointer; white-space: nowrap; text-decoration: none !important;
    transition: background .12s, border-color .12s, box-shadow .12s; line-height: 1.2;
}
.btn:hover { background: var(--surface-2); }
.btn:focus-visible { outline: none; box-shadow: 0 0 0 3px var(--primary-50); }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; pointer-events: none; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-600); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #0e6a4b; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a82222; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-whatsapp { background: #1fa855; border-color: #1fa855; color: #fff; }
.btn-whatsapp:hover { background: #178a45; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; }
.btn-xs { padding: 3px 8px; font-size: 12px; border-radius: 5px; }
.btn-lg { padding: 11px 20px; font-size: 15px; }
.btn-icon { padding: 6px; width: 32px; height: 32px; }
.btn-block { width: 100%; }
.btn .spinner { width: 14px; height: 14px; }
.btn-group { display: inline-flex; }
.btn-group .btn { border-radius: 0; margin-left: -1px; }
.btn-group .btn:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.btn-group .btn:last-child { border-radius: 0 7px 7px 0; }
.btn-group .btn.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); z-index: 1; }

.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- cards */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); }
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 13px 16px; border-bottom: 1px solid var(--border); }
.card-head h3 { font-size: 14.5px; }
.card-body { padding: 16px; }
.card-body.tight { padding: 0; }
.card-foot { padding: 12px 16px; border-top: 1px solid var(--border); background: var(--surface-2); border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.span-2 { grid-column: span 2; }
.span-3 { grid-column: span 3; }
.span-all { grid-column: 1 / -1; }

/* stat cards */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.stat {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; display: flex; flex-direction: column; gap: 4px;
    color: var(--text); text-decoration: none !important; transition: border-color .12s, box-shadow .12s, transform .12s; position: relative; overflow: hidden;
}
.stat:hover { border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-1px); }
.stat .label { font-size: 12px; color: var(--muted); font-weight: 550; text-transform: uppercase; letter-spacing: .4px; }
.stat .value { font-size: 22px; font-weight: 700; letter-spacing: -.3px; }
.stat .hint { font-size: 12px; color: var(--muted); }
.stat .stat-ico { position: absolute; right: 12px; top: 12px; width: 34px; height: 34px; border-radius: 8px; display: grid; place-items: center; }
.stat.c-blue .stat-ico { background: var(--primary-50); color: var(--primary); }
.stat.c-green .stat-ico { background: var(--success-50); color: var(--success); }
.stat.c-amber .stat-ico { background: var(--warning-50); color: var(--warning); }
.stat.c-red .stat-ico { background: var(--danger-50); color: var(--danger); }
.stat.c-purple .stat-ico { background: var(--purple-50); color: var(--purple); }
.stat.c-teal .stat-ico { background: var(--info-50); color: var(--info); }

/* ---------------------------------------------------------------- badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 12px; font-size: 11.5px; font-weight: 600; white-space: nowrap; background: #eef1f6; color: var(--text-2); }
.badge-green { background: var(--success-50); color: var(--success); }
.badge-red { background: var(--danger-50); color: var(--danger); }
.badge-amber { background: var(--warning-50); color: var(--warning); }
.badge-blue { background: var(--primary-50); color: var(--primary); }
.badge-teal { background: var(--info-50); color: var(--info); }
.badge-purple { background: var(--purple-50); color: var(--purple); }
.badge-gray { background: #eef1f6; color: #5b6475; }
.badge-dark { background: var(--navy-800); color: #fff; }

/* ---------------------------------------------------------------- tables */
.table-wrap { overflow-x: visible; max-width: 100%; }
table.table { width: 100%; border-collapse: collapse; font-size: 13.3px; }
.table th { text-align: left; font-weight: 600; color: var(--text-2); font-size: 12px; text-transform: uppercase; letter-spacing: .35px; background: var(--surface-2); padding: 10px 12px; border-bottom: 1px solid var(--border); }
.table th.sortable { cursor: pointer; user-select: none; }
.table th.sortable:hover { color: var(--text); }
.table th.sorted-asc::after { content: " ▲"; font-size: 9px; }
.table th.sorted-desc::after { content: " ▼"; font-size: 9px; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; overflow-wrap: anywhere; }
.table td.actions { overflow-wrap: normal; width: 1%; }
.table .cell-main { display: block; }
.table td .badge { margin: 1px 0; }
/* Columns that hide on smaller screens so lists never scroll sideways */
@media (max-width: 1400px) { .table .hide-lg { display: none; } }
@media (max-width: 1100px) { .table .hide-md { display: none; } }
@media (max-width: 700px)  { .table .hide-sm { display: none; } .table th, .table td { padding: 8px; } }
.table tbody tr:hover { background: #fafbfe; }
.table tbody tr:last-child td { border-bottom: 0; }
.table .actions { white-space: nowrap; text-align: right; }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.table.compact td, .table.compact th { padding: 7px 10px; }
.table .cell-main { font-weight: 560; color: var(--text); }
.table .cell-sub { font-size: 12px; color: var(--muted); }
.table-empty { padding: 40px 16px; text-align: center; color: var(--muted); }
.table-foot { display: flex; justify-content: space-between; align-items: center; padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; gap: 10px; font-size: 13px; color: var(--text-2); }
.pager { display: flex; gap: 4px; align-items: center; }
.pager button { min-width: 32px; height: 30px; border: 1px solid var(--border); background: #fff; border-radius: 6px; cursor: pointer; font: inherit; font-size: 12.5px; }
.pager button.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }
.pager button:disabled { opacity: .45; cursor: default; }

/* toolbar / filters */
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.toolbar .search { position: relative; flex: 1; min-width: 200px; max-width: 360px; }
.toolbar .search .ico { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.toolbar .search input[type=search] { padding-left: 34px; }
.filters { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; padding: 12px 14px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.filters label { font-size: 11.5px; color: var(--muted); font-weight: 600; display: block; margin-bottom: 3px; text-transform: uppercase; letter-spacing: .3px; }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--border-strong); background: #fff; padding: 5px 11px; border-radius: 16px; cursor: pointer; font: inherit; font-size: 12.5px; color: var(--text-2); }
.chip.active { background: var(--navy-800); color: #fff; border-color: var(--navy-800); }

/* row action menu */
.row-menu { position: relative; display: inline-block; }
.row-menu .dropdown-menu { min-width: 190px; }

/* ---------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field.span-2 { grid-column: span 2; }
.field.span-all { grid-column: 1 / -1; }
.field > label, .label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .req::after, label.req::after { content: " *"; color: var(--danger); }
.field .help { font-size: 11.8px; color: var(--muted); }
.field .error { font-size: 12px; color: var(--danger); }
.field.has-error input, .field.has-error select, .field.has-error textarea { border-color: var(--danger); background: #fff8f8; }
.input, input:not([type]), input[type=text], input[type=email], input[type=password], input[type=number], input[type=date], input[type=datetime-local], input[type=time],
input[type=tel], input[type=url], input[type=search], input[type=month], select, textarea {
    width: 100%; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: 7px; font: inherit; font-size: 13.5px; color: var(--text);
    background: #fff; transition: border-color .12s, box-shadow .12s;
}
textarea { min-height: 76px; resize: vertical; }
.pw-wrap { position: relative; width: 100%; }
.pw-wrap input { padding-right: 42px !important; }
.pw-toggle { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 34px; height: 30px; border: 0; background: transparent;
    color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 6px; }
.pw-toggle:hover { color: var(--text); background: var(--surface-2); }
.pw-toggle:focus-visible { outline: 2px solid var(--primary); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
input:disabled, select:disabled, textarea:disabled, input[readonly] { background: var(--surface-2); color: var(--text-2); }
select { padding-right: 28px; }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-size: 13.5px; user-select: none; }
.check input { width: 16px; height: 16px; accent-color: var(--primary); }
.input-group { display: flex; }
.input-group > span { padding: 8px 10px; background: var(--surface-2); border: 1px solid var(--border-strong); border-right: 0; border-radius: 7px 0 0 7px; color: var(--text-2); font-size: 13px; }
.input-group > input { border-radius: 0 7px 7px 0; }
.input-group > input:not(:last-child) { border-radius: 0; }
.input-group > .btn { border-radius: 0 7px 7px 0; margin-left: -1px; }

.form-section { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.form-section > h3 { padding: 13px 18px; border-bottom: 1px solid var(--border); font-size: 14.5px; display: flex; gap: 8px; align-items: center; }
.form-section > h3 .step { width: 24px; height: 24px; border-radius: 50%; background: var(--navy-800); color: #fff; font-size: 12px; display: grid; place-items: center; }
.form-section > .body { padding: 18px; }
.portal-login { margin-left: auto; display: flex; align-items: center; gap: 12px; font-weight: 400; font-size: 13px; flex-wrap: wrap; justify-content: flex-end; }
.portal-login-info { display: flex; flex-direction: column; text-align: right; line-height: 1.3; }
.portal-login-info small { color: var(--muted); font-size: 12px; }
.switch { position: relative; display: inline-block; width: 40px; height: 22px; flex: none; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span { position: absolute; inset: 0; background: var(--border-strong); border-radius: 11px; transition: background .15s; pointer-events: none; }
.switch span::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.25); transition: transform .15s; }
.switch input:checked + span { background: var(--success); }
.switch input:checked + span::after { transform: translateX(18px); }
.switch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.switch input:disabled + span { opacity: .55; }
@media (max-width: 700px) { .form-section > h3 { flex-wrap: wrap; } .portal-login { margin-left: 0; width: 100%; justify-content: space-between; } .portal-login-info { text-align: left; } }
.form-actions { position: sticky; bottom: 0; background: rgba(243,245,249,.96); backdrop-filter: blur(4px); border-top: 1px solid var(--border); padding: 12px 0; display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; z-index: 5; }
.alert-box { padding: 11px 14px; border-radius: 8px; font-size: 13.5px; margin-bottom: 14px; border: 1px solid; }
.alert-box.error { background: var(--danger-50); color: #8f1f1f; border-color: #f5c2c2; }
.alert-box.success { background: var(--success-50); color: #0c5c42; border-color: #b8e5d1; }
.alert-box.info { background: var(--info-50); color: #084e6d; border-color: #b8dcec; }
.alert-box.warning { background: var(--warning-50); color: #7a4106; border-color: #f6d6a8; }

/* ---------------------------------------------------------------- tabs */
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: thin; }
.tab { padding: 10px 14px; border: 0; background: none; cursor: pointer; font: inherit; font-weight: 550; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; font-size: 13.5px; }
.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------------------------------------------------------------- detail views */
.detail-hero { display: flex; gap: 18px; align-items: flex-start; padding: 18px; }
.detail-hero .cover { width: 180px; height: 120px; border-radius: 8px; background: var(--surface-2) center/cover no-repeat; border: 1px solid var(--border); flex-shrink: 0; display: grid; place-items: center; color: var(--muted); }
.detail-hero h1 { font-size: 21px; }
.kv { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 20px; }
.kv > div > span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .35px; font-weight: 600; margin-bottom: 2px; }
.kv > div > b { font-weight: 550; word-break: break-word; }
.kv-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border); gap: 12px; }
.kv-row:last-child { border-bottom: 0; }
.kv-row span { color: var(--muted); }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; border-left: 2px solid var(--border); margin-left: 6px; }
.timeline li::before { content: ""; position: absolute; left: -6px; top: 3px; width: 10px; height: 10px; border-radius: 50%; background: #fff; border: 2px solid var(--primary); }
.timeline li:last-child { border-left-color: transparent; }
.timeline .when { font-size: 12px; color: var(--muted); }

/* ---------------------------------------------------------------- uploader */
.dropzone {
    border: 2px dashed var(--border-strong); border-radius: 10px; padding: 22px; text-align: center; background: var(--surface-2); cursor: pointer;
    transition: border-color .12s, background .12s; color: var(--text-2);
}
.dropzone:hover, .dropzone.drag { border-color: var(--primary); background: var(--primary-50); }
.dropzone .ico { width: 28px; height: 28px; color: var(--primary); margin-bottom: 6px; }
.dropzone small { display: block; color: var(--muted); margin-top: 4px; }
.upload-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; margin-top: 12px; }
.upload-item { border: 1px solid var(--border); border-radius: 8px; background: #fff; overflow: hidden; position: relative; display: flex; flex-direction: column; }
.upload-item.dragging { opacity: .4; }
.upload-item.over { outline: 2px dashed var(--primary); }
.upload-item .thumb { height: 100px; background: var(--surface-2) center/cover no-repeat; display: grid; place-items: center; color: var(--muted); position: relative; }
.upload-item .thumb video { width: 100%; height: 100%; object-fit: cover; }
.upload-item .meta { padding: 7px 8px; font-size: 12px; display: flex; flex-direction: column; gap: 5px; }
.upload-item .meta .name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 550; }
.upload-item .meta input, .upload-item .meta select { padding: 4px 6px; font-size: 12px; }
.upload-item .tools { position: absolute; top: 5px; right: 5px; display: flex; gap: 4px; }
.upload-item .tools button { width: 26px; height: 26px; border-radius: 6px; border: 0; background: rgba(13,23,48,.75); color: #fff; cursor: pointer; display: grid; place-items: center; }
.upload-item .tools button.on { background: #f5a524; }
.upload-item .grip { position: absolute; top: 5px; left: 5px; background: rgba(13,23,48,.75); color: #fff; border-radius: 6px; width: 26px; height: 26px; display: grid; place-items: center; cursor: grab; }
.upload-item .cover-tag { position: absolute; bottom: 5px; left: 5px; background: #f5a524; color: #000; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 4px; }
.progress { height: 6px; background: #e9edf4; border-radius: 4px; overflow: hidden; }
.progress > div { height: 100%; background: var(--primary); width: 0; transition: width .15s; }
.progress.done > div { background: var(--success); }
.progress.err > div { background: var(--danger); }
.upload-item .err { color: var(--danger); font-size: 11.5px; }
.file-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 7px; margin-top: 6px; background: #fff; }
.file-row .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.file-row .progress { width: 120px; }

/* gallery */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.gallery-item { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; background: #fff; position: relative; }
.gallery-item .thumb { height: 130px; background: var(--surface-2) center/cover no-repeat; cursor: zoom-in; display: grid; place-items: center; color: var(--muted); }
.gallery-item .cap { padding: 7px 9px; font-size: 12.5px; }

/* ---------------------------------------------------------------- modals */
.modal-root .backdrop { position: fixed; inset: 0; background: rgba(13,23,48,.5); z-index: 90; display: flex; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto; animation: fade .12s ease; }
.modal { background: #fff; border-radius: 10px; box-shadow: var(--shadow-lg); width: 100%; max-width: 560px; display: flex; flex-direction: column; max-height: 90vh; animation: pop .15s ease; }
.modal.lg { max-width: 860px; }
.modal.xl { max-width: 1100px; }
.modal.sm { max-width: 420px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { font-size: 16px; }
.modal-body { padding: 18px; overflow-y: auto; }
.modal-foot { padding: 12px 18px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; background: var(--surface-2); border-radius: 0 0 10px 10px; }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { transform: translateY(8px) scale(.98); opacity: 0; } }
.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.88); z-index: 100; display: flex; align-items: center; justify-content: center; }
.lightbox img, .lightbox video { max-width: 92vw; max-height: 86vh; border-radius: 6px; }
.lightbox .lb-close, .lightbox .lb-prev, .lightbox .lb-next { position: absolute; background: rgba(255,255,255,.12); border: 0; color: #fff; width: 44px; height: 44px; border-radius: 50%; cursor: pointer; display: grid; place-items: center; }
.lightbox .lb-close { top: 18px; right: 18px; }
.lightbox .lb-prev { left: 18px; top: 50%; }
.lightbox .lb-next { right: 18px; top: 50%; }
.lightbox .lb-cap { position: absolute; bottom: 18px; left: 0; right: 0; text-align: center; color: #ddd; }

/* ---------------------------------------------------------------- toasts */
.toast-stack { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 120; }
.toast { min-width: 260px; max-width: 420px; background: var(--navy-800); color: #fff; padding: 11px 14px; border-radius: 8px; box-shadow: var(--shadow-lg); font-size: 13.5px; display: flex; gap: 10px; align-items: flex-start; animation: pop .15s ease; }
.toast.success { background: #0f6b4d; }
.toast.error { background: #a32020; }
.toast.warning { background: #9a5208; }
.toast button { margin-left: auto; background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; }

/* ---------------------------------------------------------------- empty state */
.empty-state { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-state h2 { color: var(--text); margin-bottom: 8px; }
.empty-state .big-ico { width: 54px; height: 54px; color: var(--border-strong); margin-bottom: 12px; }

/* ---------------------------------------------------------------- dashboard */
.dash-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.dash-grid > .w-4 { grid-column: span 4; } .dash-grid > .w-5 { grid-column: span 5; } .dash-grid > .w-6 { grid-column: span 6; }
.dash-grid > .w-7 { grid-column: span 7; } .dash-grid > .w-8 { grid-column: span 8; } .dash-grid > .w-12 { grid-column: span 12; }
.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.mini-list li:last-child { border-bottom: 0; }
.mini-list .grow small { display: block; color: var(--muted); font-size: 12px; }
.chart { width: 100%; height: 240px; }
.chart text { font-family: var(--font); font-size: 11px; fill: var(--muted); }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.donut-wrap { display: flex; align-items: center; gap: 20px; padding: 16px; flex-wrap: wrap; }

/* ---------------------------------------------------------------- calendar */
.cal-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 12px 14px; border-bottom: 1px solid var(--border); }
.cal-head h2 { min-width: 200px; }
.cal-month { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-dow { padding: 8px; font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; border-bottom: 1px solid var(--border); background: var(--surface-2); text-align: center; }
.cal-cell { min-height: 112px; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); padding: 5px; overflow: hidden; }
.cal-cell:nth-child(7n) { border-right: 0; }
.cal-cell.other { background: #fafbfd; }
.cal-cell.other .d { color: #b5bccb; }
.cal-cell.today { background: #f4f8ff; }
.cal-cell .d { font-size: 12px; font-weight: 650; margin-bottom: 3px; display: flex; justify-content: space-between; }
.cal-cell.today .d span:first-child { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 7px; }
.cal-ev { display: block; font-size: 11.5px; padding: 2px 6px; border-radius: 4px; margin-bottom: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; border-left: 3px solid; text-decoration: none !important; color: var(--text); }
.cal-more { font-size: 11.5px; color: var(--primary); cursor: pointer; padding-left: 4px; }
.ev-rent_due { background: #ebf1ff; border-color: #2459d6; }
.ev-rent_overdue { background: #fdecec; border-color: #c42b2b; }
.ev-rent_paid { background: #e6f6ef; border-color: #12805c; }
.ev-reminder { background: #f1ecfd; border-color: #6b46c1; }
.ev-agreement_start, .ev-agreement_end { background: #fff4e5; border-color: #b25e09; }
.ev-document_expiry { background: #fde8f3; border-color: #b8327a; }
.ev-followup { background: #e6f4fa; border-color: #0b6e99; }
.ev-task { background: #eef1f6; border-color: #5b6475; }
.ev-inspection, .ev-maintenance, .ev-meeting, .ev-other { background: #e9f7e9; border-color: #3d8b3d; }
.cal-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week .col { border-right: 1px solid var(--border); min-height: 420px; padding: 6px; }
.cal-week .col:last-child { border-right: 0; }
.cal-week .col h4 { font-size: 12.5px; text-align: center; padding-bottom: 6px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.cal-week .col.today h4 { color: var(--primary); }
.cal-day-list .cal-ev { white-space: normal; padding: 8px 10px; font-size: 13px; margin-bottom: 6px; }

/* ---------------------------------------------------------------- chat */
.chat { display: grid; grid-template-columns: 300px 1fr; height: calc(100vh - var(--topbar-h) - 120px); min-height: 460px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.chat-list { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 0; }
.chat-list .head { padding: 12px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 8px; }
.chat-list .items { overflow-y: auto; flex: 1; }
.chat-conv { display: flex; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.chat-conv:hover { background: var(--surface-2); }
.chat-conv.active { background: var(--primary-50); }
.chat-conv .grow b { display: block; font-size: 13.5px; font-weight: 600; }
.chat-conv .grow small { color: var(--muted); display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv .unread { background: var(--primary); color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.chat-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.chat-main .head { padding: 12px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; }
.chat-msgs { flex: 1; overflow-y: auto; padding: 16px; background: #f7f9fc; display: flex; flex-direction: column; gap: 8px; }
.msg { max-width: 70%; padding: 8px 12px; border-radius: 10px; background: #fff; border: 1px solid var(--border); align-self: flex-start; word-wrap: break-word; }
.msg.mine { align-self: flex-end; background: #dbe7ff; border-color: #c5d6fb; }
.msg .meta { font-size: 11px; color: var(--muted); margin-top: 3px; text-align: right; }
.msg .who { font-size: 11.5px; font-weight: 650; color: var(--navy-600); margin-bottom: 2px; }
.msg .att { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 8px; background: rgba(255,255,255,.7); border-radius: 6px; font-size: 12.5px; }
.msg .att img { max-width: 220px; max-height: 160px; border-radius: 5px; display: block; }
.msg mark { background: #ffe58a; }
.chat-day { text-align: center; font-size: 11.5px; color: var(--muted); margin: 6px 0; }
.chat-compose { border-top: 1px solid var(--border); padding: 10px; display: flex; gap: 8px; align-items: flex-end; background: #fff; }
.chat-compose textarea { min-height: 40px; max-height: 140px; resize: none; }
.chat-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 0 10px; }
.chat-files span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 9px; font-size: 12px; }

/* ---------------------------------------------------------------- wizard */
.steps { display: flex; gap: 0; margin-bottom: 18px; background: #fff; border: 1px solid var(--border); border-radius: var(--radius); overflow-x: auto; }
.steps .s { flex: 1; padding: 12px 14px; display: flex; gap: 9px; align-items: center; font-size: 13px; color: var(--muted); border-right: 1px solid var(--border); min-width: 140px; white-space: nowrap; }
.steps .s:last-child { border-right: 0; }
.steps .s b { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #eef1f6; color: var(--text-2); font-size: 12px; }
.steps .s.active { color: var(--text); font-weight: 600; background: var(--primary-50); }
.steps .s.active b { background: var(--primary); color: #fff; }
.steps .s.done b { background: var(--success); color: #fff; }
.pick-list { max-height: 360px; overflow: auto; border: 1px solid var(--border); border-radius: 8px; }
.pick { display: flex; gap: 10px; padding: 10px 12px; border-bottom: 1px solid var(--border); cursor: pointer; align-items: center; }
.pick:last-child { border-bottom: 0; }
.pick:hover { background: var(--surface-2); }
.pick.selected { background: var(--primary-50); }
.pdf-frame { width: 100%; height: 72vh; border: 1px solid var(--border); border-radius: 8px; background: #525659; }

/* ---------------------------------------------------------------- template editor */
.tpl-editor { display: grid; grid-template-columns: 280px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.tpl-sections { position: sticky; top: calc(var(--topbar-h) + 12px); }
.tpl-sec-item { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-bottom: 1px solid var(--border); cursor: pointer; background: #fff; font-size: 13px; }
.tpl-sec-item:hover { background: var(--surface-2); }
.tpl-sec-item.active { background: var(--primary-50); font-weight: 600; }
.tpl-sec-item.off { color: var(--muted); text-decoration: line-through; }
.tpl-sec-item .grip { cursor: grab; color: var(--muted); }
.tpl-sec-item.drag-over { border-top: 2px solid var(--primary); }
.rte-toolbar { display: flex; gap: 3px; flex-wrap: wrap; padding: 6px; border: 1px solid var(--border-strong); border-bottom: 0; border-radius: 7px 7px 0 0; background: var(--surface-2); }
.rte-toolbar button { min-width: 30px; height: 30px; border: 1px solid transparent; background: transparent; border-radius: 5px; cursor: pointer; font: inherit; font-size: 13px; }
.rte-toolbar button:hover { background: #fff; border-color: var(--border); }
.rte-toolbar .sep { width: 1px; background: var(--border); margin: 3px 3px; }
.rte { min-height: 120px; border: 1px solid var(--border-strong); border-radius: 0 0 7px 7px; padding: 10px 12px; background: #fff; font-size: 13.5px; line-height: 1.55; outline: none; overflow-wrap: anywhere; }
.rte:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-50); }
.rte p { margin: 0 0 6px; }
.merge-tag { background: #e8efff; color: #1d4bbb; border-radius: 4px; padding: 0 3px; font-family: Consolas, monospace; font-size: 12px; }
.merge-list { max-height: 420px; overflow-y: auto; }
.merge-list .grp { font-size: 11px; font-weight: 700; color: var(--muted); text-transform: uppercase; padding: 8px 10px 4px; letter-spacing: .5px; }
.merge-list button { display: flex; justify-content: space-between; width: 100%; text-align: left; padding: 6px 10px; border: 0; background: none; cursor: pointer; font: inherit; font-size: 12.5px; border-radius: 5px; }
.merge-list button:hover { background: var(--primary-50); }
.merge-list button code { font-size: 11px; color: var(--primary); }
.clause-item { border: 1px solid var(--border); border-radius: 8px; margin-bottom: 10px; background: #fff; }
.clause-item .ch { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); border-radius: 8px 8px 0 0; font-size: 12.5px; }
.clause-item .rte-toolbar { border-radius: 0; border-left: 0; border-right: 0; }
.clause-item .rte { border-radius: 0 0 8px 8px; border: 0; min-height: 60px; }

/* ---------------------------------------------------------------- public listing */
.public-body { background: #f5f6f8; }
.pub-top { background: var(--navy-800); color: #fff; padding: 14px 20px; display: flex; align-items: center; gap: 12px; }
.pub-top img { max-height: 36px; border-radius: 4px; background: #fff; }
.pub-wrap { max-width: 1120px; margin: 0 auto; padding: 22px 16px 60px; }
.pub-gallery { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; border-radius: 12px; overflow: hidden; height: 440px; }
.pub-gallery .main-img, .pub-gallery .side div { background: #dfe3ea center/cover no-repeat; cursor: zoom-in; width: 100%; height: 100%; }
.pub-gallery .side { display: grid; grid-template-rows: 1fr 1fr; gap: 8px; }
.pub-gallery .side div { position: relative; }
.pub-gallery .more { position: absolute; inset: 0; background: rgba(0,0,0,.45); color: #fff; display: grid; place-items: center; font-weight: 700; font-size: 18px; }
.pub-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 22px; margin-top: 22px; align-items: start; }
.price-card { position: sticky; top: 16px; }
.price-card .rent { font-size: 30px; font-weight: 750; color: var(--navy-800); }
.price-card .rent small { font-size: 14px; color: var(--muted); font-weight: 500; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.spec { background: var(--surface-2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.spec span { display: block; font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; }
.spec b { font-size: 15px; }
.amenities { display: flex; flex-wrap: wrap; gap: 8px; }
.amenities span { background: var(--primary-50); color: var(--primary-600); padding: 5px 11px; border-radius: 16px; font-size: 13px; }

/* ---------------------------------------------------------------- auth pages */
.auth-body { min-height: 100vh; display: grid; grid-template-columns: 1fr 1fr; background: #fff; }
.auth-side { background: radial-gradient(ellipse at top left, #2a3f73, var(--navy-900)); color: #fff; padding: 48px; display: flex; flex-direction: column; justify-content: space-between; }
.auth-side h1 { color: #fff; font-size: 34px; line-height: 1.2; margin: 24px 0 12px; }
.auth-side p { color: #b8c3dc; font-size: 15px; max-width: 440px; }
.auth-side ul { color: #c9d3ea; padding-left: 18px; line-height: 2; }
.auth-main { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-card h2 { font-size: 24px; margin-bottom: 6px; }
.auth-card .field { margin-bottom: 14px; }

/* print */
@media print {
    .sidebar, .topbar, .page-actions, .no-print, .toast-stack { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    body { background: #fff; }
    .card { border: 0; box-shadow: none; }
}

/* ---------------------------------------------------------------- responsive */
@media (max-width: 1280px) {
    .stat-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .tpl-editor { grid-template-columns: 240px minmax(0, 1fr); }
    .tpl-editor > .tpl-side { grid-column: 1 / -1; }
}
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .dash-grid > [class*="w-"] { grid-column: span 12; }
    .form-grid, .form-grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-4, .grid-5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .pub-grid { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-lg); }
    .sidebar-backdrop.open { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 35; }
    .main { margin-left: 0; }
    .only-mobile { display: grid; }
    .profile-name { display: none; }
    .content { padding: 16px 16px 40px; }
    .topbar { padding: 0 12px; gap: 8px; }
    .grid-2, .grid-3, .grid-4, .grid-5 { grid-template-columns: 1fr; }
    .span-2, .span-3 { grid-column: auto; }
    .chat { grid-template-columns: 1fr; height: auto; }
    .chat-list { max-height: 240px; border-right: 0; border-bottom: 1px solid var(--border); }
    .chat-msgs { min-height: 50vh; }
    .tpl-editor { grid-template-columns: 1fr; }
    .tpl-sections { position: static; }
    .auth-body { grid-template-columns: 1fr; }
    .auth-side { display: none; }
    .pub-gallery { grid-template-columns: 1fr; height: auto; }
    .pub-gallery .main-img { height: 260px; }
    .pub-gallery .side { grid-template-rows: none; grid-template-columns: 1fr 1fr; height: 110px; }
    .cal-cell { min-height: 74px; }
    .cal-ev { font-size: 10.5px; }
    .cal-week { grid-template-columns: 1fr; }
    .cal-week .col { min-height: 0; border-right: 0; border-bottom: 1px solid var(--border); }
    .detail-hero { flex-direction: column; }
    .detail-hero .cover { width: 100%; height: 180px; }
    .dropdown-wide { width: calc(100vw - 24px); right: -60px; }
}
@media (max-width: 600px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid, .form-grid.cols-2, .form-grid.cols-4 { grid-template-columns: 1fr; }
    .field.span-2 { grid-column: auto; }
    .page-head h1 { font-size: 19px; }
    .modal-root .backdrop { padding: 0; }
    .modal { max-height: 100vh; border-radius: 0; min-height: 100vh; }
    .msg { max-width: 88%; }
}

/* ------------------------------------------------------------ Header: greeting, refresh, notifications */
.topbar-greet { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: none; padding-right: 6px; }
.topbar-greet b { font-size: 14.5px; font-weight: 650; color: var(--text); white-space: nowrap; }
.topbar-greet small { font-size: 12px; color: var(--muted); white-space: nowrap; }
.topbar-greet .wave { display: inline-block; transform-origin: 70% 70%; animation: wave 2.4s ease-in-out 1s 2; }
@keyframes wave { 0%, 60%, 100% { transform: rotate(0); } 10%, 30% { transform: rotate(14deg); } 20% { transform: rotate(-8deg); } 40% { transform: rotate(-4deg); } 50% { transform: rotate(10deg); } }
#refreshBtn .ico { transition: transform .3s ease; }
#refreshBtn:hover .ico { transform: rotate(90deg); }
#refreshBtn.spinning .ico { animation: spin .8s linear infinite; }
#refreshBtn.spinning { color: var(--primary); background: var(--primary-50); }
.dropdown-wide .dropdown-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 14px; }
.dropdown-wide .dropdown-head span { font-size: 14.5px; }
.link-btn { border: 0; background: none; padding: 4px 6px; margin: -4px -6px; border-radius: 6px; color: var(--primary); font: inherit; font-size: 12.5px; font-weight: 600; cursor: pointer; display: inline-flex; align-items: center; gap: 4px; }
.dropdown-menu button.link-btn { width: auto; padding: 4px 6px; }
.link-btn:hover { background: var(--primary-50); }
.link-btn:disabled { opacity: .5; cursor: default; }
.dropdown-menu a.dropdown-foot { display: block; text-align: center; padding: 10px 14px; border-top: 1px solid var(--border); font-weight: 600; font-size: 13px; color: var(--primary); border-radius: 0 0 8px 8px; }
.dropdown-menu .notif-item { align-items: flex-start; }
.notif-item .t, .notif-item .m { white-space: normal; }
.app-footer a { color: var(--primary); font-weight: 600; text-decoration: none; }
.app-footer a:hover { text-decoration: underline; }
@media (max-width: 1180px) { .topbar-greet small { display: none; } }
@media (max-width: 980px) { .topbar-greet { display: none; } }

/* ------------------------------------------------------------ Floating chatbox */
.chatbox { position: fixed; right: 20px; bottom: 20px; z-index: 70; }
.chatbox-fab { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer;
    box-shadow: 0 8px 24px rgba(36, 89, 214, .35); transition: transform .15s, box-shadow .15s; position: relative; }
.chatbox-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(36, 89, 214, .45); }
.chatbox-fab .ico { width: 24px; height: 24px; }
.chatbox-fab .dot-badge { top: -2px; right: -2px; border: 2px solid #fff; height: 21px; min-width: 21px; border-radius: 11px; }
.chatbox.open .chatbox-fab { transform: scale(.92); }
.chatbox-panel { position: absolute; right: 0; bottom: 66px; width: 360px; height: min(520px, calc(100vh - 120px)); background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; box-shadow: var(--shadow-lg); display: flex; flex-direction: column; overflow: hidden; animation: pop .16s ease; }
.chatbox-panel[hidden] { display: none; }
.chatbox-head { display: flex; align-items: center; gap: 6px; padding: 10px 8px 10px 14px; background: var(--navy-800); color: #fff; }
.chatbox-head .icon-btn { color: #cfd8ea; width: 32px; height: 32px; }
.chatbox-head .icon-btn:hover { background: rgba(255,255,255,.1); color: #fff; }
.chatbox-head b { display: block; font-size: 14px; }
.chatbox-head small { display: block; font-size: 11.5px; color: #aab6cf; }
.chatbox-body { flex: 1; overflow-y: auto; background: var(--surface-2); padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.chatbox-conv { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px; border: 1px solid var(--border); background: var(--surface); border-radius: 10px; cursor: pointer; text-align: left; font: inherit; color: var(--text); }
.chatbox-conv:hover { border-color: var(--primary); }
.chatbox-conv small { display: block; color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 200px; }
.chatbox-conv .grow { min-width: 0; }
.chatbox-msg { max-width: 82%; align-self: flex-start; }
.chatbox-msg > div { background: var(--surface); border: 1px solid var(--border); border-radius: 12px 12px 12px 4px; padding: 8px 11px; font-size: 13.5px; overflow-wrap: anywhere; }
.chatbox-msg > small { display: block; font-size: 11px; color: var(--muted); margin: 2px 4px 0; }
.chatbox-msg.me { align-self: flex-end; text-align: right; }
.chatbox-msg.me > div { background: var(--primary); color: #fff; border-color: var(--primary); border-radius: 12px 12px 4px 12px; text-align: left; }
.chatbox-msg.me a { color: #fff; }
.chatbox-input { display: flex; gap: 8px; padding: 10px; border-top: 1px solid var(--border); background: var(--surface); align-items: flex-end; }
.chatbox-input[hidden] { display: none; }
.chatbox-input textarea { flex: 1; resize: none; min-height: 38px; max-height: 110px; padding: 8px 11px; border-radius: 10px; }
.chatbox-input .btn { height: 38px; width: 42px; padding: 0; justify-content: center; }
@media (max-width: 600px) {
    .chatbox { right: 14px; bottom: 14px; }
    .chatbox-panel { position: fixed; inset: 0; width: auto; height: auto; border-radius: 0; bottom: 0; }
    .chatbox.open .chatbox-fab { display: none; }
}

/* ------------------------------------------------------------ Dashboard: clickable cards, paged widgets, interactive charts */
button.stat { font: inherit; text-align: left; cursor: pointer; width: 100%; }
.stat .stat-more { font-size: 11.5px; color: var(--primary); font-weight: 600; opacity: 0; transition: opacity .15s; }
.stat:hover .stat-more, .stat:focus-visible .stat-more { opacity: 1; }
.card-head .link-btn { margin: 0; }
.widget-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 12px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.widget-foot:empty { display: none; }
.widget-foot .pager button { min-width: 26px; height: 26px; font-size: 12px; }
.mini-list.loading { opacity: .55; transition: opacity .15s; }
.chart-wrap { position: relative; }
.chart .bar { transition: opacity .12s; }
.chart.hovering .grp .bar { opacity: .4; }
.chart.hovering .grp.hl .bar { opacity: 1; }
.chart .hit { fill: transparent; cursor: pointer; }
.chart .grp.hl .hit { fill: rgba(36, 89, 214, .07); }
.chart .grp:focus { outline: none; }
.chart .grp:focus-visible .hit { stroke: var(--primary); stroke-width: 1.5; }
.chart-tip { position: absolute; pointer-events: none; background: var(--navy-800); color: #fff; border-radius: 8px; padding: 8px 10px; font-size: 12px; line-height: 1.55;
    box-shadow: var(--shadow-lg); white-space: nowrap; transform: translate(-50%, calc(-100% - 10px)); z-index: 5; opacity: 0; transition: opacity .1s; }
.chart-tip.show { opacity: 1; }
.chart-tip b { font-size: 12.5px; }
.chart-tip i { display: inline-block; width: 8px; height: 8px; border-radius: 2px; margin-right: 6px; }
.chart-tip .hint { color: #aab6cf; font-size: 11px; }
.donut-wrap { position: relative; }
.donut-wrap .seg { cursor: pointer; transition: transform .15s ease, opacity .15s; transform-origin: 80px 80px; }
.donut-wrap svg.hovering .seg { opacity: .4; }
.donut-wrap svg.hovering .seg.hl { opacity: 1; transform: scale(1.06); }
.donut-legend { display: flex; flex-direction: column; gap: 4px; }
.donut-legend button { border: 0; background: none; font: inherit; font-size: 13px; color: var(--text-2); cursor: pointer; padding: 5px 8px; border-radius: 6px; text-align: left; display: flex; align-items: center; gap: 6px; }
.donut-legend button:hover, .donut-legend button.hl { background: var(--surface-2); color: var(--text); }
.donut-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; }
.list-modal .lm-tools { display: flex; align-items: center; gap: 10px; justify-content: space-between; margin-bottom: 10px; flex-wrap: wrap; }
.list-modal .lm-tools input { max-width: 260px; }
.list-modal .lm-tabs { margin-bottom: 10px; }

/* ------------------------------------------------------------ Mobile: tables as cards */
@media (max-width: 700px) {
    .table-wrap { overflow: visible; }
    table.table:not(.no-cards), table.table:not(.no-cards) tbody, table.table:not(.no-cards) tr, table.table:not(.no-cards) td { display: block; width: 100%; }
    table.table:not(.no-cards) thead { display: none; }
    table.table:not(.no-cards) tbody tr { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; margin: 0 0 10px; padding: 6px 12px; box-shadow: var(--shadow-sm); }
    table.table:not(.no-cards) tbody tr[hidden] { display: none; }
    table.table:not(.no-cards) td { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); text-align: right; }
    table.table:not(.no-cards) td:last-child { border-bottom: 0; }
    table.table:not(.no-cards) td::before { content: attr(data-label); flex: none; max-width: 45%; text-align: left; font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; padding-top: 2px; }
    table.table:not(.no-cards) td[data-label=""]::before, table.table:not(.no-cards) td:not([data-label])::before { display: none; }
    table.table:not(.no-cards) td.actions { width: 100%; justify-content: flex-end; }
    table.table:not(.no-cards) td.table-empty { justify-content: center; text-align: center; border: 0; }
    table.table:not(.no-cards) td.table-empty::before { display: none; }
    table.table:not(.no-cards) .cell-sub { text-align: right; }
    .table-foot { flex-direction: column; gap: 8px; align-items: center; }
    .chart-tip { white-space: normal; max-width: 220px; }
}
.dash-grid > .card + .card, .stat-grid + .dash-grid > .card { margin-top: 0; }
.stat .label { padding-right: 42px; line-height: 1.35; }
.chart-tip { transform: none; }
.chart-tip.left { transform: translateX(-100%); }
@media (max-width: 700px) {
    table.table:not(.no-cards) td { display: block; text-align: right; }
    table.table:not(.no-cards) td::before { float: left; margin-right: 12px; }
    table.table:not(.no-cards) td::after { content: ""; display: table; clear: both; }
    table.table:not(.no-cards) td.actions { display: flex; }
    table.table:not(.no-cards) td.actions::after { display: none; }
}
body:has(.chatbox) .content { padding-bottom: 88px; }
@media (max-width: 600px) { .stat .stat-more { display: none; } }

/* ------------------------------------------------------------ Notification bell: rings on hover / when opened */
@keyframes bell-ring {
    0%, 100% { transform: rotate(0); }
    10% { transform: rotate(16deg); } 20% { transform: rotate(-14deg); } 30% { transform: rotate(11deg); }
    40% { transform: rotate(-8deg); } 50% { transform: rotate(5deg); } 60% { transform: rotate(-3deg); } 70% { transform: rotate(1deg); }
}
#notifDropdown > .icon-btn .ico { transform-origin: 50% 2px; }
#notifDropdown > .icon-btn:hover .ico, #notifDropdown > .icon-btn:focus-visible .ico, #notifDropdown.ringing > .icon-btn .ico { animation: bell-ring .9s ease-in-out; }
#notifDropdown > .icon-btn:hover .dot-badge { animation: pop .3s ease; }
@media (prefers-reduced-motion: reduce) {
    #notifDropdown > .icon-btn .ico, #refreshBtn.spinning .ico, .topbar-greet .wave { animation: none !important; }
}

/* ------------------------------------------------------------ Mobile layout hardening (also holds with large system text sizes) */
.main { overflow-x: clip; }
.stat .value { overflow-wrap: anywhere; line-height: 1.15; }
@media (max-width: 700px) {
    .card-head { flex-wrap: wrap; row-gap: 6px; }
    .card-head .legend { gap: 10px; font-size: 12px; }
    .page-actions { width: 100%; }
    .chip-row { gap: 6px; }
    .chip-row .chip { padding: 5px 11px; }
    /* search collapses to an icon and expands over the top bar when tapped */
    .topbar { position: sticky; }
    .global-search { flex: 0 0 40px; max-width: 40px; }
    .global-search input[type=search] { padding-left: 34px; padding-right: 0; color: transparent; cursor: pointer; background: transparent; border-color: transparent; }
    .global-search input[type=search]::placeholder { color: transparent; }
    .global-search > .ico { left: 11px; pointer-events: none; color: var(--text-2); }
    .global-search:focus-within { position: absolute; left: 8px; right: 8px; max-width: none; z-index: 40; }
    .global-search:focus-within input[type=search] { color: var(--text); cursor: text; background: #fff; border-color: var(--primary); padding-right: 12px; }
    .global-search:focus-within input[type=search]::placeholder { color: var(--muted); }
    .global-search:focus-within > .ico { color: var(--muted); }
    .topbar-right { gap: 2px; }
}
@media (max-width: 600px) {
    .content { padding: 14px 12px 88px; }
    .page-head { gap: 10px; }
    .page-head .sub { font-size: 12.5px; }
    .stat-grid { gap: 10px; margin-bottom: 14px; }
    .stat { padding: 11px 12px; gap: 2px; min-width: 0; }
    .stat .label { font-size: 10.5px; letter-spacing: .3px; padding-right: 32px; min-height: 2.7em; }
    .stat .value { font-size: clamp(15px, 4.6vw, 20px); letter-spacing: -.2px; }
    .stat .stat-ico { width: 26px; height: 26px; right: 9px; top: 9px; border-radius: 7px; }
    .stat .stat-ico .ico { width: 15px; height: 15px; }
    .dash-grid { gap: 12px; }
    .mini-list li { padding: 9px 12px; }
    .donut-wrap { justify-content: center; }
    .card-head { padding: 11px 12px; }
    .card-body { padding: 12px; }
    .chatbox-fab { width: 50px; height: 50px; }
}
@media (max-width: 360px) {
    .stat-grid { grid-template-columns: 1fr 1fr; }
    .stat .value { font-size: 15px; }
    .topbar { padding: 0 6px; }
}
@media (max-width: 420px) { .stat .stat-ico { display: none; } .stat .label { padding-right: 0; } }

/* ------------------------------------------------------------ Tenant portal in the admin-style shell */
.portal-app .content.portal-content { max-width: 1180px; width: 100%; }
.portal-app .sidebar .brand { text-decoration: none; color: inherit; }
button.nav-item { border: 0; background: none; width: 100%; font: inherit; cursor: pointer; text-align: left; }
.portal-app .content h1 { font-size: 22px; }
.portal-app .content > div > .card + .card, .portal-app #pdBody > .card + .card { margin-top: 16px; }
.dropdown-menu { z-index: 80; }

/* change requests: tenant status + admin review */
.change-status { display: flex; gap: 12px; align-items: flex-start; flex-wrap: wrap; margin-bottom: 16px; }
.change-list { margin: 8px 0 0; padding: 0; list-style: none; display: grid; gap: 4px; font-size: 13px; }
.change-list li span { display: inline-block; min-width: 130px; color: var(--text-2); font-weight: 600; }
.cr-card { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.cr-head { display: flex; justify-content: space-between; gap: 10px; padding: 10px 14px; background: var(--surface-2); border-bottom: 1px solid var(--border); }
.cr-table td, .cr-table th { padding: 8px 12px; }
.cr-table .cr-old { color: var(--muted); text-decoration: line-through; text-decoration-color: rgba(122,133,153,.5); }
.cr-table .cr-new b { color: var(--success); }
.cr-actions { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--border); flex-wrap: wrap; align-items: center; }
.cr-actions input { flex: 1; min-width: 200px; }
.cr-actions input.is-invalid { border-color: var(--danger); box-shadow: 0 0 0 3px var(--danger-50); }

/* chatbox tabs (admin: agents / tenants) */
.chatbox-tabs { display: flex; gap: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 3px; margin-bottom: 4px; }
.chatbox-tabs button { flex: 1; border: 0; background: none; padding: 7px; border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chatbox-tabs button.active { background: var(--navy-800); color: #fff; }
.chatbox-list { display: flex; flex-direction: column; gap: 8px; }
@media (max-width: 600px) { .change-list li span { min-width: 0; display: block; } }
.chatbox-search { width: 100%; margin-bottom: 4px; padding: 8px 11px; border-radius: 10px; }
.grid > .card + .card, .grid > .card { margin-top: 0; }
.chatbox-empty { margin: auto; text-align: center; padding: 24px 12px; display: grid; gap: 10px; justify-items: center; }
.chatbox-hello { border: 1px solid var(--primary); background: var(--surface); color: var(--primary); font: inherit; font-weight: 600; font-size: 14px; padding: 9px 18px; border-radius: 20px; cursor: pointer; transition: background .15s, color .15s, transform .15s; }
.chatbox-hello:hover { background: var(--primary); color: #fff; transform: translateY(-1px); }
.chatbox-hello:disabled { opacity: .6; cursor: default; transform: none; }

/* chat: unread badges on the Agents / Tenants tabs, new-message preview, bubble pulse */
.tab-badge { display: inline-grid; place-items: center; min-width: 19px; height: 19px; padding: 0 5px; margin-left: 6px; border-radius: 10px; background: #e5484d; color: #fff; font-size: 11px; font-weight: 700; vertical-align: 1px; }
.chatbox-conv:has(.nav-badge) { border-color: #f3b4b6; background: #fff7f7; }
.chatbox-conv:has(.nav-badge) small { color: var(--text); font-weight: 600; }
.chatbox-peek { position: absolute; right: 0; bottom: 66px; width: 300px; max-width: calc(100vw - 28px); display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    background: var(--surface); border: 1px solid var(--border); border-left: 4px solid var(--primary); border-radius: 12px; box-shadow: var(--shadow-lg);
    font: inherit; text-align: left; color: var(--text); cursor: pointer; animation: peek-in .25s ease; }
.chatbox-peek[hidden] { display: none; }
.chatbox-peek .grow { min-width: 0; }
.chatbox-peek b { display: block; font-size: 13.5px; }
.chatbox-peek small { display: block; color: var(--text-2); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chatbox-peek-x { flex: none; width: 24px; height: 24px; display: grid; place-items: center; border-radius: 6px; color: var(--muted); font-size: 18px; line-height: 1; }
.chatbox-peek-x:hover { background: var(--surface-2); color: var(--text); }
.chatbox-peek:hover { border-color: var(--primary); }
@keyframes peek-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }
@keyframes fab-pulse { 0% { box-shadow: 0 0 0 0 rgba(36, 89, 214, .55); } 70% { box-shadow: 0 0 0 16px rgba(36, 89, 214, 0); } 100% { box-shadow: 0 0 0 0 rgba(36, 89, 214, 0); } }
.chatbox.pulse .chatbox-fab { animation: fab-pulse 1.4s ease-out 3; }
.chatbox.open .chatbox-peek { display: none; }
@media (prefers-reduced-motion: reduce) { .chatbox.pulse .chatbox-fab, .chatbox-peek { animation: none; } }

/* ------------------------------------------------------------ Chat page v2 (agents + tenants) */
.chat.chat-v2 { grid-template-columns: 340px 1fr; height: calc(100vh - var(--topbar-h) - 150px); min-height: 520px; border-radius: 12px; box-shadow: var(--shadow-sm); }
.chat-v2 .chat-list { background: var(--surface); }
.chat-tabs { display: flex; gap: 4px; margin: 12px 12px 0; padding: 3px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; }
.chat-tabs button { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; border: 0; background: none; padding: 8px; border-radius: 8px;
    font: inherit; font-size: 13.5px; font-weight: 600; color: var(--text-2); cursor: pointer; }
.chat-tabs button.active { background: var(--navy-800); color: #fff; box-shadow: var(--shadow-sm); }
.chat-tabs .tab-badge { margin-left: 2px; }
.chat-list-search { position: relative; margin: 10px 12px; }
.chat-list-search .ico { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); pointer-events: none; }
.chat-list-search input { width: 100%; padding-left: 34px; border-radius: 10px; background: var(--surface-2); }
.chat-v2 .chat-list .items { padding: 0 8px 8px; }
.chat-v2 .chat-conv { width: 100%; border: 0; border-radius: 10px; margin-bottom: 2px; background: none; font: inherit; color: var(--text); text-align: left; padding: 10px; }
.chat-v2 .chat-conv:hover { background: var(--surface-2); }
.chat-v2 .chat-conv.active { background: var(--primary-50); box-shadow: inset 3px 0 0 var(--primary); }
.chat-v2 .chat-conv .grow { min-width: 0; display: grid; gap: 2px; }
.chat-conv-top, .chat-conv-sub { display: flex; align-items: center; gap: 8px; justify-content: space-between; min-width: 0; }
.chat-conv-top b { font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-conv-top small { flex: none; font-size: 11px; color: var(--muted); }
.chat-conv-sub small { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-v2 .chat-conv.has-unread .chat-conv-sub small { color: var(--text); font-weight: 600; }
.chat-v2 .chat-conv.has-unread .chat-conv-top small { color: var(--primary); font-weight: 600; }
.chat-v2 .chat-conv .unread { flex: none; background: #e5484d; color: #fff; border-radius: 10px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.chat-empty-list { padding: 28px 16px; text-align: center; color: var(--muted); font-size: 13px; }
.chat-v2 .chat-head { padding: 10px 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; background: var(--surface); }
.chat-v2 .chat-head[hidden] { display: none; }
.chat-v2 .chat-head .avatar { width: 38px; height: 38px; }
.chat-head-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.chat-back { display: none; }
.chat-v2 .chat-msgs { background: #f4f6fa; padding: 18px 20px; gap: 6px; }
.chat-v2 .msg { max-width: min(560px, 72%); padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px; box-shadow: 0 1px 1px rgba(16,24,40,.05); }
.chat-v2 .msg.mine { background: var(--primary); border-color: var(--primary); color: #fff; border-radius: 14px 14px 4px 14px; }
.chat-v2 .msg.mine .meta { color: rgba(255,255,255,.8); }
.chat-v2 .msg.mine a { color: #fff; }
.chat-v2 .msg.mine .att { background: rgba(255,255,255,.15); }
.chat-v2 .msg .rr { margin-left: 2px; letter-spacing: -2px; }
.chat-v2 .msg .rr.read { color: #9ff0c6; }
.chat-v2 .chat-day { display: flex; justify-content: center; margin: 10px 0 4px; }
.chat-v2 .chat-day span, .chat-v2 .chat-day a { background: #e3e8f1; color: var(--text-2); border-radius: 12px; padding: 3px 12px; font-size: 11.5px; font-weight: 600; }
.chat-placeholder { margin: auto; display: grid; justify-items: center; gap: 8px; text-align: center; padding: 30px 16px; max-width: 360px; }
.chat-placeholder b { font-size: 16px; }
.chat-placeholder-ico { width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; background: var(--primary-50); color: var(--primary); }
.chat-placeholder-ico .ico { width: 28px; height: 28px; }
.chat-v2 .chat-compose { padding: 10px 12px; gap: 8px; align-items: flex-end; }
.chat-v2 .chat-compose textarea { border-radius: 12px; padding: 10px 12px; }
.chat-v2 .chat-compose .btn-primary { height: 42px; width: 46px; justify-content: center; border-radius: 12px; }
.chat-v2 .chat-compose label[hidden] { display: none; }
@media (max-width: 860px) {
    .chat.chat-v2 { grid-template-columns: 1fr; height: calc(100vh - var(--topbar-h) - 130px); }
    .chat-v2 .chat-list { max-height: none; border-right: 0; border-bottom: 0; }
    .chat-v2 .chat-main { display: none; }
    .chat-v2.thread-open .chat-list { display: none; }
    .chat-v2.thread-open .chat-main { display: flex; }
    .chat-back { display: grid; }
    .chat-v2 .chat-msgs { min-height: 0; padding: 14px 12px; }
    .chat-v2 .msg { max-width: 86%; }
    .chat-head-actions .btn { padding: 5px 9px; font-size: 12px; }
}

/* chatbox attachments */
.chatbox-attach { flex: none; width: 38px; height: 38px; display: grid; place-items: center; border-radius: 10px; color: var(--text-2); cursor: pointer; }
.chatbox-attach:hover { background: var(--surface-2); color: var(--primary); }
.chatbox-files { display: flex; gap: 6px; flex-wrap: wrap; padding: 8px 10px 0; background: var(--surface); border-top: 1px solid var(--border); }
.chatbox-files[hidden] { display: none; }
.chatbox-files span { background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; padding: 2px 9px; font-size: 12px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chatbox-files + .chatbox-input { border-top: 0; }
.chatbox-img { display: block; margin-top: 6px; }
.chatbox-img img { display: block; max-width: 220px; max-height: 180px; border-radius: 8px; }
.chatbox-file { display: flex; gap: 6px; align-items: center; margin-top: 6px; padding: 6px 8px; border-radius: 8px; background: rgba(0,0,0,.04); font-size: 12.5px; text-decoration: none; overflow-wrap: anywhere; }
.chatbox-msg.me .chatbox-file { background: rgba(255,255,255,.18); color: #fff; }
.chatbox-file small { opacity: .75; }
.chatbox-msg .chatbox-img { display: block; margin-top: 6px; }
.chatbox-msg .chatbox-img img { display: block; max-width: 220px; max-height: 180px; border-radius: 8px; object-fit: cover; }
.chatbox-msg .chatbox-file { display: flex; align-items: center; gap: 6px; margin-top: 6px; padding: 6px 9px; border-radius: 8px; background: var(--surface-2); color: var(--text); font-size: 12.5px; text-decoration: none; overflow-wrap: anywhere; }
.chatbox-msg .chatbox-file small { color: var(--muted); white-space: nowrap; }
.chatbox-msg.me .chatbox-file { background: rgba(255,255,255,.18); color: #fff; }
.chatbox-msg.me .chatbox-file small { color: rgba(255,255,255,.75); }
/* uploaded logo / app icon in the sidebar and portal header */
.brand-mark.custom-logo { background: #fff; border-radius: 9px; padding: 2px; }
.brand-mark.custom-logo img { object-fit: contain; }
.brand-cards { display: grid; gap: 16px; align-content: start; }
.brand-cards .card + .card { margin-top: 0; }
.brand-preview { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-radius: 10px; background: var(--navy-800); }
.brand-preview .brand-text strong { color: #fff; font-size: 16px; }
.brand-preview .brand-mark { width: 38px; height: 38px; flex: none; }
