/* Gestionale AR Revenue — UI v3 "chiaro e minimale" */
:root {
    --bg: #fbfbfa;
    --surface: #ffffff;
    --sidebar: #f8f8f6;
    --line: #eaeae7;
    --line-soft: #f1f1ef;
    --ink: #1a1a18;
    --ink-2: #44443f;
    --muted: #8a8a83;
    --accent: #d97706;
    --accent-bright: #f59e0b;
    --accent-soft: #faf3e3;
    --ok: #15803d;
    --err: #b91c1c;
    --r-lg: 10px;
    --r-md: 8px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
::selection { background: #f5e3bd; color: var(--ink); }
* { scrollbar-width: thin; scrollbar-color: #d8d8d2 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #d8d8d2; border-radius: 4px; }
*::-webkit-scrollbar-track { background: transparent; }
body {
    margin: 0;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--ink);
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.006em;
}
a { color: var(--ink-2); text-decoration: none; }
a:hover { color: var(--accent); }
.ico { flex: none; vertical-align: -3px; }

.shell { display: flex; min-height: 100vh; }

/* ================= Sidebar ================= */
.sidebar {
    width: 240px;
    flex: 0 0 240px;
    background: var(--sidebar);
    border-right: 1px solid var(--line-soft);
    color: var(--ink-2);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 20px 18px 14px; }
.brand-logo {
    width: 32px; height: 32px; border-radius: 8px;
    background: var(--accent-bright);
    color: #241a05;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800; font-size: 12.5px; letter-spacing: .01em;
}
.brand-name { font-weight: 700; color: var(--ink); font-size: 14px; letter-spacing: -.01em; }
.brand-sub { font-size: 10.5px; color: var(--muted); letter-spacing: .09em; text-transform: uppercase; }

.sidebar nav { flex: 1; padding: 2px 10px 12px; overflow-y: auto; }
.nav-label {
    font-size: 10.5px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase;
    color: #b3b3ab; padding: 16px 10px 5px;
}
.sidebar nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px; margin: 1px 0;
    color: var(--ink-2); border-radius: 7px; font-size: 13.5px; font-weight: 450;
    transition: background .12s, color .12s;
}
.sidebar nav a .ico { color: #a3a39b; transition: color .12s; }
.sidebar nav a:hover { background: #f0f0ed; color: var(--ink); }
.sidebar nav a:hover .ico { color: var(--ink-2); }
.sidebar nav a.active { background: #eeeeea; color: var(--ink); font-weight: 600; box-shadow: inset 2px 0 0 var(--accent-bright); }
.sidebar nav a.active .ico { color: var(--accent); }
.nav-count {
    margin-left: auto; flex: none;
    background: #e9e9e5; color: #71716a;
    font-size: 10.5px; font-weight: 650; line-height: 1;
    padding: 3px 7px; border-radius: 999px;
    font-variant-numeric: tabular-nums;
}
.sidebar nav a.active .nav-count { background: var(--accent-soft); color: var(--accent); }
.nav-count-red { background: #f8e9e7; color: #a03830; }

.sidebar-foot {
    padding: 12px 14px; border-top: 1px solid var(--line-soft);
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.who { display: flex; align-items: center; gap: 9px; min-width: 0; }
.who-avatar {
    width: 30px; height: 30px; border-radius: 50%; flex: none;
    background: #ececea; color: var(--ink-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12.5px; font-weight: 700;
}
.who-txt { display: flex; flex-direction: column; min-width: 0; }
.who-name { color: var(--ink); font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who-role { font-size: 10.5px; color: var(--muted); }
.logout { color: var(--muted); display: flex; padding: 7px; border-radius: 7px; transition: color .12s, background .12s; }
.logout:hover { color: var(--err); background: #f5f0ef; }

/* ================= Main ================= */
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 16px;
    padding: 15px 36px;
    background: rgba(251, 251, 250, .85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--line-soft);
}
.topbar h1 { margin: 0; font-size: 16.5px; font-weight: 650; letter-spacing: -.014em; flex: none; }
.topbar-date { font-size: 12.5px; color: var(--muted); flex: none; white-space: nowrap; }

/* ricerca globale nella barra in alto */
.cerca {
    display: flex; align-items: center; gap: 8px;
    flex: 1; max-width: 420px; margin: 0 auto;
    background: var(--surface-2, #f2f1ec);
    border: 1px solid var(--line-soft); border-radius: 8px;
    padding: 0 10px; transition: border-color .12s, background .12s;
}
.cerca:focus-within { background: var(--surface, #fff); border-color: var(--accent-bright); }
.cerca .ico { color: #a3a39b; flex: none; }
.cerca input {
    flex: 1; min-width: 0; border: 0; background: none; outline: none;
    padding: 7px 0; font: inherit; font-size: 13px; color: var(--ink);
}
.cerca input::placeholder { color: #a8a8a0; }
.cerca input::-webkit-search-cancel-button { cursor: pointer; }

/* gruppi di menu richiudibili */
.nav-toggle {
    display: block; width: 100%; text-align: left;
    background: none; border: 0; font: inherit; cursor: pointer;
    position: relative; padding-right: 26px;
}
.nav-toggle::after {
    content: ''; position: absolute; right: 12px; top: 50%;
    width: 6px; height: 6px; border-right: 1.6px solid #c2c2ba; border-bottom: 1.6px solid #c2c2ba;
    transform: translateY(-1px) rotate(-135deg); transition: transform .15s;
}
.nav-gruppo.is-closed .nav-toggle::after { transform: translateY(-5px) rotate(45deg); }
.nav-toggle:hover { color: var(--ink-2); }
.nav-toggle .nav-count { margin-left: 6px; vertical-align: 1px; }
.nav-gruppo:not(.is-closed) .nav-toggle .nav-count { display: none; }
.nav-gruppo.is-closed .nav-voci { display: none; }
.content { padding: 26px 36px 56px; max-width: 1200px; }

.flash {
    display: flex; align-items: center; gap: 10px;
    margin: 16px 36px -8px; padding: 10px 14px;
    border-radius: var(--r-md); font-size: 13.5px; font-weight: 500;
    background: var(--surface); border: 1px solid var(--line);
}
.flash-ok  { color: var(--ok); border-left: 3px solid #4ade80; }
.flash-err { color: var(--err); border-left: 3px solid #f87171; }

/* ================= Cards / grid ================= */
.grid { display: grid; gap: 14px; }
.grid-kpi { grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); }
.grid-2 { grid-template-columns: 1fr 1fr; align-items: start; }
@media (max-width: 980px) { .grid-2 { grid-template-columns: 1fr; } }

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    padding: 20px 22px;
}
.card h2 { margin: 0 0 14px; font-size: 14px; font-weight: 650; letter-spacing: -.01em; }
.card + .card, .grid + .card, .card + .grid, details.reveal + .card { margin-top: 14px; }

/* KPI */
.kpi { display: flex; align-items: center; gap: 14px; padding: 18px 20px; }
.kpi-ico {
    width: 38px; height: 38px; border-radius: 9px; flex: none;
    display: flex; align-items: center; justify-content: center;
    background: #f4f4f1; color: #85857d;
    border: 1px solid var(--line-soft);
}
.kpi-ico-amber { background: var(--accent-soft); color: var(--accent); border-color: #f3e5c5; }
.kpi-ico-green { background: #ebf5ee; color: var(--ok); border-color: #d8ebdd; }
.kpi-ico-red   { background: #f9eeed; color: var(--err); border-color: #f0dbd9; }
.kpi-num { font-size: 24px; font-weight: 700; letter-spacing: -.025em; line-height: 1.1; font-variant-numeric: tabular-nums; }
.kpi-label { font-size: 12px; color: var(--muted); margin-top: 2px; }
.kpi-warn .kpi-num { color: var(--err); }

/* ================= Tables ================= */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th {
    text-align: left; font-size: 10.5px; font-weight: 600; text-transform: uppercase;
    letter-spacing: .06em; color: #a3a39b;
    padding: 6px 12px 8px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
td { padding: 11px 12px; border-bottom: 1px solid var(--line-soft); vertical-align: middle; }
tr:last-child td { border-bottom: none; }
tr { transition: background .1s; }
tr:hover td { background: #fafaf8; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tr.total td { font-weight: 650; background: #fbf8f1; border-top: 1px solid #efe6d2; }
tr.total:hover td { background: #fbf8f1; }
td b { font-weight: 600; }
td a { color: var(--ink); }
td a:hover { color: var(--accent); }

/* ================= Badges ================= */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 2px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 550; white-space: nowrap;
    letter-spacing: 0;
}
.badge::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge-amber { background: #faf3df; color: #8f5f0a; }
.badge-blue  { background: #eef1f6; color: #45608a; }
.badge-gray  { background: #f1f1ee; color: #71716a; }
.badge-red   { background: #f9ebe9; color: #a03830; }
.badge-green { background: #eaf4ed; color: #23663f; }

/* ================= Forms ================= */
form.stack { display: flex; flex-direction: column; gap: 13px; }
.frow { display: flex; gap: 13px; flex-wrap: wrap; }
.frow > label { flex: 1; min-width: 170px; }
label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; font-weight: 550; color: var(--ink-2); }
label.inline { flex-direction: row; align-items: center; gap: 8px; font-weight: 450; font-size: 13px; }
label .muted { font-weight: 400; font-size: 11.5px; color: #a3a39b; }
input[type=text], input[type=email], input[type=password], input[type=date],
input[type=number], input[type=file], select, textarea {
    padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-md);
    font: inherit; color: var(--ink); background: var(--surface); width: 100%;
    transition: border-color .12s, box-shadow .12s;
}
textarea { resize: vertical; line-height: 1.55; }
input:focus, select:focus, textarea:focus {
    outline: none; border-color: #dbb26a;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, .1);
}
::placeholder { color: #b5b5ad; }
select {
    appearance: none; -webkit-appearance: none;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='13' height='13' viewBox='0 0 24 24' fill='none' stroke='%238a8a83' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
    background-repeat: no-repeat; background-position: right 11px center;
    padding-right: 32px;
}

/* ================= Buttons ================= */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 8px 14px; border-radius: var(--r-md);
    border: 1px solid transparent; cursor: pointer; font: inherit;
    font-weight: 550; font-size: 13px; line-height: 1.4; letter-spacing: -.006em;
    background: #21211d; color: #fff;
    transition: background .12s, border-color .12s;
}
.btn:hover { background: #3a3a34; color: #fff; }
.btn:active { transform: translateY(.5px); }
.btn-amber { background: var(--accent-bright); color: #241a05; }
.btn-amber:hover { background: #e18f08; color: #241a05; }
.btn-ghost { background: var(--surface); border-color: var(--line); color: var(--ink-2); }
.btn-ghost:hover { background: #f6f6f4; border-color: #dbdbd6; color: var(--ink); }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-danger { background: var(--surface); border-color: #eddbd9; color: var(--err); }
.btn-danger:hover { background: #faf3f2; color: var(--err); }

details.reveal { margin-bottom: 14px; }
details.reveal > summary { cursor: pointer; list-style: none; display: inline-flex; }
details.reveal > summary::-webkit-details-marker { display: none; }
details.reveal > .card { margin-top: 12px; }

.muted { color: var(--muted); font-size: 12.5px; }
.actions { display: flex; gap: 7px; align-items: center; flex-wrap: wrap; }
.toolbar { display: flex; gap: 11px; align-items: end; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar label { min-width: 140px; }
.spacer { flex: 1; }
code { background: #f1f1ee; border-radius: 5px; padding: 1px 6px; font-size: 12.5px; }

/* ================= Scheda cliente ================= */
.client-hero { display: flex; flex-direction: column; gap: 18px; }
.client-id { display: flex; align-items: center; gap: 16px; }
.client-avatar {
    width: 54px; height: 54px; border-radius: 14px; flex: none;
    background: linear-gradient(135deg, #fbe9c8, #f5cd8a);
    color: #7a5410;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 700;
}
.client-head { min-width: 0; }
.client-name { font-size: 18px; font-weight: 700; letter-spacing: -.015em; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.client-meta { font-size: 13px; color: var(--ink-2); margin-top: 2px; }
.client-meta a { color: var(--ink-2); text-decoration: underline; text-decoration-color: #d5d5cf; text-underline-offset: 3px; }
.client-meta a:hover { color: var(--accent); }
.client-kpis {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 0; border-top: 1px solid var(--line-soft); padding-top: 14px;
}
.client-kpis > div { display: flex; flex-direction: column; gap: 2px; padding: 0 16px; border-left: 1px solid var(--line-soft); }
.client-kpis > div:first-child { border-left: none; padding-left: 0; }
.client-kpis b { font-size: 17px; font-weight: 700; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.client-kpis span { font-size: 11.5px; color: var(--muted); }
.client-kpis .kpi-red b { color: var(--err); }
details.reveal + details.reveal { margin-top: -6px; }

/* Schede (tab) della scheda cliente */
.tabs {
    display: flex; gap: 2px; align-items: center;
    border-bottom: 1px solid var(--line);
    margin: 18px 0; overflow-x: auto;
    scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
    display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 14px; font-size: 13.5px; font-weight: 550;
    color: var(--muted); white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    transition: color .12s, border-color .12s;
}
.tab .ico { color: #b3b3ab; }
.tab:hover { color: var(--ink); }
.tab.active { color: var(--ink); border-bottom-color: var(--accent-bright); }
.tab.active .ico { color: var(--accent); }
.tab .nav-count { margin-left: 0; }
.tab-pane { display: none; }
.tab-pane.active { display: block; animation: pane-in .16s ease; }
@keyframes pane-in { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* ================= Gruppi clienti / strutture ================= */
.group-clienti { margin-bottom: 10px; }
.group-head {
    cursor: pointer; list-style: none;
    display: flex; align-items: center; gap: 10px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-md); padding: 11px 15px;
    transition: border-color .12s;
}
.group-head:hover { border-color: #d5d5cf; }
.group-head::-webkit-details-marker { display: none; }
.group-head::before {
    content: ""; width: 7px; height: 7px; flex: none;
    border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted);
    transform: rotate(-45deg); transition: transform .14s; margin-right: 2px;
}
details[open] > .group-head::before { transform: rotate(45deg); }
.group-name { font-weight: 650; font-size: 13.5px; }
tr.group-row td {
    background: #f8f8f6; font-weight: 600; font-size: 11px;
    text-transform: uppercase; letter-spacing: .05em; color: #85857d;
    padding: 6px 12px;
}
tr.group-row:hover td { background: #f8f8f6; }
tr.group-row .ico { vertical-align: -2px; margin-right: 4px; }

/* ================= Ticket thread ================= */
.thread { display: flex; flex-direction: column; gap: 12px; }
.msg {
    max-width: 740px; border-radius: var(--r-md); padding: 13px 16px;
    border: 1px solid var(--line-soft); background: #fbfbf9;
}
.msg-team { border-left: 2px solid var(--accent-bright); }
.msg-cliente { border-left: 2px solid #7d97c0; }
.msg-head { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--muted); margin-bottom: 6px; }
.msg-head b { color: var(--ink); font-size: 12.5px; }
.msg-body { white-space: pre-wrap; font-size: 13.5px; }

/* ================= Calendario pagamenti ================= */
.paytable th a { color: inherit; }
.paytable th.th-now { color: var(--accent); }
.paytable td { padding: 6px 4px; }
.paycell {
    display: inline-flex; align-items: center; justify-content: center; gap: 1px;
    min-width: 56px; padding: 4px 7px; border-radius: 6px;
    font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
    white-space: nowrap; transition: filter .1s;
}
.paycell small { font-weight: 450; opacity: .6; font-size: 10px; }
a.paycell:hover { filter: brightness(.95); }
.cell-ok     { background: #e7f2ea; color: #23663f; }
.cell-part   { background: #f8f0d9; color: #8f5f0a; }
.cell-due    { background: #f8e9e7; color: #a03830; }
.cell-future { background: #f1f1ee; color: #85857d; }
.cell-empty  { background: transparent; color: #c9c9c2; }
.pay-legend { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; margin: 13px 0 0; font-size: 12px; }

/* ================= Agenda (calendario) ================= */
.cal-card { padding-bottom: 15px; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.cal-head { margin-bottom: 5px; }
.cal-head div {
    font-size: 10.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em;
    color: #a3a39b; padding: 3px 8px;
}
.cal-day {
    min-height: 100px; min-width: 0; background: var(--surface); border: 1px solid var(--line-soft);
    border-radius: var(--r-md); padding: 6px 7px;
    display: flex; flex-direction: column; gap: 4px;
}
.cal-we { background: #fafaf8; }
.cal-out { background: transparent; border-color: transparent; min-height: 0; }
.cal-today { border-color: #ecc57d; box-shadow: 0 0 0 1px #ecc57d; background: #fffdf7; }
.cal-num { display: flex; align-items: center; justify-content: space-between; }
.cal-num span { font-size: 12px; font-weight: 600; color: var(--ink-2); }
.cal-today .cal-num span {
    background: var(--accent-bright); color: #241a05;
    width: 21px; height: 21px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
}
.cal-add {
    color: #c9c9c2; font-weight: 600; font-size: 14px; line-height: 1;
    padding: 2px 6px; border-radius: 6px; opacity: 0; transition: opacity .1s;
}
.cal-day:hover .cal-add { opacity: 1; }
.cal-add:hover { background: var(--accent-soft); color: var(--accent); }
.chip {
    display: block; padding: 3px 8px; border-radius: 6px;
    font-size: 11px; font-weight: 550; line-height: 1.35;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    transition: filter .1s;
}
.chip small { font-weight: 450; opacity: .65; }
a.chip:hover { filter: brightness(.95); }
.chip-open  { background: #eef1f6; color: #45608a; }
.chip-today { background: #f8f0d9; color: #8f5f0a; }
.chip-late  { background: #f8e9e7; color: #a03830; }
.chip-done  { background: #e7f2ea; color: #23663f; text-decoration: line-through; }
.cal-backlog .chip { display: inline-block; }
.pay-legend .chip { display: inline-block; }
@media (max-width: 800px) {
    .cal-head { display: none; }
    .cal-grid { grid-template-columns: 1fr; }
    .cal-out { display: none; }
    .cal-day { min-height: 0; }
}

/* ================= Calendario disponibilità ================= */
.cal-card { padding: 16px 0 12px; }
.cal-scroll { overflow-x: auto; padding: 0 16px; }
.cal-timeline {
    display: grid;
    grid-template-columns: 190px repeat(var(--gg), minmax(26px, 1fr)) 74px;
    gap: 0;
    min-width: 900px;
    align-items: stretch;
}
.cal-h {
    position: sticky; top: 0; z-index: 3;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: 4px 0 6px;
    text-align: center;
    font-size: 10.5px;
}
.cal-h-nome, .cal-h-tot {
    text-transform: uppercase; letter-spacing: .06em; color: var(--muted);
    font-weight: 600; text-align: left; padding-left: 4px;
}
.cal-h-tot { text-align: right; padding-right: 4px; }
.cal-h-nome { position: sticky; left: 0; z-index: 4; }
.cal-h-g span { display: block; color: #b3b3ab; font-size: 9.5px; line-height: 1.2; }
.cal-h-g b { font-size: 11.5px; font-weight: 600; color: var(--ink-2); }
.cal-h-g.we { background: #faf9f6; }
.cal-h-g.oggi b { background: var(--accent-bright); color: #241a05; border-radius: 4px; padding: 0 4px; }

.cal-gruppo {
    padding: 12px 6px 5px; font-weight: 700; font-size: 13px;
    border-bottom: 1px solid var(--line-soft); position: sticky; left: 0;
}
.cal-gruppo a { color: var(--ink); }
.cal-sottogruppo {
    padding: 6px; font-size: 10.5px; text-transform: uppercase; letter-spacing: .05em;
    color: var(--muted); background: #f8f8f6; position: sticky; left: 0;
}
.cal-nome {
    position: sticky; left: 0; z-index: 2;
    background: var(--surface);
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line-soft);
    padding: 7px 8px 7px 4px; font-size: 12.5px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    grid-column: 1;
}
.cal-nome a { color: var(--ink); font-weight: 550; }
.cal-cella {
    border-right: 1px solid var(--line-soft);
    border-bottom: 1px solid var(--line-soft);
    min-height: 30px;
}
.cal-cella.we { background: #fafaf8; }
.cal-cella.oggi { background: #fffbf2; box-shadow: inset 1px 0 0 var(--accent-bright), inset -1px 0 0 var(--accent-bright); }
.cal-barra {
    z-index: 1;
    margin: 4px 1px; padding: 0 7px;
    border-radius: 5px; font-size: 11px; font-weight: 600;
    display: flex; align-items: center;
    overflow: hidden; white-space: nowrap;
    align-self: center; min-height: 22px;
    cursor: default;
}
.cal-barra span { overflow: hidden; text-overflow: ellipsis; }
.cal-barra.blocco { font-weight: 500; font-style: italic; }
.cal-barra.cont-sx { border-top-left-radius: 0; border-bottom-left-radius: 0; margin-left: 0; }
.cal-barra.cont-dx { border-top-right-radius: 0; border-bottom-right-radius: 0; margin-right: 0; }
.cal-tot {
    grid-column: -2 / -1;
    background: var(--surface);
    border-left: 1px solid var(--line);
    border-bottom: 1px solid var(--line-soft);
    padding: 5px 4px; text-align: right; line-height: 1.25;
}
.cal-tot b { font-size: 12.5px; font-variant-numeric: tabular-nums; }
.cal-tot span { display: block; font-size: 10.5px; }
.cal-legenda { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; padding: 14px 16px 0; font-size: 12px; }
.cal-chip { padding: 2px 9px; border-radius: 999px; font-size: 11px; font-weight: 600; }

/* ================= Posta ================= */
.mail-list td { padding: 9px 10px; }
.mail-unread td { background: #fdfcf8; }
.mail-unread a b { font-weight: 700; }
.mail-dot {
    display: inline-block; width: 7px; height: 7px; border-radius: 50%;
    background: var(--accent-bright);
}
.mail-body {
    white-space: pre-wrap; overflow-wrap: anywhere;
    background: #fbfbf9; border: 1px solid var(--line-soft); border-radius: var(--r-md);
    padding: 15px 17px; font-size: 13.5px; line-height: 1.6; max-width: 840px;
}

/* ================= Variazioni percentuali ================= */
.delta-up, .delta-down {
    font-size: 11.5px; font-weight: 600; font-variant-numeric: tabular-nums;
    padding: 1px 6px; border-radius: 5px; margin-left: 5px; white-space: nowrap;
}
.delta-up   { background: #e7f2ea; color: #23663f; }
.delta-down { background: #f8e9e7; color: #a03830; }
.kpi-label .delta-up, .kpi-label .delta-down { margin-left: 3px; }

/* ================= Grafici ================= */
.chart { width: 100%; height: auto; display: block; }
.chart-y { font-size: 10px; fill: #a3a39b; font-family: inherit; }
.chart-x { font-size: 10px; fill: #a3a39b; font-family: inherit; }
.chart rect { transition: opacity .12s; }
.chart rect:hover { opacity: .8; }
.chart-legend { display: flex; gap: 16px; margin-top: 10px; font-size: 12px; color: var(--ink-2); flex-wrap: wrap; }
.chart-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.hbars { display: flex; flex-direction: column; gap: 9px; }
.hbar-row { display: grid; grid-template-columns: 170px 1fr 110px; gap: 12px; align-items: center; }
.hbar-label { font-size: 13px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-track { background: #f1f1ee; border-radius: 6px; height: 16px; overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; transition: width .4s ease; }
.hbar-val { font-size: 12.5px; font-variant-numeric: tabular-nums; text-align: right; color: var(--ink-2); }
@media (max-width: 640px) { .hbar-row { grid-template-columns: 110px 1fr 90px; } }

:focus-visible { outline: 2px solid rgba(217, 119, 6, .5); outline-offset: 2px; border-radius: 4px; }

/* ================= Chat interna ================= */
.chat-card { padding: 0; display: flex; flex-direction: column; height: calc(100vh - 210px); min-height: 420px; }
.chat-scroll { flex: 1; overflow-y: auto; padding: 20px 22px; display: flex; flex-direction: column; gap: 10px; }
.chat-day { text-align: center; margin: 8px 0 2px; }
.chat-day span {
    font-size: 11px; font-weight: 600; color: var(--muted);
    background: #f1f1ee; border-radius: 999px; padding: 3px 12px;
}
.cmsg { display: flex; gap: 10px; max-width: 72%; align-items: flex-end; }
.cmsg.mine { align-self: flex-end; flex-direction: row-reverse; }
.cmsg-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex: none;
    background: #ececea; color: var(--ink-2);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 700;
}
.cmsg.mine .cmsg-avatar { background: #f5dfae; color: #7a5410; }
.cmsg-bubble {
    background: #f4f4f1; border-radius: 12px 12px 12px 4px;
    padding: 8px 12px; min-width: 0;
}
.cmsg.mine .cmsg-bubble { background: #faf1dc; border-radius: 12px 12px 4px 12px; }
.cmsg-head { font-size: 11px; color: var(--muted); margin-bottom: 2px; }
.cmsg-head b { color: var(--ink); font-size: 11.5px; }
.cmsg-body { font-size: 13.5px; overflow-wrap: anywhere; }
.chat-input {
    display: flex; gap: 10px; padding: 12px 14px;
    border-top: 1px solid var(--line-soft); background: #fdfdfc;
    border-radius: 0 0 var(--r-lg) var(--r-lg);
}
.chat-input input { flex: 1; }

/* ================= Login ================= */
.login-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background:
        radial-gradient(700px 420px at 75% -5%, rgba(245, 158, 11, .07), transparent 60%),
        radial-gradient(600px 420px at 10% 105%, rgba(69, 96, 138, .05), transparent 60%),
        #f6f6f4;
    padding: 24px; width: 100%;
}
.login-card {
    width: 100%; max-width: 384px; background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px; padding: 34px 32px;
    box-shadow: 0 12px 40px -18px rgba(26, 26, 24, .18);
}
.login-card .brand { padding: 0 0 8px; }
.login-card h1 { font-size: 19px; margin: 12px 0 4px; letter-spacing: -.015em; }
.login-card p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }
.login-card .brand-name { color: var(--ink); }
.login-card .brand-sub { color: var(--muted); }
.login-card .btn { padding: 10px; font-size: 13.5px; margin-top: 2px; }

/* ================= Responsive ================= */
@media (max-width: 800px) {
    .shell { flex-direction: column; }
    .sidebar {
        width: 100%; flex: none; height: auto;
        position: sticky; top: 0; z-index: 30;
        border-right: none; border-bottom: 1px solid var(--line);
    }
    .brand { padding: 10px 14px 6px; }
    .brand-logo { width: 26px; height: 26px; border-radius: 7px; font-size: 10.5px; }
    .brand-name { font-size: 13px; }
    .brand-sub { display: none; }
    .sidebar nav {
        display: flex; flex-wrap: nowrap; align-items: center; overflow-x: auto; gap: 3px;
        padding: 0 12px 9px; -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .sidebar nav::-webkit-scrollbar { display: none; }
    .sidebar nav a { white-space: nowrap; padding: 5px 11px; font-size: 12.5px; flex: none; }
    .nav-label { display: none; }
    /* su schermo stretto il menu è una barra sola: i gruppi si srotolano in linea */
    .nav-gruppo, .nav-voci, .nav-gruppo.is-closed .nav-voci { display: contents; }
    .nav-toggle { display: none; }
    .topbar { padding: 11px 18px; flex-wrap: wrap; }
    .cerca { order: 3; max-width: none; width: 100%; margin: 0; }
    .topbar-date { display: none; }
    .sidebar-foot { padding: 7px 14px; }
    .who-avatar { width: 24px; height: 24px; font-size: 11px; }
    .who-role { display: none; }
    .topbar { position: static; padding: 12px 16px; }
    .topbar h1 { font-size: 15.5px; }
    .content { padding: 16px 16px 40px; }
    .card { padding: 16px; }
    .flash { margin: 12px 16px -4px; }
    .topbar-date { display: none; }
    .frow { gap: 10px; }
}

/* riga con casella di spunta e spiegazione a fianco */
.riga-check {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--r-md);
    background: var(--surface-2, #f8f8f6); font-size: 13.5px; font-weight: 450;
}
.riga-check input[type="checkbox"] { margin: 3px 0 0; flex: none; width: 15px; height: 15px; accent-color: var(--accent); }
.riga-check .muted { font-weight: 400; }

/* ================= Scheda alloggio ================= */
.scheda-testa {
    display: grid; grid-template-columns: 260px 1fr; gap: 20px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-lg); padding: 18px; margin-bottom: 14px;
}
.scheda-foto {
    border-radius: var(--r-md); overflow: hidden; background: var(--surface-2, #f2f1ec);
    aspect-ratio: 4 / 3;
}
.scheda-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.scheda-foto.vuota {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px;
    color: #b3b3ab; font-size: 12.5px; border: 1px dashed var(--line);
}
.scheda-testo h2 { margin: 0 0 8px; font-size: 19px; font-weight: 680; letter-spacing: -.02em; }
.scheda-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.fatti { display: flex; flex-wrap: wrap; gap: 8px 16px; }
.fatto { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ink-2); }
.fatto .ico { color: #a3a39b; }

/* galleria */
.galleria { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.scatto { margin: 0; border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; background: var(--surface); position: relative; }
.scatto.copertina { border-color: var(--accent-bright); box-shadow: 0 0 0 1px var(--accent-bright); }
.scatto img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; }
.tag-copertina {
    position: absolute; top: 8px; left: 8px;
    background: var(--accent-bright); color: #241a05;
    font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
    padding: 3px 7px; border-radius: 5px;
}
.scatto figcaption { padding: 10px; display: flex; flex-direction: column; gap: 8px; }
.scatto-form { display: flex; flex-direction: column; gap: 6px; }
.scatto-form input, .scatto-form select { font-size: 12.5px; padding: 5px 8px; }

/* dotazioni */
.dotazioni { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; }
.dot-titolo {
    font-size: 10.5px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase;
    color: #b3b3ab; margin-bottom: 8px;
}
.dot-voce { display: flex; align-items: center; gap: 8px; padding: 4px 0; font-size: 13px; font-weight: 450; cursor: pointer; }
.dot-voce input { width: 15px; height: 15px; accent-color: var(--accent); flex: none; margin: 0; }

/* barra di salvataggio appiccicata in fondo */
.barra-salva {
    position: sticky; bottom: 0; z-index: 10;
    margin: 14px 0 0; padding: 12px 0;
    background: linear-gradient(to top, var(--bg) 62%, transparent);
}

/* griglia degli alloggi */
.griglia-alloggi { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.tessera {
    display: block; border: 1px solid var(--line); border-radius: var(--r-lg);
    overflow: hidden; background: var(--surface); color: var(--ink-2);
    transition: border-color .12s, box-shadow .12s;
}
.tessera:hover { border-color: #ddddd6; box-shadow: 0 2px 10px rgba(0,0,0,.04); color: var(--ink-2); }
.tessera-foto { aspect-ratio: 16 / 10; background: var(--surface-2, #f2f1ec); position: relative; }
.tessera-foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tessera-foto.vuota { display: flex; align-items: center; justify-content: center; color: #c9c9c1; }
.tessera-corpo { padding: 12px 14px 14px; }
.tessera-nome { font-weight: 620; color: var(--ink); font-size: 13.5px; line-height: 1.35; }
.tessera-sotto { font-size: 12px; color: var(--muted); margin-top: 3px; }
.tessera-piede { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.tessera-stat { display: flex; gap: 12px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line-soft); }
.tessera-stat div { font-size: 12px; color: var(--muted); }
.tessera-stat b { display: block; font-size: 14px; color: var(--ink); font-variant-numeric: tabular-nums; }

@media (max-width: 700px) {
    .scheda-testa { grid-template-columns: 1fr; }
    .scheda-foto { aspect-ratio: 16 / 9; }
}

/* colpo d'occhio della scheda alloggio */
.rapide { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 18px; }
.rapida { display: flex; flex-direction: column; gap: 1px; }
.rapida-et { font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase; color: #b3b3ab; }
.rapida-val { font-size: 13.5px; color: var(--ink); font-weight: 500; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 16px; }
.chip {
    display: inline-flex; align-items: center; gap: 5px;
    background: var(--surface-2, #f4f4f1); border: 1px solid var(--line-soft);
    border-radius: 999px; padding: 4px 10px; font-size: 12.5px; color: var(--ink-2);
}
.chip .ico { color: var(--ok); }
.blocco-testo { margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line-soft); }
.blocco-et {
    font-size: 10.5px; font-weight: 650; letter-spacing: .07em; text-transform: uppercase;
    color: #b3b3ab; display: flex; align-items: center; gap: 6px; margin-bottom: 6px;
}
.blocco-et .ico { color: #b3b3ab; }
.blocco-testo p { margin: 0; font-size: 13.5px; color: var(--ink-2); line-height: 1.6; }

/* ================= Gestione ospiti ================= */
/* percorso dell'ospite */
.passi { display: flex; flex-direction: column; gap: 2px; }
.passo { display: flex; align-items: center; gap: 11px; padding: 9px 0; border-bottom: 1px solid var(--line-soft); }
.passo:last-child { border-bottom: 0; }
.passo-segno {
    width: 24px; height: 24px; border-radius: 50%; flex: none;
    display: flex; align-items: center; justify-content: center;
    font-size: 11.5px; font-weight: 700;
    background: #eeeeea; color: #a3a39b; border: 1px solid var(--line);
}
.passo.fatto .passo-segno { background: #ebf5ee; color: var(--ok); border-color: #d8ebdd; }
.passo.bloccato .passo-segno { background: #f9eeed; color: var(--err); border-color: #f0dbd9; }
.passo-testo { display: flex; flex-direction: column; line-height: 1.35; }
.passo-testo b { font-size: 13.5px; font-weight: 600; }
.passo-testo .muted { font-size: 12.5px; }
.passo.fatto .passo-testo b { color: var(--ink); }

/* conversazione con l'ospite */
.conversazione { display: flex; flex-direction: column; gap: 10px; max-height: 520px; overflow-y: auto; }
.msg { max-width: 78%; padding: 9px 12px; border-radius: 12px; font-size: 13.5px; }
.msg-loro { align-self: flex-start; background: var(--surface-2, #f4f4f1); border: 1px solid var(--line-soft); }
.msg-noi { align-self: flex-end; background: var(--accent-soft); border: 1px solid #f3e5c5; }
.msg-testa { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 600; margin-bottom: 3px; }
.msg-testa .muted { font-weight: 400; }
.msg-corpo { line-height: 1.5; color: var(--ink-2); }

/* griglia dei turni */
.griglia-turni td, .griglia-turni th { text-align: center; }
.griglia-turni td:first-child, .griglia-turni th:first-child { text-align: left; }
.griglia-turni th.oggi, .griglia-turni td.oggi { background: var(--accent-soft); }
.cella-turno form { display: flex; justify-content: center; }
.segno {
    width: 30px; height: 30px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--line); background: var(--surface);
    display: flex; align-items: center; justify-content: center;
    color: var(--ok); transition: background .12s, border-color .12s;
}
.segno:hover { border-color: #ccccc4; background: #f6f6f3; }
.segno.acceso { background: #ebf5ee; border-color: #cfe6d6; }
.griglia-turni .scoperto { color: var(--err); }

/* la barra del calendario è cliccabile */
a.cal-barra:hover { filter: brightness(.95); }

/* numero del passo nella procedura di primo avvio */
.numero-passo {
    display: inline-flex; align-items: center; justify-content: center;
    width: 21px; height: 21px; border-radius: 50%; margin-right: 8px;
    background: #eeeeea; color: #8a8a83; border: 1px solid var(--line);
    font-size: 11px; font-weight: 700; vertical-align: -4px;
}
.numero-passo.fatto { background: #ebf5ee; color: var(--ok); border-color: #d8ebdd; }
