/* ============================================================================
   HOMESLY DESIGN SYSTEM v2
   ============================================================================
   Layout: CSS grid — sidebar | main
   Pages:  Each page owns a named CSS grid layout
   Inside: Generic component classes (.panel, .stat-tile, .badge, etc.)
   Rule:   Layouts size the cells. Components fill them. No inline styles.
   ============================================================================ */

:root {
    --ink:        #0F1419;
    --ink-80:     #2C3338;
    --ink-60:     #536471;
    --ink-40:     #8B98A5;
    --ink-20:     #C4CCD2;
    --ink-10:     #E1E8ED;
    --ink-05:     #EFF3F4;
    --ink-02:     #F7F9F9;
    --white:      #FFFFFF;

    --accent:      #0D9488;
    --accent-dark: #0F766E;
    --accent-light:#CCFBF1;
    --accent-muted:#F0FDFA;

    --red:         #DC2626;  --red-light:   #FEF2F2;
    --amber:       #D97706;  --amber-light: #FFFBEB;
    --green:       #059669;  --green-light: #ECFDF5;
    --blue:        #2563EB;  --blue-light:  #EFF6FF;

    --sidebar-w:   260px;
    --header-h:    64px;
    --gap:         16px;
    --radius:      6px;
    --radius-lg:   10px;

    --shadow-sm:   0 1px 2px rgba(15,20,25,0.06);
    --shadow-md:   0 2px 8px rgba(15,20,25,0.08);
    --shadow-lg:   0 4px 16px rgba(15,20,25,0.1);

    --font: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, sans-serif;
    --mono: 'JetBrains Mono', ui-monospace, monospace;
}

body {
    font-family: var(--font);
    background: var(--ink-02);
    color: var(--ink);
    overflow-x: hidden;
}

/* ━━━ SHELL ━━━ */
.shell { min-height: 100vh; }

/* ━━━ SIDEBAR ━━━ */
.sidebar { background: var(--white); border-right: 1px solid var(--ink-10); display: flex; flex-direction: column; position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 100; }
.sidebar-brand { height: var(--header-h); display: flex; align-items: center; padding: 0 24px; border-bottom: 1px solid var(--ink-10); gap: 10px; flex-shrink: 0; }
.sidebar-brand svg { flex-shrink: 0; }
.brand-text { font-size: 17px; font-weight: 800; letter-spacing: -0.03em; }
.brand-tag { font-size: 10px; font-weight: 600; color: var(--accent); background: var(--accent-light); padding: 2px 6px; border-radius: 3px; letter-spacing: 0.04em; text-transform: uppercase; margin-left: auto; }
.sidebar-nav { flex: 1; padding: 16px 12px; overflow-y: auto; }
.nav-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--ink-40); padding: 12px 12px 6px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: var(--radius); cursor: pointer; color: var(--ink-60); font-weight: 500; font-size: 13px; transition: all 0.12s; position: relative; user-select: none; }
.nav-item:hover { background: var(--ink-05); color: var(--ink); }
.nav-item.active { background: var(--accent-muted); color: var(--accent-dark); font-weight: 600; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 6px; bottom: 6px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-icon { width: 18px; height: 18px; flex-shrink: 0; opacity: 0.7; }
.nav-item.active .nav-icon { opacity: 1; }
.nav-badge { margin-left: auto; background: var(--red); color: var(--white); font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 10px; min-width: 18px; text-align: center; }
.sidebar-footer { padding: 16px; border-top: 1px solid var(--ink-10); flex-shrink: 0; }
.user-card { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: var(--radius); cursor: pointer; transition: background 0.12s; }
.user-card:hover { background: var(--ink-05); }
.user-avatar { width: 32px; height: 32px; border-radius: 50%; background: linear-gradient(135deg, var(--accent), var(--accent-dark)); display: flex; align-items: center; justify-content: center; color: white; font-weight: 700; font-size: 12px; flex-shrink: 0; }
.user-info { flex: 1; min-width: 0; }
.user-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: var(--ink-40); }

/* ━━━ MAIN ━━━ */
.main { margin-left: var(--sidebar-w); min-height: 100vh; display: flex; flex-direction: column; }

/* ━━━ TOP BAR ━━━ */
.top-bar { height: var(--header-h); background: var(--white); border-bottom: 1px solid var(--ink-10); display: flex; align-items: center; padding: 0 32px; position: sticky; top: 0; z-index: 50; gap: 16px; flex-shrink: 0; }
.breadcrumb a { color: var(--ink-40); text-decoration: none; }
.breadcrumb a:hover { color: var(--ink-60); }
.breadcrumb .sep { color: var(--ink-20); }
.breadcrumb .current { color: var(--ink); font-weight: 600; }
.top-bar-title { font-size: 15px; font-weight: 700; color: var(--ink); }
.top-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

