/* Tenant Manager — Dashboard Styles */
:root {
    --bg: #0f172a;
    --surface: #1e293b;
    --surface-hover: #334155;
    --border: #334155;
    --text: #e2e8f0;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-rgb: 59, 130, 246;
    --green: #22c55e;
    --yellow: #eab308;
    --red: #ef4444;
    --orange: #f97316;
}

[data-theme="light"] {
    --bg: #f8fafc;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --accent: #3b82f6;        /* keep same */
    --accent-rgb: 59, 130, 246; /* keep same */
    --green: #16a34a;         /* slightly darker for white bg contrast */
    --yellow: #ca8a04;        /* darker yellow for white bg */
    --red: #dc2626;           /* slightly darker red */
    --orange: #ea580c;        /* slightly darker orange */
}

[data-theme="light"] .sidebar {
    box-shadow: 2px 0 8px rgba(0,0,0,0.05);
}

[data-theme="light"] .sidebar-dropdown {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Cards and surfaces need visible borders in light mode */
[data-theme="light"] .card,
[data-theme="light"] .stat-card {
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

/* Sidebar popup dropdown shadows lighter in light mode */
[data-theme="light"] .sidebar-popup-dropdown {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Toast readability */
[data-theme="light"] .toast {
    border: 1px solid var(--border);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Table rows */
[data-theme="light"] tr:hover td {
    background: var(--surface-hover);
}

/* Input fields */
[data-theme="light"] input,
[data-theme="light"] select,
[data-theme="light"] textarea {
    border-color: #cbd5e1;
    background: #ffffff;
}

[data-theme="light"] input:focus,
[data-theme="light"] select:focus,
[data-theme="light"] textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.15);
}

/* System preference fallback — when no cookie is set and JS hasn't run yet */
@media (prefers-color-scheme: light) {
    :root:not([data-theme]) {
        --bg: #f8fafc;
        --surface: #ffffff;
        --surface-hover: #f1f5f9;
        --border: #e2e8f0;
        --text: #1e293b;
        --text-muted: #64748b;
        --accent: #3b82f6;
        --accent-rgb: 59, 130, 246;
        --green: #16a34a;
        --yellow: #ca8a04;
        --red: #dc2626;
        --orange: #ea580c;
    }
}

/* Theme toggle button */
#theme-toggle-btn {
    transition: color 0.2s;
}

#theme-toggle-btn:hover {
    color: var(--accent);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
}

/* Container: offset for sidebar */
.container {
    max-width: none;
    margin-left: var(--sidebar-width, 280px);
    transition: margin-left 0.3s ease;
    padding: 1rem 1.5rem;
}
[data-sidebar="collapsed"] .container { margin-left: 64px; }

/* ── Sidebar drag-to-resize handle (right edge) ──────────────────────── */
.sidebar-resize-handle {
    position: absolute;
    top: 0;
    right: 0;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 250;
    background: transparent;
    transition: background 0.15s;
}
.sidebar-resize-handle:hover,
html.sidebar-resizing .sidebar-resize-handle {
    background: rgba(var(--accent-rgb, 59,130,246), 0.45);
}
/* Instant feedback while dragging — no width/margin animation lag */
html.sidebar-resizing .sidebar,
html.sidebar-resizing .container { transition: none !important; }
html.sidebar-resizing { cursor: col-resize; user-select: none; }
/* No free-resize when collapsed or on mobile (use the toggle instead) */
[data-sidebar="collapsed"] .sidebar-resize-handle { display: none; }

/* ── Sidebar ─────────────────────────────────────────────────────────── */

.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    width: var(--sidebar-width, 280px);
    background: var(--surface);
    border-right: 1px solid var(--border);
    z-index: 200;
    transition: width 0.3s ease;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Sidebar header */
.sidebar-header {
    padding: 1rem 0.75rem 0.75rem;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    overflow: hidden;
}

.sidebar-selectors {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
    transition: opacity 0.2s, max-height 0.3s ease;
    max-height: 200px;
}

