/* ==========================================================================
   Booko · UI v2
   Design system mobile-first per attività di servizi (parrucchieri, estetica,
   studi dentistici, etc.). Doppio tema chiaro/scuro tramite [data-theme].
   ========================================================================== */

/* ---------- Tokens (light) ---------- */
:root {
    --bg: #f5f6fb;
    --bg-grad-1: #ece6ff;
    --bg-grad-2: #e0f3ee;
    --surface: #ffffff;
    --surface-2: #f1f3fa;
    --surface-3: #e7eaf4;
    --text: #1a1d2e;
    --text-soft: #5b6478;
    --text-muted: #8892a6;
    --border: #e3e7f1;
    --border-strong: #cdd4e3;

    --primary: #6e56f7;
    --primary-hover: #5b42e6;
    --primary-soft: rgba(110, 86, 247, .12);
    --primary-text: #ffffff;

    --accent: #14b8a6;
    --accent-soft: rgba(20, 184, 166, .14);
    --danger: #e0413a;
    --danger-soft: rgba(224, 65, 58, .12);
    --warn: #d97706;
    --warn-soft: rgba(217, 119, 6, .14);
    --info: #2f6fed;
    --info-soft: rgba(47, 111, 237, .14);

    --radius: 16px;
    --radius-sm: 10px;
    --radius-pill: 999px;

    --shadow-sm: 0 1px 2px rgba(20, 25, 50, .04), 0 1px 1px rgba(20, 25, 50, .03);
    --shadow: 0 4px 14px rgba(20, 25, 50, .06), 0 1px 2px rgba(20, 25, 50, .04);
    --shadow-lg: 0 18px 36px rgba(20, 25, 50, .10), 0 2px 6px rgba(20, 25, 50, .05);
    --shadow-primary: 0 10px 24px rgba(110, 86, 247, .35);

    --tap: 44px;
    --topbar-h: 56px;
    --tabbar-h: 64px;

    color-scheme: light;
}

/* ---------- Tokens (dark) ---------- */
[data-theme="dark"] {
    --bg: #0d1018;
    --bg-grad-1: #1a1530;
    --bg-grad-2: #0f1a22;
    --surface: #161a26;
    --surface-2: #1d2231;
    --surface-3: #262d40;
    --text: #ebeef7;
    --text-soft: #a3acc2;
    --text-muted: #6f7892;
    --border: #262c3d;
    --border-strong: #34394d;

    --primary: #8b73ff;
    --primary-hover: #a18cff;
    --primary-soft: rgba(139, 115, 255, .18);
    --primary-text: #ffffff;

    --accent: #2dd4bf;
    --accent-soft: rgba(45, 212, 191, .16);
    --danger: #f87171;
    --danger-soft: rgba(248, 113, 113, .15);
    --warn: #fbbf24;
    --warn-soft: rgba(251, 191, 36, .15);
    --info: #60a5fa;
    --info-soft: rgba(96, 165, 250, .15);

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
    --shadow: 0 4px 14px rgba(0, 0, 0, .4);
    --shadow-lg: 0 18px 36px rgba(0, 0, 0, .55);
    --shadow-primary: 0 10px 26px rgba(139, 115, 255, .35);

    color-scheme: dark;
}

/* Auto dark se nessun tema esplicito è stato salvato */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme]) {
        --bg: #0d1018;
        --bg-grad-1: #1a1530;
        --bg-grad-2: #0f1a22;
        --surface: #161a26;
        --surface-2: #1d2231;
        --surface-3: #262d40;
        --text: #ebeef7;
        --text-soft: #a3acc2;
        --text-muted: #6f7892;
        --border: #262c3d;
        --border-strong: #34394d;
        --primary: #8b73ff;
        --primary-hover: #a18cff;
        --primary-soft: rgba(139, 115, 255, .18);
        --accent: #2dd4bf;
        --accent-soft: rgba(45, 212, 191, .16);
        --danger: #f87171;
        --danger-soft: rgba(248, 113, 113, .15);
        --warn: #fbbf24;
        --warn-soft: rgba(251, 191, 36, .15);
        --info: #60a5fa;
        --info-soft: rgba(96, 165, 250, .15);
        --shadow-sm: 0 1px 2px rgba(0, 0, 0, .35);
        --shadow: 0 4px 14px rgba(0, 0, 0, .4);
        --shadow-lg: 0 18px 36px rgba(0, 0, 0, .55);
        --shadow-primary: 0 10px 26px rgba(139, 115, 255, .35);
        color-scheme: dark;
    }
}

/* ---------- Base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    background:
        radial-gradient(900px 380px at 90% -160px, var(--bg-grad-1) 0%, transparent 60%),
        radial-gradient(900px 380px at 0% -120px, var(--bg-grad-2) 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
    color: var(--text);
    line-height: 1.5;
    -webkit-tap-highlight-color: transparent;
    padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + .5rem);
    min-height: 100vh;
    transition: background-color .25s ease, color .25s ease;
}
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { letter-spacing: -.015em; }

/* ---------- Top bar ---------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    gap: .6rem;
    min-height: var(--topbar-h);
    padding: .55rem .9rem;
    padding-top: calc(.55rem + env(safe-area-inset-top));
    background: color-mix(in srgb, var(--surface) 82%, transparent);
    border-bottom: 1px solid var(--border);
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.topbar .brand {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
    letter-spacing: -.015em;
}
.topbar .brand:hover { text-decoration: none; }
.topbar .brand-mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: .95rem; font-weight: 700;
    box-shadow: var(--shadow-primary);
}
.topbar h1 {
    font-size: 1.02rem;
    margin: 0;
    flex: 1;
    font-weight: 600;
    letter-spacing: -.01em;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.topbar .right { display: flex; gap: .35rem; align-items: center; }
.topbar form { display: inline; margin: 0; }
.topbar-user {
    display: none;
    align-items: center;
    min-height: 30px;
    padding: 0 .65rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-pill);
    background: var(--surface-2);
    color: var(--text-soft);
    font-size: .8rem;
    font-weight: 500;
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
@media (min-width: 560px) { .topbar-user { display: inline-flex; } }

/* Theme toggle */
.theme-toggle {
    width: 38px; height: 38px;
    border-radius: var(--radius-pill);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-soft);
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer;
    font-size: 1.05rem;
    transition: background .15s ease, color .15s ease, transform .15s ease;
    padding: 0;
}
.theme-toggle:hover { background: var(--surface-2); color: var(--text); }
.theme-toggle:active { transform: scale(.94); }
.theme-toggle .icon-sun { display: none; }
.theme-toggle .icon-moon { display: inline; }
[data-theme="dark"] .theme-toggle .icon-sun { display: inline; }
[data-theme="dark"] .theme-toggle .icon-moon { display: none; }

/* ---------- Container ---------- */
main { padding: 1rem .9rem; max-width: 1040px; margin: 0 auto; }
@media (min-width: 720px) { main { padding: 1.4rem; } }