/* Search */
.search-box { display: flex; align-items: center; background: var(--ink-02); border: 1px solid var(--ink-10); border-radius: var(--radius); padding: 0 12px; height: 36px; width: 280px; transition: all 0.15s; position: relative; }
.search-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,0.08); background: var(--white); }
.search-box svg { color: var(--ink-40); flex-shrink: 0; }
.search-box input { border: none; outline: none; background: transparent; font-family: var(--font); font-size: 13px; color: var(--ink); width: 100%; padding: 0 8px; }
.search-box input::placeholder { color: var(--ink-40); }

/* Search dropdown */
.search-dropdown { position: absolute; top: 100%; margin-top: 8px; left: auto; right: 0; background: var(--white); border: 1px solid var(--ink-10); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); max-height: 420px; overflow: hidden; display: none; z-index: 200; min-width: 400px; }
.search-dropdown.active { display: block; }
.search-tabs { display: flex; border-bottom: 1px solid var(--ink-10); }
.search-tab { padding: 10px 16px; font-size: 12px; font-weight: 600; color: var(--ink-40); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.12s; }
.search-tab:hover { color: var(--ink); }
.search-tab.active { color: var(--accent-dark); border-color: var(--accent); }
.search-tab-count { font-size: 10px; background: var(--ink-05); padding: 1px 5px; border-radius: 3px; margin-left: 4px; }
.search-tab.active .search-tab-count { background: var(--accent-light); color: var(--accent-dark); }
.search-results { max-height: 360px; overflow-y: auto; }
.search-results-empty { padding: 32px; text-align: center; color: var(--ink-40); font-size: 13px; }
.search-result-item { display: flex; align-items: center; gap: 12px; padding: 10px 16px; cursor: pointer; transition: background 0.1s; border-bottom: 1px solid var(--ink-05); }
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover { background: var(--ink-02); }
.search-result-icon { width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 14px; }
.search-result-body { flex: 1; min-width: 0; }
.search-result-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.search-result-sub { font-size: 11px; color: var(--ink-40); }
.search-result-end { flex-shrink: 0; }
.search-loading { padding: 24px; text-align: center; color: var(--ink-40); font-size: 12px; }

/* Icon buttons */
.icon-btn { width: 36px; height: 36px; border: 1px solid var(--ink-10); background: var(--white); border-radius: var(--radius); display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--ink-60); transition: all 0.12s; position: relative; }
.icon-btn:hover { background: var(--ink-05); color: var(--ink); border-color: var(--ink-20); }
.icon-btn .dot { position: absolute; top: 6px; right: 6px; width: 7px; height: 7px; background: var(--red); border-radius: 50%; border: 1.5px solid var(--white); }

/* ━━━ PAGE BASE ━━━ */
.page { flex: 1; padding: 28px 32px 48px; }
.page-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; gap: 16px;  position: relative; z-index: 10; }
.page-title { font-size: 22px; font-weight: 800; letter-spacing: -0.03em; margin-bottom: 4px; }
.page-subtitle { font-size: 13px; color: var(--ink-40); }
.page-actions { display: flex; gap: 8px; flex-shrink: 0; }

/* ━━━ PAGE-LEVEL GRID LAYOUTS ━━━ */
.lay-dash {
    display: grid; gap: var(--gap);
    grid-template-columns: repeat(4, 1fr);
    grid-template-areas:
        "s1     s2     s3     s4"
        "chart  chart  chart  donut"
        "feed   feed   assign assign";
}
.lay-dash > :nth-child(1) { grid-area: s1; }
.lay-dash > :nth-child(2) { grid-area: s2; }
.lay-dash > :nth-child(3) { grid-area: s3; }
.lay-dash > :nth-child(4) { grid-area: s4; }
.lay-dash > :nth-child(5) { grid-area: chart; }
.lay-dash > :nth-child(6) { grid-area: donut; }
.lay-dash > :nth-child(7) { grid-area: feed; }
.lay-dash > :nth-child(8) { grid-area: assign; }

.lay-report-summary {
    display: grid; gap: var(--gap);
    grid-template-columns: auto repeat(4, 1fr);
    grid-template-areas: "score issues cost frames duration";
}
.lay-team { display: grid; gap: var(--gap); grid-template-columns: 1fr; }
.lay-props { display: grid; gap: var(--gap); grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }

@media (max-width: 1200px) {
    .lay-dash { grid-template-columns: 1fr 1fr; grid-template-areas: "s1 s2" "s3 s4" "chart chart" "donut donut" "feed feed" "assign assign"; }
    .lay-report-summary { grid-template-columns: repeat(3,1fr); grid-template-areas: "score issues cost" "score frames duration"; }
}

/* ━━━ GENERIC COMPONENTS ━━━ */

/* Buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 16px; font-family: var(--font); font-size: 13px; font-weight: 600; border-radius: var(--radius); cursor: pointer; transition: all 0.12s; border: 1px solid transparent; white-space: nowrap; }
.btn svg { width: 15px; height: 15px; }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-primary { background: var(--accent); color: var(--white); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-secondary { background: var(--white); color: var(--ink); border-color: var(--ink-10); }
.btn-secondary:hover { background: var(--ink-05); border-color: var(--ink-20); }
.btn-secondary.btn-active { background: var(--accent-muted); border-color: var(--accent); color: var(--accent-dark); }

/* Stat tile */
.stat-tile { background: var(--white); border: 1px solid var(--ink-10); border-radius: var(--radius-lg); padding: 20px; transition: box-shadow 0.15s; min-width: 0; }
.stat-tile:hover { box-shadow: var(--shadow-md); }
.stat-tile-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.stat-tile-label { font-size: 12px; font-weight: 600; color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.04em; }
.stat-tile-icon { width: 32px; height: 32px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.stat-tile-value { font-family: var(--mono); font-size: 28px; font-weight: 600; color: var(--ink); letter-spacing: -0.04em; line-height: 1; margin-bottom: 6px; }

/* Panel */
.panel { background: var(--white); border: 1px solid var(--ink-10); border-radius: var(--radius-lg); min-width: 0; display: flex; flex-direction: column; }
.panel-header { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--ink-10); flex-shrink: 0; gap: 12px; flex-wrap: wrap; }
.panel-title { font-size: 14px; font-weight: 700; letter-spacing: -0.01em; }
.panel-body { padding: 20px; flex: 1; min-height: 0; }
.panel-body--flush { padding: 0; flex: 1; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; border-radius: 4px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.badge-green { background: var(--green-light); color: var(--green); }
.badge-amber { background: var(--amber-light); color: var(--amber); }
.badge-red { background: var(--red-light); color: var(--red); }
.badge-blue { background: var(--blue-light); color: var(--blue); }
.badge-gray { background: var(--ink-05); color: var(--ink-60); }
.badge-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.badge-overlay { backdrop-filter: blur(8px); }
.badge-ol-green { background: rgba(5,150,105,0.9); color: white; }
.badge-ol-amber { background: rgba(217,119,6,0.9); color: white; }
.badge-ol-gray { background: rgba(107,114,128,0.9); color: white; }

/* Chips */
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { padding: 6px 14px; border-radius: var(--radius); font-size: 12px; font-weight: 600; border: 1px solid var(--ink-10); background: var(--white); color: var(--ink-60); cursor: pointer; transition: all 0.12s; }
.chip:hover { border-color: var(--ink-20); color: var(--ink); }
.chip.active { background: var(--ink); color: var(--white); border-color: var(--ink); }

/* Tabs */
.tabs { display: flex; border-bottom: 1px solid var(--ink-10); }
.tab { padding: 12px 20px; font-size: 13px; font-weight: 500; color: var(--ink-40); cursor: pointer; border-bottom: 2px solid transparent; transition: all 0.12s; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--accent-dark); border-color: var(--accent); font-weight: 600; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; }
.tbl th { text-align: left; font-size: 11px; font-weight: 700; color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.06em; padding: 10px 16px; border-bottom: 1px solid var(--ink-10); background: var(--ink-02); }
.tbl td { padding: 12px 16px; font-size: 13px; border-bottom: 1px solid var(--ink-05); vertical-align: middle; }
.tbl tr:last-child td { border-bottom: none; }
.tbl tr:hover td { background: var(--ink-02); }
.tbl-primary { font-weight: 600; }
.tbl-sub { font-size: 12px; color: var(--ink-40); margin-top: 1px; }
.tbl-null { color: var(--ink-40); font-family: var(--mono); }

/* Progress */
.progress { height: 6px; background: var(--ink-05); border-radius: 3px; overflow: hidden; }
.progress-fill { height: 100%; border-radius: 3px; transition: width 0.6s cubic-bezier(0.16,1,0.3,1); }
.progress-sm { height: 4px; }

/* Score ring */

/* Feed */
.feed-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--ink-05); }
.feed-item:last-child { border-bottom: none; }
.feed-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.feed-dot.scan { background: var(--accent); }
.feed-dot.alert { background: var(--red); }
.feed-dot.update { background: var(--blue); }
.feed-dot.complete { background: var(--green); }
.feed-text { font-size: 13px; color: var(--ink-80); }
.feed-text strong { color: var(--ink); font-weight: 600; }
.feed-time { font-size: 11px; color: var(--ink-40); margin-top: 2px; }

