/* Orevia — interfaccia. Palette dal logo V6: blu notte #012C56, petrolio #028294, azzurro #0081EB */
:root {
  --navy: #012c56; --teal: #028294; --sky: #0081eb;
  --bg: #f3f6fa; --surface: #ffffff; --surface-2: #f5f8fc; --border: #dce4ee; --border-strong: #c7d3e1;
  --text: #0b1f33; --muted: #52657a; --faint: #8597ab;
  --brand: var(--navy); --brand-600: #0a3d70; --brand-50: #e6eef7; --on-brand: #ffffff;
  --accent: var(--teal); --accent-50: #e0f3f5; --link: #0067bd;
  --ferie: #02727f; --ferie-bg: #ddf1f3; --on-ferie: #ffffff; --perm: #a86400; --perm-bg: #fdf0d9; --ass: #6b4fbb; --ass-bg: #ece6fa;
  --chius: #0b4a86; --chius-bg: #e3ecf7; --danger: #c43535; --danger-bg: #fde8e8;
  --ok: #02828f; --warn: #b26a00;
  --weekend: #eef2f7; --festivo: #fcebee; --today: var(--sky);
  --shadow: 0 1px 2px rgba(1,44,86,.06), 0 2px 8px rgba(1,44,86,.07);
  --shadow-lg: 0 12px 40px rgba(1,44,86,.20);
  --radius: 12px; --radius-sm: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #07131f; --surface: #0d1d2e; --surface-2: #112539; --border: #1d3550; --border-strong: #2a4766;
    --text: #e6eef6; --muted: #93a8be; --faint: #6a8098;
    --brand: #4fb6c4; --brand-600: #7ccbd6; --brand-50: #0f2d40; --on-brand: #04202b;
    --accent: #4fb6c4; --accent-50: #0f3341; --link: #6cb8ff;
    --ferie: #4fc3cf; --ferie-bg: #0e3640; --on-ferie: #04202b; --perm: #f0b24a; --perm-bg: #3a2c12; --ass: #b9a4f5; --ass-bg: #2b2346;
    --chius: #8dbaf2; --chius-bg: #13304f; --danger: #f07b7b; --danger-bg: #3d1c1f;
    --ok: #4fc3cf; --warn: #f0b24a;
    --weekend: #0b1a2a; --festivo: #2a1a26; --today: #4ba8ff;
    --shadow: 0 1px 2px rgba(0,0,0,.35), 0 2px 8px rgba(0,0,0,.3);
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 var(--font); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--link); }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; }
.muted { color: var(--muted); } .small { font-size: 12px; }
.num { font-variant-numeric: tabular-nums; }

/* boot */
.boot { display: grid; place-items: center; height: 100vh; }
.boot-spinner { width: 28px; height: 28px; border: 3px solid var(--border); border-top-color: var(--brand); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* login */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(1200px 600px at 10% -10%, var(--brand-50), transparent), var(--bg); }
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 28px; box-shadow: var(--shadow); }
.wordmark { display: grid; justify-items: center; text-align: center; margin: 4px 0 22px; gap: 6px; }
.wordmark img { width: 230px; height: auto; }
.wordmark.sm img { width: 170px; }
.wm-title { font-weight: 650; font-size: 18px; margin-top: 6px; }
.wm-sub { font-size: 13px; color: var(--muted); letter-spacing: .02em; }
.auth-card form { display: grid; gap: 14px; }
.versione { margin-top: 18px; text-align: center; font-size: 11px; color: var(--muted); letter-spacing: .03em; font-variant-numeric: tabular-nums; }