/* ---------- Cards ---------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.1rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: .85rem;
}
.card-title {
    font-size: .72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
    margin: 0 0 .35rem;
    font-weight: 600;
}
.card h2 { margin: 0 0 .7rem; font-size: 1.08rem; font-weight: 650; }

/* Hero card (dashboard greeting) */
.hero {
    position: relative;
    overflow: hidden;
    border: 1px solid var(--border);
    background:
        radial-gradient(420px 200px at 100% 0%, var(--primary-soft) 0%, transparent 70%),
        linear-gradient(135deg, var(--surface) 0%, var(--surface-2) 100%);
    box-shadow: var(--shadow);
}
.hero h2 { font-size: 1.3rem; margin: 0 0 .25rem; }
.hero p { margin: 0; color: var(--text-soft); }

/* ---------- KPI grid ---------- */
.kpis {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .65rem;
    margin-bottom: .85rem;
}
@media (min-width: 720px) { .kpis { grid-template-columns: repeat(3, 1fr); } }
.kpi {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .95rem 1rem;
    box-shadow: var(--shadow-sm);
    transition: transform .15s ease, box-shadow .2s ease;
    position: relative;
    overflow: hidden;
}
.kpi:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.kpi::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 3px;
    background: var(--primary);
    opacity: .85;
}
.kpi .label {
    font-size: .73rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .06em;
    font-weight: 600;
}
.kpi .value { font-size: 1.7rem; font-weight: 700; margin-top: .25rem; letter-spacing: -.02em; }
.kpi.warn::before   { background: var(--warn); }
.kpi.danger::before { background: var(--danger); }
.kpi.ok::before     { background: var(--accent); }
.kpi.warn .value    { color: var(--warn); }
.kpi.danger .value  { color: var(--danger); }
.kpi.ok .value      { color: var(--accent); }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center;
    min-height: var(--tap);
    padding: 0 1.1rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit; font-weight: 600;
    cursor: pointer;
    gap: .45rem;
    text-decoration: none;
    transition: transform .12s ease, box-shadow .15s ease,
                background-color .15s ease, border-color .15s ease, color .15s ease;
    user-select: none;
    -webkit-user-select: none;
}
.btn:hover { background: var(--surface-2); text-decoration: none; transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn-primary {
    background: var(--primary);
    color: var(--primary-text);
    border-color: var(--primary);
    box-shadow: 0 4px 14px rgba(110, 86, 247, .25);
}
.btn-primary:hover {
    background: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--primary-text);
}
.btn-danger { background: transparent; color: var(--danger); border-color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); color: var(--danger); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-soft); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }
.btn-sm { min-height: 36px; padding: 0 .8rem; font-size: .87rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: .55rem; flex-wrap: wrap; }
.btn-row .btn { flex: 1 1 180px; }
.btn[disabled], .btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }

/* FAB */
.fab {
    position: fixed;
    right: 1rem;
    bottom: calc(var(--tabbar-h) + 14px + env(safe-area-inset-bottom));
    width: 58px; height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--primary-text);
    display: flex; align-items: center; justify-content: center;
    box-shadow: var(--shadow-primary);
    font-size: 1.8rem; font-weight: 300;
    z-index: 25;
    transition: transform .15s ease, box-shadow .2s ease;
}
.fab:hover { text-decoration: none; transform: translateY(-2px) scale(1.04); }
.fab:active { transform: scale(.96); }

/* ---------- Lists ---------- */
.list { list-style: none; padding: 0; margin: 0; }
.list > li {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    margin-bottom: .6rem;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
    gap: .65rem;
    align-items: flex-start;
    transition: box-shadow .2s ease, transform .15s ease, border-color .15s ease;
}
.list > li:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
@media (min-width: 700px) {
    .list > li { flex-direction: row; align-items: center; }
}
.list .meta { flex: 1; min-width: 0; }
.list .primary { font-weight: 650; font-size: 1rem; }
.list .secondary { color: var(--text-soft); font-size: .88rem; margin-top: .2rem; }
.list .actions { display: flex; gap: .35rem; flex-wrap: wrap; width: 100%; }
@media (min-width: 700px) {
    .list .actions { width: auto; justify-content: flex-end; }
}

/* ---------- Forms ---------- */
form .row { margin-bottom: 1rem; }
form label {
    display: block;
    font-size: .82rem;
    color: var(--text-soft);
    margin-bottom: .35rem;
    font-weight: 600;
}
form input[type=text], form input[type=email], form input[type=tel],
form input[type=password], form input[type=number], form input[type=datetime-local],
form input[type=date], form input[type=time], form input[type=url],
form input[type=search], form textarea, form select {
    width: 100%;
    min-height: var(--tap);
    padding: .6rem .8rem;
    font: inherit;
    color: var(--text);
    background: var(--surface);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    appearance: none;
    -webkit-appearance: none;
    transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
form textarea { min-height: 96px; resize: vertical; line-height: 1.45; }
form input::placeholder, form textarea::placeholder { color: var(--text-muted); }
form input:focus, form textarea:focus, form select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 4px var(--primary-soft);
}
form select {
    background-image: linear-gradient(45deg, transparent 50%, var(--text-soft) 50%),
                      linear-gradient(135deg, var(--text-soft) 50%, transparent 50%);
    background-position: calc(100% - 18px) 50%, calc(100% - 13px) 50%;
    background-size: 5px 5px;
    background-repeat: no-repeat;
    padding-right: 2.2rem;
}
.check {
    display: flex;
    align-items: center;
    gap: .65rem;
    min-height: var(--tap);
    padding: .35rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.check input[type=checkbox] {
    width: 20px; height: 20px;
    accent-color: var(--primary);
    cursor: pointer;
}
.check label { margin: 0; font-weight: 500; color: var(--text); cursor: pointer; }
.error { color: var(--danger); font-size: .82rem; margin-top: .35rem; display: block; font-weight: 500; }
.form-grid { display: grid; grid-template-columns: 1fr; gap: 0; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; gap: 0 1.1rem; } }
@media (min-width: 760px) { .form-grid.cols-3 { grid-template-columns: 1fr 1fr 1.4fr; gap: 0 1.1rem; } }