/* List rows */
.list-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--ink-05); transition: background 0.1s; cursor: pointer; }
.list-row:last-child { border-bottom: none; }
.list-row:hover { background: var(--ink-02); }
.list-icon { width: 40px; height: 40px; border-radius: var(--radius); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.list-icon-lg { width: 56px; height: 40px; }
.list-body { flex: 1; min-width: 0; }
.list-title { font-size: 13px; font-weight: 600; }
.list-meta { font-size: 12px; color: var(--ink-40); display: flex; gap: 12px; margin-top: 2px; flex-wrap: wrap; }
.list-end { flex-shrink: 0; }

/* Member rows */
.member-row { display: flex; align-items: center; gap: 14px; padding: 14px 20px; border-bottom: 1px solid var(--ink-05); }
.member-row:last-child { border-bottom: none; }
.member-avatar-lg { width: 36px; height: 36px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 13px; color: var(--white); flex-shrink: 0; }
.member-info { flex: 1; min-width: 0; }
.member-name { font-size: 13px; font-weight: 600; }
.member-role { font-size: 12px; color: var(--ink-40); }
.member-stats { display: flex; gap: 20px; text-align: center; }
.member-stat-val { font-family: var(--mono); font-size: 15px; font-weight: 600; }
.member-stat-label { font-size: 10px; color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.04em; }

/* Property cards */
.prop-card { background: var(--white); border: 1px solid var(--ink-10); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: all 0.15s; }
.prop-card:hover { box-shadow: var(--shadow-lg); border-color: var(--ink-20); transform: translateY(-2px); }
.prop-card-img { height: 180px; position: relative; overflow: hidden; }
.prop-card-overlay { position: absolute; inset: 0; background: linear-gradient(to top, rgba(15,20,25,0.7) 0%, transparent 50%); }
.prop-card-badges { position: absolute; top: 12px; right: 12px; display: flex; gap: 6px; }
.prop-card-price { position: absolute; bottom: 12px; left: 16px; color: var(--white); }
.prop-card-price-val { font-family: var(--mono); font-size: 20px; font-weight: 700; letter-spacing: -0.02em; }
.prop-card-price-label { font-size: 11px; opacity: 0.7; }
.prop-card-body { padding: 16px; overflow: hidden; }
.prop-card-address { font-size: 15px; font-weight: 700; margin-bottom: 4px; letter-spacing: -0.01em; }
.prop-card-location { font-size: 12px; color: var(--ink-40); margin-bottom: 14px; }
.prop-card-specs { display: flex; gap: 16px; padding-top: 12px; border-top: 1px solid var(--ink-05); flex-wrap: wrap; }
.prop-spec { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--ink-60); font-weight: 500; }
.prop-spec--end { margin-left: auto; font-weight: 600; }

/* Chart */
.chart-area { position: relative; height: 220px; }
.chart-bars { display: flex; align-items: flex-end; gap: 8px; height: 180px; }
.chart-bar-group { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.chart-bar { width: 100%; border-radius: 3px 3px 0 0; transition: height 0.5s cubic-bezier(0.16,1,0.3,1); }
.chart-bar.primary { background: var(--accent); }
.chart-label { font-size: 11px; color: var(--ink-40); font-weight: 500; }

/* Donut */
.donut-wrap { display: flex; align-items: center; justify-content: center; }
.donut-chart { position: relative; width: 120px; height: 120px; }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut-val { font-family: var(--mono); font-size: 24px; font-weight: 700; }
.donut-label { font-size: 10px; color: var(--ink-40); text-transform: uppercase; letter-spacing: 0.04em; }

/* Issue bar */
.issue-bar { display: flex; height: 8px; border-radius: 4px; overflow: hidden; margin: 16px 0 12px; }
.issue-seg { transition: width 0.4s ease; }
.issue-seg.critical { background: var(--red); }
.issue-seg.major { background: var(--amber); }
.issue-seg.minor { background: var(--blue); }
.issue-seg.cosmetic { background: var(--ink-20); }
.issue-legend { display: flex; gap: 16px; flex-wrap: wrap; }
.issue-legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-60); }
.issue-legend-dot { width: 8px; height: 8px; border-radius: 2px; }

/* Upload zone */
.upload-zone { border: 2px dashed var(--ink-20); border-radius: var(--radius-lg); padding: 40px; text-align: center; cursor: pointer; transition: all 0.15s; background: var(--white); margin-bottom: var(--gap); }
.upload-zone:hover { border-color: var(--accent); background: var(--accent-muted); }
.upload-zone svg { color: var(--ink-40); margin: 0 auto 12px; }
.upload-zone-title { font-size: 14px; font-weight: 600; margin-bottom: 4px; }
.upload-zone-sub { font-size: 12px; color: var(--ink-40); }

/* Utility */
.mono { font-family: var(--mono); }
.mb-gap { margin-bottom: var(--gap); }
.link { cursor: pointer; color: var(--accent); }
.link:hover { color: var(--accent-dark); text-decoration: underline; }
.text-muted { color: var(--ink-40); }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--ink-20); border-radius: 3px; }

