/* OnSiteX — palette ricavata dal logo:
   navy dello sfondo, ciano→blu della "X", arancio del fulmine. */
:root {
  --navy-950: #060C22;
  --navy-900: #0A1432;
  --navy-800: #111D45;
  --navy-700: #1B2A5E;
  --navy-600: #2A3C78;
  --cyan-300: #84EBFE;
  --cyan-400: #22D3EE;
  --cyan-500: #08C0F6;
  --blue-500: #1E88E5;
  --blue-600: #1668D6;
  --blue-700: #0F4FB0;
  --orange-300: #FFC069;
  --orange-400: #FFA62B;
  --orange-500: #FC792B;
  --orange-600: #E35D12;
  --grad-brand: linear-gradient(135deg, #22D3EE 0%, #1E88E5 55%, #1668D6 100%);
  --grad-bolt: linear-gradient(135deg, #FFC069 0%, #FFA62B 40%, #FC792B 100%);

  --bg: #F2F5FB;
  --surface: #FFFFFF;
  --surface-2: #F7F9FD;
  --border: #E0E6F0;
  --border-strong: #C9D3E3;
  --text: #0E1834;
  --text-2: #3A4766;
  --muted: #6A7694;
  --ok: #16A34A;     --ok-bg: #E7F7EE;
  --warn: #D97706;   --warn-bg: #FFF4E0;
  --danger: #DC2626; --danger-bg: #FDECEC;
  --info: #1668D6;   --info-bg: #E6F0FD;

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 1px 2px rgba(10, 20, 50, .06), 0 1px 3px rgba(10, 20, 50, .05);
  --shadow: 0 4px 18px rgba(10, 20, 50, .08);
  --shadow-lg: 0 18px 50px rgba(6, 12, 34, .28);
  --font-head: 'Montserrat', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --sidebar-w: 248px;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: var(--font-body); font-size: 15px; line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--blue-600); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { font-family: var(--font-head); margin: 0; letter-spacing: -.01em; }
h1 { font-size: 24px; font-weight: 700; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 15px; font-weight: 700; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.hidden { display: none !important; }

/* ── Layout ── */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar-w); z-index: 40;
  background: var(--navy-900);
  background-image: radial-gradient(120% 60% at 0% 0%, rgba(34, 211, 238, .10), transparent 60%),
                    radial-gradient(90% 50% at 100% 100%, rgba(252, 121, 43, .08), transparent 60%);
  color: #CFD8EE; display: flex; flex-direction: column; padding: 18px 14px;
}
.sidebar .brand { display: block; padding: 4px 8px 18px; }
.sidebar .brand img { width: 100%; max-width: 200px; display: block; }
.nav { display: flex; flex-direction: column; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  color: #BCC7E2; font-weight: 500; font-size: 14.5px; position: relative;
}
.nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; text-decoration: none; }
.nav a.active { background: rgba(34, 211, 238, .12); color: #fff; }
.nav a.active::before {
  content: ''; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px;
  border-radius: 0 4px 4px 0; background: var(--grad-bolt);
}
.nav svg { width: 20px; height: 20px; flex: none; }
.nav .count {
  margin-left: auto; background: var(--orange-500); color: #fff; font-size: 11px; font-weight: 700;
  border-radius: 99px; padding: 1px 7px;
}
.sidebar .spacer { flex: 1; }
.user-box {
  display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 12px;
  background: rgba(255, 255, 255, .05); border: 1px solid rgba(255, 255, 255, .07); cursor: pointer;
  color: #fff; width: 100%; font: inherit; text-align: left;
}
.user-box:hover { background: rgba(255, 255, 255, .09); }
.user-box .nome { font-weight: 600; font-size: 14px; line-height: 1.2; }
.user-box .ruolo { font-size: 12px; color: #93A0C2; }

.main { margin-left: var(--sidebar-w); min-height: 100vh; }
.content { padding: 26px 30px 60px; max-width: 1500px; margin: 0 auto; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.page-head h1 { margin-right: auto; }
.page-head .sub { width: 100%; color: var(--muted); margin-top: -8px; font-size: 14px; }

.topbar, .tabbar { display: none; }

@media (max-width: 900px) {
  .sidebar { display: none; }
  .main { margin-left: 0; padding-bottom: calc(68px + env(safe-area-inset-bottom)); }
  .content { padding: 16px 16px 40px; }
  .topbar {
    display: flex; align-items: center; gap: 10px; position: sticky; top: 0; z-index: 30;
    background: var(--navy-900); color: #fff; padding: 10px 16px; padding-top: calc(10px + env(safe-area-inset-top));
  }
  .topbar img { height: 30px; }
  .topbar .titolo { font-family: var(--font-head); font-weight: 700; font-size: 16px; margin-right: auto; }
  .topbar .user-btn { background: none; border: 0; padding: 0; cursor: pointer; }
  .tabbar {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
    background: var(--navy-900); border-top: 1px solid rgba(255, 255, 255, .08);
    padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
  }
  .tabbar a {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
    color: #8F9CC0; font-size: 11px; font-weight: 600; padding: 4px 0; position: relative;
  }
  .tabbar a:hover { text-decoration: none; }
  .tabbar a.active { color: #fff; }
  .tabbar a.active svg { color: var(--cyan-400); }
  .tabbar svg { width: 23px; height: 23px; }
  .tabbar .count { position: absolute; top: 0; right: calc(50% - 20px); background: var(--orange-500); color: #fff; font-size: 10px; border-radius: 99px; padding: 0 5px; }
  h1 { font-size: 21px; }
  .page-head { margin-bottom: 14px; }
}

/* ── Avatar ── */
.avatar {
  width: 34px; height: 34px; border-radius: 50%; flex: none; display: inline-grid; place-items: center;
  color: #fff; font-weight: 700; font-size: 13px; font-family: var(--font-head); letter-spacing: .02em;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .25);
}
.avatar.sm { width: 26px; height: 26px; font-size: 10.5px; }
.avatar.xs { width: 22px; height: 22px; font-size: 9.5px; box-shadow: 0 0 0 2px #fff; }
.avatars { display: inline-flex; }
.avatars .avatar + .avatar { margin-left: -6px; }

/* ── Card ── */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-sm); padding: 18px;
}
.card + .card { margin-top: 16px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.card-head h2, .card-head h3 { margin-right: auto; }
.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); align-items: start; }
@media (max-width: 1100px) { .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) { .grid-2, .grid-3 { grid-template-columns: minmax(0, 1fr); } }

/* ── KPI ── */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 18px; }
.kpi {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px 18px;
  box-shadow: var(--shadow-sm); position: relative; overflow: hidden;
}
.kpi .label { font-size: 12.5px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; }
.kpi .value { font-family: var(--font-head); font-size: 30px; font-weight: 800; margin-top: 4px; line-height: 1.1; }
.kpi .hint { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.kpi::after { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--grad-brand); }
.kpi.accent::after { background: var(--grad-bolt); }
.kpi.danger::after { background: var(--danger); }
.kpi.hero { background: var(--navy-900); color: #fff; border-color: var(--navy-800); }
.kpi.hero .label, .kpi.hero .hint { color: #9FB0D6; }
a.kpi { color: inherit; }
a.kpi:hover { text-decoration: none; box-shadow: var(--shadow); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  font: 600 14px var(--font-body); padding: 9px 15px; border-radius: 10px; cursor: pointer;
  border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  transition: transform .06s, box-shadow .15s, background .15s; white-space: nowrap; text-decoration: none !important;
  min-height: 40px;
}
.btn:hover { background: var(--surface-2); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }
.btn-primary { background: var(--grad-brand); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(22, 104, 214, .28); }
.btn-primary:hover { background: var(--grad-brand); filter: brightness(1.06); }
.btn-accent { background: var(--grad-bolt); color: #fff; border-color: transparent; box-shadow: 0 4px 14px rgba(252, 121, 43, .28); }
.btn-accent:hover { background: var(--grad-bolt); filter: brightness(1.05); }
.btn-dark { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.btn-dark:hover { background: var(--navy-800); }
.btn-ghost { background: transparent; border-color: transparent; color: var(--text-2); }
.btn-ghost:hover { background: rgba(10, 20, 50, .05); }
.btn-danger { color: var(--danger); border-color: #F3C2C2; }
.btn-danger:hover { background: var(--danger-bg); }
.btn-sm { padding: 6px 11px; font-size: 13px; min-height: 32px; border-radius: 8px; }
.btn-lg { padding: 13px 20px; font-size: 16px; min-height: 50px; border-radius: 12px; }
.btn-block { width: 100%; }
.btn-group { display: inline-flex; background: var(--surface); border: 1px solid var(--border-strong); border-radius: 10px; padding: 3px; gap: 2px; }
.btn-group button {
  border: 0; background: transparent; font: 600 13.5px var(--font-body); color: var(--text-2);
  padding: 6px 12px; border-radius: 7px; cursor: pointer; min-height: 32px;
}
.btn-group button.active { background: var(--navy-900); color: #fff; }
.icon-btn { width: 40px; padding: 0; }

/* ── Badge ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 600;
  padding: 3px 9px; border-radius: 99px; background: var(--surface-2); color: var(--text-2);
  border: 1px solid var(--border); white-space: nowrap; line-height: 1.35;
}
.badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.st-aperta, .st-programmato { background: var(--info-bg); color: var(--info); border-color: #C7DBFA; }
.st-in_corso { background: var(--warn-bg); color: #B45309; border-color: #FBD9A5; }
.st-chiusa, .st-completato, .st-approvata { background: var(--ok-bg); color: var(--ok); border-color: #BDE8CD; }
.st-annullata, .st-annullato, .st-rifiutata { background: #F1F3F7; color: var(--muted); border-color: var(--border); }
.st-richiesta { background: var(--warn-bg); color: #B45309; border-color: #FBD9A5; }

/* ── Forms ── */
label.f { display: block; font-size: 13px; font-weight: 600; color: var(--text-2); margin-bottom: 5px; }
.field { margin-bottom: 14px; }
.row { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number],
input[type=date], input[type=time], input[type=search], input[type=color], select, textarea {
  width: 100%; font: 15px var(--font-body); color: var(--text); background: var(--surface);
  border: 1px solid var(--border-strong); border-radius: 10px; padding: 10px 12px; min-height: 42px;
  transition: border-color .15s, box-shadow .15s; -webkit-appearance: none; appearance: none;
}
select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236A7694' stroke-width='2' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 12px center; padding-right: 34px;
}
input[type=color] { padding: 4px; height: 42px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(30, 136, 229, .16); }
.check { display: flex; align-items: center; gap: 9px; font-size: 14px; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--blue-600); }
.search { position: relative; }
.search input { padding-left: 38px; }
.search svg { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); width: 17px; color: var(--muted); }
.toolbar { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 14px; }
.toolbar .search { flex: 1 1 240px; }
.toolbar select { width: auto; }

/* ── Tabelle / liste ── */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); font-weight: 700; padding: 10px 12px; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.table td { padding: 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr.click { cursor: pointer; }
.table tr.click:hover td { background: #F6F9FF; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow-sm); }
.table-wrap .table tr:last-child td { border-bottom: 0; }
@media (max-width: 760px) {
  .table.responsive thead { display: none; }
  .table.responsive, .table.responsive tbody, .table.responsive tr, .table.responsive td { display: block; width: 100%; }
  .table.responsive tr { padding: 12px 14px; border-bottom: 1px solid var(--border); }
  .table.responsive td { border: 0; padding: 2px 0; }
  .table.responsive td[data-l]::before { content: attr(data-l) ': '; color: var(--muted); font-size: 12.5px; }
  .table.responsive td.hide-m { display: none; }
}
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.list-item:last-child { border-bottom: 0; }
.list-item .grow { flex: 1; min-width: 0; }
.list-item .t { font-weight: 600; }
.list-item .s { font-size: 13px; color: var(--muted); }
.empty { text-align: center; color: var(--muted); padding: 28px 12px; font-size: 14px; }
.empty svg { width: 40px; height: 40px; color: var(--border-strong); display: block; margin: 0 auto 8px; }
.kv { display: grid; grid-template-columns: 130px 1fr; gap: 8px 12px; font-size: 14px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 500; overflow-wrap: anywhere; }
@media (max-width: 500px) { .kv { grid-template-columns: 105px 1fr; } }

/* ── Intervento card (dashboard / mia agenda) ── */
.job {
  display: flex; gap: 14px; padding: 14px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface); position: relative; overflow: hidden; color: inherit;
}
.job + .job { margin-top: 10px; }
a.job:hover { text-decoration: none; border-color: var(--blue-500); box-shadow: var(--shadow); }
.job::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; background: var(--blue-500); }
.job.s-in_corso::before { background: var(--grad-bolt); }
.job.s-completato::before { background: var(--ok); }
.job .time { font-family: var(--font-head); font-weight: 700; font-size: 15px; min-width: 52px; line-height: 1.25; }
.job .time small { display: block; color: var(--muted); font-weight: 600; font-size: 12.5px; }
.job .body { flex: 1; min-width: 0; }
.job .cli { font-weight: 700; font-size: 15px; }
.job .tit { color: var(--text-2); font-size: 14px; }
.job .meta { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 6px; font-size: 12.5px; color: var(--muted); }
.job .acts { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

/* ── Squadra (stato tecnici oggi) ── */
.team { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 10px; }
.member { display: flex; gap: 10px; align-items: center; padding: 11px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.member .grow { flex: 1; min-width: 0; }
.member .n { font-weight: 600; font-size: 14px; }
.member .s { font-size: 12.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dot { width: 9px; height: 9px; border-radius: 50%; display: inline-block; flex: none; }
.dot.libero { background: var(--ok); }
.dot.pianificato { background: var(--blue-500); }
.dot.in_intervento { background: var(--orange-500); box-shadow: 0 0 0 3px rgba(252, 121, 43, .2); }
.dot.assente { background: #A3ACC2; }
.load { height: 6px; border-radius: 99px; background: #E8EDF5; overflow: hidden; margin-top: 5px; }
.load > span { display: block; height: 100%; background: var(--grad-brand); border-radius: 99px; }
.load.full > span { background: var(--grad-bolt); }
.load.over > span { background: var(--danger); }

/* ── Modali ── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100; background: rgba(6, 12, 34, .55); backdrop-filter: blur(3px);
  display: none; align-items: flex-start; justify-content: center; padding: 5vh 16px; overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--surface); border-radius: 18px; width: 100%; max-width: 560px; box-shadow: var(--shadow-lg);
  animation: pop .16s ease-out;
}
.modal.wide { max-width: 760px; }
@keyframes pop { from { transform: translateY(10px) scale(.98); opacity: 0; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 18px 20px 4px; }
.modal-head h2 { margin-right: auto; }
.modal-body { padding: 14px 20px; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 6px 20px 20px; flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
@media (max-width: 600px) {
  .modal-overlay { padding: 0; align-items: flex-end; }
  .modal { border-radius: 18px 18px 0 0; max-height: 92vh; overflow-y: auto; padding-bottom: env(safe-area-inset-bottom); }
}

/* ── Avvisi ── */
.alert { padding: 11px 14px; border-radius: 10px; font-size: 14px; border: 1px solid; margin-bottom: 12px; }
.alert-warn { background: var(--warn-bg); border-color: #FBD9A5; color: #8A4B05; }
.alert-danger { background: var(--danger-bg); border-color: #F3C2C2; color: #9B1C1C; }
.alert-info { background: var(--info-bg); border-color: #C7DBFA; color: #123E85; }
.alert-ok { background: var(--ok-bg); border-color: #BDE8CD; color: #14532D; }
.alert ul { margin: 6px 0 0; padding-left: 18px; }

/* ── Toast ── */
#toasts { position: fixed; z-index: 200; left: 50%; transform: translateX(-50%); bottom: calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
@media (max-width: 900px) { #toasts { bottom: calc(84px + env(safe-area-inset-bottom)); } }
.toast {
  background: var(--navy-900); color: #fff; padding: 11px 18px; border-radius: 12px; font-size: 14px; font-weight: 500;
  box-shadow: var(--shadow-lg); animation: pop .18s ease-out; max-width: 90vw; border-left: 4px solid var(--cyan-400);
}
.toast.err { border-left-color: var(--danger); }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; overflow-x: auto; scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs button {
  border: 0; background: none; font: 600 14px var(--font-body); color: var(--muted); padding: 10px 14px;
  cursor: pointer; border-bottom: 3px solid transparent; margin-bottom: -1px; white-space: nowrap;
}
.tabs button.active { color: var(--text); border-bottom-color: var(--orange-500); }

/* ── Login ── */
.login-page {
  min-height: 100vh; display: grid; place-items: center; padding: 24px 16px;
  background: var(--navy-900);
  background-image: radial-gradient(70% 50% at 15% 10%, rgba(34, 211, 238, .16), transparent 60%),
                    radial-gradient(60% 50% at 90% 90%, rgba(252, 121, 43, .14), transparent 60%);
}
.login-card {
  width: 100%; max-width: 410px; background: rgba(17, 29, 69, .72); border: 1px solid rgba(132, 235, 254, .14);
  border-radius: 22px; padding: 30px 26px; box-shadow: var(--shadow-lg); color: #fff; backdrop-filter: blur(8px);
}
.login-card .logo { display: block; width: 100%; max-width: 300px; margin: 0 auto 22px; }
.login-card label.f { color: #AFBBDA; }
.login-card input { background: rgba(6, 12, 34, .55); border-color: rgba(132, 235, 254, .2); color: #fff; }
.login-card input:focus { border-color: var(--cyan-400); box-shadow: 0 0 0 3px rgba(34, 211, 238, .18); }
.login-err { color: #FFB4A8; font-size: 14px; min-height: 20px; margin: 4px 0 10px; }
.demo-box { margin-top: 20px; padding-top: 18px; border-top: 1px solid rgba(255, 255, 255, .1); }
.demo-box p { font-size: 13px; color: #9FB0D6; margin: 0 0 10px; text-align: center; }
.demo-box .btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.demo-box button {
  background: rgba(255, 255, 255, .06); border: 1px solid rgba(255, 255, 255, .14); color: #fff; border-radius: 12px;
  padding: 11px 8px; cursor: pointer; font: 600 14px var(--font-body); text-align: center;
}
.demo-box button small { display: block; font-weight: 500; color: #9FB0D6; font-size: 12px; }
.demo-box button:hover { border-color: var(--cyan-400); }

/* ── Planner ── */
.planner-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.planner-bar .periodo { font-family: var(--font-head); font-weight: 700; font-size: 17px; min-width: 190px; }
.planner-layout { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 16px; align-items: start; }
@media (max-width: 1250px) { .planner-layout { grid-template-columns: minmax(0, 1fr); } }
.board { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); overflow: auto; max-height: calc(100vh - 170px); }
@media (max-width: 900px) { .board { max-height: none; } }
.wk { display: grid; min-width: 760px; }
.wk .hcell {
  position: sticky; top: 0; z-index: 3; background: var(--surface-2); border-bottom: 1px solid var(--border);
  padding: 9px 10px; font-size: 12.5px; font-weight: 700; color: var(--text-2); text-transform: capitalize;
}
.wk .hcell.today { color: var(--blue-600); background: #EAF3FE; }
.wk .hcell .d { font-family: var(--font-head); font-size: 17px; color: var(--text); margin-left: 3px; }
.wk .hcell.today .d { color: var(--blue-600); }
.wk .rcell {
  position: sticky; left: 0; z-index: 2; background: var(--surface); border-right: 1px solid var(--border); border-bottom: 1px solid var(--border);
  padding: 10px; display: flex; gap: 9px; align-items: flex-start;
}
.wk .rcell.corner { z-index: 4; top: 0; background: var(--surface-2); align-items: center; font-size: 12px; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .05em; }
.wk .rcell .n { font-weight: 700; font-size: 13.5px; line-height: 1.2; }
.wk .rcell .q { font-size: 11.5px; color: var(--muted); }
.wk .rcell .grow { flex: 1; min-width: 0; }
.wk .cell {
  border-bottom: 1px solid var(--border); border-left: 1px solid var(--border); padding: 6px; min-height: 96px;
  position: relative; transition: background .12s; cursor: copy; display: flex; flex-direction: column; gap: 5px;
}
.wk .cell.weekend { background: repeating-linear-gradient(135deg, #FAFBFE, #FAFBFE 6px, #F4F6FB 6px, #F4F6FB 12px); }
.wk .cell.today { background: #F6FAFF; }
.wk .cell:hover { background: #F2F7FF; }
.wk .cell.drop { background: #E3F4FE; box-shadow: inset 0 0 0 2px var(--cyan-500); }
.wk .cell.drop.bad { background: #FFF1E6; box-shadow: inset 0 0 0 2px var(--orange-500); }
.cap { margin-top: auto; display: flex; align-items: center; gap: 6px; font-size: 10.5px; color: var(--muted); font-weight: 600; }

.ev {
  border-radius: 8px; padding: 5px 7px 5px 9px; font-size: 12px; line-height: 1.3; background: #EEF5FF; color: var(--text);
  border: 1px solid #D3E4FB; position: relative; cursor: grab; user-select: none; -webkit-user-select: none;
}
.ev::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; border-radius: 8px 0 0 8px; background: var(--c, var(--blue-500)); }
.ev:hover { border-color: var(--blue-500); box-shadow: var(--shadow-sm); }
.ev .h { font-weight: 700; display: flex; gap: 4px; align-items: center; }
.ev .c { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ev .t { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 11.5px; }
.ev.s-in_corso { background: #FFF5EA; border-color: #FFD9B0; }
.ev.s-completato { background: #EEF9F2; border-color: #C9EBD6; cursor: pointer; opacity: .85; }
.ev.dragging { opacity: .4; }
.ev .multi { margin-left: auto; font-size: 10.5px; color: var(--muted); font-weight: 700; }
.ev .warn { color: var(--danger); font-weight: 800; }
.abs {
  border-radius: 8px; padding: 5px 8px; font-size: 11.5px; font-weight: 700; color: #5A647E;
  background: repeating-linear-gradient(135deg, #EEF0F5, #EEF0F5 5px, #E3E7EF 5px, #E3E7EF 10px); border: 1px solid #D9DEE8;
  cursor: pointer; text-transform: capitalize;
}
.abs.richiesta { background: repeating-linear-gradient(135deg, #FFF6EA, #FFF6EA 5px, #FFEBD2 5px, #FFEBD2 10px); border: 1px dashed var(--orange-400); color: #A0521A; }
.abs small { font-weight: 500; text-transform: none; }

/* Giorno: timeline orizzontale per tecnico */
.tl { min-width: 900px; }
.tl-row { display: grid; grid-template-columns: 200px 1fr; border-bottom: 1px solid var(--border); }
.tl-row .rcell { border-right: 1px solid var(--border); padding: 10px; display: flex; gap: 9px; align-items: center; background: var(--surface); position: sticky; left: 0; z-index: 2; }
.tl-row .rcell .n { font-weight: 700; font-size: 13.5px; }
.tl-row .rcell .q { font-size: 11.5px; color: var(--muted); }
.tl-head { position: sticky; top: 0; z-index: 3; background: var(--surface-2); }
.tl-track { position: relative; height: 66px; cursor: copy; }
.tl-head .tl-track { height: 34px; cursor: default; }
.tl-hour { position: absolute; top: 0; bottom: 0; border-left: 1px solid #EDF1F7; }
.tl-head .tl-hour { font-size: 11.5px; font-weight: 700; color: var(--muted); padding: 8px 0 0 5px; border-left-color: var(--border); }
.tl-block { position: absolute; top: 7px; bottom: 7px; overflow: hidden; }
.tl-block.ev { cursor: pointer; }
.tl-block.abs { top: 4px; bottom: 4px; }
.tl-now { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--orange-500); z-index: 1; }
.tl-now::before { content: ''; position: absolute; top: -3px; left: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--orange-500); }
.tl-track.drop { background: #E3F4FE; }

/* Mese: heatmap carico */
.hm { min-width: 900px; display: grid; }
.hm .hcell { font-size: 11px; padding: 6px 2px; text-align: center; position: sticky; top: 0; background: var(--surface-2); border-bottom: 1px solid var(--border); font-weight: 700; color: var(--muted); }
.hm .hcell.we { color: #B3BACB; }
.hm .hcell.today { color: var(--blue-600); }
.hm .rcell { position: sticky; left: 0; background: var(--surface); padding: 8px 10px; display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 600; border-bottom: 1px solid var(--border); border-right: 1px solid var(--border); z-index: 2; }
.hm .c { border-bottom: 1px solid var(--border); padding: 3px; }
.hm .c button {
  width: 100%; height: 34px; border: 0; border-radius: 6px; cursor: pointer; font: 700 10.5px var(--font-body); color: var(--text-2);
  background: #F3F5FA;
}
.hm .c button:hover { outline: 2px solid var(--blue-500); }
.hm .c.we button { background: #FAFBFD; color: #C0C6D4; }
.hm .c button.on { background: #D9F4FC; color: var(--navy-900); }
.hm .c button.over { background: var(--orange-500); color: #fff; }
.hm .c button.ass { background: repeating-linear-gradient(135deg, #E9ECF2, #E9ECF2 4px, #DCE0E9 4px, #DCE0E9 8px); color: #6A7694; }
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted); margin-top: 10px; align-items: center; }
.legend i { display: inline-block; width: 14px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }

/* Backlog */
.backlog { position: sticky; top: 16px; }
.backlog .card { padding: 14px; }
.backlog-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 260px); overflow: auto; }
.bl {
  border: 1px solid var(--border); border-radius: 10px; padding: 9px 10px; background: var(--surface); cursor: grab; font-size: 13px;
  border-left: 4px solid var(--blue-500);
}
.bl:hover { border-color: var(--blue-500); }
.bl .c { font-weight: 700; }
.bl .t { color: var(--text-2); }
.bl .m { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: 5px; font-size: 11.5px; color: var(--muted); }

/* Disponibilità tecnici nel modale */
.disp { display: flex; flex-direction: column; gap: 6px; max-height: 300px; overflow: auto; }
.disp label {
  display: flex; gap: 10px; align-items: center; border: 1px solid var(--border); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.disp label:hover { border-color: var(--blue-500); }
.disp label.sel { border-color: var(--blue-500); background: #F2F8FF; }
.disp input { width: 18px; height: 18px; accent-color: var(--blue-600); flex: none; }
.disp .grow { flex: 1; min-width: 0; }
.disp .n { font-weight: 600; font-size: 14px; }
.disp .m { font-size: 12px; color: var(--muted); }
.disp .stato { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 99px; white-space: nowrap; }
.disp .stato.libero { background: var(--ok-bg); color: var(--ok); }
.disp .stato.occupato { background: var(--warn-bg); color: #B45309; }
.disp .stato.assente { background: #EEF0F5; color: var(--muted); }

/* Mia agenda: striscia giorni */
.days { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -2px 6px; scrollbar-width: none; }
.days::-webkit-scrollbar { display: none; }
.days button {
  flex: none; width: 58px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 8px 0 7px;
  cursor: pointer; font-family: var(--font-body); color: var(--text-2); position: relative;
}
.days button .w { font-size: 11.5px; font-weight: 600; text-transform: uppercase; color: var(--muted); }
.days button .d { font-family: var(--font-head); font-size: 20px; font-weight: 800; color: var(--text); }
.days button .dots { display: flex; gap: 3px; justify-content: center; height: 6px; margin-top: 2px; }
.days button .dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--blue-500); }
.days button .dots i.a { background: #A3ACC2; }
.days button.today .w { color: var(--orange-500); }
.days button.active { background: var(--navy-900); border-color: var(--navy-900); }
.days button.active .w, .days button.active .d { color: #fff; }
.days button.active .dots i { background: var(--cyan-400); }

/* Rapportino */
.step { display: flex; gap: 12px; align-items: center; margin-bottom: 12px; }
.step .num { width: 28px; height: 28px; border-radius: 50%; display: grid; place-items: center; background: var(--navy-900); color: #fff; font: 800 13px var(--font-head); flex: none; }
.step .num.ok { background: var(--ok); }
.stepper { display: flex; align-items: center; gap: 0; border: 1px solid var(--border-strong); border-radius: 10px; overflow: hidden; background: var(--surface); }
.stepper button { width: 44px; height: 44px; border: 0; background: var(--surface-2); font-size: 20px; font-weight: 700; cursor: pointer; color: var(--text-2); }
.stepper button:active { background: #E6ECF6; }
.stepper input { border: 0 !important; border-radius: 0 !important; text-align: center; font-weight: 700; font-size: 17px; box-shadow: none !important; min-width: 0; }
.photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 10px; }
.photo { position: relative; border-radius: 10px; overflow: hidden; background: var(--surface-2); aspect-ratio: 1; border: 1px solid var(--border); }
.photo img { width: 100%; height: 100%; object-fit: cover; display: block; cursor: zoom-in; }
.photo .x { position: absolute; top: 5px; right: 5px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: rgba(6, 12, 34, .7); color: #fff; cursor: pointer; font-size: 15px; line-height: 1; }
.photo .inpdf { position: absolute; left: 5px; bottom: 5px; font-size: 10.5px; font-weight: 700; background: rgba(6, 12, 34, .7); color: #fff; border-radius: 6px; padding: 2px 6px; cursor: pointer; border: 0; }
.photo .inpdf.off { background: rgba(255, 255, 255, .85); color: var(--muted); text-decoration: line-through; }
.photo-add {
  display: grid; place-items: center; aspect-ratio: 1; border: 2px dashed var(--border-strong); border-radius: 10px; cursor: pointer;
  color: var(--blue-600); font-weight: 600; font-size: 13px; text-align: center; background: var(--surface-2);
}
.photo-add:hover { border-color: var(--blue-500); background: #F2F8FF; }
.photo-add svg { width: 28px; height: 28px; display: block; margin: 0 auto 4px; }
.sign-wrap { border: 2px dashed var(--border-strong); border-radius: 12px; background: #fff; position: relative; touch-action: none; }
.sign-wrap canvas { display: block; width: 100%; height: 200px; touch-action: none; cursor: crosshair; }
.sign-wrap .ph { position: absolute; inset: 0; display: grid; place-items: center; color: #B8C1D4; font-size: 14px; pointer-events: none; }
.sign-wrap .line { position: absolute; left: 24px; right: 24px; bottom: 42px; border-bottom: 1px solid #D5DCE8; pointer-events: none; }
.firma-img { max-width: 280px; width: 100%; background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 6px; }
.mat-row { display: grid; grid-template-columns: 110px 1fr 80px 70px auto; gap: 8px; align-items: end; }
@media (max-width: 640px) { .mat-row { grid-template-columns: 1fr 1fr; } .mat-row .desc { grid-column: 1 / -1; order: -1; } }
.lightbox { position: fixed; inset: 0; z-index: 300; background: rgba(6, 12, 34, .92); display: none; place-items: center; padding: 16px; }
.lightbox.open { display: grid; }
.lightbox img { max-width: 100%; max-height: 90vh; border-radius: 8px; }

.timeline { list-style: none; margin: 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 14px; }
.timeline li::before { content: ''; position: absolute; left: 4px; top: 6px; width: 9px; height: 9px; border-radius: 50%; background: var(--blue-500); }
.timeline li::after { content: ''; position: absolute; left: 8px; top: 18px; bottom: 0; width: 1px; background: var(--border); }
.timeline li:last-child::after { display: none; }
.timeline li.sys::before { background: var(--border-strong); }
.timeline .who { font-size: 12.5px; color: var(--muted); }
.progress-ring { font-family: var(--font-head); }

/* ───────────── Smartphone (v2) ───────────── */
.mt-list { display: flex; flex-direction: column; gap: 10px; }
.mt { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow-sm); padding: 12px; }
.mt-head { display: flex; gap: 10px; align-items: center; }
.mt-head .grow { flex: 1; min-width: 0; }
.mt-head .n { font-weight: 700; font-size: 14.5px; }
.mt-head .q { font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.mt-head .q.over { color: var(--danger); font-weight: 700; }
.mt .abs { margin-top: 8px; }
.mt-ev {
  display: flex; gap: 10px; align-items: center; width: 100%; margin-top: 8px; text-align: left; font: inherit; color: inherit;
  background: #EEF5FF; border: 1px solid #D3E4FB; border-left: 4px solid var(--blue-500); border-radius: 10px; padding: 8px 10px; cursor: pointer;
}
.mt-ev.s-in_corso { background: #FFF5EA; border-color: #FFD9B0; border-left-color: var(--orange-500); }
.mt-ev.s-completato { background: #EEF9F2; border-color: #C9EBD6; border-left-color: var(--ok); }
.mt-ev.bad { box-shadow: inset 0 0 0 1px var(--danger); }
.mt-ev .o { font-family: var(--font-head); font-weight: 800; font-size: 14px; line-height: 1.15; min-width: 44px; }
.mt-ev .o small { display: block; font-weight: 600; font-size: 11.5px; color: var(--muted); }
.mt-ev .grow { flex: 1; min-width: 0; }
.mt-ev .c { display: block; font-weight: 700; font-size: 13.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-ev .t { display: block; font-size: 12.5px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mt-ev .warn { color: var(--danger); font-weight: 800; }
.mt-free { margin-top: 6px; font-size: 12.5px; color: var(--muted); padding-left: 44px; }
.board.board-m { background: none; border: 0; box-shadow: none; overflow: visible; max-height: none; }

@media (max-width: 760px) {
  /* KPI compatti a due colonne */
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
  .kpis.kpis-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .kpi { padding: 11px 12px 11px 15px; }
  .kpi .label { font-size: 10.5px; letter-spacing: .03em; }
  .kpi .value { font-size: 23px; }
  .kpi .hint { font-size: 11.5px; }
  .card { padding: 14px; }
  .card + .card { margin-top: 12px; }
  .grid { gap: 12px; }
  .hide-m { display: none !important; }

  /* squadra: righe compatte */
  .team { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .team .member { border: 0; border-bottom: 1px solid var(--border); border-radius: 0; padding: 9px 2px; }
  .team .member:last-child { border-bottom: 0; }

  /* elenco commesse: card a tre righe */
  .table.tbl-comm tr { display: grid; grid-template-columns: auto auto minmax(0, 1fr); column-gap: 14px; row-gap: 3px; align-items: center; }
  .tbl-comm td:nth-child(1) { grid-column: 1 / 3; grid-row: 1; }
  .tbl-comm td:nth-child(4) { grid-column: 3; grid-row: 1; text-align: right; }
  .tbl-comm td:nth-child(2) { grid-column: 1 / -1; grid-row: 2; }
  .tbl-comm td:nth-child(3) { grid-row: 3; font-size: 12.5px; color: var(--muted); }
  .tbl-comm td:nth-child(5) { grid-row: 3; font-size: 12.5px; }
  .tbl-comm td:nth-child(6) { grid-row: 3; font-size: 12.5px; text-align: right; }
  .tbl-comm td:nth-child(3)::before, .tbl-comm td:nth-child(5)::before { display: none; }
  .tbl-comm td .load { width: 46px !important; }
  .table.responsive tr > td:only-child { grid-column: 1 / -1; }

  /* elenco clienti: nome, città e telefono */
  .table.tbl-cli tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 10px; }
  .tbl-cli td:nth-child(1) { grid-column: 1; grid-row: 1; }
  .tbl-cli td:nth-child(4) { grid-column: 2; grid-row: 1; align-self: start; }
  .tbl-cli td:nth-child(2), .tbl-cli td:nth-child(3) { grid-column: 1 / -1; display: inline; font-size: 13px; color: var(--text-2); }
  .tbl-cli td[data-l]::before { display: none; }
  .tbl-cli td:nth-child(3) .muted { display: none; }
  .tbl-cli td:nth-child(4) .n { display: none; }

  /* barra pianificazione */
  .planner-bar { gap: 8px; }
  .planner-bar h1, #viste [data-v="giorno"] { display: none; }
  #viste { width: 100%; }
  #viste button { flex: 1; }
  .planner-bar #vaiData { display: none; }
  .planner-bar .periodo { min-width: 0; font-size: 15.5px; }
  .fab-m {
    position: fixed; right: 16px; bottom: calc(80px + env(safe-area-inset-bottom)); z-index: 25;
    border-radius: 99px; padding: 13px 18px; box-shadow: 0 10px 24px rgba(22, 104, 214, .35);
  }

  /* azioni scheda commessa */
  .azioni-m { width: 100%; }
  .azioni-m .btn { flex: 1; justify-content: center; }
  .azioni-m .btn-accent { flex-basis: 100%; order: -1; }
}

/* ───────────── Carico ore (v3): ore occupate / disponibili, arancio = straordinario ───────────── */
.ore { display: inline-block; font-size: 12px; font-weight: 700; color: var(--text-2); white-space: nowrap; padding: 1px 7px; border-radius: 99px; background: var(--surface-2); }
.ore.extra { background: var(--orange-500); color: #fff; }
.cap { margin-top: auto; display: flex; justify-content: flex-end; }
.member .ore { margin-left: auto; }

/* Settimana e mese di un singolo operaio */
.tw-sum { display: flex; gap: 12px; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); background: var(--surface); }
.tw-sum .grow { flex: 1; min-width: 0; }
.tw-sum .n { font-weight: 700; font-size: 15px; }
.tw-sum .q { font-size: 12.5px; color: var(--muted); }
.tw-sum .ore { font-size: 14px; padding: 3px 10px; margin-top: 2px; }
.tw { display: grid; min-width: 680px; }
.tw-col { border-right: 1px solid var(--border); display: flex; flex-direction: column; min-height: 380px; }
.tw-col:last-child { border-right: 0; }
.tw-col.weekend { background: #FAFBFD; }
.tw-head { display: flex; justify-content: space-between; align-items: center; gap: 6px; padding: 9px 10px; background: var(--surface-2); border-bottom: 1px solid var(--border); font-size: 12.5px; color: var(--text-2); text-transform: capitalize; position: sticky; top: 0; z-index: 2; }
.tw-head b { font-family: var(--font-head); font-size: 16px; color: var(--text); }
.tw-col.today .tw-head b { color: var(--blue-600); }
.tw-body { flex: 1; padding: 8px; display: flex; flex-direction: column; gap: 6px; border: 0 !important; min-height: 0; }
.cal { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; padding: 12px; background: var(--surface); }
.cal-h { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; text-align: center; }
.cal-d {
  min-height: 92px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); padding: 6px 7px; text-align: left;
  display: flex; flex-direction: column; gap: 3px; font: inherit; color: inherit; cursor: pointer; overflow: hidden;
}
.cal-d:hover { border-color: var(--blue-500); }
.cal-d.fuori { border: 0; background: none; cursor: default; }
.cal-d.we { background: #FAFBFD; }
.cal-d.today { border-color: var(--blue-500); box-shadow: inset 0 0 0 1px var(--blue-500); }
.cal-d .num { font-family: var(--font-head); font-weight: 800; font-size: 14px; }
.cal-d .h { font-weight: 700; font-size: 13px; color: var(--navy-900); background: #D9F4FC; border-radius: 6px; padding: 1px 6px; align-self: flex-start; white-space: nowrap; }
.cal-d .h small { font-weight: 600; color: var(--text-2); }
.cal-d.extra .h { background: var(--orange-500); color: #fff; }
.cal-d.extra .h small { color: #fff; }
.cal-d.ass .h { background: repeating-linear-gradient(135deg, #E9ECF2, #E9ECF2 4px, #DCE0E9 4px, #DCE0E9 8px); color: #6A7694; text-transform: capitalize; }
.cal-d .cli { font-size: 11px; color: var(--muted); line-height: 1.3; }
.days button .oreg { font-size: 11px; font-weight: 700; color: var(--text-2); }
.days button .oreg.extra { color: var(--orange-600); }
.days button.active .oreg { color: var(--cyan-400); }
.board-m .tw-sum { border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 10px; }

@media (max-width: 760px) {
  .planner-bar #selTec { flex: 1 1 100%; }
  .cal { gap: 3px; padding: 8px 6px; }
  .cal-d { min-height: 54px; padding: 4px; border-radius: 8px; }
  .cal-d .num { font-size: 12px; }
  .cal-d .h { font-size: 11px; padding: 0 4px; }
  .cal-d .h small, .cal-d .cli { display: none; }
  .tw-sum { padding: 12px; }
}