.color-input-row {
    display: flex;
    gap: .6rem;
    align-items: center;
}
.color-input-row input[type="color"] {
    width: 48px;
    min-width: 48px;
    height: 42px;
    padding: 3px;
    border-radius: 12px;
    cursor: pointer;
}
.service-title {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
}
.service-color-dot {
    width: .78rem;
    height: .78rem;
    border-radius: 999px;
    display: inline-block;
    flex: 0 0 auto;
    box-shadow: 0 0 0 2px color-mix(in srgb, currentColor 8%, transparent);
}
.service-color-dot-sm {
    width: .62rem;
    height: .62rem;
    vertical-align: middle;
    margin-right: .3rem;
}
.service-color-dot-xs {
    width: .5rem;
    height: .5rem;
    align-self: center;
}
.map-preview {
    display: grid;
    gap: .65rem;
    margin: .7rem 0 1rem;
}
.map-preview iframe {
    width: 100%;
    min-height: 220px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-2);
}

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .22rem .6rem;
    border-radius: var(--radius-pill);
    font-size: .7rem;
    font-weight: 700;
    background: var(--surface-3);
    color: var(--text-soft);
    text-transform: uppercase;
    letter-spacing: .06em;
    line-height: 1.2;
}
.badge.ok     { background: var(--accent-soft); color: var(--accent); }
.badge.warn   { background: var(--warn-soft);   color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info   { background: var(--info-soft);   color: var(--info); }

/* ---------- Flash ---------- */
.flash {
    padding: .8rem 1rem;
    border-radius: var(--radius-sm);
    margin-bottom: .85rem;
    font-weight: 500;
    border: 1px solid transparent;
    display: flex; align-items: center; gap: .55rem;
}
.flash::before { font-size: 1.05rem; line-height: 1; font-weight: 800; }
.flash.ok   { background: var(--accent-soft); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 25%, transparent); }
.flash.ok::before  { content: "✓"; }
.flash.warn { background: var(--warn-soft); color: var(--warn); border-color: color-mix(in srgb, var(--warn) 25%, transparent); justify-content: space-between; }
.flash.warn::before { content: "⚠"; }
.flash.err  { background: var(--danger-soft); color: var(--danger); border-color: color-mix(in srgb, var(--danger) 25%, transparent); }
.flash.err::before { content: "!"; }

/* ---------- Bottom navigation ---------- */
.tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
    background: color-mix(in srgb, var(--surface) 92%, transparent);
    border-top: 1px solid var(--border);
    display: flex;
    gap: .15rem;
    padding: .25rem .35rem;
    padding-bottom: calc(.25rem + env(safe-area-inset-bottom));
    backdrop-filter: saturate(160%) blur(14px);
    -webkit-backdrop-filter: saturate(160%) blur(14px);
}
.tabbar a {
    flex: 1;
    text-align: center;
    padding: .5rem .25rem;
    color: var(--text-muted);
    font-size: .7rem;
    font-weight: 600;
    text-decoration: none;
    line-height: 1.1;
    border-radius: 12px;
    transition: color .15s ease, background-color .15s ease;
}
.tabbar a .icon { font-size: 1.3rem; display: block; margin-bottom: .15rem; }
.tabbar a.active { color: var(--primary); background: var(--primary-soft); }
.tabbar a:hover { text-decoration: none; background: var(--surface-2); color: var(--text); }
.tabbar a.active:hover { background: var(--primary-soft); color: var(--primary); }

/* ---------- Day nav ---------- */
.daynav {
    display: flex;
    align-items: center;
    gap: .45rem;
    margin-bottom: .85rem;
    padding: .55rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.daynav .date { flex: 1; text-align: center; font-weight: 700; }
.daynav .day-input { flex: 1; min-width: 130px; }
.btn-icon { width: 40px; padding: 0; border-radius: var(--radius-pill); }

/* ---------- Misc ---------- */
.empty {
    text-align: center;
    color: var(--text-soft);
    padding: 2.5rem 1rem;
    background: var(--surface);
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius);
}
.search-bar { display: flex; gap: .5rem; margin-bottom: .85rem; }
.search-bar input { flex: 1; }
hr.sep { border: 0; border-top: 1px solid var(--border); margin: 1.1rem 0; }
.subtle { color: var(--text-soft); font-size: .88rem; }

/* ---------- Auth/standalone pages ---------- */
.auth-wrap, .login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background:
        radial-gradient(700px 360px at 80% -120px, var(--primary-soft) 0%, transparent 60%),
        radial-gradient(700px 360px at 20% 110%, var(--accent-soft) 0%, transparent 60%),
        var(--bg);
    background-attachment: fixed;
}
.auth-card, .login-card {
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-lg);
    padding: 1.6rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.login-card h1 { margin-top: 0; font-size: 1.4rem; }
.auth-brand {
    display: flex; align-items: center; gap: .65rem;
    margin-bottom: 1rem;
}
.auth-brand .brand-mark {
    width: 38px; height: 38px;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.05rem; font-weight: 700;
    box-shadow: var(--shadow-primary);
}
.auth-brand .brand-name { font-weight: 700; letter-spacing: -.01em; font-size: 1.1rem; }
.site-brand-logo {
    width: 190px; height: 72px;
    border-radius: 0;
    object-fit: contain;
    padding: 0;
    background: transparent;
    border: 0;
    box-shadow: none;
    flex: 0 0 auto;
}
.site-brand-logo-topbar {
    width: 136px; height: 44px;
}

/* Multi-select stylizzato */
select[multiple] { min-height: 140px; padding: .35rem; }
.chk-group { display: grid; grid-template-columns: 1fr; gap: .5rem; }
@media (min-width: 520px) { .chk-group { grid-template-columns: 1fr 1fr; } }
.chk-group > label {
    display: flex; align-items: center; gap: .55rem; min-height: 44px; margin: 0;
    padding: .35rem .65rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text); background: var(--surface);
    font-weight: 500;
    cursor: pointer;
    transition: background-color .15s ease, border-color .15s ease;
}
.chk-group > label:hover { background: var(--surface-2); }
.chk-group input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--primary); }
.chk-group > label:has(input:checked) {
    border-color: var(--primary);
    background: var(--primary-soft);
}

/* ---------- Agenda compact filters ---------- */
.compact-filters { padding: .85rem .9rem; }
.compact-filters .filter-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: .45rem .6rem;
}
.compact-filters .head {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: .55rem;
}
.compact-filters .head strong {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .07em;
    color: var(--text-soft); font-weight: 700;
}
.compact-filters .row { margin-bottom: 0; }
.compact-filters label { margin-bottom: .2rem; font-size: .78rem; }
.compact-filters input,
.compact-filters select { min-height: 40px; padding: .45rem .6rem; }
@media (min-width: 560px) {
    .compact-filters .filter-grid { grid-template-columns: repeat(3, 1fr); }
}

/* ---------- Slot picker ---------- */
.slot-toolbar {
    display: flex;
    gap: .4rem;
    align-items: center;
    margin-bottom: .65rem;
}
.slot-toolbar .day-input { flex: 1; }
.slot-meta { display: flex; justify-content: space-between; align-items: center; margin-bottom: .45rem; }
.slot-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: .5rem;
}
@media (min-width: 520px) {
    .slot-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 720px) {
    .slot-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
.slot-btn {
    min-height: var(--tap);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-strong);
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s ease, background-color .12s ease, border-color .12s ease, color .12s ease;
}
.slot-btn:hover { background: var(--surface-2); border-color: var(--primary); }
.slot-btn.selected {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-soft);
}
.slot-btn.occupied {
    background: var(--danger-soft);
    border-color: color-mix(in srgb, var(--danger) 30%, transparent);
    color: var(--danger);
    text-decoration: line-through;
    cursor: not-allowed;
}
.slot-grid.loading { opacity: .55; pointer-events: none; }

