/* =====================================================================
   theme-orlandi.css — "immobiliare design" mockup design system
   The authoritative look for the admin app: flush dark-navy sidebar
   (DS port: icon-box + Playfair wordmark, royal-blue active pill),
   floating white topbar with the page title, accent-topped stat cards,
   azure primary. Loads AFTER style.css and branding.css.php so it wins
   the cascade.
   BUILD-STAMP: orlandi-shell-20260722 (sidebar DS block consolidated —
   was appended at EOF, which put it after the ≤768px media rules and
   broke the mobile margin reset)
   ===================================================================== */

:root {
    /* --- exact palette sampled from the mockups --- */
    --color-primary:        #3186d5;   /* azure accent (buttons, active nav) */
    --color-primary-dark:   #276fb4;
    --color-primary-light:  #e3eefb;
    --color-sidebar-bg:     #06224F;   /* dark navy sidebar (ported from React design) */
    --color-sidebar-hover:  rgba(255,255,255,0.1);
    --color-sidebar-active: #0B3D91;   /* royal-blue active pill */
    --color-bg:             #e9eef5;   /* soft blue-gray canvas */
    --color-surface:        #ffffff;
    --color-text:           #1f2a3a;
    --color-text-muted:     #6b7688;
    --color-border:         #e6ebf1;
    --color-border-strong:  #d5dde7;
    --color-success:        #16a34a;
    --color-warning:        #e08a1e;
    --color-danger:         #dc2626;
    --radius:               14px;
    --radius-sm:            10px;
    --shadow:               0 1px 2px rgba(30,42,58,.04), 0 1px 3px rgba(30,42,58,.05);
    --shadow-md:            0 8px 24px rgba(30,42,58,.07), 0 2px 6px rgba(30,42,58,.05);
    --sidebar-width:        240px;     /* React w-60 (design-system AppShell) */
    --shell-gap:            14px;      /* breathing room around the floating panels */
    /* --- Immobiliare Orlandi Design System (ui_kits/app/AppShell.jsx) --- */
    --font-brand: "Playfair Display", Georgia, "Times New Roman", serif;
    --ds-navy:  #06224F;   /* --color-sidebar in the design system */
    --ds-royal: #0B3D91;   /* --color-primary in the design system */
}

/* =====================================================================
   App shell — floating panels on the blue-gray canvas
   ===================================================================== */
body { background: var(--color-bg); }

/* --- Sidebar: flush full-height navy rail (DS AppShell port) ---
   Matches the React AppShell sidebar (fixed inset-y-0 left-0, no
   radius/gap/shadow). Deep-navy rail + royal-blue active pill,
   icon-box + Playfair wordmark lockup, 12px nav pills. */
.sidebar {
    background: var(--ds-navy);
    top: 0;
    left: 0;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
    overflow: hidden;
}
.main-wrapper { margin-left: var(--sidebar-width); }

