:root {
  --bg: #EEF1F4; --card: #FFFFFF; --ink: #0D1117; --navy: #1F3456; --teal: #0B8FB0; --teal-l: #5FC3D6;
  --teal-bg: #E3F3F7; --red: #B8242F; --red-bg: #F8E6E7; --amber: #9A6A00; --amber-bg: #FBF1D9;
  --green: #1E7A4C; --green-bg: #E2F3EA; --grey: #5B6770; --line: #DCE2E8; --soft: #F6F8FA;
  --radius: 14px; --shadow: 0 1px 2px rgba(13,17,23,.04), 0 4px 16px rgba(13,17,23,.06);
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 "Poppins", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--teal); }
.hidden { display: none !important; }

/* layout */
.app { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.side { background: var(--navy); color: #fff; padding: 22px 14px; position: sticky; top: 0; height: 100vh; }
.brand { display: flex; align-items: center; gap: 10px; margin: 0 6px 26px; }
.brand .dot { width: 34px; height: 34px; border-radius: 50%; background: var(--teal); display: grid; place-items: center;
  font-weight: 800; font-size: 13px; letter-spacing: .5px; }
.brand b { display: block; font-size: 14px; } .brand small { opacity: .7; font-size: 12px; }
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav button { all: unset; cursor: pointer; display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; font-size: 14px; color: rgba(255,255,255,.78); }
.nav button:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav button.active { background: #fff; color: var(--navy); font-weight: 600; }
.nav .ico { width: 20px; text-align: center; }
.nav .count { margin-left: auto; background: var(--red); color: #fff; border-radius: 99px; font-size: 11px;
  padding: 1px 7px; font-weight: 600; }
.main { padding: 26px 30px 90px; max-width: 1280px; width: 100%; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
h1 { font-size: 24px; margin: 0; color: var(--navy); font-weight: 700; letter-spacing: -.2px; }
h1 em { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; color: var(--teal); font-size: 1.15em; }
h2 { font-size: 15px; margin: 0 0 12px; color: var(--navy); font-weight: 600; display: flex; align-items: center; gap: 8px; }
h2 .pill { font-weight: 500; }
.sub { color: var(--grey); font-size: 13px; }

/* cards */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.tiles { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 12px; margin-bottom: 16px; }
.tile { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
.tile .lbl { font-size: 12px; color: var(--grey); }
.tile .num { font-size: 26px; font-weight: 700; color: var(--navy); line-height: 1.2; margin-top: 2px; }
.tile .delta { font-size: 12px; color: var(--grey); }
.tile .delta.up { color: var(--green); } .tile .delta.down { color: var(--red); }

.banner { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 11px; border-radius: 99px; font-size: 12.5px;
  background: var(--card); box-shadow: var(--shadow); }
.chip .led { width: 8px; height: 8px; border-radius: 50%; background: var(--grey); }
.chip.on .led { background: var(--green); } .chip.off .led { background: var(--red); }

.list { display: flex; flex-direction: column; }
.row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-top: 1px solid var(--line); min-width: 0; }
.row:first-child { border-top: 0; padding-top: 2px; }
.row .who { flex: 1; min-width: 0; }
.row .who b { display: block; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .who small { color: var(--grey); font-size: 12.5px; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row.click { cursor: pointer; } .row.click:hover { background: var(--soft); margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-radius: 8px; }
.row.stack { flex-wrap: wrap; }
.row.stack .actions { width: 100%; justify-content: flex-start; padding-left: 70px; margin-top: -2px; }
.empty { color: var(--grey); font-size: 13.5px; padding: 6px 0; }
.time { font-weight: 700; color: var(--teal); min-width: 48px; font-variant-numeric: tabular-nums; }
.actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.pill { display: inline-block; font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--soft);
  color: var(--grey); font-weight: 500; white-space: nowrap; }
.pill.teal { background: var(--teal-bg); color: var(--teal); } .pill.red { background: var(--red-bg); color: var(--red); }
.pill.amber { background: var(--amber-bg); color: var(--amber); } .pill.green { background: var(--green-bg); color: var(--green); }
.days { min-width: 58px; text-align: center; font-weight: 700; font-size: 13px; border-radius: 10px; padding: 6px 4px; }
.days small { display: block; font-weight: 500; font-size: 10.5px; }

.btn { border: 0; cursor: pointer; border-radius: 10px; padding: 8px 14px; font-weight: 600; font-size: 13.5px;
  background: var(--teal); color: #fff; white-space: nowrap; text-decoration: none; display: inline-flex; align-items: center; gap: 6px; }
.btn:hover { filter: brightness(1.06); }
.btn.ghost { background: var(--soft); color: var(--navy); }
.btn.line { background: transparent; color: var(--navy); box-shadow: inset 0 0 0 1px var(--line); }
.btn.wa { background: #1FA855; } .btn.danger { background: var(--red); }
.btn.sm { padding: 6px 10px; font-size: 12.5px; border-radius: 8px; }
.btn:disabled { opacity: .5; cursor: default; }

/* forms */
.field { display: flex; flex-direction: column; gap: 4px; margin-bottom: 12px; }
.field label { font-size: 12.5px; color: var(--grey); font-weight: 500; }
.field input, .field select, .field textarea, .search { border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
  background: #fff; outline: none; width: 100%; }
.field input:focus, .field select:focus, .field textarea:focus, .search:focus { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-bg); }
.field textarea { min-height: 70px; resize: vertical; }
.frow { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-bottom: 12px; }
.check input { width: 18px; height: 18px; accent-color: var(--teal); }
.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search { max-width: 260px; }
.seg { display: inline-flex; background: var(--card); border-radius: 10px; box-shadow: var(--shadow); padding: 3px; }
.seg button { all: unset; cursor: pointer; padding: 6px 12px; border-radius: 8px; font-size: 13px; color: var(--grey); }
.seg button.active { background: var(--navy); color: #fff; }

/* pipeline */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(230px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: rgba(255,255,255,.55); border-radius: var(--radius); padding: 10px; min-height: 140px; }
.col h3 { font-size: 13px; margin: 2px 4px 10px; color: var(--navy); display: flex; justify-content: space-between; }
.lead { background: #fff; border-radius: 11px; padding: 11px 12px; margin-bottom: 8px; box-shadow: var(--shadow); cursor: pointer; }
.lead b { font-weight: 600; font-size: 14px; } .lead .meta { display: flex; gap: 5px; flex-wrap: wrap; margin-top: 6px; }
.lead .todo { font-size: 12px; color: var(--red); margin-top: 6px; font-weight: 500; }

/* calendar */
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 10px; }
.day { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 10px; min-height: 180px; }
.day.today { box-shadow: inset 0 0 0 2px var(--teal), var(--shadow); }
.day h4 { margin: 0 0 8px; font-size: 12.5px; color: var(--grey); font-weight: 500; display: flex; justify-content: space-between; }
.day h4 b { color: var(--navy); font-size: 16px; }
.ev { border-left: 3px solid var(--teal); background: var(--teal-bg); border-radius: 8px; padding: 7px 8px; margin-bottom: 6px;
  cursor: pointer; font-size: 12.5px; }
.ev.mensile { border-color: var(--navy); background: #E6EBF2; }
.ev.fatta { opacity: .55; } .ev.annullata, .ev.no_show { opacity: .45; text-decoration: line-through; }
.ev b { display: block; font-size: 12.5px; }
.add-day { all: unset; cursor: pointer; color: var(--teal); font-size: 18px; line-height: 1; }

/* chart */
.chart { width: 100%; height: auto; display: block; overflow: visible; }
.chart text { font-size: 11px; fill: var(--grey); }
.chart .bar { fill: var(--teal); } .chart .bar:hover, .chart .hit:hover + .bar { fill: var(--navy); }
.chart .grid line { stroke: var(--line); }
.funnel .fr { display: grid; grid-template-columns: 150px 1fr 40px; gap: 10px; align-items: center; margin-bottom: 8px; font-size: 13px; }
.funnel .track { background: var(--soft); border-radius: 4px; height: 14px; }
.funnel .fill { background: var(--teal); height: 14px; border-radius: 4px; min-width: 2px; }
.funnel .n { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; }
.tip { position: fixed; pointer-events: none; background: var(--ink); color: #fff; font-size: 12px; padding: 6px 9px;
  border-radius: 8px; z-index: 60; white-space: nowrap; }

/* chat */
.msgs { display: flex; flex-direction: column; gap: 6px; max-height: 260px; overflow: auto; padding: 4px; background: var(--soft); border-radius: 10px; }
.msg { max-width: 82%; padding: 6px 10px; border-radius: 10px; font-size: 13px; background: #fff; align-self: flex-start; }
.msg.out { align-self: flex-end; background: #DCF3E5; }
.msg small { display: block; color: var(--grey); font-size: 10.5px; }

/* modal */
.overlay { position: fixed; inset: 0; background: rgba(13,17,23,.45); display: flex; align-items: flex-start; justify-content: center;
  z-index: 50; padding: 40px 14px; overflow-y: auto; }
.modal { background: #fff; border-radius: 18px; width: 100%; max-width: 560px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal .mh { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.modal .mh h3 { margin: 0; color: var(--navy); font-size: 18px; }
.x { all: unset; cursor: pointer; font-size: 22px; color: var(--grey); padding: 0 6px; }
.mfoot { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 8px; }
.sep { height: 1px; background: var(--line); margin: 16px 0; }
.toast { position: fixed; bottom: 86px; left: 50%; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 10px 16px;
  border-radius: 10px; font-size: 14px; z-index: 70; box-shadow: var(--shadow); max-width: 90vw; }
.code { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--soft); padding: 8px 10px; border-radius: 8px;
  word-break: break-all; }

/* login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login .card { width: 100%; max-width: 360px; padding: 28px; }

/* tablet */
@media (max-width: 1100px) {
  .tiles { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .week { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
/* telefono */
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; bottom: 0; top: auto; left: 0; right: 0; height: auto; padding: 6px 4px calc(6px + env(safe-area-inset-bottom));
    z-index: 40; }
  .brand { display: none; }
  .nav { flex-direction: row; justify-content: space-around; }
  .nav button { flex-direction: column; gap: 2px; font-size: 10.5px; padding: 6px 4px; flex: 1; justify-content: center; position: relative; }
  .nav .ico { font-size: 18px; }
  .nav .count { position: absolute; top: 0; right: 14%; margin: 0; font-size: 10px; padding: 0 5px; }
  .nav .lbl-long { display: none; }
  .main { padding: 16px 14px 100px; }
  h1 { font-size: 21px; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .tiles { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .week { grid-template-columns: 1fr; } .day { min-height: 0; }
  .row { flex-wrap: wrap; } .row .actions { width: 100%; justify-content: flex-start; padding-left: 70px; }
  .funnel .fr { grid-template-columns: 110px 1fr 32px; }
  .frow { grid-template-columns: 1fr; gap: 0; }
  .search { max-width: none; flex: 1; }
}