/* ---------- Business hours grid ---------- */
.hours-grid { display: grid; gap: .55rem; }

/* Layout "moderno" basato su 3 radio (mode): Eredita / Personalizza / Chiuso */
.hours-row.mode {
    display: grid;
    grid-template-columns: 1fr;
    gap: .55rem;
    padding: .7rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.hours-row.mode .hours-day { font-weight: 700; color: var(--text); display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.hours-row.mode .hours-tenant-hint { font-weight: 400; font-size: .82rem; }

/* Segmented control */
.hours-modes { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg {
    flex: 1 1 auto; min-width: 0;
    display: inline-flex; align-items: center; justify-content: center;
    padding: .5rem .7rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--surface);
    cursor: pointer; user-select: none;
    transition: background .12s ease, border-color .12s ease, color .12s ease;
    text-align: center;
}
.seg input[type=radio] { position: absolute; opacity: 0; pointer-events: none; }
.seg span { font-size: .87rem; color: var(--text-soft); white-space: nowrap; }
.seg:hover { background: var(--surface-2); }
.seg:has(input:checked) {
    background: var(--primary);
    border-color: var(--primary);
}
.seg:has(input:checked) span { color: var(--primary-text); font-weight: 600; }

/* Riga orari: visibile solo in modalità CUSTOM */
.hours-times { display: none; flex-direction: column; gap: .5rem; }
.hours-row.mode.is-custom .hours-times { display: flex; }
.hours-row.mode.is-closed .hours-times,
.hours-row.mode.is-inherit .hours-times { display: none; }

.hours-row-times { display: flex; align-items: center; gap: .4rem; }
.hours-row-times input[type=time] {
    flex: 1 1 0; min-width: 0; min-height: 38px;
    padding: .35rem .5rem; background: var(--surface);
}
.hours-sep { color: var(--text-muted); font-weight: 600; }

/* Selettore pausa pranzo */
.hours-break-modes { display: flex; gap: .35rem; flex-wrap: wrap; }
.seg-sm { padding: .35rem .65rem; }
.seg-sm span { font-size: .8rem; }

.hours-break {
    display: none;
    align-items: center; gap: .4rem;
    padding: .45rem .55rem;
    border: 1px dashed var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
}
.hours-row.mode.is-custom.has-break .hours-break { display: flex; }
.hours-break .break-label {
    font-size: .8rem; color: var(--text-soft); font-weight: 600;
    flex: 0 0 auto; padding-right: .25rem;
}
.hours-break input[type=time] {
    flex: 1 1 0; min-width: 0; min-height: 36px;
    padding: .3rem .5rem; background: var(--surface-2);
}

@media (min-width: 720px) {
    .hours-row.mode {
        grid-template-columns: 200px 1fr 320px;
        align-items: start;
        gap: .9rem;
    }
}

/* ---------- Periodi ferie operatore ---------- */
.timeoff-form { margin-bottom: .75rem; }
.timeoff-list { list-style: none; padding: 0; margin: .85rem 0 0; display: grid; gap: .45rem; }
.timeoff-item {
    display: flex; justify-content: space-between; align-items: center; gap: .6rem;
    padding: .6rem .75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-2);
}
.timeoff-info { display: flex; flex-direction: column; }
.timeoff-info strong { color: var(--text); }

/* Reduce motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ========================================================
   Public booking page (self-service, mobile-first)
   ======================================================== */
.public-body { background: var(--bg); }
.public-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 10;
}
.public-header-inner {
    max-width: 720px; margin: 0 auto;
    display: flex; align-items: center; gap: .8rem;
    padding: .75rem 1rem;
}
.public-mark {
    width: 38px; height: 38px;
    background: var(--primary); color: var(--primary-text);
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.05rem;
}
.public-header-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.public-header-text strong { color: var(--text); font-size: 1rem; }
.public-header-text .subtle { font-size: .78rem; }
.public-map-link { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.public-map-link:hover { color: var(--primary); text-decoration: underline; }
.public-main { max-width: 720px; margin: 0 auto; padding: 1rem; }
.public-footer { text-align: center; padding: 1.5rem 1rem 2.5rem; }

/* Stepper */
.wiz-steps {
    list-style: none; padding: 0; margin: 0 0 1rem;
    display: grid; grid-template-columns: repeat(4, 1fr);
    gap: .35rem;
}
.wiz-steps li {
    display: flex; flex-direction: column; align-items: center; gap: .25rem;
    color: var(--text-muted); font-size: .72rem;
    padding-top: .35rem;
    border-top: 3px solid var(--border);
    text-align: center;
}
.wiz-steps li span {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--surface-2); color: var(--text-soft);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .8rem; margin-top: -16px;
    border: 2px solid var(--bg);
}
.wiz-steps li em { font-style: normal; }
.wiz-steps li.active { color: var(--primary); border-top-color: var(--primary); }
.wiz-steps li.active span { background: var(--primary); color: var(--primary-text); }
.wiz-steps li.done    { color: var(--text-soft); border-top-color: var(--primary); }
.wiz-steps li.done span { background: var(--primary); color: var(--primary-text); }
@media (max-width: 480px) { .wiz-steps li em { display: none; } }

.wiz-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 1rem 1.1rem;
    margin-bottom: .85rem;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.wiz-card.text-center { text-align: center; }
.wiz-card h2 { margin: .25rem 0 .35rem; font-size: 1.2rem; }
.wiz-back {
    display: inline-block; font-size: .85rem; color: var(--text-soft);
    margin-bottom: .35rem; text-decoration: none;
}
.wiz-back:hover { color: var(--primary); }
.wiz-empty { text-align: center; padding: 1.5rem 1rem; }
.wiz-empty p { margin: .25rem 0; }

/* Pick cards (servizio / operatore) */
.pick-grid { display: grid; gap: .55rem; }
.pick-card {
    display: flex; align-items: center; gap: .85rem;
    padding: .9rem 1rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); text-decoration: none;
    color: var(--text);
    transition: transform .12s ease, border-color .12s ease, box-shadow .12s ease;
    box-shadow: 0 1px 2px rgba(0,0,0,.03);
}
.pick-card:hover { border-color: var(--primary); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(110,86,247,.12); }
.pick-card-main { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: .15rem; }
.pick-card-main strong { color: var(--text); }
.pick-card-meta { display: flex; flex-direction: column; align-items: flex-end; gap: .25rem; }
.pick-card-meta .badge {
    font-size: .72rem; padding: .15rem .5rem;
    background: var(--surface-2); color: var(--text-soft); border-radius: 999px;
}
.pick-card-meta .price { font-weight: 700; color: var(--text); }
.pick-card .chev { font-size: 1.4rem; color: var(--text-muted); }

.staff-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #9b88ff);
    color: var(--primary-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem; flex: 0 0 auto;
}