/* Brand lockup — 40px icon box + stacked IMMOBILIARE / ORLANDI wordmark */
.sidebar-brand { padding: 20px 18px 12px; position: relative; }
.sb-brand {
    display: flex; flex-direction: row; align-items: center; justify-content: flex-start;
    gap: 12px; width: 100%; text-decoration: none; color: #fff; text-align: left; min-width: 0;
}
.sb-brand__logo { max-height: 54px; max-width: 82%; object-fit: contain; border-radius: 8px; }
.sb-brand__ico {
    width: 40px; height: 40px; color: #fff; margin: 0; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 12px; background: rgba(255, 255, 255, 0.1);
}
.sb-brand__ico svg, .sb-brand__ico [data-lucide] { width: 22px; height: 22px; }
.sb-brand__word {
    display: flex; flex-direction: column; min-width: 0;
    font-family: var(--font-brand); line-height: 1.05;
}
.sb-brand__eyebrow {
    font-size: 12px; font-weight: 600; letter-spacing: 0.12em; padding-left: 0;
    color: rgba(255, 255, 255, 0.7);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.sb-brand__name {
    font-family: var(--font-brand);
    font-size: 18px; font-weight: 800; letter-spacing: 0; line-height: 1.05; color: #fff;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}
.sidebar-brand .sidebar-close-btn { position: absolute; top: 10px; right: 10px; }

/* Profile card under the brand */
.sb-profile {
    display: flex; align-items: center; gap: 10px;
    margin: 8px 12px 6px; padding: 10px 12px;
    background: rgba(255, 255, 255, 0.055);
    border: 1px solid rgba(255, 255, 255, 0.07);
    border-radius: 13px; text-decoration: none;
    transition: background var(--transition, 0.18s ease);
}
a.sb-profile:hover { background: rgba(255, 255, 255, 0.1); }
.sb-profile__avatar {
    width: 40px; height: 40px; border-radius: 50%; flex-shrink: 0; /* DS 40px avatar */
    background: linear-gradient(135deg, #3186d5, #7c5cd0);
    color: #fff; font-weight: 700; font-size: 15px;
    display: flex; align-items: center; justify-content: center;
}
.sb-profile__meta { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; flex: 1; }
.sb-profile__meta b { color: #fff; font-size: 13.5px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sb-profile__meta small { color: rgba(255, 255, 255, 0.55); font-size: 11.5px; text-transform: capitalize; }
.sb-profile__chev { color: rgba(255, 255, 255, 0.4); flex-shrink: 0; }
.sb-profile__chev svg, .sb-profile__chev [data-lucide] { width: 16px; height: 16px; }

/* Nav — 12px pills with section labels (DS) */
.sidebar-nav { padding: 12px 12px 12px; }
.sidebar-nav ul { gap: 4px; }
.nav-link {
    border-radius: 12px; padding: 10px 12px; gap: 12px;
    font-size: 14px; font-weight: 500; color: rgba(255, 255, 255, 0.7);
}
.nav-link:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }
.nav-link.active {
    background: var(--ds-royal); color: #fff; font-weight: 500;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}
.nav-link .nav-icon, .nav-link [data-lucide] { width: 18px; height: 18px; color: rgba(255, 255, 255, 0.7); }
.nav-link:hover .nav-icon, .nav-link:hover [data-lucide],
.nav-link.active .nav-icon, .nav-link.active [data-lucide] { color: #fff; }

/* Nav item present in code but intentionally turned off (see config/roles.php DISABLED_VIEWS) */
.nav-link--disabled { cursor: not-allowed; opacity: 0.45; }
.nav-link--disabled:hover { background: none; color: rgba(255, 255, 255, 0.7); }
.nav-badge {
    margin-left: auto; font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.04em; color: rgba(255, 255, 255, 0.6); background: rgba(255, 255, 255, 0.12);
    border-radius: 999px; padding: 2px 7px; flex-shrink: 0;
}

/* Section labels */
details.nav-group > summary { padding: 14px 12px 6px; }
.nav-group-label {
    font-size: 10px; font-weight: 600; text-transform: uppercase;
    letter-spacing: 0.08em; color: rgba(255, 255, 255, 0.4);
}
details.nav-group > summary:hover .nav-group-label { color: rgba(255, 255, 255, 0.6); }
.nav-group-arrow { color: rgba(255, 255, 255, 0.3); }

/* Footer */
.sidebar-footer { border-top: 1px solid rgba(255, 255, 255, 0.1); }

/* --- Topbar: floating white card carrying the page title ---
   Single home for the whole selector (consolidated out of 01-base,
   05-ui-polish and 08-shell-dashboard — see assets/css/README.md §4). */
.topbar {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--color-surface);
    height: auto; min-height: 74px;
    margin: var(--shell-gap) var(--shell-gap) 4px calc(var(--shell-gap) / 2 + 4px);
    padding: 12px 18px;
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    /* Single source of truth for the topbar layer — was conflicting across era
       files (15 in 08-shell, 1150 in 01-base, 1200 in 03-clients mobile), and the
       stray 15 left its own dropdowns behind 1000-level content (.pp-subnav,
       and the sticky filter bar at 900). 1050 sits ABOVE that content but BELOW the detail rail
       (1060), the mobile sidebar overlay (1100), the media lightbox (1200) and
       modals (1400+). */
    z-index: 1050;
}
.topbar-title { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; margin-right: 6px; }
.topbar-title h1 {
    font-size: 21px; font-weight: 800; letter-spacing: -0.01em; color: var(--color-text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw;
}
.topbar-sub { font-size: 13px; color: var(--color-text-muted); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 34vw; }
@media (max-width: 1100px) { .topbar-sub { display: none; } .topbar-title h1 { font-size: 18px; } }

/* --- Breadcrumb bar: the path actually walked, + a Back that retraces it ---
   Sits between the topbar and the content. It is the ONLY way back in the app:
   the pages used to carry their own "Indietro" button as well, which put two
   back controls one above the other, and the in-page one always lied about
   where it went (a fixed parent, not the way you came). On a page with no path
   walked (a pasted link, a reload) app.js stands the section in for the missing
   step, so the bar still appears; on a top-level list it stays [hidden].

   The back arrow is deliberately quiet — a bordered, shadowed pill read as the
   page's primary action and drowned out the crumbs next to it, which are the
   part that actually says where you are. */
.crumbbar {
    display: flex; align-items: center; gap: 2px;
    margin: 6px var(--shell-gap) 0 calc(var(--shell-gap) / 2 + 4px);
    padding: 0 2px;
    min-width: 0;
}
.crumbbar[hidden] { display: none; }
/* Una pastiglia bianca appena accennata: senza nessuno sfondo la freccia
   spariva nel canvas e non si leggeva più come un bottone, ma un bordo o
   un'ombra a riposo la promuovevano ad azione principale della pagina. */
.crumbbar__back {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 28px; height: 28px; padding: 0;
    border: 0; border-radius: 999px;
    background: rgba(255, 255, 255, .55); color: var(--color-text-muted);
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease, box-shadow .15s ease;
}
.crumbbar__back:hover { background: var(--color-surface); color: var(--color-primary); box-shadow: var(--shadow); }
.crumbbar__back:active { background: var(--color-primary-light); box-shadow: none; }
.crumbbar__back:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
/* La classe sta sull'<i>, e createIcons() la ricopia sull'<svg> che lo sostituisce. */
.crumbbar__back [data-lucide], .crumbbar__back svg {
    width: 16px; height: 16px;
    transition: transform .15s ease;
}
/* Il bottone non porta più la scritta "Indietro": il verso è l'unica etichetta
   che gli resta, quindi al passaggio la freccia si muove dove porta. */
.crumbbar__back:hover svg { transform: translateX(-1px); }
/* Separatore fra la freccia e il percorso: dice che sono due cose diverse
   senza aggiungere un bordo intero. Sfumato alle estremità, così stacca senza
   tagliare la riga come farebbe un tratto pieno. */
.crumbbar__back + .crumbs::before {
    content: ""; flex: 0 0 auto;
    width: 1px; height: 18px; margin: 0 8px 0 6px;
    background: linear-gradient(to bottom,
        transparent, var(--color-border-strong) 30%,
        var(--color-border-strong) 70%, transparent);
}

/* Una riga sola, che scorre: un percorso lungo non deve far crescere la barra
   di tre righe su mobile né spingere la pagina in larghezza. */
.crumbs {
    display: flex; align-items: center; flex-wrap: nowrap; gap: 0;
    list-style: none; margin: 0; padding: 0;
    flex: 1 1 auto; min-width: 0; overflow-x: auto; scrollbar-width: none;
    font-size: 13px; line-height: 1.4;
}
.crumbs::-webkit-scrollbar { display: none; }
.crumb {
    display: inline-flex; align-items: center; flex: 0 0 auto;
    color: var(--color-text-muted); min-width: 0;
}
/* Il separatore è un segno, non un carattere da leggere: disegnato coi bordi
   sta esattamente a metà altezza, mentre uno "/" o un ">" di testo pendono
   sotto la linea di base e andrebbero riallineati a mano. */
.crumb + .crumb::before {
    content: ""; flex: 0 0 auto;
    width: 5px; height: 5px; margin: 0 7px;
    border: 1.5px solid var(--color-border-strong);
    border-left: 0; border-bottom: 0; border-radius: 1px;
    transform: rotate(45deg);
}
/* Il passo è sempre un elemento interno, mai il <li>: il separatore nasce sul
   <li> e finirebbe dentro la pastiglia del passo corrente. Sul <li>, che è un
   flex container, l'ellissi non verrebbe nemmeno disegnata. */
.crumb__step {
    display: block;
    padding: 4px 10px; border-radius: 999px; max-width: 32ch;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.crumb__link {
    border: 0; background: none;
    font: inherit; color: var(--color-text-muted); cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}
.crumb__link:hover { color: var(--color-primary); background: var(--color-primary-light); }
.crumb__link:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
/* La pagina corrente è un'etichetta, non un bersaglio: una pastiglia bianca sul
   canvas azzurrino, come le schede sotto, chiude visibilmente il percorso dove
   sei. Il padding recupera l'1px per lato del bordo, così sta alta esattamente
   quanto i passi cliccabili accanto. */
.crumb--current .crumb__step {
    font-weight: 600; color: var(--color-text);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    box-shadow: var(--shadow);
    padding: 3px 11px;
}
@media (max-width: 768px) {
    .crumbbar { margin: 6px 10px 0; }
}
@media (prefers-reduced-motion: reduce) {
    .crumbbar__back, .crumbbar__back svg, .crumb__link { transition: none; }
    .crumbbar__back:hover svg { transform: none; }
}

/* --app-content-pad-b mirrors the padding-bottom below. Sticky footers inside
   the scroller (the *_edit form action bars) resolve `bottom` against this
   padding edge, so they need to cancel it out to sit flush. Keep in sync. */
.app-content { --app-content-pad-b: 44px; padding: 10px 18px 44px calc(var(--shell-gap) / 2 + 4px); }

/* Mobile: the sidebar becomes a full-height overlay again, panels lose margins */
@media (max-width: 768px) {
    /* Off-canvas drawer: restore the elevation the top-level `box-shadow:
       none` (flush desktop rail) would otherwise strip from the overlay. */
    .sidebar { top: 0; left: 0; height: 100vh; border-radius: 0; box-shadow: var(--shadow-md); }
    .main-wrapper { margin-left: 0; }
    .topbar { margin: 10px 10px 4px; min-height: 60px; padding: 8px 12px; }
    .topbar-title h1 { max-width: 40vw; }
    .app-content { --app-content-pad-b: 40px; padding: 8px 10px 40px; }
}

/* =====================================================================
   Shared components
   ===================================================================== */

/* --- Stat cards: colored top accent + sparkline + delta pill --- */
.db-stat {
    position: relative;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px 20px 18px;
    overflow: hidden;
    box-shadow: var(--shadow);
}
.db-stat::before {
    content: "";
    position: absolute;
    inset: 0 0 auto 0;
    height: 4px;
    background: var(--accent, var(--color-primary));
}
.db-stats .db-stat:nth-child(1) { --accent: #3186d5; }
.db-stats .db-stat:nth-child(2) { --accent: #16a34a; }
.db-stats .db-stat:nth-child(3) { --accent: #7c5cd0; }
.db-stats .db-stat:nth-child(4) { --accent: #f0a83c; }
.db-stats .db-stat:nth-child(5) { --accent: #3186d5; }
.db-stats .db-stat:nth-child(6) { --accent: #16a34a; }

/* 3-up variant — list pages with three summary tiles (e.g. Provvigioni).
   Overrides the base repeat(4) from 08-shell-dashboard on wide screens;
   breakpoints mirror it. (agent_profile used this for a 2x3 of six KPIs; it is
   on eight tiles now and sits on the base repeat(4).) */
.db-stats--3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 1100px) { .db-stats--3 { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px)  { .db-stats--3 { grid-template-columns: 1fr; } }

/* Semantic accent overrides — a tile in a problem/urgent state recolours its
   stripe + chip so it reads at a glance, beating the positional :nth-child
   accent (matched specificity 0-3-0, placed later in source order). */
.db-stats .db-stat.db-stat--ok     { --accent: #16a34a; }
.db-stats .db-stat.db-stat--warn   { --accent: #e08a1e; }
.db-stats .db-stat.db-stat--danger { --accent: #dc2626; }

.db-stat__chip {
    position: absolute;
    top: 26px; right: 18px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%;
    background: color-mix(in srgb, var(--accent, var(--color-primary)) 13%, #fff);
    color: var(--accent, var(--color-primary));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent, var(--color-primary)) 22%, #fff);
    margin: 0;
}
.db-stat__chip svg, .db-stat__chip [data-lucide] { width: 20px; height: 20px; color: inherit; }
.db-stat__label { color: var(--color-text-muted); font-size: 13.5px; font-weight: 600; margin-bottom: 4px; }
.db-stat__value { font-size: 33px; font-weight: 800; letter-spacing: -.02em; color: var(--color-text); line-height: 1.1; }

/* sparkline slot (canvas painted by the view JS) */
.db-stat__spark { display: block; margin-top: 10px; width: 110px; height: 26px; }

/* delta pill (e.g. +8%, -3%) */
.db-delta {
    display: inline-flex; align-items: center; gap: 4px;
    margin-top: 10px; font-size: 12.5px; font-weight: 600;
    color: var(--color-text-muted);
}
.db-delta.up   { color: #16a34a; }
.db-delta.down { color: #dc2626; }
.db-delta.up::before, .db-delta.down::before {
    display: inline-block; padding: 2px 7px; border-radius: 999px; font-size: 11px;
}
.db-delta.up::before   { content: attr(data-pill); background: #e7f7ee; color: #16a34a; }
.db-delta.down::before { content: attr(data-pill); background: #fdecec; color: #dc2626; }
.db-delta.up::before:empty, .db-delta.down::before:empty { display: none; }

/* --- Dashboard: chart legend, appointments rail, recent-properties table --- */
.db-grid > * { min-width: 0; }  /* grid items must be allowed to shrink (ellipsis) */
.db-list .appt { padding-left: 0; padding-right: 0; }
.db-legend { display: flex; align-items: center; gap: 14px; }
.db-legend__item { display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--color-text-muted); font-weight: 600; }
.db-legend__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--color-primary); display: inline-block; }

.appt { display: flex; align-items: center; gap: 12px; padding: 13px 0; border-top: 1px solid #eef2f7; }
.appt:first-child { border-top: none; }
.appt__time { font-weight: 800; font-size: 13.5px; color: var(--color-text); width: 42px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.appt__bar { width: 4px; align-self: stretch; border-radius: 4px; background: var(--color-primary); flex-shrink: 0; min-height: 34px; }
.appt__bar[data-status="completed"] { background: #16a34a; }
.appt__bar[data-status="no_show"]   { background: #e08a1e; }
.appt__body { flex: 1; min-width: 0; }
.appt__body b { display: block; font-size: 13.5px; font-weight: 700; color: var(--color-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt__body span { display: block; font-size: 12px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appt .badge { flex-shrink: 0; }

.db-tablewrap { overflow-x: auto; }
.db-thumb {
    width: 44px; height: 44px; border-radius: 9px; overflow: hidden; position: relative;
    background: #e3eefb; color: #7ba7d4; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}
.db-thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.db-thumb [data-lucide], .db-thumb svg { width: 19px; height: 19px; }
.db-propcell { min-width: 0; }
.db-propcell b { display: block; font-weight: 600; }
.db-city { font-size: 12px; color: var(--color-text-muted); display: block; }
.db-permonth { font-size: 11px; color: var(--color-text-muted); font-weight: 500; margin-left: 2px; }
.chip--type { background: #e3eefb; color: #276fb4; text-transform: capitalize; }
.pill--violet { background: #f0e9fd; color: #7c3aed; }
.db-rowaction {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--color-primary-light); color: var(--color-primary);
}
.db-rowaction:hover { background: var(--color-primary); color: #fff; }
.db-rowaction [data-lucide], .db-rowaction svg { width: 16px; height: 16px; }

/* =====================================================================
   List pages — stat strip + list card + table (mockup anatomy)
   ===================================================================== */
/* The page title and one-line purpose description now live in the real topbar
   (#page-title / #topbar-sub — app.js reads this markup on every navigation and
   copies it up), so never render the source text here. When a view has no
   header actions either, the whole bar collapses instead of leaving an empty
   strip with just its border. */
.view-header .view-header__text { display: none; }
/* Scoped to the page-header pattern (always has .view-header__text) so the
   unrelated card sub-headers reusing the .view-header class (settings.html
   panels: bare <h3> + button, no .view-header__text) are never touched. */
.view-header:has(.view-header__text):not(:has(.view-header__actions)) { display: none; }
.view-header { justify-content: flex-end; align-items: center; }


.list-card { overflow: visible; }
.list-card > .db-card__head { padding: 18px 20px 4px; }
.list-card > .db-card__head h3 { font-size: 16.5px; font-weight: 800; }
.list-card .toolbar {
    margin: 0; border: none; box-shadow: none; background: transparent;
    padding: 10px 20px 12px; border-radius: 0;
}
.list-card .pagination-container { padding: 6px 20px 16px; margin: 0; }

.lt-wrap, .table-wrapper { overflow-x: auto; }
.lt, .data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.lt thead th, .data-table thead th {
    text-align: left; font-size: 11px; font-weight: 700; letter-spacing: 0.05em;
    text-transform: uppercase; color: var(--color-text-muted);
    padding: 10px 12px; border-bottom: 1px solid var(--color-border);
    background: #f7f9fc; white-space: nowrap;
}
.lt thead th:first-child, .data-table thead th:first-child { padding-left: 20px; }
.lt thead th:last-child, .data-table thead th:last-child { padding-right: 20px; }
.lt tbody td, .data-table tbody td { padding: 12px; border-bottom: 1px solid #eef2f7; vertical-align: middle; color: var(--color-text); }
.lt tbody td:first-child, .data-table tbody td:first-child { padding-left: 20px; }
.lt tbody td:last-child, .data-table tbody td:last-child { padding-right: 20px; }
.lt tbody tr:last-child td, .data-table tbody tr:last-child td { border-bottom: none; }
.lt tbody tr.lt-row { cursor: pointer; }
.lt tbody tr.lt-row, .data-table tbody tr { transition: background 0.12s; }
.lt tbody tr.lt-row:nth-child(even), .data-table tbody tr:nth-child(even) { background: #fafcfe; }
.lt tbody tr.lt-row:hover, .data-table tbody tr:hover { background: #f2f7fd; }
.lt .entity-loading, .lt .entity-empty, .lt .entity-error { text-align: center; padding: 26px 16px; color: var(--color-text-muted); }
.lt-check { width: 34px; }
.lt-actions-h { text-align: right; }

.lt-who { display: flex; align-items: center; gap: 11px; min-width: 0; }
.lt-who__txt { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.lt-who__txt b { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-who__txt small { font-size: 11.5px; color: var(--color-text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-av {
    width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 700; font-size: 12.5px;
}
.av-a0 { background: #2563eb; } .av-a1 { background: #0d9488; }
.av-a2 { background: #7c3aed; } .av-a3 { background: #d97706; }
.av-a4 { background: #16a34a; } .av-a5 { background: #db2777; }
.av-a6 { background: #0891b2; } .av-a7 { background: #e11d48; }

.lt-contacts { line-height: 1.35; }
.lt-contacts a { display: block; color: var(--color-text); text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.lt-contacts a:hover { color: var(--color-primary); }
.lt-contacts small { display: block; color: var(--color-text-muted); font-size: 12px; }
.lt-count {
    display: inline-flex; align-items: center; gap: 6px;
    background: #e3eefb; color: #276fb4; border-radius: 999px;
    padding: 4px 11px; font-weight: 700; font-size: 12.5px;
}
.lt-count svg, .lt-count [data-lucide] { width: 14px; height: 14px; }

/* Agente Ref. cell (proprietari.png): small avatar + agent name */
.lt-agent { display: flex; align-items: center; gap: 8px; min-width: 0; }
.lt-agent > span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.lt-agent--none { font-size: 13px; }
.lt-av--sm { width: 28px; height: 28px; font-size: 11px; }

.lt-actions { text-align: right; white-space: nowrap; }
.lt-actions .btn { padding: 6px 8px; }
.lt-actions .btn svg, .lt-actions .btn [data-lucide] { width: 15px; height: 15px; }

/* Row actions kebab menu (Invia messaggio / Archivia / Elimina) */
.lt-menu {
    position: fixed; z-index: 1300; /* above topbar (1150), below modals (1400) */
    min-width: 195px; padding: 6px;
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 10px; box-shadow: 0 12px 32px rgba(15, 23, 42, 0.16);
    display: flex; flex-direction: column;
}
.lt-menu__item {
    display: flex; align-items: center; gap: 9px; width: 100%;
    padding: 8px 10px; border: none; background: none; border-radius: 7px;
    font: inherit; font-size: 13.5px; font-weight: 600; color: var(--color-text);
    cursor: pointer; text-align: left; transition: background 0.12s;
}
.lt-menu__item:hover:not(:disabled) { background: #f2f7fd; }
.lt-menu__item:disabled { opacity: 0.45; cursor: not-allowed; }
.lt-menu__item svg, .lt-menu__item [data-lucide] { width: 15px; height: 15px; flex-shrink: 0; }
.lt-menu__item--danger { color: #dc2626; }
.lt-menu__item--danger:hover:not(:disabled) { background: #fdf0f0; }
.lt-menu__sep { height: 1px; background: var(--color-border); margin: 4px 6px; }
@media (max-width: 900px) { .lt-contacts, .lt thead th:nth-child(3) { display: none; } }

/* ── Modal Invia messaggio: sezione "Allega documenti" ─────────────────────
   Toggle circolari per categoria (D blu, F verde, C ambra, P viola) e chips
   degli allegati selezionati. */
.attach-filters { display: flex; gap: 8px; margin-bottom: 4px; }
.attach-toggle {
    width: 30px; height: 30px; border-radius: 50%;
    border: 2px solid #cbd5e1; background: none; color: #64748b;
    font: inherit; font-size: 12.5px; font-weight: 700; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
    transition: background 0.12s, border-color 0.12s, color 0.12s;
}
.attach-toggle.is-active { color: #fff; }
.attach-toggle--d.is-active { background: #2563eb; border-color: #2563eb; }
.attach-toggle--f.is-active { background: #16a34a; border-color: #16a34a; }
.attach-toggle--c.is-active { background: #d97706; border-color: #d97706; }
.attach-toggle--p.is-active { background: #7c3aed; border-color: #7c3aed; }
.attach-legend { margin: 0 0 10px; font-size: 12px; }
.attach-row { display: flex; gap: 8px; align-items: center; }
.attach-row .form-select { flex: 1; min-width: 0; }
.attach-chips-box { margin-top: 12px; }
.attach-chips-title {
    display: block; font-size: 12.5px; font-weight: 600;
    color: var(--color-text); margin-bottom: 6px;
}
.attach-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.attach-chip {
    display: inline-flex; align-items: center; gap: 6px; max-width: 100%;
    padding: 3px 6px 3px 4px; border: 1px solid var(--color-border);
    border-radius: 999px; background: var(--color-surface); font-size: 12.5px;
}
.attach-chip__dot {
    width: 18px; height: 18px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    color: #fff; font-size: 10px; font-weight: 700;
}
.attach-chip__dot--d { background: #2563eb; }
.attach-chip__dot--f { background: #16a34a; }
.attach-chip__dot--c { background: #d97706; }
.attach-chip__dot--p { background: #7c3aed; }
.attach-chip__name { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip__x {
    border: none; background: none; cursor: pointer; color: #94a3b8;
    font-size: 15px; line-height: 1; padding: 0 2px;
}
.attach-chip__x:hover { color: #dc2626; }
.attach-chip--flash { animation: attach-chip-flash 0.9s ease; }
@keyframes attach-chip-flash {
    0%, 60% { background: #fef3c7; border-color: #f59e0b; }
    100%    { background: var(--color-surface); border-color: var(--color-border); }
}

/* status pills row + card grids hosted inside a list card */
.filter-pills--inset { padding: 0 20px 12px; }
.entity-grid--inset { padding: 4px 20px 18px; }

/* Bare table wrappers (views not yet wrapped in a list-card) get the same
   white-card treatment so every table view reads like the mockups. */
.table-wrapper:not(.list-card .table-wrapper) {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

/* Entity cards — align with the mockup card language */
.entity-card { border-radius: var(--radius); box-shadow: var(--shadow); border: 1px solid var(--color-border); }
.entity-card--clickable:hover { box-shadow: var(--shadow-md); border-color: #cfe0f2; }

/* Property card: blue price + Scheda/Modifica CTA row (mockup) */
.prop-price { font-size: 18px; font-weight: 800; color: var(--color-primary); white-space: nowrap; letter-spacing: -0.01em; }
.prop-price small { font-size: 11.5px; font-weight: 600; color: var(--color-text-muted); margin-left: 2px; }
.entity-card__prop-header { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.prop-cta { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 16px 12px; }
.prop-cta .btn { justify-content: center; height: 36px; font-weight: 700; font-size: 13px; border-radius: 9px; }
.prop-cta .btn svg, .prop-cta .btn [data-lucide] { width: 15px; height: 15px; }
.prop-cta .btn-open-prop { background: #fff; border: 1.5px solid var(--color-primary); color: var(--color-primary); }
.prop-cta .btn-open-prop:hover { background: var(--color-primary-light); }
.prop-cta .btn-edit-prop { background: #eef2f7; border: 1px solid var(--color-border); color: var(--color-text); }
.prop-cta .btn-edit-prop:hover { background: #e2e9f2; }
.prop-cta .btn-open-prop:only-child { grid-column: 1 / -1; }

/* --- Right detail rail (proprietari.png) --- */
.detail-rail {
    position: fixed; top: var(--shell-gap, 14px); right: var(--shell-gap, 14px);
    bottom: var(--shell-gap, 14px); width: min(332px, 92vw);
    background: var(--color-surface); border: 1px solid var(--color-border);
    border-radius: 16px; box-shadow: 0 18px 44px rgba(15, 25, 40, 0.18);
    /* Above the sticky topbar (1050) so the rail's head (close ×, avatar)
       isn't buried under it, below the mobile sidebar overlay (1100). */
    z-index: 1060; overflow-y: auto; padding: 18px 18px 16px;
    display: flex; flex-direction: column; gap: 14px;
    animation: rail-in 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes rail-in { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }
.detail-rail__close {
    position: absolute; top: 10px; right: 12px;
    border: none; background: none; font-size: 22px; line-height: 1;
    color: var(--color-text-muted); cursor: pointer; padding: 4px 6px; border-radius: 8px;
}
.detail-rail__close:hover { background: #eef2f7; color: var(--color-text); }
.detail-rail__id { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px; padding-top: 6px; }
.detail-rail__avatar {
    width: 76px; height: 76px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff; font-weight: 800; font-size: 26px;
    background: var(--color-primary);
    box-shadow: 0 0 0 5px var(--color-primary-light);
}
.detail-rail__id h3 { font-size: 18px; font-weight: 800; letter-spacing: -0.01em; }
.detail-rail__chips { display: flex; gap: 6px; flex-wrap: wrap; justify-content: center; }
.detail-rail__sec h4 {
    font-size: 11.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--color-text-muted); margin-bottom: 7px;
}
.detail-rail__box {
    background: #f3f7fc; border-radius: 11px; padding: 11px 13px;
    font-size: 13px; line-height: 1.55; word-break: break-word;
}
.detail-rail__box a { color: var(--color-text); text-decoration: none; }
.detail-rail__box a:hover { color: var(--color-primary); }
.rail-doc {
    display: flex; align-items: center; gap: 9px; padding: 9px 11px;
    background: #f3f7fc; border-radius: 10px; margin-bottom: 7px;
    font-size: 13px; color: var(--color-primary); text-decoration: none; min-width: 0;
}
.rail-doc:hover { background: #e3eefb; }
.rail-doc svg, .rail-doc [data-lucide] { width: 16px; height: 16px; flex-shrink: 0; }
.rail-doc span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-prop {
    display: flex; align-items: center; gap: 10px; padding: 8px;
    border: 1px solid var(--color-border); border-radius: 11px; margin-bottom: 8px;
    cursor: pointer; transition: border-color 0.12s, box-shadow 0.12s; min-width: 0;
}
.rail-prop:hover { border-color: var(--color-primary); box-shadow: var(--shadow); }
.rail-prop__img {
    width: 46px; height: 46px; border-radius: 8px; flex-shrink: 0;
    background: #e3eefb center/cover no-repeat; color: #7ba7d4;
    display: flex; align-items: center; justify-content: center;
    overflow: hidden;
}
.rail-prop__img svg, .rail-prop__img [data-lucide] { width: 18px; height: 18px; }
/* La miniatura arriva come background-image (clients) o come <img> vero
   (buildings): senza queste misure l'<img> si disegna alla sua dimensione
   naturale e sfonda il riquadro da 46px, trascinando con se' tutta la barra. */
.rail-prop__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.rail-prop__txt { min-width: 0; flex: 1; line-height: 1.35; }
.rail-prop__txt b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rail-prop__txt span { font-size: 12.5px; font-weight: 800; color: var(--color-primary); }
.detail-rail__empty { font-size: 12.5px; }
.detail-rail__cta { margin-top: auto; justify-content: center; width: 100%; }
.lt tbody tr.lt-row.is-active,
.data-table tbody tr.is-active { background: #e9f2fc; box-shadow: inset 3px 0 0 var(--color-primary); }

/* Cards / panels */
.db-card, .card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.db-card__head h3 { font-weight: 700; letter-spacing: -.01em; }

/* Data tables: status pills */
.db-table th {
    font-size: 11px; letter-spacing: .04em; text-transform: uppercase;
    color: var(--color-text-muted); font-weight: 600;
}
/* ---------------------------------------------------------------------------
   Status pills — ONE shape + ONE semantic palette (fix #2).
   .badge is the canonical status pill; .status-pill, table pills and bare
   .pill/.chip share its shape. The ~75 domain badge--* variants (lead/invoice/
   appt/payment/…) already use this pastel family, so the core semantic classes
   below are the single source of truth and everything reads as one system.
   NOTE: interactive components with their own prefix (prop-chip, map-chip,
   filter-pill, compare-chip) are deliberately NOT covered here.
   --------------------------------------------------------------------------- */
.badge, .status-pill, .db-table .pill, .pill, .chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; line-height: 1.5;
    white-space: nowrap; vertical-align: middle;
}
/* neutral default for bare pills/chips with no colour variant (e.g. feature tags) */
.pill:not([class*="--"]), .chip:not([class*="--"]) { background: #eef2f7; color: var(--color-text-muted); }

/* Canonical semantic palette — the same colour means the same thing everywhere. */
.badge--success, .badge--ok,    .pill--green                { background: #dcfce7; color: #15803d; }
.badge--warning, .badge--warn,  .pill--amber                { background: #fef3c7; color: #b45309; }
.badge--danger,  .badge--error, .badge--overdue, .pill--red { background: #fee2e2; color: #b91c1c; }
.badge--info,    .pill--blue                                { background: #e3eefb; color: #276fb4; }
.badge--neutral, .badge--muted, .pill--gray, .pill--neutral { background: #e2e8f0; color: #475569; }

/* Primary button — azure */
.btn--primary, .settings-tab--active {
    background: var(--color-primary);
    border-color: var(--color-primary);
    box-shadow: 0 8px 18px rgba(49,134,213,.28);
}
.btn--primary:hover { background: var(--color-primary-dark); }

/* Topbar search — pill with soft ring like the mockup */
.global-search__input {
    border-radius: 999px;
    background: #f4f6f9;
    border: 1px solid var(--color-border);
}
.global-search__input:focus {
    background: #fff;
    box-shadow: 0 0 0 3px var(--color-primary-light);
    border-color: var(--color-primary);
}

/* =====================================================================
   Leads — Kanban pipeline board (matches "Leads — Pipeline Kanban" mockup)
   ===================================================================== */
.view-header__actions { display: flex; gap: 12px; align-items: center; }
.leads-viewtoggle { display: inline-flex; gap: 4px; background: #eef2f7; border: 1px solid var(--color-border); border-radius: 10px; padding: 3px; }
.leads-viewtoggle button { border: none; background: none; padding: 7px 10px; border-radius: 8px; cursor: pointer; color: var(--color-text-muted); display: flex; align-items: center; }
.leads-viewtoggle button.active { background: var(--color-primary); color: #fff; box-shadow: 0 4px 10px rgba(49,134,213,.28); }
.leads-viewtoggle button svg { width: 18px; height: 18px; }

/* All 6 pipeline stages share the width equally and shrink to fit, so no
   column (Convertito/Perso) is ever clipped on desktop. minmax(0,1fr) + the
   column's min-width:0 are both required to let the columns shrink. */
.kanban { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 14px; padding: 4px 2px 16px; align-items: start; }
.kanban__col { min-width: 0; background: #f4f7fb; border: 1px solid var(--color-border); border-radius: 14px; display: flex; flex-direction: column; min-height: 120px; }

/* Narrow screens: 6 columns would be unreadably thin, so fall back to a
   horizontal-scroll board with a clearly visible scrollbar. */
@media (max-width: 900px) {
    .kanban { display: flex; grid-template-columns: none; overflow-x: auto; overflow-y: hidden; scroll-snap-type: x proximity; scrollbar-width: thin; scrollbar-color: #c2ccda #e9eef5; }
    .kanban__col { flex: 0 0 240px; scroll-snap-align: start; }
    .kanban::-webkit-scrollbar { height: 10px; }
    .kanban::-webkit-scrollbar-track { background: #e9eef5; border-radius: 999px; }
    .kanban::-webkit-scrollbar-thumb { background: #c2ccda; border-radius: 999px; border: 2px solid #e9eef5; }
    .kanban::-webkit-scrollbar-thumb:hover { background: var(--color-primary); }
}
.kanban__head { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 14px; border-radius: 13px 13px 0 0; color: #fff; font-weight: 700; font-size: 14.5px; letter-spacing: .01em; position: relative; }
.kanban__count { position: absolute; right: 12px; background: rgba(255,255,255,.28); color: #fff; min-width: 22px; height: 22px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; padding: 0 6px; }
.kanban__body { padding: 12px; display: flex; flex-direction: column; gap: 12px; }
.kanban__empty { color: #9aa6b6; font-size: 13px; text-align: center; padding: 18px 6px; }

/* column accent colors — mapped to the real lead statuses */
.kanban__col--new        .kanban__head { background: #ec7a3c; }
.kanban__col--contacted  .kanban__head { background: #3186d5; }
.kanban__col--interested .kanban__head { background: #7c5cd0; }
.kanban__col--negotiating .kanban__head { background: #e0a020; }
.kanban__col--converted  .kanban__head { background: #16a34a; }
.kanban__col--lost       .kanban__head { background: #6b7688; }

.kcard { background: #fff; border: 1px solid var(--color-border); border-left: 4px solid var(--kc, var(--color-primary)); border-radius: 12px; padding: 14px; box-shadow: var(--shadow); cursor: pointer; transition: transform .12s, box-shadow .12s; }
.kcard:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.kanban__col--new        .kcard { --kc: #ec7a3c; }
.kanban__col--contacted  .kcard { --kc: #3186d5; }
.kanban__col--interested .kcard { --kc: #7c5cd0; }
.kanban__col--negotiating .kcard { --kc: #e0a020; }
.kanban__col--converted  .kcard { --kc: #16a34a; }
.kanban__col--lost       .kcard { --kc: #6b7688; }
.kcard__top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.kcard__name { font-weight: 700; color: #1f2a3a; font-size: 14.5px; line-height: 1.25; }
.kcard__interest { display: inline-flex; align-items: center; gap: 5px; margin-top: 6px; font-size: 12.5px; color: var(--color-text-muted); }
.kcard__interest svg { width: 14px; height: 14px; }
.kcard__budget { margin-top: 8px; font-weight: 700; color: #1f2a3a; font-size: 14px; }
.kcard__foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 12px; }
.kcard__avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--color-primary-light); color: var(--color-primary); display: inline-flex; align-items: center; justify-content: center; font-weight: 700; font-size: 12px; }
/* Agent + archive hug the right edge; the status pill keeps the left. */
.kcard__agent { font-size: 12px; color: #9aa6b6; margin-left: auto; }
.kcard__archive {
    display: inline-flex; align-items: center; justify-content: center;
    flex: 0 0 auto; width: 26px; height: 26px; padding: 0;
    border: 0; border-radius: 8px; background: transparent;
    color: #9aa6b6; cursor: pointer; transition: background .12s, color .12s;
}
.kcard__archive:hover { background: #f1f5f9; color: #b91c1c; }
.kcard__archive:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.kcard__archive svg { width: 15px; height: 15px; }

/* In-card status dropdown — styled as the stage pill it replaces */
.kcard__status {
    appearance: none; -webkit-appearance: none;
    border: 0; border-radius: 999px; cursor: pointer;
    font: 600 11.5px/1 Inter, sans-serif; padding: 5px 22px 5px 10px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='3'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 8px center;
    max-width: 100%;
}
.kcard__status--new         { background-color: #dbeafe; color: #1d4ed8; }
.kcard__status--contacted   { background-color: #fef3c7; color: #b45309; }
.kcard__status--interested  { background-color: #dcfce7; color: #15803d; }
.kcard__status--negotiating { background-color: #ede9fe; color: #6d28d9; }
.kcard__status--converted   { background-color: #ccfbf1; color: #0f766e; }
.kcard__status--lost        { background-color: #e2e8f0; color: #475569; }

/* Drag & drop feedback */
.kcard--dragging { opacity: .45; }
.kanban__col--over { outline: 2px dashed var(--color-primary); outline-offset: -2px; background: #eaf2fb; }

/* Bottom pipeline stats bar */
.leads-statsbar { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 18px; }
.leads-statsbar .stat { flex: 1 1 200px; background: #fff; border: 1px solid var(--color-border); border-radius: 12px; padding: 14px 18px; box-shadow: var(--shadow); }
.leads-statsbar .stat b { display: block; font-size: 20px; font-weight: 800; color: #1f2a3a; }
.leads-statsbar .stat span { font-size: 12.5px; color: var(--color-text-muted); }
.leads-statsbar .stat .bar { height: 6px; border-radius: 999px; background: #eef2f7; margin-top: 8px; overflow: hidden; }
.leads-statsbar .stat .bar i { display: block; height: 100%; background: var(--color-primary); border-radius: 999px; }

/* =====================================================================
   Mappa — split list + map layout (matches "Mappa Immobili" mockup)
   ===================================================================== */
.map-view .map-layout { display: grid; grid-template-columns: 360px 1fr; gap: 18px; align-items: stretch; height: calc(100vh - 210px); min-height: 460px; }
@media (max-width: 900px) { .map-view .map-layout { grid-template-columns: 1fr; height: auto; } }

.map-side { background: #fff; border: 1px solid var(--color-border); border-radius: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.map-side__head { display: flex; align-items: baseline; justify-content: space-between; padding: 16px 18px 6px; }
.map-side__head h3 { font-size: 18px; font-weight: 800; letter-spacing: -.01em; }
.map-side__count { font-size: 13px; color: var(--color-text-muted); font-weight: 600; }
.map-side__search { position: relative; padding: 8px 18px 4px; }
.map-side__search svg { position: absolute; left: 30px; top: 50%; transform: translateY(-50%); width: 17px; height: 17px; color: #8a95a6; }
.map-side__search input { width: 100%; padding: 10px 14px 10px 38px; border: 1px solid var(--color-border-strong); border-radius: 10px; font-size: 14px; }
.map-side__search input:focus { outline: none; border-color: var(--color-primary); box-shadow: 0 0 0 3px var(--color-primary-light); }

.map-filters { display: flex; flex-wrap: wrap; gap: 7px; padding: 10px 18px; }
.map-chip { border: 1px solid var(--color-border-strong); background: #fff; color: var(--color-text-muted); padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; cursor: pointer; transition: all .12s; }
.map-chip:hover { border-color: var(--color-primary); color: var(--color-primary); }
.map-chip.active { background: var(--color-primary); border-color: var(--color-primary); color: #fff; }
/* "Azzera filtri" chiude la riga delle etichette (map.js buildClearButton).
   Prende la forma della pastiglia per stare nella riga, e tiene i colori
   rossi di .btn-clear-filters che ha in tutte le altre pagine. `margin-left`
   e' gia' `auto` dalla regola condivisa: lo spinge a fine riga, anche quando
   le etichette vanno a capo e lui resta da solo sulla seconda. */
.map-filters .btn-clear-filters { padding: 6px 13px; border-radius: 999px; font-size: 12.5px; font-weight: 600; line-height: 1.15; height: auto; }

.map-list { flex: 1; overflow-y: auto; padding: 4px 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.map-list__empty { color: #9aa6b6; font-size: 13px; text-align: center; padding: 24px 6px; }
.map-card { display: flex; gap: 12px; padding: 10px; border: 1px solid var(--color-border); border-radius: 12px; cursor: pointer; transition: all .12s; background: #fff; }
.map-card:hover { border-color: var(--color-primary); box-shadow: var(--shadow-md); }
.map-card:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 1px; }
.map-card--nogeo { opacity: .6; }
.map-card__img { width: 64px; height: 64px; border-radius: 9px; background-size: cover; background-position: center; flex-shrink: 0; background-color: #eef2f7; }
.map-card__img--empty { display: flex; align-items: center; justify-content: center; color: #b3bdca; }
.map-card__img--empty svg { width: 22px; height: 22px; }
.map-card__body { min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: 4px; }
.map-card__addr { font-weight: 700; font-size: 14px; color: #1f2a3a; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.map-card__meta { display: flex; align-items: center; gap: 12px; }
.map-card__price { font-weight: 700; color: var(--color-primary); font-size: 13.5px; }
.map-card__status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--color-text-muted); }

.map-canvas { position: relative; border-radius: 14px; overflow: hidden; border: 1px solid var(--color-border); box-shadow: var(--shadow); }
.map-canvas .leaflet-map, .map-view .leaflet-map { height: 100%; min-height: 460px; }
/* La legenda sta a destra: l'angolo in alto a sinistra è dello zoom di Leaflet,
   e sovrapposta gli copriva il pulsante "+". pointer-events:none così la mappa
   si trascina anche passando sotto la legenda. */
.map-canvas .map-legend { position: absolute; top: 14px; right: 14px; z-index: 500; max-width: calc(100% - 28px); pointer-events: none; background: rgba(255,255,255,.94); backdrop-filter: blur(4px); border: 1px solid var(--color-border); border-radius: 10px; padding: 8px 12px; display: flex; gap: 14px; box-shadow: var(--shadow); font-size: 12.5px; }
.map-canvas .map-legend span { display: inline-flex; align-items: center; gap: 6px; }
.map-canvas .map-legend .map-dot { margin: 0; flex-shrink: 0; }
/* Su schermo stretto la tela si restringe e la legenda tornerebbe comunque
   addosso allo zoom: scende in basso, dove non c'è nessun comando. */
@media (max-width: 900px) {
    .map-canvas .map-legend { top: auto; bottom: 14px; left: 14px; right: auto; font-size: 11.5px; gap: 10px; padding: 6px 10px; }
}
.map-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.map-dot--available { background: #16a34a; }
.map-dot--rented { background: #2563eb; }
.map-dot--sold { background: #7c3aed; }
.map-pin-icon { background: none; border: none; filter: drop-shadow(0 3px 4px rgba(0,0,0,.25)); }

/* Map popup card */
.map-popup-wrap .leaflet-popup-content-wrapper { border-radius: 14px; padding: 0; overflow: hidden; box-shadow: var(--shadow-lg); }
.map-popup-wrap .leaflet-popup-content { margin: 0; width: 230px !important; }
.map-popup__img { height: 120px; background-size: cover; background-position: center; background-color: #eef2f7; }
.map-popup__body { padding: 12px 14px 14px; }
.map-popup__body strong { font-size: 14.5px; color: #1f2a3a; }
.map-popup__city { color: var(--color-text-muted); font-size: 12.5px; margin: 2px 0 8px; }
.map-popup__row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.map-popup__price { font-weight: 800; color: #1f2a3a; font-size: 15px; }
.map-popup__actions { display: flex; flex-direction: column; gap: 6px; }

/* --- Mappa: area visibile, selezione tappe, cluster ---------------------- */

.map-side__opts { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 0 18px 8px; }
.map-side__toggle { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 600; color: var(--color-text-muted); cursor: pointer; user-select: none; }
.map-side__toggle input { accent-color: var(--color-primary); width: 15px; height: 15px; cursor: pointer; }
.map-side__opts .btn { flex-shrink: 0; }

.map-card { position: relative; }
.map-card__check { align-self: center; accent-color: var(--color-primary); width: 17px; height: 17px; cursor: pointer; flex-shrink: 0; }
.map-card--selected { border-color: var(--color-primary); background: var(--color-primary-light, #eef4ff); }

.map-selection { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-top: 1px solid var(--color-border); background: #fbfcfe; }
.map-selection[hidden] { display: none; }
.map-selection > span { font-size: 13px; font-weight: 700; color: #1f2a3a; margin-right: auto; }

.map-pin-icon--selected { filter: drop-shadow(0 0 0 2px var(--color-primary)) drop-shadow(0 3px 6px rgba(0,0,0,.35)); transform: scale(1.12); }

/* Icone cluster proprietarie — MarkerCluster.Default.css non viene caricato. */
.map-cluster { background: none; border: none; }
.map-cluster span {
    display: flex; align-items: center; justify-content: center;
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--color-primary); color: #fff;
    font-weight: 800; font-size: 13.5px;
    border: 3px solid rgba(255,255,255,.9);
    box-shadow: 0 3px 8px rgba(0,0,0,.3);
}
.map-cluster--md span { width: 46px; height: 46px; font-size: 14.5px; }
.map-cluster--lg span { width: 54px; height: 54px; font-size: 16px; }
/* Gruppo che contiene tappe selezionate: badge col numero di tappe dentro. */
.map-cluster span { position: relative; }
.map-cluster--sel span { border-color: #f59e0b; box-shadow: 0 0 0 3px rgba(245,158,11,.45), 0 3px 8px rgba(0,0,0,.3); }
.map-cluster span i {
    position: absolute; top: -6px; right: -6px;
    min-width: 19px; height: 19px; padding: 0 4px;
    border-radius: 999px; background: #f59e0b; color: #fff;
    font-style: normal; font-size: 11px; font-weight: 800; line-height: 19px;
    text-align: center; border: 2px solid #fff;
}

/* --- Pianificatore itinerario ------------------------------------------- */

.route-modal .modal { max-width: 720px; width: 100%; }
.route-sub { margin-bottom: 14px; font-size: 13px; }

.route-controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: flex-end; padding-bottom: 14px; border-bottom: 1px solid var(--color-border); margin-bottom: 14px; }
.route-field { display: flex; flex-direction: column; gap: 5px; flex: 1 1 200px; }
.route-field > span { font-size: 12px; font-weight: 700; color: var(--color-text-muted); }
.route-check { display: inline-flex; align-items: center; gap: 7px; font-size: 13px; font-weight: 600; color: var(--color-text-muted); cursor: pointer; padding-bottom: 9px; }
.route-check input { accent-color: var(--color-primary); width: 16px; height: 16px; cursor: pointer; }

.route-stops__head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 8px; font-size: 13.5px; }
.route-stop { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border: 1px solid var(--color-border); border-radius: 10px; margin-bottom: 7px; cursor: pointer; }
.route-stop:hover { border-color: var(--color-primary); }
.route-stop input { accent-color: var(--color-primary); width: 16px; height: 16px; cursor: pointer; flex-shrink: 0; }
.route-stop--nogeo { opacity: .55; cursor: not-allowed; }
.route-stop__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.route-stop__label { font-weight: 700; font-size: 13.5px; color: #1f2a3a; }
.route-stop__sub { font-size: 12px; color: var(--color-text-muted); }
.route-stop__flag { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; color: #9aa6b6; border: 1px solid var(--color-border); border-radius: 999px; padding: 2px 8px; white-space: nowrap; }

.route-result:empty { display: none; }
.route-summary { display: flex; gap: 10px; margin: 16px 0 12px; }
.route-summary > div { flex: 1; background: #f6f8fb; border-radius: 11px; padding: 11px 13px; display: flex; flex-direction: column; gap: 2px; }
.route-summary strong { font-size: 19px; font-weight: 800; color: #1f2a3a; letter-spacing: -.01em; }
.route-summary span { font-size: 11.5px; color: var(--color-text-muted); }
.route-note { font-size: 12.5px; color: var(--color-text-muted); margin-bottom: 10px; }
.route-warn { background: #fff6e6; border: 1px solid #f2d49b; color: #8a5b00; border-radius: 9px; padding: 8px 12px; font-size: 12.5px; margin-bottom: 8px; }

.route-legs { list-style: none; margin: 4px 0 0; padding: 0; }
.route-leg { display: flex; gap: 12px; align-items: flex-start; padding: 11px 0; border-bottom: 1px solid var(--color-border); }
.route-leg:last-child { border-bottom: none; }
.route-leg__num { flex-shrink: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--color-primary); color: #fff; display: flex; align-items: center; justify-content: center; font-size: 12.5px; font-weight: 800; }
.route-leg--start .route-leg__num { background: #64748b; }
.route-leg--start .route-leg__num svg { width: 14px; height: 14px; }
.route-leg__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.route-leg__body strong { font-size: 13.5px; color: #1f2a3a; }
.route-leg__body .text-muted { font-size: 12px; }
.route-leg__travel { font-size: 12px; color: var(--color-text-muted); margin-top: 3px; }
.route-leg__time { font-size: 13px; font-weight: 800; color: #1f2a3a; flex-shrink: 0; }
.route-leg--conflict .route-leg__num { background: #dc2626; }
.route-leg__conflict { font-size: 12px; font-weight: 600; color: #b91c1c; margin-top: 3px; }

.route-empty { color: #9aa6b6; font-size: 13px; text-align: center; padding: 20px 6px; }
.route-disclaimer { font-size: 11.5px; color: #9aa6b6; margin-top: 12px; line-height: 1.5; }
.route-status { margin-right: auto; font-size: 12.5px; color: var(--color-text-muted); }
.route-status--warn { color: #b45309; font-weight: 600; }

@media (max-width: 620px) {
    .route-summary { flex-direction: column; }
    .route-controls { flex-direction: column; align-items: stretch; }
}

