:root {
  --bg: #f3f5fa;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #0f172a;
  --text-2: #475569;
  --muted: #94a3b8;
  --border: #e5e9f2;
  --primary: #2952e3;
  --primary-2: #1e3fb8;
  --primary-soft: #eaefff;
  --navy: #0f1b3d;
  --navy-2: #172a5c;
  --green: #0f9d67;
  --green-soft: #e3f7ee;
  --red: #e0384f;
  --red-soft: #fdeaed;
  --amber: #d98a07;
  --amber-soft: #fff4dc;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .04), 0 4px 16px rgba(15, 23, 42, .06);
  --shadow-lg: 0 10px 40px rgba(15, 23, 42, .14);
  --sidebar: 264px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font: 15px/1.5 Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
h1 { font-size: 1.25rem; font-weight: 700; margin: 0 0 1rem; letter-spacing: -.01em; }
h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 .9rem; letter-spacing: -.01em; }
code { background: var(--surface-2); padding: .1rem .35rem; border-radius: 6px; }
.ic { width: 20px; height: 20px; flex: none; }

/* ---------- Struttura ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar); z-index: 40;
  background: linear-gradient(180deg, var(--navy) 0%, #0b1530 100%); color: #c7d2fe;
  display: flex; flex-direction: column; padding: 1rem .9rem;
}
.sidebar-head { display: flex; align-items: center; justify-content: space-between; padding: .25rem .4rem 1.25rem; }
.logo { display: flex; align-items: center; gap: .7rem; color: #fff; font-weight: 800; font-size: 1.05rem; letter-spacing: -.01em; }
.logo:hover { text-decoration: none; }
.logo-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: linear-gradient(135deg, #4f7cff, #2952e3); box-shadow: 0 6px 18px rgba(41, 82, 227, .45); }
.logo-mark .ic { color: #fff; width: 20px; height: 20px; }
.side-nav { flex: 1; overflow-y: auto; }
.nav-section { font-size: .7rem; text-transform: uppercase; letter-spacing: .08em; color: #6b7bb0; font-weight: 600; margin: 1.1rem .7rem .4rem; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .62rem .75rem; margin-bottom: 2px; border-radius: 10px; color: #c7d2fe; font-weight: 500; transition: background .15s, color .15s; }
.side-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.side-nav a.active { background: rgba(79, 124, 255, .18); color: #fff; box-shadow: inset 3px 0 0 #6f93ff; }
.side-nav a .ic { width: 19px; height: 19px; opacity: .9; }
.side-user { display: flex; align-items: center; gap: .6rem; padding: .8rem .5rem 0; margin-top: .75rem; border-top: 1px solid rgba(255, 255, 255, .08); }
.side-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.side-user-info strong { color: #fff; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side-user-info span { font-size: .75rem; color: #8b9bd0; }
.sidebar .icon-btn { color: #a5b4fc; }
.sidebar .icon-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.main { flex: 1; margin-left: var(--sidebar); min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: .75rem; height: 64px; padding: 0 2rem; background: rgba(243, 245, 250, .85); backdrop-filter: blur(10px); border-bottom: 1px solid transparent; }
.topbar-title { font-size: 1.15rem; font-weight: 700; letter-spacing: -.01em; flex: 1; }
.topbar-date { color: var(--text-2); font-size: .88rem; font-weight: 500; background: var(--surface); padding: .35rem .8rem; border-radius: 999px; box-shadow: var(--shadow); }
.content { padding: .5rem 2rem 2.5rem; max-width: 1240px; width: 100%; }
.backdrop { display: none; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border: 0; background: none; border-radius: 10px; color: var(--text-2); cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.only-mobile { display: none; }
.tabbar { display: none; }

/* ---------- Componenti ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; margin-bottom: 1.25rem; box-shadow: var(--shadow); }
.card.narrow { max-width: 440px; margin: 1rem auto; }
details.card summary { cursor: pointer; list-style: none; display: flex; align-items: center; gap: .5rem; font-weight: 600; color: var(--primary); }
details.card summary::-webkit-details-marker { display: none; }
details.card[open] summary { margin-bottom: .5rem; }
.alert { display: flex; align-items: flex-start; gap: .65rem; padding: .85rem 1rem; border-radius: var(--radius-sm); margin-bottom: 1rem; font-weight: 500; border: 1px solid transparent; }
.alert .ic { width: 19px; height: 19px; margin-top: 1px; }
.alert-success { background: var(--green-soft); color: #08643f; border-color: #bfe9d5; }
.alert-error { background: var(--red-soft); color: #a31d31; border-color: #f7c6ce; }
.alert-info { background: var(--primary-soft); color: var(--primary-2); border-color: #cdd8ff; }
.muted { color: var(--text-2); }
.small { font-size: .85rem; }

label { display: block; margin-bottom: 1rem; font-size: .85rem; font-weight: 600; color: var(--text-2); }
input, select, textarea {
  display: block; width: 100%; margin-top: .4rem; padding: .66rem .8rem; font: inherit; font-weight: 400; color: var(--text);
  border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
/* Stessa altezza per campi e menu su tutti i browser (Safari ignora il padding dei select nativi) */
input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=color]), select { height: 2.75rem; line-height: 1.25; }
select {
  -webkit-appearance: none; appearance: none; padding-right: 2.4rem; cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right .8rem center; background-size: 16px;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 4px rgba(41, 82, 227, .12); }
