/* Prenotazione Aule - tema "lavagna e gesso" */
:root {
  --slate: #22343A;      /* lavagna */
  --slate-2: #304850;
  --chalk: #F3F5F2;      /* gesso, sfondo */
  --paper: #FFFFFF;
  --ink: #1D2A2E;
  --muted: #64767A;
  --line: #DCE2DF;
  --line-soft: #EBEFEC;
  --marker: #F2C94C;     /* evidenziatore */
  --marker-soft: #FBF0C6;
  --free: #2E9E6B;
  --busy: #D64545;
  --f-display: "Bahnschrift", "DIN Alternate", "DIN 2014", "Barlow Semi Condensed", "Segoe UI Variable Display", system-ui, sans-serif;
  --f-text: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
  --slot: 26px;
  --roomw: 168px;
  --cellw: 34px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font-family: var(--f-text); background: var(--chalk); color: var(--ink); font-size: 15px; line-height: 1.4; -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100vh; min-height: 100dvh; display: grid; place-items: center; padding: 20px; background: var(--slate); background-image: radial-gradient(circle at 20% 15%, #355058 0, transparent 55%), radial-gradient(circle at 85% 90%, #1a292e 0, transparent 50%); }
.login { background: var(--paper); border-radius: 18px; padding: 32px 28px; width: 100%; max-width: 380px; box-shadow: 0 30px 60px rgba(10,20,24,.35); }
.login img { width: 52px; height: 52px; }
.login h1 { font-family: var(--f-display); font-weight: 600; margin: 14px 0 2px; font-size: 26px; letter-spacing: -.01em; }
.login p { margin: 0 0 22px; color: var(--muted); }
.login label { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); font-weight: 600; margin-bottom: 14px; }
.login input { padding: 11px 12px; border: 1px solid #cfd7d3; border-radius: 10px; background: #fff; }
.login .btn { width: 100%; padding: 12px; margin-top: 4px; justify-content: center; }

/* ---------- Struttura ---------- */
.shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.top { flex: none; background: var(--slate); color: #fff; padding: 10px 18px; padding-top: max(10px, env(safe-area-inset-top)); display: flex; align-items: center; gap: 14px; position: relative; z-index: 20; }
.brand { display: flex; align-items: center; gap: 10px; margin-right: auto; font-family: var(--f-display); font-size: 19px; font-weight: 600; letter-spacing: -.01em; }
.brand img { width: 30px; height: 30px; }
.tabs { display: flex; gap: 2px; background: rgba(255,255,255,.08); border-radius: 12px; padding: 3px; }
.tabs button { background: none; border: 0; color: #d5e0dc; padding: 7px 14px; border-radius: 9px; cursor: pointer; font-weight: 500; }
.tabs button:hover { color: #fff; }
.tabs button.on { background: var(--paper); color: var(--slate); font-weight: 650; }
.user { font-size: 13px; color: #bfcdc8; }
.btn-top { background: rgba(255,255,255,.1); border: 0; color: #fff; width: 38px; height: 38px; border-radius: 10px; cursor: pointer; font-size: 17px; }
.btn-top:hover { background: rgba(255,255,255,.18); }

.bar { flex: none; display: flex; align-items: center; gap: 8px; padding: 12px 18px; background: var(--paper); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.bar .title { font-family: var(--f-display); font-weight: 600; font-size: 21px; flex: 1; min-width: 0; letter-spacing: -.01em; }
.bar .title::first-letter { text-transform: uppercase; }
.bar input[type=date] { padding: 7px 9px; border: 1px solid var(--line); border-radius: 10px; background: #fff; }
main { flex: 1; min-height: 0; overflow: auto; }

/* ---------- Pulsanti ---------- */
.btn { border: 1px solid var(--line); background: var(--paper); padding: 8px 14px; border-radius: 10px; cursor: pointer; white-space: nowrap; font-weight: 500; text-decoration: none; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { background: #f6f8f7; border-color: #cbd4d0; }
.btn.primary { background: var(--marker); border-color: #e3b733; color: #2b2405; font-weight: 650; }
.btn.primary:hover { background: #ecbf37; }
.btn.blue { background: var(--slate); border-color: var(--slate); color: #fff; }
.btn.blue:hover { background: var(--slate-2); }
.btn.danger { color: var(--busy); border-color: #f1c9c9; }
.btn.danger:hover { background: #fdf1f1; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.icon { width: 38px; justify-content: center; padding: 8px 0; font-size: 18px; line-height: 1; }

/* ---------- PANORAMICA: mappa del mese ---------- */
.ov { padding: 18px; display: flex; flex-direction: column; gap: 18px; max-width: 1500px; margin: 0 auto; }
.board { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.board-scroll { overflow-x: auto; }
.mx { display: grid; min-width: max-content; }
.mx-day, .mx-cell { min-width: 0; }
.mx-corner { position: sticky; left: 0; z-index: 3; background: var(--paper); padding: 10px 14px; display: flex; flex-direction: column; justify-content: flex-end; font-size: 12px; color: var(--muted); border-bottom: 1px solid var(--line); border-right: 1px solid var(--line); }
.mx-corner b { font-family: var(--f-display); font-weight: 600; font-size: 14px; color: var(--ink); }
.mx-day { border: 0; background: none; padding: 8px 0 6px; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 2px; border-bottom: 1px solid var(--line); }
.mx-day .lvl { width: 14px; height: 34px; background: var(--line-soft); border-radius: 4px; position: relative; overflow: hidden; margin-bottom: 4px; }
.mx-day .lvl i { position: absolute; left: 0; right: 0; bottom: 0; background: var(--slate); border-radius: 0 0 4px 4px; }
.mx-day b { font-family: var(--f-display); font-weight: 600; font-size: 15px; line-height: 1.1; padding: 0 4px; border-radius: 4px; }
.mx-day small { font-size: 11px; color: var(--muted); }
.mx-day.we small, .mx-day.we b { color: #98a6a9; }
.mx-day.today b { background: var(--marker); color: #2b2405; }
.mx-day.sel, .mx-cell.sel { background: #e8eff0; }
.mx-day:hover { background: #f2f5f4; }
.mx-room { position: sticky; left: 0; z-index: 2; background: var(--paper); padding: 0 14px; display: flex; align-items: center; gap: 9px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-soft); min-height: 48px; font-weight: 600; font-size: 14px; }
.mx-room span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-room small { color: var(--muted); font-weight: 400; margin-left: auto; font-size: 12px; }
.dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.mx-cell { border: 0; border-bottom: 1px solid var(--line-soft); background: none; padding: 7px 5px; cursor: pointer; }
.mx-cell .pill { display: block; height: 100%; min-height: 34px; position: relative; border-radius: 5px; background: var(--line-soft); overflow: hidden; }
.mx-cell.we .pill { background: repeating-linear-gradient(135deg, #eef1ef 0 4px, #f7f9f8 4px 8px); }
.mx-cell .pill i { position: absolute; left: 0; right: 0; }
.mx-cell .pill i.opz { opacity: .45; }
.mx-cell:hover .pill { box-shadow: 0 0 0 2px var(--slate) inset; }
.mx-cell.sel .pill { box-shadow: 0 0 0 2px var(--slate); }
.legend { display: flex; gap: 18px; flex-wrap: wrap; padding: 10px 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); align-items: center; }
.legend .sw { display: inline-block; width: 12px; height: 20px; border-radius: 3px; vertical-align: middle; margin-right: 6px; background: var(--line-soft); position: relative; overflow: hidden; }
.legend .sw i { position: absolute; left: 0; right: 0; top: 30%; height: 40%; background: var(--slate); }

/* ---------- PANORAMICA: il giorno selezionato ---------- */
.detail { background: var(--paper); border: 1px solid var(--line); border-radius: 16px; padding: 22px 22px 14px; }
.dhead { display: flex; gap: 28px; align-items: flex-end; flex-wrap: wrap; margin-bottom: 20px; }
.bigdate { display: flex; align-items: baseline; gap: 12px; font-family: var(--f-display); line-height: .9; }
.bigdate .dn { font-size: 76px; font-weight: 700; letter-spacing: -.04em; color: var(--slate); }
.bigdate .side { display: flex; flex-direction: column; gap: 6px; }
.bigdate .wd { font-size: 24px; font-weight: 600; }
.bigdate .my { font-size: 15px; color: var(--muted); font-family: var(--f-text); }
.bigdate .oggi { align-self: flex-start; background: var(--marker); color: #2b2405; font-size: 12px; font-weight: 700; padding: 3px 8px; border-radius: 6px; font-family: var(--f-text); }
.stats { display: flex; gap: 26px; margin: 0; flex-wrap: wrap; flex: 1; }
.stats div { min-width: 92px; }
.stats dt { font-size: 12.5px; color: var(--muted); margin-bottom: 2px; }
.stats dd { margin: 0; font-family: var(--f-display); font-size: 28px; font-weight: 600; letter-spacing: -.02em; }
.stats dd small { font-size: 15px; color: var(--muted); font-weight: 500; }
.meter { height: 6px; width: 100%; max-width: 120px; background: var(--line-soft); border-radius: 3px; margin-top: 6px; overflow: hidden; }
.meter i { display: block; height: 100%; background: var(--slate); border-radius: 3px; }

.tl { display: grid; grid-template-columns: 230px 1fr; }
.tl-name { padding: 10px 14px 10px 0; display: flex; flex-direction: column; gap: 4px; justify-content: center; border-bottom: 1px solid var(--line-soft); min-width: 0; }
.tl-name b { display: flex; align-items: center; gap: 8px; font-size: 14.5px; }
.tl-name b span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { font-size: 12.5px; display: flex; align-items: center; gap: 6px; color: var(--muted); }
.st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #b8c3c0; flex: none; }
.st.free { color: #1f7a51; } .st.free::before { background: var(--free); }
.st.busy { color: #b23131; } .st.busy::before { background: var(--busy); box-shadow: 0 0 0 3px #f8dada; }
.tl-ticks { position: relative; height: 22px; border-bottom: 1px solid var(--line); }
.tl-ticks span { position: absolute; bottom: 4px; transform: translateX(-50%); font-size: 11px; color: var(--muted); font-variant-numeric: tabular-nums; }
.tl-ticks span:first-child { transform: none; }
.tl-track { position: relative; min-height: 58px; border-bottom: 1px solid var(--line-soft); cursor: copy; background-image: linear-gradient(to right, var(--line-soft) 1px, transparent 1px); background-size: var(--hourw, 7.14%) 100%; }
.tl-track.ro { cursor: default; }
.tl-ev { position: absolute; top: 8px; bottom: 8px; border: 0; border-radius: 8px; background: var(--c); color: #fff; text-align: left; padding: 5px 8px; overflow: hidden; cursor: pointer; font-size: 12.5px; line-height: 1.25; box-shadow: 0 1px 2px rgba(20,35,40,.2); }
.tl-ev b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 650; }
.tl-ev span { white-space: nowrap; opacity: .9; font-variant-numeric: tabular-nums; }
.tl-ev:hover { filter: brightness(1.07); }
.tl-ev.opzione, .ev.opzione, .chip.opzione { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.28) 0 5px, transparent 5px 10px); outline: 2px dashed rgba(255,255,255,.85); outline-offset: -4px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 0; border-left: 2px dashed rgba(214,69,69,.5); z-index: 2; pointer-events: none; }
.tl-ticks .now-lbl { transform: translateX(-50%); bottom: 2px; background: #fbe3e3; color: #b23131; font-weight: 650; padding: 1px 6px; border-radius: 6px; z-index: 1; display: inline !important; }
.tl-foot { font-size: 12.5px; color: var(--muted); margin-top: 12px; }

/* ---------- Vista Giorno (griglia) ---------- */
.day-wrap { overflow: auto; height: 100%; background: var(--paper); }
.day { display: grid; position: relative; min-width: max-content; }
.day .corner, .day .rh { position: sticky; top: 0; background: var(--paper); z-index: 5; border-bottom: 1px solid var(--line); padding: 10px 6px; font-weight: 650; font-size: 13.5px; text-align: center; height: 56px; }
.day .corner { left: 0; z-index: 6; }
.day .rh small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.day .rh .dot { display: inline-block; margin-right: 6px; vertical-align: 1px; }
.day .times { position: sticky; left: 0; background: var(--paper); z-index: 4; border-right: 1px solid var(--line); }
.day .t { height: var(--slot); font-size: 11px; color: var(--muted); text-align: right; padding-right: 7px; transform: translateY(-7px); font-variant-numeric: tabular-nums; }
.day .col { position: relative; border-right: 1px solid var(--line-soft); }
.day .cell { height: var(--slot); border-bottom: 1px dashed #eef1ef; cursor: copy; }
.day .cell.hour { border-bottom: 1px solid var(--line-soft); }
.day .cell:hover { background: var(--marker-soft); }
.ev { position: absolute; left: 4px; right: 4px; border-radius: 8px; padding: 5px 8px; font-size: 12px; overflow: hidden; cursor: pointer; color: #fff; box-shadow: 0 1px 2px rgba(20,35,40,.2); line-height: 1.25; }
.ev b { display: block; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-line { position: absolute; left: 0; right: 0; height: 0; border-top: 2px dashed rgba(214,69,69,.5); z-index: 3; pointer-events: none; }

/* ---------- Vista Settimana ---------- */
.week-wrap { overflow: auto; background: var(--paper); height: 100%; }
table.week { border-collapse: collapse; width: 100%; min-width: 880px; table-layout: fixed; }
table.week th, table.week td { border-bottom: 1px solid var(--line-soft); border-right: 1px solid var(--line-soft); vertical-align: top; }
table.week thead th { background: var(--paper); padding: 10px 4px; font-size: 13px; position: sticky; top: 0; z-index: 2; font-weight: 650; border-bottom: 1px solid var(--line); }
table.week thead th::first-letter { text-transform: uppercase; }
table.week thead th.today span { background: var(--marker); padding: 2px 7px; border-radius: 6px; }
table.week th.room { text-align: left; padding: 10px 12px; font-size: 13.5px; width: 160px; background: var(--paper); position: sticky; left: 0; z-index: 1; }
table.week th.room .dot { display: inline-block; margin-right: 7px; vertical-align: 0; }
table.week td { padding: 4px; height: 70px; cursor: copy; }
table.week td:hover { background: var(--marker-soft); }
table.week td.we { background: #f8faf9; }
.chip { display: block; border-radius: 7px; padding: 4px 7px; font-size: 12px; color: #fff; margin-bottom: 4px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: pointer; font-variant-numeric: tabular-nums; }

/* ---------- Elenco ---------- */
.list-wrap { padding: 18px; max-width: 1000px; margin: 0 auto; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; align-items: end; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.filters label { font-size: 12px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; font-weight: 600; }
.filters input, .filters select { padding: 8px 9px; border: 1px solid var(--line); border-radius: 9px; background: #fff; }
.day-group h3 { font-family: var(--f-display); font-weight: 600; font-size: 16px; margin: 20px 0 8px; }
.day-group h3::first-letter { text-transform: uppercase; }
.item { background: var(--paper); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin-bottom: 7px; cursor: pointer; display: flex; gap: 14px; align-items: center; }
.item:hover { border-color: #c5cfcb; }
.item .bar-c { width: 5px; align-self: stretch; border-radius: 3px; flex: none; }
.item .when { font-family: var(--f-display); font-weight: 600; min-width: 96px; font-size: 15px; font-variant-numeric: tabular-nums; }
.item .what { flex: 1; min-width: 0; }
.item .what b { display: block; }
.item .what small { color: var(--muted); }
.badge { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 20px; background: var(--marker-soft); color: #7a5a00; margin-left: 7px; font-weight: 650; vertical-align: 1px; }
.cap-warn { background: #fff6dc; border: 1px solid #f0d27a; color: #6b4e00; border-radius: 10px; padding: 9px 12px; font-size: 13.5px; }
.badge.warn { background: #fde4e4; color: #a12a2a; }
.empty { text-align: center; color: var(--muted); padding: 50px 10px; }

/* ---------- Finestre ---------- */
.modal { position: fixed; inset: 0; background: rgba(22,34,38,.55); display: flex; align-items: flex-start; justify-content: center; z-index: 50; overflow: auto; padding: 36px 12px; }
.modal-box { background: var(--paper); border-radius: 18px; width: 100%; max-width: 580px; padding: 24px; box-shadow: 0 30px 70px rgba(10,20,24,.35); animation: pop .16s ease-out; }
.modal-box.wide { max-width: 840px; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-box h2 { margin: 0 0 16px; font-family: var(--f-display); font-weight: 600; font-size: 23px; letter-spacing: -.01em; }
.modal-box h2.sub { font-size: 17px; margin-top: 22px; }
.form { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1fr); gap: 13px; }
.form .full { grid-column: 1 / -1; }
.form label { display: flex; flex-direction: column; gap: 5px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.form input, .form select, .form textarea { padding: 10px 11px; border: 1px solid #cfd7d3; border-radius: 10px; background: #fff; width: 100%; font-weight: 400; color: var(--ink); }
.form input:focus, .form select:focus, .form textarea:focus, .login input:focus { outline: 3px solid var(--marker-soft); border-color: #d9b23a; }
.form input[type=color] { padding: 3px; height: 42px; }
.form textarea { min-height: 74px; resize: vertical; }
.form .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); font-weight: 500; }
.form .check input { width: auto; }
.repeat { background: var(--chalk); border-radius: 12px; padding: 11px 13px; }
.repeat .row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 9px; }
.repeat .row label { flex: 1; min-width: 140px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.actions .left { margin-right: auto; display: flex; gap: 8px; }
.meta { font-size: 12.5px; color: var(--muted); margin-top: 14px; }
.err { background: #fdf1f1; color: #8f2020; border: 1px solid #f1c9c9; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; margin-top: 14px; }
.err ul { margin: 6px 0 4px; padding-left: 18px; }
table.grid { width: 100%; border-collapse: collapse; font-size: 14px; }
table.grid th, table.grid td { padding: 9px 6px; border-bottom: 1px solid var(--line-soft); text-align: left; }
table.grid th { font-size: 12px; color: var(--muted); font-weight: 600; }
table.grid td.r { text-align: right; white-space: nowrap; }
.off { opacity: .5; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 8px; }
.scroll { max-height: 55vh; overflow: auto; }
.hint { font-size: 12.5px; color: var(--muted); margin: 8px 0 0; }

.menu { position: absolute; right: 14px; top: 56px; background: var(--paper); color: var(--ink); border-radius: 14px; box-shadow: 0 16px 40px rgba(10,20,24,.25); padding: 6px; min-width: 210px; z-index: 30; }
.menu button { display: block; width: 100%; text-align: left; background: none; border: 0; padding: 10px 12px; border-radius: 9px; cursor: pointer; }
.menu button:hover { background: var(--chalk); }
.menu hr { border: 0; border-top: 1px solid var(--line-soft); margin: 4px 0; }

.toast { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); background: var(--slate); color: #fff; padding: 11px 18px; border-radius: 12px; z-index: 60; font-size: 14px; box-shadow: 0 10px 24px rgba(10,20,24,.3); max-width: 90vw; }
.toast.bad { background: var(--busy); }
.fab { display: none; }

@media (prefers-reduced-motion: reduce) { .modal-box { animation: none; } }

@media (max-width: 760px) {
  :root { --slot: 30px; --roomw: 118px; --cellw: 30px; }
  body { overflow-x: hidden; }
  .top { padding: 8px 10px; gap: 8px; }
  .brand, .user { display: none; }
  .tabs { flex: 1; }
  .tabs button { flex: 1; padding: 7px 4px; font-size: 13.5px; }
  .new-btn { display: none !important; }
  .bar { padding: 9px 10px; gap: 6px; }
  .bar .title { flex-basis: 100%; order: 9; font-size: 18px; }
  .bar input[type=date] { flex: 1; min-width: 0; }
  .bar .new-btn { display: none; }
  .fab { display: flex; position: fixed; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); width: 60px; height: 60px; border-radius: 18px; background: var(--marker); color: #2b2405; border: 0; font-size: 32px; align-items: center; justify-content: center; box-shadow: 0 8px 20px rgba(10,20,24,.3); z-index: 25; cursor: pointer; }
  .ov { padding: 10px 10px 96px; gap: 12px; }
  .mx-room { padding: 0 8px; font-size: 13px; }
  .mx-room small { display: none; }
  .detail { padding: 16px 12px 10px; }
  .dhead { flex-direction: column; align-items: stretch; gap: 16px; }
  .bigdate .dn { font-size: 60px; }
  .stats { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; }
  .stats div { min-width: 0; }
  .stats dd { font-size: 24px; }
  .tl { grid-template-columns: 1fr; }
  .tl-name { border-bottom: 0; padding: 12px 0 6px; flex-direction: row; justify-content: space-between; align-items: center; }
  .tl-head-name { display: none; }
  .tl-ticks span.odd { display: none; }
  .tl-track { min-height: 50px; border: 1px solid var(--line-soft); border-radius: 10px; }
  .tl-ev { padding: 4px 6px; font-size: 11.5px; }
  .tl-ev span { display: none; }
  .modal { padding: 0; }
  .modal-box { border-radius: 0; min-height: 100%; max-width: none; padding: 20px 16px; }
  .list-wrap { padding: 10px 10px 96px; }
  .item .when { min-width: 80px; font-size: 14px; }
}