/* Day strip orizzontale scorrevole */
.day-strip {
    display: flex; gap: .4rem; overflow-x: auto;
    padding: .5rem 1rem .75rem;
    margin: 0 -1rem;
    scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.day-strip::-webkit-scrollbar { display: none; }
.day-chip {
    flex: 0 0 auto; scroll-snap-align: start;
    width: 60px; min-height: 76px;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: .1rem; text-decoration: none;
    padding: .5rem .25rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 14px; color: var(--text-soft);
    position: relative;
    transition: background .12s ease, border-color .12s ease, color .12s ease, transform .12s ease;
}
.day-chip:hover { border-color: var(--primary); color: var(--text); }
.day-chip .d-name { font-size: .65rem; font-weight: 700; letter-spacing: .04em; }
.day-chip .d-num  { font-size: 1.25rem; font-weight: 700; color: var(--text); line-height: 1; }
.day-chip .d-mon  { font-size: .62rem; color: var(--text-muted); letter-spacing: .04em; }
.day-chip .d-dot  {
    position: absolute; bottom: 6px; width: 5px; height: 5px;
    background: var(--primary); border-radius: 50%;
}
.day-chip.is-selected {
    background: var(--primary); border-color: var(--primary); color: var(--primary-text);
}
.day-chip.is-selected .d-num,
.day-chip.is-selected .d-mon { color: var(--primary-text); }
.day-chip.is-selected .d-dot { background: var(--primary-text); }
.day-chip.is-empty { opacity: .55; }

/* Slot pill grid (pagina pubblica) */
.public-slot-grid {
    display: grid; gap: .45rem;
    grid-template-columns: repeat(auto-fill, minmax(82px, 1fr));
    margin-top: .25rem;
}
.slot-pill {
    text-align: center; padding: .65rem .35rem;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: 999px; text-decoration: none;
    color: var(--text); font-weight: 600; font-size: .92rem;
    transition: background .12s ease, border-color .12s ease, color .12s ease, transform .12s ease;
}
.slot-pill:hover {
    background: var(--primary); color: var(--primary-text);
    border-color: var(--primary); transform: translateY(-1px);
}

/* Summary box */
.summary-box {
    display: grid; gap: .55rem;
    padding: .75rem .85rem;
    background: var(--surface-2);
    border-radius: var(--radius-sm);
    margin-top: .5rem;
}
.summary-box > div { display: flex; flex-direction: column; gap: .1rem; line-height: 1.25; }
.summary-box .subtle { font-size: .72rem; text-transform: uppercase; letter-spacing: .05em; }

/* Confirm tick */
.confirm-tick {
    width: 64px; height: 64px; border-radius: 50%;
    background: var(--primary); color: var(--primary-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.7rem; margin-bottom: .5rem;
    box-shadow: 0 8px 24px rgba(110,86,247,.35);
}

/* ---------- Brand logo come immagine ---------- */
.brand-logo-img {
    width: 30px; height: 30px;
    border-radius: 9px;
    object-fit: cover;
    box-shadow: var(--shadow-primary);
    flex: 0 0 auto;
}
.public-logo-img {
    width: 38px; height: 38px;
    border-radius: 12px;
    object-fit: cover;
    box-shadow: var(--shadow-sm);
    flex: 0 0 auto;
}

/* ---------- Avatar in lista operatori ---------- */
.list-avatar {
    width: 44px; height: 44px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #9b88ff);
    color: var(--primary-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .9rem; flex: 0 0 auto;
    overflow: hidden;
}
.list-avatar img {
    width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
}

/* ---------- Avatar upload row (operatori + impostazioni) ---------- */
.avatar-upload-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-top: .65rem;
}
.avatar-preview {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, #9b88ff, var(--primary));
    color: var(--primary-text);
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 1.4rem;
    overflow: hidden; flex: 0 0 auto;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-sm);
}
.avatar-preview img {
    width: 80px; height: 80px; object-fit: cover; border-radius: 50%;
}
.avatar-preview.large {
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--primary), var(--accent));
}
.avatar-preview.large img {
    border-radius: var(--radius-sm);
}

/* ---------- QR section ---------- */
.qr-section {
    display: flex;
    gap: 1.2rem;
    align-items: flex-start;
    flex-wrap: wrap;
    margin-top: .65rem;
}
.qr-preview { flex: 0 0 auto; }
.qr-actions { flex: 1 1 200px; padding-top: .25rem; }