input[type=checkbox] { display: inline-block; width: 18px; height: 18px; margin: 0 .55rem 0 0; vertical-align: -3px; accent-color: var(--primary); }
input[type=radio] { display: inline-block; width: 18px; height: 18px; margin: 0 .55rem 0 0; accent-color: var(--primary); flex: none; }
label:has(> input[type=radio]) { font-weight: 500; color: var(--text); display: flex; align-items: flex-start; cursor: pointer; }
label:has(> input[type=checkbox]) { font-weight: 500; color: var(--text); display: flex; align-items: center; cursor: pointer; }
.check-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: .6rem; }
.check-grid label { margin: 0; padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.check-grid label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: .45rem; padding: .62rem 1.05rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); color: var(--text); font: inherit; font-weight: 600; font-size: .9rem; cursor: pointer; transition: all .15s; white-space: nowrap; }
.btn:hover { text-decoration: none; border-color: #cbd3e3; background: var(--surface-2); }
.btn .ic { width: 17px; height: 17px; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(41, 82, 227, .25); }
.btn.primary:hover { background: var(--primary-2); }
.btn.danger { color: var(--red); border-color: #f5c2ca; background: var(--surface); }
.btn.danger:hover { background: var(--red-soft); }
.btn.small { padding: .38rem .7rem; font-size: .82rem; border-radius: 8px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
button.link { background: none; border: 0; font: inherit; cursor: pointer; }
form.inline { display: inline; }

.table-wrap { overflow-x: auto; margin: 0 -1.4rem; padding: 0 1.4rem; }
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .9rem; }
.table th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; font-weight: 600; color: var(--muted); padding: .65rem .75rem; border-bottom: 1px solid var(--border); background: var(--surface); white-space: nowrap; }
.table td { padding: .8rem .75rem; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr { transition: background .12s; }
.table tbody tr:hover { background: var(--surface-2); }
.table tbody tr:last-child td { border-bottom: 0; }
.table tfoot th { border-top: 1px solid var(--border); border-bottom: 0; color: var(--text); font-size: .85rem; }
.person { display: flex; align-items: center; gap: .7rem; font-weight: 600; }
.avatar { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; flex: none; font-size: .78rem; font-weight: 700; color: hsl(var(--h) 55% 32%); background: hsl(var(--h) 75% 92%); }
.avatar.lg { width: 48px; height: 48px; font-size: 1rem; }
.sidebar .avatar { color: #fff; background: hsl(var(--h) 55% 45%); }

.tag { display: inline-flex; align-items: center; padding: .15rem .55rem; border-radius: 7px; font-size: .8rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tag.in { background: var(--green-soft); color: var(--green); }
.tag.out { background: var(--red-soft); color: var(--red); }
.badge { display: inline-flex; align-items: center; gap: .35rem; padding: .2rem .6rem; border-radius: 999px; font-size: .75rem; font-weight: 600; background: #eef1f6; color: var(--text-2); white-space: nowrap; }
.badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .7; }
.badge.ok { background: var(--green-soft); color: var(--green); }
.badge.warn { background: var(--amber-soft); color: #a86800; }
.badge.bad { background: var(--red-soft); color: var(--red); }

.row-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; flex-wrap: wrap; margin-bottom: 1rem; }
.row-between h1 { margin: 0; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(230px, 100%), 1fr)); gap: 0 1.1rem; }
.filters { display: flex; flex-wrap: wrap; gap: .8rem; align-items: flex-end; }
.filters label { margin: 0; min-width: 150px; }
.filters label:has(> input[type=checkbox]) { min-width: 0; padding-bottom: .65rem; }
.actions { display: flex; gap: .6rem; flex-wrap: wrap; margin-top: .5rem; }
.segmented { display: inline-flex; background: #e9edf5; padding: 4px; border-radius: 12px; gap: 2px; }
.segmented a { padding: .42rem .9rem; border-radius: 9px; font-weight: 600; font-size: .86rem; color: var(--text-2); }
.segmented a:hover { text-decoration: none; color: var(--text); }
.segmented a.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.empty-state { text-align: center; color: var(--text-2); padding: 2rem 1rem; }

/* ---------- Statistiche ---------- */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 1.25rem; }
.stat { display: flex; align-items: center; gap: 1rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.2rem; box-shadow: var(--shadow); }
.stat-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; flex: none; }
.stat-icon .ic { width: 23px; height: 23px; }
.stat-icon.green { background: var(--green-soft); color: var(--green); }
.stat-icon.blue { background: var(--primary-soft); color: var(--primary); }
.stat-icon.red { background: var(--red-soft); color: var(--red); }
.stat-icon.amber { background: var(--amber-soft); color: var(--amber); }
.stat-label { font-size: .82rem; color: var(--text-2); font-weight: 500; }
.stat-value { font-size: 1.75rem; font-weight: 800; letter-spacing: -.02em; line-height: 1.1; color: var(--text); }
a.stat:hover { text-decoration: none; border-color: #cbd3e3; }

/* ---------- Timbratura ---------- */
.punch-hero { position: relative; overflow: hidden; text-align: center; max-width: 520px; margin: 0 auto 1.25rem; padding: 2rem 1.5rem 1.6rem; background: linear-gradient(160deg, var(--navy) 0%, var(--navy-2) 60%, #23409a 100%); color: #fff; border: 0; }
.punch-hero::before { content: ""; position: absolute; width: 380px; height: 380px; border-radius: 50%; top: -190px; right: -140px; background: radial-gradient(circle, rgba(111, 147, 255, .35), transparent 70%); }
.punch-hero > * { position: relative; }
.hello { font-size: .95rem; color: #c7d2fe; margin: 0; }
.clock { font-size: 3.6rem; font-weight: 800; letter-spacing: -.03em; margin: .1rem 0 0; font-variant-numeric: tabular-nums; line-height: 1.1; }
.clock small { font-size: 1.4rem; color: #8ea2e6; font-weight: 600; }
.shift { display: inline-flex; align-items: center; gap: .4rem; font-size: .85rem; color: #c7d2fe; background: rgba(255, 255, 255, .08); padding: .3rem .8rem; border-radius: 999px; margin-top: .6rem; }
.shift .ic { width: 15px; height: 15px; }
.punch-btn-wrap { display: grid; place-items: center; margin: 1.8rem 0 1.2rem; }
.punch-btn {
  position: relative; width: 190px; height: 190px; border-radius: 50%; border: 0; cursor: pointer; color: #fff;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .35rem;
  font: inherit; font-weight: 800; font-size: 1.15rem; letter-spacing: .02em; transition: transform .15s, filter .15s;
}
.punch-btn .ic { width: 46px; height: 46px; stroke-width: 1.7; }
.punch-btn small { font-weight: 500; font-size: .78rem; opacity: .85; letter-spacing: 0; }
.punch-btn.in { background: radial-gradient(circle at 30% 25%, #2ee6a0, #0f9d67 70%); box-shadow: 0 12px 40px rgba(15, 157, 103, .5), 0 0 0 10px rgba(46, 230, 160, .12); }
.punch-btn.out { background: radial-gradient(circle at 30% 25%, #ff7a8c, #e0384f 70%); box-shadow: 0 12px 40px rgba(224, 56, 79, .5), 0 0 0 10px rgba(255, 122, 140, .12); }
.punch-btn:not(:disabled)::after { content: ""; position: absolute; inset: -10px; border-radius: 50%; border: 2px solid currentColor; opacity: 0; animation: pulse 2.2s infinite; }
.punch-btn.in::after { color: #2ee6a0; }
.punch-btn.out::after { color: #ff7a8c; }
.punch-btn:not(:disabled):hover { transform: scale(1.03); }
.punch-btn:not(:disabled):active { transform: scale(.97); }
.punch-btn:disabled { filter: grayscale(.85) brightness(.75); cursor: not-allowed; box-shadow: none; }
@keyframes pulse { 0% { transform: scale(.95); opacity: .6; } 100% { transform: scale(1.25); opacity: 0; } }
.geo-status { display: flex; align-items: center; justify-content: center; gap: .5rem; font-size: .9rem; font-weight: 500; padding: .7rem 1rem; border-radius: 12px; background: rgba(255, 255, 255, .08); color: #dbe3ff; }
.geo-status .dot { width: 9px; height: 9px; border-radius: 50%; background: #8ea2e6; flex: none; animation: blink 1.2s infinite; }
.geo-status.good { background: rgba(46, 230, 160, .14); color: #a7f3d0; }
.geo-status.good .dot { background: #2ee6a0; animation: none; }
.geo-status.bad { background: rgba(255, 122, 140, .16); color: #fecdd3; }
.geo-status.bad .dot { background: #ff7a8c; animation: none; }
@keyframes blink { 50% { opacity: .3; } }
.ghost-btn { margin-top: .9rem; display: inline-flex; align-items: center; gap: .4rem; background: none; border: 0; color: #a5b4fc; font: inherit; font-weight: 600; font-size: .88rem; cursor: pointer; padding: .4rem .7rem; border-radius: 8px; }
.ghost-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.ghost-btn .ic { width: 16px; height: 16px; }
#result .alert { margin: 1rem 0 0; text-align: left; }
.punch-hero .alert-success { background: rgba(46, 230, 160, .16); color: #d1fae5; border-color: rgba(46, 230, 160, .3); }
.punch-btn.done, .punch-btn.done:disabled { background: radial-gradient(circle at 30% 25%, #6ee7b7, #0f9d67 70%); filter: none; opacity: .9; }
.punch-hero .alert-info { background: rgba(255, 255, 255, .1); color: #e0e7ff; border-color: rgba(255, 255, 255, .18); text-align: left; }
.exempt-box { margin: 1.6rem 0 .4rem; padding: 1.4rem 1.2rem; border-radius: 16px; background: rgba(255, 255, 255, .08); }
.exempt-box > .ic { width: 40px; height: 40px; color: #6ee7b7; }
.exempt-box p { color: #dbe3ff; margin: .6rem 0 1rem; line-height: 1.5; }
.punch-hero .alert-error { background: rgba(255, 122, 140, .18); color: #ffe4e8; border-color: rgba(255, 122, 140, .3); }
.today-card { max-width: 520px; margin: 0 auto 1.25rem; }
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { display: flex; align-items: center; gap: .9rem; padding: .55rem 0; position: relative; }
.timeline li:not(:last-child)::after { content: ""; position: absolute; left: 17px; top: 42px; bottom: -8px; width: 2px; background: var(--border); }
.tl-dot { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; flex: none; }
.tl-dot .ic { width: 17px; height: 17px; }
.tl-dot.in { background: var(--green-soft); color: var(--green); }
.tl-dot.out { background: var(--red-soft); color: var(--red); }
.tl-time { font-weight: 800; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.tl-meta { font-size: .82rem; color: var(--text-2); }
.timeline .empty { color: var(--text-2); justify-content: center; padding: 1rem 0; }

/* ---------- Orari ---------- */
.sched-table input[type=time] { min-width: 7rem; margin: 0; padding: .5rem .6rem; }
.sched-table td:first-child { font-weight: 600; }
.sched-table .hours { font-weight: 700; font-variant-numeric: tabular-nums; color: var(--primary); }
#map { height: 340px; border-radius: var(--radius-sm); margin-bottom: 1.2rem; border: 1px solid var(--border); z-index: 0; }

/* ---------- Accesso ---------- */
body.bare { min-height: 100vh; background: linear-gradient(135deg, #0b1530 0%, var(--navy-2) 55%, #2952e3 130%); }
.bare-main { min-height: 100vh; display: grid; place-items: center; padding: 1.5rem; }
.login-card { width: 100%; max-width: 420px; background: var(--surface); border-radius: 22px; padding: 2.2rem 2rem; box-shadow: var(--shadow-lg); }
.login-brand { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 1.8rem; }
.login-brand .logo-mark { width: 58px; height: 58px; border-radius: 18px; margin-bottom: 1rem; }
.login-brand .logo-mark .ic { width: 30px; height: 30px; }
.login-brand h1 { margin: 0; font-size: 1.45rem; }
.login-brand p { margin: .3rem 0 0; color: var(--text-2); }
.login-card .btn.primary { padding: .8rem; font-size: 1rem; margin-top: .4rem; }
.bare-main > .alert { position: fixed; top: 1rem; left: 50%; transform: translateX(-50%); max-width: 92vw; }
.bare-main .card.narrow { border-radius: 22px; box-shadow: var(--shadow-lg); }

/* ---------- Telefono ---------- */
@media (max-width: 960px) {
  .sidebar { transform: translateX(-100%); transition: transform .25s ease; box-shadow: var(--shadow-lg); }
  .nav-open .sidebar { transform: none; }
  .nav-open .backdrop { display: block; position: fixed; inset: 0; z-index: 30; background: rgba(15, 23, 42, .45); }
  .main { margin-left: 0; }
  .only-mobile { display: inline-grid; }
  .topbar { padding: 0 1rem; height: 58px; }
  .topbar-date { display: none; }
  .content { padding: .25rem 1rem 2rem; }
  .card { padding: 1.1rem; border-radius: 14px; }
  .table-wrap { margin: 0 -1.1rem; padding: 0 1.1rem; }
  .stats { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .stat { flex-direction: column; align-items: flex-start; gap: .6rem; padding: 1rem; }
  .stat-icon { width: 40px; height: 40px; border-radius: 12px; }
}
@media (max-width: 960px) {
  body.has-shell:has(.tabbar) .content { padding-bottom: 6rem; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 25; background: rgba(255, 255, 255, .95); backdrop-filter: blur(12px); border-top: 1px solid var(--border); padding: .4rem .5rem calc(.4rem + env(safe-area-inset-bottom)); }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: .15rem; padding: .35rem 0; font-size: .7rem; font-weight: 600; color: var(--muted); border-radius: 10px; }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: var(--primary); }
  .tabbar .ic { width: 22px; height: 22px; }
  .punch-hero { margin-left: -1rem; margin-right: -1rem; border-radius: 0 0 26px 26px; margin-top: -.25rem; }
  .clock { font-size: 3.2rem; }
}

/* ---------- Documenti ---------- */
.ic.big { width: 38px; height: 38px; color: var(--primary); }
.nowrap { white-space: nowrap; }
.dropzone { position: relative; display: flex; flex-direction: column; align-items: center; gap: .45rem; text-align: center; padding: 2rem 1.25rem; border: 2px dashed #c9d3ea; border-radius: var(--radius); background: var(--surface-2); color: var(--text); cursor: pointer; transition: all .15s; font-weight: 500; }
.dropzone:hover, .dropzone.over { border-color: var(--primary); background: var(--primary-soft); }
.dropzone.has-files { border-style: solid; border-color: var(--green); background: var(--green-soft); }
.dropzone input[type=file] { position: absolute; inset: 0; opacity: 0; cursor: pointer; margin: 0; }
.file-list { font-weight: 600; color: var(--green); font-size: .88rem; }
.year-tabs { display: flex; gap: .5rem; overflow-x: auto; margin-bottom: 1.1rem; padding-bottom: 2px; }
.year-tabs a { padding: .5rem 1.1rem; border-radius: 999px; background: var(--surface); border: 1px solid var(--border); font-weight: 700; color: var(--text-2); }
.year-tabs a:hover { text-decoration: none; color: var(--text); }
.year-tabs a.on { background: var(--primary); border-color: var(--primary); color: #fff; box-shadow: 0 4px 12px rgba(41, 82, 227, .25); }
.doc-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: .8rem; }
.doc-tile { position: relative; display: flex; flex-direction: column; gap: .3rem; padding: 1rem; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); color: var(--text); transition: all .15s; }
a.doc-tile:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); transform: translateY(-2px); }
.doc-tile.empty { background: var(--surface-2); color: var(--muted); border-style: dashed; }
.doc-tile.new::after { content: ""; position: absolute; top: 12px; right: 12px; width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 0 4px var(--green-soft); }
.doc-icon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 11px; background: var(--red-soft); color: var(--red); margin-bottom: .2rem; flex: none; }
.doc-tile.empty .doc-icon { background: #eef1f6; color: var(--muted); }
.doc-name { font-weight: 700; }
.doc-meta { font-size: .78rem; color: var(--text-2); display: block; font-weight: 500; }
.doc-tile.new .doc-meta { color: var(--green); font-weight: 700; }
.doc-tile.empty .doc-meta { color: var(--muted); }
.doc-list { display: flex; flex-direction: column; gap: .6rem; }
.doc-row { display: flex; align-items: center; gap: .9rem; padding: .85rem 1rem; border: 1px solid var(--border); border-radius: 14px; color: var(--text); }
.doc-row > span:nth-child(2) { flex: 1; }
.doc-row:hover { text-decoration: none; border-color: var(--primary); box-shadow: var(--shadow); }
.empty-state .ic.big { width: 48px; height: 48px; margin-bottom: .5rem; }
@media (max-width: 960px) { .doc-grid { grid-template-columns: repeat(2, 1fr); } }

/* Richieste di assenza */
.leave-dot { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 50%; margin-right: .45rem; vertical-align: 0; }
.badge.attesa { background: #fff4d6; color: #8a5a00; }
.badge.approvata { background: var(--green-soft); color: #08643f; }
.badge.rifiutata { background: #fde2e6; color: #a3172b; }
.badge.annullata { background: #eef0f5; color: var(--muted); }
.req-actions { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.req-actions input[type=text] { min-width: 160px; flex: 1; }
.stat-link { text-decoration: none; color: inherit; }
@media (max-width: 640px) {
  .req-actions input[type=text] { min-width: 0; width: 100%; }
  .table td .muted.small { overflow-wrap: anywhere; }
}

/* Chiusura mese */
.close-state { display: flex; gap: .8rem; align-items: flex-start; padding: .9rem 1rem; border-radius: 12px; background: var(--amber-soft); color: #7a4b00; margin: .4rem 0 1rem; }
.close-state.closed { background: var(--green-soft); color: #08643f; }
.close-state > .ic { width: 22px; height: 22px; flex: none; margin-top: 1px; }
.close-state strong { display: block; }
.close-state span { font-size: .9rem; }
.close-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: flex-start; }
.close-form { display: inline-flex; gap: .8rem; align-items: center; }
.close-form label { margin: 0; }
.inline-details { position: relative; }
.inline-details > summary { list-style: none; }
.inline-details > summary::-webkit-details-marker { display: none; }
.pop-form { position: absolute; z-index: 20; top: calc(100% + .4rem); left: 0; width: min(360px, 86vw); background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; box-shadow: 0 12px 32px rgba(15, 27, 61, .16); }
.table tr.selected td { background: var(--primary-soft); }
.day-table tr.off td { background: #f6f7fa; color: var(--text-2); }
.day-table tr.anom td { background: #fff6f7; }
.day-table .badge { margin: .1rem 0; }
.fix summary { cursor: pointer; color: var(--primary); font-weight: 600; font-size: .85rem; margin-top: .3rem; }
.fix-form { display: grid; gap: .4rem; margin: .6rem 0; padding: .7rem; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); min-width: 220px; }
.fix-form input, .fix-form select { margin: 0; }
.fix-row { display: flex; gap: .4rem; }
.fix-row[hidden] { display: none; }
.plain-list { list-style: none; padding: 0; margin: 0; }
.plain-list li { padding: .45rem 0; border-bottom: 1px solid var(--border); font-size: .9rem; }
.nowrap { white-space: nowrap; }
.co-box { padding: .7rem .9rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); }
.co-box:has(input[name^=co]:checked) { border-color: var(--primary); background: var(--primary-soft); }
.check-grid .co-box label, .check-grid .co-box label:has(input:checked) { margin: 0 0 .35rem; padding: 0; border: 0; background: none; }
.co-select { width: 100%; min-width: 0; margin-top: .35rem; }
.band { display: flex; flex-wrap: wrap; align-items: center; gap: .3rem; min-width: 250px; }
.sched-table .band input[type=time] { width: 116px; min-width: 0; margin: 0; }
.req-card { border: 1px solid var(--border); border-radius: 12px; padding: .9rem 1rem; margin-top: .8rem; }
.req-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .6rem; }
.req-card p { margin: .6rem 0; }

/* Dividi PDF: creazione dei dipendenti mancanti dalla CU */
.lul-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.lul-new { display: flex; gap: .4rem; flex-wrap: wrap; align-items: center; }
.lul-new input[type=text] { width: 9rem; height: 2.2rem; padding: .3rem .5rem; margin: 0; }
.lul-new .lul-check { display: inline-flex; align-items: center; gap: .3rem; margin: 0; font-size: .85rem; white-space: nowrap; }
.lul-new .lul-check input { margin: 0; }

/* Dipendenti: scelta della società */
.co-pick { margin: 1rem 0 0; }
.co-pick .stat { text-decoration: none; color: inherit; transition: border-color .15s, transform .15s; }
.co-pick .stat:hover { border-color: var(--primary); transform: translateY(-1px); }
.co-pick .stat-label { display: block; font-size: .95rem; color: var(--text); font-weight: 600; }

/* Richieste divise per società */
.badge.parziale { background: #e8eefc; color: #2342a8; }
.part-line { margin-bottom: .25rem; }
.part-actions { display: inline-flex; align-items: center; gap: .3rem; flex-wrap: wrap; }
.part-actions .small { font-weight: 600; }

/* Campi data e ora su iPhone/iPad: Safari impone una larghezza minima e un'altezza propria, il campo usciva dal riquadro */
.grid > *, label { min-width: 0; }
input[type=date], input[type=time] { min-width: 0; max-width: 100%; }
@supports (-webkit-touch-callout: none) {
  input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; text-align: left; }
  input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; margin: 0; min-height: 1.25em; }
}

/* Timbrature da sistemare */
.issue-banner { display: flex; text-decoration: none; margin-bottom: 1rem; }
.issue-card .req-head { display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start; margin-bottom: .5rem; }
.issue-card details { margin: .5rem 0; }
.issue-card details > summary { list-style: none; display: inline-flex; }
.issue-card details > summary::-webkit-details-marker { display: none; }
.issue-form { margin-top: .9rem; padding: .9rem; background: var(--bg, #f3f5fa); border-radius: var(--radius-sm); }

/* v17: ricerca indirizzo nelle sedi */
.geo-search { display: flex; gap: .6rem; margin-bottom: .75rem; }
.geo-search input { flex: 1; min-width: 0; }
.geo-results { border: 1px solid var(--border); border-radius: var(--radius-sm); margin-bottom: .75rem; padding: .4rem; font-size: .9rem; }
.geo-item { display: block; width: 100%; text-align: left; background: none; border: 0; border-radius: 6px; padding: .5rem .6rem; cursor: pointer; font: inherit; color: inherit; }
.geo-item:hover { background: var(--primary-soft); }

/* v17: impostazioni per società, informativa */
.co-settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(260px, 100%), 1fr)); gap: 1rem; margin-bottom: 1rem; }
.co-box { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .9rem 1rem; margin: 0; min-width: 0; }
.co-box legend { font-weight: 700; padding: 0 .4rem; }
.privacy-text { background: var(--bg, #f6f7fb); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; max-height: 55vh; overflow: auto; font-size: .92rem; line-height: 1.55; overflow-wrap: anywhere; }

/* v17: su telefono niente esce dal riquadro (pulsanti lunghi vanno a capo, campi entro la larghezza) */
@media (max-width: 640px) {
  .card .btn, .pop-form .btn { max-width: 100%; white-space: normal; text-align: center; }
  .card input, .card select, .card textarea { max-width: 100%; }
  .filters, .actions, .req-actions, .close-actions { flex-wrap: wrap; }
  .filters > *, .req-actions > * { min-width: 0; max-width: 100%; }
  .card, .req-card, .stat, fieldset { min-width: 0; overflow-wrap: anywhere; }
  .filters label { min-width: 0; flex: 1 1 140px; }
  .fix-form { min-width: 0; }
  input, select, textarea { min-width: 0; }
}
