*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,sans-serif;background:#f3f4fa;color:#14183a;line-height:1.5}
header{background:#fff;border-bottom:4px solid #1426a8;padding:.5rem 1rem;display:flex;justify-content:space-between;align-items:center}
header a{color:#1426a8;text-decoration:none;font-weight:600}
header img{height:48px;display:block}
main{max-width:640px;margin:1.5rem auto;padding:0 1rem}
.card{background:#fff;border-radius:10px;padding:1.25rem;box-shadow:0 1px 3px rgba(0,0,0,.08);margin-bottom:1rem}
label{display:block;margin:.75rem 0 .25rem;font-weight:600;font-size:.9rem}
input,textarea{width:100%;padding:.65rem;border:1px solid #b9bde0;border-radius:6px;font:inherit}
textarea{min-height:110px;resize:vertical}
button{margin-top:1rem;padding:.7rem 1.2rem;border:0;border-radius:8px;background:#3d72d4;color:#fff;font:inherit;font-weight:600;cursor:pointer}
button.secondary{background:#e4e6f6;color:#14183a}
.tabs{display:flex;gap:.5rem;margin-bottom:.5rem}
.msg{margin-top:.75rem;min-height:1.2em;font-size:.9rem}
.msg.err{color:#b3261e}.msg.ok{color:#1426a8}
.hidden{display:none !important}
@media(min-width:900px){main{max-width:820px}}

:root{--brand:#1426a8;--accent:#3d72d4;--chip:#dbe6fb;--chip-text:#1f4fb5;--green:#d4ecd2;--green-text:#2f6b2a;--amber:#f6e0b0;--amber-text:#7a5200}
.muted{color:#5b6090;margin:.25rem 0}
.person{display:flex;gap:.9rem;align-items:center;margin-bottom:.5rem}
.avatar{flex:0 0 52px;height:52px;border-radius:50%;background:var(--chip);color:var(--chip-text);display:flex;align-items:center;justify-content:center;font-weight:700;font-size:1.1rem}
.person h2,.person h3,.person p{margin:0}
.days{display:flex;gap:.4rem;overflow-x:auto;padding-bottom:.4rem}
button.day,button.slot{margin:0;background:#fff;color:#14183a;border:1px solid #d5d8ee;font-weight:500}
button.day{display:flex;flex-direction:column;align-items:center;min-width:56px;padding:.5rem .4rem;flex:0 0 auto}
.slots{display:grid;grid-template-columns:repeat(3,1fr);gap:.5rem}
button.slot{padding:.7rem .2rem}
button.sel{background:var(--chip);color:var(--chip-text);border-color:var(--chip-text)}
button:disabled{opacity:.45;cursor:not-allowed;text-decoration:line-through;background:#f1f2f8}
button.cta{width:100%;padding:.9rem;font-size:1.05rem}
button.cta:disabled{text-decoration:none;background:#9db7e6;opacity:1}
.note{text-align:center;color:#5b6090;font-size:.9rem;margin:.6rem 0 0}
.sheet-bg{position:fixed;inset:0;background:rgba(20,24,58,.45);display:flex;align-items:flex-end;justify-content:center;z-index:10}
.sheet{background:#fff;width:100%;max-width:520px;border-radius:16px 16px 0 0;padding:1.25rem;max-height:92vh;overflow:auto}
.sheet .row{display:flex;gap:.5rem}.sheet .row button{flex:1}
.hp{position:absolute;left:-9999px;height:0;overflow:hidden}
@media(min-width:600px){.sheet-bg{align-items:center}.sheet{border-radius:16px}}

/* ---- pannello nutrizionista ---- */
.panel{display:flex;flex-direction:column;max-width:1100px;margin:0 auto;min-height:calc(100vh - 70px)}
.side{display:flex;gap:.25rem;overflow-x:auto;padding:.5rem;background:#fff;border-bottom:1px solid #e1e3f3}
.side a,.side .soon{padding:.6rem .9rem;border-radius:8px;text-decoration:none;color:#14183a;white-space:nowrap;font-weight:500}
.side a.active{background:var(--chip);color:var(--chip-text)}
.side .soon{color:#9aa0c7;cursor:not-allowed}.side .soon small{font-size:.7rem;margin-left:.2rem}
.badge{display:inline-block;min-width:1.4em;padding:0 .4em;border-radius:1em;background:var(--accent);color:#fff;font-size:.75rem;text-align:center}
.content{flex:1;padding:1rem}
.content h2{margin-top:.2rem}
.req{background:#fff;border:1px solid #e1e3f3;border-radius:10px;padding:.8rem 1rem;margin-bottom:.6rem}
.req-top{display:flex;justify-content:space-between;gap:.5rem;flex-wrap:wrap}
.req .muted a{color:var(--accent)}
.actions{display:flex;gap:.5rem;margin-top:.6rem}
button.chip-btn{margin:0;padding:.4rem 1rem;border:1px solid #c9cdea;border-radius:999px;background:#fff;color:#14183a}
button.chip-btn.primary{background:var(--chip);color:var(--chip-text);border-color:var(--chip)}
button.chip-btn:disabled{text-decoration:none}
.tag{display:inline-block;margin-top:.4rem;padding:.1rem .6rem;border-radius:999px;font-size:.8rem}
.tag.confirmed{background:var(--chip);color:var(--chip-text)}
.tag.pending{background:var(--amber);color:var(--amber-text)}
.tag.rejected{background:#f3dada;color:#8a2a2a}
.agenda-head{display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:.8rem}
.agenda-head h2{font-size:1.05rem}
.week{display:grid;grid-template-columns:repeat(7,1fr);gap:.4rem;margin-bottom:1rem}
.day-cell{background:#fff;border:1px solid #e1e3f3;border-radius:10px;padding:.5rem;text-align:center;font-size:.85rem}
.day-cell.today{border-color:var(--accent)}
.day-cell .dn{font-weight:600;margin-bottom:.35rem}
.pill{display:block;margin:.15rem 0;padding:.2rem .3rem;border-radius:8px;font-size:.8rem}
.pill.free{background:var(--green);color:var(--green-text)}
.pill.visits{background:var(--chip);color:var(--chip-text)}
.pill.wait{background:var(--amber);color:var(--amber-text)}
.pill.closed{background:#eceef6;color:#7a7fa6}
@media(max-width:700px){.week{grid-template-columns:repeat(2,1fr)}}
@media(min-width:900px){
  .panel{flex-direction:row}
  .side{flex-direction:column;width:200px;overflow:visible;border-bottom:0;border-right:1px solid #e1e3f3;padding:1rem .6rem}
  .content{padding:1.5rem}
}

/* ---- icone e ricerca ---- */
.ic{width:20px;height:20px;stroke:currentColor;fill:none;stroke-width:2;stroke-linecap:round;stroke-linejoin:round;vertical-align:-4px;margin-right:.45rem;flex:0 0 auto}
.side a,.side .soon{display:flex;align-items:center}
.searchbox{position:relative}
.searchbox .ic{position:absolute;left:.8rem;top:50%;transform:translateY(-50%);margin:0;color:#7a80b0}
.searchbox input{padding-left:2.6rem}
header a{display:flex;align-items:center}

/* ---- editor orari ---- */
.presets{display:flex;flex-wrap:wrap;gap:.5rem;align-items:center;margin:.6rem 0}
select{padding:.4rem .6rem;border:1px solid #c9cdea;border-radius:8px;font:inherit;background:#fff}
.legend{display:flex;gap:.6rem;align-items:center;font-size:.85rem;color:#5b6090;margin:.4rem 0}
.sw{display:inline-block;width:14px;height:14px;border:1px solid #c9cdea;border-radius:3px;background:#fff}
.sw.on{background:var(--accent);border-color:var(--accent)}
.grid-wrap{overflow:auto;max-height:65vh;border:1px solid #e1e3f3;border-radius:10px}
table.avail{border-collapse:separate;border-spacing:0;width:100%;min-width:460px;font-size:.8rem;user-select:none;-webkit-user-select:none}
table.avail th{position:sticky;top:0;background:#fff;z-index:1;padding:.4rem .2rem;cursor:pointer;color:var(--brand);border-bottom:1px solid #e1e3f3}
table.avail th small{display:block;font-weight:400;color:#7a80b0;font-size:.7rem}
table.avail th.corner{cursor:default}
table.avail th:hover{background:var(--chip)}
table.avail td.t{padding:0 .5rem;color:#6a6f9a;white-space:nowrap;width:3.2rem;text-align:right;vertical-align:top;font-size:.75rem}
table.avail td.s{border-left:1px solid #eef0f8;border-bottom:1px dashed #eef0f8;height:24px;cursor:pointer}
table.avail tr.hour td.s{border-top:1px solid #d5d8ee}
table.avail td.s:hover{background:var(--chip)}
table.avail td.s.on{background:var(--accent);border-bottom-color:#2f5fbd}
.summary .sum-row{display:flex;gap:.8rem;padding:.35rem 0;border-bottom:1px solid #f0f1f8}
.summary .sum-row strong{width:2.6rem;color:var(--brand)}
.sum-total{margin-top:.6rem;font-weight:600}
.savebar{display:flex;align-items:center;gap:1rem;flex-wrap:wrap}
#avail-dirty{color:var(--amber-text)}

/* ---- editor orari semplice ---- */
.drow{display:flex;gap:1rem;align-items:flex-start;padding:.9rem 0;border-bottom:1px solid #eef0f8}
.drow .switch{display:flex;align-items:center;gap:.7rem;min-width:9.5rem;margin:0;cursor:pointer;font-weight:400}
.drow .switch input{position:absolute;opacity:0;width:0;height:0}
.drow .track{position:relative;flex:0 0 42px;height:24px;border-radius:999px;background:#c9cdea;transition:background .15s}
.drow .track::after{content:"";position:absolute;top:3px;left:3px;width:18px;height:18px;border-radius:50%;background:#fff;transition:transform .15s}
.drow .switch input:checked + .track{background:var(--accent)}
.drow .switch input:checked + .track::after{transform:translateX(18px)}
.drow .switch input:focus-visible + .track{outline:2px solid var(--brand);outline-offset:2px}
.rng{flex:1;min-height:24px;display:flex;flex-direction:column;gap:.5rem;justify-content:center}
.rline{display:flex;align-items:center;gap:.5rem;flex-wrap:wrap}
.rline select{min-width:5.2rem;font-size:1rem}
.rtools{display:flex;gap:1rem;flex-wrap:wrap}
button.link-btn{margin:0;padding:0;background:none;color:var(--accent);font-weight:500;font-size:.9rem}
button.icon-btn{margin:0;padding:.3rem .6rem;background:#eceef6;color:#555;border-radius:8px}
@media(max-width:560px){.drow{flex-direction:column;gap:.6rem}}