/* ---------- Agenda: customer link & contact icons ---------- */
a.customer-link {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
a.customer-link:hover { text-decoration: underline; }

.contact-icons {
    display: inline-flex;
    align-items: center;
    gap: .3rem;
    margin-left: .35rem;
    vertical-align: middle;
}
a.contact-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    text-decoration: none;
    transition: background .15s, color .15s;
    color: var(--text-soft);
    background: transparent;
}
a.contact-icon:hover { background: var(--surface-3); }
a.contact-icon.whatsapp:hover { color: #25d366; }
a.contact-icon.email:hover    { color: var(--primary); }
a.contact-icon.phone:hover    { color: var(--accent); }

/* ── Toolbar agenda ─────────────────────────────────────────── */
.agenda-toolbar {
    display: flex;
    gap: .5rem;
    justify-content: flex-end;
    margin-bottom: .75rem;
}

/* ── Calendario mensile ─────────────────────────────────────── */
.cal-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 1px;
    background: var(--border);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    margin-bottom: 1rem;
    box-shadow: var(--shadow);
}
.cal-head {
    background: var(--surface-2);
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    padding: .65rem 0;
    color: var(--text-soft);
}
.cal-head.cal-weekend { color: var(--accent); }
.cal-cell {
    background: var(--surface);
    min-height: 110px;
    padding: .42rem .42rem .3rem;
    position: relative;
    transition: background .14s;
}
.cal-cell:hover { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.cal-cell:hover .cal-cell-add { opacity: 1; }
.cal-cell.cal-out { background: var(--surface-2); opacity: .42; pointer-events: none; }
.cal-cell.cal-weekend:not(.cal-today):not(.cal-out) {
    background: color-mix(in srgb, var(--surface-2) 60%, var(--surface));
}
.cal-cell.cal-today { background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.cal-day-num {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: .3rem;
    min-height: 24px;
}
.cal-day-num a {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-soft);
    text-decoration: none;
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
    transition: background .12s, color .12s;
}
.cal-day-num a:hover { background: var(--surface-3); color: var(--primary); }
.cal-today .cal-day-num a { background: var(--primary); color: #fff; font-weight: 800; }
.cal-cell-add {
    opacity: 0;
    font-size: .85rem;
    color: var(--text-soft);
    text-decoration: none;
    width: 22px; height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background .12s, color .12s, opacity .15s;
    font-weight: 400;
    line-height: 1;
}
.cal-cell-add:hover { background: var(--primary); color: #fff; opacity: 1 !important; }
.cal-events { display: flex; flex-direction: column; gap: 2px; }
.cal-event {
    display: block;
    font-size: .71rem;
    border-radius: 5px;
    padding: .2rem .4rem .2rem .5rem;
    background: color-mix(in srgb, var(--primary) 9%, var(--surface));
    color: var(--text);
    border: 1px solid color-mix(in srgb, var(--primary) 14%, transparent);
    border-left: 3px solid var(--primary);
    overflow: hidden;
    cursor: pointer;
    text-decoration: none;
    transition: transform .1s, filter .1s;
}
.cal-event:hover { transform: translateX(2px); filter: brightness(.96); }
.cal-event.cal-event-done {
    background: color-mix(in srgb, var(--ok) 9%, var(--surface));
    border-color: color-mix(in srgb, var(--ok) 18%, transparent);
    border-left-color: var(--ok);
}
.cal-event.cal-event-cancelled {
    background: var(--surface-2);
    border-color: transparent;
    border-left-color: var(--border);
    color: var(--text-soft);
    text-decoration: line-through;
    opacity: .65;
}
.cal-event-row {
    display: flex;
    align-items: center;
    gap: 3px;
    overflow: hidden;
}
.cal-event-time {
    font-weight: 700;
    flex-shrink: 0;
    font-size: .67rem;
    opacity: .75;
}
.cal-event-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    font-weight: 600;
}
.cal-event-service {
    display: block;
    font-size: .62rem;
    color: var(--text-soft);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 1px;
}
.cal-event-more {
    display: block;
    font-size: .67rem;
    color: var(--primary);
    font-weight: 600;
    padding: .05rem .4rem;
    text-decoration: none;
    opacity: .85;
    margin-top: 1px;
}
.cal-event-more:hover { opacity: 1; text-decoration: underline; }
.cal-legend { display: none; gap: .75rem; font-size: .8rem; margin-top: .5rem; }

/* ── Stampa ──────────────────────────────────────────────────── */
@media print {
    .no-print,
    .topbar,
    .sidebar,
    .fab,
    .daynav,
    .compact-filters,
    .agenda-toolbar { display: none !important; }

    body, section { padding: 0 !important; margin: 0 !important; }

    .cal-grid { border: 1px solid #ccc; }
    .cal-head { background: #f0f0f0 !important; -webkit-print-color-adjust: exact; }
    .cal-cell { min-height: 70px; break-inside: avoid; }
    .cal-event { -webkit-print-color-adjust: exact; }

    .list li { break-inside: avoid; border-bottom: 1px solid #eee; }
    .actions { display: none !important; }

    .cal-legend { display: flex !important; }
    .print-only { display: flex !important; }
}
.print-only { display: none; }

/* ==========================================================================
   UI v3 · Redesign moderno pagine interne e booking pubblico
   ========================================================================== */
:root {
    --bg: #f7f9ff;
    --bg-grad-1: rgba(109, 93, 252, .20);
    --bg-grad-2: rgba(6, 182, 212, .16);
    --surface: rgba(255, 255, 255, .92);
    --surface-1: #ffffff;
    --surface-2: #f4f7ff;
    --surface-3: #e9eefc;
    --text: #101828;
    --text-main: var(--text);
    --text-soft: #5f6f89;
    --text-muted: #8a97ad;
    --border: rgba(226, 232, 240, .92);
    --border-strong: #cbd5e1;
    --primary: #6d5dfc;
    --primary-hover: #4f46e5;
    --primary-soft: rgba(109, 93, 252, .12);
    --accent: #06b6d4;
    --accent-soft: rgba(6, 182, 212, .14);
    --ok: #16a34a;
    --danger: #ef4444;
    --danger-soft: rgba(239, 68, 68, .12);
    --warn: #f59e0b;
    --warn-soft: rgba(245, 158, 11, .14);
    --info: #2563eb;
    --info-soft: rgba(37, 99, 235, .12);
    --radius: 22px;
    --radius-sm: 14px;
    --shadow-sm: 0 10px 28px rgba(15, 23, 42, .055);
    --shadow: 0 18px 46px rgba(15, 23, 42, .075);
    --shadow-lg: 0 30px 90px rgba(79, 70, 229, .17), 0 14px 38px rgba(15, 23, 42, .08);
    --shadow-primary: 0 18px 34px rgba(79, 70, 229, .27);
    --topbar-h: 74px;
    --tabbar-h: 72px;
}

[data-theme="dark"] {
    --bg: #080c16;
    --bg-grad-1: rgba(109, 93, 252, .28);
    --bg-grad-2: rgba(6, 182, 212, .18);
    --surface: rgba(17, 24, 39, .88);
    --surface-1: #101827;
    --surface-2: #151f32;
    --surface-3: #1f2a44;
    --text: #f8fafc;
    --text-main: var(--text);
    --text-soft: #cbd5e1;
    --text-muted: #94a3b8;
    --border: rgba(51, 65, 85, .86);
    --border-strong: #475569;
    --primary: #8b7cff;
    --primary-hover: #a79bff;
    --primary-soft: rgba(139, 124, 255, .18);
    --accent: #22d3ee;
    --accent-soft: rgba(34, 211, 238, .14);
    --shadow-sm: 0 10px 28px rgba(0, 0, 0, .30);
    --shadow: 0 18px 46px rgba(0, 0, 0, .38);
    --shadow-lg: 0 30px 90px rgba(0, 0, 0, .55);
}

body {
    background:
        radial-gradient(900px 420px at 94% -12%, var(--bg-grad-1), transparent 66%),
        radial-gradient(780px 380px at 0% 0%, var(--bg-grad-2), transparent 62%),
        linear-gradient(180deg, var(--bg), color-mix(in srgb, var(--bg) 88%, #ffffff 12%));
    color: var(--text);
    font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}
body:not(.app-shell) { padding-bottom: 0; }
body.app-shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 5rem); }
a { transition: color .15s ease, background-color .15s ease, border-color .15s ease, transform .15s ease; }

/* App shell */
.topbar {
    min-height: var(--topbar-h);
    margin: .75rem .75rem 0;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface) 88%, transparent);
    box-shadow: var(--shadow-sm);
}
.topbar .brand-mark,
.auth-brand .brand-mark,
.public-mark {
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: var(--shadow-primary);
}
.topbar h1 {
    color: var(--text);
    font-size: clamp(1.05rem, 2vw, 1.35rem);
    font-weight: 800;
    letter-spacing: -.035em;
}
.topbar-user {
    background: var(--surface-2);
    border-color: var(--border);
    color: var(--text-soft);
}
.theme-toggle {
    border-color: transparent;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
}

main {
    width: min(1120px, calc(100% - 1.5rem));
    max-width: none;
    padding: 1.2rem 0;
}
section { animation: pageFadeIn .24s ease both; }
@keyframes pageFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards, dashboard, liste */
.card,
.kpi,
.list > li,
.daynav,
.wiz-card,
.pick-card,
.empty {
    border-color: var(--border);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.card { padding: clamp(1rem, 2vw, 1.45rem); }
.card-title {
    color: var(--primary);
    font-weight: 900;
    letter-spacing: .11em;
}
.card h2 { color: var(--text); font-size: clamp(1.15rem, 2vw, 1.45rem); font-weight: 800; letter-spacing: -.035em; }
.hero {
    min-height: 170px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-color: color-mix(in srgb, var(--primary) 24%, var(--border));
    background:
        radial-gradient(520px 240px at 92% 0%, color-mix(in srgb, var(--primary) 22%, transparent), transparent 72%),
        radial-gradient(420px 230px at 0% 100%, color-mix(in srgb, var(--accent) 18%, transparent), transparent 70%),
        linear-gradient(135deg, var(--surface), var(--surface-2));
}
.hero::after {
    content: "";
    position: absolute;
    width: 170px; height: 170px;
    right: -50px; bottom: -70px;
    border-radius: 48px;
    background: linear-gradient(135deg, color-mix(in srgb, var(--primary) 26%, transparent), color-mix(in srgb, var(--accent) 20%, transparent));
    transform: rotate(18deg);
}
.hero h2 { font-size: clamp(1.45rem, 4vw, 2.25rem); letter-spacing: -.055em; }
.subscription-details {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(230px, 1fr));
    gap: .75rem;
}
.subscription-detail {
    min-height: 92px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface-2);
    padding: .9rem 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: .55rem;
}
.subscription-detail span {
    color: var(--text-soft);
    font-size: .72rem;
    font-weight: 900;
    letter-spacing: .08em;
    text-transform: uppercase;
}
.subscription-detail strong {
    color: var(--text);
    font-size: 1rem;
    font-weight: 800;
    line-height: 1.25;
    overflow-wrap: anywhere;
}
.subscription-detail.technical strong {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: .82rem;
    font-weight: 700;
}
.kpis { gap: .85rem; }
.kpi {
    border-radius: 20px;
    padding: 1rem;
}
.kpi::before {
    inset: auto 1rem 1rem auto;
    width: 38px;
    height: 38px;
    border-radius: 14px;
    opacity: .13;
}
.kpi .label { font-size: .72rem; font-weight: 900; letter-spacing: .08em; }
.kpi .value { font-size: clamp(1.85rem, 5vw, 2.35rem); font-weight: 900; }

/* Buttons e input */
.btn {
    border-radius: 999px;
    border-color: transparent;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
    font-weight: 800;
}
.btn:hover { box-shadow: inset 0 0 0 1px var(--border-strong), var(--shadow-sm); }
.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    border-color: transparent;
    box-shadow: var(--shadow-primary);
}
.btn-danger { background: var(--danger-soft); border-color: transparent; box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 24%, transparent); }
.btn-ghost { box-shadow: none; }
.btn-icon { width: 42px; }
.fab {
    width: 62px; height: 62px;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    box-shadow: 0 22px 44px rgba(79, 70, 229, .34);
}
form input[type=text], form input[type=email], form input[type=tel],
form input[type=password], form input[type=number], form input[type=datetime-local],
form input[type=date], form input[type=time], form input[type=url],
form input[type=search], form textarea, form select {
    border-color: transparent;
    border-radius: 16px;
    background: color-mix(in srgb, var(--surface-2) 86%, var(--surface) 14%);
    box-shadow: inset 0 0 0 1px var(--border);
}
form input:focus, form textarea:focus, form select:focus {
    border-color: transparent;
    box-shadow: inset 0 0 0 1px var(--primary), 0 0 0 4px var(--primary-soft);
}
form label { color: var(--text-soft); font-weight: 800; }
.check,
.chk-group > label,
.hours-row.mode,
.timeoff-item { border-color: var(--border); background: var(--surface-2); }