/* Animation */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
.anim { animation: fadeUp 0.35s cubic-bezier(0.16,1,0.3,1) both; }
.d1 { animation-delay: 0.05s; } .d2 { animation-delay: 0.1s; } .d3 { animation-delay: 0.15s; } .d4 { animation-delay: 0.2s; }

/* Loading overlay */
#myLoading { display: none; position: fixed; inset: 0; background: rgba(255,255,255,0.8); z-index: 9999; backdrop-filter: blur(2px); }
#myLoading::after { content: ''; position: absolute; top: 50%; left: 50%; width: 32px; height: 32px; margin: -16px 0 0 -16px; border: 3px solid var(--ink-10); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.6s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Mobile menu toggle (hidden on desktop) */
.mobile-menu-toggle { display: none; width: 36px; height: 36px; align-items: center; justify-content: center; cursor: pointer; border-radius: var(--radius); }
.mobile-menu-toggle:hover { background: var(--ink-05); }
.mobile-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 99; }
.mobile-overlay.active { display: block; }
/* ━━━ MODAL ━━━ */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,20,25,0.45); z-index: 400; display: none; align-items: center; justify-content: center; padding: 24px; backdrop-filter: blur(3px); }
.modal-backdrop.open { display: flex; }
.modal { background: var(--white); border-radius: var(--radius-lg); box-shadow: var(--shadow-lg); width: 100%; max-width: 540px; max-height: 90vh; display: flex; flex-direction: column; animation: modalIn 0.15s cubic-bezier(0.16,1,0.3,1) both; }
@keyframes modalIn { from { opacity: 0; transform: translateY(12px) scale(0.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 24px; border-bottom: 1px solid var(--ink-10); flex-shrink: 0; }
.modal-title { font-size: 15px; font-weight: 700; letter-spacing: -0.01em; }
.modal-close { width: 28px; height: 28px; border-radius: var(--radius); border: none; background: transparent; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--ink-40); transition: all 0.12s; }
.modal-close:hover { background: var(--ink-05); color: var(--ink); }
.modal-body { padding: 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--ink-10); display: flex; justify-content: flex-end; gap: 8px; flex-shrink: 0; }

/* ━━━ FORM FIELDS ━━━ */
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 16px; }
.field:last-child { margin-bottom: 0; }
.field-label { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-60); }
.field-label .req { color: var(--red); margin-left: 2px; }
.field-ctrl { border: 1px solid var(--ink-10); border-radius: var(--radius); padding: 8px 12px; font-family: var(--font); font-size: 13px; color: var(--ink); background: var(--white); transition: all 0.15s; width: 100%; box-sizing: border-box; }
.field-ctrl:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(13,148,136,0.1); }
.field-ctrl::placeholder { color: var(--ink-40); }
.field-ctrl[type="number"] { -moz-appearance: textfield; }
.field-ctrl[type="number"]::-webkit-inner-spin-button { -webkit-appearance: none; }
select.field-ctrl { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238B98A5' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 30px; cursor: pointer; }
.field-row { display: grid; gap: 12px; }
.field-row-2 { grid-template-columns: 1fr 1fr; }
.field-row-3 { grid-template-columns: 1fr 1fr 1fr; }
.field-row-4 { grid-template-columns: 2fr 1fr 1fr 1fr; }
.field-hint { font-size: 11px; color: var(--ink-40); }
.field-error { font-size: 11px; color: var(--red); display: none; }
.field.has-error .field-ctrl { border-color: var(--red); box-shadow: 0 0 0 3px rgba(220,38,38,0.08); }
.field.has-error .field-error { display: block; }

/* ━━━ PROP CARD ACTIONS ━━━ */
.prop-card-actions { display: flex; gap: 6px; opacity: 0; transition: opacity 0.15s; position: absolute; top: 12px; left: 12px; }
.prop-card:hover .prop-card-actions { opacity: 1; }
.prop-card-action { width: 28px; height: 28px; border-radius: var(--radius); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; backdrop-filter: blur(8px); transition: all 0.12s; }
.prop-card-action.edit { background: rgba(255,255,255,0.85); color: var(--ink); }
.prop-card-action.delete { background: rgba(220,38,38,0.85); color: white; }
.prop-card-action:hover { transform: scale(1.08); }

/* ━━━ TOAST ━━━ */
.toast-shelf { position: fixed; bottom: 24px; right: 24px; z-index: 500; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast { background: var(--ink); color: var(--white); padding: 12px 18px; border-radius: var(--radius-lg); font-size: 13px; font-weight: 500; box-shadow: var(--shadow-lg); pointer-events: auto; display: flex; align-items: center; gap: 10px; animation: toastIn 0.25s cubic-bezier(0.16,1,0.3,1) both; max-width: 320px; }
.toast.success { background: var(--green); }
.toast.error { background: var(--red); }
@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateY(8px); } }
.toast.out { animation: toastOut 0.2s ease forwards; }

