:root {
  --bg: #fafafa;
  --surface: #fff;
  --text: #1d1d1f;
  --muted: #6e6e73;
  --line: #e5e5ea;
  --accent: #2f6fde;
  --accent-soft: #eaf1fd;
  --ok: #1f8a4c;
  --warn: #b26a00;
  --err: #c62828;
  --radius: 10px;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
a { color: var(--accent); text-decoration: none; }
h1 { font-size: 24px; margin: 0 0 4px; font-weight: 650; }
h2 { font-size: 17px; margin: 28px 0 12px; font-weight: 650; }
h3 { font-size: 15px; margin: 18px 0 8px; font-weight: 600; }
.muted { color: var(--muted); }
.small { font-size: 13px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 28px; padding: 0 24px; height: 56px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); font-size: 17px; }
.top nav { display: flex; gap: 4px; }
.top nav a { color: var(--muted); padding: 6px 12px; border-radius: 8px; }
.top nav a.active { color: var(--text); background: var(--bg); font-weight: 600; }
main { max-width: 1100px; margin: 0 auto; padding: 28px 24px 80px; }

.bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; }
.bar .grow { flex: 1; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 14px; }

button, .btn { font: inherit; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--text); padding: 7px 14px; border-radius: 8px; display: inline-flex; align-items: center; gap: 6px; }
button:hover, .btn:hover { border-color: #c7c7cc; }
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.danger { color: var(--err); }
button.link { border: 0; background: none; padding: 2px 4px; color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }

input, select, textarea { font: inherit; color: inherit; border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; background: var(--surface); width: 100%; }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
input[type=checkbox], input[type=radio] { width: auto; accent-color: var(--accent); }
label.f { display: block; margin-bottom: 12px; }
label.f > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 0 16px; }
.grid .wide { grid-column: 1 / -1; }
.checks { display: flex; flex-wrap: wrap; gap: 6px 16px; padding: 4px 0; }
.checks label { display: inline-flex; align-items: center; gap: 6px; }
.scale { display: flex; gap: 4px; flex-wrap: wrap; }
.scale label { border: 1px solid var(--line); border-radius: 8px; padding: 5px 10px; cursor: pointer; font-size: 14px; }
.scale input { display: none; }
.scale label:has(input:checked) { background: var(--accent); border-color: var(--accent); color: #fff; }

table { width: 100%; border-collapse: collapse; }
th { text-align: left; font-weight: 500; font-size: 13px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--bg); }
.t-center { text-align: center; }

.pill { display: inline-block; font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--bg); border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.ok { color: var(--ok); border-color: #bfe3cc; background: #eef8f1; }
.pill.warn { color: var(--warn); border-color: #f0d9b0; background: #fdf6ea; }
.pill.err { color: var(--err); border-color: #f2c4c4; background: #fdeeee; }
.t-lezione { background: #efe9fb; color: #5b3cc4; border-color: #ddd2f6; }
.t-lab_presenza { background: #e8f4ec; color: #1f7a45; border-color: #cbe7d4; }
.t-lab_online { background: #e7f1fb; color: #1f5f9e; border-color: #cbe0f4; }
.t-cq_individuale, .t-cq_iniziale, .t-cq_finale { background: #fdf1e3; color: #9a5a00; border-color: #f4dcbc; }

.head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin-bottom: 22px; overflow-x: auto; }
.tabs a { padding: 9px 14px; color: var(--muted); border-bottom: 2px solid transparent; white-space: nowrap; }
.tabs a.active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

.week { margin-bottom: 22px; }
.week h3 { display: flex; gap: 10px; align-items: baseline; }
.day { display: grid; grid-template-columns: 130px 1fr; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); }
.day:first-of-type { border-top: 0; }
.day .dname { color: var(--muted); font-size: 14px; padding-top: 6px; }
.day.today .dname { color: var(--accent); font-weight: 600; }
.act { display: grid; grid-template-columns: 100px 1fr auto; gap: 10px; align-items: center; padding: 5px 0; }
.act .when { font-variant-numeric: tabular-nums; font-size: 14px; }
.act .what { min-width: 0; }
.act .where { color: var(--muted); font-size: 13px; }
.act .tools { opacity: 0; }
.act:hover .tools { opacity: 1; }

.saved { font-size: 13px; color: var(--muted); min-width: 80px; text-align: right; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.note { background: var(--accent-soft); border-radius: 8px; padding: 10px 14px; font-size: 14px; margin-bottom: 14px; }
.note.warn { background: #fdf6ea; }

#toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: #1d1d1f; color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; transition: opacity .2s; pointer-events: none; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; }
#toast.err { background: var(--err); }

dialog { border: 0; border-radius: 14px; padding: 0; width: min(640px, 94vw); box-shadow: 0 20px 60px rgba(0,0,0,.25); }
dialog::backdrop { background: rgba(0,0,0,.3); }
#modal-body { padding: 22px 24px; }
#modal-body .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 10px; }
.mail-preview { border: 1px solid var(--line); border-radius: 8px; padding: 14px; max-height: 60vh; overflow: auto; }

@media (max-width: 700px) {
  .top { gap: 12px; padding: 0 16px; }
  main { padding: 20px 16px 60px; }
  .day { grid-template-columns: 1fr; }
  .act { grid-template-columns: 80px 1fr; }
  .act .tools { opacity: 1; grid-column: 1 / -1; }
}

body.login .top nav { display: none; }
.login-box { max-width: 360px; margin: 10vh auto 0; padding: 28px; }

.act.click { cursor: pointer; border-radius: 8px; padding: 5px 6px; margin: 0 -6px; }
.act.click:hover { background: var(--bg); }
.act.gone .when, .act.gone .what > strong, .act.gone .what > .pill:first-child { text-decoration: line-through; opacity: .55; }
.act.absent .when { color: var(--err); }
.udrow { display: flex; align-items: center; gap: 8px; margin: 3px 0 1px; }
.ud { display: inline-flex; gap: 3px; }
.ud i { width: 18px; height: 8px; border-radius: 3px; background: var(--line); }
.ud i.ud-on { background: #57b17c; }
.ud i.ud-cq { background: #e7a94b; }
.ud i.ud-x { background: #e06666; }
details > summary { list-style: none; }
details > summary::before { content: "▸ "; }
details[open] > summary::before { content: "▾ "; }
.auto.dim { opacity: .45; }
button.small { font-size: 13px; padding: 5px 10px; }
input.locked { background: var(--bg); color: var(--muted); cursor: not-allowed; }