/* Scrollable nav area */
.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0.5rem 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Nav items */
.sidebar-item {
    display: flex;
    align-items: center;
    flex-wrap: nowrap;
    align-content: center;
    gap: 0.65rem;
    padding: 0.45rem 0.65rem;
    border-radius: 0.375rem;
    color: var(--text-muted);
    text-decoration: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    white-space: nowrap;
    min-width: 0;
}
.sidebar-item > i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 1.1rem;
    text-align: center;
}
/* Colored sidebar icons by category */
.sidebar-item > i.bi-speedometer2  { color: #3b82f6; } /* Dashboard — blue */
.sidebar-item > i.bi-people        { color: #8b5cf6; } /* Teamwork — purple */
.sidebar-item > i.bi-clipboard-pulse { color: #f59e0b; } /* Digest — amber */
.sidebar-item > i.bi-person-lines-fill { color: #ec4899; } /* Huurders — pink */
.sidebar-item > i.bi-person-plus   { color: #22c55e; } /* Onboarding — green */
.sidebar-item > i.bi-person-dash   { color: #ef4444; } /* Offboarding — red */
.sidebar-item > i.bi-file-earmark-ruled { color: #6366f1; } /* Huurcontracten — indigo */
.sidebar-item > i.bi-file-earmark-pdf { color: #dc2626; } /* Contractbouwer — red */
.sidebar-item > i.bi-graph-up-arrow { color: #14b8a6; } /* Indexatie — teal */
.sidebar-item > i.bi-clipboard-check { color: #64748b; } /* Verplichtingen — slate */
.sidebar-item > i.bi-houses        { color: #f97316; } /* Gebouwen — orange */
.sidebar-item > i.bi-wrench        { color: #eab308; } /* Onderhoud — yellow */
.sidebar-item > i.bi-person-gear   { color: #0ea5e9; } /* Aannemers — sky */
.sidebar-item > i.bi-graph-up      { color: #10b981; } /* Verbruik — emerald */
.sidebar-item > i.bi-receipt       { color: #a855f7; } /* Kosten — violet */
.sidebar-item > i.bi-person-badge  { color: #d946ef; } /* Eigenaars — fuchsia */
.sidebar-item > i.bi-cash-coin     { color: #22c55e; } /* Huuroverzicht — green */
.sidebar-item > i.bi-bank          { color: #0284c7; } /* Bank Import — sky dark */
.sidebar-item > i.bi-list-check    { color: #6366f1; } /* Transacties — indigo */
.sidebar-item > i.bi-envelope      { color: #3b82f6; } /* Communicatie — blue */
.sidebar-item > i.bi-robot         { color: #8b5cf6; } /* AI Chat — purple */
.sidebar-item > i.bi-calendar3     { color: #f43f5e; } /* Kalender — rose */
.sidebar-item > i.bi-file-earmark-richtext { color: #f59e0b; } /* Flyers — amber */
.sidebar-item > i.bi-sliders       { color: #64748b; } /* Instellingen — slate */
.sidebar-item > i.bi-shield-lock   { color: #ef4444; } /* Toegangsbeheer — red */
.sidebar-item > i.bi-credit-card   { color: #22c55e; } /* Abonnement — green */
.sidebar-item > i.bi-funnel        { color: #0ea5e9; } /* Regels — sky */
.sidebar-item > i.bi-pencil-square { color: #f97316; } /* Templates — orange */
.sidebar-item > i.bi-book          { color: #6366f1; } /* Juridisch/Wiki — indigo */
.sidebar-item > i.bi-info-circle   { color: #3b82f6; } /* FAQ — blue */
.sidebar-item > i.bi-question-circle { color: #8b5cf6; } /* Help — purple */
.sidebar-item > i.bi-map           { color: #14b8a6; } /* Roadmap — teal */
.sidebar-item > i.bi-megaphone     { color: #f59e0b; } /* Feedback — amber */
.sidebar-item > i.bi-trophy        { color: #eab308; } /* Gamificatie — yellow */
/* Active item keeps accent color on icon */
.sidebar-item.active > i { color: var(--accent); }
.sidebar-item:hover {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}
.sidebar-item.active {
    color: var(--accent);
    background: rgba(var(--accent-rgb), 0.1);
    border-left: 3px solid var(--accent);
    padding-left: calc(0.65rem - 3px);
}

/* ── Gamification widget (sidebar progress ring) ── */
.gamification-widget {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 0.65rem;
    margin: 0.25rem 0.4rem 0.5rem;
    border-radius: 0.5rem;
    background: rgba(var(--accent-rgb, 59,130,246), 0.06);
    border: 1px solid rgba(var(--accent-rgb, 59,130,246), 0.15);
    min-height: 0;
}
.gamification-widget:empty { display: none; }
.gw-ring-wrap {
    position: relative;
    width: 40px; height: 40px;
    flex-shrink: 0;
}
.gw-ring { width: 100%; height: 100%; }
.gw-ring-bg { stroke: var(--border); }
.gw-ring-progress {
    stroke: var(--accent, #3b82f6);
    transition: stroke-dashoffset 0.6s ease;
}
.gw-ring-done { stroke: var(--green, #22c55e); }
.gw-ring-check {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.9rem; font-weight: 700;
    color: var(--green, #22c55e);
}
.gw-text {
    display: flex; flex-direction: column;
    font-size: 0.78rem; line-height: 1.3;
    min-width: 0; overflow: hidden;
}
.gw-xp { font-weight: 600; color: var(--text); white-space: nowrap; }
.gw-streak { color: var(--text-muted); white-space: nowrap; }

/* Collapsed sidebar: ring only */
[data-sidebar="collapsed"] .gamification-widget {
    justify-content: center;
    padding: 0.4rem;
    margin: 0.25rem auto 0.5rem;
    width: 48px;
    border: none; background: none;
}
[data-sidebar="collapsed"] .gw-text { display: none; }
[data-sidebar="collapsed"] .gw-ring-wrap { width: 32px; height: 32px; }

/* Label + description stack */
.sidebar-label {
    font-size: 0.85rem;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s, width 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
    max-width: 160px;
}
.sidebar-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    transition: opacity 0.2s;
    white-space: nowrap;
    line-height: 1;
    margin-top: 0.05rem;
    flex-shrink: 1;
    min-width: 0;
}
/* Compact single-line rows: icon + label only. The description is hidden
   inline and surfaced as a hover tooltip (sidebar-hover-tip JS in nav.html). */
.sidebar-item > i { align-self: center; }
.sidebar-item > .sidebar-label { flex: 1 1 auto; line-height: 1.2; max-width: none; }
.sidebar-item > .sidebar-desc  { display: none; }

/* Group containers */
.sidebar-group {
    margin-top: 0.25rem;
}

/* Collapsible group toggle button */
.sidebar-group-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 0.5rem 0.75rem;
    margin-top: 0.75rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-family: inherit;
    opacity: 0.7;
    transition: opacity 0.2s, color 0.2s;
}

.sidebar-group-toggle:hover {
    opacity: 1;
    color: var(--text);
}

.sidebar-group-chevron {
    font-size: 0.55rem;
    transition: transform 0.2s;
    flex-shrink: 0;
}

.sidebar-group-toggle[aria-expanded="false"] .sidebar-group-chevron {
    transform: rotate(-90deg);
}

/* Label text with trailing separator line */
.sidebar-group-label-text {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-group-label-text::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
    opacity: 0.5;
    margin-left: 0.25rem;
}

/* Collapsible items wrapper — tree view: grouped items are indented under a
   vertical guide line that branches off the group header. */
.sidebar-group-items {
    overflow: hidden;
    transition: max-height 0.3s ease;
    margin-left: 1.05rem;
    padding-left: 0.55rem;
    border-left: 1px solid var(--border);
}
.sidebar-group:hover > .sidebar-group-items { border-left-color: var(--text-muted); }

/* Sidebar footer */
/* Logged-in user card in sidebar footer */
.sidebar-user-card {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 0.75rem;
    margin-bottom: 0.4rem;
    border-radius: 0.375rem;
    background: rgba(var(--accent-rgb, 59,130,246), 0.06);
    border: 1px solid rgba(var(--accent-rgb, 59,130,246), 0.15);
    width: 100%;
}
.sidebar-user-avatar {
    width: 34px; height: 34px; border-radius: 50%;
    background: var(--accent, #3b82f6); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
    flex-shrink: 0;
}
.sidebar-user-info { min-width: 0; overflow: hidden; }
.sidebar-user-name {
    font-size: 0.82rem; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar-user-role {
    font-size: 0.7rem; color: var(--text-muted);
    text-transform: capitalize;
}
[data-sidebar="collapsed"] .sidebar-user-card {
    justify-content: center; padding: 0.4rem;
    background: none; border: none; margin-bottom: 0.25rem;
}
[data-sidebar="collapsed"] .sidebar-user-info { display: none; }

.sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 0.5rem;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    gap: 0.25rem;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-footer-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 0.375rem;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    text-decoration: none;
    font-size: 1rem;
    flex-shrink: 0;
}
.sidebar-footer-btn:hover,
.sidebar-footer-btn.active {
    background: var(--surface-hover);
    color: var(--text);
    text-decoration: none;
}
.sidebar-footer-btn.active { color: var(--accent); }

.sidebar-logout-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 0.375rem;
    color: var(--red, #ef4444);
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    border: 1px solid rgba(239, 68, 68, 0.25);
    background: rgba(239, 68, 68, 0.06);
    margin-top: 0.5rem;
    min-height: 40px;
    width: 100%;
    justify-content: center;
    transition: background 0.15s;
}
.sidebar-logout-btn i { font-size: 1rem; }
.sidebar-logout-btn .logout-label { white-space: nowrap; }
.sidebar-logout-btn:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
}
[data-sidebar="collapsed"] .sidebar-logout-btn .logout-label { display: none; }
[data-sidebar="collapsed"] .sidebar-logout-btn { width: auto; border: none; background: none; margin-top: 0; justify-content: center; }

/* ── Mobile/Tablet user menu (top header) ── */
.user-avatar-sm {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--accent, #3b82f6); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.9rem;
    cursor: pointer; user-select: none;
    flex-shrink: 0;
}
.mobile-user-menu { position: relative; }
.mobile-user-dropdown {
    display: none;
    position: absolute; top: calc(100% + 0.5rem); right: 0;
    background: var(--surface, var(--bg)); border: 1px solid var(--border);
    border-radius: 0.5rem; padding: 0.75rem;
    min-width: 200px; z-index: 300;
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}
.mobile-user-dropdown.show { display: block; }
.dropdown-user-info { display: flex; flex-direction: column; gap: 0.15rem; }
.dropdown-user-info strong { font-size: 0.88rem; color: var(--text); }
.dropdown-role { font-size: 0.75rem; color: var(--text-muted); text-transform: capitalize; }
.dropdown-logout {
    display: flex; align-items: center; gap: 0.5rem;
    padding: 0.5rem 0.5rem; border-radius: 0.375rem;
    color: var(--red, #ef4444); text-decoration: none;
    font-weight: 600; font-size: 0.85rem;
    min-height: 44px;
}
.dropdown-logout:hover { background: rgba(239,68,68,0.1); }

/* Badge on footer buttons */
.sidebar-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 0.85rem;
    height: 0.85rem;
    border-radius: 9999px;
    font-size: 0.55rem;
    font-weight: 700;
    background: var(--red);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 0.2rem;
    line-height: 1;
    pointer-events: none;
}

/* Dropdown panels anchored to sidebar footer */
.sidebar-footer-dropdown-wrap { position: relative; }

.sidebar-dropdown {
    position: absolute;
    bottom: calc(100% + 0.5rem);
    left: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
    width: 22rem;
    max-height: 20rem;
    overflow-y: auto;
    z-index: 500;
}

/* Popup dropdowns — fixed position, outside sidebar to avoid overflow clipping */
.sidebar-popup-dropdown {
    position: fixed;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    width: 22rem;
    max-height: 20rem;
    overflow-y: auto;
    z-index: 1000;
}
.sidebar-dropdown-header {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.75rem;
    font-weight: 700;
    color: #ef4444;
}

/* ── Collapsed state ──────────────────────────────────────────────────── */
[data-sidebar="collapsed"] .sidebar { width: 64px; }

[data-sidebar="collapsed"] .sidebar-label,
[data-sidebar="collapsed"] .sidebar-desc,
[data-sidebar="collapsed"] .sidebar-selectors {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
}

/* Collapsed: hide group toggle entirely (no room for it) */
[data-sidebar="collapsed"] .sidebar-group-toggle {
    opacity: 0;
    max-height: 0;
    overflow: hidden;
    pointer-events: none;
    padding: 0;
    margin: 0;
}

/* Collapsed: keep group items always visible (icons show, labels hidden) */
[data-sidebar="collapsed"] .sidebar-group-items {
    max-height: none !important;
    overflow: visible;
    /* drop the tree indent/guide when collapsed — icons center instead */
    margin-left: 0;
    padding-left: 0;
    border-left: none;
}

/* Collapsed: center icon in item */
[data-sidebar="collapsed"] .sidebar-item {
    justify-content: center;
    padding: 0.55rem 0;
}
[data-sidebar="collapsed"] .sidebar-item > i {
    margin: 0;
}

/* Collapsed: center footer */
[data-sidebar="collapsed"] .sidebar-footer {
    flex-direction: column;
    align-items: center;
}

/* Flip collapse icon when collapsed */
[data-sidebar="collapsed"] .sidebar-collapse-icon {
    transform: rotate(180deg);
}

/* ── Collapsed tooltips (CSS-only, right of sidebar) ─────────────────── */
[data-sidebar="collapsed"] .sidebar-item[data-tooltip]::after,
[data-sidebar="collapsed"] .sidebar-footer-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    left: calc(100% + 0.5rem);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface-hover);
    color: var(--text);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
    padding: 0.3rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    z-index: 9999;
}
[data-sidebar="collapsed"] .sidebar-item[data-tooltip]:hover::after,
[data-sidebar="collapsed"] .sidebar-footer-btn[data-tooltip]:hover::after {
    opacity: 1;
}

/* ── Expanded-sidebar hover tooltip (shows each item's description) ──────
   Appended to <body> by nav.html JS so it is never clipped by the sidebar's
   overflow. Collapsed mode keeps the CSS label tooltip above. */
.sb-hover-tip {
    position: fixed;
    transform: translateY(-50%);
    max-width: 260px;
    background: var(--surface-hover);
    color: var(--text);
    font-size: 0.75rem;
    line-height: 1.35;
    padding: 0.35rem 0.6rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.12s ease;
    z-index: 10000;
}
.sb-hover-tip.show { opacity: 1; }

/* ── Profile / account menu (avatar dropdown: settings, bug report, logout) ── */
/* The user card is now a <button> — reset UA styles, keep the card look. */
button.sidebar-user-card {
    font-family: inherit;
    text-align: left;
    cursor: pointer;
}
.sidebar-user-avatar { position: relative; }
.profile-avatar-badge { position: absolute; top: -3px; right: -3px; }
.profile-chevron {
    margin-left: auto;
    font-size: 0.6rem;
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}
button.sidebar-user-card[aria-expanded="true"] .profile-chevron { transform: rotate(180deg); }
[data-sidebar="collapsed"] .profile-chevron { display: none; }

.profile-menu-item {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.6rem;
    background: none;
    border: none;
    border-radius: 0.375rem;
    text-align: left;
    text-decoration: none;
    font-family: inherit;
    font-size: 0.82rem;
    color: var(--text);
    cursor: pointer;
}
.profile-menu-item:hover { background: var(--surface-hover); color: var(--text); text-decoration: none; }
.profile-menu-item > i { font-size: 0.95rem; width: 1.15rem; text-align: center; color: var(--text-muted); flex-shrink: 0; }
.profile-menu-item-danger, .profile-menu-item-danger > i { color: #ef4444; }
.profile-menu-divider { height: 1px; background: var(--border); margin: 0.3rem 0.2rem; }

/* ── Action Queue cards (actionable dashboard "Needs Attention", shared v2 + simple) ── */
#aq-actions-container { outline: none; }
.aq-card { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.4rem; border-bottom: 1px solid var(--border); flex-wrap: wrap; scroll-margin: 6rem; }
.aq-card:last-child { border-bottom: none; }
.aq-card .kind { flex-shrink: 0; }
.aq-main { flex: 1 1 auto; min-width: 9rem; }
.aq-label { font-weight: 600; font-size: 0.9rem; color: var(--text); text-decoration: none; }
.aq-label:hover { text-decoration: underline; }
.aq-detail { font-size: 0.78rem; color: var(--text-muted); margin-top: 0.1rem; }
.aq-actions { display: flex; align-items: center; gap: 0.3rem; flex-wrap: wrap; flex-shrink: 0; }
.aq-btn { font-size: 0.72rem; padding: 0.22rem 0.5rem; border-radius: 0.3rem; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; text-decoration: none; white-space: nowrap; font-family: inherit; line-height: 1.3; }
.aq-btn:hover { background: var(--surface-hover); }
.aq-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.aq-primary:hover { filter: brightness(1.07); background: var(--accent); }
.aq-dismiss { color: var(--red, #ef4444); }
.aq-snooze { position: relative; display: inline-block; }
.aq-snooze > summary { list-style: none; }
.aq-snooze > summary::-webkit-details-marker { display: none; }
.aq-snooze-menu { display: flex; flex-direction: column; gap: 0.2rem; margin-top: 0.25rem; padding: 0.3rem; background: var(--surface); border: 1px solid var(--border); border-radius: 0.375rem; }
.aq-done { text-align: center; padding: 1.25rem 0.5rem; color: var(--text-muted); }
.aq-done-icon { font-size: 1.6rem; margin-bottom: 0.25rem; }
.aq-done-sub { font-size: 0.78rem; margin-top: 0.2rem; opacity: 0.8; }
/* Keyboard triage: selected card highlight + focus ring (works in dark + light) */
.aq-card.aq-selected { background: rgba(var(--accent-rgb, 59,130,246), 0.12); border-radius: 0.375rem; }
.aq-card:focus-visible, .aq-card.aq-selected:focus { outline: 2px solid var(--accent, #3b82f6); outline-offset: -2px; }
.aq-kbd-hint { font-size: 0.68rem; color: var(--text-muted); margin-left: 0.5rem; opacity: 0.7; }
/* Touch / no-keyboard: hide the keyboard hint (triage keys are a desktop progressive enhancement) */
@media (hover: none) { .aq-kbd-hint { display: none; } }

/* ── Fix 2: Tooltip clipping — allow tooltips to extend beyond sidebar boundary ── */
[data-sidebar="collapsed"] .sidebar {
    overflow: visible;  /* allow tooltips to extend beyond sidebar */
}
[data-sidebar="collapsed"] .sidebar-nav {
    overflow-y: auto;   /* keep nav scrollable */
    overflow-x: visible;
}

/* ── Fix 3: Visual polish ──────────────────────────────────────────────── */

/* (active item accent bar merged into primary .sidebar-item.active above) */

/* Group toggle hidden in collapsed sidebar — chevron also hidden */

/* Icon hover glow — subtle accent color on hover */
.sidebar-item:hover > i {
    color: var(--accent);
    transition: color 0.2s;
}

/* Sidebar header polish — subtle gradient line below */
.sidebar-header::after {
    content: '';
    display: block;
    height: 1px;
    background: linear-gradient(90deg, var(--accent), transparent);
    opacity: 0.3;
}

/* ── Print: hide sidebar ─────────────────────────────────────────────── */
@media print {
    .sidebar { display: none !important; }
    .container { margin-left: 0 !important; }
}

/* Stats bar */
.stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.stat-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
}
.stat-card .label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-card .value { font-size: 1.5rem; font-weight: 700; margin-top: 0.25rem; }
.stat-card .value.green { color: var(--green); }
.stat-card .value.yellow { color: var(--yellow); }
.stat-card .value.red { color: var(--red); }

/* Unit grid */
.unit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.unit-card {
    background: var(--surface);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid var(--border);
    transition: border-color 0.15s;
    cursor: pointer;
}
.unit-card:hover { border-color: var(--accent); }

.unit-card .unit-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.unit-card .unit-number { font-weight: 700; font-size: 1.1rem; }
.unit-card .floor { color: var(--text-muted); font-size: 0.8rem; }

.unit-card .tenant-name { font-size: 0.95rem; margin-bottom: 0.5rem; }
.unit-card .rent-info { font-size: 0.85rem; color: var(--text-muted); }

/* Status badges */
.badge {
    display: inline-block;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}
.badge-paid { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-partial { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-pending { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.badge-overdue { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-exiting { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-legal { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-vacant { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-late { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-missed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-short { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-overpaid { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-warn { background: rgba(234,179,8,0.15); color: var(--yellow, #eab308); }
.badge-ocmw { background: rgba(234,179,8,0.15); color: var(--yellow, #eab308); }

/* Workflows section */
.section-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 1.5rem 0 0.75rem 0;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border);
}

.workflow-list { list-style: none; }
.workflow-item {
    background: var(--surface);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.workflow-item .name { font-weight: 500; }
.workflow-item .detail { color: var(--text-muted); font-size: 0.85rem; }

/* Checklist */
.checklist { list-style: none; margin-top: 0.5rem; }
.checklist li {
    padding: 0.4rem 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
}
.checklist li.done { color: var(--text-muted); text-decoration: line-through; }
.checklist input[type="checkbox"] { accent-color: var(--accent); }

/* Chat widget */
.chat-container {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 400px;
    max-height: 600px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.chat-header {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    display: flex;
    justify-content: space-between;
}
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    min-height: 300px;
    max-height: 400px;
}
.chat-msg { margin-bottom: 0.75rem; }
.chat-msg.user { text-align: right; }
.chat-msg .bubble {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.4;
}
.chat-msg.user .bubble { background: var(--accent); color: white; }
.chat-msg.assistant .bubble { background: var(--surface-hover); color: var(--text); }
.chat-input {
    display: flex;
    border-top: 1px solid var(--border);
    padding: 0.5rem;
}
.chat-input input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-size: 0.9rem;
    outline: none;
}
.chat-input input:focus { border-color: var(--accent); }
.chat-input button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.5rem 1rem;
    margin-left: 0.5rem;
    cursor: pointer;
    font-weight: 600;
}
.chat-input button:hover { opacity: 0.9; }

/* Chat toggle button */
.chat-toggle {
    position: fixed;
    bottom: 1rem;
    right: 1rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 999;
    box-shadow: 0 4px 12px rgba(var(--accent-rgb),0.4);
    transition: box-shadow 0.3s ease;
}
.chat-toggle.has-tip {
    animation: chat-pulse 2s ease-in-out infinite;
}
@keyframes chat-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(var(--accent-rgb),0.4); }
    50% { box-shadow: 0 4px 20px rgba(var(--accent-rgb),0.7), 0 0 8px rgba(var(--accent-rgb),0.3); }
}

/* Proactive tip bubble */
.tip-bubble {
    position: fixed;
    bottom: 5rem;
    right: 1rem;
    max-width: 280px;
    background: var(--surface, #1e293b);
    border: 1px solid var(--border, #334155);
    border-radius: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text, #e2e8f0);
    font-size: 0.85rem;
    line-height: 1.4;
    cursor: pointer;
    z-index: 998;
    box-shadow: 0 4px 16px rgba(0,0,0,0.3);
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}
.tip-bubble::after {
    content: '';
    position: absolute;
    bottom: -6px;
    right: 1.5rem;
    width: 12px;
    height: 12px;
    background: var(--surface, #1e293b);
    border-right: 1px solid var(--border, #334155);
    border-bottom: 1px solid var(--border, #334155);
    transform: rotate(45deg);
    pointer-events: none;
}
.tip-bubble-text {
    flex: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.tip-bubble-close {
    background: none;
    border: none;
    color: var(--text-muted, #94a3b8);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    flex-shrink: 0;
}
.tip-bubble-close:hover { color: var(--text, #e2e8f0); }
.tip-bubble:hover { border-color: var(--accent, #3b82f6); }

/* Tip bubble animations */
.tip-bubble-enter {
    animation: tip-slide-in 0.3s ease-out forwards;
}
.tip-bubble-exit {
    animation: tip-fade-out 0.2s ease-in forwards;
}
@keyframes tip-slide-in {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes tip-fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* Chat popup — suggestion chips */
.chat-popup {
    position: fixed;
    bottom: 4.5rem;
    right: 1rem;
    width: 300px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0,0,0,0.35);
    z-index: 999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: tip-slide-in 0.25s ease-out;
}
.chat-popup.open { display: flex; }
.chat-popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9rem;
}
.chat-popup-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.1rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}
.chat-popup-close:hover { color: var(--text); }
.chat-popup-chips {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    padding: 0.75rem 1rem;
}
.tip-chip {
    display: block;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.45rem 0.75rem;
    font-size: 0.82rem;
    color: var(--text);
    text-decoration: none;
    transition: border-color 0.15s, background 0.15s;
    line-height: 1.35;
}
.tip-chip:hover {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb),0.08);
    color: var(--text);
    text-decoration: none;
}
.chat-popup-input {
    display: flex;
    gap: 0.4rem;
    padding: 0.5rem 1rem 0.75rem;
    border-top: 1px solid var(--border);
}
.chat-popup-input input {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.4rem 0.65rem;
    color: var(--text);
    font-size: 0.82rem;
    outline: none;
    min-width: 0;
}
.chat-popup-input input:focus { border-color: var(--accent); }
.chat-popup-input button {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 0.5rem;
    padding: 0.4rem 0.75rem;
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
}
.chat-popup-input button:hover { opacity: 0.88; }
@media (max-width: 640px) {
    .chat-popup { width: calc(100vw - 2rem); right: 1rem; left: 1rem; }
}

/* ── Management UI ──────────────────────────────────────────────────────── */

/* Page header with title + action button */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}
.page-header h2 { font-size: 1.3rem; font-weight: 600; }

/* Cards */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}

/* Data tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}
.data-table th {
    text-align: left;
    padding: 0.5rem 0.75rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}
.data-table tr:hover { background: rgba(var(--accent-rgb),0.04); }
.data-table tr.edit-row { background: var(--bg); }
.data-table tr.edit-row td { padding: 1rem 0.75rem; }

/* Filter bar */
.filter-bar {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}
.filter-bar input,
.filter-bar select {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    color: var(--text);
    font-size: 0.875rem;
    outline: none;
}
.filter-bar input { flex: 1; min-width: 200px; }
.filter-bar input:focus,
.filter-bar select:focus { border-color: var(--accent); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    border-radius: 0.375rem;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}
.btn:hover { background: var(--surface-hover); border-color: var(--accent); }
.btn-sm { padding: 0.25rem 0.5rem; font-size: 0.75rem; }
.btn-accent { background: var(--accent); color: white; border-color: var(--accent); }
.btn-accent:hover { opacity: 0.9; background: var(--accent); }
.btn-danger { background: rgba(239,68,68,0.15); color: var(--red); border-color: var(--red); }
.btn-danger:hover { background: rgba(239,68,68,0.25); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-muted); }
.btn-ghost:hover { color: var(--text); background: var(--surface); }

/* Detail panel (unit detail) */
.detail-panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
}
.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}
.detail-header h2 { font-size: 1.2rem; font-weight: 600; }
.detail-section {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}
.detail-section:last-child { border-bottom: none; margin-bottom: 0; }
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}
.section-header h3 { font-size: 0.95rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

/* Info grid (key-value pairs) */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 0.5rem 1.5rem;
}
.info-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}
.info-item.info-full { grid-column: 1 / -1; }
.info-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Forms */
.edit-form {
    background: var(--bg);
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    padding: 1rem;
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 0.75rem;
}
.form-grid.compact {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.5rem;
}
.form-group { display: flex; flex-direction: column; gap: 0.25rem; }
.form-group.form-full { grid-column: 1 / -1; }
.form-group label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.form-group input,
.form-group select,
.form-group textarea {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.4rem 0.5rem;
    color: var(--text);
    font-size: 0.85rem;
    outline: none;
    font-family: inherit;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.inline-edit { padding: 0; }

/* Inline select (for status dropdowns in tables) */
.inline-select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.25rem;
    padding: 0.2rem 0.4rem;
    color: var(--text);
    font-size: 0.8rem;
    cursor: pointer;
}

/* Maintenance items in unit detail */
.maint-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
    margin-bottom: 0.5rem;
}
.maint-title { font-size: 0.9rem; font-weight: 500; }
.maint-meta { font-size: 0.75rem; color: var(--text-muted); margin-top: 0.15rem; }
.maint-desc { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.25rem; }

/* Alert messages */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 0.75rem;
}
.alert-success { background: rgba(34,197,94,0.1); color: var(--green); border: 1px solid rgba(34,197,94,0.3); }
.alert-danger { background: rgba(239,68,68,0.1); color: var(--red); border: 1px solid rgba(239,68,68,0.3); }
.alert-warning { background: rgba(234,179,8,0.1); color: var(--yellow, #eab308); border: 1px solid rgba(234,179,8,0.3); }

/* Text helpers */
.text-muted { color: var(--text-muted); }

/* Additional badge colors */
.badge-active { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-terminated { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-superseded { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.badge-departed { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.badge-open { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-in_progress { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-scheduled { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-completed { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-cancelled { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.badge-initiated { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-prospect { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-normal { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.badge-high { background: rgba(249,115,22,0.15); color: var(--orange); }
.badge-urgent { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-low { background: rgba(148,163,184,0.1); color: var(--text-muted); }

/* ── Tenant Profile ─────────────────────────────────────────────────────── */

.profile-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}
.profile-header h2 { font-size: 1.4rem; font-weight: 700; margin: 0; }
.profile-meta { display: flex; gap: 0.5rem; align-items: center; margin-top: 0.25rem; font-size: 0.85rem; color: var(--text-muted); flex-wrap: wrap; }
.profile-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; align-items: center; }
.profile-actions .btn { font-size: 0.78rem; padding: 0.35rem 0.65rem; white-space: nowrap; }

/* Profile section groups */
.profile-section-title {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin: 1.5rem 0 0.5rem;
    padding-bottom: 0.3rem;
    border-bottom: 1px solid var(--border);
}
.profile-section-title:first-child { margin-top: 0; }

/* Compliance bar */
.compliance-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1.5rem;
    padding: 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
}
.compliance-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.3rem 0.6rem;
    border-radius: 0.375rem;
    font-size: 0.8rem;
    font-weight: 500;
}
.compliance-item.ok { background: rgba(34,197,94,0.1); color: var(--green); }
.compliance-item.missing { background: rgba(239,68,68,0.1); color: var(--red); }
.compliance-item.warn { background: rgba(234,179,8,0.1); color: var(--yellow); }
.compliance-item.na { background: rgba(148,163,184,0.05); color: var(--text-muted); }
.compliance-icon { font-size: 0.9rem; font-weight: 700; }

/* Profile two-column grid */
.profile-grid {
    display: grid;
    grid-template-columns: 2fr 3fr;
    gap: 1rem;
    align-items: start;
}
.profile-col { display: flex; flex-direction: column; gap: 0.75rem; }

/* Timeline */
.timeline { position: relative; padding-left: 1.5rem; }
.timeline-item {
    position: relative;
    padding-bottom: 1rem;
    padding-left: 0.75rem;
    border-left: 2px solid var(--border);
}
.timeline-item.active { border-left-color: var(--accent); }
.timeline-item:last-child { border-left-color: transparent; }
.timeline-dot {
    position: absolute;
    left: -0.45rem;
    top: 0.15rem;
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background: var(--border);
}
.timeline-dot.active { background: var(--accent); }
.timeline-dot.terminated { background: var(--red); }
.timeline-dot.superseded { background: var(--text-muted); }
.timeline-header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; }
.timeline-details { font-size: 0.8rem; color: var(--text-muted); line-height: 1.6; }

/* Communications list */
.comms-list { display: flex; flex-direction: column; gap: 0.5rem; }
.comms-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.5rem 0.75rem;
}
.comms-header { display: flex; gap: 0.5rem; align-items: center; margin-bottom: 0.25rem; }
.comms-date { font-size: 0.75rem; color: var(--text-muted); margin-left: auto; }
.comms-subject { font-size: 0.85rem; font-weight: 500; }
.comms-body { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; white-space: pre-line; }
.comms-meta { font-size: 0.7rem; color: var(--text-muted); margin-top: 0.25rem; }
.badge-email { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-mattermost { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-sms { background: rgba(234,179,8,0.15); color: var(--yellow); }
.badge-sent { background: rgba(34,197,94,0.1); color: var(--green); }
.badge-failed { background: rgba(239,68,68,0.1); color: var(--red); }
.badge-draft { background: rgba(148,163,184,0.1); color: var(--text-muted); }
.badge-signed { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-ok { background: rgba(34,197,94,0.1); color: var(--green); }
.badge-missed { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-short { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-overpaid { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-high { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-medium { background: rgba(245,158,11,0.15); color: var(--yellow); }
.badge-info { background: rgba(var(--accent-rgb),0.12); color: var(--accent); }
.badge-warning { background: rgba(234,179,8,0.15); color: var(--yellow, #eab308); }
.badge-success { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-danger { background: rgba(239,68,68,0.15); color: var(--red); }
.badge-error { background: rgba(239,68,68,0.15); color: var(--red); }

/* Indexation review */
.indexation-review .card { background: var(--surface); padding: 1rem; border-radius: 0.5rem; }
.indexation-review .data-table { width: 100%; }
.indexation-review .data-table th { font-size: 0.75rem; text-transform: uppercase; color: var(--text-muted); }
.indexation-review .data-table td, .indexation-review .data-table th { padding: 0.3rem 0.5rem; }

/* Workflow cards */
.workflow-card {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}
.workflow-title { font-size: 0.9rem; font-weight: 500; display: flex; gap: 0.5rem; align-items: center; }
.workflow-meta { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.15rem; }
.workflow-notes { font-size: 0.8rem; color: var(--text-muted); margin-top: 0.5rem; font-style: italic; }

/* Progress bar */
.checklist-progress {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0.5rem 0;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.progress-bar {
    flex: 1;
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 3px;
    transition: width 0.3s;
}

/* Payment row highlighting */
.row-warn { background: rgba(239,68,68,0.04); }
.payment-summary {
    font-size: 0.8rem;
    color: var(--text-muted);
    padding-top: 0.5rem;
    margin-top: 0.5rem;
    border-top: 1px solid var(--border);
}

/* Deposit */
.deposit-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin-bottom: 0.5rem;
}

/* Tenant link in table */
.tenant-link { color: var(--accent); text-decoration: none; }
.tenant-link:hover { text-decoration: underline; }

/* ── Mobile: hamburger toggle — deprecated with sidebar ────────────────── */
/* .nav-toggle { display: none; background: none; border: none; color: var(--text); font-size: 1.5rem; cursor: pointer; padding: 0.25rem; } */

/* ── Responsive ────────────────────────────────────────────────────────── */

/* Desktop: hide mobile-only elements */
.mobile-header { display: none; }

/* Tablet layout (grid adjustments) */
@media (max-width: 1024px) {
    .stats { grid-template-columns: repeat(2, 1fr); }
    .unit-grid { grid-template-columns: repeat(2, 1fr); }
    .profile-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: repeat(2, 1fr); }
}

/* Tablet + Phone: hamburger sidebar (≤1199px) */
@media (max-width: 1199px) {
    /* No free-resize on mobile — the sidebar is an overlay here */
    .sidebar-resize-handle { display: none !important; }
    .mobile-header {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        padding: 0.75rem 1rem;
        background: var(--surface);
        border-bottom: 1px solid var(--border);
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 198;
    }

    .mobile-hamburger {
        background: none;
        border: none;
        color: var(--text);
        font-size: 1.5rem;
        cursor: pointer;
        padding: 0.5rem;
        min-width: 48px;
        min-height: 48px;
        display: flex;
        align-items: center;
        justify-content: center;
        border-radius: 0.375rem;
    }

    .mobile-hamburger:active {
        background: rgba(var(--accent-rgb, 59,130,246), 0.15);
    }

    .mobile-brand {
        font-weight: 700;
        font-size: 1rem;
        color: var(--text);
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        z-index: 201;
        width: 280px;
    }

    .sidebar.sidebar-open {
        transform: translateX(0);
    }

    .sidebar-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.45);
        backdrop-filter: blur(2px);
        z-index: 199;
    }

    .sidebar-backdrop.active {
        display: block;
    }

    .container {
        margin-left: 0 !important;
        padding: 0.75rem;
        padding-top: 3.5rem; /* space for mobile header */
    }

    /* Touch-friendly sizing */
    .sidebar-item {
        min-height: 48px;
        padding: 0.6rem 0.75rem;
    }

    .sidebar-footer-btn {
        min-width: 48px;
        min-height: 48px;
    }

    /* Header stacks vertically */
    header { flex-direction: column; gap: 0.5rem; align-items: flex-start; padding: 0.75rem 0; margin-bottom: 1rem; }
    header h1 { font-size: 1.2rem; }

    /* Property selector in header */
    .property-selector { width: 100%; }
    .property-selector select { width: 100%; font-size: 0.9rem; }

    /* Grid layouts → single column */
    .stats { grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
    .stat-card { padding: 0.75rem; }
    .stat-card .value { font-size: 1.2rem; }
    .unit-grid { grid-template-columns: 1fr; gap: 0.75rem; }
    .form-grid { grid-template-columns: 1fr; }
    .info-grid { grid-template-columns: 1fr; }
    .profile-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .filter-bar input { min-width: 0; width: 100%; }
    .page-header { flex-direction: column; gap: 0.75rem; align-items: flex-start; }

    /* Touch-friendly buttons */
    .btn { padding: 0.5rem 0.875rem; font-size: 0.85rem; min-height: 2.5rem; }
    .btn-sm { padding: 0.4rem 0.6rem; font-size: 0.8rem; min-height: 2.25rem; }

    /* Touch-friendly checkboxes */
    input[type="checkbox"] { width: 1.25rem; height: 1.25rem; min-width: 1.25rem; }

    /* Tables: horizontal scroll */
    .data-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -0.5rem; padding: 0 0.5rem; }
    .data-table { min-width: 600px; }
    .data-table th, .data-table td { padding: 0.5rem; font-size: 0.8rem; white-space: nowrap; }

    /* Cards */
    .card { padding: 0.875rem; margin-bottom: 0.75rem; }
    .detail-panel { padding: 1rem; margin-top: 1rem; }

    /* Chat widget */
    .chat-container { width: calc(100% - 1rem); right: 0.5rem; left: 0.5rem; max-height: 70vh; }
    .chat-toggle { width: 44px; height: 44px; bottom: 0.75rem; right: 0.75rem; }
    .tip-bubble { right: 0.5rem; left: 0.5rem; max-width: none; bottom: 4rem; }

    /* Checklist items: stack date + buttons below */
    .checklist-step { flex-wrap: wrap; }
    .checklist-step input[type="date"] { width: 100%; margin-top: 0.25rem; }

    /* Workflow cards */
    .workflow-item { flex-direction: column; align-items: flex-start; gap: 0.5rem; }

    /* Profile */
    .profile-header { flex-direction: column; gap: 0.5rem; }
    .profile-actions { width: 100%; }
    .profile-actions .btn { flex: 1; justify-content: center; }
    .compliance-bar { gap: 0.35rem; padding: 0.5rem; }
    .compliance-item { font-size: 0.75rem; padding: 0.25rem 0.5rem; }

    /* Timeline */
    .timeline { padding-left: 1rem; }

    /* Photo thumbnails */
    .photo-grid { grid-template-columns: repeat(3, 1fr); }
    .photo-thumb { height: 5rem; }

    /* Export bar */
    .export-bar { flex-wrap: wrap; justify-content: flex-start; }
}

/* ── Tablet portrait (600-768px) ────────────────────────────────────────── */
@media (max-width: 768px) {
    /* Touch-friendly form inputs across the entire app */
    input, select, textarea, button {
        font-size: 16px !important; /* prevents iOS zoom on focus */
        min-height: 2.5rem;
    }
    input[type="number"] { min-height: 2.5rem; }
    select { -webkit-appearance: menulist; padding: 0.4rem 0.5rem !important; }

    /* Profile actions: wrap nicely on tablet */
    .profile-actions {
        display: flex !important;
        flex-wrap: wrap !important;
        gap: 0.4rem !important;
    }
    .profile-actions .btn, .profile-actions a.btn {
        flex: 1 1 auto;
        min-width: 45%;
        text-align: center;
        white-space: nowrap;
        font-size: 0.8rem !important;
    }

    /* Condition form: stack element rows for tablet */
    details > div[style*="grid-template-columns: 120px"] {
        grid-template-columns: 1fr 1fr !important;
    }
    details > div[style*="grid-template-columns: 140px"] {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Damage rows: stack on narrow */
    .damage-row {
        grid-template-columns: 1fr 1fr !important;
    }

    /* Furniture rows: stack */
    .furn-row {
        grid-template-columns: 1fr 1fr !important;
        gap: 0.3rem !important;
    }

    /* Inline grids with 2 columns: keep 2 on tablet */
    div[style*="grid-template-columns: 1fr 1fr"][style*="gap: 0.3rem"] {
        grid-template-columns: 1fr !important;
    }

    /* Lawyer portal: procedure stepper wraps */
    div[style*="min-width: 100px"][style*="text-align: center"] {
        min-width: 80px !important;
        font-size: 0.65rem !important;
    }

    /* Nav bar: wrap on tablet */
    .navbar {
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
    }

    /* Portal nav: horizontal scroll on tablet */
    .portal-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
        padding-bottom: 0.25rem;
    }
    .portal-nav a {
        display: inline-block;
        white-space: nowrap;
    }
}

/* Small phone */
@media (max-width: 480px) {
    .stats { grid-template-columns: 1fr; }
    .stat-card .label { font-size: 0.65rem; }
    header h1 { font-size: 1rem; }
    .photo-grid { grid-template-columns: repeat(2, 1fr); }

    /* Profile actions: full-width stack */
    .profile-actions .btn, .profile-actions a.btn {
        min-width: 100% !important;
    }

    /* Condition form: fully stacked */
    details > div[style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .damage-row, .furn-row {
        grid-template-columns: 1fr !important;
    }

    /* Procedure stepper: vertical on phone */
    div[style*="min-width: 100px"][style*="text-align: center"] {
        min-width: 100% !important;
    }
}

/* ── Utility: print-only / no-print ────────────────────────────────────── */

.print-only { display: none; }
.no-print { display: block; }

/* ── Export bar ─────────────────────────────────────────────────────────── */

.export-bar {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    justify-content: flex-end;
}

/* ── Print styles ───────────────────────────────────────────────────────── */

@media print {
    /* Base */
    body {
        background: #fff;
        color: #000;
        font-size: 11pt;
        box-shadow: none;
    }

    /* Layout */
    .container {
        max-width: 100%;
        padding: 0;
        margin-left: 0 !important;
    }

    /* Hide interactive / chrome elements */
    .sidebar,
    nav,
    header nav,
    .profile-actions,
    .btn,
    button,
    #unit-detail,
    script,
    .export-bar,
    .chat-container,
    .chat-toggle,
    .tip-bubble,
    .filter-bar,
    .no-print { display: none !important; }

    /* Cards */
    .card,
    .detail-panel,
    .stat-card,
    .unit-card,
    .workflow-card,
    .maint-item,
    .deposit-item,
    .comms-item {
        border-radius: 0;
        border: 1px solid #ccc;
        box-shadow: none;
        background: #fff;
        color: #000;
        page-break-inside: avoid;
        break-inside: avoid;
    }

    /* Tables */
    .data-table {
        width: 100%;
    }
    .data-table th,
    .data-table td {
        padding: 4px;
        border: 1px solid #ccc;
        color: #000;
        background: #fff;
    }
    .data-table th {
        background: #f0f0f0;
    }
    .data-table tr:hover { background: #fff; }

    /* Profile grid — single column */
    .profile-grid {
        display: block;
    }
    .profile-col { margin-bottom: 1rem; }

    /* Remove dark-mode colors from text and muted text */
    .text-muted,
    .info-label,
    .stat-card .label,
    .timeline-details,
    .comms-body,
    .comms-meta,
    .maint-meta,
    .maint-desc,
    .workflow-meta,
    .workflow-notes,
    .payment-summary { color: #555; }

    /* Show print-only elements */
    .print-only { display: block !important; }
}

/* ── Contract builder ───────────────────────────────────────────────── */
.clause-card { transition: opacity 0.15s; }
.clause-card.disabled { opacity: 0.4; }
.clause-body-preview {
    font-size: 0.8rem;
    color: var(--text-muted);
    cursor: pointer;
    max-height: 3em;
    overflow: hidden;
    line-height: 1.5;
}
.badge-generated { background: rgba(34,197,94,0.15); color: var(--green); }

/* Exit Checklist Panel */
.exit-checklist {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.checklist-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}
.checklist-item:hover {
    background: var(--surface-hover);
}
.checklist-item.done {
    opacity: 0.6;
}
.checklist-label {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    cursor: pointer;
    flex: 1;
    font-size: 0.9rem;
}
.checklist-check {
    font-size: 1.1rem;
    min-width: 1.2rem;
    text-align: center;
}
.checklist-item.done .checklist-text {
    text-decoration: line-through;
    color: var(--text-muted);
}
.checklist-date {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.badge-completed { background: rgba(34,197,94,0.15); color: var(--green); }
.badge-cancelled { background: rgba(148,163,184,0.15); color: var(--text-muted); }
.badge-in_progress { background: rgba(var(--accent-rgb),0.15); color: var(--accent); }
.badge-initiated { background: rgba(249,115,22,0.15); color: var(--orange); }
#exit-panel-container .detail-panel {
    margin-top: 1rem;
    animation: fadeIn 0.2s ease-in;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ── Photo uploads ─────────────────────────────────────────────────────── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-top: 0.5rem;
}
.photo-thumb {
    position: relative;
    height: 6rem;
    border-radius: 0.375rem;
    overflow: hidden;
    border: 1px solid var(--border);
    cursor: pointer;
}
.photo-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}
.photo-thumb .photo-delete {
    position: absolute;
    top: 0.15rem;
    right: 0.15rem;
    background: rgba(0,0,0,0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 1.25rem;
    height: 1.25rem;
    font-size: 0.7rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
.photo-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 0.375rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    cursor: pointer;
    transition: border-color 0.15s;
}
.photo-upload-btn:hover { border-color: var(--accent); color: var(--text); }
.photo-upload-btn input[type="file"] { display: none; }

/* ── Data table responsive wrapper ─────────────────────────────────────── */
.data-table-wrap { overflow-x: auto; }

/* ── Property selector ─────────────────────────────────────────────────── */
.property-selector select {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    padding: 0.3rem 0.5rem;
    color: var(--accent);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
}
.property-selector select:focus { border-color: var(--accent); outline: none; }

/* ── Cost page ─────────────────────────────────────────────────────────── */
.cost-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}
.cost-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1rem;
}
.cost-card .cost-label { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.cost-card .cost-value { font-size: 1.3rem; font-weight: 700; margin-top: 0.25rem; }
.cost-card .cost-value.negative { color: var(--red); }
.cost-bar { height: 4px; background: var(--border); border-radius: 2px; margin-top: 0.5rem; overflow: hidden; }
.cost-bar-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── Owner page ────────────────────────────────────────────────────────── */
.owner-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
}
.owner-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; }
.owner-name { font-size: 1.1rem; font-weight: 600; }
.owner-units { display: flex; flex-wrap: wrap; gap: 0.5rem; margin-top: 0.5rem; }
.owner-unit-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.2rem 0.5rem;
    background: rgba(var(--accent-rgb),0.1);
    border-radius: 0.25rem;
    font-size: 0.75rem;
    color: var(--accent);
}

/* Hide non-essential table columns on narrow viewports.
   Used by tenant_profile payment history and similar dense tables. */
@media (max-width: 900px) {
    .hide-narrow { display: none !important; }
}

/* ── Command Palette ──────────────────────────────────────────────────────── */
.cp-overlay {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 15vh;
}
.cp-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
}
.cp-dialog {
    position: relative;
    width: 90%;
    max-width: 560px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}
.cp-search-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
}
.cp-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-size: 1rem;
    font-family: inherit;
}
.cp-input::placeholder { color: var(--text-muted); }
.cp-kbd {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
    border-radius: 0.25rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-family: inherit;
}
.cp-results {
    max-height: 50vh;
    overflow-y: auto;
    padding: 0.25rem 0;
}
.cp-category {
    padding: 0.4rem 1rem 0.2rem;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.cp-result {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.5rem 1rem;
    font-size: 0.88rem;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.1s;
}
.cp-result:hover, .cp-result.cp-selected {
    background: var(--surface-hover);
}
.cp-result i {
    font-size: 0.9rem;
    color: var(--text-muted);
    width: 1.2rem;
    text-align: center;
}
.cp-hint {
    padding: 1.5rem 1rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* Search icon in nav */
.nav-search-btn {
    opacity: 0.7;
    transition: opacity 0.15s;
}
.nav-search-btn:hover { opacity: 1; }

@media (max-width: 768px) {
    .cp-overlay { padding-top: 5vh; }
    .cp-dialog { width: 95%; max-width: none; }
}

/* ── Phase Stepper Bar ──────────────────────────────────────────────── */
.phase-stepper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    overflow-x: auto;
}
.stepper-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    text-decoration: none;
    color: var(--text-muted);
    min-width: 3.5rem;
    cursor: pointer;
    transition: color 0.2s;
}
.stepper-item:hover { color: var(--text); }
.stepper-circle {
    width: 1.6rem;
    height: 1.6rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    border: 2px solid var(--border);
    background: var(--bg);
    color: var(--text-muted);
    transition: all 0.2s;
}
.stepper-done .stepper-circle {
    background: var(--green, #22c55e);
    border-color: var(--green, #22c55e);
    color: #fff;
}
.stepper-current .stepper-circle {
    border-color: var(--accent);
    background: rgba(var(--accent-rgb),0.15);
    color: var(--accent);
    box-shadow: 0 0 0 3px rgba(var(--accent-rgb),0.15);
}
.stepper-label { font-size: 0.6rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.stepper-current .stepper-label { color: var(--accent); }
.stepper-done .stepper-label { color: var(--green, #22c55e); }
.stepper-count { font-size: 0.55rem; color: var(--text-muted); }
.stepper-line {
    flex: 1;
    height: 2px;
    background: var(--border);
    min-width: 1rem;
    max-width: 3rem;
    align-self: center;
    margin-bottom: 1.2rem;
}
.stepper-line-done { background: var(--green, #22c55e); }

@media (max-width: 640px) {
    .stepper-item { min-width: 2.5rem; }
    .stepper-label { font-size: 0.5rem; }
    .stepper-circle { width: 1.3rem; height: 1.3rem; font-size: 0.6rem; }
}

/* ── Phase Accordion ────────────────────────────────────────────────── */
.phase-accordion {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    margin-bottom: 0.5rem;
    overflow: hidden;
}
.phase-accordion.phase-completed { border-left: 3px solid var(--green, #22c55e); }
.phase-accordion.phase-open { border-left: 3px solid var(--accent); }
.phase-accordion.phase-future { opacity: 0.7; }
.phase-accordion.phase-future:hover { opacity: 1; }

.phase-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
}
.phase-header:hover { background: rgba(var(--accent-rgb),0.04); }

.phase-icon {
    width: 1.4rem;
    height: 1.4rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    flex-shrink: 0;
}
.phase-completed .phase-icon { background: var(--green, #22c55e); color: #fff; }
.phase-open .phase-icon { background: var(--accent); color: #fff; }
.phase-future .phase-icon { background: var(--bg); color: var(--text-muted); border: 1px solid var(--border); }

.phase-title { font-size: 0.8rem; font-weight: 600; }
.phase-completed .phase-title { color: var(--text-muted); }

.phase-progress {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.phase-chevron {
    font-size: 0.5rem;
    color: var(--text-muted);
    transition: transform 0.2s;
}
.phase-open .phase-chevron { transform: rotate(180deg); }

.phase-body {
    max-height: 0;
    overflow: hidden;
    padding: 0 1rem;
    transition: max-height 0.3s ease-out, padding 0.2s ease-out;
}
.phase-open .phase-body {
    max-height: none;
    overflow: visible;
    padding: 0 1rem 1rem;
}

/* ── Toast notifications ────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    pointer-events: none;
}

/* Centered announcement popup — for important notifications (bug fixes, updates) */
.announce-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--surface);
    border: 1px solid var(--accent);
    border-radius: 0.75rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
    padding: 1.5rem 2rem;
    z-index: 9998;
    max-width: 420px;
    text-align: center;
    animation: announce-in 0.3s ease;
}
.announce-popup .announce-icon {
    font-size: 2rem;
    color: var(--green);
    margin-bottom: 0.5rem;
}
/* Variants — set via showAnnouncement(title, body, icon, 'error'|'warning'|'info') */
.announce-popup.announce-popup--error   .announce-icon { color: var(--red, #ef4444); }
.announce-popup.announce-popup--warning .announce-icon { color: var(--yellow, #f59e0b); }
.announce-popup.announce-popup--info    .announce-icon { color: var(--accent); }
.announce-popup.announce-popup--error   { border-color: var(--red, #ef4444); }
.announce-popup.announce-popup--warning { border-color: var(--yellow, #f59e0b); }
.announce-popup .announce-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.announce-popup .announce-body {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}
.announce-popup .announce-close {
    background: none;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    color: var(--text);
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85rem;
}
.announce-popup .announce-close:hover {
    background: var(--surface-hover);
}
.announce-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 9997;
}
@keyframes announce-in {
    from { opacity: 0; transform: translate(-50%, -50%) scale(0.95); }
    to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.toast {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    min-width: 18rem;
    max-width: 26rem;
    background: var(--surface);
    border: 1px solid var(--border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: all;
    animation: toast-in 0.25s ease-out;
}

.toast.toast-hiding {
    animation: toast-out 0.3s ease-in forwards;
}

.toast-icon {
    font-size: 1rem;
    flex-shrink: 0;
    margin-top: 0.05rem;
}

.toast-message {
    flex: 1;
    font-size: 0.85rem;
    line-height: 1.4;
    color: var(--text);
}

.toast-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color 0.15s;
}
.toast-close:hover { color: var(--text); }

/* Accent bar on left edge */
.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0.5rem 0 0 0.5rem;
}
.toast { position: relative; }

.toast-success::before { background: var(--green); }
.toast-success .toast-icon { color: var(--green); }

.toast-error::before { background: var(--red); }
.toast-error .toast-icon { color: var(--red); }

.toast-info::before { background: var(--accent); }
.toast-info .toast-icon { color: var(--accent); }

.toast-warning::before { background: var(--orange); }
.toast-warning .toast-icon { color: var(--orange); }

@keyframes toast-in {
    from { opacity: 0; transform: translateX(2rem); }
    to   { opacity: 1; transform: translateX(0); }
}

@keyframes toast-out {
    from { opacity: 1; transform: translateX(0); max-height: 6rem; margin-bottom: 0; }
    to   { opacity: 0; transform: translateX(2rem); max-height: 0; margin-bottom: -0.5rem; }
}

/* ── Help tip tooltips ──────────────────────────────────────────────── */
.help-tip {
    position: relative;
    display: inline-flex;
    align-items: center;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.help-tip-icon {
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
    text-decoration: none;
    line-height: 1;
}

.help-tip-icon:hover,
.help-tip-icon:focus {
    opacity: 1;
    color: var(--accent);
    outline: none;
}

.help-tip-bubble {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--surface);
    color: var(--text);
    font-size: 0.72rem;
    font-weight: 400;
    line-height: 1.4;
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    border: 1px solid var(--border);
    max-width: 250px;
    width: max-content;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    z-index: 9999;
    transition: opacity 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.4);
}

/* Arrow pointing down */
.help-tip-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: var(--border);
}

.help-tip-bubble::before {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: var(--surface);
    margin-top: -1px;
    z-index: 1;
}

.help-tip:hover .help-tip-bubble,
.help-tip-icon:focus ~ .help-tip-bubble {
    visibility: visible;
    opacity: 1;
}

/* ── Sidebar count badges ───────────────────────────────────────────── */
.sidebar-count-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.25rem;
    height: 1.25rem;
    padding: 0 0.35rem;
    border-radius: 0.625rem;
    font-size: 0.65rem;
    font-weight: 700;
    background: var(--accent);
    color: #fff;
    margin-left: auto;
    flex-shrink: 0;
}

.sidebar-count-badge:empty { display: none; }

/* Pulsing attention dot — appears on sidebar items with non-empty badges */
.sidebar-count-badge:not(:empty)::before {
    content: '';
    position: absolute;
    top: -2px;
    right: -2px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--yellow);
    animation: sidebar-pulse 2s ease-in-out infinite;
}
.sidebar-count-badge { position: relative; }

@keyframes sidebar-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(1.3); }
}

/* Sub-items under onboarding/offboarding */
.sidebar-sub-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0.75rem 0.25rem 2.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.375rem;
    transition: color 0.15s, background 0.15s;
}

.sidebar-sub-item:hover {
    color: var(--text);
    background: var(--surface-hover);
}

.sidebar-sub-dot {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: var(--accent);
    flex-shrink: 0;
}

/* Hide sub-items and badges when sidebar is collapsed */
[data-sidebar="collapsed"] .sidebar-sub-item,
[data-sidebar="collapsed"] .sidebar-count-badge {
    display: none;
}

/* ── Waiting badge (R4) ─────────────────────────────────────────────── */
.badge-waiting {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    padding: 0.15rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.65rem;
    font-weight: 600;
    background: rgba(234,179,8,0.15);
    color: #b45309;
    white-space: nowrap;
}

/* ── SLA aging borders ─────────────────────────────────────────────── */
.sla-border-green { border-left: 4px solid var(--green, #22c55e); }
.sla-border-yellow { border-left: 4px solid var(--yellow, #f59e0b); }
.sla-border-red { border-left: 4px solid var(--red, #ef4444); }
.sla-border-dark-red { border-left: 4px solid #991b1b; }

/* ── SLA badges ────────────────────────────────────────────────────── */
.sla-badge { font-size: 0.7rem; padding: 0.15rem 0.4rem; border-radius: 0.25rem; font-weight: 600; white-space: nowrap; }
.sla-badge-green { background: rgba(34,197,94,0.15); color: #16a34a; }
.sla-badge-yellow { background: rgba(245,158,11,0.15); color: #d97706; }
.sla-badge-red { background: rgba(239,68,68,0.15); color: #dc2626; }
.sla-badge-dark-red { background: rgba(153,27,27,0.15); color: #991b1b; }

/* ── SLA compliance header ─────────────────────────────────────────── */
.sla-compliance-bar {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.85rem;
}
.sla-compliance-bar .sla-pct { font-size: 1.25rem; font-weight: 700; }
.sla-compliance-good { background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.3); }
.sla-compliance-warn { background: rgba(245,158,11,0.1); border: 1px solid rgba(245,158,11,0.3); }
.sla-compliance-bad { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); }
.sla-compliance-neutral { background: rgba(148,163,184,0.08); border: 1px solid rgba(148,163,184,0.25); color: var(--text-muted); }

/* ── Sortable columns ──────────────────────────────────────────────── */
.sortable-th { cursor: pointer; user-select: none; white-space: nowrap; }
.sortable-th:hover { color: var(--accent); }
.sort-arrow { font-size: 0.7em; margin-left: 0.25rem; opacity: 0.4; }
.sort-arrow.active { opacity: 1; color: var(--accent); }

/* ── Overdue pulsing dot ───────────────────────────────────────────── */
.overdue-dot {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--red, #ef4444);
    margin-left: 0.3rem;
    animation: overdue-pulse 1.5s ease-in-out infinite;
    vertical-align: middle;
}
@keyframes overdue-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ── Maintenance timeline ─────────────────────────────────────────── */
.maint-timeline { list-style: none; padding: 0; margin: 0.5rem 0; }
.maint-timeline li { position: relative; padding-left: 1.5rem; padding-bottom: 0.75rem; border-left: 2px solid var(--border); }
.maint-timeline li:last-child { border-left: none; }
.maint-timeline li::before { content: ''; position: absolute; left: -5px; top: 2px; width: 8px; height: 8px; border-radius: 50%; background: var(--border); }
.maint-timeline li.reached::before { background: var(--accent, #3b82f6); }
.maint-timeline li.reached { border-left-color: var(--accent, #3b82f6); }
.maint-timeline .tl-date { font-size: 0.75rem; color: var(--text-muted); }
.maint-timeline .tl-msg { font-size: 0.78rem; color: var(--text); margin-top: 0.2rem; font-style: italic; }

/* ── Photo gallery ────────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(80px, 1fr)); gap: 0.5rem; margin-top: 0.5rem; }
.photo-grid img { width: 100%; height: 80px; object-fit: cover; border-radius: 0.375rem; cursor: pointer; border: 1px solid var(--border); }
.photo-lightbox { position: fixed; inset: 0; background: rgba(0,0,0,0.8); display: none; align-items: center; justify-content: center; z-index: 9999; }
.photo-lightbox:target { display: flex; }
.photo-lightbox img { max-width: 90vw; max-height: 90vh; border-radius: 0.5rem; }
.photo-lightbox .close { position: absolute; top: 1rem; right: 1rem; color: #fff; font-size: 2rem; text-decoration: none; }

/* ── Notify modal ─────────────────────────────────────────────────── */
.notify-modal-content { background: var(--bg-card, var(--surface, var(--bg))); border: 1px solid var(--border); border-radius: 0.5rem; padding: 1.5rem; max-width: 500px; margin: 1rem; width: 100%; }

/* ── Gamification dashboard card ─────────────────────────────────── */
.gamification-card { background: var(--bg-card, var(--bg)); border: 1px solid rgba(var(--accent-rgb),0.2); border-radius: 0.5rem; padding: 1rem; margin-bottom: 0.75rem; }
.gc-top { display: flex; gap: 1.5rem; flex-wrap: wrap; }
.gc-ring-section { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; min-width: 100px; }
.gc-ring-wrap { position: relative; width: 80px; height: 80px; }
.gc-ring-lg { width: 100%; height: 100%; }
.gc-ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.gc-ring-xp { font-size: 1.2rem; font-weight: 800; color: var(--text); line-height: 1; }
.gc-ring-target { font-size: 0.7rem; color: var(--text-muted); }
.gc-streak { display: flex; align-items: center; gap: 0.25rem; font-size: 0.9rem; }
.gc-streak-fire { font-size: 1.1rem; }
.gc-streak-num { font-weight: 700; color: var(--text); }
.gc-streak-label { color: var(--text-muted); font-size: 0.75rem; }
.gc-best-streak { font-size: 0.7rem; color: var(--text-muted); }

/* Badge grid */
.gc-badges { flex: 1; min-width: 200px; }
.gc-badges-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.gc-badge-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); gap: 0.4rem; }
.gc-badge { display: flex; flex-direction: column; align-items: center; padding: 0.4rem; border-radius: 0.375rem; font-size: 0.72rem; text-align: center; border: 1px solid var(--border); }
.gc-badge-earned { background: rgba(var(--accent-rgb), 0.08); border-color: rgba(var(--accent-rgb), 0.2); }
.gc-badge-locked { opacity: 0.4; }
.gc-badge-icon { font-size: 1.2rem; margin-bottom: 0.15rem; }
.gc-badge-name { color: var(--text); line-height: 1.2; }

/* XP History chart */
.gc-chart { margin-top: 0.75rem; }
.gc-chart-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.4rem; }
.gc-chart-bars { display: flex; align-items: flex-end; gap: 0.35rem; height: 60px; }
.gc-bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; justify-content: flex-end; }
.gc-bar { width: 100%; min-height: 2px; background: var(--accent); border-radius: 0.15rem 0.15rem 0 0; transition: height 0.3s; }
.gc-bar-hit { background: var(--green, #22c55e); }
.gc-bar-label { font-size: 0.6rem; color: var(--text-muted); margin-top: 0.15rem; }

/* Settings */
.gc-settings { margin-top: 0.75rem; padding-top: 0.75rem; border-top: 1px solid var(--border); }
.gc-intensity { display: flex; gap: 0.35rem; flex-wrap: wrap; margin-bottom: 0.5rem; }
.gc-intensity-chip { padding: 0.3rem 0.6rem; border: 1px solid var(--border); border-radius: 1rem; font-size: 0.72rem; cursor: pointer; color: var(--text-muted); transition: all 0.15s; }
.gc-intensity-active { border-color: var(--accent); background: rgba(var(--accent-rgb), 0.1); color: var(--accent); font-weight: 600; }
.gc-weekend-toggle { font-size: 0.78rem; color: var(--text-muted); display: flex; align-items: center; gap: 0.35rem; cursor: pointer; }

/* Suggested actions */
.gc-suggestions { margin-top: 0.75rem; }
.gc-suggestions-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); margin-bottom: 0.35rem; }
.gc-suggestion { display: flex; align-items: center; gap: 0.5rem; padding: 0.4rem 0.5rem; border-radius: 0.375rem; font-size: 0.8rem; color: var(--text); text-decoration: none; transition: background 0.15s; }
.gc-suggestion:hover { background: var(--surface-hover); }
.gc-suggestion i { color: var(--accent); font-size: 0.9rem; }
.gc-suggestion-xp { margin-left: auto; color: var(--green, #22c55e); font-weight: 600; font-size: 0.75rem; }