@media (max-width: 768px) {
    .modal { max-width: 100%; max-height: 95vh; }
    .field-row-3 { grid-template-columns: 1fr 1fr; }
    .field-row-4 { grid-template-columns: 1fr 1fr; }
    .prop-card-actions { opacity: 1; }
}

@media (max-width: 768px) {
    :root { --sidebar-w: 0px; }
    .chip-row {flex-wrap: unset!important;}
    .chip {padding: 4px 10px!important;}

    .sidebar { width: 260px; transform: translateX(-260px); transition: transform 0.18s ease; overflow: hidden; }
    .sidebar.open { transform: translateX(0); }
    .mobile-menu-toggle { display: flex !important; }

    .top-bar { overflow: visible; }
    .search-box { position: static; }
    .search-dropdown { position: fixed; top: var(--header-h); left: 0; right: 0; width: 100%; min-width: 0; max-height: 70vh; border-radius: 0 0 var(--radius-lg) var(--radius-lg); }

    .main { margin-left: 0; }
    .page { padding: 20px 16px 40px; }
    .top-bar { padding: 0 16px; gap: 8px; }
    .top-bar-title { display: none; }
    .top-bar-actions { flex: 1; min-width: 0; }
    .search-box { flex: 1; width: auto; min-width: 0; }
    .search-dropdown { min-width: 0; width: 100vw; right: -16px; left: auto; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
    .lay-dash { grid-template-columns: 1fr 1fr; grid-template-areas: "s1 s2" "s3 s4" "chart chart" "donut donut" "feed feed" "assign assign"; }
    .lay-report-summary { grid-template-columns: 1fr 1fr; grid-template-areas: "score score" "issues cost" "frames duration"; }
    .lay-props { grid-template-columns: 1fr; }
    .page-header { flex-direction: column; }
    .member-stats { display: none; }
    .member-row { flex-wrap: wrap; gap: 10px; }

    .upload-zone { padding: 24px 16px; }
    .upload-zone-title { font-size: 13px; word-break: break-word; }
    .upload-zone-sub { font-size: 11px; word-break: break-word; }

    /* ━━━ MOBILE TABLE FIX ━━━ */
    .panel-body--flush,
    .panel-body {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .tbl {
        min-width: 520px;
    }

    .tbl th,
    .tbl td {
        padding: 10px 12px;
        font-size: 12px;
        white-space: nowrap;
    }

    .tbl th {
        font-size: 10px;
    }
    .panel:has(.tbl)::after {
        content: '';
        position: absolute;
        top: 0; bottom: 0; right: 0;
        width: 24px;
        background: linear-gradient(to right, transparent, var(--white));
        pointer-events: none;
        opacity: 0;
        transition: opacity 0.2s;
    }
}

/* ═══════════════════════════════════════════════════════════════════
   NOTIFICATION DROPDOWN
   ═══════════════════════════════════════════════════════════════════ */

/* Container wraps bell + dropdown for click-outside logic */
.notif-container { position: relative; }

/* Badge count on bell */
.notif-count-badge {
    position: absolute; top: 2px; right: 2px; min-width: 16px; height: 16px;
    background: var(--red); color: var(--white); font-size: 10px; font-weight: 700;
    border-radius: 10px; display: flex; align-items: center; justify-content: center;
    padding: 0 4px; border: 1.5px solid var(--white); line-height: 1; pointer-events: none;
}

/* Dropdown panel */
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0; width: 360px;
    background: var(--white); border: 1px solid var(--ink-10); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); z-index: 300; display: none;
    flex-direction: column; max-height: 440px;
}
.notif-dropdown.open { display: flex; animation: modalIn 0.12s cubic-bezier(0.16,1,0.3,1) both; }

.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--ink-10); flex-shrink: 0;
}
.notif-dropdown-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.notif-mark-all {
    font-size: 12px; font-weight: 500; color: var(--accent); background: none;
    border: none; cursor: pointer; padding: 0;
}
.notif-mark-all:hover { text-decoration: underline; }

.notif-dropdown-body { overflow-y: auto; flex: 1; }

