/* ==========================================================================
   Gestionale Immobiliare — Global Styles (Phase 1)
   ========================================================================== */

/* Enforce the HTML `hidden` attribute even on elements with explicit display rules (e.g. .btn uses inline-flex) */
[hidden] { display: none !important; }

:root {
    --color-primary:       #206bac;
    --color-primary-dark:  #174f82;
    --color-primary-light: #deeef9;
    --color-sidebar-bg:    #0d2140;
    --color-sidebar-hover: #1a3a6e;
    --color-sidebar-active:#206bac;
    --color-bg:            #f2f6fb;
    --color-surface:       #ffffff;
    --color-surface-muted: #f8fafb;
    --color-text:          #1a2535;
    --color-text-muted:    #5a7291;
    --color-border:        #d3e0ef;
    --color-border-strong: #b4c8e0;
    --color-zebra:         #f4f8fc;
    --color-success:       #16a34a;
    --color-warning:       #d97706;
    --color-danger:        #dc2626;
    --sidebar-width:       260px;
    --topbar-height:       64px;
    --radius:              12px;
    --radius-sm:           8px;
    --shadow:              0 1px 2px rgba(13, 33, 64, 0.05), 0 1px 3px rgba(13, 33, 64, 0.05);
    --shadow-md:           0 6px 18px rgba(13, 33, 64, 0.08), 0 2px 6px rgba(13, 33, 64, 0.05);
    --shadow-lg:           0 18px 40px rgba(13, 33, 64, 0.16), 0 6px 14px rgba(13, 33, 64, 0.08);
    --section-gap:         28px;
    --transition:          0.18s ease;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--color-text);
    background: var(--color-bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

.settings-tabs { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }
.settings-tab { padding: 8px 16px; border: 1px solid var(--color-border); background: var(--color-surface); border-radius: var(--radius); cursor: pointer; font-size: 14px; }
.settings-tab--active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); }
.settings-panel .card { padding: 24px; }
.form-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.app-layout {
    display: flex;
    min-height: 100vh;
}

.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    margin-left: var(--sidebar-width);
    transition: margin-left var(--transition);
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--color-sidebar-bg);
    color: #cbd5e1;
    display: flex;
    flex-direction: column;
    z-index: 1100;
    transition: transform var(--transition);
}

/* Desktop: X button collapses the sidebar; hamburger re-opens it */
body.sidebar-collapsed .sidebar {
    transform: translateX(-100%);
}

body.sidebar-collapsed .main-wrapper {
    margin-left: 0;
}

body.sidebar-collapsed .sidebar-toggle {
    display: flex;
}

.sidebar.open {
    transform: translateX(0);
}

.sidebar-header {
    padding: 18px 20px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
}

.logo {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}

.logo-img {
    display: block;
    width: auto;
    height: auto;
    max-height: 64px;
    max-width: 100%;
    object-fit: contain;
    object-position: left center;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    font-size: 13px;
    font-weight: 700;
    color: #f8fafc;
    line-height: 1.35;
}

.logo-text small {
    font-size: 11px;
    font-weight: 400;
    color: #94a3b8;
    white-space: nowrap;
}

.sidebar-close-btn {
    display: none; /* Desktop: sidebar always open, no close button. Shown on mobile only. */
    background: none;
    border: none;
    color: #64748b;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 4px;
    flex-shrink: 0;
    margin-top: 2px;
    transition: color var(--transition), background var(--transition);
}

.sidebar-close-btn:hover {
    color: #f8fafc;
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    padding: 16px 0;
}

.sidebar-nav ul {
    list-style: none;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: #cbd5e1;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background var(--transition), color var(--transition);
    border-left: 3px solid transparent;
}

.nav-link:hover {
    background: var(--color-sidebar-hover);
    color: #f8fafc;
}

.nav-link.active {
    background: rgba(32, 107, 172, 0.18);
    color: #93c5fd;
    border-left-color: var(--color-sidebar-active);
}

.nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

/* Collapsible nav groups */
details.nav-group {
    margin: 0;
    padding: 0;
}
details.nav-group > summary {
    display: flex;
    align-items: center;
    padding: 10px 20px 4px;
    color: #94a3b8;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    cursor: pointer;
    list-style: none;
    user-select: none;
}
details.nav-group > summary::-webkit-details-marker { display: none; }
details.nav-group > summary::marker { display: none; }
details.nav-group > summary:hover { color: #e2e8f0; }
.nav-group-label { flex: 1; }
.nav-group-arrow {
    font-size: 10px;
    opacity: 0.6;
    display: inline-block;
    transition: transform var(--transition);
}
details.nav-group[open] > summary .nav-group-arrow {
    transform: rotate(180deg);
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
}

.user-name {
    font-size: 14px;
    font-weight: 600;
    color: #e2e8f0;
}

/* --------------------------------------------------------------------------
   Topbar
   -------------------------------------------------------------------------- */
.topbar {
    height: var(--topbar-height);
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow);
}

.sidebar-toggle {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
}

.sidebar-toggle span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--color-text);
    border-radius: 2px;
}

.page-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--color-text);
}

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */
.app-content {
    flex: 1;
    min-width: 0;
    padding: 28px 28px 40px;
    overflow-y: auto;
    height: calc(100vh - var(--topbar-height));
}

/* Section blocks inside views */
.content-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px 22px;
    margin-bottom: var(--section-gap);
}

.content-section:last-child {
    margin-bottom: 0;
}

.content-section__title {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
}

/* --------------------------------------------------------------------------
   Loading spinner
   -------------------------------------------------------------------------- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 60px 0;
    color: var(--color-text-muted);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* --------------------------------------------------------------------------
   Dashboard
   -------------------------------------------------------------------------- */
.dashboard-header {
    margin-bottom: 28px;
}

.dashboard-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--color-text);
    margin-bottom: 4px;
}

.dashboard-header p {
    color: var(--color-text-muted);
    font-size: 14px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.settings-panel .card { padding: 24px; }
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    border: 1px solid var(--color-border);
    display: flex;
    align-items: flex-start;
    gap: 16px;
    transition: box-shadow var(--transition), transform var(--transition);
}