/* layout */
.shell { display: grid; grid-template-columns: 240px 1fr; min-height: 100vh; }
.sidebar { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { display: grid; gap: 4px; padding: 2px 10px 16px; }
.brand img { width: 168px; height: auto; display: block; }
.brand span { font-size: 12px; color: var(--muted); padding-left: 4px; }
.nav-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 14px 10px 6px; }
.nav a { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border-radius: var(--radius-sm); color: var(--text); text-decoration: none; font-weight: 500; }
.nav a:hover { background: var(--surface-2); }
.nav a.active { background: var(--brand-50); color: var(--brand); box-shadow: inset 3px 0 0 var(--accent); }
.nav a .ico { width: 18px; text-align: center; opacity: .85; }
.nav a .badge { margin-left: auto; }
.sidebar .me { margin-top: auto; border-top: 1px solid var(--border); padding: 12px 10px 0; display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 600; font-size: 13px; color: #fff; background: var(--navy); flex: none; }
.me .who { flex: 1; min-width: 0; } .me .who b { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.main { min-width: 0; }
.topbar { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 12px; padding: 18px 28px; border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.spacer { flex: 1; }   /* separatore elastico, valido ovunque */
.menu-btn { display: none; }
.content { padding: 24px 28px 48px; max-width: 1400px; }

/* componenti */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-h { display: flex; align-items: center; flex-wrap: wrap; gap: 8px 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.card-h select { width: auto; }   /* es. selettore dell'anno: resta accanto al titolo anche quando la riga va a capo */
.card-b { padding: 18px; }
.grid { display: grid; gap: 16px; }
.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.stack { display: grid; gap: 16px; }
.row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.kpi { padding: 16px 18px; }
.kpi .lbl { color: var(--muted); font-size: 12px; font-weight: 500; }
.kpi .val { font-size: 28px; font-weight: 650; margin-top: 4px; letter-spacing: -.02em; }
.kpi .sub { color: var(--muted); font-size: 12px; margin-top: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); cursor: pointer; font-weight: 550; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.primary:hover { background: var(--brand-600); }
.btn.success { background: var(--ferie); border-color: var(--ferie); color: var(--on-ferie); }
.btn.danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 40%, var(--border)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.sm { height: 30px; padding: 0 10px; font-size: 13px; }
.btn.icon { width: 36px; padding: 0; }
.btn.icon.sm { width: 30px; }
a.btn { text-decoration: none; }

.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); white-space: nowrap; }
.badge.brand { background: var(--brand); color: var(--on-brand); border-color: transparent; }
.badge.IN_ATTESA { background: var(--perm-bg); color: var(--perm); border-color: transparent; }   /* solo richieste e voci in attesa */
.badge.warn { background: transparent; color: var(--warn); border-color: color-mix(in srgb, var(--warn) 60%, transparent); }   /* avvisi e lavori in corso: a contorno, per distinguersi da "In attesa" (pieno) */
.badge.APPROVATA, .badge.ok { background: var(--ferie-bg); color: var(--ferie); border-color: transparent; }
.badge.RIFIUTATA, .badge.ko { background: var(--danger-bg); color: var(--danger); border-color: transparent; }
.badge.ANNULLATA { text-decoration: line-through; }
.chip-F { color: var(--ferie); } .chip-P { color: var(--perm); }

label.f, div.f:not(.muted) { display: grid; gap: 6px; font-weight: 550; font-size: 13px; }
.f .hint { font-weight: 400; color: var(--muted); font-size: 12px; }
div.f .small, div.f .check { font-weight: 400; }   /* in un div.f solo l'etichetta è in grassetto */
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], input[type=email], input[type=search], input[type=tel], select, textarea {
  height: 38px; padding: 0 12px; border-radius: var(--radius-sm); border: 1px solid var(--border-strong); background: var(--surface); width: 100%; }
textarea { height: auto; min-height: 70px; padding: 10px 12px; resize: vertical; }
input:focus, select:focus, textarea:focus, .btn:focus-visible, .seg button:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: 1px; }
input[type=color] { width: 44px; height: 38px; padding: 2px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
.check { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; font-weight: 500; }
.seg { display: inline-flex; background: var(--surface-2); border: 1px solid var(--border); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 14px; border-radius: 7px; cursor: pointer; font-weight: 550; color: var(--muted); }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.err { color: var(--danger); font-size: 13px; min-height: 18px; }

table.t { width: 100%; border-collapse: collapse; }
.t th { text-align: left; font-size: 12px; font-weight: 600; color: var(--muted); padding: 10px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; background: var(--surface-2); }
.t td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.t tr:last-child td { border-bottom: 0; }
.t td.r, .t th.r { text-align: right; }
.t-wrap { overflow-x: auto; }
.empty { padding: 36px 16px; text-align: center; color: var(--muted); }

.bar { position: relative; height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--border); overflow: hidden; min-width: 90px; }
.bar > i { position: absolute; inset: 0 auto 0 0; background: var(--warn); border-radius: 99px; }
.bar > i.ok { background: var(--ok); }
.bar > b { position: absolute; top: -2px; bottom: -2px; width: 2px; background: var(--text); opacity: .45; }

.ring { --p: 0; --c: var(--warn); width: 108px; height: 108px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--c) calc(var(--p) * 1%), var(--surface-2) 0); }
.ring > div { width: 84px; height: 84px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; text-align: center; }
.ring b { font-size: 20px; display: block; } .ring span { font-size: 11px; color: var(--muted); }

.alert { padding: 10px 12px; border-radius: var(--radius-sm); background: var(--perm-bg); color: var(--text); font-size: 13px; border-left: 3px solid var(--perm); }
.alert.info { background: var(--brand-50); border-left-color: var(--brand); }
.alert.error { background: var(--danger-bg); border-left-color: var(--danger); }
.alerts { display: grid; gap: 6px; }