/* Individual notification row */
.notif-item {
    display: flex; gap: 10px; padding: 12px 16px; cursor: pointer;
    transition: background 0.12s;
}
.notif-item:hover { background: var(--ink-02); }
.notif-item.unread { background: var(--accent-light); }
.notif-item.unread:hover { background: #d4eeec; }

.notif-dot-col { width: 8px; flex-shrink: 0; padding-top: 6px; }
.notif-dot {
    width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
    display: block;
}

.notif-body { flex: 1; min-width: 0; }
.notif-msg { font-size: 13px; color: var(--ink); line-height: 1.45; }
.notif-meta {
    display: flex; gap: 8px; margin-top: 4px; font-size: 11px; color: var(--ink-40);
}

/* Empty state inside dropdown */
.notif-empty {
    padding: 32px 16px; text-align: center; color: var(--ink-40); font-size: 13px;
    display: flex; flex-direction: column; align-items: center; gap: 8px;
}

/* Mobile: full-width dropdown */
@media (max-width: 600px) {
    .notif-dropdown { width: calc(100vw - 32px); right: -12px; }
    .lay-report-summary {
        grid-template-columns: 1fr 1fr !important;
        grid-template-areas:
            "score score"
            "issues cost"
            "frames duration" !important;
    }
    .stat-tile-value { font-size: 22px; }
    .stat-tile { padding: 14px; }
}

/* ═══════════════════════════════════════════════════════════════════
   ADVANCED FILTER PANEL
   ═══════════════════════════════════════════════════════════════════ */
.adv-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 16px;
}
.field-range {
    display: flex;
    align-items: center;
    gap: 6px;
}
.field-range .field-ctrl { flex: 1; min-width: 0; }
.field-range-sep {
    color: var(--ink-40);
    font-size: 13px;
    flex-shrink: 0;
}
.adv-filter-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding-top: 4px;
    border-top: 1px solid var(--ink-05);
}
.adv-filter-panel .panel { border: 1px solid var(--accent); border-color: var(--ink-10); }
.adv-filter-panel.has-filters .panel { border-color: var(--accent); }
.filter-active-badge {
    display: inline-flex; align-items: center; justify-content: center;
    min-width: 18px; height: 18px; border-radius: 9px;
    background: var(--accent); color: var(--white);
    font-size: 10px; font-weight: 700; padding: 0 5px;
    margin-left: 6px; line-height: 1;
}

@media (max-width: 768px) {
    .adv-filter-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 480px) {
    .adv-filter-grid { grid-template-columns: 1fr; }
}

/* ═══════════════════════════════════════════════════════════════════
   ADDRESS AUTOCOMPLETE DROPDOWN
   ═══════════════════════════════════════════════════════════════════ */
.addr-autocomplete-wrap { position: relative; }
.addr-dropdown {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    background: var(--white); border: 1px solid var(--ink-10); border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    box-shadow: var(--shadow-md); z-index: 400; max-height: 240px; overflow-y: auto;
}
.addr-dropdown.open { display: block; }
.addr-item {
    padding: 10px 14px; cursor: pointer; font-size: 13px; color: var(--ink-80);
    border-bottom: 1px solid var(--ink-05); transition: background 0.1s;
}
.addr-item:last-child { border-bottom: none; }
.addr-item:hover, .addr-item.active { background: var(--accent-muted); color: var(--ink); }
.addr-item-main { font-weight: 500; color: var(--ink); }
.addr-item-sub { font-size: 11px; color: var(--ink-40); margin-top: 2px; }

/* ═══════════════════════════════════════════════════════════════════
   AUTOFILL FIELD LOADING ANIMATION
   ═══════════════════════════════════════════════════════════════════ */
.autofill-field { position: relative; }
.autofill-field.loading .field-ctrl {
    color: transparent;
    background: linear-gradient(90deg, var(--ink-05) 25%, var(--ink-10) 50%, var(--ink-05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.4s ease-in-out infinite;
    pointer-events: none;
}
.autofill-field.loading .field-label::after {
    content: '';
    display: inline-block; width: 12px; height: 12px; margin-left: 6px;
    border: 2px solid var(--ink-20); border-top-color: var(--accent);
    border-radius: 50%; animation: spin 0.6s linear infinite;
    vertical-align: middle;
}
.autofill-field.filled .field-ctrl {
    animation: autofillPop 0.3s ease-out;
    border-color: var(--accent); background: var(--accent-muted);
    transition: border-color 0.6s ease, background 0.6s ease;
}

@keyframes shimmer {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}
@keyframes autofillPop {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.02); }
    100% { transform: scale(1); }
}

/* Sidebar user card row with logout button */
.user-card-row { display: flex; align-items: center; gap: 6px; }

/* ═══ CHART TOOLTIP ═══ */
.chart-tooltip {
    position: absolute; z-index: 200; pointer-events: none;
    background: var(--ink); color: var(--white); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg); padding: 12px 14px; min-width: 220px; max-width: 320px;
    font-size: 12px; line-height: 1.4;
}
.chart-tooltip::after {
    content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 6px solid transparent; border-top-color: var(--ink);
}
.chart-tip-header {
    font-weight: 700; font-size: 13px; margin-bottom: 8px; padding-bottom: 6px;
    border-bottom: 1px solid rgba(255,255,255,0.15);
}
.chart-tip-row { margin-bottom: 6px; }
.chart-tip-row:last-child { margin-bottom: 0; }
.chart-tip-addr { font-weight: 600; font-size: 12px; margin-bottom: 2px; }
.chart-tip-meta { display: flex; gap: 8px; font-size: 11px; opacity: 0.85; flex-wrap: wrap; }
.chart-tip-type {
    background: rgba(255,255,255,0.15); padding: 1px 6px; border-radius: 3px; font-weight: 500;
}
.chart-bar-group:hover .chart-bar { opacity: 0.85; }