.stat-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon--clients    { background: #dbeafe; }
.stat-icon--properties { background: #dcfce7; }
.stat-icon--available  { background: #dcfce7; }
.stat-icon--rented     { background: #dbeafe; }
.stat-icon--tenants    { background: #f3e8ff; }
.stat-icon--reminders  { background: #fef3c7; }
.stat-icon--overdue    { background: #fef2f2; }
.stat-icon--sold       { background: #f3e8ff; }
/* Lucide icons inside the stat tiles: size + per-type tint */
.stat-icon svg { width: 24px; height: 24px; }
.stat-icon--clients svg, .stat-icon--rented svg     { color: #2563eb; }
.stat-icon--properties svg, .stat-icon--available svg { color: #16a34a; }
.stat-icon--tenants svg, .stat-icon--sold svg        { color: #7c3aed; }
.stat-icon--reminders svg { color: #d97706; }
.stat-icon--overdue svg   { color: #dc2626; }

.stat-card--alert {
    border-color: #fecaca;
    background: #fff8f8;
}

.stat-card--alert .stat-value {
    color: var(--color-danger);
}

.stat-body {
    flex: 1;
}

.stat-label {
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 32px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
}

.stat-value.loading {
    color: var(--color-text-muted);
    font-size: 24px;
}

.stat-sub {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 4px;
}

/* Placeholder view */
.placeholder-view {
    text-align: center;
    padding: 80px 24px;
    color: var(--color-text-muted);
}

.placeholder-view .placeholder-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.placeholder-view h2 {
    font-size: 22px;
    color: var(--color-text);
    margin-bottom: 8px;
}

/* Error alert */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 20px;
}

.alert--error {
    background: #fef2f2;
    color: var(--color-danger);
    border: 1px solid #fecaca;
}

.alert--success {
    background: #f0fdf4;
    color: var(--color-success);
    border: 1px solid #bbf7d0;
}

.alert--warning {
    background: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.alert--info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.text-muted {
    color: var(--color-text-muted);
    font-size: 13px;
}

/* --------------------------------------------------------------------------
   View header & toolbar (Phase 2+)
   -------------------------------------------------------------------------- */
.view-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: var(--section-gap);
    padding-bottom: 18px;
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.view-header__actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.view-header h2 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.view-header p {
    color: var(--color-text-muted);
    font-size: 14px;
}

.toolbar,
.reports-toolbar,
.filter-bar {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
}

.toolbar {
    margin-bottom: 18px;
    padding: 14px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.filter-bar__actions {
    display: flex;
    justify-content: flex-end;
    flex-shrink: 0;
}

.filter-bar__controls {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    min-width: 0;
}

.filter-bar__controls .search-box {
    flex: 1 1 200px;
    min-width: 0;
}

.filter-bar__controls > .form-input,
.filter-bar__controls > .form-select,
.filter-bar__controls > input[type="search"],
.filter-bar__controls > input[type="date"],
.filter-bar__controls > input[type="text"] {
    flex: 0 1 auto;
    min-width: 140px;
    max-width: 100%;
}

.btn-clear-filters {
    flex-shrink: 0;
    white-space: nowrap;
    margin-left: auto;
    align-self: center;
    gap: 6px;
    background: #fef2f2;
    border-color: #fca5a5;
    color: #dc2626;
    animation: filter-clear-in 0.18s ease-out;
}

.btn-clear-filters[hidden] {
    display: none;
}

@keyframes filter-clear-in {
    from { opacity: 0; transform: translateX(6px); }
    to   { opacity: 1; transform: translateX(0); }
}

.btn-clear-filters:hover {
    background: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.search-box {
    flex: 1;
    min-width: 0;
}

/* --------------------------------------------------------------------------
   Buttons
   -------------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius);
    border: 1px solid transparent;
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition), color var(--transition);
    white-space: nowrap;
    font-family: inherit;
    line-height: 1.4;
}

.btn--primary {
    background: var(--color-primary);
    color: #fff;
}

.btn--primary:hover {
    background: var(--color-primary-dark);
}

.btn--ghost {
    background: transparent;
    color: var(--color-text-muted);
    border-color: var(--color-border);
}

.btn--ghost:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

/* Outlined primary — pairs with a solid primary button (e.g. dashboard "+ Proprietario") */
.btn--outline-primary {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
    border-color: var(--color-primary);
}

.btn--outline-primary:hover {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.btn--danger {
    background: var(--color-danger);
    color: #fff;
}

.btn--danger:hover {
    background: #b91c1c;
}

/* CSV / data transfer actions */
.btn--export {
    background: #ecfdf5;
    color: #047857;
    border-color: #34d399;
    box-shadow: 0 1px 2px rgba(4, 120, 87, 0.08);
}

.btn--export:hover {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

.btn--import {
    background: #eff6ff;
    color: #1d4ed8;
    border-color: #60a5fa;
    box-shadow: 0 1px 2px rgba(29, 78, 216, 0.08);
}

.btn--import:hover {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e3a8a;
}

/* Compare properties action (analytics / indigo) */
.btn--compare {
    background: #eef2ff;
    color: #4338ca;
    border-color: #a5b4fc;
    box-shadow: 0 1px 2px rgba(67, 56, 202, 0.08);
}

.btn--compare:hover {
    background: #e0e7ff;
    border-color: #818cf8;
    color: #3730a3;
}

/* Portal export action (publish / cyan) */
.btn--portal {
    background: #ecfeff;
    color: #0e7490;
    border-color: #67e8f9;
    box-shadow: 0 1px 2px rgba(14, 116, 144, 0.08);
}

.btn--portal:hover {
    background: #cffafe;
    border-color: #22d3ee;
    color: #155e75;
}

.btn--sm.btn--export,
.btn--sm.btn--import {
    font-weight: 700;
}

.btn--sm {
    padding: 5px 10px;
    font-size: 13px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --------------------------------------------------------------------------
   Forms
   -------------------------------------------------------------------------- */
.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 9px 12px;
    font-size: 14px;
    font-family: inherit;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text);
    transition: border-color var(--transition), box-shadow var(--transition);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

.form-textarea {
    resize: vertical;
    min-height: 80px;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 6px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.required {
    color: var(--color-danger);
}

/* --------------------------------------------------------------------------
   Data table
   -------------------------------------------------------------------------- */
.table-wrapper {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.data-table th {
    text-align: left;
    padding: 13px 16px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border-bottom: 2px solid var(--color-border);
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    vertical-align: middle;
}

.data-table tbody tr:nth-child(even) {
    background: var(--color-zebra);
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #eef4ff;
}

.data-table a {
    color: var(--color-primary);
    text-decoration: none;
}

.data-table a:hover {
    text-decoration: underline;
}

.col-actions {
    white-space: nowrap;
    text-align: right;
}

.table-empty {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px 16px !important;
}

.table-empty--error {
    color: var(--color-danger);
}

/* --------------------------------------------------------------------------
   Status badges
   -------------------------------------------------------------------------- */
.badge {
    display: inline-block;
    padding: 4px 11px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.3;
    white-space: nowrap;
    background: #e2e8f0;
    color: #334155;
    border: 1px solid transparent;
}

.badge--active {
    background: #dcfce7;
    color: #15803d;
}

.badge--inactive {
    background: #fef3c7;
    color: #b45309;
}

.badge--archived {
    background: #f1f5f9;
    color: #64748b;
}

.badge--success {
    background: #dcfce7;
    color: #15803d;
}

.badge--danger {
    background: #fee2e2;
    color: #b91c1c;
}

.badge--muted {
    background: #f1f5f9;
    color: #64748b;
}

.badge--warning {
    background: #fef3c7;
    color: #b45309;
}

.badge--log-create {
    background: #dcfce7;
    color: #15803d;
}

.badge--log-update {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge--log-delete {
    background: #fee2e2;
    color: #b91c1c;
}

.badge--log-login {
    background: #ede9fe;
    color: #6d28d9;
}

.badge--log-logout {
    background: #f1f5f9;
    color: #64748b;
}

.badge--key-out {
    background: #fef3c7;
    color: #b45309;
}

.badge--key-in_office {
    background: #dcfce7;
    color: #15803d;
}

.badge--key-lost {
    background: #fee2e2;
    color: #b91c1c;
}

/* --------------------------------------------------------------------------
   Confirmation dialog (custom, replaces native confirm())
   -------------------------------------------------------------------------- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 1300;
    background: rgba(15, 23, 42, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    animation: confirm-fade 0.15s ease-out;
}

.confirm-overlay[hidden] {
    display: none;
}

.confirm-dialog {
    background: var(--color-surface);
    border-radius: 14px;
    box-shadow: 0 24px 64px rgba(15, 23, 42, 0.28);
    width: 100%;
    max-width: 380px;
    padding: 26px 24px 20px;
    text-align: center;
    animation: confirm-pop 0.16s ease-out;
}

.confirm-dialog__icon {
    width: 54px;
    height: 54px;
    margin: 0 auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 26px;
    border-radius: 50%;
    background: #fef2f2;
    color: #dc2626;
}
.confirm-dialog__icon svg { width: 26px; height: 26px; }

.confirm-dialog__title {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--color-text);
}

.confirm-dialog__message {
    font-size: 14px;
    color: var(--color-text-muted);
    line-height: 1.5;
    margin-bottom: 22px;
}

.confirm-dialog__actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.confirm-dialog__actions .btn {
    min-width: 110px;
}

@keyframes confirm-fade {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes confirm-pop {
    from { opacity: 0; transform: translateY(8px) scale(0.97); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* --------------------------------------------------------------------------
   Modal
   -------------------------------------------------------------------------- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 24px;
}

.modal-overlay[hidden] {
    display: none;
}

.modal {
    background: var(--color-surface);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal--sm {
    max-width: 420px;
}

.modal--lg {
    max-width: 720px;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 0;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    line-height: 1;
    color: var(--color-text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--color-bg);
    color: var(--color-text);
}

.modal-body {
    padding: 20px 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 0 24px 20px;
}

.modal--sm .modal-footer {
    padding: 0 24px 20px;
}

.form-section {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px 4px;
    margin-bottom: 18px;
}

.form-section legend {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    padding: 0 6px;
}

.form-row--3 {
    grid-template-columns: 1fr 1fr 1fr;
}

.form-row--4 {
    grid-template-columns: repeat(4, 1fr);
}

.badge--available {
    background: #dcfce7;
    color: #15803d;
}

.badge--rented {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge--sold {
    background: #f3e8ff;
    color: #7e22ce;
}

/* --------------------------------------------------------------------------
   Gallery (Phase 3)
   -------------------------------------------------------------------------- */
.gallery-hint {
    font-size: 13px;
    margin-bottom: 16px;
    padding: 10px 14px;
    background: var(--color-bg);
    border-radius: var(--radius);
}

.gallery-hint-inline {
    font-size: 13px;
    margin: 0 0 14px;
}

.gallery-section {
    grid-column: 1 / -1;
}

.gallery-section__title {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin: 0 0 10px;
}

.gallery-section__grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 12px;
}

.gallery-upload {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 16px;
}

.gallery-upload__type {
    width: auto;
    min-width: 140px;
}

.gallery-upload__file {
    flex: 1;
    min-width: 160px;
    font-size: 13px;
}

.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.gallery-empty {
    text-align: center;
    padding: 20px;
}

.gallery-item {
    position: relative;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--color-bg);
}

.gallery-item--cover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.gallery-item__preview {
    position: relative;
    cursor: pointer;
}

.gallery-item__preview:hover .gallery-item__img,
.gallery-item__preview:hover .gallery-item__video {
    opacity: 0.92;
}

.gallery-item__cover-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    background: var(--color-primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
}

.gallery-item__play {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.45);
    pointer-events: none;
}

.gallery-item__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    align-items: center;
    padding: 6px 8px 8px;
    border-top: 1px solid var(--color-border);
    background: var(--color-surface);
}

.btn--xs {
    padding: 3px 8px;
    font-size: 11px;
    min-height: 24px;
}

.gallery-item__img,
.gallery-item__video {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
    background: #e2e8f0;
}

.gallery-item__doc {
    height: 110px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: var(--color-text-muted);
    background: #e2e8f0;
}

.gallery-item__meta {
    padding: 8px 10px;
    font-size: 11px;
}

.gallery-item__type {
    display: block;
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: 2px;
}

.gallery-item__name {
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.gallery-item__delete {
    margin-left: auto;
    width: 28px;
    height: 28px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    background: var(--color-surface);
    color: var(--color-text-muted);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.gallery-item__delete:hover {
    background: var(--color-danger);
}

/* Property card cover photo */
.entity-card--clickable {
    cursor: pointer;
}

.entity-card--clickable:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

.entity-card__cover {
    position: relative;
    aspect-ratio: 16 / 9;
    min-height: 200px;
    background: #e2e8f0;
    overflow: hidden;
    border-bottom: 1px solid var(--color-border);
}

.entity-card__cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.entity-card__cover-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: var(--color-text-muted);
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, #eef2f7 0%, #e2e8f0 100%);
}

.entity-card__cover-icon {
    font-size: 32px;
    opacity: 0.65;
}

.entity-card__cover-select {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    background: rgba(255, 255, 255, 0.92);
    border-radius: 6px;
    padding: 4px 6px;
    cursor: pointer;
}

.entity-card__cover-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.22);
}

.entity-card--property .entity-card__prop-header {
    border-bottom: none;
    background: transparent;
    padding-top: 14px;
}

/* Media lightbox */
.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    background: rgba(15, 23, 42, 0.88);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.media-lightbox[hidden] {
    display: none !important;
}

.media-lightbox__close {
    position: absolute;
    top: 16px;
    right: 20px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 28px;
    cursor: pointer;
    line-height: 1;
}

.media-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.media-lightbox__content {
    max-width: min(960px, 92vw);
    max-height: 78vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-lightbox__content img,
.media-lightbox__content video {
    max-width: 100%;
    max-height: 78vh;
    border-radius: var(--radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.media-lightbox__content iframe {
    width: min(960px, 90vw);
    height: min(720px, 75vh);
    border: none;
    border-radius: var(--radius);
    background: #fff;
}

.media-lightbox__caption {
    margin-top: 14px;
    color: #e2e8f0;
    font-size: 14px;
    text-align: center;
    max-width: 720px;
}

/* --------------------------------------------------------------------------
   Documents (Phase 4)
   -------------------------------------------------------------------------- */
.form-hint {
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.doc-name {
    font-weight: 600;
}

.badge--doc-invoice {
    background: #fef3c7;
    color: #b45309;
}

.badge--doc-contract {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge--doc-id {
    background: #f3e8ff;
    color: #7e22ce;
}

.badge--doc-other {
    background: #f1f5f9;
    color: #64748b;
}

/* --------------------------------------------------------------------------
   Communications / Chat (Phase 5)
   -------------------------------------------------------------------------- */
.communications-view {
}

.chat-layout {
    display: flex;
    gap: 0;
    flex: 1;
    min-height: 480px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.chat-sidebar {
    width: 300px;
    flex-shrink: 0;
    border-right: 1px solid var(--color-border);
    display: flex;
    flex-direction: column;
    background: #f8fafc;
}

.chat-sidebar__search {
    padding: 14px;
    border-bottom: 1px solid var(--color-border);
}

.chat-sidebar__search.filter-bar {
    gap: 8px;
}

.chat-sidebar__search .filter-bar__controls .form-input,
.chat-sidebar__search .filter-bar__controls input[type="search"] {
    flex: 1 1 100%;
    min-width: 0;
    width: 100%;
}

.chat-client-list {
    list-style: none;
    overflow-y: auto;
    flex: 1;
}

.chat-client-list__empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 13px;
}

.chat-client-list__error {
    color: var(--color-danger);
}

.chat-client-item {
    display: block;
    width: 100%;
    text-align: left;
    padding: 12px 14px;
    border: none;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition);
}

.chat-client-item:hover {
    background: #eef2f7;
}

.chat-client-item--active {
    background: var(--color-primary-light);
    border-left: 3px solid var(--color-primary);
}

.chat-client-item__top {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    margin-bottom: 4px;
}

.chat-client-item__name {
    font-weight: 600;
    font-size: 14px;
    color: var(--color-text);
}

.chat-client-item__time {
    font-size: 11px;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.chat-client-item__bottom {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-client-item__preview {
    font-size: 12px;
    color: var(--color-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-client-item__count {
    font-size: 11px;
    background: var(--color-primary);
    color: #fff;
    border-radius: 10px;
    padding: 1px 7px;
    flex-shrink: 0;
}

.chat-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
}

.chat-panel__empty {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--color-text-muted);
    gap: 12px;
}

.chat-panel__empty-icon {
    font-size: 48px;
}

.chat-panel__active {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-panel__active[hidden],
.chat-panel__empty[hidden] {
    display: none;
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface);
    flex-shrink: 0;
}

.chat-header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.chat-header__info span {
    font-size: 13px;
}

.badge--channel-email {
    background: #dbeafe;
    color: #1d4ed8;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f1f5f9;
}

.chat-loading,
.chat-no-messages {
    text-align: center;
    color: var(--color-text-muted);
    padding: 40px 20px;
    font-size: 14px;
}

.chat-loading--error {
    color: var(--color-danger);
}

.chat-bubble {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-bubble--sent {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble--received {
    align-self: flex-start;
    background: var(--color-surface);
    color: var(--color-text);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}

.chat-bubble__subject {
    font-weight: 700;
    font-size: 13px;
    margin-bottom: 6px;
}

.chat-bubble--sent .chat-bubble__subject {
    color: #dbeafe;
}

.chat-bubble__body {
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-bubble__meta {
    display: flex;
    gap: 10px;
    margin-top: 8px;
    font-size: 11px;
    opacity: 0.75;
}

.chat-bubble__failed {
    color: #fecaca;
    font-weight: 600;
}

.chat-compose {
    border-top: 1px solid var(--color-border);
    padding: 14px 20px 16px;
    background: var(--color-surface);
    flex-shrink: 0;
}

.chat-compose__tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 12px;
}

.chat-tab {
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    border: 1px solid var(--color-border);
    border-radius: 20px;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    font-family: inherit;
    transition: background var(--transition), color var(--transition);
}

.chat-tab--active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

.chat-body-input {
    resize: none;
}

.chat-compose__actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 4px;
}

.chat-compose__hint {
    font-size: 12px;
}

/* Client profile — comm history preview */
.client-comm-history {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
    max-height: 200px;
    overflow-y: auto;
}

.client-comm-item {
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    border-left: 3px solid var(--color-border);
    background: var(--color-bg);
}

.client-comm-item--sent {
    border-left-color: var(--color-primary);
}

.client-comm-item--received {
    border-left-color: var(--color-success);
}

.client-comm-item__head {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.client-comm-item__subject {
    font-weight: 600;
    margin-bottom: 2px;
}

.client-comm-item__body {
    color: var(--color-text-muted);
    white-space: pre-wrap;
}

/* --------------------------------------------------------------------------
   Reminders (Phase 6)
   -------------------------------------------------------------------------- */
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 12px;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--color-primary);
}

.badge--reminder-pending {
    background: #fef3c7;
    color: #b45309;
}

.badge--reminder-completed {
    background: #dcfce7;
    color: #15803d;
}

.badge--reminder-cancelled {
    background: #f1f5f9;
    color: #64748b;
}

.reminder-date--overdue {
    color: var(--color-danger);
    font-weight: 700;
}

.reminder-date--soon {
    color: var(--color-warning);
    font-weight: 600;
}

.row--overdue {
    background: #fff5f5;
}

.row--overdue:hover {
    background: #fee2e2 !important;
}

.reminder-notify-icons {
    font-size: 16px;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Social Media (Phase 7)
   -------------------------------------------------------------------------- */
.meta-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}

.meta-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.meta-card__header h3 {
    font-size: 16px;
    font-weight: 700;
    margin-bottom: 2px;
}

.meta-card__body {
    padding: 20px;
}

.meta-status {
    font-size: 13px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    white-space: nowrap;
}

.meta-status--connected {
    background: #dcfce7;
    color: #15803d;
}

.meta-status--simulated {
    background: #fef3c7;
    color: #b45309;
}

.badge--platform-facebook,
.badge--platform-both {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge--platform-instagram {
    background: #fce7f3;
    color: #be185d;
}

.badge--social-draft {
    background: #f1f5f9;
    color: #64748b;
}

.badge--social-scheduled {
    background: #fef3c7;
    color: #b45309;
}

.badge--social-published {
    background: #dcfce7;
    color: #15803d;
}

.badge--social-failed {
    background: #fef2f2;
    color: var(--color-danger);
}

.post-caption-cell {
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.post-has-image {
    flex-shrink: 0;
}

.post-error {
    color: var(--color-danger) !important;
    display: block;
    margin-top: 2px;
}

.post-image-preview {
    margin-top: 8px;
}

.post-image-preview img {
    max-width: 200px;
    max-height: 150px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    object-fit: cover;
}

.property-photo-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.property-photo-picker__item {
    border: 2px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0;
    background: var(--color-bg);
    cursor: pointer;
    overflow: hidden;
    aspect-ratio: 1;
}

.property-photo-picker__item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.property-photo-picker__item.selected,
.property-photo-picker__item:hover {
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

/* --------------------------------------------------------------------------
   Sidebar backdrop (mobile)
   -------------------------------------------------------------------------- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    z-index: 99;
}

.sidebar-backdrop:not([hidden]) {
    display: block;
}

body.nav-open {
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Responsive — phone & tablet
   -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .main-wrapper {
        margin-left: 0;
        height: auto;
        overflow: visible;
    }

    .app-content {
        height: auto;
        overflow-y: visible;
    }

    .communications-view {
        height: auto;
    }

    .sidebar {
        transform: translateX(-100%);
        box-shadow: var(--shadow-md);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-close-btn {
        display: block; /* Mobile: allow closing the overlay sidebar */
    }

    .app-content {
        padding: 16px;
    }

    .topbar {
        padding: 0 16px;
        height: 56px;
        z-index: 1200;
    }

    .page-title {
        font-size: 17px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .form-row,
    .form-row--2,
    .form-row--3,
    .form-row--4 {
        grid-template-columns: 1fr;
    }

    .view-header {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
        margin-bottom: 16px;
    }

    .view-header .btn,
    .view-header__actions {
        width: 100%;
    }

    .view-header__actions .btn {
        flex: 1;
    }

    .view-header h2 {
        font-size: 20px;
    }

    .filter-bar__controls {
        flex-direction: column;
        align-items: stretch;
    }

    /* In a column flex container, `flex: 1 1 200px` would make the search box
       200px TALL (flex-basis is the main/vertical size), leaving a big gap.
       Reset it so every stacked control keeps its natural height. */
    .filter-bar__controls .search-box,
    .filter-bar__controls > .form-input,
    .filter-bar__controls > .form-select,
    .filter-bar__controls > input,
    .filter-bar__controls > select {
        flex: 0 0 auto;
        width: 100%;
        min-width: 0;
        max-width: none;
    }

    .search-box {
        min-width: 0;
        width: 100%;
    }

    .filter-bar__controls .form-input,
    .filter-bar__controls .form-select,
    .filter-bar__controls > input {
        width: 100%;
        max-width: none;
    }

    .filter-bar__actions {
        justify-content: stretch;
    }

    .filter-bar__controls .btn-clear-filters {
        width: 100%;
        margin-left: 0;
    }

    /* Tables → stacked cards */
    .table-wrapper {
        overflow-x: visible;
        border: none;
        background: transparent;
        box-shadow: none;
    }

    .table-wrapper .data-table thead {
        display: none;
    }

    .table-wrapper .data-table tbody tr {
        display: block;
        margin-bottom: 14px;
        padding: 14px 16px;
        background: var(--color-surface);
        border: 1px solid var(--color-border);
        overflow: hidden;
        border-radius: var(--radius);
        box-shadow: var(--shadow);
    }

    .table-wrapper .data-table tbody tr.row--overdue {
        border-left: 3px solid var(--color-danger);
    }

    .table-wrapper .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 12px;
        padding: 8px 0;
        border: none;
        text-align: right;
        min-width: 0;
        word-break: break-word;
        overflow-wrap: break-word;
    }

    .table-wrapper .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        color: var(--color-text-muted);
        text-align: left;
        flex: 0 0 38%;
        word-break: normal;
    }

    .table-wrapper .data-table td.table-empty,
    .table-wrapper .data-table td[colspan] {
        display: block;
        text-align: center;
    }

    .table-wrapper .data-table td.table-empty::before,
    .table-wrapper .data-table td[colspan]::before {
        display: none;
    }

    .table-wrapper .data-table td.col-actions {
        justify-content: flex-end;
        flex-wrap: wrap;
        gap: 8px;
        padding-top: 10px;
        margin-top: 4px;
        border-top: 1px solid var(--color-border);
    }

    .table-wrapper .data-table td.col-actions::before {
        display: none;
    }

    .settings-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
        padding-bottom: 4px;
        margin-bottom: 16px;
    }

    .settings-tabs::-webkit-scrollbar {
        display: none;
    }

    .settings-tab {
        flex-shrink: 0;
    }

    .chat-layout {
        flex-direction: column;
        height: auto;
        min-height: 0;
    }

    .chat-sidebar {
        width: 100%;
        max-height: 42vh;
        min-height: 180px;
        border-right: none;
        border-bottom: 1px solid var(--color-border);
    }

    .chat-bubble {
        max-width: 92%;
    }

    .chat-compose__actions {
        flex-direction: column;
        align-items: stretch;
    }

    .chat-compose__actions .btn {
        width: 100%;
    }

    .modal-overlay {
        padding: 12px;
        align-items: flex-end;
    }

    .modal {
        max-width: 100%;
        width: 100%;
        max-height: 92vh;
        margin: 0;
        border-bottom-left-radius: 0;
        border-bottom-right-radius: 0;
    }

    .modal-footer {
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .meta-card__header {
        flex-direction: column;
        gap: 8px;
    }

    .btn {
        min-height: 44px;
    }

    .btn--sm {
        min-height: 40px;
        min-width: 40px;
    }

    /* Tenant portal */
    .tenant-layout .main-wrapper {
        margin-left: 0;
    }

    .tenant-layout .sidebar {
        transform: translateX(-100%);
    }

    .tenant-layout .sidebar.open {
        transform: translateX(0);
    }

    .tenant-info-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* --------------------------------------------------------------------------
   Dashboard enhancements
   -------------------------------------------------------------------------- */
.dashboard-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.dashboard-header__actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.stats-grid--6 {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.dashboard-bottom {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-top: 8px;
}

.dashboard-section {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc;
}

.section-header h3 {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
}

.upcoming-list {
    padding: 8px 0;
}

.upcoming-loading {
    padding: 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
}

.upcoming-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    transition: background var(--transition);
}

.upcoming-item:last-child {
    border-bottom: none;
}

.upcoming-item:hover {
    background: #f8fafc;
}

.upcoming-item__icon {
    font-size: 20px;
    flex-shrink: 0;
    color: #d97706;
    display: inline-flex;
}
.upcoming-item__icon svg { width: 20px; height: 20px; }

.upcoming-item__body {
    flex: 1;
    min-width: 0;
}

.upcoming-item__title {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upcoming-item__meta {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.upcoming-item__date {
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text-muted);
    flex-shrink: 0;
    text-align: right;
}

.quick-actions {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1px;
    background: var(--color-border);
}

.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 20px 12px;
    background: var(--color-surface);
    text-decoration: none;
    color: var(--color-text);
    transition: background var(--transition), color var(--transition);
    cursor: pointer;
}

.quick-action:hover {
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.quick-action__icon {
    font-size: 24px;
}

.quick-action__label {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

/* Quick-access customizer */
.ql-picker {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
}

.ql-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
}

.ql-option:hover {
    background: var(--color-bg);
}

.ql-option--on {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.ql-option input {
    flex-shrink: 0;
}

.ql-option__icon {
    font-size: 18px;
}

.ql-option__label {
    font-size: 13px;
    font-weight: 600;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --------------------------------------------------------------------------
   Entity cards (Proprietari & Immobili)
   -------------------------------------------------------------------------- */
.entity-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 18px;
    margin-bottom: var(--section-gap);
}

/* Immobili & Leads — always 2 cards per row on tablet/desktop */
.entity-grid--wide,
.properties-view .entity-grid,
.leads-view .entity-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 22px;
}

@media (max-width: 640px) {
    .entity-grid--wide,
    .properties-view .entity-grid,
    .leads-view .entity-grid {
        grid-template-columns: 1fr;
    }
}

.entity-loading,
.entity-empty,
.entity-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 48px 24px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.entity-error {
    color: var(--color-danger);
}

.entity-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    transition: box-shadow var(--transition), border-color var(--transition);
    min-width: 0;
}

.entity-card--property,
.lead-card {
    overflow: visible;
    min-height: 280px;
}

.entity-card--property .entity-card__street {
    font-size: 16px;
}

.entity-card--property .entity-card__city {
    font-size: 14px;
}

.entity-card--property .entity-card__body,
.lead-card__body {
    padding: 16px 20px;
}

.entity-card--property .entity-card__prop-header {
    padding: 16px 20px 12px;
}

.entity-card--property .entity-card__footer,
.lead-card .entity-card__footer {
    padding: 14px 20px 18px;
}

.entity-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-border-strong);
    transform: none;
}

/* Client card header */
.entity-card__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 16px 12px;
}

.entity-card__avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: 700;
    flex-shrink: 0;
}

.entity-card__title-group {
    flex: 1;
    min-width: 0;
}

.entity-card__name {
    font-size: 15px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 4px;
}

/* Property card header */
.entity-card__prop-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--color-border);
    background: var(--color-surface-muted);
    flex-wrap: wrap;
}

.entity-card--property .entity-card__prop-header .badge {
    flex-shrink: 0;
    align-self: flex-start;
}

.entity-card__address {
    flex: 1;
    min-width: 0;
}

.entity-card__street {
    font-size: 14px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.35;
    word-break: break-word;
}

.entity-card--property .entity-card__street,
.lead-card .entity-card__info {
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
}

.entity-card__city {
    font-size: 13px;
    margin-top: 4px;
    line-height: 1.35;
    word-break: break-word;
}

/* Card body */
.entity-card__body {
    padding: 14px 18px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.entity-card__info {
    display: flex;
    align-items: flex-start;
    gap: 6px;
    font-size: 13px;
    color: var(--color-text);
    line-height: 1.4;
    word-break: break-word;
}

.entity-card__info a {
    word-break: break-all;
}

.entity-card__info a {
    color: var(--color-primary);
    text-decoration: none;
}

.entity-card__info a:hover {
    text-decoration: underline;
}

.entity-card__info-icon {
    font-size: 14px;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    color: var(--color-text-muted);
}
/* Sizing for Lucide icons that replaced inline emoji across cards/labels/stats */
.entity-card__info-icon svg { width: 15px; height: 15px; }
.entity-card__stat-icon svg { width: 16px; height: 16px; vertical-align: -3px; }
.scheda-row__label svg { width: 15px; height: 15px; vertical-align: -2px; margin-right: 3px; }
.agent-stat__icon svg { width: 22px; height: 22px; }
.reminder-item__icon svg { width: 18px; height: 18px; vertical-align: -3px; }
.doc-item__icon svg, .doc-row__name svg { width: 15px; height: 15px; vertical-align: -2px; }

/* Property chips */
.prop-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
}

.prop-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--color-text);
}

.prop-chip--roi { background: #dcfce7; color: #15803d; border-color: #86efac; }
.prop-chip--available { background: #dcfce7; color: #15803d; border-color: #86efac; }
.prop-chip--rented { background: #dbeafe; color: #1d4ed8; border-color: #93c5fd; }

/* Card footer */
.entity-card__footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--color-border);
    background: #f8fafc;
}

.entity-card__stat {
    display: flex;
    align-items: center;
    gap: 6px;
}

.entity-card__stat-icon {
    font-size: 14px;
}

.entity-card__stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
}

.entity-card__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    justify-content: flex-end;
}

.entity-card--property .entity-card__footer {
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.entity-card--property .entity-card__actions {
    flex: 1 1 auto;
    min-width: 0;
    justify-content: flex-end;
}

.entity-card--property .entity-card__stat {
    flex-shrink: 0;
}

/* --------------------------------------------------------------------------
   Responsive — dashboard & cards
   -------------------------------------------------------------------------- */
@media (max-width: 900px) {
    .dashboard-bottom {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .dashboard-header {
        flex-direction: column;
        align-items: stretch;
    }

    .entity-grid:not(.entity-grid--wide) {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(3, 1fr);
    }

    .stats-grid--6 {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid--6 {
        grid-template-columns: 1fr;
    }

    .quick-actions {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tenant portal components */
.tenant-cards {
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 720px;
}

.tenant-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.tenant-info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.tenant-info-item__label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

.tenant-info-item__value {
    font-size: 15px;
    font-weight: 600;
    color: var(--color-text);
}

@media (max-width: 480px) {
    .tenant-info-grid {
        grid-template-columns: 1fr;
    }

    .view-header h2 {
        font-size: 18px;
    }
}

/* ===========================================================================
   Phase 11 — Leads, Visite, Mappa, Fatture, Valutazioni, Template, 2FA, CSV
   =========================================================================== */

.view-header__actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* Status badges (shared) */
.badge--lead-new        { background: #dbeafe; color: #1d4ed8; }
.badge--lead-contacted  { background: #fef3c7; color: #b45309; }
.badge--lead-interested { background: #dcfce7; color: #15803d; }
.badge--lead-negotiating{ background: #ede9fe; color: #6d28d9; }
.badge--lead-converted  { background: #ccfbf1; color: #0f766e; }
.badge--lead-lost       { background: #e2e8f0; color: #475569; }
.badge--interest        { background: var(--color-primary-light); color: var(--color-primary-dark); }

/* Lead card */
.lead-card { display: flex; flex-direction: column; border-left: 4px solid var(--color-border); }
.lead-card--new        { border-left-color: #2563eb; }
.lead-card--contacted  { border-left-color: #d97706; }
.lead-card--interested { border-left-color: #16a34a; }
.lead-card--negotiating{ border-left-color: #7c3aed; }
.lead-card--converted  { border-left-color: #0d9488; }
.lead-card--lost       { border-left-color: #94a3b8; }
.lead-card__header { display: flex; align-items: flex-start; gap: 12px; padding: 18px 20px 14px; }
.lead-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--color-primary); color: #fff;
    display: flex; align-items: center; justify-content: center; font-weight: 600; flex-shrink: 0; }
.lead-card__name { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 0; }
.lead-card__name strong { font-size: 16px; line-height: 1.35; word-break: break-word; }
.lead-card__name .badge { align-self: flex-start; }
.lead-card__body { padding: 0 20px 16px; display: flex; flex-direction: column; gap: 10px; }
.lead-meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.lead-card .entity-card__footer {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px 16px;
}

.lead-card .entity-card__footer .btn-match {
    width: 100%;
    justify-content: center;
}

.lead-card .entity-card__actions {
    width: 100%;
    justify-content: flex-end;
}

/* Contract cards */
.contract-card {
    border-left: 4px solid var(--color-border);
}

.contract-card--draft {
    border-left-color: #94a3b8;
    background: linear-gradient(to bottom, #f8fafc 0%, var(--color-surface) 48px);
}

.contract-card--sent {
    border-left-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff 0%, var(--color-surface) 52px);
}

.contract-card--signed,
.contract-card--active {
    border-left-color: #16a34a;
    background: linear-gradient(to bottom, #ecfdf5 0%, var(--color-surface) 52px);
}

.contract-card--expired {
    border-left-color: #d97706;
    background: linear-gradient(to bottom, #fffbeb 0%, var(--color-surface) 52px);
}

.contract-card--cancelled {
    border-left-color: #dc2626;
    background: linear-gradient(to bottom, #fef2f2 0%, var(--color-surface) 52px);
    opacity: 0.92;
}

.contract-card .entity-card__header {
    padding-bottom: 10px;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
}

.contract-card__badges {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

/* Contract type badges */
.badge--contract-type {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background: var(--color-primary-light);
    color: var(--color-primary-dark);
}

.badge--contract-type-locazione {
    background: #ede9fe;
    color: #5b21b6;
    border-color: #c4b5fd;
}

.badge--contract-type-compravendita {
    background: #fce7f3;
    color: #9d174d;
    border-color: #f9a8d4;
}

.badge--contract-type-preliminare {
    background: #e0e7ff;
    color: #3730a3;
    border-color: #a5b4fc;
}

.badge--contract-type-mandato {
    background: #ffedd5;
    color: #9a3412;
    border-color: #fdba74;
}

.badge--contract-type-altro {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

/* Contract status badges */
.badge--contract-draft {
    background: #f1f5f9;
    color: #475569;
    border: 1px dashed #94a3b8;
    font-weight: 700;
}

.badge--contract-sent {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    font-weight: 700;
}

.badge--contract-signed {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    font-weight: 700;
}

/* Attivo = date-driven "in force" state (status left Automatico) */
.badge--contract-active {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    font-weight: 700;
}

.badge--contract-expired {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
    font-weight: 700;
}

.badge--contract-cancelled {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    font-weight: 700;
}

.contract-card--draft .entity-card__footer {
    background: #f8fafc;
}

.contract-card--sent .entity-card__footer {
    background: #f0f7ff;
}

.contract-card--signed .entity-card__footer,
.contract-card--active .entity-card__footer {
    background: #f0fdf4;
}

/* Payment cards (Pagamenti) */
.payment-card {
    border-left: 4px solid var(--color-border);
}

.payment-card--pending {
    border-left-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff 0%, var(--color-surface) 52px);
}

.payment-card--paid {
    border-left-color: #16a34a;
    background: linear-gradient(to bottom, #ecfdf5 0%, var(--color-surface) 52px);
}

.payment-card--late {
    border-left-color: #dc2626;
    background: linear-gradient(to bottom, #fef2f2 0%, var(--color-surface) 52px);
}

.payment-card--cancelled {
    border-left-color: #94a3b8;
    background: linear-gradient(to bottom, #f8fafc 0%, var(--color-surface) 52px);
    opacity: 0.9;
}

.payment-card .entity-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
}

.payment-card .entity-card__title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.payment-card .entity-card__name {
    font-size: 22px;
    font-weight: 800;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    letter-spacing: -0.02em;
}

.payment-card--pending .entity-card__name {
    color: #1d4ed8;
}

.payment-card--paid .entity-card__name {
    color: #15803d;
}

.payment-card--late .entity-card__name {
    color: #b91c1c;
}

.payment-card--cancelled .entity-card__name {
    color: #64748b;
    text-decoration: line-through;
    text-decoration-color: #94a3b8;
}

.badge--payment-pending {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #93c5fd;
    font-weight: 700;
}

.badge--payment-paid {
    background: #dcfce7;
    color: #15803d;
    border: 1px solid #86efac;
    font-weight: 700;
}

.badge--payment-late {
    background: #fee2e2;
    color: #b91c1c;
    border: 1px solid #fca5a5;
    font-weight: 700;
}

.badge--payment-cancelled {
    background: #f1f5f9;
    color: #64748b;
    border: 1px dashed #94a3b8;
    font-weight: 700;
}

.payment-card--pending .entity-card__footer {
    background: #f0f7ff;
}

.payment-card--paid .entity-card__footer {
    background: #f0fdf4;
}

.payment-card--late .entity-card__footer {
    background: #fff5f5;
}

.payment-card--cancelled .entity-card__footer {
    background: #f8fafc;
}

.payment-card .btn-paid {
    background: #ecfdf5;
    color: #047857;
    border-color: #34d399;
}

.payment-card .btn-paid:hover {
    background: #d1fae5;
    border-color: #10b981;
    color: #065f46;
}

/* Expense cards (Spese) — styled by category */
.expense-card {
    border-left: 4px solid var(--color-border);
}

.expense-card--manutenzione {
    border-left-color: #d97706;
    background: linear-gradient(to bottom, #fffbeb 0%, var(--color-surface) 52px);
}

.expense-card--utenze {
    border-left-color: #2563eb;
    background: linear-gradient(to bottom, #eff6ff 0%, var(--color-surface) 52px);
}

.expense-card--tasse {
    border-left-color: #7c3aed;
    background: linear-gradient(to bottom, #f5f3ff 0%, var(--color-surface) 52px);
}

.expense-card--assicurazione {
    border-left-color: #0d9488;
    background: linear-gradient(to bottom, #f0fdfa 0%, var(--color-surface) 52px);
}

.expense-card--agenzia {
    border-left-color: #db2777;
    background: linear-gradient(to bottom, #fdf2f8 0%, var(--color-surface) 52px);
}

.expense-card--altro {
    border-left-color: #64748b;
    background: linear-gradient(to bottom, #f8fafc 0%, var(--color-surface) 52px);
}

.expense-card .entity-card__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
    padding: 16px 18px 12px;
    border-bottom: 1px solid var(--color-border);
    background: transparent;
}

.expense-card .entity-card__title-group {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
}

.expense-card .entity-card__name {
    font-size: 22px;
    font-weight: 800;
    white-space: normal;
    overflow: visible;
    text-overflow: unset;
    letter-spacing: -0.02em;
}

.expense-card--manutenzione .entity-card__name { color: #b45309; }
.expense-card--utenze .entity-card__name        { color: #1d4ed8; }
.expense-card--tasse .entity-card__name        { color: #6d28d9; }
.expense-card--assicurazione .entity-card__name { color: #0f766e; }
.expense-card--agenzia .entity-card__name      { color: #be185d; }
.expense-card--altro .entity-card__name         { color: #475569; }

.badge--expense {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.03em;
    text-transform: uppercase;
    border: 1px solid transparent;
    background: #f1f5f9;
    color: #475569;
}

.badge--expense-manutenzione {
    background: #fef3c7;
    color: #b45309;
    border-color: #fcd34d;
}

.badge--expense-utenze {
    background: #dbeafe;
    color: #1d4ed8;
    border-color: #93c5fd;
}

.badge--expense-tasse {
    background: #ede9fe;
    color: #6d28d9;
    border-color: #c4b5fd;
}

.badge--expense-assicurazione {
    background: #ccfbf1;
    color: #0f766e;
    border-color: #5eead4;
}

.badge--expense-agenzia {
    background: #fce7f3;
    color: #be185d;
    border-color: #f9a8d4;
}

.badge--expense-altro {
    background: #f1f5f9;
    color: #475569;
    border-color: #cbd5e1;
}

.expense-card--manutenzione .entity-card__footer { background: #fffbeb; }
.expense-card--utenze .entity-card__footer        { background: #f0f7ff; }
.expense-card--tasse .entity-card__footer        { background: #f5f3ff; }
.expense-card--assicurazione .entity-card__footer { background: #f0fdfa; }
.expense-card--agenzia .entity-card__footer      { background: #fdf2f8; }
.expense-card--altro .entity-card__footer         { background: #f8fafc; }

/* Match list */
.match-list { display: flex; flex-direction: column; gap: 8px; }
.match-item, .appraisal-item { display: flex; justify-content: space-between; align-items: center;
    gap: 12px; padding: 10px 12px; border: 1px solid var(--color-border); border-radius: var(--radius); }
.appraisal-history { display: flex; flex-direction: column; gap: 8px; }
.appraisal-item { flex-direction: column; align-items: stretch; }

/* Appointment card */
.appointment-card { border-left: 4px solid var(--color-border); }
.appointment-card--scheduled { border-left-color: #2563eb; }
.appointment-card--completed { border-left-color: #16a34a; }
.appointment-card--cancelled { border-left-color: #dc2626; }
.appointment-card--no_show   { border-left-color: #94a3b8; }
.appointment-card__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; padding: 14px 16px; }
.badge--appt-scheduled { background: #dbeafe; color: #1d4ed8; }
.badge--appt-completed { background: #dcfce7; color: #15803d; }
.badge--appt-cancelled { background: #fee2e2; color: #b91c1c; }
.badge--appt-no_show   { background: #e2e8f0; color: #475569; }

/* Invoice card */
.invoice-card { border-left: 4px solid var(--color-border); }
.invoice-card--draft     { border-left-color: #94a3b8; }
.invoice-card--sent      { border-left-color: #2563eb; }
.invoice-card--paid      { border-left-color: #16a34a; }
.invoice-card--cancelled { border-left-color: #dc2626; }
.invoice-card__header { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 14px 16px; }
.badge--invoice-draft     { background: #e2e8f0; color: #475569; }
.badge--invoice-sent      { background: #dbeafe; color: #1d4ed8; }
.badge--invoice-paid      { background: #dcfce7; color: #15803d; }
.badge--invoice-cancelled { background: #fee2e2; color: #b91c1c; }

/* Map */
.map-view { display: flex; flex-direction: column; height: calc(100vh - 160px); min-width: 0; }
.leaflet-map {
    flex: 1;
    width: 100%;
    min-width: 0;
    min-height: 400px;
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    overflow: hidden;
    /* Contain Leaflet's internal panes (z-index up to ~800) in their own
       stacking context so they can never paint over the fixed sidebar. */
    position: relative;
    z-index: 0;
    isolation: isolate;
}

/* Belt-and-suspenders: keep every Leaflet layer/control below the chrome. */
.leaflet-map .leaflet-pane,
.leaflet-map .leaflet-top,
.leaflet-map .leaflet-bottom { z-index: 1; }
.map-legend { display: flex; gap: 16px; margin-bottom: 12px; flex-wrap: wrap; font-size: 14px; }
.map-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; margin-right: 4px; vertical-align: middle; }
.map-dot--available { background: #16a34a; }
.map-dot--rented    { background: #2563eb; }
.map-dot--sold      { background: #7c3aed; }
.map-popup { font-size: 13px; line-height: 1.5; }

/* Templates */
.template-list { display: flex; flex-direction: column; gap: 8px; max-height: 320px; overflow-y: auto; }
.template-item { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px;
    border: 1px solid var(--color-border); border-radius: var(--radius); cursor: pointer; }
.template-item:hover { background: var(--color-bg); }
.template-item--active { border-color: var(--color-primary); background: var(--color-primary-light); }

/* Appraisal modal */
.appraisal-modal .modal-body { max-height: 75vh; overflow-y: auto; }

/* Portal export modal */
.portal-export-options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.portal-export-option {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 14px 16px;
    background: var(--color-bg);
    border: 1.5px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    text-align: left;
    transition: border-color .15s, background .15s, box-shadow .15s;
    width: 100%;
}

.portal-export-option:hover {
    border-color: #22d3ee;
    background: #ecfeff;
    box-shadow: 0 2px 8px rgba(14,116,144,.12);
}

.portal-export-option:active {
    background: #cffafe;
}

.portal-export-option__icon {
    font-size: 22px;
    flex-shrink: 0;
}

.portal-export-option__info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.portal-export-option__info strong {
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text);
}

.portal-export-option__info span {
    font-size: 12px;
    color: var(--color-muted);
}

.portal-export-option__arrow {
    font-size: 16px;
    color: var(--color-muted);
    transition: transform .15s, color .15s;
}

.portal-export-option:hover .portal-export-option__arrow {
    transform: translateX(3px);
    color: #0e7490;
}

/* TOTP setup */
.totp-setup { max-width: 520px; }

/* CSV import preview */
.import-preview { max-height: 280px; overflow: auto; border: 1px solid var(--color-border); border-radius: var(--radius); }
.import-preview table { width: 100%; font-size: 13px; }

/* Pagination & bulk selection */
.pagination-container { margin-top: 16px; }
.pagination-bar { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.bulk-toolbar { display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--color-primary-light); border-radius: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.bulk-toolbar[hidden] { display: none !important; }
.entity-card__select { margin-right: 8px; }
.price-history-list { font-size: 13px; margin-top: 8px; }
.price-history-item { padding: 6px 0; border-bottom: 1px solid var(--color-border); }
.price-history-item:last-child { border-bottom: none; }

/* ── Topbar actions & notification bell ─────────────────────────── */
.topbar-actions { display: flex; align-items: center; gap: 12px; margin-left: auto; }
.notif-wrapper { position: relative; }
.notif-bell {
    background: none; border: none; cursor: pointer;
    font-size: 20px; padding: 6px 8px;
    border-radius: var(--radius);
    position: relative;
    transition: background var(--transition);
    line-height: 1;
}
.notif-bell:hover { background: var(--color-bg); }
.notif-badge {
    position: absolute; top: 2px; right: 2px;
    background: var(--color-danger); color: #fff;
    border-radius: 10px; font-size: 10px; font-weight: 700;
    padding: 1px 5px; min-width: 16px; text-align: center;
    line-height: 14px; pointer-events: none;
}
.notif-dropdown {
    position: absolute; top: calc(100% + 8px); right: 0;
    width: 320px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    z-index: 300;
}
.notif-dropdown__header {
    padding: 12px 16px; font-size: 13px; font-weight: 700;
    border-bottom: 1px solid var(--color-border);
    background: #f8fafc; border-radius: var(--radius) var(--radius) 0 0;
}
.notif-dropdown__list { max-height: 320px; overflow-y: auto; }
.notif-item {
    display: block; width: 100%; padding: 12px 16px;
    border: none; border-bottom: 1px solid var(--color-border);
    background: transparent; text-align: left;
    cursor: pointer; font-family: inherit;
    transition: background var(--transition);
}
.notif-item:last-child { border-bottom: none; }
.notif-item:hover { background: var(--color-bg); }
.notif-item__title { display: block; font-size: 13px; font-weight: 600; color: var(--color-text); }
.notif-item__date  { display: block; font-size: 11px; color: var(--color-text-muted); margin-top: 2px; }
.notif-empty { padding: 20px 16px; text-align: center; }

/* --- Calendar --- */
.cal-title { font-weight: 700; min-width: 160px; text-align: center; display: inline-block; }
.cal-layout { display: grid; grid-template-columns: 1fr 320px; gap: 20px; align-items: start; }
.cal-main { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 12px; }
.cal-weekdays { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; margin-bottom: 6px; }
.cal-weekdays span { text-align: center; font-size: 12px; font-weight: 700; color: var(--color-text-muted); text-transform: uppercase; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-day {
    min-height: 90px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    padding: 4px;
    cursor: pointer;
    display: flex; flex-direction: column; gap: 4px;
    transition: background var(--transition);
}
.cal-day:hover { background: var(--color-bg); }
.cal-day--empty { background: transparent; border: none; cursor: default; min-height: 0; }
.cal-day--today { border-color: var(--color-primary); box-shadow: inset 0 0 0 1px var(--color-primary); }
.cal-day--selected { background: var(--color-primary-light); }
.cal-day--has-events .cal-day__num { font-weight: 700; }
.cal-day__num { font-size: 13px; font-weight: 500; }
.cal-day__events { display: flex; flex-direction: column; gap: 2px; overflow: hidden; }
.cal-event {
    font-size: 11px;
    padding: 1px 4px;
    border-radius: 4px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: var(--color-primary-light); color: var(--color-primary-dark);
}
.cal-event--pending { background: var(--color-primary-light); color: var(--color-primary-dark); }
.cal-event--completed { background: #dcfce7; color: #15803d; }
.cal-event--cancelled { background: #f1f5f9; color: #64748b; }
.cal-event--more { background: transparent; color: var(--color-text-muted); font-size: 10px; }
.cal-side { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius); padding: 16px; position: sticky; top: 16px; }
.cal-side__title { font-size: 15px; margin-bottom: 12px; text-transform: capitalize; }
.cal-side__events { display: flex; flex-direction: column; gap: 8px; }
.cal-side-item { padding: 10px; border: 1px solid var(--color-border); border-radius: 6px; }
.cal-side-item__time { font-size: 12px; color: var(--color-text-muted); }
.cal-side-item__title { font-weight: 600; margin-top: 2px; }
.cal-side-item__desc { font-size: 13px; margin: 4px 0; }

@media (max-width: 900px) {
    .cal-layout { grid-template-columns: 1fr; }
    .cal-side { position: static; }
    .cal-day { min-height: 72px; }
}

/* --- Reports page --- */
.reports-toolbar {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 8px 14px;
    box-shadow: var(--shadow);
}

.reports-toolbar__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    margin: 0;
}

.reports-toolbar__year {
    max-width: 100px;
    margin: 0;
}

.reports-kpi {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.reports-kpi__card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.reports-kpi__card--success .reports-kpi__value {
    color: var(--color-success);
}

.reports-kpi__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
}

/* ── Dashboard charts ────────────────────────────────────────────── */
.stats-grid--8 { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 1100px) { .stats-grid--8 { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 800px)  { .stats-grid--8 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 480px)  { .stats-grid--8 { grid-template-columns: 1fr 1fr; } }

.dashboard-charts {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin: 20px 0;
}
@media (max-width: 900px) { .dashboard-charts { grid-template-columns: 1fr; } }

.chart-card { padding: 20px; }
.chart-card__header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 16px;
}
.chart-card__header h3 { font-size: 15px; font-weight: 700; margin: 0; }
.chart-container {
    position: relative;
    height: 220px;
}
.chart-container--doughnut {
    height: 220px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.reports-kpi__value {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-text);
    line-height: 1.2;
}

.reports-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.report-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.report-card--wide {
    grid-column: 1 / -1;
}

.report-card__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--color-border);
    background: linear-gradient(180deg, #f8fafc 0%, var(--color-surface) 100%);
}

.report-card__title {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.report-card__icon {
    font-size: 20px;
    line-height: 1;
}

.report-card__header h3 {
    font-size: 16px;
    font-weight: 700;
    margin: 0;
}

.report-card__body {
    padding: 20px;
    flex: 1;
}

.report-section + .report-section {
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

.report-subtitle {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin: 0 0 12px;
}

.report-row {
    display: grid;
    grid-template-columns: minmax(90px, 120px) 1fr auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 10px;
}

.report-row__label {
    font-size: 13px;
    color: var(--color-text);
}

.report-row__value {
    font-size: 13px;
    font-weight: 700;
    color: var(--color-text);
    white-space: nowrap;
}

.report-bar {
    background: var(--color-bg);
    border-radius: 6px;
    height: 10px;
    overflow: hidden;
}

.report-bar__fill {
    height: 100%;
    background: var(--color-primary);
    border-radius: 6px;
    transition: width 0.4s ease;
    min-width: 2px;
}

.report-bar__fill--status-available { background: var(--color-success); }
.report-bar__fill--status-rented   { background: var(--color-primary); }
.report-bar__fill--status-sold     { background: #7c3aed; }
.report-bar__fill--expected        { background: #93c5fd; }
.report-bar__fill--collected       { background: var(--color-success); }
.report-bar__fill--cat-manutenzione { background: #f59e0b; }
.report-bar__fill--cat-utenze      { background: #3b82f6; }
.report-bar__fill--cat-tasse        { background: #ef4444; }
.report-bar__fill--cat-assicurazione { background: #8b5cf6; }
.report-bar__fill--cat-agenzia      { background: var(--color-primary); }

.report-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.report-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 14px;
}

.report-list li:last-child {
    border-bottom: none;
}

.report-list strong {
    font-size: 15px;
    color: var(--color-primary);
}

.report-payments-summary {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 20px;
    padding: 12px 14px;
    background: var(--color-bg);
    border-radius: 8px;
    font-size: 14px;
}

.report-chart {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    height: 200px;
    padding: 8px 4px 0;
    border-bottom: 2px solid var(--color-border);
}

.report-chart__col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 0;
    height: 100%;
}

.report-chart__bars {
    flex: 1;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 3px;
}

.report-chart__bar {
    width: 42%;
    border-radius: 4px 4px 0 0;
    min-height: 2px;
    transition: height 0.4s ease;
}

.report-chart__bar--expected  { background: #93c5fd; }
.report-chart__bar--collected { background: var(--color-success); }

.report-chart__label {
    font-size: 11px;
    color: var(--color-text-muted);
    margin-top: 8px;
    text-align: center;
}

.report-legend {
    display: flex;
    gap: 20px;
    margin-top: 16px;
    font-size: 13px;
    color: var(--color-text-muted);
}

.report-swatch {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 3px;
    margin-right: 6px;
    vertical-align: middle;
}

.report-swatch--expected  { background: #93c5fd; }
.report-swatch--collected { background: var(--color-success); }

.report-loading {
    display: flex;
    justify-content: center;
    padding: 32px;
}

.report-empty {
    padding: 12px 0;
    margin: 0;
}

@media (max-width: 900px) {
    .reports-kpi {
        grid-template-columns: repeat(2, 1fr);
    }

    .reports-grid {
        grid-template-columns: 1fr;
    }

    .report-card--wide {
        grid-column: auto;
    }

    .report-row {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .report-row__value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .reports-kpi {
        grid-template-columns: 1fr;
    }

    .report-chart {
        height: 160px;
        gap: 4px;
    }

    .report-chart__label {
        font-size: 9px;
    }
}

/* --- Agent portfolio cards --- */
.agents-grid {
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 20px;
}

.agent-card {
    border-top: 3px solid var(--color-border);
    padding: 0;
}

.agent-card--agent {
    border-top-color: var(--color-primary);
}

.agent-card--admin {
    border-top-color: #7c3aed;
}

.agent-card--super_admin {
    border-top-color: #b45309;
}

.agent-card__header {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 14px;
    padding: 18px 18px 14px;
    background: linear-gradient(180deg, #f8fafc 0%, var(--color-surface) 100%);
}

.agent-card__identity {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.agent-card__identity .entity-card__name {
    margin: 0;
}

.agent-card__email {
    font-size: 12px;
    color: var(--color-text-muted);
    text-decoration: none;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-card__email:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.agent-card__rate {
    text-align: right;
    flex-shrink: 0;
}

.agent-card__rate-value {
    display: block;
    font-size: 22px;
    font-weight: 800;
    color: var(--color-primary);
    line-height: 1.1;
}

.agent-card__rate-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-text-muted);
    margin-top: 2px;
}

.agent-card__progress {
    height: 4px;
    background: var(--color-bg);
    margin: 0 18px;
}

.agent-card__progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--color-primary), #34d399);
    border-radius: 0 2px 2px 0;
    transition: width 0.4s ease;
    min-width: 0;
}

.agent-card__stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 16px 18px 18px;
}

.agent-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 4px;
    padding: 12px 8px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: background var(--transition), border-color var(--transition);
}

.agent-card:hover .agent-stat {
    background: #fff;
}

.agent-stat__icon {
    font-size: 16px;
    line-height: 1;
}

.agent-stat__value {
    font-size: 20px;
    font-weight: 800;
    color: var(--color-text);
    line-height: 1.1;
}

.agent-stat__label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--color-text-muted);
    line-height: 1.3;
}

.badge--role-agent {
    background: #dbeafe;
    color: #1d4ed8;
    align-self: flex-start;
}

.badge--role-admin {
    background: #ede9fe;
    color: #6d28d9;
    align-self: flex-start;
}

.badge--role-super_admin {
    background: #ffedd5;
    color: #c2410c;
    align-self: flex-start;
}

@media (max-width: 900px) {
    .agents-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .agent-card__header {
        grid-template-columns: auto 1fr;
        grid-template-rows: auto auto;
    }

    .agent-card__rate {
        grid-column: 1 / -1;
        display: flex;
        align-items: baseline;
        justify-content: space-between;
        text-align: left;
        padding-top: 4px;
        border-top: 1px solid var(--color-border);
    }

    .agent-card__rate-value {
        font-size: 18px;
    }

    .agent-card__stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ==========================================================================
   UI polish — sharper sections, zebra lists, clearer separation
   ========================================================================== */

.stats-grid,
.dashboard-charts,
.reports-kpi,
.reports-grid {
    margin-bottom: var(--section-gap);
}

.stat-card {
    border-radius: var(--radius);
    border-color: var(--color-border);
}

.stat-card:hover {
    transform: none;
    border-color: var(--color-border-strong);
}

.card,
.settings-panel .card,
.table-wrapper,
.cal-main,
.reports-toolbar,
.reports-kpi__card,
.report-card {
    border-color: var(--color-border);
    box-shadow: var(--shadow);
}

.settings-panel .card + .card,
.settings-panel form.card {
    margin-top: var(--section-gap);
}

.template-list .template-item:nth-child(even),
.template-list > .template-item:nth-child(even) {
    background: var(--color-zebra);
}

.template-item {
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
}

.match-list .match-item:nth-child(even),
.appraisal-history .appraisal-item:nth-child(even) {
    background: var(--color-zebra);
}

.report-list li:nth-child(even) {
    background: var(--color-zebra);
    margin: 0 -12px;
    padding-left: 12px;
    padding-right: 12px;
    border-radius: var(--radius-sm);
}

.price-history-item:nth-child(even) {
    background: var(--color-zebra);
    margin: 0 -8px;
    padding-left: 8px;
    padding-right: 8px;
    border-radius: var(--radius-sm);
}

.notif-item:nth-child(even) {
    background: var(--color-zebra);
}

.lead-card,
.appointment-card,
.invoice-card {
    margin-bottom: 10px;
    box-shadow: var(--shadow);
}

.topbar {
    border-bottom-color: var(--color-border);
    box-shadow: 0 1px 0 rgba(15, 23, 42, 0.04);
}

.pagination-container {
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
}

.bulk-toolbar {
    border: 1px solid #bfdbfe;
}

.modal {
    border: 1px solid var(--color-border);
}

.alert {
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
}

/* ── Scheda Cliente (Client Profile) ─────────────────────────────── */
.client-profile-view { max-width: 1200px; }

.profile-topbar { margin-bottom: 16px; }

.profile-hero {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    padding: 24px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.profile-hero__avatar {
    width: 68px; height: 68px;
    border-radius: 50%;
    background: var(--color-primary);
    color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700;
    flex-shrink: 0;
    letter-spacing: -1px;
}

.profile-hero__info { flex: 1; min-width: 0; }

.profile-hero__name {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.profile-hero__name h2 { font-size: 22px; font-weight: 700; margin: 0; }

.profile-hero__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
}

.profile-hero__meta a { color: var(--color-primary); text-decoration: none; }
.profile-hero__meta a:hover { text-decoration: underline; }

.profile-hero__notes {
    background: var(--color-bg);
    border-left: 3px solid var(--color-primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    padding: 10px 14px;
    font-size: 14px;
}

.profile-hero__notes strong {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--color-text-muted);
    margin-bottom: 4px;
}

.profile-hero__notes p { margin: 0; color: var(--color-text); white-space: pre-wrap; line-height: 1.55; }

.profile-hero__actions { display: flex; gap: 8px; flex-shrink: 0; align-self: flex-start; }

/* Profile tabs */
.profile-tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--color-border);
    margin-bottom: 20px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.profile-tab {
    padding: 10px 22px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    color: var(--color-text-muted);
    white-space: nowrap;
    transition: color var(--transition), border-color var(--transition);
    font-family: inherit;
}

.profile-tab:hover { color: var(--color-text); }
.profile-tab--active { color: var(--color-primary); border-bottom-color: var(--color-primary); }

/* Profile panels */
.profile-panel { animation: fadeIn 0.15s ease; }

.profile-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    gap: 12px;
    flex-wrap: wrap;
}

/* Property cards inside profile */
.profile-prop-card { cursor: default; }
.prop-card-thumb-wrap { height: 110px; overflow: hidden; border-radius: var(--radius) var(--radius) 0 0; background: var(--color-bg); }
.prop-card-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.prop-card-thumb--empty { display: flex; align-items: center; justify-content: center; font-size: 34px; height: 100%; }
.profile-prop-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.profile-prop-rent { font-size: 13px; font-weight: 700; color: var(--color-primary); }

/* Document list */
.docs-list { display: flex; flex-direction: column; gap: 8px; }
.doc-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: background var(--transition);
}
.doc-item:hover { background: var(--color-bg); }
.doc-item__icon { font-size: 24px; flex-shrink: 0; line-height: 1; }
.doc-item__info { flex: 1; min-width: 0; }
.doc-item__name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item__meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.doc-item__actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Chat thread in profile */
.chat-container { display: flex; flex-direction: column; gap: 12px; }
.chat-messages {
    min-height: 260px;
    max-height: 460px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 16px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
}
.chat-bubble {
    max-width: 68%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.5;
}
.chat-bubble--sent {
    align-self: flex-end;
    background: var(--color-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-bubble--received {
    align-self: flex-start;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-bottom-left-radius: 4px;
}
.chat-bubble__head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    font-size: 11px;
    opacity: 0.7;
    margin-bottom: 5px;
}
.chat-bubble__subject { font-weight: 700; margin-bottom: 4px; }
.chat-bubble__body { white-space: pre-wrap; }
.chat-compose__form {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 16px;
}
.chat-compose__row { display: flex; gap: 10px; align-items: flex-end; }
.chat-compose__row .form-textarea { flex: 1; resize: vertical; }
.chat-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* Reminders list in profile */
.reminders-list { display: flex; flex-direction: column; gap: 8px; }
.reminder-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    transition: background var(--transition);
}
.reminder-item:hover { background: var(--color-bg); }
.reminder-item--completed { opacity: 0.55; }
.reminder-item--cancelled { opacity: 0.45; }
.reminder-item__icon { font-size: 18px; flex-shrink: 0; line-height: 1; }
.reminder-item__info { flex: 1; min-width: 0; }
.reminder-item__title { font-weight: 600; font-size: 14px; }
.reminder-item__meta { font-size: 12px; color: var(--color-text-muted); margin-top: 2px; }
.reminder-item__actions { display: flex; gap: 4px; flex-shrink: 0; }

/* Automation card */
.automation-preview {
    margin-top: 8px;
    font-size: 12px;
    color: var(--color-text-muted);
    background: var(--color-bg);
    border-radius: 6px;
    padding: 6px 10px;
    white-space: pre-wrap;
    line-height: 1.5;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

@media (max-width: 640px) {
    .profile-hero { flex-direction: column; }
    .profile-hero__actions { align-self: stretch; }
    .chat-bubble { max-width: 88%; }
    .profile-tab { padding: 10px 14px; font-size: 13px; }
}

/* ==========================================================================
   BUTTON SYSTEM — visual polish (tactile, semantic, accessible)
   Appended last so these rules win the cascade cleanly.
   ========================================================================== */

/* ── Base: add depth + lift to every button ─────────────────────────────── */
.btn {
    box-shadow: 0 1px 2px rgba(15,23,42,.07), 0 1px 1px rgba(15,23,42,.04);
    transition:
        background   .15s ease,
        border-color .15s ease,
        color        .15s ease,
        box-shadow   .15s ease,
        transform    .12s ease;
    letter-spacing: .01em;
}
.btn:not(:disabled):hover  { transform: translateY(-1px); }
.btn:not(:disabled):active { transform: translateY(0) scale(.98); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: grayscale(.3); }

/* Keyboard focus ring */
.btn:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(37,99,235,.18);
}

/* ── Primary: gradient + coloured shadow ────────────────────────────────── */
.btn--primary {
    background: linear-gradient(160deg, #4f8ef7 0%, var(--color-primary-dark) 100%);
    border-color: var(--color-primary-dark);
    box-shadow: 0 2px 8px rgba(37,99,235,.32), 0 1px 2px rgba(15,23,42,.08);
    text-shadow: 0 1px 1px rgba(0,0,0,.14);
}
.btn--primary:not(:disabled):hover {
    background: linear-gradient(160deg, var(--color-primary) 0%, #1a3fc5 100%);
    box-shadow: 0 4px 16px rgba(37,99,235,.40), 0 2px 4px rgba(15,23,42,.08);
}
.btn--primary:not(:disabled):active {
    box-shadow: 0 1px 4px rgba(37,99,235,.30);
}

/* ── Ghost: visible white card instead of completely transparent ─────────── */
.btn--ghost {
    background: #ffffff;
    color: var(--color-text);
    border-color: var(--color-border-strong);
    box-shadow: 0 1px 3px rgba(15,23,42,.08), 0 1px 1px rgba(15,23,42,.04);
}
.btn--ghost:not(:disabled):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
    box-shadow: 0 3px 10px rgba(37,99,235,.16);
}
.btn--ghost:not(:disabled):active {
    background: #dbeafe;
    border-color: var(--color-primary);
    box-shadow: 0 1px 3px rgba(37,99,235,.20);
}

/* Small ghost buttons (table action icons) — start subtle, pop on hover */
.btn--sm.btn--ghost {
    background: var(--color-surface-muted);
    border-color: var(--color-border);
    color: var(--color-text-muted);
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.btn--sm.btn--ghost:not(:disabled):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
    box-shadow: 0 2px 8px rgba(37,99,235,.15);
}

/* Destructive table actions — red on hover (matched via title) */
.btn--sm.btn--ghost[title*="Elimina"]:not(:disabled):hover,
.btn--sm.btn--ghost[title*="elimina"]:not(:disabled):hover,
.btn--sm.btn--ghost[title*="Archivia"]:not(:disabled):hover,
.btn--sm.btn--ghost[title*="archivia"]:not(:disabled):hover,
.btn--sm.btn--ghost[title*="Rimuovi"]:not(:disabled):hover,
.btn--sm.btn--ghost[title*="Cancella"]:not(:disabled):hover {
    background: #fef2f2;
    border-color: #fca5a5;
    color: var(--color-danger);
    box-shadow: 0 2px 8px rgba(220,38,38,.14);
}

/* ── Danger: gradient + red shadow ─────────────────────────────────────── */
.btn--danger {
    background: linear-gradient(160deg, #f87171 0%, var(--color-danger) 100%);
    border-color: var(--color-danger);
    box-shadow: 0 2px 8px rgba(220,38,38,.30), 0 1px 2px rgba(15,23,42,.08);
    text-shadow: 0 1px 1px rgba(0,0,0,.14);
}
.btn--danger:not(:disabled):hover {
    background: linear-gradient(160deg, var(--color-danger) 0%, #b91c1c 100%);
    box-shadow: 0 4px 16px rgba(220,38,38,.38);
}
.btn--danger:not(:disabled):active {
    box-shadow: 0 1px 4px rgba(220,38,38,.28);
}

/* ── Outline primary ────────────────────────────────────────────────────── */
.btn--outline-primary {
    box-shadow: 0 1px 3px rgba(37,99,235,.12);
}
.btn--outline-primary:not(:disabled):hover {
    box-shadow: 0 3px 10px rgba(37,99,235,.24);
}

/* ── Semantic colour variants — add shadow + lift on hover ──────────────── */
.btn--export:not(:disabled):hover {
    box-shadow: 0 3px 10px rgba(4,120,87,.22);
}
.btn--import:not(:disabled):hover {
    box-shadow: 0 3px 10px rgba(29,78,216,.22);
}
.btn--compare:not(:disabled):hover {
    box-shadow: 0 3px 10px rgba(67,56,202,.22);
}
.btn--portal:not(:disabled):hover {
    box-shadow: 0 3px 10px rgba(14,116,144,.22);
}

/* Clear filters button: already has red colours, add lift */
.btn-clear-filters {
    box-shadow: 0 1px 3px rgba(220,38,38,.14);
    transition: background .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease;
}
.btn-clear-filters:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: 0 3px 10px rgba(220,38,38,.28);
}

/* ── XS buttons (gallery, inline) ──────────────────────────────────────── */
.btn--xs {
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.btn--xs:not(:disabled):hover { transform: translateY(-1px); }

/* ── Modal close × ─────────────────────────────────────────────────────── */
.modal-close {
    transition: background .15s ease, color .15s ease, transform .12s ease;
    border-radius: var(--radius-sm);
}
.modal-close:hover {
    background: #fee2e2;
    color: var(--color-danger);
    transform: scale(1.12);
}
.modal-close:active {
    background: #fecaca;
    transform: scale(.96);
}

/* ── Gallery delete button ──────────────────────────────────────────────── */
.gallery-item__delete {
    transition: background .15s ease, color .15s ease, border-color .15s ease,
                transform .12s ease, box-shadow .15s ease;
}
.gallery-item__delete:hover {
    background: var(--color-danger);
    color: #fff;
    border-color: var(--color-danger);
    transform: scale(1.08);
    box-shadow: 0 2px 8px rgba(220,38,38,.30);
}

/* ── Notification bell ──────────────────────────────────────────────────── */
.notif-bell {
    transition: background .15s ease, transform .12s ease;
}
.notif-bell:hover { transform: scale(1.1) rotate(-8deg); }
.notif-bell:active { transform: scale(.95); }

/* ── Settings tabs ──────────────────────────────────────────────────────── */
.settings-tab {
    transition: background .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.settings-tab:not(.settings-tab--active):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37,99,235,.14);
}
.settings-tab--active {
    box-shadow: 0 2px 8px rgba(37,99,235,.28);
}

/* ── Profile / client-profile tabs ─────────────────────────────────────── */
.profile-tab {
    transition: background .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.profile-tab:not(.active):hover {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
    color: var(--color-primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(37,99,235,.14);
}
.profile-tab.active {
    box-shadow: 0 2px 8px rgba(37,99,235,.24);
}

/* ── Kanban / view-toggle buttons ───────────────────────────────────────── */
.mw-view-toggle {
    transition: background .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.07);
}
.mw-view-toggle:not(.active):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15,23,42,.12);
}
.mw-view-toggle.active {
    box-shadow: 0 2px 8px rgba(37,99,235,.22);
}

/* ── Commissions tabs ───────────────────────────────────────────────────── */
.comm-tab {
    transition: background .15s ease, border-color .15s ease, color .15s ease,
                box-shadow .15s ease, transform .12s ease;
    box-shadow: 0 1px 2px rgba(15,23,42,.06);
}
.comm-tab:not(.active):hover {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(15,23,42,.12);
}
.comm-tab.active {
    box-shadow: 0 2px 8px rgba(37,99,235,.22);
}

/* ===== Mobile table card overrides ======================================== */
@media (max-width: 768px) {

    /* Hide unlabelled cells (checkbox / select-all columns) */
    .table-wrapper .data-table td:not([data-label]) {
        display: none;
    }

    /* Force ALL content in cards to wrap — overrides the many white-space:nowrap rules */
    .table-wrapper .data-table td,
    .table-wrapper .data-table td * {
        white-space: normal !important;
        word-break: break-word;
        overflow-wrap: break-word;
        max-width: 100%;
    }

    /* Buttons/links stay on one line */
    .table-wrapper .data-table td button,
    .table-wrapper .data-table td a.btn {
        white-space: nowrap !important;
        word-break: keep-all;
    }

    /* Badge text stays compact */
    .table-wrapper .data-table td .badge {
        white-space: nowrap !important;
        display: inline-block;
    }

    /* code tags can break anywhere */
    .table-wrapper .data-table td code {
        word-break: break-all;
    }

    /* First labelled cell = card title row */
    .table-wrapper .data-table tbody tr > td[data-label]:first-of-type {
        padding-bottom: 10px;
        margin-bottom: 2px;
        border-bottom: 1px solid var(--color-border-muted, #f0f4f8);
        font-weight: 600;
    }

    /* ── Per-view column pruning: hide less-useful columns on small screens ── */

    /* Documents: hide size & property (keep tipo, name, owner, date, actions) */
    .documents-view .table-wrapper td[data-label="Dimensione"],
    .documents-view .table-wrapper td[data-label="Immobile"] {
        display: none;
    }

    /* Tenants: hide portal & contract dates (keep name, email, property, rent, actions) */
    .tenants-view .table-wrapper td[data-label="Contratto"],
    .tenants-view .table-wrapper td[data-label="Portale"] {
        display: none;
    }

    /* Reminders: hide frequency (keep title, date, status, client, actions) */
    .reminders-view .table-wrapper td[data-label="Frequenza"],
    .reminders-view .table-wrapper td[data-label="Ripetizione"] {
        display: none;
    }

    /* Commissions: hide percentage (keep agent, type, amount, contract, date, status) */
    .commissions-view .table-wrapper td[data-label="%"],
    .commissions-view .table-wrapper td[data-label="Percentuale"] {
        display: none;
    }

    /* Payments: hide notes */
    .payments-view .table-wrapper td[data-label="Note"] {
        display: none;
    }

    /* Invoices: hide notes */
    .invoices-view .table-wrapper td[data-label="Note"] {
        display: none;
    }
}

/* ===== Collapsible filter bars ============================================ */
.toolbar,
.reports-toolbar,
.filter-bar {
    overflow: hidden;
    transition:
        max-height .3s cubic-bezier(.4,0,.2,1),
        opacity    .22s ease,
        padding    .3s  cubic-bezier(.4,0,.2,1),
        margin     .3s  cubic-bezier(.4,0,.2,1);
}
.toolbar:not(.is-open),
.reports-toolbar:not(.is-open),
.filter-bar:not(.is-open) {
    max-height: 0;
    opacity: 0;
    pointer-events: none;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
}
.toolbar.is-open,
.reports-toolbar.is-open,
.filter-bar.is-open {
    max-height: 600px;
    opacity: 1;
    pointer-events: auto;
}

/* Toggle button */
.toolbar-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    width: 100%;
    padding: 0.7rem 1.1rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--color-primary, #2563eb);
    background: var(--surface-muted, #f8fafc);
    border: 1px solid var(--color-border, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.toolbar-toggle:hover {
    background: var(--color-primary-light, #eff6ff);
    border-color: var(--color-primary, #2563eb);
    box-shadow: 0 1px 4px rgba(37,99,235,.14);
}
.toolbar-toggle .toggle-icon {
    display: inline-block;
    font-style: normal;
    font-size: 0.7rem;
    transition: transform .28s cubic-bezier(.4,0,.2,1);
    line-height: 1;
}
.toolbar-toggle[aria-expanded="true"] .toggle-icon {
    transform: rotate(180deg);
}

/* ── Property Profile (Scheda Immobile) ──────────────────── */
/* Fill the available width so the sticky sidebar sits near the right edge.
   The .pp-layout grid (1fr + 340px) distributes the space dynamically; on a
   single-column fallback (<=980px) the cap is irrelevant. */
.property-profile-view { max-width: 100%; }

.property-profile-hero {
    display: flex;
    gap: 0;
    overflow: hidden;
    padding: 0;
    align-items: stretch;
}

.pp-hero-cover {
    width: 320px;
    flex-shrink: 0;
    background: var(--color-bg);
    position: relative;
}
.pp-hero-cover-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    min-height: 220px;
}
.pp-hero-cover-placeholder {
    width: 100%;
    min-height: 220px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--color-text-muted, #94a3b8);
    font-size: 14px;
}
.pp-hero-cover-placeholder span:first-child { font-size: 48px; }

.pp-hero-body {
    flex: 1;
    padding: 24px 28px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.pp-hero-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.pp-hero-address {
    font-size: 20px;
    font-weight: 700;
    margin: 0 0 4px;
    line-height: 1.2;
}

.pp-hero-location { font-size: 14px; }

.pp-hero-owner {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
}

.btn-link {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    cursor: pointer;
    font-size: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
}
.btn-link:hover { opacity: 0.8; }

.pp-hero-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--color-primary);
}
.pp-hero-price-sub { font-size: 14px; font-weight: 400; color: var(--color-text-muted, #64748b); }

.pp-hero-notes {
    background: var(--color-bg);
    border-left: 3px solid var(--color-primary, #2563eb);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    font-size: 13px;
}
.pp-hero-notes strong { display: block; font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; opacity: 0.6; margin-bottom: 3px; }
.pp-hero-notes p { margin: 0; white-space: pre-wrap; }

.pp-hero-description { font-size: 13px; line-height: 1.5; }

.pp-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

/* Price history table */
.price-history-list { padding: 4px 0; }
.price-history-list .data-table { width: 100%; }

/* Property profile — tabs spacing & panel header */
.property-profile-view .profile-tabs {
    margin-top: 32px;
    border-bottom: none;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px 12px 0 0;
    padding: 0 8px;
    gap: 4px;
    overflow: hidden;
}

.property-profile-view .profile-tab {
    border-radius: 8px 8px 0 0;
    border-bottom: 3px solid transparent;
    padding: 13px 20px;
    font-size: 13px;
    margin-bottom: 0;
}

.property-profile-view .profile-tab--active {
    background: var(--color-bg);
    border-bottom-color: var(--color-primary);
}

.property-profile-view .profile-panel {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-top: none;
    border-radius: 0 0 12px 12px;
    padding: 20px 24px 24px;
    /* Stable height so the loading->data swap doesn't change the column height
       (which made the sticky sidebar jump/flicker). */
    min-height: 420px;
}

.property-profile-view .profile-panel__header {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--color-border);
}

.property-profile-view #pp-media-count,
.property-profile-view #pp-docs-count,
.property-profile-view #pp-reminders-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-muted);
    letter-spacing: 0.2px;
}

@media (max-width: 680px) {
    .property-profile-hero { flex-direction: column; }
    .pp-hero-cover { width: 100%; }
    .pp-hero-cover-img { min-height: 180px; max-height: 220px; }
}

/* ── Copy button (inline on cards and scheda) ─────────────── */
.btn--copy {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    padding: 1px 5px;
    font-size: 11px;
    line-height: 1.4;
    opacity: 0.4;
    transition: opacity 0.15s, background 0.15s, border-color 0.15s;
    margin-left: auto;
    flex-shrink: 0;
    color: var(--color-text);
}
.btn--copy:hover {
    opacity: 1;
    background: var(--color-bg);
    border-color: var(--color-border);
}
.btn--copy.copied {
    opacity: 1;
    color: #16a34a;
}

/* ── Scheda Proprietario modal body ───────────────────────── */
.scheda-hero {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 20px;
}
.scheda-hero__avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: var(--color-primary, #2563eb);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    flex-shrink: 0;
}
.scheda-hero__info { flex: 1; min-width: 0; }
.scheda-hero__name {
    font-size: 20px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.scheda-contact {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 5px 0;
    font-size: 14px;
}
.scheda-contact a { color: var(--color-primary); text-decoration: none; }
.scheda-contact a:hover { text-decoration: underline; }
.scheda-notes {
    background: var(--color-bg);
    border-left: 3px solid var(--color-primary, #2563eb);
    padding: 10px 14px;
    border-radius: 0 6px 6px 0;
    margin: 16px 0;
}
.scheda-notes strong {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    margin-bottom: 4px;
}
.scheda-notes p { margin: 0; white-space: pre-wrap; }
.scheda-stats { display: flex; gap: 16px; flex-wrap: wrap; margin: 12px 0 4px; }
.scheda-id-info {
    margin-top: 14px;
    padding-top: 14px;
    border-top: 1px solid var(--color-border);
}
.scheda-id-info__label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.6;
    margin-bottom: 8px;
}

/* ID card section inside edit modal */
.id-card-status-container { font-size: 14px; }
.id-card-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

/* ID card front/back layout */
.id-card-sides {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}
.id-card-side {
    flex: 1;
    min-width: 160px;
    padding: 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: 8px;
}
.id-card-side-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted, #94a3b8);
    margin-bottom: 8px;
}

/* Reminder rows in property profile */
.reminder-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 8px;
    transition: background 0.15s;
}
.reminder-row + .reminder-row { margin-top: 6px; }
.reminder-row--done { opacity: 0.55; }
.reminder-row__info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 14px;
}
.reminder-row__info .text-muted { font-size: 12px; }
.reminder-row__actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    align-items: center;
}

/* ── Property Profile — title section ────────────────────────── */
/* Clean, subtle back link (replaces the boxed button) on the property page */
.profile-topbar--pp { margin-bottom: 8px; }
.pp-back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    padding: 4px 2px;
    margin-left: -2px;
    cursor: pointer;
    color: var(--color-text-muted, #64748b);
    font-size: 0.85rem;
    font-weight: 600;
    line-height: 1;
    transition: color .15s ease, gap .15s ease;
}
.pp-back-link:hover { color: var(--color-primary, #2563eb); gap: 9px; }
.pp-back-link svg { width: 16px; height: 16px; }

.pp-title-section {
    margin-bottom: 16px;
}
.pp-title-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 4px;
}
.pp-title-heading {
    font-size: 22px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}
.pp-title-meta {
    font-size: 14px;
    color: var(--color-text-muted, #64748b);
}

/* ── Booking.com gallery ─────────────────────────────────────── */
.pp-gallery {
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 24px;
    background: var(--color-bg);
    min-height: 240px;
    position: relative;
}
.pp-gallery--loading {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 0 photos */
.pp-gallery-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 240px;
    color: var(--color-text-muted, #94a3b8);
    font-size: 14px;
    border: 2px dashed var(--color-border);
    border-radius: 12px;
}
.pp-gallery-placeholder__icon { font-size: 48px; }

/* 1 photo */
.pp-gallery-single {
    display: flex;
    height: 420px;
}
.pp-gallery-single .pp-gallery-main-wrap {
    flex: 1;
}

/* 2+ photos: split layout */
.pp-gallery-split {
    display: flex;
    height: 420px;
    gap: 4px;
}

/* Main photo */
.pp-gallery-main-wrap {
    position: relative;
    flex: 0 0 62%;
    min-width: 0;
    cursor: pointer;
    overflow: hidden;
}
.pp-gallery-main-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s;
}
.pp-gallery-main-wrap:hover .pp-gallery-main-img { transform: scale(1.02); }

/* "Show all" button on main photo */
.pp-gallery-btn-all {
    position: absolute;
    bottom: 14px;
    right: 14px;
    background: rgba(255,255,255,0.92);
    border: none;
    border-radius: 8px;
    padding: 7px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.15s;
    z-index: 2;
}
.pp-gallery-btn-all:hover { background: #fff; }

/* Thumbnail column */
.pp-gallery-thumbs {
    flex: 1;
    display: flex;
    gap: 4px;
    min-width: 0;
    overflow: hidden;
}
.pp-gallery-thumbs--col { flex-direction: column; }
.pp-gallery-thumbs--grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}
/* 3 thumbnails (4 photos total): let the 3rd span the full bottom row so there's no empty cell */
.pp-gallery-thumbs--c3 .pp-gallery-thumb:nth-child(3) { grid-column: 1 / -1; }

.pp-gallery-thumb {
    position: relative;
    overflow: hidden;
    cursor: pointer;
    flex: 1;
    min-height: 0;
}
.pp-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.25s;
}
.pp-gallery-thumb:hover img { transform: scale(1.04); }

/* "+N foto" overlay on last thumbnail */
.pp-gallery-thumb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.52);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.5px;
    pointer-events: none;
    z-index: 1;
}

/* ── Info card (below gallery) ───────────────────────────────── */
.pp-info-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px 28px;
    margin-bottom: 8px;
}
.pp-info-main {
    display: flex;
    gap: 32px;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.pp-info-left { flex: 1 1 260px; min-width: 0; }
.pp-info-right { flex: 0 0 220px; min-width: 0; }

.pp-info-price {
    font-size: 26px;
    font-weight: 800;
    color: var(--color-primary, #2563eb);
    line-height: 1;
    margin-bottom: 12px;
}
.pp-info-price-type {
    font-size: 15px;
    font-weight: 400;
    color: var(--color-text-muted, #64748b);
    margin-left: 4px;
}
.pp-info-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.pp-info-description {
    font-size: 14px;
    line-height: 1.6;
    margin: 0 0 10px;
    color: var(--color-text);
}
.pp-info-notes {
    font-size: 13px;
    background: var(--color-bg);
    border-left: 3px solid var(--color-primary, #2563eb);
    padding: 8px 12px;
    border-radius: 0 6px 6px 0;
    margin: 0;
    line-height: 1.5;
}

.pp-info-detail-block {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
}
.pp-info-detail-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted, #94a3b8);
}
.pp-info-owner-btn {
    background: none;
    border: none;
    padding: 0;
    color: var(--color-primary);
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-align: left;
}
.pp-info-owner-btn:hover { opacity: 0.75; }

.pp-info-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--color-border);
}

/* ── Lightbox ─────────────────────────────────────────────────── */
.pp-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9900;
    align-items: center;
    justify-content: center;
}
.pp-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.92);
}
.pp-lightbox-img-wrap {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}
.pp-lightbox-img {
    max-width: 90vw;
    max-height: 82vh;
    object-fit: contain;
    border-radius: 6px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.6);
    display: block;
}
.pp-lightbox-counter {
    color: rgba(255,255,255,0.7);
    font-size: 14px;
}
.pp-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    z-index: 2;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
}
.pp-lightbox-close:hover { background: rgba(255,255,255,0.3); }
.pp-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 2;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    font-size: 28px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    line-height: 1;
}
.pp-lightbox-nav:hover { background: rgba(255,255,255,0.3); }
.pp-lightbox-prev { left: 20px; }
.pp-lightbox-next { right: 20px; }

@media (max-width: 680px) {
    .pp-gallery-split { flex-direction: column; height: auto; }
    .pp-gallery-main-wrap { flex: none; height: 220px; }
    .pp-gallery-thumbs { flex: none; height: 100px; flex-direction: row; }
    .pp-gallery-thumbs--grid { display: flex; flex-direction: row; }
    .pp-gallery-single { height: 220px; }
    .pp-info-main { gap: 16px; }
    .pp-info-right { flex: 1 1 100%; }
}

/* ── Gestione Foto — management grid ────────────────────────── */
#pp-gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
}

#pp-gallery-grid .gallery-item {
    border: 1px solid var(--color-border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--color-bg);
    display: flex;
    flex-direction: column;
}

#pp-gallery-grid .gallery-item-thumb {
    position: relative;
    width: 100%;
    height: 100px;
    overflow: hidden;
    cursor: pointer;
    background: var(--color-bg);
}

#pp-gallery-grid .gallery-item-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.2s;
}
#pp-gallery-grid .gallery-item-thumb:hover img { transform: scale(1.06); }

#pp-gallery-grid .gallery-item-icon {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
}

#pp-gallery-grid .gallery-cover-badge {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: var(--color-primary);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    letter-spacing: 0.3px;
    text-transform: uppercase;
}

#pp-gallery-grid .gallery-item-info {
    padding: 6px 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
}

#pp-gallery-grid .gallery-item-name {
    font-size: 11px;
    color: var(--color-text-muted, #64748b);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.3;
}

#pp-gallery-grid .gallery-item-actions {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-top: 2px;
}

/* ── Floating compare bar ────────────────────────────────────── */
.compare-float-bar {
    position: fixed;
    bottom: 0;
    left: var(--sidebar-width, 260px);
    right: 0;
    z-index: 300;
    background: var(--color-surface, #1e293b);
    border-top: 2px solid var(--color-primary, #2563eb);
    padding: 10px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.25);
    animation: compareBarSlideUp 0.2s ease;
}
.compare-float-bar[hidden] { display: none; }

@keyframes compareBarSlideUp {
    from { transform: translateY(100%); }
    to   { transform: translateY(0); }
}

.compare-float-bar__chips {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    flex: 1;
    min-width: 0;
}

.compare-chip {
    background: var(--color-primary, #2563eb);
    color: #fff;
    font-size: 0.78rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 200px;
}

.compare-chip--more {
    background: var(--color-bg, #0f172a);
    border: 1px solid var(--color-border, #334155);
    color: var(--color-text-muted, #94a3b8);
}

.compare-float-bar__actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.compare-float-clear {
    color: var(--color-text-muted, #94a3b8);
    border-color: var(--color-border, #334155);
}
.compare-float-clear:hover { color: var(--color-text, #e2e8f0); }

.compare-float-go {
    background: var(--color-primary, #2563eb);
    color: #fff;
    border: none;
    font-weight: 600;
}
.compare-float-go:hover { opacity: 0.9; }

@media (max-width: 768px) {
    .compare-float-bar { left: 0; }
}

/* ── Scheda quick-view detail rows (shared across modules) ─────── */
.scheda-rows { display: flex; flex-direction: column; gap: 0; }
.scheda-row {
    display: flex;
    gap: 16px;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border);
    align-items: flex-start;
}
.scheda-row:last-child { border-bottom: none; }
.scheda-row__label {
    width: 130px;
    flex-shrink: 0;
    color: var(--color-text-muted, #64748b);
    font-size: 0.82rem;
    font-weight: 500;
    padding-top: 1px;
}
.scheda-row__value { flex: 1; font-size: 0.9rem; line-height: 1.4; }
.scheda-modal-badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.scheda-amount-hero {
    font-size: 28px;
    font-weight: 800;
    color: var(--color-primary, #2563eb);
    margin-bottom: 8px;
}

/* ── Property profile: redesigned listing layout ──────────────────────────── */
.pp-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 340px;
    gap: 24px;
    align-items: stretch;
    margin-top: 16px;
}
.pp-main { min-width: 0; }
.pp-aside {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: static;
}
/* Let the Promemoria card grow to absorb extra height so the two columns stay even. */
.pp-aside > .pp-side-card--grow { flex: 1 1 auto; }
.pp-summary-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 18px 18px 16px;
}
.pp-summary-price { font-size: 1.6rem; font-weight: 800; color: var(--color-text); line-height: 1.1; }
.pp-summary-price__type { font-size: 0.85rem; font-weight: 600; color: var(--color-text-muted, #64748b); }
.pp-summary-badge { margin-top: 10px; }
.pp-summary-owner { margin-top: 14px; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.pp-summary-owner-btn { text-align: left; padding-left: 0; }
.pp-summary-label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: .03em; color: var(--color-text-muted, #64748b); }
.pp-summary-facts { margin: 14px 0 0; padding: 14px 0 0; border-top: 1px solid var(--color-border); display: flex; flex-direction: column; gap: 8px; }
.pp-summary-facts > div { display: flex; justify-content: space-between; gap: 12px; font-size: 0.85rem; }
.pp-summary-facts dt { color: var(--color-text-muted, #64748b); margin: 0; }
.pp-summary-facts dd { margin: 0; font-weight: 600; text-align: right; }
.pp-summary-actions { margin-top: 16px; display: flex; flex-direction: column; gap: 8px; }
.pp-summary-actions .btn { width: 100%; justify-content: center; }

.pp-section-title { margin: 0 0 10px; font-size: 1.05rem; }
.pp-section-subtitle { margin: 16px 0 8px; font-size: 0.9rem; color: var(--color-text-muted, #64748b); }
.pp-feature-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.pp-info-card { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: 12px; padding: 18px 20px; }
.pp-info-description { margin: 0; white-space: pre-line; line-height: 1.6; }
.pp-info-notes { margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--color-border); font-size: 0.85rem; color: var(--color-text-muted, #64748b); }

/* Key facts strip under the gallery */
.pp-highlights {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 16px 0 20px;
}
.pp-hl {
    flex: 1 1 104px;
    max-width: 180px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 10px;
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

@media (max-width: 980px) {
    .pp-layout { grid-template-columns: 1fr; }
    .pp-aside { position: static; }
}
.pp-hl__icon { font-size: 20px; line-height: 1; color: var(--color-primary, #2563eb); display: inline-flex; }
.pp-hl__icon svg { width: 20px; height: 20px; }
.pp-hl__value { font-weight: 700; font-size: 0.95rem; }
.pp-hl__label { font-size: 0.72rem; color: var(--color-text-muted, #64748b); text-transform: uppercase; letter-spacing: .02em; }

.pp-columns {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 320px;
    gap: 20px;
    align-items: start;
    margin-bottom: 8px;
}
.pp-col-side { display: flex; flex-direction: column; gap: 16px; }
.pp-side-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 14px 16px;
}
.pp-side-card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}
.pp-side-card__head h3 { margin: 0; font-size: 0.95rem; }
.pp-side-upload { cursor: pointer; margin: 0; }
.pp-side-list { display: flex; flex-direction: column; gap: 8px; }
.pp-side-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    font-size: 0.82rem;
}
.pp-side-item__main { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1 1 auto; }

/* Contract status dots (active / expired) */
.status-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: 0 0 auto; }
.status-dot--active  { background: #16a34a; box-shadow: 0 0 0 3px rgba(22,163,74,.15); }
.status-dot--expired { background: #dc2626; box-shadow: 0 0 0 3px rgba(220,38,38,.15); }
.status-dot--pending { background: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.15); }
.pp-side-status { font-size: 0.7rem; font-weight: 700; flex: 0 0 auto; text-transform: uppercase; letter-spacing: .02em; }
.pp-side-status--active  { color: #16a34a; }
.pp-side-status--expired { color: #dc2626; }
.pp-side-status--pending { color: #b45309; }
.pp-side-item__main strong { font-size: 0.85rem; }
.pp-side-item__name { word-break: break-all; }
.pp-side-item--file { background: var(--color-bg, #f8fafc); }
.pp-side-attach { display: inline-flex; align-items: center; gap: 4px; font-size: 0.72rem; font-weight: 600; color: var(--color-primary, #2563eb); margin-top: 2px; }
.pp-side-attach svg { width: 13px; height: 13px; }

/* Small per-contract delete button in the side card */
.pp-side-del {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 1px solid transparent;
    border-radius: 7px;
    background: transparent;
    color: var(--color-text-muted, #94a3b8);
    cursor: pointer;
    transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.pp-side-del:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #fecaca;
}
.pp-side-del:active { transform: scale(.94); }
.pp-side-del svg { width: 15px; height: 15px; }

/* Importa-contratto modal: auto-filled fields + file info */
.pci-fileinfo { display: flex; align-items: center; gap: 6px; padding: 8px 10px; background: var(--color-bg, #f8fafc); border: 1px solid var(--color-border); border-radius: 8px; font-size: 0.85rem; margin-bottom: 12px; }
.pci-fileinfo svg { width: 15px; height: 15px; }
.form-input.pci-autofilled, .form-select.pci-autofilled { border-color: #16a34a; background: rgba(22,163,74,.06); }

@media (max-width: 900px) {
    .pp-columns { grid-template-columns: 1fr; }
}

/* ── Immobili: column-count toggle (#12) ──────────────────────────────────── */
/* Horizontal colored status filter pills (contratti) */
.filter-pills { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 22px; }
.filter-pill {
    border: 1px solid var(--color-border);
    color: var(--color-text-muted, #64748b);
    background: var(--color-surface, #fff);
    border-radius: 999px;
    padding: 7px 16px;
    font-size: 0.84rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.filter-pill:hover:not(.is-active) {
    background: var(--color-bg, #f1f5f9);
    color: var(--color-text);
    border-color: var(--color-border-strong, #cbd5e1);
}
/* One quiet accent for the selected filter — no rainbow of status colors. */
.filter-pill.is-active {
    background: var(--color-primary);
    color: #fff;
    border-color: var(--color-primary);
}

/* Uploaded contract files shown in the Contratti list read as attachments */
.contract-card--file { border-style: dashed; }

.view-cols-row { display: flex; justify-content: flex-end; margin: 4px 0 14px; }
.view-cols-toggle { display: inline-flex; gap: 2px; border: 1px solid var(--color-border); border-radius: 8px; overflow: hidden; }
.view-cols-btn {
    background: var(--color-surface);
    border: none;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-muted, #64748b);
}
.view-cols-btn:hover { background: var(--color-bg, #f1f5f9); }
.view-cols-btn.active { background: var(--color-primary, #2563eb); color: #fff; }

/* Property card: description preview (clamped to 2 lines) */
.entity-card__desc {
    margin: 8px 0 0;
    font-size: 0.82rem;
    color: var(--color-text-muted, #64748b);
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Column-count overrides for the properties grid (desktop) */
.properties-view .entity-grid.entity-grid--cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.properties-view .entity-grid.entity-grid--cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.properties-view .entity-grid.entity-grid--cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
@media (max-width: 1100px) {
    .properties-view .entity-grid.entity-grid--cols-4 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .properties-view .entity-grid.entity-grid--cols-3,
    .properties-view .entity-grid.entity-grid--cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 640px) {
    .properties-view .entity-grid[class*="entity-grid--cols-"] { grid-template-columns: 1fr; }
}

/* ── Social post modal (#13) ──────────────────────────────────────────────── */
.social-media-picker { display: flex; gap: 8px; flex-wrap: wrap; }
.social-thumb {
    width: 84px; height: 64px; border-radius: 8px; overflow: hidden;
    border: 2px solid var(--color-border); padding: 0; cursor: pointer; background: none;
}
.social-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.social-thumb.selected { border-color: var(--color-primary, #2563eb); box-shadow: 0 0 0 2px rgba(37,99,235,.25); }
.social-when { display: flex; gap: 18px; }
.social-when__opt { display: flex; align-items: center; gap: 6px; cursor: pointer; }

/* Property profile: social publish confirmation preview */
.pp-social-preview { display: flex; gap: 14px; align-items: flex-start; margin: 14px 0; }
.pp-social-preview__img {
    width: 170px; height: 128px; flex: 0 0 auto;
    border-radius: 8px; overflow: hidden;
    background: var(--color-bg, #f8fafc);
    display: flex; align-items: center; justify-content: center;
    position: relative;
}
.pp-social-preview__img img { width: 100%; height: 100%; object-fit: cover; }
.pp-social-count {
    position: absolute; bottom: 6px; right: 6px;
    background: rgba(0,0,0,.72); color: #fff;
    font-size: 0.72rem; font-weight: 600;
    padding: 2px 8px; border-radius: 10px;
}
.pp-social-success { text-align: center; padding: 26px 8px; }
.pp-social-success__icon { font-size: 48px; line-height: 1; }
.pp-social-success p { margin: 10px 0 0; font-weight: 600; font-size: 1.05rem; }
.pp-social-preview__noimg { font-size: 0.78rem; color: var(--color-text-muted, #64748b); text-align: center; padding: 8px; }
.pp-social-preview__caption {
    flex: 1; min-width: 0; margin: 0;
    white-space: pre-wrap; word-break: break-word;
    font-family: inherit; font-size: 0.86rem; line-height: 1.5;
    background: var(--color-bg, #f8fafc);
    border: 1px solid var(--color-border);
    border-radius: 8px; padding: 12px;
    max-height: 280px; overflow: auto;
}
@media (max-width: 640px) {
    .pp-social-preview { flex-direction: column; }
    .pp-social-preview__img { width: 100%; }
}

/* ==========================================================================
   UI polish layer — typography, depth, focus, hover (2026 refresh)
   Loaded last so it gently refines the shared components.
   ========================================================================== */

/* Lucide icons in the sidebar */
.nav-icon { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; flex: 0 0 auto; }
.nav-icon svg { width: 18px; height: 18px; stroke-width: 2; }
.logo-icon svg { width: 26px; height: 26px; }
.quick-action__icon svg { width: 22px; height: 22px; }
.ql-option__icon svg { width: 18px; height: 18px; vertical-align: -3px; }

/* Buttons — weight, smooth transitions, subtle hover lift, focus ring */
.btn {
    font-weight: 600;
    letter-spacing: .01em;
    transition: transform var(--transition), box-shadow var(--transition),
                background var(--transition), border-color var(--transition), color var(--transition);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary { box-shadow: 0 2px 6px rgba(32, 107, 172, .25); }
.btn--primary:hover { box-shadow: 0 5px 14px rgba(32, 107, 172, .32); }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
/* Inline icons inside buttons / tabs / section heads */
.btn { gap: 6px; }
.btn svg { width: 16px; height: 16px; flex: 0 0 auto; }
.btn--sm svg, .btn--xs svg { width: 15px; height: 15px; }

/* WhatsApp click-to-chat button (brand green) */
.btn-wa {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 8px;
    border: 1px solid transparent;
    background: #25D366;
    color: #fff;
    cursor: pointer;
    text-decoration: none;
    transition: background .15s ease, transform .12s ease, box-shadow .15s ease;
}
.btn-wa:hover { background: #1ebe5b; box-shadow: 0 2px 6px rgba(37,211,102,.35); }
.btn-wa:active { transform: scale(.95); }
.btn-wa svg { width: 17px; height: 17px; }
/* Labelled variant (auto-widens when there's text) */
.btn-wa--label { width: auto; padding: 0 12px; height: 34px; font-weight: 600; font-size: 0.85rem; }
.btn-wa--label span { line-height: 1; }
/* Full-width WhatsApp button (e.g. property "Condividi") */
.btn--whatsapp { background: #25D366; color: #fff; border-color: #25D366; }
.btn--whatsapp:hover { background: #1ebe5b; border-color: #1ebe5b; color: #fff; }
.btn--whatsapp svg { width: 16px; height: 16px; }
.profile-tab svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.pp-side-card__head h3 svg { width: 16px; height: 16px; vertical-align: -3px; margin-right: 4px; }
.ce-ico, .inline-ico { width: 15px; height: 15px; vertical-align: -3px; }

/* Cards & clickable surfaces */
.card, .entity-card {
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition), border-color var(--transition);
}
.entity-card--clickable { cursor: pointer; }
.entity-card--clickable:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
    border-color: var(--color-border-strong);
}

/* Form controls — consistent radius + a clear focus ring */
.form-input, .form-select, .form-textarea {
    border-radius: var(--radius-sm);
    transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-light);
}

/* Badges → pills */
.badge { border-radius: 999px; font-weight: 600; letter-spacing: .02em; }

/* Modals — softer, deeper, blurred backdrop */
.modal { border-radius: var(--radius); box-shadow: var(--shadow-lg); }
.modal-overlay { backdrop-filter: blur(2px); }

/* Tighter, more deliberate headings */
h1, h2, h3, h4 { letter-spacing: -0.01em; }

/* Dedicated Nuovo/Modifica pages — fill the page width like a real form
   (fields flow in a responsive grid instead of a narrow centered modal card). */
.entity-edit-view .form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: 16px;
    align-items: start;
}
.entity-edit-view .form-row .form-group { min-width: 0; }
.entity-edit-view .form-actions { border-top: 1px solid var(--color-border); padding-top: 16px; }
.entity-edit-view .card { max-width: none; }