.list { display: grid; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; display: inline-block; }
.dot.F { background: var(--ferie); } .dot.P { background: var(--perm); } .dot.G { background: var(--ass); } .dot.X { background: var(--chius); } .dot.S { background: var(--danger); }

/* calendario team */
.cal-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.cal-toolbar .title { font-size: 18px; font-weight: 650; min-width: 170px; text-transform: capitalize; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend i { width: 14px; height: 14px; border-radius: 4px; display: inline-block; border: 1px solid var(--border); }
.cal-scroll { overflow: auto; max-height: calc(100vh - 230px); border-radius: var(--radius); }
table.cal { border-collapse: separate; border-spacing: 0; font-size: 12px; user-select: none; }
.cal th, .cal td { border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); text-align: center; padding: 0; height: 34px; min-width: 32px; }
.cal thead th { position: sticky; top: 0; z-index: 3; background: var(--surface); font-weight: 600; height: 44px; }
.cal thead th .dw { display: block; font-size: 10px; color: var(--faint); font-weight: 500; text-transform: uppercase; }
.cal .name { position: sticky; left: 0; z-index: 2; background: var(--surface); text-align: left; padding: 0 12px; min-width: 150px; max-width: 180px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal thead .name { z-index: 4; }
.cal .tot { position: sticky; right: 0; background: var(--surface); min-width: 84px; padding: 0 8px; font-variant-numeric: tabular-nums; z-index: 2; }
.cal thead .tot { z-index: 4; }
.cal .we { background: var(--weekend); }
.cal .fe { background: var(--festivo); }
.cal .chx { background: color-mix(in srgb, var(--chius-bg) 55%, transparent); }
.cal .td-today { box-shadow: inset 0 -3px 0 var(--today); }
.cal thead th.td-today { color: var(--today); }
.cal tr.grp td { height: 26px; background: var(--surface-2); text-align: left; }
.cal tr.grp td.name { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; }
.t tr.grp-row td { background: var(--surface-2); font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--brand); font-weight: 700; padding-top: 8px; padding-bottom: 8px; }
.cal tr.special td.name { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .05em; }
.cal td { position: relative; }
.cal td.cell { cursor: default; }
.cal td.cell.editable { cursor: pointer; }
.cal td.cell.editable:hover, .cal td.cell.editable:focus { background: var(--brand-50); outline: none; }
.cal .extra { position: absolute; right: 1px; bottom: 1px; font-size: 9px; font-weight: 700; line-height: 1; padding: 2px 3px; border-radius: 4px;
  background: color-mix(in srgb, var(--sky, #0081eb) 16%, transparent); color: var(--link); z-index: 1; }
.legend .extra { font-size: 10px; font-weight: 700; padding: 1px 4px; border-radius: 4px; background: color-mix(in srgb, var(--sky, #0081eb) 16%, transparent); color: var(--link); }
.tot-mese { display: grid; gap: 1px; font-size: 10.5px; font-weight: 600; text-align: right; line-height: 1.25; white-space: nowrap; }
.chip-X { color: var(--link); }
.cal td.sel { background: color-mix(in srgb, var(--brand) 25%, transparent) !important; }
.pill { position: absolute; inset: 5px 2px; border-radius: 6px; display: grid; place-items: center; font-weight: 700; font-size: 11px; }
.pill.F { background: var(--ferie-bg); color: var(--ferie); }
.pill.P { background: var(--perm-bg); color: var(--perm); }
.pill.G { background: var(--ass-bg); color: var(--ass); }
.pill.X { background: var(--chius-bg); color: var(--chius); }
.pill.H { background: linear-gradient(135deg, var(--chius-bg) 50%, transparent 50%); color: var(--chius); border: 1px dashed var(--chius); }
.pill.half { background: linear-gradient(135deg, var(--ferie-bg) 50%, transparent 50%); border: 1px solid var(--ferie-bg); }
.pill.pending { background-image: repeating-linear-gradient(135deg, transparent 0 4px, rgba(127,127,127,.18) 4px 7px); outline: 1.5px dashed currentColor; outline-offset: -2px; }
.scad { width: 18px; height: 18px; border-radius: 50%; background: var(--danger); color: #fff; font-size: 10px; display: inline-grid; place-items: center; cursor: help; font-weight: 700; }
.cal .pct { font-size: 11px; display: block; }
.cal .pct.ok { color: var(--ok); } .cal .pct.ko { color: var(--warn); }

/* modal */
.modal-back { position: fixed; inset: 0; background: rgba(10,15,25,.45); display: grid; place-items: center; padding: 16px; z-index: 50; animation: fade .12s ease-out; }
.modal { width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 16px; box-shadow: var(--shadow-lg); border: 1px solid var(--border); }
.modal.wide { max-width: 760px; }
.modal-h { display: flex; align-items: center; gap: 10px; padding: 18px 22px 0; }
.modal-h .spacer { flex: 1; }
.modal-b { padding: 18px 22px; display: grid; gap: 14px; }
/* novità di versione */
.novita { display: grid; gap: 10px; }
.novita h3 { margin: 0; font-size: 16px; }
.novita p { margin: 0; }
.novita ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.novita li { display: grid; grid-template-columns: 92px 1fr; gap: 10px; align-items: start; }
.novita li .badge { justify-content: center; }
@media (max-width: 480px) { .novita li { grid-template-columns: 1fr; gap: 4px; } .novita li .badge { justify-self: start; } }
.modal-f { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; padding: 0 22px 20px; }
.preview { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: var(--radius-sm); background: var(--surface-2); border: 1px solid var(--border); }
.preview .big { font-size: 26px; font-weight: 700; }
@keyframes fade { from { opacity: 0; } }

/* toast */
#toast-root { position: fixed; bottom: 20px; right: 20px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow-lg); max-width: min(380px, calc(100vw - 40px)); animation: fade .15s; }
.toast.error { background: var(--danger); color: #fff; }

.secret { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 18px; padding: 12px; background: var(--surface-2); border: 1px dashed var(--border-strong); border-radius: var(--radius-sm); text-align: center; user-select: all; }

/* responsive */
@media (max-width: 1100px) { .cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .cols-3 { grid-template-columns: 1fr; } }
@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 40; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow-lg); }
  .shell.nav-open .sidebar { transform: none; }
  .menu-btn { display: inline-flex; }
  .topbar { padding: 12px 16px; }
  .content { padding: 16px; }
  .cols-2, .form-grid { grid-template-columns: 1fr; }
  .cal-scroll { max-height: none; }
}
@media (max-width: 520px) {
  .cols-4 { grid-template-columns: 1fr 1fr; } .kpi .val { font-size: 22px; }
  /* telefono: righe degli elenchi e barra della console vanno a capo, i toast restano nello schermo */
  .list-item { flex-wrap: wrap; } .list-item .grow { flex: 1 1 180px; }
  .topbar nav { width: 100%; }
  #toast-root { left: 20px; }
}

/* accesso dell'operatore della piattaforma a uno studio */
.op-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 28px; background: var(--danger-bg); color: var(--text); border-bottom: 2px solid var(--danger); font-size: 13px; }
.op-banner span { flex: 1; min-width: 200px; }
@media (max-width: 760px) { .op-banner { padding: 10px 16px; } }

/* privacy: informativa ai dipendenti */
textarea.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; line-height: 1.5; min-height: 320px; }
dl.dati { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 6px 16px; margin: 0 0 10px; }
dl.dati dt { color: var(--muted); font-size: 13px; }
dl.dati dd { margin: 0; overflow-wrap: anywhere; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }
.informativa { max-height: 65vh; overflow-y: auto; line-height: 1.55; }
.informativa h2 { font-size: 17px; margin: 0 0 4px; }
.informativa h3 { font-size: 14.5px; margin: 14px 0 4px; }
.informativa p { margin: 0 0 8px; }
.informativa ul { margin: 0 0 8px; padding-left: 20px; }
@media (max-width: 520px) { dl.dati { grid-template-columns: 1fr; gap: 2px; } dl.dati dd { margin-bottom: 8px; } }

/* calendario: viste anno e giorno */
.linkbtn { border: 0; background: none; padding: 0; font: inherit; color: inherit; cursor: pointer; text-transform: capitalize; }
.linkbtn:hover { color: var(--link); text-decoration: underline; }
.cal-anno th, .cal-anno td { min-width: 76px; }
.cal-anno .anno-cella { cursor: pointer; padding: 2px 4px; }
.cal-anno .anno-cella:hover { background: color-mix(in srgb, var(--link) 8%, transparent); }
.cal-anno .tot-mese { text-align: center; }
.faint { color: var(--faint); }
tr.giorno-riga { cursor: pointer; }
tr.giorno-riga:hover td { background: color-mix(in srgb, var(--link) 6%, transparent); }
tr.giorno-riga:focus-visible { outline: 2px solid color-mix(in srgb, var(--brand) 55%, transparent); outline-offset: -2px; }
.pill-box { position: relative; display: inline-block; width: 40px; height: 26px; vertical-align: middle; margin-right: 6px; }
