/* Premavo portfolio dashboard — new shell, KPI cards, map, donut, panels.
   Loads after premavo.css; reuses its tokens (--brand, --status-*) and .badge/.btn. */

:root {
    --sidebar-w: 232px;
    --topbar-h: 64px;
    --health-healthy: #16a34a;
    --health-attention: #d97706;
    --health-critical: #dc2626;
    --panel-radius: 14px;
}

/* ===== Shell layout ===== */
#view-shell.active { flex-direction: row; align-items: stretch; min-height: 100vh; background: #f4f6fa; }

.sidebar { width: var(--sidebar-w); flex-shrink: 0; background: #ffffff; color: #475569; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; border-right: 1px solid #e8edf3; }
.sidebar .sb-brand { padding: 20px 18px; font-size: 17px; font-weight: 800; letter-spacing: .04em; color: #0f172a; display: flex; align-items: center; gap: 9px; }
.sidebar .sb-brand .brand-mark { width: 24px; height: 24px; color: var(--brand); flex-shrink: 0; }
.sidebar nav { display: flex; flex-direction: column; padding: 6px 10px; gap: 2px; flex: 1; overflow-y: auto; }
.sidebar nav button { display: flex; align-items: center; gap: 11px; background: none; border: none; color: #475569; padding: 10px 12px; font-size: 14px; font-weight: 500; cursor: pointer; text-align: left; border-radius: 9px; width: 100%; }
.sidebar nav button:hover { background: #f1f5f9; color: #0f172a; }
.sidebar nav button.active { background: var(--brand-light); color: var(--brand-dark); font-weight: 600; }
.sidebar nav button.active .sb-icon { color: var(--brand); }
.sidebar .sb-icon { width: 20px; text-align: center; font-size: 15px; }
.sb-foot { padding: 14px; border-top: 1px solid #eef2f7; display: flex; flex-direction: column; gap: 8px; }
.sb-foot .sb-user { font-size: 12px; color: #94a3b8; word-break: break-word; }
.sb-foot .btn.ghost { color: #475569; border-color: #e2e8f0; }

.shell-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }

/* ===== Topbar ===== */
.topbar { height: var(--topbar-h); flex-shrink: 0; background: #fff; border-bottom: 1px solid var(--border, #e3e8ef); display: flex; align-items: center; justify-content: space-between; padding: 0 22px; gap: 16px; position: sticky; top: 0; z-index: 20; }
.tb-greeting { font-size: 18px; font-weight: 700; color: #111827; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tb-actions { display: flex; align-items: center; gap: 12px; }
.tb-search { width: 240px; max-width: 38vw; padding: 9px 13px; border: 1px solid #d8dee9; border-radius: 9px; font-size: 14px; background: #f7f9fc; }
.tb-search:focus { outline: none; border-color: var(--brand); background: #fff; box-shadow: 0 0 0 3px rgba(13,148,136,.15); }
.tb-icon-btn { position: relative; background: #f1f4f9; border: none; width: 40px; height: 40px; border-radius: 10px; font-size: 17px; cursor: pointer; }
.tb-icon-btn:hover { background: #e6ebf3; }
.notif-dot { position: absolute; top: 8px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent-red); }

.notif-wrap { position: relative; }
.notif-dropdown { position: absolute; right: 0; top: 48px; width: 320px; max-width: 86vw; background: #fff; border: 1px solid #e3e8ef; border-radius: 12px; box-shadow: 0 8px 30px rgba(16,24,40,.16); padding: 8px; z-index: 50; max-height: 60vh; overflow-y: auto; }
.notif-dropdown h4 { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: #6b7280; margin: 6px 8px 8px; }
.notif-item { display: flex; gap: 10px; padding: 9px 8px; border-radius: 8px; cursor: pointer; }
.notif-item:hover { background: #f6f8fb; }
.notif-item .ni-dot { width: 8px; height: 8px; border-radius: 50%; margin-top: 6px; flex-shrink: 0; }
.notif-item .ni-title { font-size: 13px; font-weight: 600; color: #1f2937; }
.notif-item .ni-sub { font-size: 12px; color: #6b7280; }

/* ===== Mobile nav drawer ===== */
.nav-toggle { display: none; }
.sidebar-backdrop { display: none; }

/* ===== Content ===== */
.content { flex: 1; overflow-y: auto; padding: 22px; }
.content > h1 { font-size: 20px; font-weight: 700; margin: 0 0 4px; color: #111827; }
.content .sub { color: #6b7280; font-size: 13px; margin: 0 0 18px; }
.section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 0 16px; gap: 12px; flex-wrap: wrap; }
.section-head h1 { font-size: 20px; font-weight: 700; margin: 0; }

/* ===== KPI cards ===== */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-card { background: #fff; border-radius: var(--panel-radius); padding: 16px 18px; box-shadow: 0 1px 3px rgba(16,24,40,.07); display: flex; align-items: center; gap: 14px; }
.kpi-icon { width: 46px; height: 46px; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.kpi-icon.blue { background: #eaf1ff; color: #2563eb; }
.kpi-icon.green { background: #e9f9ee; color: var(--health-healthy); }
.kpi-icon.red { background: #fdeced; color: var(--health-critical); }
.kpi-icon.amber { background: #fef5e7; color: var(--health-attention); }
.kpi-main { min-width: 0; }
.kpi-value { font-size: 26px; font-weight: 800; line-height: 1.1; color: #111827; }
.kpi-label { font-size: 12.5px; color: #6b7280; margin-top: 2px; }

/* ===== Panels & grid ===== */
.grid { display: grid; gap: 16px; }
.grid.cols-3 { grid-template-columns: 1.3fr 1fr 1fr; }
.grid.cols-2 { grid-template-columns: 1fr 1fr; }
.grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
.panel { background: #fff; border-radius: var(--panel-radius); padding: 18px; box-shadow: 0 1px 3px rgba(16,24,40,.07); min-width: 0; }
.panel > .ph { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.panel > .ph h3 { font-size: 14.5px; font-weight: 700; margin: 0; color: #1f2937; }
.panel .ph-link { font-size: 12px; color: var(--brand); cursor: pointer; font-weight: 600; }
.span-row { grid-column: 1 / -1; }

/* ===== Map ===== */
#portfolio-map { height: 360px; border-radius: 12px; z-index: 1; }
.map-legend { display: flex; gap: 14px; margin-top: 12px; flex-wrap: wrap; font-size: 12px; color: #4b5563; }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.lg-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ===== Donut ===== */
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut { position: relative; width: 150px; height: 150px; flex-shrink: 0; }
.donut .donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.donut .dc-n { font-size: 28px; font-weight: 800; color: #111827; }
.donut .dc-l { font-size: 11px; color: #6b7280; }
.donut-legend { display: flex; flex-direction: column; gap: 10px; flex: 1; }
.donut-legend .dl-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.donut-legend .dl-dot { width: 10px; height: 10px; border-radius: 3px; }
.donut-legend .dl-n { margin-left: auto; font-weight: 700; }

/* ===== Priorities ===== */
.prio-item { display: flex; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f1f3f7; }
.prio-item:last-child { border-bottom: none; }
.prio-item .pi-bar { width: 4px; border-radius: 4px; flex-shrink: 0; }
.prio-item.high .pi-bar { background: var(--health-critical); }
.prio-item.medium .pi-bar { background: var(--health-attention); }
.prio-item .pi-title { font-size: 13.5px; font-weight: 600; color: #1f2937; }
.prio-item .pi-sub { font-size: 12px; color: #6b7280; margin-top: 1px; }
.prio-item .pi-go { margin-left: auto; align-self: center; color: #c0c7d4; }

/* ===== Attention cards (with photo) ===== */
.attn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.attn-card { border: 1px solid #eef1f6; border-radius: 12px; overflow: hidden; cursor: pointer; background: #fff; transition: box-shadow .15s; }
.attn-card:hover { box-shadow: 0 4px 14px rgba(16,24,40,.1); }
.attn-photo { height: 96px; background: #e7ecf3 center/cover no-repeat; position: relative; }
.attn-photo .attn-score { position: absolute; top: 8px; right: 8px; background: rgba(17,24,39,.78); color: #fff; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 20px; }
.attn-body { padding: 10px 12px; }
.attn-name { font-size: 14px; font-weight: 700; color: #1f2937; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.attn-meta { font-size: 12px; color: #6b7280; margin-top: 2px; }
.attn-chips { display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap; }

/* ===== Compliance by category ===== */
.cmp-row { margin-bottom: 14px; }
.cmp-row:last-child { margin-bottom: 0; }
.cmp-top { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 6px; }
.cmp-top .cmp-pct { font-weight: 700; }
.cmp-bar { height: 8px; border-radius: 6px; background: #eef1f6; overflow: hidden; }
.cmp-bar > span { display: block; height: 100%; border-radius: 6px; background: var(--brand); }

/* ===== Quick actions ===== */
.qa-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.qa-btn { display: flex; align-items: center; gap: 10px; padding: 13px; border: 1px solid #e7ebf2; border-radius: 11px; background: #fbfcfe; cursor: pointer; font-size: 13.5px; font-weight: 600; color: #374151; text-align: left; }
.qa-btn:hover { background: #f3f6fb; border-color: #d8dee9; }
.qa-btn .qa-ic { font-size: 17px; }

/* ===== Health badges ===== */
.badge.healthy         { background: #e9f9ee; color: var(--health-healthy); }
.badge.needs_attention { background: #fef5e7; color: var(--health-attention); }
.badge.critical        { background: #fdeced; color: var(--health-critical); }

/* ===== Simple list rows reused by sections ===== */
.row-list { display: flex; flex-direction: column; }
.row-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid #f1f3f7; }
.row-item:last-child { border-bottom: none; }
.row-item .ri-main { flex: 1; min-width: 0; }
.row-item .ri-title { font-size: 14px; font-weight: 600; color: #1f2937; }
.row-item .ri-sub { font-size: 12px; color: #6b7280; margin-top: 2px; }

/* ===== Building detail header (inside shell) ===== */
.bd-header { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; }
.bd-header .back-btn { background: #f1f4f9; border: none; width: 38px; height: 38px; border-radius: 10px; font-size: 18px; cursor: pointer; }
.bd-header .bd-name { font-size: 20px; font-weight: 700; }
.bd-tabs { display: flex; gap: 6px; overflow-x: auto; margin-bottom: 18px; padding-bottom: 4px; }
.bd-tabs button { flex-shrink: 0; padding: 8px 14px; border: 1px solid #e3e8ef; background: #fff; border-radius: 20px; font-size: 13px; font-weight: 600; color: #4b5563; cursor: pointer; }
.bd-tabs button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ===== Responsive ===== */
@media (max-width: 1100px) {
    .grid.cols-3 { grid-template-columns: 1fr 1fr; }
    .grid.cols-3 > .span-when-narrow { grid-column: 1 / -1; }
}
@media (max-width: 899px) {
    #view-shell.active { flex-direction: column; }
    .nav-toggle { display: flex; align-items: center; justify-content: center; }
    .sidebar {
        position: fixed; top: 0; left: 0; height: 100vh; z-index: 200;
        transform: translateX(-100%);
        transition: transform .25s ease;
        box-shadow: 2px 0 24px rgba(16,24,40,.18);
    }
    .sidebar.open { transform: translateX(0); }
    .sidebar-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.42); z-index: 150; }
    .topbar { padding: 0 14px; }
    .tb-greeting { font-size: 15px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: 1fr; }
    .attn-grid, .qa-grid { grid-template-columns: 1fr; }
    .content { padding: 14px; }
}
@media (max-width: 480px) {
    /* Too many elements fighting for space on a phone-width topbar — drop the
       greeting and collapse "+ Add Building" to just the icon. */
    .tb-greeting { display: none; }
    #add-building-btn .btn-label { display: none; }
    #add-building-btn { padding: 9px 12px; }
    .tb-search { width: 110px; }
    .topbar { gap: 8px; }
    .tb-actions { gap: 8px; }
}