/* ═══ STACKED CHART BARS ═══ */
.chart-bar-stack {
    display: flex; flex-direction: column; justify-content: flex-end;
    width: 100%; border-radius: 4px 4px 0 0; overflow: hidden;
    transition: height 0.5s cubic-bezier(0.16,1,0.3,1);
}
.chart-bar-seg { width: 100%; transition: height 0.4s ease; }
.chart-bar-seg.complete { background: var(--accent); }
.chart-bar-seg.open { background: var(--amber); }
.chart-bar-seg.empty { background: var(--ink-10); }
.chart-bar-group:hover .chart-bar-stack { opacity: 0.85; }

/* ═══ QUICK ACTIONS DROPDOWN ═══ */
.qa-wrap { position: relative; z-index: 100; }
.qa-trigger { gap: 6px !important; }
.qa-caret { transition: transform 0.15s ease; flex-shrink: 0; }
.qa-wrap.open .qa-caret { transform: rotate(180deg); }
.qa-menu {
    display: none; position: absolute; top: calc(100% + 6px); right: 0;
    width: 260px; background: var(--white); border: 1px solid var(--ink-10);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
    z-index: 200; padding: 6px 0; overflow: hidden;
}
.qa-wrap.open .qa-menu { display: block; animation: qaIn 0.12s ease-out; }
@keyframes qaIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
.qa-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 14px;
    cursor: pointer; transition: background 0.08s;
}
.qa-item:hover, .qa-item.active { background: var(--ink-02); }
.qa-icon {
    width: 34px; height: 34px; border-radius: var(--radius); flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.qa-label { flex: 1; min-width: 0; }
.qa-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.qa-desc { font-size: 11px; color: var(--ink-40); margin-top: 1px; }
.qa-sep { height: 1px; background: var(--ink-05); margin: 4px 0; }

/* ═══ SCAN PROGRESS PHASES ═══ */
.scan-progress-phases {
    display: flex; align-items: center; justify-content: center; gap: 0;
    padding: 16px 0 8px; margin-bottom: 8px;
}
.scan-phase {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    font-size: 11px; font-weight: 500; color: var(--ink-20); transition: color 0.3s;
}
.scan-phase.active { color: var(--accent); }
.scan-phase.done { color: var(--green); }
.scan-phase-dot {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid var(--ink-10); background: var(--white);
    display: flex; align-items: center; justify-content: center;
    transition: all 0.3s ease;
}
.scan-phase.active .scan-phase-dot {
    border-color: var(--accent); background: var(--accent);
    box-shadow: 0 0 0 4px rgba(13,148,136,0.15);
    animation: phasePulse 1.5s ease-in-out infinite;
}
.scan-phase.done .scan-phase-dot {
    border-color: var(--green); background: var(--green);
    box-shadow: none; animation: none;
}
.scan-phase.done .scan-phase-dot::after { content: ''; display: block; width: 8px; height: 5px; border-left: 2px solid white; border-bottom: 2px solid white; transform: rotate(-45deg) translateY(-1px); }
.scan-phase-line { flex: 1; max-width: 48px; height: 2px; background: var(--ink-10); }
.scan-phase.done + .scan-phase-line { background: var(--green); }
@keyframes phasePulse { 0%,100% { box-shadow: 0 0 0 4px rgba(13,148,136,0.15); } 50% { box-shadow: 0 0 0 8px rgba(13,148,136,0.08); } }

/* ═══ ROOM DISCOVERY GRID ═══ */
.room-discovery-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
}
.room-card {
    padding: 10px; border-radius: var(--radius); border: 1px solid var(--ink-10);
    text-align: center; transition: all 0.3s ease;
    background: var(--white);
}
.room-card.pending { opacity: 0.4; }
.room-card.discovered {
    opacity: 1; border-color: var(--ink-10);
    animation: roomPop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.room-card-icon { margin-bottom: 4px; }
.room-card-name { font-size: 11px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.room-card-status { font-size: 10px; font-weight: 500; margin-top: 2px; }
.room-card.pending .room-card-status { color: var(--ink-20); }
@keyframes roomPop { 0% { transform: scale(0.85); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }

/* ═══ PROPERTY DETAIL ═══ */
@media (max-width: 768px) {
    .detail-top-row { grid-template-columns: 1fr !important; }
}

/* Sortable table headers */
th[onclick] { cursor: pointer; user-select: none; white-space: nowrap; }
th[onclick]:hover { color: var(--accent); }
th[onclick]::after { content: '\2195'; margin-left: 4px; font-size: 10px; color: var(--ink-20); }
th.sort-asc::after { content: '\2191'; color: var(--accent); }
th.sort-desc::after { content: '\2193'; color: var(--accent); }
