/* ==========================================================================
   LashManager – foglio di stile unico (mobile-first)
   Indice:
   1. Token (colori, raggi, ombre)   6. Liste e righe
   2. Base                           7. Calendario
   3. Struttura (sidebar, barre)     8. Pagine di accesso
   4. Componenti (card, bottoni…)    9. Utility
   5. Form                          10. Breakpoint desktop
   I colori dello studio arrivano dal layout come --primary, --primary-strong
   e --primary-soft (vedi Company::PALETTES).
   ========================================================================== */

/* 1. Token ---------------------------------------------------------------- */
:root {
    --primary: #b0607c;
    --primary-strong: #8a4560;
    --primary-soft: #f9eef2;
    --primary-ink: var(--primary-strong); /* testi in colore (link, titoletti) */

    --bg: #faf7f5;
    --surface: #ffffff;
    --surface-2: #f6f1ed;
    --line: #ece4de;
    --line-strong: #ddd2ca;
    --line-faint: #f4eee9;
    --surface-muted: #fcfaf9;
    --text: #2b2320;
    --muted: #7b6d67;
    --faint: #a89a93;

    --success: #2f7a57;
    --success-soft: #e7f4ed;
    --danger: #b4464b;
    --danger-soft: #fbeced;
    --warning: #9a6216;
    --warning-soft: #fdf2df;
    --info: #3a5f86;
    --info-soft: #e9f0f8;

    --radius-sm: 10px;
    --radius: 14px;
    --radius-lg: 20px;
    --shadow-sm: 0 1px 2px rgba(43, 35, 32, .05);
    --shadow: 0 1px 2px rgba(43, 35, 32, .04), 0 8px 24px rgba(43, 35, 32, .06);
    --shadow-lg: 0 18px 50px rgba(43, 35, 32, .14);

    --tabbar-h: 68px;
    --hour: 64px;
    --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 2. Base ----------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
    margin: 0;
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4, p { margin: 0; }
h1 { font-size: 1.5rem; line-height: 1.2; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.1rem; line-height: 1.3; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
a { color: inherit; text-decoration: none; }
a.link { color: var(--primary-ink); font-weight: 600; }
a.link:hover { text-decoration: underline; }
img, svg { display: block; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; border-radius: 6px; }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-sm { width: 16px; height: 16px; }

/* 3. Struttura ------------------------------------------------------------ */
.shell { min-height: 100vh; }
.sidebar { display: none; }
.main { min-width: 0; }
.page {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px 16px calc(var(--tabbar-h) + 32px + env(safe-area-inset-bottom));
    display: grid;
    gap: 16px;
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    padding-top: calc(10px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid var(--line);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar-title strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-title span { display: block; font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.brand-mark {
    width: 36px; height: 36px; flex: none;
    display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(140deg, var(--primary), var(--primary-strong));
    color: #fff;
    font-weight: 750;
    font-size: .95rem;
    letter-spacing: -.02em;
}

.tabbar {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    align-items: center;
    height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
    padding: 6px 6px env(safe-area-inset-bottom);
    background: color-mix(in srgb, var(--surface) 94%, transparent);
    backdrop-filter: saturate(1.4) blur(16px);
    -webkit-backdrop-filter: saturate(1.4) blur(16px);
    border-top: 1px solid var(--line);
}
.tab-link {
    display: grid;
    justify-items: center;
    gap: 2px;
    padding: 6px 2px;
    font-size: .7rem;
    font-weight: 600;
    color: var(--faint);
    border-radius: 12px;
}
.tab-link .icon { width: 22px; height: 22px; }
.tab-link.is-active { color: var(--primary-ink); }
.tab-fab {
    justify-self: center;
    width: 52px; height: 52px;
    display: grid; place-items: center;
    border-radius: 18px;
    background: linear-gradient(140deg, var(--primary), var(--primary-strong));
    color: #fff;
    box-shadow: 0 8px 20px color-mix(in srgb, var(--primary) 40%, transparent);
    transform: translateY(-10px);
}
.tab-fab .icon { width: 26px; height: 26px; stroke-width: 2.2; }

.acting-banner {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 12px;
    padding: 10px 16px;
    background: var(--warning-soft);
    color: var(--warning);
    font-size: .88rem;
    border-bottom: 1px solid color-mix(in srgb, var(--warning) 25%, transparent);
}
.acting-banner form { margin: 0; }

/* 4. Componenti ----------------------------------------------------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 16px;
    min-width: 0;
}
.card-flush { padding: 0; overflow: hidden; }
.card-header {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    margin-bottom: 12px;
}
.card-flush .card-header { padding: 14px 16px 0; }
.card-header h2 { font-size: 1rem; }
.card-sub { color: var(--muted); font-size: .85rem; margin-top: 2px; }

.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px; }
.page-header .eyebrow { margin-bottom: 4px; }
.page-header p { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.eyebrow { font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--primary-ink); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    min-height: 44px;
    padding: 0 16px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    font-size: .92rem;
    line-height: 1;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, transform .05s;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--primary-strong); border-color: var(--primary-ink); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary-strong) 88%, #000); }
.btn-soft { background: var(--primary-soft); border-color: transparent; color: var(--primary-ink); }
.btn-soft:hover { background: color-mix(in srgb, var(--primary-soft) 80%, var(--primary)); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-danger { background: var(--surface); border-color: color-mix(in srgb, var(--danger) 30%, transparent); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); }
.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-whatsapp { background: #1f9d55; border-color: #1f9d55; color: #fff; }
.btn-whatsapp:hover { background: #198a4a; }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: .85rem; border-radius: 10px; }
.btn-icon { width: 44px; padding: 0; }
.btn-icon.btn-sm { width: 36px; }
.btn-block { width: 100%; }

.badge {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: .74rem;
    font-weight: 650;
    background: var(--surface-2);
    color: var(--muted);
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }
.badge-warning { background: var(--warning-soft); color: var(--warning); }
.badge-info { background: var(--info-soft); color: var(--info); }
.badge-primary { background: var(--primary-soft); color: var(--primary-ink); }
.badge-neutral { background: var(--surface-2); color: var(--muted); }

.alert {
    display: flex; gap: 10px; align-items: flex-start;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: .92rem;
    border: 1px solid transparent;
}
.alert .icon { margin-top: 1px; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: color-mix(in srgb, var(--success) 22%, transparent); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: color-mix(in srgb, var(--warning) 22%, transparent); }
.alert-danger { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 22%, transparent); }
.alert-info { background: var(--info-soft); color: var(--info); border-color: color-mix(in srgb, var(--info) 22%, transparent); }

.kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.kpi {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 12px 14px;
    min-width: 0;
}
.kpi-label { font-size: .78rem; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 1.45rem; font-weight: 750; letter-spacing: -.02em; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.kpi-hint { font-size: .75rem; color: var(--faint); }

.empty {
    display: grid; justify-items: center; gap: 8px;
    text-align: center;
    padding: 28px 16px;
    color: var(--muted);
}
.empty .icon { width: 32px; height: 32px; color: var(--faint); }
.empty strong { color: var(--text); }

.segmented {
    display: inline-grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    padding: 3px;
    border-radius: 12px;
    background: var(--surface-2);
    border: 1px solid var(--line);
}
.segmented a {
    padding: 7px 14px;
    border-radius: 9px;
    font-size: .85rem;
    font-weight: 600;
    color: var(--muted);
    text-align: center;
}
.segmented a.is-active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

.avatar {
    width: 40px; height: 40px; flex: none;
    display: grid; place-items: center;
    border-radius: 50%;
    background: var(--primary-soft);
    color: var(--primary-ink);
    font-weight: 700;
    font-size: .85rem;
}
.avatar-lg { width: 64px; height: 64px; font-size: 1.3rem; }

.color-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; background: var(--dot, var(--line-strong)); box-shadow: inset 0 0 0 1px rgba(0,0,0,.06); }

.bar-track { height: 8px; border-radius: 999px; background: var(--surface-2); overflow: hidden; }
.bar-fill { height: 100%; border-radius: inherit; background: var(--primary); }

.chart-bars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; align-items: end; height: 160px; }
.chart-bar { display: grid; gap: 6px; align-items: end; height: 100%; grid-template-rows: 1fr auto auto; text-align: center; }
.chart-bar-col { align-self: end; border-radius: 8px 8px 4px 4px; background: var(--primary-soft); min-height: 4px; }
.chart-bar.is-current .chart-bar-col { background: var(--primary); }
.chart-bar small { font-size: .72rem; color: var(--muted); }
.chart-bar strong { font-size: .72rem; }

.sheet-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* 5. Form ----------------------------------------------------------------- */
.form { display: grid; gap: 16px; }
.form-section { display: grid; gap: 12px; }
.form-section + .form-section { padding-top: 16px; border-top: 1px solid var(--line); }
.form-section-title { font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.form-grid { display: grid; gap: 12px; }
.field { display: grid; gap: 6px; min-width: 0; }
.field > label, .label { font-size: .85rem; font-weight: 600; color: var(--text); }
.hint { font-size: .8rem; color: var(--muted); }
.input, .select, .textarea, .field input:not([type=checkbox]):not([type=radio]), .field select, .field textarea {
    width: 100%;
    min-height: 46px;
    padding: 10px 12px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 16px; /* evita lo zoom automatico su iPhone */
    transition: border-color .15s, box-shadow .15s;
}
.field textarea, .textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
.field-error { font-size: .8rem; color: var(--danger); }
.check { display: flex; align-items: center; gap: 10px; font-size: .92rem; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--primary-ink); }
.form-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.form-actions .btn-primary { flex: 1 1 auto; }

.search {
    position: relative;
    display: flex; align-items: center;
}
.search .icon { position: absolute; left: 12px; color: var(--faint); pointer-events: none; }
.search input { padding-left: 40px !important; }

.choice-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.choice {
    position: relative;
    display: grid; gap: 2px;
    padding: 10px 12px 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 12px;
    background: var(--surface);
    cursor: pointer;
    overflow: hidden;
}
.choice::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--dot, var(--line-strong)); }
.choice input { position: absolute; opacity: 0; pointer-events: none; }
.choice strong { font-size: .9rem; line-height: 1.25; }
.choice span { font-size: .78rem; color: var(--muted); }
.choice:has(input:checked) { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); background: var(--primary-soft); }
.choice:has(input:focus-visible) { outline: 2px solid var(--primary); outline-offset: 2px; }

.swatches { display: flex; flex-wrap: wrap; gap: 8px; }
.swatch { position: relative; cursor: pointer; }
.swatch input { position: absolute; opacity: 0; }
.swatch span {
    display: flex; align-items: center; gap: 8px;
    padding: 7px 12px 7px 8px;
    border: 1px solid var(--line-strong);
    border-radius: 999px;
    font-size: .85rem;
    font-weight: 600;
}
.swatch i { width: 18px; height: 18px; border-radius: 50%; background: var(--dot); }
.swatch input:checked + span { border-color: var(--text); box-shadow: 0 0 0 1px var(--text); }
.swatch input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }

details.disclosure > summary {
    display: flex; align-items: center; justify-content: space-between; gap: 8px;
    list-style: none;
    cursor: pointer;
    font-weight: 650;
    color: var(--primary-ink);
    padding: 4px 0;
}
details.disclosure > summary::-webkit-details-marker { display: none; }
details.disclosure > summary::after { content: "+"; font-size: 1.2rem; font-weight: 500; }
details.disclosure[open] > summary::after { content: "–"; }
details.disclosure[open] > summary { margin-bottom: 12px; }

/* 6. Liste ---------------------------------------------------------------- */
.list { display: grid; }
.list-row {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 16px;
    border-top: 1px solid var(--line);
    min-width: 0;
}
.list > .list-row:first-child { border-top: 0; }
a.list-row:hover { background: var(--surface-2); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-meta { font-size: .83rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 2px 10px; }
.list-meta > span { white-space: nowrap; }
.list-aside { text-align: right; flex: none; display: grid; justify-items: end; gap: 4px; }
.list-group-title {
    padding: 10px 16px 6px;
    font-size: .78rem; font-weight: 700; letter-spacing: .05em; text-transform: uppercase;
    color: var(--muted);
    background: var(--surface-2);
    border-top: 1px solid var(--line);
}
.list > .list-group-title:first-child { border-top: 0; }

.appt-row { align-items: stretch; }
.appt-time { flex: none; width: 52px; display: grid; align-content: start; font-variant-numeric: tabular-nums; }
.appt-time strong { font-size: .95rem; }
.appt-time small { color: var(--faint); font-size: .75rem; }
.appt-stripe { width: 4px; flex: none; border-radius: 4px; background: var(--ev-fg, var(--primary)); opacity: .55; }
.appt-row.is-muted .list-title { text-decoration: line-through; color: var(--muted); }

.detail-list { display: grid; }
.detail-row { display: flex; justify-content: space-between; gap: 16px; padding: 10px 0; border-top: 1px dashed var(--line); font-size: .92rem; }
.detail-row:first-child { border-top: 0; }
.detail-row span { color: var(--muted); }
.detail-row strong { text-align: right; font-weight: 600; min-width: 0; overflow-wrap: anywhere; }

.next-card {
    position: relative;
    overflow: hidden;
    border: 0;
    color: #fff;
    background: linear-gradient(140deg, var(--primary), var(--primary-strong));
    box-shadow: 0 12px 30px color-mix(in srgb, var(--primary) 35%, transparent);
}
.next-card .eyebrow { color: rgba(255,255,255,.8); }
.next-card .next-time { font-size: 2rem; font-weight: 750; letter-spacing: -.02em; line-height: 1.1; margin-top: 6px; }
.next-card .next-who { font-size: 1.05rem; font-weight: 650; margin-top: 6px; }
.next-card .next-what { opacity: .85; font-size: .9rem; }
.next-card .btn { background: rgba(255,255,255,.18); border-color: rgba(255,255,255,.25); color: #fff; }
.next-card .btn:hover { background: rgba(255,255,255,.28); }
.next-card .btn-whatsapp { background: #fff; color: #198a4a; border-color: #fff; }

/* 7. Calendario ----------------------------------------------------------- */
.cal-toolbar { display: grid; gap: 10px; }
.cal-nav { display: flex; align-items: center; gap: 6px; }
.cal-title { flex: 1; min-width: 0; font-size: 1.15rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-controls { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.week-day {
    display: grid; justify-items: center; gap: 2px;
    padding: 8px 0 6px;
    border-radius: 12px;
    color: var(--muted);
}
.week-day small { font-size: .7rem; font-weight: 600; text-transform: uppercase; }
.week-day strong { font-size: 1.05rem; color: var(--text); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.week-day i { width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.week-day.has-items i { background: var(--primary); }
.week-day.is-today strong { color: var(--primary-ink); box-shadow: inset 0 0 0 1.5px var(--primary); }
.week-day.is-selected strong { background: var(--primary-strong); color: #fff; box-shadow: none; }
.week-day.is-selected.has-items i { background: var(--primary-strong); }

.timegrid {
    position: relative;
    display: grid;
    grid-template-columns: 44px repeat(var(--days, 1), minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.timegrid-head { display: contents; }
.timegrid-head > div {
    position: sticky; top: 0;
    padding: 8px 4px;
    text-align: center;
    font-size: .78rem;
    color: var(--muted);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    z-index: 2;
}
.timegrid-head a { display: grid; justify-items: center; }
.timegrid-head strong { font-size: 1.05rem; color: var(--text); width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; }
.timegrid-head .is-today strong { background: var(--primary-strong); color: #fff; }
.time-gutter { position: relative; border-right: 1px solid var(--line); }
.time-gutter span {
    display: block;
    height: var(--hour);
    padding-right: 6px;
    text-align: right;
    font-size: .7rem;
    color: var(--faint);
    transform: translateY(-.55em);
    font-variant-numeric: tabular-nums;
}
.time-gutter span:first-child { transform: none; padding-top: 2px; }
.day-col {
    position: relative;
    border-left: 1px solid var(--line);
    background-image: repeating-linear-gradient(to bottom, var(--line) 0 1px, transparent 1px var(--hour)),
                      repeating-linear-gradient(to bottom, transparent 0 calc(var(--hour) / 2), var(--line-faint) calc(var(--hour) / 2) calc(var(--hour) / 2 + 1px), transparent calc(var(--hour) / 2 + 1px) var(--hour));
}
.day-col:nth-child(2) { border-left: 0; }
.day-col.is-today { background-color: color-mix(in srgb, var(--primary-soft) 45%, transparent); }
.slot { display: block; height: calc(var(--hour) / 2); }
.slot:hover { background: color-mix(in srgb, var(--primary-soft) 80%, transparent); }
.slot:hover::after { content: "+"; display: block; padding: 2px 8px; color: var(--primary-ink); font-weight: 700; }

.event {
    position: absolute;
    top: calc(var(--start) * var(--hour) / 60 + 1px);
    height: calc(var(--dur) * var(--hour) / 60 - 2px);
    left: calc(var(--lane) * 100% / var(--lanes) + 2px);
    width: calc(100% / var(--lanes) - 4px);
    padding: 4px 7px;
    border-radius: 8px;
    border-left: 3px solid var(--ev-fg);
    background: var(--ev-bg);
    color: var(--ev-fg);
    font-size: .76rem;
    line-height: 1.25;
    overflow: hidden;
    z-index: 1;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.event:hover { z-index: 3; box-shadow: var(--shadow); }
.event strong { display: block; font-size: .8rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.event span { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; opacity: .9; }
.event time { font-weight: 650; font-variant-numeric: tabular-nums; }
.event.is-completed { opacity: .7; }
.event.is-completed strong::before { content: "✓ "; }
.event.is-no_show { opacity: .55; background-image: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.55) 6px 12px); }
.event.is-short strong, .event.is-short span { display: inline; }

.now-line {
    position: absolute; left: 0; right: 0;
    top: calc(var(--now) * var(--hour) / 60);
    height: 2px;
    background: var(--danger);
    z-index: 4;
    pointer-events: none;
}
.now-line::before { content: ""; position: absolute; left: -5px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); }

.cal-week-grid { display: none; }
.week-list { display: grid; gap: 10px; }

.month-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-lg);
    overflow: hidden;
}
.month-head {
    padding: 8px 4px;
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
}
.month-cell {
    display: grid;
    align-content: start;
    gap: 3px;
    min-height: 62px;
    padding: 5px;
    border-top: 1px solid var(--line);
    border-left: 1px solid var(--line);
    min-width: 0;
}
.month-cell:nth-child(7n + 1) { border-left: 0; }
.month-head + .month-cell, .month-grid > .month-cell:nth-child(-n + 14) { border-top: 0; }
.month-cell.is-outside { background: var(--surface-muted); }
.month-cell.is-outside .month-num { color: var(--faint); }
.month-num { font-size: .82rem; font-weight: 650; width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; }
.month-cell.is-today .month-num { background: var(--primary-strong); color: #fff; }
.month-cell:hover { background: var(--surface-2); }
.month-dots { display: flex; flex-wrap: wrap; gap: 3px; padding-left: 4px; }
.month-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--ev-fg, var(--primary)); }
.month-pill {
    display: none;
    padding: 2px 6px;
    border-radius: 6px;
    background: var(--ev-bg);
    color: var(--ev-fg);
    font-size: .74rem;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.month-more { display: none; font-size: .72rem; color: var(--muted); padding-left: 4px; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }

/* 8. Pagine di accesso ---------------------------------------------------- */
.auth {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px 16px;
    background:
        radial-gradient(1200px 500px at 10% -10%, var(--primary-soft), transparent 60%),
        radial-gradient(900px 500px at 110% 110%, #f3ece6, transparent 60%),
        var(--bg);
}
.auth-card { width: min(420px, 100%); display: grid; gap: 18px; }
.auth-brand { display: flex; align-items: center; gap: 12px; }
.auth-brand .brand-mark { width: 44px; height: 44px; font-size: 1.1rem; border-radius: 14px; }
.auth-brand strong { display: block; font-size: 1.15rem; }
.auth-brand span { display: block; font-size: .85rem; color: var(--muted); }
.auth .card { padding: 22px; box-shadow: var(--shadow); }
.auth-foot { text-align: center; font-size: .9rem; color: var(--muted); }

/* 9. Utility -------------------------------------------------------------- */
.stack { display: grid; gap: 16px; }
.stack-sm { display: grid; gap: 8px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.grid-2, .grid-3 { display: grid; gap: 16px; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
.text-right { text-align: right; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; }
@media (max-width: 1023px) { .only-desktop { display: none !important; } }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
form.inline { display: inline; margin: 0; }

/* 10. Breakpoint ---------------------------------------------------------- */
@media (min-width: 640px) {
    .form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .form-grid .full { grid-column: 1 / -1; }
    .kpis { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .sheet-actions { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .month-cell { min-height: 96px; }
    .month-pill { display: block; }
    .month-more { display: block; }
    .month-dots { display: none; }
    h1 { font-size: 1.75rem; }
}

@media (min-width: 768px) {
    .cal-week-grid { display: grid; }
    .week-list { display: none; }
    .cal-toolbar { grid-template-columns: 1fr auto; align-items: center; }
}

@media (min-width: 1024px) {
    .shell { display: grid; grid-template-columns: 252px minmax(0, 1fr); }
    .topbar, .tabbar { display: none; }
    .only-mobile { display: none !important; }
    .page { padding: 28px 32px 48px; gap: 20px; }
    .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .grid-main { grid-template-columns: minmax(0, 1.6fr) minmax(300px, 1fr); align-items: start; }
    .sticky-aside { position: sticky; top: 24px; }

    .sidebar {
        position: sticky; top: 0;
        height: 100vh;
        display: flex; flex-direction: column; gap: 6px;
        padding: 20px 14px;
        background: var(--surface);
        border-right: 1px solid var(--line);
        overflow-y: auto;
    }
    .sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 16px; }
    .sidebar-brand strong { display: block; font-size: .98rem; }
    .sidebar-brand span { display: block; font-size: .78rem; color: var(--muted); }
    .sidebar .btn-primary { margin: 0 4px 10px; }
    .nav-section { padding: 14px 10px 4px; font-size: .7rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--faint); }
    .nav-link {
        display: flex; align-items: center; gap: 10px;
        padding: 9px 10px;
        border-radius: 10px;
        color: var(--muted);
        font-weight: 600;
        font-size: .92rem;
    }
    .nav-link:hover { background: var(--surface-2); color: var(--text); }
    .nav-link.is-active { background: var(--primary-soft); color: var(--primary-ink); }
    .sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--line); display: flex; align-items: center; gap: 10px; }
    .sidebar-foot .list-main { font-size: .85rem; }

    :root { --hour: 72px; }
}

details > summary { list-style: none; }
details > summary::-webkit-details-marker { display: none; }
.cal-controls .segmented { flex: 1; }
@media (min-width: 768px) { .cal-controls .segmented { flex: none; } }
@media (max-width: 1023px) { .first-on-mobile { order: -1; } }
input::placeholder { text-transform: none; }

/* 11. Prenotazione online (pagine pubbliche /prenota/...) ------------------ */
body.booking { background: linear-gradient(180deg, var(--primary-soft) 0, var(--bg) 320px); }
.booking-header {
    position: sticky; top: 0; z-index: 20;
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 12px 16px; padding-top: calc(12px + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--primary-soft) 85%, transparent);
    backdrop-filter: saturate(1.4) blur(14px);
    -webkit-backdrop-filter: saturate(1.4) blur(14px);
    border-bottom: 1px solid color-mix(in srgb, var(--primary) 15%, transparent);
}
.booking-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.booking-brand strong { display: block; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.booking-brand small { display: block; font-size: .75rem; color: var(--muted); }
.booking-page { width: 100%; max-width: 640px; margin: 0 auto; padding: 20px 16px 40px; display: grid; gap: 16px; }
.booking-hero h1 { font-size: 1.6rem; }
.booking-hero p { color: var(--muted); margin-top: 6px; }
.booking-narrow { max-width: 440px; width: 100%; justify-self: center; }
.booking-footer {
    display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 16px;
    padding: 24px 16px calc(24px + env(safe-area-inset-bottom));
    font-size: .85rem; color: var(--muted);
    border-top: 1px solid var(--line);
}
.booking-footer span, .booking-footer a { display: inline-flex; align-items: center; gap: 6px; }
.service-row { align-items: flex-start; }
.service-row .list-aside { align-self: center; }

.day-scroller {
    display: flex; gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding: 2px 2px 8px;
    margin: 0 -16px; padding-left: 16px; padding-right: 16px;
    scrollbar-width: none;
}
.day-scroller::-webkit-scrollbar { display: none; }
.day-chip {
    flex: none;
    scroll-snap-align: start;
    display: grid; justify-items: center; gap: 0;
    width: 62px; padding: 8px 0;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
}
.day-chip small { font-size: .7rem; text-transform: uppercase; color: var(--muted); font-weight: 600; }
.day-chip strong { font-size: 1.3rem; line-height: 1.2; }
.day-chip.is-selected { background: var(--primary-strong); border-color: var(--primary-ink); color: #fff; }
.day-chip.is-selected small { color: rgba(255,255,255,.8); }
.day-chip.is-full { opacity: .45; }

.slot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 8px; }
.slot-btn {
    display: grid; place-items: center;
    min-height: 46px;
    border: 1px solid color-mix(in srgb, var(--primary) 35%, var(--line));
    border-radius: 12px;
    background: var(--surface);
    color: var(--primary-ink);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}
.slot-btn:hover { background: var(--primary-strong); color: #fff; border-color: var(--primary-ink); }

.booking-success { text-align: center; display: grid; justify-items: center; gap: 6px; }
.success-mark { width: 56px; height: 56px; border-radius: 50%; display: grid; place-items: center; background: var(--success-soft); color: var(--success); }
.success-mark .icon { width: 28px; height: 28px; stroke-width: 2.4; }
.card.is-highlighted { border-color: var(--primary); box-shadow: 0 0 0 2px color-mix(in srgb, var(--primary) 25%, transparent); }

/* Richieste online in attesa, lato staff */
.event.is-pending { border-left-style: dashed; background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255,255,255,.6) 8px 14px); }
.qr-box { display: grid; place-items: center; padding: 12px; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); }
.qr-box svg { width: 200px; height: 200px; }
.copy-field { display: flex; gap: 8px; }
.copy-field input { flex: 1; min-width: 0; }
.weekday-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.weekday-picks label { position: relative; cursor: pointer; }
.weekday-picks input { position: absolute; opacity: 0; }
.weekday-picks span { display: grid; place-items: center; width: 46px; height: 40px; border: 1px solid var(--line-strong); border-radius: 10px; font-weight: 600; font-size: .85rem; color: var(--muted); }
.weekday-picks input:checked + span { background: var(--primary-strong); border-color: var(--primary-ink); color: #fff; }
.weekday-picks input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.nav-count { margin-left: auto; min-width: 22px; height: 22px; padding: 0 6px; display: grid; place-items: center; border-radius: 999px; background: var(--info); color: #fff; font-size: .72rem; font-weight: 700; }
.tab-link { position: relative; }
.tab-count { position: absolute; top: 2px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; display: grid; place-items: center; border-radius: 999px; background: var(--info); color: #fff; font-size: .65rem; font-weight: 700; }
@media (max-width: 420px) { .hide-xs { display: none; } }

/* 12. Tema scuro (solo gestionale) ----------------------------------------
   Attivo con <html data-theme="dark">, oppure data-theme="auto" quando il
   dispositivo è in modalità scura. Le pagine delle clienti non lo usano. */
html[data-theme="dark"] {
    color-scheme: dark;
    --bg: #171312;
    --surface: #221c1b;
    --surface-2: #2c2524;
    --surface-muted: #1c1716;
    --line: #362e2c;
    --line-strong: #4a403d;
    --line-faint: #2a2322;
    --text: #f3ece9;
    --muted: #b5a8a3;
    --faint: #85776f;
    --primary-ink: color-mix(in srgb, var(--primary) 55%, #fff);
    --primary-soft: color-mix(in srgb, var(--primary) 24%, #221c1b);
    --success: #6fcf9b;  --success-soft: #1c3428;
    --danger: #f08a8f;   --danger-soft: #3a1f21;
    --warning: #e9b462;  --warning-soft: #392b17;
    --info: #8db8e3;     --info-soft: #1d2b3a;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        color-scheme: dark;
        --bg: #171312;
        --surface: #221c1b;
        --surface-2: #2c2524;
        --surface-muted: #1c1716;
        --line: #362e2c;
        --line-strong: #4a403d;
        --line-faint: #2a2322;
        --text: #f3ece9;
        --muted: #b5a8a3;
        --faint: #85776f;
        --primary-ink: color-mix(in srgb, var(--primary) 55%, #fff);
        --primary-soft: color-mix(in srgb, var(--primary) 24%, #221c1b);
        --success: #6fcf9b;  --success-soft: #1c3428;
        --danger: #f08a8f;   --danger-soft: #3a1f21;
        --warning: #e9b462;  --warning-soft: #392b17;
        --info: #8db8e3;     --info-soft: #1d2b3a;
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
        --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px rgba(0, 0, 0, .35);
    }
}

/* Pulsanti pieni con testo scuro sopra un fondo che nel tema scuro diventa chiaro */
html[data-theme="dark"] .btn-success, html[data-theme="dark"] .nav-count, html[data-theme="dark"] .tab-count { color: #10231a; }
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] .btn-success, html[data-theme="auto"] .nav-count, html[data-theme="auto"] .tab-count { color: #10231a; }
}

/* Scelta modalità nel profilo (stile segmented con radio) */
.segmented-option { position: relative; cursor: pointer; }
.segmented-option input { position: absolute; opacity: 0; }
.segmented-option span { display: block; padding: 7px 14px; border-radius: 9px; font-size: .85rem; font-weight: 600; color: var(--muted); text-align: center; }
.segmented-option input:checked + span { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.segmented-option input:focus-visible + span { outline: 2px solid var(--primary); outline-offset: 2px; }
.recovery-codes { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--surface); color: var(--text); font-size: .95rem; line-height: 1.7; columns: 2; font-variant-numeric: tabular-nums; white-space: pre; }
.secret-key { display: block; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); font-size: .9rem; letter-spacing: .05em; overflow-wrap: anywhere; }
.slot-btn { flex-direction: column; gap: 0; line-height: 1.1; }
.slot-btn small { font-size: .65rem; font-weight: 600; opacity: .85; }
.slot-btn.is-busy { border-style: dashed; color: var(--muted); background: var(--surface-2); }
.slot-btn.is-busy:hover { background: var(--warning-soft); color: var(--warning); border-color: var(--warning); }
.closure-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 4px; font-size: .88rem; }
.closure-list li { display: flex; justify-content: space-between; gap: 12px; }
.proposal { margin-top: 12px; padding: 12px 14px; border-radius: var(--radius); background: var(--warning-soft); border: 1px solid color-mix(in srgb, var(--warning) 25%, transparent); display: grid; gap: 4px; }
.timeline { list-style: none; margin: 4px 0 0; padding: 0 0 0 14px; border-left: 2px solid var(--line); display: grid; gap: 12px; }
.timeline-item { position: relative; }
.timeline-item::before { content: ""; position: absolute; left: -20px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--line-strong); border: 2px solid var(--surface); }
.timeline-item.is-staff::before { background: var(--primary); }
.timeline-item.is-client::before { background: var(--info); }
.timeline-meta { font-size: .75rem; color: var(--faint); }
.timeline-text { display: grid; gap: 2px; font-size: .9rem; }
.timeline-text span { color: var(--muted); }

/* Orari, chiusure e richieste in attesa nel calendario */
.event.is-proposed { border-left-style: dotted; background-image: repeating-linear-gradient(135deg, transparent 0 8px, rgba(255,255,255,.6) 8px 14px); }
.off-hours {
    position: absolute; left: 0; right: 0;
    top: calc(var(--start) * var(--hour) / 60);
    height: calc(var(--dur) * var(--hour) / 60);
    background: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--line-strong) 45%, transparent) 6px 7px);
    background-color: color-mix(in srgb, var(--surface-2) 60%, transparent);
    pointer-events: none;
}
.day-closed-label {
    position: absolute; top: 6px; left: 6px; right: 6px; z-index: 2;
    padding: 4px 8px; border-radius: 8px;
    background: var(--warning-soft); color: var(--warning);
    font-size: .74rem; font-weight: 650; text-align: center;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    pointer-events: none;
}
.week-day.is-closed strong { color: var(--faint); text-decoration: line-through; }
.month-cell.is-closed { background: repeating-linear-gradient(135deg, transparent 0 8px, color-mix(in srgb, var(--line) 70%, transparent) 8px 9px); }
.month-closed { font-size: .66rem; font-weight: 650; color: var(--warning); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.week-hours { display: grid; }
.day-hours { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; padding: 10px 0; border-top: 1px solid var(--line); }
.day-hours:first-child { border-top: 0; }
.day-toggle { display: flex; align-items: center; gap: 8px; min-height: 40px; font-weight: 650; cursor: pointer; }
.day-toggle input { width: 20px; height: 20px; accent-color: var(--primary-strong); }
.day-ranges { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.day-ranges .range { display: flex; align-items: center; gap: 6px; }
.day-ranges input[type=time] { min-height: 40px; padding: 6px 8px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--surface); color: var(--text); font: inherit; font-size: 16px; }
.day-hours .closed-text { display: none; color: var(--faint); min-height: 40px; align-items: center; }
.day-hours.is-closed .range, .day-hours.is-closed .add-range { display: none; }
.day-hours.is-closed .closed-text { display: flex; }
.holiday-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px 16px; }
.check.holiday span { display: grid; line-height: 1.25; }
.check.holiday small { color: var(--muted); font-size: .78rem; }

/* Pagina di accesso: vetrina del gestionale (desktop) + modulo */
.auth { display: grid; grid-template-columns: 1fr; padding: 0; place-items: stretch; }
.auth-panel { display: grid; place-items: center; padding: 24px 16px; min-height: 100vh; }
.auth-showcase { display: none; }
.auth-logo { width: 44px; height: 44px; object-fit: contain; border-radius: 14px; background: #fff; }
@media (min-width: 960px) {
    .auth { grid-template-columns: minmax(380px, 1fr) minmax(460px, 1fr); }
    .auth-showcase {
        display: grid; place-items: center; padding: 48px;
        background:
            radial-gradient(600px 400px at 0% 0%, color-mix(in srgb, #fff 18%, transparent), transparent 70%),
            linear-gradient(150deg, var(--primary), var(--primary-strong));
        color: #fff;
    }
    .auth-showcase-inner { max-width: 440px; display: grid; gap: 22px; }
    .auth-brand-light span { color: rgba(255,255,255,.8); }
    .auth-brand-light .brand-mark { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.3); }
    .auth-brand-light strong { font-size: 1.5rem; }
    .auth-welcome { font-size: 1.15rem; line-height: 1.5; opacity: .95; }
    .auth-features { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
    .auth-features li { display: flex; gap: 10px; align-items: flex-start; }
    .auth-features .icon { margin-top: 3px; }
    .auth-mock { display: grid; gap: 6px; padding: 14px; border-radius: 16px; background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.2); }
    .auth-mock-row { display: grid; grid-template-columns: 48px 1fr; gap: 10px; align-items: center; font-size: .85rem; }
    .auth-mock-row b { font-variant-numeric: tabular-nums; opacity: .85; font-weight: 600; }
    .auth-mock-row span { padding: 6px 10px; border-radius: 8px; background: var(--c, transparent); color: #3a2a2a; font-weight: 600; }
    .auth-mock-row.is-break span { background: repeating-linear-gradient(135deg, transparent 0 6px, rgba(255,255,255,.25) 6px 7px); color: #fff; opacity: .8; font-weight: 500; }
    .auth-brand-compact { display: none; }
}

/* Caricamento tra una pagina e l'altra (public/js/app.js): visibile solo se l'attesa è lunga */
#boost-loader { position: fixed; inset: 0 0 auto 0; z-index: 100; pointer-events: none; opacity: 0; transition: opacity .15s; }
#boost-loader.is-visible { opacity: 1; }
#boost-loader .boost-bar { height: 3px; background: var(--primary); transform-origin: left; animation: boost-progress 2.5s ease-out forwards; }
#boost-loader .boost-pill {
    position: fixed; top: 14px; left: 50%; transform: translateX(-50%);
    padding: 6px 14px; border-radius: 999px;
    background: var(--surface); color: var(--text); box-shadow: var(--shadow);
    font-size: .82rem; font-weight: 600;
}
@keyframes boost-progress { from { transform: scaleX(.05); } to { transform: scaleX(.9); } }
@media (prefers-reduced-motion: reduce) { #boost-loader .boost-bar { animation: none; transform: scaleX(.6); } }
