:root {
  --bg: #f6f4ef;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --ink: #1b2422;
  --muted: #66716e;
  --line: #e2ded4;
  --brand: #13463d;
  --brand-2: #1d6355;
  --brand-soft: #e3efe9;
  --accent: #e8743b;
  --accent-soft: #fbe9df;
  --danger: #b4382b;
  --ok: #2c7a4b;
  --q0: #5b6cd1; --q1: #c2851b; --q2: #13463d; --q3: #2a8a8a; --q4: #b2557f;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(20, 30, 25, .05), 0 4px 16px rgba(20, 30, 25, .05);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111715; --surface: #18201e; --surface-2: #1f2926; --ink: #e8ece9; --muted: #98a39f; --line: #2b3633;
    --brand: #7cc4ad; --brand-2: #9ad5c2; --brand-soft: #1d332d; --accent: #f08d5a; --accent-soft: #3a261c;
    --danger: #ef7a6d; --ok: #6cc28f; --q2: #7cc4ad; --shadow: none; color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Manrope, system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--bg); color: var(--ink); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--brand-2); }
h1 { font-size: 1.6rem; margin: .1rem 0; letter-spacing: -.02em; line-height: 1.2; }
h2 { font-size: 1.2rem; margin: 0; }
h3 { font-size: 1rem; margin: 0 0 .6rem; }
h4 { font-size: .85rem; margin: .6rem 0 .3rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .82rem; }
.pre { white-space: pre-wrap; }
.big { font-size: 1.35rem; font-weight: 700; margin: .2rem 0; }
.mt { margin-top: 1.2rem; }
.pad { padding: .8rem; }
.lead { font-size: 1.02rem; color: var(--muted); max-width: 65ch; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; background: var(--brand); color: #fff; display: flex; flex-direction: column; padding: 1.2rem .8rem; }
@media (prefers-color-scheme: dark) { .sidebar { background: #0c1412; border-right: 1px solid var(--line); } }
.brand { display: flex; align-items: center; gap: .6rem; color: inherit; text-decoration: none; font-weight: 800; line-height: 1.1; margin: 0 .4rem 1.6rem; }
.brand-name { display: flex; flex-direction: column; letter-spacing: .14em; font-size: 1.05rem; }
.brand-name small { letter-spacing: .02em; font-weight: 600; font-size: .62rem; opacity: .8; margin-top: .2rem; white-space: nowrap; }
.logo { font-family: Georgia, 'Times New Roman', serif; }
.logo { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 10px; background: var(--accent); color: #fff; font-weight: 800; font-size: .95rem; flex: none; }
.sidebar nav { display: flex; flex-direction: column; gap: 2px; }
.sidebar nav a { display: flex; align-items: center; gap: .7rem; padding: .55rem .7rem; border-radius: 10px; color: rgba(255,255,255,.82); text-decoration: none; font-weight: 600; }
.sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar nav a.on { background: rgba(255,255,255,.14); color: #fff; }
.ico { width: 1.2em; text-align: center; opacity: .9; }
.side-foot { margin-top: auto; display: flex; flex-direction: column; gap: .3rem; padding: .6rem; border-top: 1px solid rgba(255,255,255,.12); }
.side-foot a { color: #fff; text-decoration: none; font-weight: 600; font-size: .9rem; }
.link { background: none; border: 0; color: rgba(255,255,255,.7); text-align: left; padding: 0; cursor: pointer; font: inherit; font-size: .85rem; }
.view { padding: 1.6rem 2rem 4rem; max-width: 1180px; width: 100%; outline: none; }
.bottom-nav { display: none; }
.loading { color: var(--muted); padding: 2rem 0; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .sidebar { display: none; }
  .view { padding: 1rem 1rem calc(5.5rem + env(safe-area-inset-bottom)); }
  .bottom-nav { display: flex; position: fixed; inset: auto 0 0 0; background: var(--surface); border-top: 1px solid var(--line); padding: .3rem .2rem calc(.3rem + env(safe-area-inset-bottom)); z-index: 20; }
  .bottom-nav a { flex: 1; display: flex; flex-direction: column; align-items: center; text-decoration: none; color: var(--muted); font-size: 1.1rem; padding: .25rem 0; border-radius: 10px; }
  .bottom-nav a small { font-size: .68rem; font-weight: 600; }
  .bottom-nav a.on { color: var(--brand); background: var(--brand-soft); }
  h1 { font-size: 1.35rem; }
}

/* ---------- page parts ---------- */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; margin-bottom: 1.2rem; flex-wrap: wrap; }
.back { display: inline-block; margin-bottom: .6rem; color: var(--muted); text-decoration: none; font-size: .9rem; font-weight: 600; }
.back:hover { color: var(--ink); }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; box-shadow: var(--shadow); }
.card.flush { padding: 0; overflow: hidden; }
.card.highlight { border-color: var(--accent); background: linear-gradient(0deg, var(--surface), var(--surface)) padding-box; box-shadow: 0 0 0 3px var(--accent-soft); }
.empty { text-align: center; color: var(--muted); padding: 1.6rem 1rem; }
.empty.small { padding: .8rem; font-size: .85rem; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.grid-2 > .card { margin-bottom: 0; }
.grid-2 + * { margin-top: 1rem; }
@media (max-width: 900px) { .grid-2 { grid-template-columns: 1fr; } }
.row-between { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.actions { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; justify-content: flex-end; }
.actions.bar { justify-content: flex-start; margin-bottom: 1rem; }
.stack { display: flex; flex-direction: column; gap: .8rem; }
.notice { background: var(--accent-soft); border-radius: 10px; padding: .7rem .9rem; margin-bottom: 1rem; font-size: .9rem; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-bottom: 1rem; }
.stats > div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: .9rem 1rem; }
.stats strong { display: block; font-size: 1.6rem; letter-spacing: -.02em; }
.stats span { color: var(--muted); font-size: .85rem; }
@media (max-width: 700px) { .stats { grid-template-columns: 1fr 1fr; } }

/* ---------- buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; padding: .55rem 1rem; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font: inherit; font-weight: 700; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
@media (prefers-color-scheme: dark) { .btn-primary { color: #0c1412; } }
.btn-primary:hover { background: var(--brand-2); border-color: var(--brand-2); }
.btn-ghost { background: transparent; border-color: transparent; }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }
.btn-block { width: 100%; }
.btn.danger, .danger { color: var(--danger); }
.icon-btn { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 1rem; text-decoration: none; flex: none; }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn.danger { border-color: transparent; background: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
label { display: flex; flex-direction: column; gap: .3rem; font-weight: 600; font-size: .86rem; }
label.inline, label.check { flex-direction: row; align-items: center; gap: .5rem; font-weight: 500; }
label.check { align-items: flex-start; }
input, select, textarea { font: inherit; font-weight: 500; font-size: .95rem; padding: .55rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); width: 100%; min-width: 0; }
input[type="checkbox"], input[type="radio"] { width: auto; accent-color: var(--brand); }
textarea { resize: vertical; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .9rem 1rem; }
.form-grid .full { grid-column: 1 / -1; }
.form-grid h3 { margin: 0; }
@media (max-width: 600px) { .form-grid { grid-template-columns: 1fr; } }
.form-inline { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; margin-top: .8rem; }
.form-inline input, .form-inline select { width: auto; }
.w-xs { width: 80px !important; } .w-sm { width: 120px !important; } .w-md { width: 200px !important; } .w-lg { width: 280px !important; }
.form-inline select.ex-select { min-width: 220px; }
@media (max-width: 600px) { .form-inline > * { flex: 1 1 45%; } .w-lg, .w-md { width: 100% !important; } }
.search { margin-bottom: 1rem; max-width: 420px; }
.with-unit { display: flex; align-items: center; gap: .5rem; max-width: 260px; }
.with-unit span { color: var(--muted); font-weight: 600; }
.copy-box { display: flex; gap: .5rem; }
.suggest { position: relative; display: flex; flex-direction: column; border-radius: 10px; overflow: hidden; }
.suggest:not(:empty) { border: 1px solid var(--line); margin-top: .2rem; max-height: 260px; overflow-y: auto; }
.suggest button { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 0; border-bottom: 1px solid var(--line); background: var(--surface); padding: .5rem .7rem; font: inherit; color: var(--ink); cursor: pointer; }
.suggest button:hover { background: var(--brand-soft); }
.suggest small { color: var(--muted); font-weight: 500; }

/* ---------- questionnaires ---------- */
.qform { max-width: 760px; }
.q-section { border: 0; padding: 0; margin: 0 0 1.6rem; }
.q-section legend { font-weight: 800; font-size: 1.05rem; display: flex; align-items: center; gap: .6rem; margin-bottom: .8rem; }
.step { display: inline-grid; place-items: center; width: 26px; height: 26px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); font-size: .8rem; }
.q { margin-bottom: 1.1rem; }
.q[hidden] { display: none; }
.q-label { font-size: .95rem; font-weight: 700; display: block; margin-bottom: .3rem; }
.q-help { color: var(--muted); font-size: .82rem; margin: -.15rem 0 .35rem; }
.req { color: var(--accent); }
.choices { display: flex; flex-direction: column; gap: .35rem; }
.choices-inline { flex-direction: row; }
.choice { flex-direction: row; align-items: center; gap: .6rem; font-weight: 500; padding: .5rem .7rem; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-size: .92rem; }
.choice:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.scale { display: flex; gap: .3rem; flex-wrap: wrap; }
.scale label { position: relative; }
.scale input { position: absolute; opacity: 0; }
.scale span { display: grid; place-items: center; width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; font-weight: 700; cursor: pointer; }
.scale input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.scale input:focus-visible + span { outline: 2px solid var(--accent); outline-offset: 2px; }
.sticky-actions { position: sticky; bottom: 0; background: var(--surface); padding: .8rem 0; border-top: 1px solid var(--line); justify-content: space-between; }
@media (max-width: 860px) { .sticky-actions { bottom: calc(4.2rem + env(safe-area-inset-bottom)); } }
.ans-section { margin-bottom: 1.2rem; }
.ans-section h3 { border-bottom: 1px solid var(--line); padding-bottom: .4rem; }
.ans-section dl { margin: 0; display: grid; grid-template-columns: minmax(180px, 40%) 1fr; gap: .1rem 1rem; }
.ans { display: contents; }
.ans dt { color: var(--muted); font-size: .88rem; padding: .3rem 0; }
.ans dd { margin: 0; font-weight: 600; padding: .3rem 0; white-space: pre-wrap; }
@media (max-width: 600px) { .ans-section dl { grid-template-columns: 1fr; } .ans dd { padding-top: 0; border-bottom: 1px dashed var(--line); } }
.meta-line { color: var(--muted); font-size: .85rem; margin-bottom: 1rem; }
.code-pill { display: inline-grid; place-items: center; min-width: 34px; height: 24px; padding: 0 .4rem; border-radius: 7px; font-size: .75rem; font-weight: 800; color: #fff; background: var(--q0); margin-right: .2rem; flex: none; }
.code-Q1 { background: var(--q1); } .code-Q2 { background: var(--q2); } .code-Q3 { background: var(--q3); } .code-Q4 { background: var(--q4); }
@media (prefers-color-scheme: dark) { .code-Q2 { color: #0c1412; } }
.page-head .code-pill { margin-bottom: .3rem; }

/* editor */
.editor { display: flex; flex-direction: column; gap: 1rem; margin-bottom: 1rem; }
.ed-section { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; }
.ed-section-head { display: flex; gap: .5rem; align-items: center; margin-bottom: .8rem; }
.ed-title { font-weight: 800; font-size: 1.05rem; }
.ed-q { display: flex; gap: .6rem; padding: .8rem; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: .6rem; }
.ed-q-main { flex: 1; display: flex; flex-direction: column; gap: .45rem; min-width: 0; }
.ed-q-meta { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.ed-q-meta select { width: auto; }
.ed-tools { display: flex; gap: .2rem; align-items: flex-start; }

/* ---------- badges & lists ---------- */
.badge { display: inline-block; font-size: .72rem; font-weight: 700; padding: .15rem .55rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge-assegnato { background: var(--accent-soft); color: var(--accent); }
.badge-compilato { background: #fff2c9; color: #8a6400; }
@media (prefers-color-scheme: dark) { .badge-compilato { background: #3a3218; color: #e6c463; } }
.badge-rivisto, .badge-attivo, .badge-completato { background: var(--brand-soft); color: var(--brand); }
.badge-confermato { background: #e3e9fb; color: #3d4fa6; }
@media (prefers-color-scheme: dark) { .badge-confermato { background: #232a45; color: #a7b5f0; } }
.badge-annullato { text-decoration: line-through; }
.dot-badge { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 .35rem; border-radius: 99px; background: var(--accent); color: #fff; font-size: .72rem; font-weight: 800; }
.dot-badge.alt { background: var(--brand-2); }
.list, .appt-list, .entries, .threads { list-style: none; margin: 0; padding: 0; }
.list li a, .appt-list li a, .appt-list li { display: flex; align-items: center; gap: .8rem; padding: .6rem .2rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; }
.list li:last-child a, .appt-list li:last-child, .appt-list li:last-child a { border-bottom: 0; }
.list li a > span:nth-child(2), .appt-list li > span:nth-child(2), .appt-list a > span:nth-child(2) { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.list small, .appt-list small { color: var(--muted); font-weight: 500; }
.card.flush .list li a { padding: .8rem 1rem; }
.chev { color: var(--muted); font-size: 1.3rem; }
.time { display: flex; flex-direction: column; font-weight: 800; min-width: 54px; color: var(--brand); }
.time small { color: var(--muted); font-weight: 600; }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.table th { text-align: left; font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: .55rem .6rem; border-bottom: 1px solid var(--line); white-space: nowrap; }
.table td { padding: .6rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.card.flush .table th:first-child, .card.flush .table td:first-child { padding-left: 1rem; }
.clickable { cursor: pointer; }
.clickable:hover td { background: var(--surface-2); }
.log-table input { padding: .4rem .45rem; width: 100% !important; min-width: 48px; }
.log-table td { padding: .45rem .3rem; }
.log-table th:first-child, .log-table td:first-child { width: 34%; }
.log-form-notes { margin-top: .8rem; }

/* ---------- patient page ---------- */
.patient-head { align-items: center; justify-content: flex-start; }
.patient-head .actions { margin-left: auto; }
.avatar { width: 52px; height: 52px; border-radius: 50%; background: var(--brand-soft); color: var(--brand); display: grid; place-items: center; font-weight: 800; font-size: 1.1rem; flex: none; }
.tabs { display: flex; gap: .2rem; border-bottom: 1px solid var(--line); margin-bottom: 1.2rem; overflow-x: auto; scrollbar-width: none; }
.tabs a { padding: .6rem .85rem; text-decoration: none; color: var(--muted); font-weight: 700; font-size: .9rem; border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.on { color: var(--brand); border-color: var(--accent); }
.path { list-style: none; margin: 0; padding: 0; }
.path-step { display: flex; gap: .9rem; position: relative; padding-bottom: 1rem; }
.path-step:not(:last-child)::before { content: ""; position: absolute; left: 19px; top: 40px; bottom: 0; width: 2px; background: var(--line); }
.path-dot { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: .78rem; font-weight: 800; border: 2px solid var(--line); background: var(--surface); flex: none; color: var(--muted); }
.path-step.wait .path-dot { border-color: var(--accent); color: var(--accent); }
.path-step.done .path-dot { background: var(--brand); border-color: var(--brand); color: #fff; }
.path-body { flex: 1; min-width: 0; }
.path-body .row-between { margin: 0; }
.path-actions { display: flex; gap: .4rem; margin-top: .4rem; }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .8rem; margin-bottom: 1rem; }
.cards .card { margin: 0; }
.link-card { text-decoration: none; color: inherit; display: block; }
.link-card:hover { border-color: var(--brand-2); }

/* ---------- diary & plan ---------- */
.day-nav, .week-nav { display: flex; align-items: center; gap: .6rem; margin-bottom: 1rem; }
.day-nav input { width: auto; }
.macro-strip { display: grid; grid-template-columns: repeat(4, 1fr); gap: .5rem; margin-bottom: .4rem; }
.macro-strip > div { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem; text-align: center; }
.macro-strip strong { display: block; font-size: 1.3rem; }
.macro-strip span { font-size: .75rem; color: var(--muted); }
.meal-h { margin-top: 1rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.meal-h:first-child { margin-top: 0; }
.entries li { display: flex; justify-content: space-between; gap: .6rem; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.pro-comment { background: var(--brand-soft); border-radius: 10px; padding: .7rem .9rem; margin-top: 1rem; }
.targets { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.targets span { background: var(--accent-soft); border-radius: 10px; padding: .35rem .7rem; font-weight: 800; }
.targets small { color: var(--accent); font-weight: 800; margin-right: .35rem; }
.plan-day + .plan-day { margin-top: 1.4rem; padding-top: 1.2rem; border-top: 2px solid var(--line); }
.plan-day-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: .4rem; }
.plan-meal ul { list-style: none; padding: 0; margin: 0; }
.plan-meal li { display: flex; align-items: center; gap: .6rem; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.plan-meal li > span:first-child { flex: 1; }

/* ---------- training ---------- */
.workout + .workout { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: 1rem; }
.ex-table td:last-child { white-space: nowrap; text-align: right; }
details.log { border-bottom: 1px solid var(--line); padding: .5rem 0; }
details.log summary { cursor: pointer; }
.sets { margin: .4rem 0; padding-left: 1.2rem; font-size: .9rem; }
.bars { display: flex; flex-direction: column; gap: .4rem; }
.bar-row { display: grid; grid-template-columns: 70px 1fr 90px; gap: .6rem; align-items: center; font-size: .85rem; }
.bar-track { background: var(--surface-2); border-radius: 99px; height: 10px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: var(--brand-2); border-radius: 99px; }
.bar-val { text-align: right; color: var(--muted); }
.chart { width: 100%; height: auto; }
.chart .grid { stroke: var(--line); }
.chart .axis { fill: var(--muted); font-size: 11px; font-family: inherit; }
.chart .line { fill: none; stroke: var(--brand-2); stroke-width: 2.5; stroke-linejoin: round; }
.chart .dot { fill: var(--surface); stroke: var(--brand-2); stroke-width: 2; }
.seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex-wrap: wrap; }
.seg button { border: 0; background: var(--surface); padding: .35rem .7rem; font: inherit; font-size: .82rem; font-weight: 700; color: var(--muted); cursor: pointer; }
.seg button.on { background: var(--brand); color: #fff; }

/* ---------- agenda ---------- */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .5rem; }
.week-day { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; min-height: 160px; padding: .4rem; display: flex; flex-direction: column; gap: .35rem; }
.week-day.today { border-color: var(--accent); }
.week-day-head { font-weight: 800; font-size: .82rem; text-transform: capitalize; padding: .2rem .3rem; color: var(--muted); }
.appt { display: flex; flex-direction: column; text-align: left; gap: 0; border: 0; border-left: 3px solid var(--brand-2); background: var(--brand-soft); border-radius: 8px; padding: .4rem .5rem; font: inherit; font-size: .8rem; color: var(--ink); cursor: pointer; }
.appt span { font-weight: 800; color: var(--brand); }
.appt small { color: var(--muted); }
.appt.annullato { opacity: .5; text-decoration: line-through; }
.appt.completato { border-left-color: var(--muted); background: var(--surface-2); }
@media (max-width: 860px) { .week { grid-template-columns: 1fr; } .week-day { min-height: 0; } }

/* ---------- messages ---------- */
.inbox { display: grid; grid-template-columns: 280px 1fr; gap: 1rem; align-items: start; }
.threads li a { display: flex; flex-wrap: wrap; justify-content: space-between; padding: .75rem 1rem; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; gap: .2rem .5rem; }
.threads li a small { width: 100%; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.threads li a.on { background: var(--brand-soft); }
@media (max-width: 860px) { .inbox { grid-template-columns: 1fr; } }
.chat { display: flex; flex-direction: column; }
.chat-list { max-height: 55vh; overflow-y: auto; display: flex; flex-direction: column; gap: .6rem; padding: .3rem 0 1rem; }
.msg { max-width: 78%; align-self: flex-start; }
.msg.mine { align-self: flex-end; text-align: right; }
.bubble { background: var(--surface-2); padding: .55rem .8rem; border-radius: 14px 14px 14px 4px; text-align: left; overflow-wrap: anywhere; }
.msg.mine .bubble { background: var(--brand); color: #fff; border-radius: 14px 14px 4px 14px; }
@media (prefers-color-scheme: dark) { .msg.mine .bubble { color: #0c1412; } }
.msg-meta { font-size: .72rem; color: var(--muted); margin-top: .2rem; }
.chat-form { display: flex; gap: .5rem; align-items: flex-end; border-top: 1px solid var(--line); padding-top: .8rem; }

/* ---------- patient home ---------- */
.tiles { display: grid; grid-template-columns: repeat(4, 1fr); gap: .8rem; margin-top: 1rem; }
.tile { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 1rem; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .15rem; }
.tile:hover { border-color: var(--brand-2); }
.tile-ico { font-size: 1.5rem; }
.tile small { color: var(--muted); }
@media (max-width: 700px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------- auth ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 1rem; background: radial-gradient(circle at 20% 10%, var(--brand-soft), transparent 50%), var(--bg); }
.auth-card { width: 100%; max-width: 420px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 2rem; box-shadow: var(--shadow); }
.brand.big { color: var(--brand); margin: 0 0 1.4rem; }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(10, 20, 17, .45); display: grid; place-items: center; padding: 1rem; z-index: 50; animation: fade .15s; }
.modal { background: var(--surface); border-radius: 18px; width: 100%; max-width: 460px; max-height: 90vh; overflow-y: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal-wide { max-width: 680px; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.2rem; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: var(--surface); z-index: 1; }
.modal-body { padding: 1.2rem; }
.modal-body .actions { margin-top: 1rem; }
@keyframes fade { from { opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translate(-50%, 20px); background: var(--ink); color: var(--bg); padding: .7rem 1.1rem; border-radius: 12px; font-weight: 700; opacity: 0; transition: .25s; z-index: 60; max-width: calc(100% - 2rem); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast-err { background: var(--danger); color: #fff; }
@media (max-width: 860px) { .toast { bottom: calc(5rem + env(safe-area-inset-bottom)); } }

@media print {
  .sidebar, .bottom-nav, .actions, .back, button, .tabs { display: none !important; }
  .layout { display: block; } .view { padding: 0; } .card { box-shadow: none; break-inside: avoid; }
}

/* =====================================================================
   VERSIONE 2.0
   ===================================================================== */
:root { --s-A: #2f7d6b; --s-B: #5b6cd1; --s-C: #c2851b; --s-D: #b2557f; --s-E: #2a8a8a; --s-F: #7a5cc4; --s-G: #c4553b; }
.main-col { min-width: 0; display: flex; flex-direction: column; }
.topbar { display: flex; justify-content: flex-end; align-items: center; gap: .6rem; padding: .7rem 2rem 0; }
.mini-brand { display: none; margin: 0; }
.bell { position: relative; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; width: 40px; height: 40px; font-size: 1.05rem; cursor: pointer; }
.bell-n { position: absolute; top: -5px; right: -5px; background: var(--accent); color: #fff; border-radius: 99px; font-size: .68rem; font-weight: 800; min-width: 19px; height: 19px; display: grid; place-items: center; padding: 0 4px; }
.view { padding-top: .6rem; }
@media (max-width: 860px) { .topbar { padding: .6rem 1rem 0; justify-content: space-between; } .mini-brand { display: flex; } }
.notif li.unread a { background: var(--brand-soft); }
.notif li a { padding: .7rem .5rem; border-radius: 8px; }
.public-view { max-width: 820px; margin: 0 auto; }
.btn-xs { padding: .2rem .55rem; font-size: .76rem; border-radius: 8px; }
.actions.start { justify-content: flex-start; }
.align-start { align-items: start; }
.danger-notice { background: #fde5e1; color: #8c2a1f; }
@media (prefers-color-scheme: dark) { .danger-notice { background: #3a1d19; color: #f3a79c; } }
.warn-text { color: var(--danger); font-weight: 600; }
.chip { display: inline-block; font-size: .72rem; font-weight: 700; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin: 0 .15rem; white-space: nowrap; }
.chips { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin: .4rem 0; }
.chip-check { flex-direction: row; font-weight: 600; font-size: .8rem; }
.chip-check input { position: absolute; opacity: 0; pointer-events: none; }
.chip-check span { padding: .25rem .65rem; border: 1px solid var(--line); border-radius: 99px; cursor: pointer; background: var(--surface); }
.chip-check input:checked + span { background: var(--brand); border-color: var(--brand); color: #fff; }
.chip-check input:focus-visible + span { outline: 2px solid var(--accent); }
.chip-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .3rem .7rem; font: inherit; font-size: .8rem; font-weight: 600; cursor: pointer; color: var(--ink); }
.chip-btn:hover { border-color: var(--brand-2); }
.mini { border: 0; background: transparent; cursor: pointer; font-size: .85rem; padding: .15rem .3rem; border-radius: 6px; color: var(--muted); text-decoration: none; display: inline-flex; align-items: center; }
.mini:hover { background: var(--surface-2); color: var(--ink); }
.mini.danger:hover { color: var(--danger); }
.mini.star.on { color: var(--accent); }
.subtabs { display: flex; gap: .3rem; margin-bottom: 1rem; flex-wrap: wrap; }
.subtabs button { border: 1px solid var(--line); background: var(--surface); padding: .45rem .9rem; border-radius: 99px; font: inherit; font-weight: 700; font-size: .86rem; cursor: pointer; color: var(--muted); }
.subtabs button.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs { flex-wrap: nowrap; }
.kpis { display: flex; flex-wrap: wrap; gap: .5rem; }
.kpis > div { background: var(--surface-2); border-radius: 10px; padding: .5rem .75rem; min-width: 92px; display: flex; flex-direction: column; }
.kpis > div.main { background: var(--brand); color: #fff; }
.kpis small { font-size: .7rem; opacity: .8; }
.kpis b { font-size: 1.2rem; }
.result:empty { display: none; }
.grid-inputs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; margin-bottom: .6rem; }
.grid-inputs label.need input { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.table tr.hl td { background: var(--brand-soft); }
h4 { margin-top: 1rem; }
.form-grid.tight { gap: .5rem; }
.legend { display: flex; gap: .8rem; font-size: .78rem; color: var(--muted); }
.legend .lg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; background: var(--brand-2); }
.chart .line.s1, .legend .s1::before { stroke: var(--accent); background: var(--accent); }
.chart .dot.s1 { stroke: var(--accent); }
.charts-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 1rem; margin-bottom: 1rem; }
.charts-grid .card { margin: 0; }
.charts-grid h4 { margin: 0; }
.delta { font-size: .8rem; font-weight: 800; }
.delta.up { color: var(--brand-2); } .delta.down { color: var(--accent); }
.filters { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.filters input[type=search] { max-width: 280px; }
.filters select { width: auto; }
.table.foods td { vertical-align: middle; }
.lab-low { color: #3d6fd1; font-weight: 800; } .lab-high { color: var(--danger); font-weight: 800; }
.lab-form input { padding: .3rem .4rem; min-width: 70px; }
.modal-xl { max-width: 1000px; }
.note h5 { margin: .8rem 0 .2rem; font-size: .8rem; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }
.habits td.c, .habits th.c { text-align: center; padding: .4rem .25rem; font-size: .8rem; }
.h-ok { background: var(--brand-soft); color: var(--brand); font-weight: 800; }
.h-ko { background: var(--accent-soft); color: var(--accent); }
.req { display: flex; justify-content: space-between; gap: .8rem; align-items: center; padding: .6rem 0; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.req:last-child { border-bottom: 0; }

/* sessioni e lettere */
.sess-l { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; color: #fff; font-weight: 800; font-size: .75rem; background: var(--s-A); margin-right: .35rem; flex: none; }
.s-B.sess-l { background: var(--s-B); } .s-C.sess-l { background: var(--s-C); } .s-D.sess-l { background: var(--s-D); } .s-E.sess-l { background: var(--s-E); } .s-F.sess-l { background: var(--s-F); } .s-G.sess-l { background: var(--s-G); }

/* ---------------- editor dei piani ---------------- */
.pe-head h1 { margin: 0; }
.pe-title { font-size: 1.5rem; font-weight: 800; border: 1px solid transparent; padding: .2rem .4rem; margin-left: -.4rem; background: transparent; letter-spacing: -.02em; }
.pe-title:hover, .pe-title:focus { border-color: var(--line); background: var(--surface); }
.pe { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
@media (max-width: 1100px) { .pe { grid-template-columns: 1fr; } .pe-side .sticky { position: static; } }
.sticky { position: sticky; top: 1rem; }
.pe-schema .row-between { margin-bottom: .4rem; }
.week-map { display: grid; grid-template-columns: repeat(7, 1fr); gap: .4rem; }
.week-map label { align-items: center; font-size: .75rem; color: var(--muted); }
.week-map select { padding: .35rem; text-align: center; font-weight: 800; }
.rot input { max-width: 220px; font-weight: 800; letter-spacing: .1em; }
.presets { display: flex; flex-wrap: wrap; gap: .2rem; align-items: center; margin-top: .6rem; }
.pe-tabs { display: flex; gap: .4rem; overflow-x: auto; padding-bottom: .2rem; margin-bottom: .6rem; }
.pe-tab { display: flex; align-items: center; gap: .1rem; flex-wrap: wrap; border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: .5rem .8rem; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); white-space: nowrap; }
.pe-tab small { width: 100%; font-weight: 600; color: var(--muted); font-size: .72rem; padding-left: 1.7rem; }
.pe-tab.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.pe-tab.add { color: var(--muted); border-style: dashed; }
.pe-session-head { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .6rem; }
.pe-session-head .actions { margin-left: auto; }
.pe-sname { font-size: 1.1rem; font-weight: 800; max-width: 280px; }
.pe-targets { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .5rem; align-items: end; background: var(--surface-2); padding: .7rem; border-radius: 12px; }
.pe-targets label { font-size: .75rem; }
.pe-exercise { display: flex; justify-content: space-between; align-items: center; gap: .5rem; flex-wrap: wrap; font-size: .88rem; margin: .7rem 0; }
.pe-notes { margin-bottom: .8rem; }
.meals { display: flex; flex-direction: column; gap: .8rem; }
.meal { border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; background: var(--surface); }
.meal-head { display: flex; align-items: center; gap: .5rem; flex-wrap: wrap; }
.meal-time { width: 96px; padding: .3rem .4rem; }
.meal-name { font-weight: 800; max-width: 220px; padding: .3rem .5rem; }
.meal-time-ro { font-weight: 800; color: var(--brand); }
.meal-head h4 { margin: 0; text-transform: none; letter-spacing: 0; font-size: 1rem; color: var(--ink); }
.meal-tot { font-size: .78rem; color: var(--muted); margin-left: auto; }
.meal-tools { display: flex; gap: .2rem; }
.meal-tools .icon-btn { width: 28px; height: 28px; font-size: .85rem; }
.meal-target, .meal-notes { margin: .3rem 0 0; font-size: .82rem; }
details.menu { position: relative; }
details.menu summary { list-style: none; }
details.menu summary::-webkit-details-marker { display: none; }
.menu-list { position: absolute; right: 0; top: 110%; z-index: 30; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 10px 30px rgba(0,0,0,.12); display: flex; flex-direction: column; min-width: 240px; padding: .3rem; }
.menu-list button { border: 0; background: none; text-align: left; padding: .5rem .7rem; border-radius: 8px; font: inherit; font-size: .88rem; cursor: pointer; color: var(--ink); }
.menu-list button:hover { background: var(--surface-2); }
.menu-list .danger { color: var(--danger); }
.rows { display: flex; flex-direction: column; gap: .35rem; margin-top: .5rem; }
.row { border-left: 3px solid var(--brand-soft); padding: .3rem 0 .3rem .6rem; }
.opt { display: flex; align-items: center; flex-wrap: wrap; gap: .25rem .35rem; }
.opt.alt { padding-left: .6rem; margin-top: .2rem; font-size: .92rem; }
.oppure { font-size: .72rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; margin-right: .2rem; }
.it { display: inline-flex; align-items: center; gap: .25rem; background: var(--surface-2); border-radius: 9px; padding: .2rem .3rem .2rem .55rem; border: 1px solid transparent; }
.it.conflict { border-color: var(--danger); background: #fde5e1; }
@media (prefers-color-scheme: dark) { .it.conflict { background: #3a1d19; } }
.it.locked { border-color: var(--brand-2); }
.it-name { font-weight: 600; font-size: .88rem; }
.adhoc { color: var(--accent); margin-right: .2rem; }
.it-g { width: 64px !important; padding: .15rem .3rem; font-weight: 800; text-align: right; }
.it .unit { font-size: .78rem; color: var(--muted); }
.hint { font-size: .72rem; color: var(--muted); }
.hint:empty { display: none; }
.plus { color: var(--muted); font-weight: 800; }
.mini.add { font-weight: 800; color: var(--brand-2); }
.row-n { font-size: .74rem; color: var(--muted); margin-left: auto; }
.row-n.warn { color: var(--accent); font-weight: 700; }
.row-tools { display: inline-flex; gap: 0; opacity: .5; }
.row:hover .row-tools { opacity: 1; }
.row-note { font-size: .8rem; color: var(--muted); font-style: italic; margin-top: .15rem; }
.add-row { margin-top: .4rem; }
.tbar { margin-bottom: .55rem; }
.tbar-top { display: flex; justify-content: space-between; font-size: .84rem; }
.tbar-track { height: 8px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: .2rem; }
.tbar-track span { display: block; height: 100%; background: var(--muted); border-radius: 99px; }
.tbar.ok .tbar-track span { background: var(--brand-2); } .tbar.under .tbar-track span { background: #d9a441; } .tbar.over .tbar-track span { background: var(--danger); }
.ea { border-radius: 10px; padding: .55rem .7rem; font-size: .85rem; margin: .6rem 0; background: var(--surface-2); }
.ea-adeguata { background: var(--brand-soft); } .ea-ridotta { background: #fff2c9; } .ea-bassa { background: #fde5e1; }
@media (prefers-color-scheme: dark) { .ea-ridotta { background: #3a3218; } .ea-bassa { background: #3a1d19; } }
.balance { display: flex; flex-direction: column; gap: .5rem; border-top: 1px solid var(--line); padding-top: .7rem; margin-top: .4rem; }
.pe-more { margin-top: .8rem; border-top: 1px solid var(--line); padding-top: .6rem; }
.pe-more summary { cursor: pointer; font-weight: 700; }
.pe-more > * + * { margin-top: .6rem; }
.supp { font-size: .85rem; padding: .2rem 0; }
.picker-bar { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.picker-bar input:first-child { flex: 1; min-width: 200px; }
.picker-list { max-height: 50vh; overflow-y: auto; margin-top: .6rem; display: flex; flex-direction: column; gap: 2px; }
.picker-sec { font-size: .74rem; font-weight: 800; text-transform: uppercase; color: var(--muted); padding: .3rem .2rem; }
.pk-item { display: flex; flex-direction: column; align-items: flex-start; text-align: left; border: 0; background: var(--surface); padding: .5rem .6rem; border-radius: 8px; cursor: pointer; font: inherit; color: var(--ink); }
.pk-item:hover, .pk-item.on { background: var(--brand-soft); }
.pk-item small { color: var(--muted); }
.picker-foot { margin-top: .6rem; border-top: 1px solid var(--line); padding-top: .5rem; }
.ex-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.ex-row select { width: auto; max-width: 260px; }
.ex-k { font-size: .8rem; font-weight: 700; color: var(--brand-2); margin-left: auto; }

/* ---------------- foto ---------------- */
.gal-date { margin: 1rem 0 .4rem; }
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .6rem; }
.gal-item { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.gal-item img, .gal-item video { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; background: var(--surface-2); }
.gal-meta { display: flex; align-items: center; gap: .2rem; padding: .3rem; }
.gal-meta .mini:last-child { margin-left: auto; }
.gal-item p { padding: 0 .5rem .4rem; margin: 0; }
.doc-ico { display: grid; place-items: center; aspect-ratio: 3/4; font-size: 2rem; background: var(--surface-2); text-align: center; }
.doc-ico span { font-size: .72rem; padding: 0 .4rem; word-break: break-all; }
.up-opts { padding: .6rem 1rem; }
.up-opts .form-inline { margin: 0; }
.cmp-tools { display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: .6rem; }
.cmp { display: grid; gap: .4rem; grid-template-columns: repeat(2, 1fr); }
.cmp-3 { grid-template-columns: repeat(3, 1fr); } .cmp-2 { grid-template-columns: repeat(2, 1fr); }
.cmp-cell { position: relative; overflow: hidden; background: #111; border-radius: 8px; aspect-ratio: 3/4; touch-action: none; cursor: grab; }
.cmp-cell img { width: 100%; height: 100%; object-fit: cover; user-select: none; transform-origin: center; }
.cmp-cell.grid::after { content: ""; position: absolute; inset: 0; pointer-events: none; background-image: linear-gradient(rgba(255,255,255,.35) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.35) 1px, transparent 1px); background-size: 33.33% 33.33%; }
.file-q { display: flex; flex-direction: column; gap: .4rem; align-items: flex-start; }
.file-thumbs { display: flex; gap: .4rem; flex-wrap: wrap; }
.thumb { width: 72px; height: 72px; border-radius: 8px; overflow: hidden; background: var(--surface-2); display: grid; place-items: center; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.q-info { background: var(--accent-soft); padding: .6rem .8rem; border-radius: 10px; font-size: .9rem; }
.formula-out { display: inline-block; font-weight: 800; font-size: 1.1rem; padding: .3rem .6rem; background: var(--surface-2); border-radius: 8px; min-width: 60px; }

/* ---------------- app paziente ---------------- */
.today-card { display: block; text-decoration: none; color: inherit; border-color: var(--brand-2); }
.today-card h3 { display: flex; align-items: center; margin: .1rem 0; }
.today-prog { text-align: center; } .today-prog b { font-size: 1.5rem; display: block; } .today-prog small { color: var(--muted); }
.habit-today { display: flex; flex-wrap: wrap; gap: .5rem; }
.habit-btn { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .5rem .9rem; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.habit-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.habit-num { flex-direction: row; align-items: center; gap: .5rem; border: 1px solid var(--line); border-radius: 99px; padding: .25rem .4rem .25rem .9rem; }
.habit-num input { width: 90px; padding: .3rem .5rem; border-radius: 99px; }
.sess-pick select { max-width: 320px; }
.meal-day h3 { margin: 0; display: flex; align-items: center; gap: .5rem; }
.meal-clock { font-size: .8rem; background: var(--brand-soft); color: var(--brand); padding: .15rem .45rem; border-radius: 6px; }
.day-rows { list-style: none; padding: 0; margin: .5rem 0; }
.day-rows > li { padding: .35rem 0; border-bottom: 1px dashed var(--line); }
.day-rows details summary { font-size: .8rem; color: var(--brand-2); cursor: pointer; }
.day-rows details ul { margin: .2rem 0; padding-left: 1.1rem; font-size: .9rem; }
.checks { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.ck { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .4rem .8rem; font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; color: var(--ink); flex-direction: row; }
.ck.on[data-ck="fatto"] { background: var(--brand); color: #fff; border-color: var(--brand); }
.ck.on[data-ck="variato"] { background: #d9a441; color: #fff; border-color: #d9a441; }
.ck.on[data-ck="saltato"] { background: var(--accent); color: #fff; border-color: var(--accent); }
.ck.photo { padding: .35rem .6rem; }
.ck-thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; }
.ck-note { margin-top: .5rem; }
.meal-day.ck-fatto { border-left: 4px solid var(--brand-2); } .meal-day.ck-variato { border-left: 4px solid #d9a441; } .meal-day.ck-saltato { border-left: 4px solid var(--accent); }
.tiles { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 700px) { .tiles { grid-template-columns: 1fr 1fr; } }

/* ---------------- prenotazione ---------------- */
.book { max-width: 760px; margin: 0 auto; }
.book-head { display: flex; align-items: center; gap: 1rem; margin: 1rem 0; }
.book-logo { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: .6rem; }
.type-card { display: flex; flex-direction: column; text-align: left; border: 1px solid var(--line); border-radius: 12px; padding: .8rem; background: var(--surface); cursor: pointer; font: inherit; color: var(--ink); }
.type-card.on { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand-soft); }
.type-card small { color: var(--muted); }
.day-strip { display: flex; gap: .35rem; overflow-x: auto; padding-bottom: .3rem; }
.day-btn { display: flex; flex-direction: column; align-items: center; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: .4rem .6rem; min-width: 58px; cursor: pointer; font: inherit; color: var(--ink); }
.day-btn small { font-size: .68rem; color: var(--muted); text-transform: capitalize; }
.day-btn:disabled { opacity: .35; cursor: default; }
.day-btn.on { background: var(--brand); color: #fff; border-color: var(--brand); } .day-btn.on small { color: #fff; }
.slots { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .8rem; }
.slot { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .45rem .8rem; font: inherit; font-weight: 700; cursor: pointer; color: var(--ink); }
.slot.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.logo-row { display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.logo-prev { width: 64px; height: 64px; object-fit: contain; border-radius: 12px; border: 1px solid var(--line); }
.logo.big { width: 64px; height: 64px; font-size: 1.3rem; }
.type-row, .avail-row { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .3rem 0; }
.type-row select { width: auto; }
.avail-row b { width: 92px; }
.avail-row input { width: auto; padding: .3rem .4rem; }

/* ---------------- stampa / PDF ---------------- */
body.printing .sidebar, body.printing .bottom-nav, body.printing .topbar { display: none; }
body.printing .layout { display: block; }
body.printing .view { max-width: 900px; margin: 0 auto; }
.print-bar { display: flex; gap: 1rem; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; }
.print-doc { background: #fff; color: #1b2422; padding: 2rem; border-radius: 12px; border: 1px solid var(--line); font-size: 14px; }
.pr-head { display: flex; align-items: center; gap: 1rem; border-bottom: 3px solid #13463d; padding-bottom: .8rem; margin-bottom: 1rem; }
.pr-logo { width: 56px; height: 56px; object-fit: contain; }
.pr-studio { font-weight: 800; font-size: 1.2rem; color: #13463d; }
.pr-sub { font-size: .8rem; color: #66716e; }
.pr-title { font-size: 1.5rem; margin: .2rem 0; }
.pr-meta { color: #66716e; margin: .1rem 0; }
.pr-session { margin-top: 1.4rem; break-inside: avoid-page; }
.pr-session h2 { font-size: 1.15rem; border-bottom: 1px solid #e2ded4; padding-bottom: .3rem; color: #13463d; }
.pr-days { font-size: .8rem; font-weight: 600; color: #66716e; margin-left: .4rem; }
.pr-tot { font-size: .8rem; color: #66716e; }
.pr-meal { break-inside: avoid; margin-top: .7rem; }
.pr-meal h3 { font-size: .95rem; margin: 0 0 .2rem; }
.pr-time { color: #e8743b; }
.pr-meal ul, .pr-session > ul { margin: 0; padding-left: 1.1rem; }
.pr-meal li { padding: .12rem 0; }
.pr-alt { font-size: .85rem; color: #4a5552; }
.pr-alt i { font-style: normal; color: #b5b0a5; }
.pr-note { font-size: .85rem; color: #4a5552; font-style: italic; white-space: pre-wrap; }
.pr-foot { margin-top: 2rem; font-size: .75rem; color: #8a928f; border-top: 1px solid #e2ded4; padding-top: .5rem; }
.shop { list-style: none; padding: 0; columns: 2; }
.shop li { break-inside: avoid; padding: .2rem 0; }
.shop label { flex-direction: row; font-weight: 500; gap: .5rem; align-items: center; }
@media (max-width: 600px) { .shop { columns: 1; } .print-doc { padding: 1rem; } }
@media print {
  @page { margin: 14mm; }
  body { background: #fff; }
  .no-print, .topbar { display: none !important; }
  .print-doc { border: 0; padding: 0; }
  .view { max-width: none; }
}
.toast { pointer-events: none; }
.meal-time { width: 118px; }
.it .mini { opacity: .4; } .it:hover .mini, .it.locked .mini { opacity: 1; }
.it:has(.it-g[value="0"]) { opacity: .55; text-decoration: line-through; }

/* ======================================================================
   VERSIONE 3: chat 2.0, scanner, notifiche, da seguire, acqua, consensi
   ====================================================================== */
/* --- chat --- */
.chat2 { display: flex; flex-direction: column; padding: 0; overflow: hidden; height: min(72vh, 760px); }
.chat2 > .notice { margin: .8rem; }
.chat-pinned { padding: .5rem 1rem; background: var(--accent-soft); font-size: .85rem; border-bottom: 1px solid var(--line); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-pinned a { color: inherit; }
.chat-scroll { flex: 1; overflow-y: auto; padding: .8rem 1rem; display: flex; flex-direction: column; overscroll-behavior: contain; }
.chat-more { align-self: center; margin-bottom: .5rem; }
.chat-items { display: flex; flex-direction: column; gap: .35rem; }
.day-sep { text-align: center; margin: .8rem 0 .4rem; }
.day-sep span { background: var(--surface-2); color: var(--muted); font-size: .75rem; padding: .15rem .7rem; border-radius: 99px; text-transform: capitalize; }
.msg2 { max-width: min(78%, 520px); align-self: flex-start; display: flex; flex-direction: column; }
.msg2.mine { align-self: flex-end; align-items: flex-end; }
.bubble2 { position: relative; background: var(--surface-2); padding: .5rem .75rem .35rem; border-radius: 16px 16px 16px 5px; overflow-wrap: anywhere; }
.msg2.mine .bubble2 { background: var(--brand); color: #fff; border-radius: 16px 16px 5px 16px; }
.msg2.auto .bubble2 { background: var(--brand-soft); color: var(--ink); }
@media (prefers-color-scheme: dark) { .msg2.mine .bubble2 { color: #0c1412; } }
.msg2.mine .bubble2 a { color: inherit; }
.msg-text { white-space: normal; }
.msg-foot { display: flex; gap: .35rem; justify-content: flex-end; align-items: center; font-size: .7rem; opacity: .75; margin-top: .15rem; }
.tick.read { color: #8fe3c4; }
.msg2:not(.mine) .tick.read { color: var(--brand); }
.msg-menu-btn { position: absolute; top: .1rem; right: -1.9rem; border: 0; background: none; color: var(--muted); font-size: 1.1rem; cursor: pointer; opacity: 0; transition: opacity .15s; padding: .2rem .4rem; }
.msg2.mine .msg-menu-btn { right: auto; left: -1.9rem; }
.msg2:hover .msg-menu-btn, .msg-menu-btn:focus { opacity: 1; }
@media (pointer: coarse) { .msg-menu-btn { opacity: .55; } }
.quote { display: block; border-left: 3px solid var(--accent); padding: .2rem .5rem; margin-bottom: .3rem; font-size: .8rem; background: rgba(0,0,0,.06); border-radius: 6px; color: inherit; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.quote b { display: block; font-size: .72rem; }
.msg-img img { display: block; max-width: 260px; max-height: 260px; border-radius: 10px; margin-bottom: .25rem; object-fit: cover; }
.msg-audio { width: 240px; max-width: 100%; height: 36px; }
.msg-video { max-width: 280px; border-radius: 10px; }
.msg-file { display: inline-flex; align-items: center; gap: .4rem; padding: .4rem .6rem; background: rgba(0,0,0,.07); border-radius: 10px; color: inherit; text-decoration: none; max-width: 100%; }
.msg-file span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg-file small { opacity: .7; }
.rx-row { display: flex; gap: .25rem; margin-top: -.25rem; z-index: 1; }
.rx { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 0 .4rem; font-size: .85rem; cursor: pointer; }
.rx.on { border-color: var(--brand); background: var(--brand-soft); }
.rx small { margin-left: .15rem; }
.rx-pick { display: flex; flex-wrap: wrap; gap: .3rem; justify-content: center; margin-bottom: .8rem; }
.rx-big { font-size: 1.6rem; background: var(--surface-2); border: 0; border-radius: 12px; padding: .3rem .5rem; cursor: pointer; }
.menu-list { display: grid; gap: .4rem; }
.flash .bubble2 { outline: 3px solid var(--accent); }
.chat-typing { min-height: 1.2rem; font-size: .78rem; color: var(--muted); padding: 0 1rem; font-style: italic; }
.chat-reply, .chat-quick { border-top: 1px solid var(--line); padding: .45rem 1rem; font-size: .85rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; background: var(--surface-2); }
.chat-quick { flex-direction: column; align-items: stretch; padding: .3rem; max-height: 220px; overflow-y: auto; }
.chat-quick button { text-align: left; border: 0; background: none; padding: .45rem .6rem; border-radius: 8px; cursor: pointer; color: inherit; font: inherit; }
.chat-quick button small { display: block; color: var(--muted); }
.chat-quick button.on, .chat-quick button:hover { background: var(--brand-soft); }
.chat-compose { display: flex; gap: .4rem; align-items: flex-end; border-top: 1px solid var(--line); padding: .6rem .7rem calc(.6rem + env(safe-area-inset-bottom)); background: var(--surface); }
.chat-compose textarea { flex: 1; resize: none; min-height: 2.5rem; max-height: 160px; border-radius: 20px; padding: .55rem .9rem; }
.chat-attach, .chat-mic { font-size: 1.15rem; flex: none; cursor: pointer; }
.chat-recorder { display: flex; align-items: center; gap: .6rem; padding: .7rem 1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.chat-recorder audio { height: 36px; flex: 1; min-width: 180px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: #d33; animation: pulse 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; }
@keyframes pulse { 50% { opacity: .3; } }
/* inbox */
.inbox2 { display: grid; grid-template-columns: 320px 1fr; gap: 1rem; align-items: start; }
.threads2 { position: sticky; top: 1rem; max-height: calc(100vh - 9rem); display: flex; flex-direction: column; }
.threads-tools { padding: .7rem; border-bottom: 1px solid var(--line); display: grid; gap: .5rem; }
.threads-tools input { width: 100%; }
#t-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; }
#t-list li { position: relative; border-bottom: 1px solid var(--line); }
#t-list li a { display: flex; gap: .6rem; align-items: center; padding: .65rem 2.2rem .65rem .8rem; text-decoration: none; color: inherit; }
#t-list li.on a { background: var(--brand-soft); }
#t-list li.unread strong { font-weight: 800; }
#t-list .t-body { flex: 1; min-width: 0; }
#t-list .t-body small:last-child { display: block; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.t-menu { position: absolute; right: .3rem; top: 50%; transform: translateY(-50%); }
.avatar.sm { width: 2.2rem; height: 2.2rem; font-size: .8rem; flex: none; }
.thread-head { display: flex; align-items: center; gap: .7rem; margin-bottom: .6rem; flex-wrap: wrap; }
.thread-head > div:nth-child(3) { flex: 1; display: flex; flex-direction: column; }
.back-thread { display: none; }
.seg-sm button, .seg-sm label { font-size: .78rem; padding: .25rem .55rem; }
.pick-list { display: flex; flex-wrap: wrap; gap: .3rem; max-height: 220px; overflow-y: auto; padding: .4rem 0; }
@media (max-width: 860px) {
  .inbox2 { grid-template-columns: 1fr; }
  .inbox2.has-thread .threads2 { display: none; }
  .inbox2:not(.has-thread) #thread2 { display: none; }
  .threads2 { position: static; max-height: none; }
  .back-thread { display: inline-flex; }
  .chat2 { height: calc(100dvh - 14rem); }
  .msg-menu-btn { right: -1.6rem; }
}

/* --- scanner --- */
.scan-view { position: relative; background: #000; border-radius: 12px; overflow: hidden; aspect-ratio: 4 / 3; max-height: 60vh; }
.scan-video { width: 100%; height: 100%; object-fit: cover; display: block; }
.scan-box { position: absolute; left: 5%; right: 5%; top: 25%; bottom: 25%; border: 3px solid rgba(255,255,255,.9); border-radius: 12px; box-shadow: 0 0 0 999px rgba(0,0,0,.35); }
.scan-laser { position: absolute; left: 4%; right: 4%; top: 50%; height: 2px; background: #ff5a3c; box-shadow: 0 0 8px #ff5a3c; animation: laser 1.6s ease-in-out infinite; }
@keyframes laser { 0%, 100% { transform: translateY(-40px); } 50% { transform: translateY(40px); } }
.scan-status { position: absolute; bottom: .6rem; left: 0; right: 0; text-align: center; color: #fff; font-size: .85rem; text-shadow: 0 1px 3px #000; }
.scan-tools { display: flex; justify-content: center; margin: .5rem 0; }
.scan-alt { display: grid; gap: .6rem; margin-top: .8rem; }
.file-btn { cursor: pointer; text-align: center; }
.file-btn.done { border-color: var(--ok); color: var(--ok); }
.product-card { display: flex; gap: .8rem; align-items: flex-start; padding: .7rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); margin: .5rem 0; }
.product-img { width: 64px; height: 64px; object-fit: contain; border-radius: 8px; background: #fff; flex: none; }
.product-img.ph { display: grid; place-items: center; font-size: 1.8rem; background: var(--surface-2); }
.warn-text { color: var(--danger); }
.search-scan { display: flex; gap: .5rem; align-items: flex-end; }
.search-scan label { flex: 1; }
.recents { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; }
.chip-btn { border: 1px solid var(--line); background: var(--surface-2); border-radius: 99px; padding: .2rem .65rem; font: inherit; font-size: .8rem; cursor: pointer; color: inherit; }
.chip-btn:hover { border-color: var(--brand); }
.sub-img { max-width: 100%; border-radius: 10px; }
.sub-row { display: flex; justify-content: space-between; gap: .6rem; flex-wrap: wrap; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.sub-row small { display: block; color: var(--muted); }

/* --- da seguire --- */
.attention li { display: flex; align-items: center; gap: .4rem; }
.attention li > a:first-child { flex: 1; }
.st-dot { width: .75rem; height: .75rem; border-radius: 50%; flex: none; }
.st-risk { background: var(--danger); } .st-warn { background: #e2a52b; } .st-idle { background: #8b8f8e; } .st-ok { background: var(--ok); } .st-pause { background: #6a7dc9; }
.att-kpi { display: flex; gap: .8rem; text-align: center; }
.att-kpi b { display: block; line-height: 1.1; } .att-kpi small { font-size: .68rem; color: var(--muted); }
@media (max-width: 600px) { .att-kpi { display: none; } }
.nudge { display: flex; align-items: center; gap: .8rem; background: var(--brand-soft); }
.nudge > span { font-size: 1.6rem; }
.nudge > div { flex: 1; display: flex; flex-direction: column; }
.nudge small { color: var(--muted); }

/* --- acqua --- */
.water-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin: .4rem 0 .6rem; }
.water-bar span { display: block; height: 100%; background: linear-gradient(90deg, #4aa3df, #2b7bbf); border-radius: 99px; transition: width .3s; }
.glasses { display: flex; gap: .3rem; flex-wrap: wrap; margin-bottom: .5rem; }
.glass { width: 16px; height: 22px; border: 2px solid #4aa3df; border-top: 0; border-radius: 0 0 5px 5px; opacity: .5; }
.glass.on { background: #4aa3df; opacity: 1; }

/* --- consensi e firma --- */
.consent-doc .pre, p.pre { white-space: pre-wrap; }
.sig-pad-wrap { position: relative; }
.sig-pad { width: 100%; height: 180px; border: 2px dashed var(--line); border-radius: 12px; background: #fff; touch-action: none; display: block; }
.sig-pad-wrap button { position: absolute; top: .4rem; right: .4rem; }
.sig-box { border-top: 1px solid var(--line); margin-top: 1rem; padding-top: .8rem; }
.sig-img { max-width: 280px; background: #fff; border-radius: 8px; border: 1px solid var(--line); }
.copy-row { display: flex; gap: .4rem; } .copy-row input { flex: 1; font-family: ui-monospace, monospace; font-size: .8rem; }

/* --- questionari: nota e diario --- */
.q-note { margin-top: .4rem; }
.q-note summary { cursor: pointer; color: var(--brand-2); font-size: .85rem; }
.q-note textarea { width: 100%; margin-top: .3rem; }
.ans-note { font-size: .85rem; color: var(--muted); margin-top: .2rem; }
.comments { list-style: none; padding: 0; margin: 0 0 .6rem; display: grid; gap: .5rem; }
.comments li { background: var(--surface-2); padding: .5rem .7rem; border-radius: 10px; }
.comments li.mine { background: var(--brand-soft); }
.comments p { margin: .2rem 0 0; }
.grow { flex: 1; }
.alt-pick { border: 1px solid var(--line); border-radius: 10px; padding: .4rem .6rem; }
.link-card { display: flex; flex-direction: column; text-decoration: none; color: inherit; }
@media print { .no-print, .modal-head { display: none !important; } }

/* ======================================================================
   VERSIONE 3.1: fatture, listino, dispositivi, foto IA
   ====================================================================== */
.pill { display: inline-block; font-size: .72rem; padding: .1rem .5rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); margin: .1rem .2rem .1rem 0; white-space: nowrap; }
.pill-ok { background: var(--brand-soft); color: var(--ok); } .pill-warn { background: #fbf0d6; color: #8a6210; } .pill-err { background: var(--accent-soft); color: var(--danger); }
@media (prefers-color-scheme: dark) { .pill-warn { background: #3a3218; color: #e6c463; } }
.seg a { text-decoration: none; color: inherit; padding: .3rem .7rem; border-radius: 8px; display: inline-block; }
.seg a.on { background: var(--brand); color: #fff; }
.inv-line { display: flex; gap: .4rem; margin-bottom: .4rem; } .inv-line input:first-child { flex: 1; }
.sum-dl { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; margin: 0; } .sum-dl dd { margin: 0; text-align: right; font-variant-numeric: tabular-nums; }
.invoice-doc { max-width: 820px; } .inv-head { display: flex; justify-content: space-between; gap: 1rem; flex-wrap: wrap; border-bottom: 2px solid var(--brand); padding-bottom: .8rem; margin-bottom: .8rem; }
.inv-head h2 { margin: 0; } .inv-no { text-align: right; } .inv-client { margin: .6rem 0 1rem; }
.inv-tot { max-width: 340px; margin-left: auto; margin-top: .6rem; } .inv-actions { margin-bottom: .8rem; flex-wrap: wrap; }
.shop-item .big small { font-size: .9rem; color: var(--muted); }
.dev-card h3 { margin-top: 0; } .steps-list li { margin-bottom: .4rem; }
.ai-plate { display: grid; grid-template-columns: 220px 1fr; gap: 1rem; } .ai-photo { width: 100%; border-radius: 12px; object-fit: cover; max-height: 300px; }
.ai-items { list-style: none; padding: 0; margin: .5rem 0; display: grid; gap: .4rem; } .ai-items li { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; } .ai-name { flex: 1; min-width: 140px; }
.chip.warn { background: var(--accent-soft); color: var(--danger); }
.ai-wait { text-align: center; padding: 2rem 0; } .spinner { display: inline-block; width: 32px; height: 32px; border: 3px solid var(--line); border-top-color: var(--brand); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (max-width: 600px) { .ai-plate { grid-template-columns: 1fr; } .inv-no { text-align: left; } }
@media print { .invoice-doc { box-shadow: none; border: 0; max-width: none; } .sidebar, .topbar, .bottom-nav, .back { display: none !important; } }

/* ===== Editor dei piani: trascinamento, selezione multipla, appunti, gruppi, vista compatta (come Fiber) ===== */
.row-grip { cursor: grab; color: var(--muted); font-weight: 800; padding: 0 .15rem; user-select: none; opacity: .55; }
.row:hover .row-grip { opacity: 1; }
.row-sel { width: auto !important; margin: 0 .2rem 0 0; accent-color: var(--brand); opacity: .45; }
.row:hover .row-sel, .row.sel .row-sel { opacity: 1; }
.row.sel { background: var(--brand-soft); border-left-color: var(--brand-2); border-radius: 6px; }
.row.dragging { opacity: .45; }
.row.drop-before { box-shadow: 0 -3px 0 var(--brand-2); }
.row.drop-after { box-shadow: 0 3px 0 var(--brand-2); }
.meal.drop-meal { outline: 2px dashed var(--brand-2); outline-offset: 2px; }
.meal.focus { border-color: var(--brand-2); }
.row-group { font-weight: 800; font-size: .85rem; color: var(--brand-2); margin-bottom: .1rem; }
.sel-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; padding: .5rem .6rem; border: 1px dashed var(--line); border-radius: 10px; margin: .2rem 0 .7rem; }
.sel-bar.on { border-style: solid; border-color: var(--brand-2); background: var(--brand-soft); position: sticky; top: .5rem; z-index: 5; }
.sel-clip { margin-left: auto; display: inline-flex; gap: .3rem; }
.pe-viewseg { margin-left: auto; }
.pe.compact .opt.alt, .pe.compact [data-act="add-alt"], .pe.compact .hint, .pe.compact .row-note, .pe.compact .pe-targets, .pe.compact .pe-exercise, .pe.compact .pe-notes { display: none; }
.pe.compact .row { padding-top: .1rem; padding-bottom: .1rem; }
.meal-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: .6rem; }
.meal-pick fieldset { border: 1px solid var(--line); border-radius: 10px; padding: .4rem .7rem; margin: 0; }
.meal-pick legend { font-weight: 800; font-size: .85rem; padding: 0 .3rem; }
.pr-group, .day-group { font-weight: 800; }
/* Editor dei questionari: trascinamento di domande e sezioni */
.ed-grip { cursor: grab; color: var(--muted); font-weight: 800; user-select: none; align-self: flex-start; padding: .35rem .1rem; }
.ed-q.drop-before, .ed-section.drop-before { box-shadow: 0 -3px 0 var(--brand-2); }
.ed-q.drop-after, .ed-section.drop-after { box-shadow: 0 3px 0 var(--brand-2); }
/* Kinetica Coach integrato */
.kin-frame { display: block; width: 100%; height: calc(100vh - 48px); min-height: 560px; border: 0; border-radius: 14px; background: #EEF2F1; }
.kin-frame-tab { height: calc(100vh - 230px); min-height: 640px; }
@media (max-width: 900px) { .kin-frame { height: calc(100dvh - 140px); border-radius: 0; margin: 0 -1rem; width: calc(100% + 2rem); } .kin-frame-tab { height: calc(100dvh - 160px); } }
@media (prefers-color-scheme: dark) { .kin-frame { background: #0E1513; } }
/* Agenda unica */
.ag-view a { text-decoration: none; }
.ag-filter { display: flex; align-items: center; gap: .8rem; flex-wrap: wrap; margin: .2rem 0 .8rem; }
.ag-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; vertical-align: -1px; margin-left: .4rem; }
.ag-dot.nutrizione { background: var(--brand-2); } .ag-dot.allenamento { background: #1D5BC4; }
.appt.area-allenamento { border-left-color: #1D5BC4; background: #DCE6F8; }
.appt.area-allenamento.annullato { opacity: .55; }
.area-chip-allenamento { background: #DCE6F8; color: #1D5BC4; }
@media (prefers-color-scheme: dark) { .appt.area-allenamento { background: #1F2D47; border-left-color: #86ABF2; } .ag-dot.allenamento { background: #86ABF2; } .area-chip-allenamento { background: #1F2D47; color: #86ABF2; } }
.seg a { background: var(--surface); padding: .35rem .7rem; font-size: .82rem; font-weight: 700; color: var(--muted); }
.seg a.on { background: var(--brand); color: #fff; }

/* ===== 3.4: navigazione più semplice ===== */
.bell-n[hidden] { display: none; }
.sidebar { overflow-y: auto; }
.nav-group { font-size: .68rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; color: rgba(255,255,255,.5); padding: 1rem .7rem .3rem; }
.side-search { display: flex; align-items: center; gap: .5rem; width: 100%; margin: -.6rem 0 .8rem; padding: .5rem .7rem; border-radius: 10px; border: 1px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: rgba(255,255,255,.8); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.side-search:hover { background: rgba(255,255,255,.12); color: #fff; }
.side-search kbd { margin-left: auto; font: 700 .7rem system-ui; opacity: .7; border: 1px solid rgba(255,255,255,.3); border-radius: 5px; padding: 1px 5px; }
.bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; background: none; border: 0; color: var(--muted); font: inherit; font-size: 1.1rem; padding: .25rem 0; cursor: pointer; }
.bottom-nav button small { font-size: .68rem; font-weight: 600; }
.more-menu h4 { margin: .9rem 0 .4rem; }
.more-menu h4:first-child { margin-top: 0; }
.more-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: .4rem; }
.more-grid a, .more-grid button { display: flex; flex-direction: column; align-items: center; gap: .25rem; padding: .7rem .3rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); text-decoration: none; font: inherit; font-size: .8rem; font-weight: 700; text-align: center; cursor: pointer; }
.more-grid span { font-size: 1.2rem; }
.search-box input { font-size: 1.05rem; padding: .75rem .9rem; }
.search-res { margin: .6rem 0; max-height: 50vh; overflow-y: auto; }
.search-res a.sel { background: var(--brand-soft); border-radius: 8px; }
.search-res small { display: block; }
/* sezioni del paziente: gruppi e sottosezioni */
.subtabs-pn { display: flex; gap: .4rem; margin: -.6rem 0 1.1rem; flex-wrap: wrap; }
.subtabs-pn a { padding: .35rem .8rem; border-radius: 99px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-weight: 700; font-size: .85rem; text-decoration: none; }
.subtabs-pn a.on { background: var(--brand); border-color: var(--brand); color: #fff; }
/* home del paziente */
.tiles-h { margin: 1.4rem 0 -.3rem; }
.more-tiles { margin-top: 1.2rem; }
.more-tiles summary { cursor: pointer; font-weight: 800; color: var(--muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 900px) { .tiles { grid-template-columns: repeat(2, 1fr) !important; } }
/* primi passi */
.first-steps h3 { margin: 0; }
.fs-bar { height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; margin: .6rem 0 .4rem; }
.fs-bar span { display: block; height: 100%; background: var(--brand-2); }
.fs-list { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: .2rem .8rem; }
.fs-list a { display: flex; align-items: center; gap: .7rem; padding: .55rem .2rem; text-decoration: none; color: inherit; }
.fs-list small { display: block; color: var(--muted); font-size: .8rem; }
.fs-check { flex: none; width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: .8rem; font-weight: 800; color: #fff; }
.fs-list li.done .fs-check { background: var(--ok); border-color: var(--ok); }
.fs-list li.done strong { color: var(--muted); text-decoration: line-through; }

/* ===== 3.5: agenda del mese ===== */
.ag-bar { display: flex; justify-content: space-between; align-items: center; gap: .8rem; flex-wrap: wrap; margin-bottom: .8rem; }
.ag-nav { display: flex; align-items: center; gap: .5rem; }
.ag-month { font-size: 1.25rem; text-transform: capitalize; min-width: 11ch; text-align: center; }
.ag-layers { display: flex; gap: .4rem; flex-wrap: wrap; }
.ag-layer { display: inline-flex; align-items: center; gap: .4rem; border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: .3rem .75rem; font: inherit; font-size: .82rem; font-weight: 700; color: var(--ink); cursor: pointer; }
.ag-layer.off { opacity: .45; text-decoration: line-through; }
.ag-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--c, #888); flex: none; vertical-align: 0; }
.ag-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 1rem; align-items: start; }
.ag-month-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.ag-wd { font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); text-align: center; padding: .2rem 0; }
.ag-cell { min-height: 112px; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 5px; display: flex; flex-direction: column; gap: 2px; text-align: left; font: inherit; color: var(--ink); cursor: pointer; overflow: hidden; }
.ag-cell:hover { border-color: var(--muted); }
.ag-cell.out { opacity: .5; }
.ag-cell.today .ag-n { background: var(--accent); color: #fff; }
.ag-cell.sel { border-color: var(--brand-2); box-shadow: inset 0 0 0 1px var(--brand-2); }
.ag-n { font-size: .78rem; font-weight: 800; width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; }
.ag-ev { font-size: .7rem; line-height: 1.25; padding: 2px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; background: color-mix(in srgb, var(--c) 16%, var(--surface)); color: color-mix(in srgb, var(--c) 80%, var(--ink)); border-left: 3px solid var(--c); }
.ag-ev.ext { background: transparent; border-left-style: dotted; }
.ag-ev.cancelled, .ag-item.cancelled { text-decoration: line-through; opacity: .5; }
.ag-more { font-size: .68rem; color: var(--muted); font-weight: 700; padding-left: 4px; }
.ag-dots { display: none; gap: 3px; flex-wrap: wrap; margin-top: auto; }
.ag-dots i { width: 7px; height: 7px; border-radius: 50%; }
.ag-side { position: sticky; top: 1rem; }
.ag-day-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .6rem; }
.ag-day-head h3 { margin: 0; text-transform: capitalize; }
.ag-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: .4rem; }
.ag-item { display: flex; gap: .7rem; width: 100%; text-align: left; align-items: flex-start; border: 0; border-left: 4px solid var(--c); background: color-mix(in srgb, var(--c) 9%, var(--surface)); border-radius: 8px; padding: .5rem .6rem; font: inherit; color: var(--ink); cursor: pointer; }
.ag-item small { display: block; color: var(--muted); }
.ag-time { font-weight: 800; font-size: .85rem; min-width: 3.2rem; }
.ag-area-seg button.on { background: var(--c); color: #fff; }
.ag-blue { background: #1D5BC4; border-color: #1D5BC4; }
.ag-color { width: 38px; height: 30px; padding: 2px; }
@media (max-width: 1100px) { .ag-wrap { grid-template-columns: 1fr; } .ag-side { position: static; } }
@media (max-width: 700px) {
  .ag-cell { min-height: 54px; padding: 3px; }
  .ag-ev, .ag-more { display: none; }
  .ag-dots { display: flex; }
  .ag-month { font-size: 1.05rem; }
}

/* ===================== Riatletizzazione (3.6) ===================== */
.rts-kpis { margin-bottom: 1rem; }
.rts-cases, .rts-protos { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: .9rem; }
.rts-case-card, .rts-proto-card { text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: .35rem; margin: 0; }
.rts-case-card:hover, .rts-proto-card:hover { border-color: var(--brand-2); }
.rts-phase-line { display: grid; grid-template-columns: 1fr 110px auto; gap: .6rem; align-items: center; font-size: .88rem; }
.rts-bar { display: block; height: 8px; border-radius: 99px; background: var(--surface-2); overflow: hidden; margin: .3rem 0; }
.rts-bar > span { display: block; height: 100%; background: linear-gradient(90deg, var(--accent), var(--brand-2)); border-radius: 99px; }
.rts-cat { margin-bottom: 1.4rem; }
.rts-cat h3 small { font-weight: 500; font-size: .8rem; }
.rts-test-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .6rem; }
.rts-test-tile { text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; cursor: pointer; font: inherit; color: inherit; display: flex; flex-direction: column; gap: .25rem; }
.rts-test-tile:hover { border-color: var(--brand-2); }
.rts-test-tile small { color: var(--muted); font-size: .78rem; line-height: 1.35; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.rts-lab-head { margin-bottom: 1rem; gap: 1rem; }
.rts-lab-head input { max-width: 520px; }
.rts-phases { display: flex; flex-direction: column; gap: .8rem; }
.rts-phase { border: 1px solid var(--line); border-radius: 12px; padding: .8rem 1rem; }
.rts-phase.cur { border-color: var(--accent); background: var(--accent-soft); }
.rts-ph-grid ul { margin: .2rem 0 .6rem; padding-left: 1.1rem; }
.rts-ph-grid li { margin: .15rem 0; }
.warn-list li { color: var(--danger); }
.rts-src li { margin: .2rem 0; }
.rts-crit { list-style: none; padding: 0 !important; }
.rts-crit li { display: flex; gap: .5rem; align-items: center; padding: .4rem .5rem; border-radius: 8px; margin: .2rem 0; background: var(--surface-2); }
.rts-crit li.ok { background: var(--brand-soft); }
.rts-crit li.ko { background: var(--accent-soft); }
.rts-crit .ic { width: 1.4rem; height: 1.4rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-weight: 800; font-size: .8rem; background: var(--surface); flex: none; }
.rts-crit li.ok .ic { color: var(--ok); } .rts-crit li.ko .ic { color: var(--danger); }
.rts-crit .tick { display: inline-flex; flex-direction: row; gap: .25rem; align-items: center; font-size: .8rem; font-weight: 600; }
.rts-steps { list-style: none; padding: 0; margin: 1rem 0; display: flex; gap: .3rem; overflow-x: auto; }
.rts-steps li { flex: 1; min-width: 92px; }
.rts-steps li button { width: 100%; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: .45rem .4rem; font: inherit; font-size: .76rem; cursor: pointer; color: var(--muted); display: flex; flex-direction: column; align-items: center; gap: .2rem; text-align: center; line-height: 1.2; }
.rts-steps .dot { width: 1.6rem; height: 1.6rem; border-radius: 50%; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; color: var(--muted); }
.rts-steps li.done .dot { background: var(--brand-soft); color: var(--ok); }
.rts-steps li.cur .dot { background: var(--accent); color: #fff; }
.rts-steps li.cur button { color: var(--ink); font-weight: 700; }
.rts-steps li.view button { border-color: var(--brand-2); box-shadow: 0 0 0 1px var(--brand-2) inset; }
.small-steps li { min-width: 0; display: flex; justify-content: center; }
.rts-continuum { display: flex; gap: .3rem; flex-wrap: wrap; margin: .6rem 0 0; }
.rts-continuum span { font-size: .75rem; font-weight: 700; padding: .25rem .7rem; border-radius: 99px; background: var(--surface-2); color: var(--muted); }
.rts-continuum span.on { background: var(--brand); color: #fff; }
.rts-chiptests { display: flex; flex-wrap: wrap; gap: .35rem; }
.rts-pt-head { margin-bottom: 1rem; gap: .8rem; flex-wrap: wrap; }
.rts-tf-head { display: flex; justify-content: space-between; gap: 1rem; align-items: flex-start; }
.rts-tf-head h3 { margin: 0; }
.rts-rows { display: flex; flex-direction: column; gap: .35rem; margin: .4rem 0 .8rem; }
.rts-row { display: grid; grid-template-columns: 1.6rem repeat(var(--nf, 3), minmax(0, 1fr)) auto; gap: .4rem; align-items: center; }
.rts-rows.compact .rts-row { grid-auto-flow: column; grid-template-columns: 1.6rem; grid-auto-columns: minmax(0, 1fr); }
.rts-rows.compact .rts-row > .rts-row-tools { width: auto; }
.rts-row-h { font-size: .72rem; color: var(--muted); font-weight: 700; }
.rts-row.stacked { display: flex; flex-wrap: wrap; gap: .5rem; border-bottom: 1px dashed var(--line); padding-bottom: .5rem; }
.rts-row.stacked .rts-f { flex: 1 1 200px; font-size: .8rem; }
.rts-n { font-size: .75rem; font-weight: 800; color: var(--muted); }
.rts-row input, .rts-row select { min-width: 0; width: 100%; }
.rts-row-tools { display: inline-flex; gap: .2rem; }
.rts-row-add { display: flex; gap: .4rem; flex-wrap: wrap; }
.rts-res { background: var(--surface-2); border-radius: 12px; padding: .7rem .8rem; margin: .5rem 0 1rem; }
.rts-res .kpis > div { background: var(--surface); }
.rts-res .kpis > div.main { background: var(--brand); }
.rts-picker h4 { margin-top: .9rem; }
.rts-picker .chips { display: flex; flex-wrap: wrap; gap: .35rem; }
.rts-ed-phase { margin: .6rem 0; }
.rts-crit-row { display: flex; gap: .35rem; align-items: center; margin: .25rem 0; flex-wrap: wrap; }
.rts-crit-row select:first-child { max-width: 320px; }
.rts-scale { display: flex; flex-direction: column; gap: .1rem; }
.rts-scale output { font-weight: 800; color: var(--brand); }
.rts-my h2 { margin: 0; }
.rts-ex li.done { color: var(--ok); }
.rts-print h2 { margin-top: 1.2rem; font-size: 1.05rem; }
.nowrap { white-space: nowrap; }
/* analisi video */
.vt-top { display: flex; gap: .8rem; align-items: flex-end; flex-wrap: wrap; margin-bottom: .6rem; }
.vt-num { font-size: .78rem; display: inline-flex; flex-direction: column; }
.vt-num input { width: 6.5rem; }
.vt-stage { position: relative; background: #000; border-radius: 10px; overflow: hidden; max-height: 62vh; aspect-ratio: 16 / 9; margin: 0 auto; max-width: 100%; }
.vt-stage video, .vt-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; }
.vt-stage canvas { cursor: crosshair; }
.vt-empty { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; color: #ddd; padding: 2rem; text-align: center; }
.vt-ctrl { display: flex; gap: .35rem; align-items: center; margin: .6rem 0; flex-wrap: wrap; }
.vt-time { font-variant-numeric: tabular-nums; font-size: .82rem; color: var(--muted); min-width: 9rem; text-align: right; }
.vt-tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-bottom: .5rem; }
.vt-marks { display: flex; gap: .3rem; flex-wrap: wrap; }
.vt-out { margin: .4rem 0; }
.ac-canvas { width: 100%; height: 160px; background: var(--surface-2); border-radius: 10px; margin: .5rem 0; }
@media (max-width: 700px) {
  .rts-phase-line { grid-template-columns: 1fr; }
  .rts-lr.grid-2, .rts-ph-grid.grid-2 { grid-template-columns: 1fr; }
  .rts-rows.compact .rts-row { grid-auto-flow: row; grid-template-columns: 1.6rem 1fr 1fr; }
  .rts-rows.compact .rts-row-h { display: none; }
}
@media print { .no-print { display: none !important; } }
.vt-empty[hidden] { display: none; }
.rts-steps li { padding: 0 !important; margin: 0 !important; background: none !important; border: 0 !important; }
.rts-steps li::before, .rts-steps li::after { display: none !important; }
.rts-crit-row select[data-ck="m"] { flex: 1 1 260px; width: auto; max-width: none; }
.rts-crit-row select[data-ck="op"] { flex: none; width: 4.5rem; }
.rts-crit-row input[data-ck="v"] { flex: none; width: 5.5rem; }
.rts-crit-row input[data-ck="label"] { flex: 2 1 200px; width: auto; }
.rts-crit-row [hidden] { display: none !important; }
.rts-vpanel { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; border: 2px dashed var(--brand-2); background: var(--brand-soft); border-radius: 14px; padding: .9rem 1rem; margin: .8rem 0; }
.rts-vpanel-ico { font-size: 2rem; }
.rts-vpanel small { display: block; color: var(--muted); font-size: .8rem; }
.rts-vpanel select { width: auto; }
.vt-rec { position: absolute; left: .6rem; right: .6rem; bottom: .6rem; display: flex; gap: .5rem; align-items: center; background: rgba(0,0,0,.6); color: #fff; padding: .4rem .6rem; border-radius: 10px; flex-wrap: wrap; z-index: 2; }
.vt-rec[hidden] { display: none; }
.vt-rec .rec-dot { width: .7rem; height: .7rem; border-radius: 50%; background: #888; }
.vt-rec.on .rec-dot { background: #e53935; animation: vtblink 1s infinite; }
@keyframes vtblink { 50% { opacity: .3; } }
.vt-empty small { color: #bbb; }
@media (hover: hover) and (pointer: fine) { .vt-phone { display: none; } }
.vt-rec [hidden] { display: none !important; }
/* 3.7: niente sbordamenti su telefono */
@media (max-width: 700px) {
  .card table.table:not(.table-wrap table) { display: block; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .search-scan { flex-wrap: wrap; }
  .search-scan label { flex: 1 1 100%; }
  .rts-case .actions, .rts-pt-head .actions { flex-wrap: wrap; }
  .view { overflow-x: clip; }
}
.chip-link { background: transparent; border: 1px solid var(--line); color: var(--brand-2); cursor: pointer; }
.chip-link:hover { border-color: var(--brand-2); }
.ok-text { color: var(--ok); } .warn-text { color: var(--danger); }
.rts-stats { margin-bottom: .4rem; }
.rts-base { border: 1px solid var(--line); border-radius: 12px; padding: .6rem .9rem; }
.rts-base legend { font-weight: 700; font-size: .85rem; padding: 0 .3rem; }
/* 3.8 */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; }
@media (max-width: 800px) { .grid-3 { grid-template-columns: 1fr; } }
.rts-radar { width: 100%; max-width: 340px; display: block; margin: 0 auto; }
.rts-radar .rg { fill: none; stroke: var(--line); }
.rts-radar .r90 { stroke: var(--accent); stroke-dasharray: 4 4; }
.rts-radar .rv { fill: color-mix(in srgb, var(--brand-2) 25%, transparent); stroke: var(--brand-2); stroke-width: 2; }
.rts-radar .rd { fill: var(--brand-2); } .rts-radar .rd.low { fill: var(--danger); }
.rts-radar .rl { font-size: 9px; fill: var(--muted); } .rts-radar .rv2 { font-weight: 700; fill: var(--ink); } .rts-radar .rv2.low { fill: var(--danger); }
.rts-hep-list { list-style: none; padding: 0; margin: .5rem 0; }
.rts-hep-list li { display: flex; gap: .7rem; align-items: center; padding: .5rem 0; border-bottom: 1px solid var(--line); }
.rts-hep-list li:last-child { border-bottom: 0; }
.rts-hep-list img, .rts-hep-noimg { width: 64px; height: 48px; object-fit: cover; border-radius: 8px; flex: none; background: var(--surface-2); display: inline-flex; align-items: center; justify-content: center; }
.rts-hep-list .grow { display: flex; flex-direction: column; min-width: 0; }
.rts-hep-list small { font-size: .78rem; }
.rts-hep-list.pt li.done { opacity: .65; }
.rts-hep-list.pt li.done strong { text-decoration: line-through; }
.rts-hep-tools { display: inline-flex; gap: .2rem; flex-wrap: wrap; justify-content: flex-end; }
.rts-hep-ck { display: flex; flex-direction: column; align-items: center; font-size: .72rem; font-weight: 700; color: var(--muted); }
.rts-hep-ck input { width: 1.6rem; height: 1.6rem; accent-color: var(--ok); }
.rts-hp-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: .4rem; max-height: 55vh; overflow: auto; margin: .6rem 0; }
.rts-hp-item { display: flex; gap: .5rem; align-items: center; border: 1px solid var(--line); border-radius: 10px; padding: .35rem; cursor: pointer; flex-direction: row; font-weight: 400; }
.rts-hp-item.on { border-color: var(--brand-2); background: var(--brand-soft); }
.rts-hp-item img, .rts-hp-item .rts-hep-noimg { width: 56px; height: 42px; object-fit: cover; border-radius: 6px; flex: none; }
.rts-hp-item span { display: flex; flex-direction: column; font-size: .85rem; }
.rts-hp-item small { color: var(--muted); }
.rts-edu-pro { list-style: none; padding: 0; } .rts-edu-pro li { display: flex; justify-content: space-between; gap: .5rem; padding: .35rem 0; border-bottom: 1px solid var(--line); font-size: .9rem; }
.rts-edu details { border: 1px solid var(--line); border-radius: 10px; padding: .5rem .7rem; margin: .35rem 0; }
.rts-edu summary { cursor: pointer; font-weight: 700; }
.rts-avail { margin: .4rem 0 .6rem; }
.rts-gs input, .rts-gs select { min-width: 4.5rem; }
.rts-print-logo img { max-height: 60px; max-width: 200px; float: right; }
.form-inline { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; }
.form-inline label { display: inline-flex; flex-direction: row; gap: .4rem; align-items: center; }
.form-inline input, .form-inline select { width: auto; }
.rts-hep-list img, .rts-hp-item img { object-fit: contain; background: #fff; }

/* ===== 3.9 Editor come Fiber ===== */
.pe-toolbar { position: sticky; bottom: .6rem; z-index: 20; display: flex; align-items: center; gap: .15rem; flex-wrap: wrap; margin: 1rem auto 0; width: fit-content; max-width: 100%;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .3rem .45rem; box-shadow: 0 8px 28px rgba(0,0,0,.14); }
.pe-toolbar .tb { border: 0; background: transparent; border-radius: 9px; padding: .3rem .45rem; cursor: pointer; display: inline-flex; flex-direction: column; align-items: center; font-size: 1rem; line-height: 1.1; color: var(--ink); min-width: 44px; }
.pe-toolbar .tb span { font-size: .62rem; font-weight: 700; color: var(--muted); }
.pe-toolbar .tb:hover:not(:disabled) { background: var(--surface-2); }
.pe-toolbar .tb:disabled { opacity: .35; cursor: default; }
.pe-toolbar .tb-count { padding: 0 .5rem; font-size: .8rem; max-width: 14rem; }
.pe-toolbar .tb-sep { width: 1px; align-self: stretch; background: var(--line); margin: 0 .2rem; }
.inl-add { position: relative; display: flex; gap: .4rem; align-items: center; margin-top: .35rem; border-radius: 9px; }
.inl-add .inl-q { flex: 1; border: 1px dashed var(--line); background: transparent; padding: .45rem .6rem; border-radius: 9px; font-size: .9rem; }
.inl-add .inl-q:focus { border-style: solid; border-color: var(--brand-2); background: var(--surface); }
.inl-add.drop-into { outline: 2px dashed var(--brand-2); }
.inl-pop { position: absolute; left: 0; right: 0; top: calc(100% + 4px); z-index: 40; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 14px 34px rgba(0,0,0,.18); max-height: 360px; display: flex; flex-direction: column; overflow: hidden; }
.inl-tabs { display: flex; gap: .2rem; padding: .4rem .5rem; border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.inl-tabs button { border: 0; background: transparent; padding: .25rem .55rem; border-radius: 8px; font-weight: 700; font-size: .8rem; color: var(--muted); cursor: pointer; }
.inl-tabs button.on { color: var(--ink); background: var(--surface-2); }
.inl-list { overflow: auto; flex: 1; }
.inl-item { display: flex; align-items: center; gap: .3rem; width: 100%; text-align: left; padding: .45rem .7rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; cursor: pointer; font: inherit; }
.inl-item > div { flex: 1; min-width: 0; }
.inl-item small { display: block; color: var(--muted); }
.inl-item.on, .inl-item:hover { background: var(--brand-soft); }
.inl-mac { display: flex; gap: .9rem; font-size: .72rem; color: var(--muted); margin-top: .1rem; }
.inl-mac b { color: var(--ink); }
.inl-foot { padding: .35rem .7rem; border-top: 1px solid var(--line); }
.it-name[draggable="true"] { cursor: grab; }
.it.dragging, .meal.dragging, .pe-tab.dragging { opacity: .45; }
.opt.drop-into { outline: 2px dashed var(--brand-2); outline-offset: 2px; border-radius: 9px; background: var(--brand-soft); }
.meal.drop-before { box-shadow: 0 -4px 0 var(--brand-2); } .meal.drop-after { box-shadow: 0 4px 0 var(--brand-2); }
.pe-tab.drop-into { outline: 2px dashed var(--accent); }
.meal-grip { cursor: grab; color: var(--muted); font-weight: 800; user-select: none; }
.meal-ico { font-size: 1.05rem; }
.it.manual { border-color: var(--accent); }
button.adhoc { border: 0; background: none; padding: 0 .15rem 0 0; cursor: pointer; font-size: .8rem; }
.it-u { padding: .1rem .2rem; font-size: .75rem; max-width: 7.5rem; border-radius: 6px; }
.pe-pie { display: flex; align-items: center; gap: .8rem; margin: .4rem 0; }
.pe-pie ul { list-style: none; margin: 0; padding: 0; font-size: .82rem; }
.pe-pie li { display: flex; align-items: center; gap: .35rem; }
.pe-pie i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.copy-in .ci-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.copy-in .ci-row > b { min-width: 9rem; font-size: .85rem; }
.copy-in .ci-row .chips { flex: 1; }
.chip-check.is-src span { opacity: .45; }
.switch-row { display: flex !important; flex-direction: row !important; align-items: center; gap: .5rem; font-weight: 600; }
@media (max-width: 700px) { .pe-toolbar .tb span { display: none; } .pe-toolbar .tb { min-width: 34px; } .inl-mac { gap: .5rem; } }
.it-g { -moz-appearance: textfield; }
.it-g::-webkit-inner-spin-button, .it-g::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.ex-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.ex-bar > label { display: flex; flex-direction: column; font-size: .75rem; font-weight: 700; }
.ex-bar select { min-width: 16rem; }
.ex-bar .ex-sp { flex: 1; }
.ex-checks label { display: flex; padding: .25rem .6rem; font-weight: 600; }
.ex-hint { margin: .3rem 0 .8rem; }
#ex-doc .ex-doc { border: 1px solid var(--line); border-radius: 12px; }
.ex-doc.ex-editing { outline: 2px dashed var(--accent); outline-offset: 4px; }
.ex-doc.ex-land { max-width: none; }
body.printing .view:has(.ex-land) { max-width: 1200px; }
@media print { #ex-doc .ex-doc { border: 0; padding: 0; } .ex-doc.ex-editing { outline: 0; } }

/* ===== 3.9 Timeline del cliente ===== */
.tl { padding: .6rem .7rem; margin-bottom: .9rem; overflow: hidden; }
.tl-bar { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.tl-toggle { border: 0; background: none; font-weight: 800; cursor: pointer; font-size: .95rem; padding: .2rem .3rem; color: var(--ink); }
.tl-zoom button { font-size: .75rem; padding: .2rem .5rem; }
.tl-sp { flex: 1; }
.menu-list.menu-right { right: 0; left: auto; }
.tl-new .menu-list a { display: block; padding: .45rem .8rem; white-space: nowrap; color: var(--ink); text-decoration: none; }
.tl-new .menu-list a:hover { background: var(--surface-2); }
.tl-lanes .menu-list label { display: flex; padding: .3rem .7rem; font-weight: 600; }
.tl-scroll { overflow-x: auto; margin-top: .5rem; border: 1px solid var(--line); border-radius: 10px; }
.tl-inner { position: relative; }
.tl-head, .tl-lane { display: flex; border-bottom: 1px solid var(--line); }
.tl { --tl-lab: 150px; }
.tl-lab { position: sticky; left: 0; z-index: 3; width: var(--tl-lab); flex: 0 0 var(--tl-lab); display: flex; align-items: center; gap: .35rem; padding: 0 .55rem; font-size: .78rem; font-weight: 800; color: #fff; background: var(--c, var(--brand)); border-right: 1px solid var(--line); }
.tl-corner { background: var(--surface); color: var(--muted); font-weight: 600; }
.tl-scale { position: relative; height: 38px; background: var(--surface); }
.tl-month { position: absolute; top: 2px; font-size: .72rem; font-weight: 800; color: var(--ink); padding-left: 3px; border-left: 1px solid var(--line); white-space: nowrap; }
.tl-days { position: absolute; left: 0; right: 0; bottom: 0; height: 18px; }
.tl-day { position: absolute; font-size: .62rem; color: var(--muted); text-align: center; }
.tl-day.we { color: var(--danger); }
.tl-day.today { background: var(--accent); color: #fff; border-radius: 4px; font-weight: 800; }
.tl-track { position: relative; background: repeating-linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), transparent 100%); }
.tl-lane:nth-child(even) .tl-track { background: color-mix(in srgb, var(--surface-2) 45%, transparent); }
.tl-barx { position: absolute; height: 18px; border-radius: 6px; background: color-mix(in srgb, var(--c) 30%, var(--surface)); border: 1px solid var(--c); color: var(--ink); font-size: .7rem; font-weight: 700; line-height: 16px; padding: 0 .4rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; }
.tl-barx small { font-weight: 500; color: var(--muted); }
.tl-barx.draft { border-style: dashed; background: var(--surface); }
.tl-barx.open { border-right-width: 0; border-top-right-radius: 0; border-bottom-right-radius: 0; }
.tl-barx:hover, .tl-dot:hover { filter: brightness(.93); z-index: 2; }
.tl-dot { position: absolute; top: 50%; width: 12px; height: 12px; margin: -6px 0 0 -6px; border-radius: 50%; background: var(--c); border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--c); text-decoration: none; }
.tl-dot.wait { background: var(--surface); }
.tl-dot.off { opacity: .35; }
.tl-dot span { position: absolute; left: 14px; top: -3px; font-size: .66rem; color: var(--ink); white-space: nowrap; font-weight: 600; pointer-events: none; }
.tl-bal .tl-lab { background: var(--ink); }
.tl-week { position: absolute; top: 3px; bottom: 3px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: .72rem; border-right: 1px solid var(--line); color: var(--muted); }
.tl-week b { color: var(--ink); } .tl-week small { font-size: .6rem; }
.tl-week.ok b { color: #2e7d32; } .tl-week.over b { color: var(--danger); } .tl-week.under b { color: #3f86b8; }
.tl-nowl { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); opacity: .7; pointer-events: none; }
.tl-legend { margin: .4rem 0 0; }
@media (max-width: 700px) { .tl { --tl-lab: 96px; } .tl-lab { font-size: .68rem; } .tl-lab span { display: none; } }
/* ===== 3.9 Report come Fiber ===== */
.rp-bar { display: flex; flex-wrap: wrap; gap: .5rem; align-items: flex-end; }
.rp-bar > label { display: flex; flex-direction: column; font-size: .75rem; font-weight: 700; }
.rp-bar select { min-width: 12rem; }
.rp-sp { flex: 1; }
.rp-views { margin: .7rem 0 .4rem; }
.rp-group { display: flex; gap: .6rem; align-items: baseline; padding: .3rem 0; border-top: 1px solid var(--line); flex-wrap: wrap; }
.rp-group > b { min-width: 7rem; font-size: .8rem; color: var(--muted); }
.rp-group .chips { flex: 1; }
.rp-gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .7rem; }
.rp-gallery figure { margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
.rp-gallery img { width: 100%; aspect-ratio: 3/4; object-fit: cover; display: block; }
.rp-gallery figcaption { font-size: .75rem; padding: .3rem .5rem; color: var(--muted); }
@media print { .rp-bar, .rp-views, .rp-group input, .no-print { display: none !important; } .rp-chart { break-inside: avoid; } }
/* ===== 3.9 Moduli in tempo reale ===== */
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: #2e9d5b; margin-left: .3rem; vertical-align: middle; animation: livepulse 1.6s infinite; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(46,157,91,.55); } 70% { box-shadow: 0 0 0 8px rgba(46,157,91,0); } 100% { box-shadow: 0 0 0 0 rgba(46,157,91,0); } }
.q-watch #q-draft { margin-top: .8rem; }
.q-studio { margin-bottom: .6rem; padding-bottom: .5rem; border-bottom: 1px solid var(--line); }

/* ===== 3.9 Valutazione funzionale (come My Jump Lab) ===== */
.mj { max-width: 900px; margin: 0 auto; padding-bottom: 5rem; }
.mj-top { display: flex; align-items: center; gap: .8rem; padding: .9rem 1rem; border-radius: 16px; background: linear-gradient(180deg, color-mix(in srgb, #d9577a 75%, var(--surface)) 0%, var(--surface) 100%); margin-bottom: 1rem; }
.mj-title { flex: 1; text-align: center; } .mj-title h1 { margin: 0; font-size: 1.5rem; } .mj-title small { color: var(--muted); }
.mj-avatar { width: 42px; height: 42px; border-radius: 50%; border: 2px solid #d9577a; background: var(--surface); color: #c2405f; font-weight: 800; display: inline-grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.mj-avatar.sm { width: 34px; height: 34px; font-size: .8rem; border-width: 1.5px; }
.mj-h2 { font-size: 1.2rem; margin: .4rem 0 .8rem; }
.mj-list { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; margin-bottom: 1rem; }
.mj-item { display: flex; align-items: center; gap: .8rem; width: 100%; padding: .75rem 1rem; border: 0; border-bottom: 1px solid var(--line); background: transparent; text-align: left; cursor: pointer; color: var(--ink); text-decoration: none; font: inherit; }
.mj-item:last-child { border-bottom: 0; } .mj-item:hover, .mj-item.on { background: color-mix(in srgb, #d9577a 9%, var(--surface)); }
.mj-item > span:not(.mj-ico):not(.mj-chev):not(.mj-tags):not(.mj-avatar) { flex: 1; min-width: 0; }
.mj-item b { display: block; font-weight: 600; } .mj-item small { display: block; color: var(--muted); font-size: .78rem; }
.mj-ico { font-size: 1.35rem; width: 2rem; text-align: center; }
.mj-chev { color: var(--muted); font-size: 1.3rem; }
.mj-tags { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.mj-group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: .8rem; overflow: hidden; }
.mj-group-h { width: 100%; display: flex; justify-content: space-between; padding: .7rem 1rem; border: 0; background: var(--surface-2); font-weight: 700; cursor: pointer; color: var(--ink); font: inherit; font-weight: 700; }
.mj-group .mj-list { border: 0; border-radius: 0; margin: 0; display: none; }
.mj-group.open .mj-list { display: block; }
.mj-tabs { position: fixed; left: 50%; transform: translateX(-50%); bottom: .8rem; z-index: 30; display: flex; gap: .2rem; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: .3rem; box-shadow: 0 8px 26px rgba(0,0,0,.14); }
.mj-tabs a { display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: .3rem .5rem; border-radius: 11px; color: var(--muted); text-decoration: none; font-size: .72rem; font-weight: 700; }
.mj-tabs a span { font-size: 1.1rem; } .mj-tabs a.on { color: #c2405f; background: color-mix(in srgb, #d9577a 10%, var(--surface)); }
.mj-note { text-align: center; }
.mj-big { font-size: 1.25rem; font-weight: 800; margin-bottom: .4rem; }
.mj-rank { display: flex; flex-direction: column; gap: .35rem; }
.mj-rank-row { display: grid; grid-template-columns: 2.2rem minmax(8rem, 1.3fr) 2fr auto 4.5rem; align-items: center; gap: .6rem; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: .5rem .7rem; }
.mj-pos { width: 2rem; height: 2rem; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--surface-2); }
.mj-pos.p1 { background: #f2c94c; } .mj-pos.p2 { background: #d7dbe0; } .mj-pos.p3 { background: #e3a76f; }
.mj-rank-name small { display: block; color: var(--muted); font-size: .72rem; }
.mj-rank-bar { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; } .mj-rank-bar i { display: block; height: 100%; background: #d9577a; border-radius: 99px; }
.mj-z { font-size: .75rem; text-align: right; } .mj-z.up { color: #2e7d32; } .mj-z.down { color: var(--danger); }
.mj-timer { text-align: center; } .mj-time { font-size: 3.4rem; font-weight: 800; font-variant-numeric: tabular-nums; margin: .5rem 0; }
.mj-laps { text-align: left; max-width: 16rem; margin: .5rem auto; }
.hv-video { width: 100%; max-height: 120px; object-fit: cover; border-radius: 10px; background: #000; }
@media (max-width: 700px) { .mj-tabs { bottom: 4.6rem; } .mj-tabs a { min-width: 58px; font-size: .64rem; } .mj-rank-row { grid-template-columns: 2rem 1fr auto; } .mj-rank-bar, .mj-z { display: none; } }
@media print { .mj-tabs, .mj-top .btn { display: none; } }
.mj-hero { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: .8rem 1rem; margin-bottom: .8rem; }
.mj-hero small { color: var(--muted); font-weight: 700; letter-spacing: .04em; font-size: .7rem; }
.mj-hero b { font-size: 2.3rem; } .mj-hero > div span { color: var(--muted); }
.mj-delta { float: right; font-weight: 800; font-size: 1rem; } .mj-delta.up { color: #2e9d5b !important; } .mj-delta.down { color: var(--danger) !important; }
.mj-pr { color: #3f86b8; font-size: .8rem; margin: .1rem 0 .4rem; font-weight: 700; }
.mj-cmp { display: grid; grid-template-columns: 1fr 1fr; gap: 0; height: 14px; margin-top: .4rem; }
.mj-cmp i { display: block; height: 100%; } .mj-cmp i:first-child { background: #c9c5bb; justify-self: end; } .mj-cmp i:last-child { background: #4aa3df; }
.mj-item input[type=checkbox] { width: 1.2rem; height: 1.2rem; }
.vt-hint { margin-left: .6rem; }

/* 3.11 — prontezza, batterie, report di una pagina, tempi del percorso */
@media (max-width: 480px) { .mj-tabs a { min-width: 52px; padding: .3rem .15rem; font-size: .66rem; } }
.pill-bad { background: color-mix(in srgb, #c0392b 14%, var(--surface)); color: #b0281f; }
.bad-text { color: #b0281f; }
.rd-kpis { margin: .6rem 0 .9rem; }
.rd-table tr.sel td { background: color-mix(in srgb, var(--accent, #2b6cb0) 8%, var(--surface)); }
.rd-in { display: inline-flex; gap: .3rem; align-items: center; } .rd-in input { width: 7.5rem; }
.bat-prog { height: 8px; border-radius: 4px; background: var(--line); overflow: hidden; margin: .4rem 0 .2rem; } .bat-prog span { display: block; height: 100%; background: #2c7a4b; }
.rep1-bar { display: inline-block; width: 80px; height: 8px; background: var(--line); border-radius: 4px; vertical-align: middle; } .rep1-bar span { display: block; height: 100%; background: var(--accent, #2b6cb0); border-radius: 4px; }
.rts-tl .tl-grid { display: grid; grid-template-columns: minmax(120px, 28%) 1fr; gap: .35rem .8rem; align-items: center; margin: .6rem 0; }
.rts-tl .tl-name { font-size: .82rem; } .rts-tl .tl-name.cur { font-weight: 700; }
.rts-tl .tl-track { position: relative; height: 18px; background: color-mix(in srgb, var(--line) 45%, transparent); border-radius: 4px; }
.rts-tl .tl-plan { position: absolute; top: 3px; height: 12px; border-radius: 3px; background: color-mix(in srgb, var(--accent, #2b6cb0) 22%, transparent); border: 1px dashed color-mix(in srgb, var(--accent, #2b6cb0) 60%, transparent); }
.rts-tl .tl-act { position: absolute; top: 5px; height: 8px; border-radius: 3px; background: #2c7a4b; } .rts-tl .tl-act.cur { background: var(--accent, #2b6cb0); }
.rts-tl .tl-now { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #c0392b; }
.rts-tl .tl-tgt { position: absolute; top: 4px; width: 10px; height: 10px; transform: translateX(-5px) rotate(45deg); background: #9a5b00; }
@media (max-width: 600px) { .rts-tl .tl-grid { grid-template-columns: 1fr; } }
.rd-name { background: none; border: 0; padding: 0; font: inherit; font-weight: 700; color: var(--ink, inherit); cursor: pointer; text-align: left; text-decoration: underline; text-decoration-color: var(--line); }
.rd-table td:first-child { white-space: nowrap; }

/* 3.12 — fotocamera, piano giornaliero, app del paziente, quadranti */
.mo-ctl { display: flex; flex-wrap: wrap; gap: .5rem .8rem; margin-bottom: .6rem; } .mo-ctl label { display: flex; flex-direction: column; font-size: .78rem; gap: .2rem; } .mo-ctl label.mo-ck { flex-direction: row; align-items: center; }
.mo-ctl input[type=number] { width: 5rem; } .mo-hz span { display: flex; gap: .3rem; align-items: center; }
.mo-stage { position: relative; background: #111; border-radius: 12px; overflow: hidden; aspect-ratio: 16 / 9; max-height: 62vh; margin: 0 auto; transition: box-shadow .2s; }
.mo-stage.in { box-shadow: 0 0 0 5px #2c7a4b inset; }
.mo-stage video, .mo-stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; } .mo-stage .mirror { transform: scaleX(-1); }
.mo-hud { position: absolute; left: 0; right: 0; bottom: 0; padding: .6rem .8rem; background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; }
.mo-big { font: 800 2.6rem/1 system-ui, sans-serif; } .mo-sub { font-size: .9rem; margin-top: .2rem; }
.mo-bar { position: relative; height: 8px; border-radius: 4px; background: rgba(255,255,255,.25); margin-top: .5rem; } .mo-bar span { position: absolute; top: 0; bottom: 0; background: rgba(44,200,110,.75); border-radius: 4px; } .mo-bar i { position: absolute; top: -4px; width: 3px; height: 16px; background: #ff8a3d; }
.pl-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .3rem; margin: .5rem 0; }
.pl-day { display: flex; flex-direction: column; align-items: center; gap: .1rem; padding: .4rem .2rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); cursor: pointer; min-height: 84px; font: inherit; color: inherit; }
.pl-day small { font-size: .68rem; color: var(--muted); } .pl-day b { font-size: 1.1rem; } .pl-day span { font-size: .68rem; text-align: center; overflow: hidden; max-height: 2.6em; } .pl-day em { font-size: .64rem; color: var(--muted); }
.pl-day.today { border-color: var(--accent, #2b6cb0); } .pl-day.ok { background: color-mix(in srgb, #2c7a4b 10%, var(--surface)); } .pl-day.warn { background: color-mix(in srgb, #e3aa52 14%, var(--surface)); } .pl-day.bad { background: color-mix(in srgb, #c0392b 10%, var(--surface)); }
.pl-ms { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: .3rem; } .pl-ms li { display: flex; align-items: center; gap: .6rem; } .pl-ms li > span { width: 1.6rem; height: 1.6rem; border-radius: 50%; display: grid; place-items: center; background: var(--line); font-size: .8rem; } .pl-ms li.done > span { background: #2c7a4b; color: #fff; } .pl-ms li small { color: var(--muted); margin-left: auto; }
@media (max-width: 600px) { .pl-day span, .pl-day em { display: none; } .pl-day { min-height: 56px; } }
.streak { display: flex; flex-wrap: wrap; align-items: baseline; gap: .4rem .6rem; padding: .5rem .7rem; border-radius: 12px; background: color-mix(in srgb, #e67e22 10%, var(--surface)); margin: .6rem 0; } .streak b { font-size: 1.3rem; } .streak .badges { font-size: 1.2rem; }
.hep-tools { display: flex; flex-wrap: wrap; gap: .3rem; align-items: center; margin-top: .3rem; }
.ht { text-align: center; } .ht-ph { font-weight: 700; } .ht-n { font: 800 3.4rem/1.1 system-ui, sans-serif; margin: .4rem 0; } .ht-s { color: var(--muted); margin-bottom: .6rem; }
.my-test { border-top: 1px solid var(--line); padding: .5rem 0; } .my-test summary { cursor: pointer; display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; }
.norm-bar { position: relative; height: 10px; border-radius: 5px; background: var(--line); margin: .5rem 0 .3rem; } .norm-bar .band { position: absolute; top: 0; bottom: 0; background: color-mix(in srgb, #2c7a4b 35%, transparent); border-radius: 5px; } .norm-bar i { position: absolute; top: -4px; width: 4px; height: 18px; margin-left: -2px; background: var(--accent, #2b6cb0); border-radius: 2px; }
.quad { width: 100%; max-width: 720px; display: block; margin: .6rem auto; color: var(--ink, #222); }
.rep1-com { margin-top: .8rem; padding: .6rem .8rem; border-radius: 10px; background: color-mix(in srgb, var(--accent, #2b6cb0) 6%, var(--surface)); } .rep1-com h3 { margin: 0 0 .3rem; font-size: 1rem; } .rep1-com ul { margin: 0; padding-left: 1.1rem; }
.rts-tiles fieldset { border: 1px solid var(--line); border-radius: 10px; margin: 0 0 .5rem; }

/* 3.13 — diario: fotodietometro, descrizione, etichetta */
.diary-ways { display: flex; flex-wrap: wrap; gap: .4rem; }
.atl input#atl-q { width: 100%; margin: .4rem 0; }
.atl-cats { display: flex; flex-wrap: wrap; gap: .3rem; margin-bottom: .6rem; } .atl-cats button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: .25rem .7rem; font: inherit; font-size: .8rem; cursor: pointer; color: inherit; } .atl-cats button.on { background: var(--ink, #1d2b28); color: var(--surface); }
.atl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .5rem; max-height: 58vh; overflow: auto; }
.atl-tile { display: flex; flex-direction: column; gap: .15rem; text-align: left; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); padding: .35rem; cursor: pointer; font: inherit; color: inherit; }
.atl-tile img { width: 100%; aspect-ratio: 265 / 222; object-fit: cover; border-radius: 8px; } .atl-tile b { font-size: .82rem; line-height: 1.2; } .atl-tile small { color: var(--muted); font-size: .72rem; }
.atl-noimg { display: grid; place-items: center; aspect-ratio: 265 / 222; background: var(--line); border-radius: 8px; font-size: 1.6rem; } .atl-noimg.big { font-size: 2.4rem; }
.atl-ports { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: .6rem; margin: .6rem 0; }
.atl-port { display: flex; flex-direction: column; gap: .15rem; border: 2px solid var(--line); border-radius: 12px; padding: .4rem; cursor: pointer; }
.atl-port:has(input:checked), .atl-port.on { border-color: var(--accent, #2b6cb0); background: color-mix(in srgb, var(--accent, #2b6cb0) 7%, var(--surface)); }
.atl-port input { position: absolute; opacity: 0; pointer-events: none; } .atl-port img { width: 100%; border-radius: 8px; }
.atl-ports.mini { grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); } .atl-ports.mini .atl-port span { font-size: .72rem; }
.atl-fac { gap: .3rem; align-items: center; flex-wrap: wrap; } .chip-radio { display: inline-flex; align-items: center; gap: .25rem; border: 1px solid var(--line); border-radius: 999px; padding: .2rem .6rem; font-size: .82rem; cursor: pointer; }
.atl-sug { border: 1px dashed var(--line); border-radius: 12px; padding: .5rem .6rem; margin: .4rem 0; }
.rv-photo { max-width: 260px; display: block; margin-bottom: .4rem; border-radius: 10px; }
.btn.rec { background: #c0392b; color: #fff; }
/* 3.13 dispendio adattivo */
.xp .xp-kpi{display:flex;flex-wrap:wrap;gap:18px;margin:8px 0 12px}
.xp .xp-kpi>div{min-width:130px}
.xp .xp-kpi small{display:block;color:var(--muted,#667);font-size:.78rem}
.xp .xp-big{font-size:2rem;font-weight:700}
.xp .xp-mid{font-size:1.35rem;font-weight:600}
.xp .xp-goal{align-items:center;gap:14px;flex-wrap:wrap;margin-bottom:8px}
#xp-card{margin-bottom:14px}
#pxp{margin-bottom:14px}
@media (max-width:520px){.ai-items li{display:grid;grid-template-columns:auto auto 1fr auto;align-items:center}.ai-items .ai-name{grid-column:1/-1}}
.xp select{width:auto;max-width:100%}
/* 3.14 IA interna */
.lp-bar{height:8px;border-radius:4px;background:var(--line,#e5e7eb);overflow:hidden;margin:.6rem auto;max-width:320px}
.lp-bar span{display:block;height:100%;width:0;background:var(--accent,#2f7d4f);transition:width .3s}
.lp-res{display:grid;grid-template-columns:minmax(0,220px) 1fr;gap:1rem;align-items:start}
.lp-res .atl-tile.on{outline:2px solid var(--accent,#2f7d4f)}
@media (max-width:620px){.lp-res{grid-template-columns:1fr}.lp-res .rv-photo{max-height:200px;object-fit:cover;width:100%}}
.atl-mine{display:flex;gap:.6rem;align-items:center;margin:.4rem 0}.atl-mine img{width:110px;height:110px;object-fit:cover;border-radius:10px}
/* 3.15 digiuno */
.fast-main{display:flex;gap:1.2rem;align-items:center;flex-wrap:wrap}
.fast-ring{width:150px;height:150px}.fast-ring .fr-bg{fill:none;stroke:var(--line);stroke-width:10}.fast-ring .fr-fg{fill:none;stroke:var(--brand);stroke-width:10;stroke-linecap:round;transition:stroke-dashoffset .6s}.fast-ring .fr-fg.done{stroke:var(--ok)}
.fast-ring .fr-t{font-size:17px;font-weight:800;fill:var(--ink)}.fast-ring .fr-s{font-size:9px;fill:var(--muted)}
.fast-info{flex:1;min-width:200px}.fast-info p{margin:.2rem 0}
.fast-protos{display:flex;flex-wrap:wrap;gap:.4rem;margin:.6rem 0}
.fast-stats{display:grid;grid-template-columns:repeat(auto-fit,minmax(110px,1fr));gap:.6rem;margin:.8rem 0}.fast-stats b{display:block;font-size:1.2rem}.fast-stats small{color:var(--muted)}
.fast-bars{display:flex;gap:4px;align-items:flex-end;height:90px;margin-top:.4rem}.fast-bars div{flex:1;display:flex;flex-direction:column;justify-content:flex-end;height:100%;align-items:center}
.fast-bars span{display:block;width:100%;background:var(--muted);opacity:.5;border-radius:4px 4px 0 0}.fast-bars span.ok{background:var(--brand);opacity:1}.fast-bars small{font-size:.65rem;color:var(--muted)}
#h-fast .card,#d-fast .card{margin-bottom:1rem}
/* 3.15 pulsante + e primi passi */
.qa-fab{position:fixed;right:18px;bottom:84px;width:58px;height:58px;border-radius:50%;border:0;background:var(--brand);color:#fff;font-size:2rem;line-height:1;box-shadow:0 6px 18px rgba(0,0,0,.25);z-index:40;cursor:pointer;display:grid;place-items:center}
.qa-fab span{margin-top:-3px}
@media (min-width:900px){.qa-fab{bottom:28px;right:28px}}
@media print{.qa-fab{display:none}}
.qa-grid{display:grid;grid-template-columns:repeat(3,1fr);gap:.6rem}
.qa-btn{display:flex;flex-direction:column;align-items:center;gap:.3rem;padding:.8rem .4rem;border:1px solid var(--line);border-radius:14px;background:var(--surface);color:var(--ink);font:inherit;font-weight:600;font-size:.85rem;text-align:center;cursor:pointer;text-decoration:none}
.qa-btn span{font-size:1.6rem}
.qa-btn:hover{border-color:var(--brand)}
.first-steps .fs-bar{height:8px;background:var(--line);border-radius:4px;overflow:hidden;margin:.4rem 0 .8rem}.first-steps .fs-bar span{display:block;height:100%;background:var(--brand)}
.fs-list{list-style:none;padding:0;margin:0;display:grid;gap:.5rem}.fs-list li{display:flex;gap:.6rem;align-items:flex-start}.fs-list li small{display:block}
.fs-ck{width:22px;height:22px;flex:none;border-radius:50%;border:2px solid var(--line);display:grid;place-items:center;font-size:.8rem;font-weight:800}
.fs-list li.ok .fs-ck{background:var(--ok);border-color:var(--ok);color:#fff}.fs-list li.ok span{color:var(--muted)}
.diary-more{border:1px dashed var(--line);border-radius:12px;padding:.5rem .8rem}.diary-more summary{cursor:pointer;font-weight:600;color:var(--muted)}.diary-more .form-grid{margin-top:.6rem}
.dict-all{border:1px dashed var(--line);border-radius:12px;padding:.5rem .8rem}.dict-all summary{cursor:pointer;font-weight:700}
.help-btn{border:1px solid var(--line);background:var(--surface);border-radius:12px;width:40px;height:40px;font-weight:800;font-size:1.05rem;cursor:pointer;color:var(--ink)}
.help-list{padding-left:1.1rem;display:grid;gap:.5rem;margin:0 0 .8rem}
html.fs-l body{zoom:1.12}html.fs-xl body{zoom:1.25}
.fs-pick{display:flex;gap:.4rem}.fs-pick button.on{background:var(--brand);color:#fff;border-color:var(--brand)}
/* 3.17 mappa del dolore, statistiche, lista d'attesa */
.pm-wrap{display:grid;grid-template-columns:1fr 1fr;gap:.6rem;max-width:520px}.pm-wrap.small{max-width:360px}
.pm-svg{width:100%;height:auto}.pm-body{fill:var(--surface-2,#eef1ef);stroke:var(--line);stroke-width:1.5}
.pm-z{stroke:transparent;stroke-width:2;cursor:pointer;fill-opacity:.85}.pm-z:hover,.pm-z:focus{stroke:var(--brand);fill:var(--brand-soft)!important;outline:none}.pm-z.on{stroke:#fff}
.pm-lab{font-size:8px;fill:var(--muted);letter-spacing:.04em}
.pm-list{list-style:none;padding:0;display:grid;gap:.3rem;margin:.6rem 0}.pm-n{display:inline-block;padding:0 .4rem;border-radius:6px;font-weight:700;font-size:.8rem}
.pm-alert{border:2px solid var(--danger);border-radius:14px;padding:1rem;background:var(--accent-soft)}.pm-ok{border:2px solid var(--ok);border-radius:14px;padding:1rem}
.pm-actions{margin-bottom:.8rem}.pm-card{margin-bottom:1rem}.pm-tr td,.pm-tr th{padding:.3rem .5rem}
.st-kpi{grid-template-columns:repeat(auto-fit,minmax(110px,1fr))}
.st-bars{display:flex;align-items:flex-end;gap:4px;height:120px;margin:.8rem 0 .2rem}.st-bars div{flex:1;display:flex;flex-direction:column;justify-content:flex-end;align-items:center;height:100%}.st-bars span{display:block;width:100%;background:var(--brand);border-radius:4px 4px 0 0;min-height:2px}.st-bars small{font-size:.65rem;color:var(--muted)}
#dash-stats{margin-top:1rem}#ag-wl{margin-top:1rem}.wl li{display:flex;justify-content:space-between;gap:.6rem;align-items:center}
.dict-found{margin:.6rem 0;padding:.6rem .8rem}.dict-found ul{margin:.3rem 0 .5rem 1rem;padding:0}
.insights{margin-bottom:1rem}.ins-kpi{display:flex;gap:1.4rem;margin:.4rem 0}.ins-kpi b{font-size:1.3rem;display:block}.ins-kpi small{color:var(--muted)}
.ins-list{list-style:none;padding:0;margin:.4rem 0 0;display:grid;gap:.35rem}.ins-list li{font-size:.92rem}