.search-bar {
    padding: .55rem;
    border: 1px solid var(--border);
    border-radius: 24px;
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.search-bar .btn { flex: 0 0 auto; }
.list { display: grid; gap: .75rem; }
.list > li {
    margin-bottom: 0;
    border-radius: 22px;
    padding: 1rem;
}
.list > li:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.list .primary { font-size: 1.05rem; font-weight: 850; color: var(--text); }
.list .actions form { margin: 0; }
.badge { border: 1px solid color-mix(in srgb, currentColor 18%, transparent); }
.empty {
    border-style: solid;
    padding: 3rem 1rem;
    color: var(--text-soft);
}
.empty::before {
    content: "◇";
    display: block;
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: .35rem;
}

/* Agenda */
.compact-filters .head strong { color: var(--primary); font-weight: 900; }
.daynav { border-radius: 999px; padding: .55rem; }
.daynav .date { color: var(--text); }
.agenda-toolbar { gap: .55rem; }
.slot-grid { gap: .6rem; }
.slot-btn {
    border-radius: 999px;
    border-color: transparent;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
}
.slot-btn:hover { transform: translateY(-1px); box-shadow: inset 0 0 0 1px var(--primary), var(--shadow-sm); }
.slot-btn.selected {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--primary-text);
    box-shadow: var(--shadow-primary);
}
.slot-btn.occupied { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--danger) 30%, transparent); }
.contact-icons { gap: .4rem; }
a.contact-icon {
    width: 32px; height: 32px;
    background: var(--surface-2);
    box-shadow: inset 0 0 0 1px var(--border);
}


/* Login, errori, booking pubblico */
.auth-wrap, .login-wrap {
    background:
        radial-gradient(820px 430px at 88% -10%, var(--bg-grad-1), transparent 64%),
        radial-gradient(760px 420px at 8% 105%, var(--bg-grad-2), transparent 62%),
        var(--bg);
}
.auth-card, .login-card {
    max-width: 440px;
    border-radius: 30px;
    background: var(--surface);
    box-shadow: var(--shadow-lg);
}
.login-card h1 { font-size: 1.85rem; font-weight: 900; letter-spacing: -.055em; }
.public-body {
    background:
        radial-gradient(780px 360px at 100% -10%, var(--bg-grad-1), transparent 62%),
        radial-gradient(680px 360px at 0% 0%, var(--bg-grad-2), transparent 60%),
        var(--bg);
}
.public-header {
    margin: .75rem auto 0;
    width: min(720px, calc(100% - 1.5rem));
    border: 1px solid var(--border);
    border-radius: 24px;
    background: color-mix(in srgb, var(--surface) 90%, transparent);
    box-shadow: var(--shadow-sm);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}
.public-main { padding-top: 1.2rem; }
.wiz-card { border-radius: 26px; padding: 1.25rem; }
.wiz-steps { gap: .55rem; }
.wiz-steps li { border-top-width: 4px; font-weight: 800; }
.wiz-steps li span { box-shadow: 0 0 0 4px var(--bg); }
.pick-card { border-radius: 22px; box-shadow: var(--shadow-sm); }
.pick-card:hover { box-shadow: var(--shadow); }
.staff-avatar,
.list-avatar,
.avatar-preview { background: linear-gradient(135deg, var(--primary), var(--accent)); box-shadow: var(--shadow-sm); }
.day-chip { border-radius: 18px; background: var(--surface); box-shadow: var(--shadow-sm); }
.day-chip.is-selected,
.slot-pill:hover,
.confirm-tick { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); }
.slot-pill { box-shadow: inset 0 0 0 1px var(--border); border-color: transparent; background: var(--surface); }
.summary-box { border: 1px solid var(--border); background: var(--surface-2); }

