/* ===========================================================
   TURNI SALA PROVE — stile mobile-first
   =========================================================== */
:root {
  --bg: #0a0a0a;
  --card: #161616;
  --card2: #1f1f1f;
  --ink: #f4f4f4;
  --muted: #9a9a9a;
  --line: #2a2a2a;
  --line-strong: #3a3a3a;
  --primary: #f0f0f0;
  --primary-d: #cfcfcf;
  --accent: #ffffff;
  --accent-d: #d4d4d4;
  --danger: #ff5a72;
  --header-h: 44px;
  --gutter-w: 48px;
  --cell-h: 15px;
  --tabbar-h: 58px;
  --weekend: #121212;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  overflow: hidden;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }

/* ---------- Bottoni ---------- */
.btn {
  border: none; border-radius: 12px; padding: 13px 18px;
  font-size: 15px; font-weight: 600; cursor: pointer;
  background: var(--primary); color: #fff; transition: transform .05s, filter .15s;
}
.btn:active { transform: scale(.98); }
.btn-ghost { background: #efecfb; color: var(--primary-d); }
.btn-small { padding: 10px 14px; font-size: 14px; border-radius: 10px; }
.btn-danger { background: #fde7eb; color: var(--danger); }
.btn-save { background: var(--accent); width: 100%; display: flex; align-items: center; justify-content: center; gap: 8px; }
.save-dot { width: 9px; height: 9px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,.4); }

/* ---------- Schermate login/blocked ---------- */
.screen { position: fixed; inset: 0; }
.center { display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card {
  background: var(--card); border-radius: 22px; padding: 32px 26px;
  width: 100%; max-width: 380px; text-align: center;
  box-shadow: 0 18px 50px rgba(50,30,120,.16);
}
.login-card .logo { font-size: 58px; line-height: 1; }
.login-card h1 { font-size: 23px; margin: 14px 0 6px; }
.login-card p { font-size: 14.5px; line-height: 1.5; margin: 0 0 18px; }
.btn-google { width: 100%; background: #fff; color: #3c4043; border: 1px solid var(--line-strong); display: flex; align-items: center; justify-content: center; gap: 10px; }
.btn-google .g { font-weight: 800; color: #4285f4; font-family: Arial, sans-serif; }
.or { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 13px; margin: 18px 0; }
.or::before, .or::after { content: ""; height: 1px; background: var(--line); flex: 1; }
.email-form { display: flex; flex-direction: column; gap: 10px; }
.email-form input { padding: 12px 14px; border: 1px solid var(--line-strong); border-radius: 12px; font-size: 15px; }
.login-msg { font-size: 13.5px; min-height: 18px; margin-top: 14px !important; color: var(--primary-d); }
.login-msg.err { color: var(--danger); }

/* ---------- App shell ---------- */
#app { display: flex; flex-direction: column; height: 100dvh; }
.app-header {
  height: var(--header-h); flex: 0 0 auto; display: flex; align-items: center;
  background: linear-gradient(180deg, var(--primary), var(--primary-d));
  color: #fff; padding: 0 6px; gap: 4px;
}
.weeknav { flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; }
.nav-btn { background: rgba(255,255,255,.16); color: #fff; border: none; width: 34px; height: 34px; border-radius: 10px; font-size: 22px; line-height: 1; cursor: pointer; }
.nav-btn:active { background: rgba(255,255,255,.30); }
.week-center { display: flex; flex-direction: column; align-items: center; min-width: 150px; }
.week-label { font-size: 14.5px; font-weight: 700; }
.today-btn { background: none; border: none; color: rgba(255,255,255,.8); font-size: 11.5px; cursor: pointer; padding: 0; text-decoration: underline; }
.logout-btn { background: rgba(255,255,255,.16); color: #fff; border: none; width: 34px; height: 34px; border-radius: 10px; font-size: 17px; cursor: pointer; }

.app-main { flex: 1 1 auto; overflow: hidden; position: relative; }
.view { height: 100%; display: flex; flex-direction: column; }
.hint { flex: 0 0 auto; font-size: 12.5px; color: var(--muted); padding: 8px 12px; background: #fbfaff; border-bottom: 1px solid var(--line); }

/* ---------- Calendario ---------- */
.cal-scroll { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; background: var(--card); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.cal { display: grid; grid-template-columns: var(--gutter-w) 1fr; grid-template-rows: var(--header-h) auto; position: relative; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
.cal-corner { grid-row: 1; grid-column: 1; position: sticky; top: 0; left: 0; z-index: 7; background: var(--card); border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-strong); }
.cal-days { grid-row: 1; grid-column: 2; position: sticky; top: 0; z-index: 6; display: grid; grid-template-columns: repeat(7, 1fr); background: var(--card); border-bottom: 1px solid var(--line-strong); }
.cal-dayh { display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; color: var(--muted); border-left: 1px solid var(--line); line-height: 1.2; padding: 3px 0; }
.cal-dayh b { font-size: 15px; color: var(--ink); }
.cal-dayh.weekend { background: var(--weekend); }
.cal-dayh.today { background: #efeaff; }
.cal-dayh.today b { color: var(--primary-d); }

.cal-times { grid-row: 2; grid-column: 1; position: sticky; left: 0; z-index: 4; background: var(--card); border-right: 1px solid var(--line); }
.cal-time { height: calc(var(--cell-h) * 2); font-size: 10.5px; color: var(--muted); text-align: right; padding-right: 5px; border-top: 1px solid var(--line); position: relative; }
.cal-time span { position: relative; top: -7px; background: var(--card); padding: 0 1px; }
.cal-time:first-child { border-top: none; }
.cal-time:first-child span { top: 2px; }

.cal-grid { grid-row: 2; grid-column: 2; display: grid; grid-template-columns: repeat(7, 1fr); }
.cal-col { position: relative; border-left: 1px solid var(--line); touch-action: pan-y; }
.cal-times, .cal-days, .cal-corner { touch-action: pan-y; }
.cal-col.weekend { background: var(--weekend); }
.slot { height: var(--cell-h); border-top: 1px solid transparent; }
.slot.hour { border-top: 1px solid var(--line); }
.slot.h3 { border-top: 1px solid var(--line-strong); } /* mezzogiorno/mezzanotte */

/* strisce (le mie) */
.strip {
  position: absolute; left: 2px; right: 2px; border-radius: 6px;
  background: linear-gradient(180deg, var(--accent), var(--accent-d));
  color: #fff; font-size: 10px; font-weight: 700; z-index: 3;
  box-shadow: 0 1px 4px rgba(15,122,55,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 2px 1px;
  overflow: hidden; cursor: pointer;
}
.strip small { font-size: 9px; opacity: .9; }
.selection { position: absolute; left: 2px; right: 2px; border-radius: 6px; background: rgba(22,163,74,.35); border: 2px dashed var(--accent-d); z-index: 4; pointer-events: none; }
.cal-col.painting { touch-action: none; }

/* ---------- Overview blocchi ---------- */
.ov-block { position: absolute; left: 1px; right: 1px; border-radius: 4px; mix-blend-mode: multiply; z-index: 2; }
.ov-full {
  position: absolute; left: 0; right: 0; z-index: 5;
  background: rgba(22,163,74,.5); border-top: 2px solid var(--accent-d); border-bottom: 2px solid var(--accent-d);
  display: flex; align-items: center; justify-content: center;
  font-size: 9.5px; font-weight: 800; color: #08531f; text-align: center; line-height: 1.05;
}

/* ---------- Legenda ---------- */
.legend { flex: 0 0 auto; display: flex; flex-wrap: wrap; gap: 6px 10px; padding: 8px 12px; background: #fbfaff; border-bottom: 1px solid var(--line); font-size: 12px; }
.legend .chip { display: inline-flex; align-items: center; gap: 5px; }
.legend .chip .dot { width: 12px; height: 12px; border-radius: 4px; }
.legend .chip.absent { opacity: .4; }
.legend .chip.me b { color: var(--primary-d); }

/* ---------- Resoconto ---------- */
.summary { flex: 0 0 auto; max-height: 38%; overflow-y: auto; padding: 10px 12px 16px; border-top: 1px solid var(--line-strong); background: var(--card); }
.summary h3 { margin: 0 0 8px; font-size: 14px; }
.summary .sum-day { margin-bottom: 8px; }
.summary .sum-day .d { font-weight: 700; font-size: 13px; }
.summary .sum-row { display: flex; gap: 8px; align-items: baseline; font-size: 13px; padding: 3px 0; }
.summary .sum-row .t { font-weight: 700; color: var(--accent-d); white-space: nowrap; }
.summary .sum-row .who { color: var(--muted); font-size: 12px; }
.summary .empty { color: var(--muted); font-size: 13px; }
.summary .best { margin-top: 6px; font-size: 12.5px; color: var(--muted); }

/* ---------- Admin ---------- */
.admin-wrap { padding: 14px; overflow-y: auto; height: 100%; }
.admin-wrap h2 { font-size: 17px; margin: 2px 0 12px; }
.admin-form { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.admin-form input, .admin-form select { padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 15px; }
.admin-form-row { display: flex; gap: 8px; align-items: center; }
.admin-form-row select { flex: 1; }
.color-pick { display: flex; flex-direction: column; align-items: center; font-size: 9px; color: var(--muted); }
.color-pick input[type=color] { width: 42px; height: 38px; border: none; background: none; padding: 0; border-radius: 10px; }
.user-list { display: flex; flex-direction: column; gap: 8px; }
.user-row { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.user-row .dot { width: 20px; height: 20px; border-radius: 6px; flex: 0 0 auto; }
.user-row .info { flex: 1; min-width: 0; }
.user-row .info .n { font-weight: 600; font-size: 14.5px; }
.user-row .info .e { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-row .tag { font-size: 10px; font-weight: 700; padding: 2px 7px; border-radius: 99px; background: #efeaff; color: var(--primary-d); }
.user-row .tag.off { background: #f1eef7; color: var(--muted); }
.user-row button { border: none; background: #f3f1fb; border-radius: 8px; padding: 7px 9px; font-size: 14px; cursor: pointer; }
.user-row .lock { color: var(--muted); font-size: 15px; padding: 0 4px; }

/* ---------- Tab bar ---------- */
.tabbar { height: var(--tabbar-h); flex: 0 0 auto; display: flex; background: var(--card); border-top: 1px solid var(--line-strong); padding-bottom: env(safe-area-inset-bottom); }
.tab { flex: 1; background: none; border: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; font-size: 11px; color: var(--muted); cursor: pointer; }
.tab .ti { font-size: 20px; filter: grayscale(.4); opacity: .65; }
.tab.active { color: var(--primary-d); font-weight: 700; }
.tab.active .ti { filter: none; opacity: 1; }

/* ---------- Modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(20,10,40,.5); display: flex; align-items: flex-end; justify-content: center; z-index: 50; }
.modal-card { background: var(--card); width: 100%; max-width: 460px; border-radius: 20px 20px 0 0; padding: 20px; animation: up .18s ease; }
@keyframes up { from { transform: translateY(20px); opacity: .6; } }
.modal-card h3 { margin: 0 0 14px; font-size: 17px; }
.modal-card label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.modal-card select { width: 100%; padding: 11px; border: 1px solid var(--line-strong); border-radius: 10px; font-size: 15px; margin-top: 4px; }
.modal-times { display: flex; gap: 12px; }
.modal-times label { flex: 1; }
.m-err { color: var(--danger); font-size: 12.5px; min-height: 16px; margin: 0 0 6px; }
.modal-actions { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.modal-actions .spacer { flex: 1; }

/* ---------- Toast ---------- */
.toast { position: fixed; bottom: calc(var(--tabbar-h) + 14px); left: 50%; transform: translateX(-50%); background: #221a3a; color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; z-index: 60; box-shadow: 0 8px 24px rgba(0,0,0,.25); max-width: 90%; text-align: center; }
.toast.err { background: var(--danger); }

/* ---------- Login: link "cambia account" ---------- */
.btn-link { background: none; border: none; color: var(--primary-d); font-size: 13.5px; margin-top: 12px; cursor: pointer; text-decoration: underline; }

/* ---------- Badge aggiornamento (header) ---------- */
.update-badge { display: inline-flex; align-items: center; gap: 5px; background: linear-gradient(135deg, #D97757, #C15F3C); color: #fff; border: none; border-radius: 999px; padding: 6px 12px; font-size: 12px; font-weight: 800; cursor: pointer; margin-right: 4px; box-shadow: 0 2px 8px rgba(193,95,60,.45); }
.update-badge .ico { color: #fff5d4; animation: updBlink 1s ease-in-out infinite; }
.update-badge:hover .ico { animation-play-state: paused; }
.update-badge:disabled { opacity: .65; cursor: wait; }
@keyframes updBlink { 0%,100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(1.18); } }

/* ---------- Toast aggiornamento (centrato) ---------- */
.update-toast { position: fixed; top: 50%; left: 50%; transform: translate(-50%,-50%); z-index: 70; background: #fff; border: 2px solid #f0d9cf; border-radius: 18px; padding: 26px 24px 22px; width: min(86%, 360px); text-align: center; box-shadow: 0 24px 64px rgba(40,20,90,.32); }
.update-toast-x { position: absolute; top: 6px; right: 10px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.update-toast .ut-emoji { font-size: 40px; line-height: 1; }
.update-toast .ut-title { font-size: 17px; font-weight: 800; margin: 8px 0 4px; }
.update-toast .ut-text { font-size: 13.5px; color: var(--muted); margin-bottom: 16px; }
.update-toast .ut-reload { background: linear-gradient(135deg, #D97757, #C15F3C); width: 100%; }

/* ---------- Overlay aggiornamento in corso ---------- */
.update-overlay { position: fixed; inset: 0; z-index: 90; background: linear-gradient(135deg, #2a1c4a, #1f1147); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 30px; }
.uo-spinner { width: 56px; height: 56px; border: 5px solid rgba(255,255,255,.18); border-top-color: #D97757; border-radius: 50%; animation: uoSpin .9s linear infinite; margin-bottom: 20px; }
@keyframes uoSpin { to { transform: rotate(360deg); } }
.uo-title { font-size: 18px; font-weight: 700; margin-bottom: 6px; }
.uo-text { font-size: 13.5px; opacity: .82; max-width: 320px; line-height: 1.45; }

/* ===========================================================
   TEMA WIR — bianco / nero (niente viola)
   =========================================================== */
.app-header { background: linear-gradient(180deg, #1d1d1d, #0c0c0c); border-bottom: 1px solid #2a2a2a; }
.savebar { padding: 10px 12px; background: var(--card); border-top: 1px solid var(--line); }
.login-card { box-shadow: 0 18px 50px rgba(0,0,0,.55); }
.modal { background: rgba(0,0,0,.62); }
.toast { background: #1c1c1c; }
/* bottoni */
#btn-m-save, #btn-add-user { color: #0a0a0a; }
.btn-save { background: transparent; border: 1.6px solid var(--line-strong); color: var(--ink); }
.btn-save.editing { background: #ffffff; border-color: #ffffff; color: #0a0a0a; }
.btn-ghost { background: rgba(255,255,255,.10); color: #ededed; }
.btn-google { background: #f4f4f6; color: #2b2b2e; border-color: rgba(255,255,255,.12); }
.save-dot { background: var(--ink); box-shadow: none; }
.btn-save.editing .save-dot { background: #0a0a0a; }
.cal-scroll.editing { box-shadow: inset 0 0 0 2px rgba(255,255,255,.20); }
/* input */
input, select, textarea { background: var(--card2); color: var(--ink); }
input[type="color"] { background: none; }
.admin-form input, .admin-form select, .modal-card select, #m-giorno, #m-inizio, #m-fine { background: var(--card2); color: var(--ink); border-color: var(--line-strong); }
.hint { background: var(--card2); color: var(--muted); }
.login-msg { color: #cfcfcf; }
.legend { background: var(--card2); }
/* griglia: strisce e selezione bianche */
.strip { background: linear-gradient(180deg, #26d167, #15a04a); color: #ffffff; box-shadow: 0 1px 5px rgba(0,0,0,.55); }
.strip small { opacity: .7; }
.selection { background: rgba(38,209,103,.30); border-color: #26d167; }
.cal-dayh.today { background: rgba(255,255,255,.12); }
.cal-dayh.today b { color: #ffffff; }
/* vista d'insieme */
.ov-block { mix-blend-mode: screen; }
.ov-block, .ov-band { pointer-events: none; }
.ov-name { position: absolute; left: 2px; right: 2px; font-size: 9px; font-weight: 800; line-height: 1.1; z-index: 4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-shadow: 0 1px 2px rgba(0,0,0,.95), 0 0 3px rgba(0,0,0,.9); }
.ov-full { background: rgba(38,209,103,.34); border-top: 2px solid #26d167; border-bottom: 2px solid #26d167; color: #daffe9; z-index: 5; }
.summary .sum-row .t, .summary .best b { color: #34d36f; }
/* tab / tag / overlay aggiornamento */
.tab.active { color: #ffffff; }
.tab.active .ti { filter: none; opacity: 1; }
.user-row button { background: var(--card2); color: var(--ink); }
.user-row .tag { background: rgba(255,255,255,.14); color: #ffffff; }
.user-row .tag.off { background: rgba(255,255,255,.07); color: var(--muted); }
.update-toast { background: var(--card); border-color: rgba(217,119,87,.55); }
.update-toast .ut-title { color: var(--ink); }
.update-overlay { background: linear-gradient(135deg, #1a1a1a, #070707); }
.uo-spinner { border-top-color: #ffffff; }

/* ---- Selettore strumento + vista Elenco ---- */
.strum-sel { padding: 9px 6px; border-radius: 8px; font-size: 14px; max-width: 132px; }
.admin-form-row { flex-wrap: wrap; }
.user-row { flex-wrap: wrap; row-gap: 8px; }
.user-row .strum-sel { flex: 0 0 auto; padding: 7px 4px; font-size: 13px; max-width: 116px; }
.summary.list-full { max-height: none; flex: 1 1 auto; min-height: 0; border-top: none; }

/* ---- Incroci verdi con icone strumenti + legenda in basso ---- */
.legend { border-bottom: none; border-top: 1px solid var(--line-strong); }
.ov-band { position: absolute; left: 1px; right: 1px; z-index: 4; border-radius: 5px; background: rgba(38,209,103,.24); display: flex; align-items: center; justify-content: center; overflow: hidden; pointer-events: none; }
.ov-band .iconz { display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 0 1px; font-size: 17px; line-height: 1.05; }
.ov-band.full { z-index: 6; flex-direction: column; gap: 1px; background: rgba(38,209,103,.5); border: 1.5px solid #2bd46a; box-shadow: 0 0 10px rgba(38,209,103,.45); }
.ov-band.full .tt { font-size: 9px; font-weight: 800; color: #eaffef; }

/* ---- Elenco: righe per giorno raggruppate per mese ---- */
.el-month { font-size: 12px; font-weight: 800; letter-spacing: .08em; color: var(--muted); margin: 16px 0 7px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.el-month:first-of-type { margin-top: 2px; }
.el-row { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border-radius: 11px; background: var(--card2); margin-bottom: 6px; border: 1.5px solid transparent; overflow: hidden; }
.el-row.full { border-color: #2bd46a; box-shadow: 0 0 9px rgba(38,209,103,.4); }
.el-day { font-weight: 700; font-size: 14px; flex: 0 0 auto; min-width: 58px; }
.el-info { font-size: 12.5px; color: var(--muted); flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.el-icons { display: flex; gap: 2px; align-items: center; flex: 0 0 auto; }
.lg-strum { font-size: 15px; }

/* ---- Toast info disponibilità (tap su un rettangolo in "Tutti") ---- */
.tap-modal { position: fixed; inset: 0; background: rgba(0,0,0,.55); display: flex; align-items: center; justify-content: center; z-index: 80; padding: 24px; }
.tap-card { position: relative; background: var(--card); border: 1px solid var(--line-strong); border-radius: 18px; padding: 20px 18px 14px; width: min(90%, 360px); box-shadow: 0 24px 64px rgba(0,0,0,.55); }
.tap-x { position: absolute; top: 6px; right: 10px; background: none; border: none; font-size: 24px; line-height: 1; color: var(--muted); cursor: pointer; padding: 4px 8px; }
.tap-card h4 { margin: 0 0 10px; font-size: 15px; }
.tap-row { display: flex; align-items: center; gap: 8px; padding: 7px 0; font-size: 14px; }
.tap-row + .tap-row { border-top: 1px solid var(--line); }
.tap-row .dot { width: 14px; height: 14px; border-radius: 4px; flex: 0 0 auto; }
.tap-row .em { font-size: 18px; }
.tap-row .nm { font-weight: 600; flex: 1 1 auto; }
.tap-row .tap-time { color: var(--muted); font-size: 12.5px; white-space: nowrap; }

/* ---- Transizione di scorrimento al cambio settimana ---- */
@keyframes calSlideNext { from { transform: translateX(100%); opacity: .55; } to { transform: translateX(0); opacity: 1; } }
@keyframes calSlidePrev { from { transform: translateX(-100%); opacity: .55; } to { transform: translateX(0); opacity: 1; } }
.cal.slide-next { animation: calSlideNext .26s cubic-bezier(.22,.61,.36,1); }
.cal.slide-prev { animation: calSlidePrev .26s cubic-bezier(.22,.61,.36,1); }

/* ---- Icone strumenti (Twemoji): cartoon, sempre visibili, grandi ---- */
.strum-ico { display: inline-block; vertical-align: middle; width: 20px; height: 20px; }
.ov-band .iconz .strum-ico { width: 22px; height: 22px; margin: 1px; }
.el-icons .strum-ico { width: 23px; height: 23px; }
.lg-strum .strum-ico { width: 18px; height: 18px; }
.tap-row .em .strum-ico { width: 26px; height: 26px; }