/* Desktop: rail laterale professionale */
@media (min-width: 960px) {
    body.app-shell { padding: 0 0 0 112px; }
    .topbar { margin: 1rem 1.25rem 0; }
    main { width: min(1120px, calc(100% - 2.5rem)); padding: 1.35rem 0 2rem; }
    .tabbar {
        top: 1rem;
        bottom: 1rem;
        left: 1rem;
        right: auto;
        width: 82px;
        border: 1px solid var(--border);
        border-radius: 30px;
        flex-direction: column;
        gap: .35rem;
        padding: .6rem;
        background: color-mix(in srgb, var(--surface) 86%, transparent);
        box-shadow: var(--shadow);
    }
    .tabbar a {
        flex: 0 0 auto;
        min-height: 72px;
        border-radius: 22px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: .28rem;
        font-size: .68rem;
    }
    .tabbar a.active { background: linear-gradient(135deg, var(--primary), var(--primary-hover)); color: var(--primary-text); box-shadow: var(--shadow-primary); }
    .tabbar a.active .icon { color: var(--primary-text); }
    .kpis { grid-template-columns: repeat(6, 1fr); }
    .list .actions { min-width: max-content; }
}

/* Mobile refinements */
@media (max-width: 720px) {
    body.app-shell { padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 5rem); }
    .topbar {
        margin: .55rem .55rem 0;
        min-height: 62px;
        border-radius: 22px;
        padding: .45rem .55rem;
        padding-top: calc(.45rem + env(safe-area-inset-top));
    }
    .topbar h1 { font-size: 1.02rem; }
    .topbar .right { gap: .25rem; }
    .topbar .btn-sm { min-height: 34px; padding: 0 .65rem; }
    main { width: min(100% - 1rem, 1120px); padding: .85rem 0; }
    .hero { min-height: 150px; }
    .kpis { grid-template-columns: repeat(2, 1fr); }
    .btn-row .btn { flex-basis: 100%; }
    .search-bar { flex-direction: column; }
    .search-bar .btn { width: 100%; }
    .list > li { align-items: stretch; }
    .list .actions { width: 100%; }
    .list .actions .btn,
    .list .actions form,
    .list .actions button { width: 100%; }
    .daynav { border-radius: 22px; align-items: stretch; }
    .daynav form { flex-wrap: wrap; }
    .daynav .day-input { min-width: 0; }
    .agenda-toolbar { justify-content: stretch; }
    .agenda-toolbar .btn { flex: 1; }
    .slot-toolbar { flex-wrap: wrap; }
    .slot-toolbar .day-input { flex-basis: 100%; order: -1; }
    .slot-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .cal-grid { border-radius: 12px; overflow: hidden; grid-template-columns: repeat(7, minmax(0, 1fr)); }
    .cal-cell { min-height: 54px; padding: .1rem .08rem; }
    .cal-cell-add { display: none !important; }
    .cal-cell.cal-weekend:not(.cal-today):not(.cal-out) { background: var(--surface); }
    .cal-event { font-size: .55rem; padding: 1px 2px 1px 4px; border-left-width: 2px; transition: none; }
    .cal-event:hover { transform: none; filter: none; }
    .cal-event-service { display: none !important; }
    .cal-event-more { font-size: .55rem; padding: 0 2px; }
    .cal-event-row { gap: 1px; }
    .cal-event-time { font-size: .54rem; }
    .cal-head { font-size: .6rem; padding: .28rem 0; letter-spacing: 0; }
    .cal-day-num { margin-bottom: .08rem; min-height: 16px; }
    .cal-day-num a { width: 16px; height: 16px; font-size: .65rem; }
    .public-header { width: calc(100% - 1rem); margin-top: .55rem; }
    .public-main { padding: .85rem .5rem; }
}

/* ---------- Wizard di prima configurazione (barra in alto) ---------- */
.wizard-bar {
    background: linear-gradient(135deg, var(--primary-soft), color-mix(in srgb, var(--accent-soft) 70%, transparent));
    border: 1px solid color-mix(in srgb, var(--primary) 25%, transparent);
    border-radius: var(--radius);
    padding: .9rem 1rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}
.wizard-bar.wizard-bar-done {
    background: linear-gradient(135deg, var(--accent-soft), var(--primary-soft));
    border-color: color-mix(in srgb, var(--accent) 35%, transparent);
}
.wizard-bar-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: .8rem;
    flex-wrap: wrap;
}
.wizard-bar-title {
    font-weight: 700;
    color: var(--primary);
    font-size: .95rem;
}
.wizard-bar.wizard-bar-done .wizard-bar-title { color: var(--accent); }
.wizard-bar-sub { font-size: .85rem; color: var(--text-soft); margin-top: .1rem; }
.wizard-bar-actions { display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.wizard-bar-progress {
    background: color-mix(in srgb, var(--surface-2) 80%, transparent);
    border-radius: 999px;
    height: 8px;
    overflow: hidden;
    margin: .7rem 0 .55rem;
}
.wizard-bar-progress-fill {
    height: 100%;
    background: linear-gradient(135deg, var(--primary), var(--accent));
    border-radius: 999px;
    transition: width .4s ease;
}
.wizard-bar-steps {
    display: flex;
    gap: .35rem;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.wizard-bar-steps > span {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    padding: .25rem .55rem;
    border-radius: 999px;
    background: var(--surface);
    border: 1px solid var(--border);
}
.wizard-bar-steps .dot {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--surface-3);
    color: var(--text-muted);
    font-weight: 800;
    font-size: .72rem;
}
.wizard-bar-steps > span.current {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-soft);
}
.wizard-bar-steps > span.current .dot {
    background: var(--primary);
    color: var(--primary-text);
}
.wizard-bar-steps > span.done {
    color: var(--accent);
    border-color: color-mix(in srgb, var(--accent) 40%, transparent);
    background: var(--accent-soft);
}
.wizard-bar-steps > span.done .dot { background: var(--accent); color: #fff; }
.wizard-bar-steps > span.done .dot::before { content: "✓"; }
.wizard-bar-steps > span.done .dot { font-size: 0; }
.wizard-bar-steps > span.done .dot::before { font-size: .8rem; }

/* ---------- Tabbar SVG icon rules ---------- */
.tabbar a .icon {
    width: 24px;
    height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto .16rem;
    color: currentColor;
}
.tabbar a .icon svg {
    width: 23px;
    height: 23px;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ---------- Tabbar: scroll orizzontale su mobile quando ci sono molte voci ---------- */
@media (max-width: 720px) {
    .tabbar {
        overflow-x: auto;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .tabbar::-webkit-scrollbar { display: none; }
    .tabbar a {
        flex: 0 0 auto;
        min-width: 64px;
    }
}
