/* ==========================================================================
   ATRIO — App inquilino (prototipo mobile)
   ========================================================================== */

body {
  background:
    radial-gradient(900px 500px at 15% -10%, #1D5B59 0%, transparent 60%),
    linear-gradient(165deg, #0E2322, #143432 55%, #0B1C1B);
  min-height: 100vh;
  display: flex; align-items: center; justify-content: center;
  padding: 28px;
  overflow: hidden;
}

/* --- Cornice telefono (solo desktop) ---------------------------------- */
.stage { display: flex; align-items: center; gap: 56px; }

.aside { max-width: 290px; color: #A6BCBA; animation: atr-fade-up .8s var(--e-out) both; }
.aside .back { display: inline-flex; align-items: center; gap: 8px; font-size: 14.5px; font-weight: 600; color: #8FB5B3; margin-bottom: 28px; transition: color .2s, gap .25s var(--e-out); }
.aside .back:hover { color: #E8A77E; gap: 12px; }
.aside .back svg { width: 15px; height: 15px; }
.aside h1 { font-family: var(--font-display); font-weight: 600; font-size: 31px; color: #F4F1EB; margin: 0 0 12px; letter-spacing: .015em; line-height: 1.15; }
.aside p { font-size: 15px; line-height: 1.65; margin: 0 0 22px; }
.aside ul { list-style: none; padding: 0; margin: 0; font-size: 14.5px; line-height: 1.5; }
.aside li { display: flex; gap: 10px; padding: 7px 0; border-top: 1px solid rgba(255,255,255,.08); }
.aside li span:first-child { color: #E8A77E; font-weight: 700; flex: none; width: 18px; }

.device {
  position: relative; flex: none;
  width: 393px; height: 852px;
  background: #0A100F;
  border-radius: 56px;
  padding: 11px;
  box-shadow:
    0 0 0 2px rgba(255,255,255,.1),
    0 2px 0 3px rgba(0,0,0,.5),
    0 60px 120px rgba(0,0,0,.55);
  animation: atr-fade-up .9s .1s var(--e-out) both;
}
.device::after {           /* dynamic island */
  content: ''; position: absolute; top: 24px; left: 50%; transform: translateX(-50%);
  width: 118px; height: 33px; border-radius: 99px; background: #0A100F; z-index: 60;
}
.screen-wrap {
  position: relative; width: 100%; height: 100%;
  border-radius: 46px; overflow: hidden; background: var(--paper);
  display: flex; flex-direction: column;
}

@media (max-width: 1150px) { .aside { display: none; } }
@media (max-width: 560px), (max-height: 900px) and (max-width: 860px) {
  body { padding: 0; display: block; overflow: auto; }
  .stage { display: block; }
  .aside { display: none; }
  .device { width: 100%; height: 100dvh; border-radius: 0; padding: 0; box-shadow: none; animation: none; }
  .device::after { display: none; }
  .screen-wrap { border-radius: 0; }
  .statusbar { padding-top: max(10px, env(safe-area-inset-top)); }
}

/* --- Status bar finta --------------------------------------------------- */
.statusbar {
  flex: none; height: 54px; display: flex; align-items: flex-end; justify-content: space-between;
  padding: 0 30px 7px; font-size: 15px; font-weight: 600; letter-spacing: .01em;
  color: var(--ink); z-index: 50; position: relative;
  background: var(--paper); transition: color .35s, background .35s;
}
.statusbar.on-dark { color: #fff; background: #153735; }
.statusbar .sb-right { display: flex; align-items: center; gap: 6px; }
.statusbar .sb-right svg { width: 17px; height: 12px; }

/* --- Contenitore schermate --------------------------------------------- */
.viewport { position: relative; flex: 1; overflow: hidden; }

.screen {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  background: var(--paper);
  padding-bottom: 112px;
}
.screen::-webkit-scrollbar { width: 0; }
.screen.is-sub { background: var(--paper); box-shadow: -14px 0 40px rgba(14,35,34,.14); z-index: 20; }
.screen.enter-right { animation: scr-in-right .38s var(--e-out) both; }
.screen.exit-right  { animation: scr-out-right .3s var(--e-in-out) both; }
.screen.enter-fade  { animation: scr-fade-in .3s var(--e-out) both; }

@keyframes scr-in-right  { from { transform: translateX(100%); } to { transform: none; } }
@keyframes scr-out-right { from { transform: none; } to { transform: translateX(100%); } }
@keyframes scr-fade-in   { from { opacity: 0; transform: scale(.985) translateY(6px); } to { opacity: 1; transform: none; } }

/* --- Header di sezione --------------------------------------------------- */
.hd { padding: 10px 22px 14px; }
.hd .eyebrow { font-size: 13.5px; font-weight: 600; letter-spacing: .1em; text-transform: uppercase; color: var(--ink-3); }
.hd h1 { font-family: var(--font-display); font-size: 31px; font-weight: 400; letter-spacing: .015em; margin: 4px 0 0; }
.hd .sub { font-size: 15px; color: var(--ink-2); margin-top: 5px; line-height: 1.45; }

.topbar { display: flex; align-items: center; justify-content: space-between; padding: 6px 11px 0; }
.iconbtn {
  width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center;
  color: var(--ink-2); background: transparent; transition: background .2s, color .2s, transform .2s var(--e-spring);
  position: relative;
}
.iconbtn:hover { background: rgba(20,28,25,.055); color: var(--ink); }
.iconbtn:active { transform: scale(.9); }
.iconbtn svg { width: 23px; height: 23px; }
.iconbtn .dot-badge {
  position: absolute; top: 9px; right: 9px; width: 9px; height: 9px; border-radius: 99px;
  background: var(--copper-500); box-shadow: 0 0 0 2.5px var(--paper);
}

.subhead {
  display: flex; align-items: center; gap: 4px; padding: 4px 10px 10px;
  position: sticky; top: 0; z-index: 30;
  background: color-mix(in srgb, var(--paper) 88%, transparent);
  backdrop-filter: blur(16px);
}
.subhead h2 { font-size: 17.5px; font-weight: 650; margin: 0; letter-spacing: -.01em; flex: 1; }
.subhead .iconbtn svg { width: 22px; }

/* --- Blocchi -------------------------------------------------------------- */
.sec { padding: 0 22px; }
.sec + .sec { margin-top: 26px; }
.sec-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  font-size: 14px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  color: var(--ink-3); margin: 0 0 11px;
}
.sec-title a { font-size: 14px; font-weight: 600; letter-spacing: 0; text-transform: none; color: var(--copper-600); }

.card2 {
  background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--sh-1);
  border: 1px solid var(--line-2); overflow: hidden;
}

/* righe elenco */
.row {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 16px 18px; min-height: 68px;
  background: var(--surface); transition: background .18s;
  position: relative;
}
.row + .row { box-shadow: inset 0 1px 0 var(--line-2); }
button.row:active, a.row:active { background: var(--pine-50); }
.row .ri {
  flex: none; width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center;
  background: var(--pine-50); color: var(--pine-700);
}
.row .ri svg { width: 23px; height: 23px; }
.row .ri.copper { background: var(--copper-100); color: var(--copper-700); }
.row .ri.ai { background: var(--ai-100); color: var(--ai-600); }
.row .ri.warn { background: var(--warn-bg); color: var(--warn); }
.row .ri.ok { background: var(--ok-bg); color: var(--ok); }
.row .rt { flex: 1; min-width: 0; }
.row .rt b { display: block; font-size: 16px; font-weight: 600; letter-spacing: -.005em; }
.row .rt small { display: block; font-size: 14.5px; color: var(--ink-3); margin-top: 3px; line-height: 1.35; }
.row .rr { flex: none; display: flex; align-items: center; gap: 10px; color: var(--ink-4); }
.row .rr svg { width: 19px; height: 19px; }
.row .rr .amount { font-size: 16px; font-weight: 650; color: var(--ink); font-variant-numeric: tabular-nums; }

/* --- Pulsanti ------------------------------------------------------------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
  min-height: 56px; padding: 0 24px; border-radius: var(--r-md);
  font-size: 16.5px; font-weight: 650; letter-spacing: -.005em;
  transition: transform .18s var(--e-spring), box-shadow .25s, background .2s, opacity .2s;
  width: 100%;
}
.btn svg { width: 20px; height: 20px; }
.btn:active { transform: scale(.975); }
.btn--primary { background: var(--pine-700); color: #fff; box-shadow: 0 4px 14px rgba(29,91,89,.26); }
.btn--primary:hover { background: var(--pine-600); }
.btn--copper { background: var(--copper-600); color: #fff; box-shadow: 0 4px 14px rgba(180,97,58,.3); }
.btn--ai { background: var(--ai-600); color: #fff; box-shadow: 0 4px 14px rgba(76,58,122,.32); }
.btn--ai:hover { background: var(--ai-500); }
.btn--copper:hover { background: var(--copper-500); }
.btn--light { background: var(--surface); color: var(--ink); border: 1px solid var(--line); box-shadow: var(--sh-1); }
.btn--ghost { background: rgba(20,28,25,.05); color: var(--ink); }
.btn--danger { background: var(--danger-bg); color: var(--danger); }
.btn[disabled] { opacity: .45; pointer-events: none; }
.btn--sm { min-height: 44px; font-size: 15.5px; padding: 0 18px; width: auto; border-radius: var(--r-sm); }

/* --- Interruttore --------------------------------------------------------- */
.sw {
  flex: none; width: 60px; height: 34px; border-radius: 99px; background: #DAD4CA;
  position: relative; transition: background .3s var(--e-out);
}
.sw::before {
  content: ''; position: absolute; left: 13px; top: 50%; width: 11px; height: 6px;
  border-left: 2.5px solid #fff; border-bottom: 2.5px solid #fff;
  transform: translateY(-70%) rotate(-45deg); opacity: 0; transition: opacity .25s .05s;
}
.sw.on::before { opacity: 1; }
.sw::after {
  content: ''; position: absolute; top: 3px; left: 3px; width: 28px; height: 28px; border-radius: 99px;
  background: #fff; box-shadow: 0 2px 5px rgba(0,0,0,.2);
  transition: transform .32s var(--e-spring);
}
.sw.on { background: var(--ok); }
.sw.on::after { transform: translateX(26px); }

/* ==========================================================================
   CHIAVE
   ========================================================================== */
.key-screen { background: linear-gradient(180deg, #153735 0%, #1D5B59 42%, #276664 100%); }
.key-screen .hd h1, .key-screen .hd .eyebrow, .key-screen .hd .sub { color: #fff; }
.key-screen .hd .eyebrow { color: #93B5B3; }
.key-screen .hd .sub { color: #B2CBC9; }
.key-screen .iconbtn { color: #B2CBC9; }
.key-screen .iconbtn:hover { background: rgba(255,255,255,.1); color: #fff; }
.key-screen .iconbtn .dot-badge { box-shadow: 0 0 0 2.5px #1D5B59; }

.keypad { display: grid; place-items: center; padding: 10px 0 18px; }
.keybtn {
  position: relative; width: 218px; height: 218px; border-radius: 50%;
  display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 34% 28%, #46908D, #2A6F6C 62%, #1A4F4D);
  box-shadow: 0 18px 44px rgba(0,0,0,.36), inset 0 2px 0 rgba(255,255,255,.22), inset 0 -10px 24px rgba(0,0,0,.26);
  transition: transform .3s var(--e-spring), box-shadow .3s;
}
.keybtn:active { transform: scale(.955); }
.keybtn .kb-inner { display: grid; place-items: center; gap: 9px; transition: opacity .25s, transform .3s var(--e-out); }
.keybtn .kb-inner svg { width: 54px; height: 54px; stroke-width: 1.4; }
.keybtn .kb-label { font-size: 15.5px; font-weight: 650; letter-spacing: .01em; }
.keybtn .ring {
  position: absolute; top: -18px; left: -18px; width: 254px; height: 254px;
  border-radius: 50%; border: 2px solid rgba(255,255,255,.2);
  opacity: 0; pointer-events: none;
}
.keybtn.idle .ring { animation: ring-pulse 3.2s var(--e-out) infinite; }
.keybtn.idle .ring:nth-of-type(2) { animation-delay: 1.1s; }
@keyframes ring-pulse {
  0%   { opacity: .75; transform: scale(.92); }
  70%  { opacity: 0;   transform: scale(1.22); }
  100% { opacity: 0;   transform: scale(1.22); }
}
.keybtn .prog {
  position: absolute; top: -14px; left: -14px;
  width: 246px; height: 246px; max-width: none;
  transform: rotate(-90deg); opacity: 0; transition: opacity .2s;
}
.keybtn .prog circle { fill: none; stroke-width: 4; stroke-linecap: round; }
.keybtn .prog .trk { stroke: rgba(255,255,255,.14); }
.keybtn .prog .bar { stroke: #E8A77E; stroke-dasharray: 740; stroke-dashoffset: 740; }
.keybtn.opening .prog { opacity: 1; }
.keybtn.opening .prog .bar { animation: prog-fill 1.25s var(--e-in-out) forwards; }
@keyframes prog-fill { to { stroke-dashoffset: 0; } }
.keybtn.opened {
  background: radial-gradient(circle at 34% 28%, #5FB58F, #2E7D5B 62%, #216047);
  box-shadow: 0 18px 50px rgba(46,125,91,.5), inset 0 2px 0 rgba(255,255,255,.26);
}
.keybtn.opened .kb-inner { animation: atr-pop .45s var(--e-spring) both; }

.key-target {
  text-align: center; color: #fff; margin-top: -2px; padding: 0 24px 4px;
}
.key-target .kt-name { font-size: 20px; font-weight: 650; letter-spacing: -.01em; }
.key-target .kt-hint { font-size: 14.5px; color: #A6C5C3; margin-top: 5px; line-height: 1.4; min-height: 20px; }

.doors { padding: 14px 22px 0; }
.doors-t { font-size: 13.5px; font-weight: 700; letter-spacing: .09em; text-transform: uppercase; color: #8FB5B3; padding: 0 0 11px; }
.door {
  display: flex; align-items: center; gap: 13px; width: 100%; text-align: left;
  padding: 13px 15px; border-radius: var(--r-md); min-height: 66px;
  background: rgba(255,255,255,.07); border: 1.5px solid transparent;
  transition: background .22s, border-color .22s, transform .22s var(--e-spring);
}
.door + .door { margin-top: 9px; }
.door:active { transform: scale(.985); }
.door.sel { background: rgba(255,255,255,.15); border-color: rgba(232,167,126,.75); }
.door .di { flex: none; width: 42px; height: 42px; border-radius: 13px; display: grid; place-items: center; background: rgba(255,255,255,.1); color: #D7E8E7; }
.door .di svg { width: 22px; height: 22px; }
.door.sel .di { background: var(--copper-600); color: #fff; }
.door .dt { flex: 1; min-width: 0; color: #fff; }
.door .dt b { display: block; font-size: 15.8px; font-weight: 600; }
.door .dt small { display: block; font-size: 14px; color: #9DBDBB; margin-top: 2px; }
.door .dk { flex: none; font-size: 13.5px; font-weight: 650; color: #E8A77E; opacity: 0; transition: opacity .22s; }
.door.sel .dk { opacity: 1; }

.key-foot { padding: 20px 22px 6px; }
.offline-pill {
  display: flex; align-items: center; gap: 10px; padding: 13px 16px; border-radius: var(--r-md);
  background: rgba(255,255,255,.07); color: #B2CBC9; font-size: 14.2px; line-height: 1.45;
}
.offline-pill svg { width: 19px; height: 19px; flex: none; color: #8FB5B3; }

/* ==========================================================================
   SERVIZI
   ========================================================================== */
/* --- scheda servizio: stato scritto a parole, azione con etichetta ----- */
.svc {
  background: var(--surface); border-radius: var(--r-lg);
  border: 1.5px solid var(--line-2); box-shadow: var(--sh-1); overflow: hidden;
  transition: border-color .25s, box-shadow .25s;
}
.svc + .svc { margin-top: 12px; }
.svc.active { border-color: var(--pine-300); box-shadow: var(--sh-2); }

.svc-main {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 15px 16px 14px; background: transparent; transition: background .18s;
}
.svc-main:active { background: var(--pine-50); }
.svc .si {
  flex: none; width: 50px; height: 50px; border-radius: 15px; display: grid; place-items: center;
  background: var(--paper-2); color: var(--ink-3); transition: background .3s, color .3s;
}
.svc.active .si { background: var(--pine-700); color: #fff; }
.svc .si svg { width: 25px; height: 25px; }
.svc .st { flex: 1; min-width: 0; }
.svc .st b { display: block; font-size: 17px; font-weight: 650; line-height: 1.25; }
.svc .st small { display: block; font-size: 14.5px; color: var(--ink-3); margin-top: 3px; }
.svc .st .price { color: var(--ink-2); font-weight: 600; }
.svc .sc { flex: none; display: flex; align-items: center; gap: 5px; color: var(--ink-4); font-size: 13.5px; font-weight: 600; }
.svc .sc svg { width: 19px; height: 19px; }

.svc-foot {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 14px 12px 16px; border-top: 1px solid var(--line-2); background: var(--paper);
}
.svc.active .svc-foot { background: var(--pine-50); border-top-color: var(--pine-100); }
.svc-state {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px;
  font-size: 15px; font-weight: 650; color: var(--ink-3);
}
.svc-state.on { color: var(--ok); }
.svc-state .pt { width: 10px; height: 10px; border-radius: 99px; background: currentColor; flex: none; }
.svc-state .sl { display: flex; flex-direction: column; min-width: 0; }
.svc-state .sl b { font-weight: 650; line-height: 1.2; }
.svc-state em { font-style: normal; font-weight: 500; font-size: 13.5px; color: var(--ink-3); line-height: 1.25; margin-top: 2px; }

.svc-act {
  flex: none; min-height: 46px; padding: 0 18px; border-radius: 13px;
  font-size: 15.5px; font-weight: 650; display: inline-flex; align-items: center; gap: 8px;
  transition: transform .18s var(--e-spring), background .2s, box-shadow .2s;
}
.svc-act:active { transform: scale(.96); }
.svc-act svg { width: 18px; height: 18px; }
.svc-act--attiva { background: var(--copper-600); color: #fff; box-shadow: 0 3px 10px rgba(180,97,58,.3); }
.svc-act--attiva:hover { background: var(--copper-500); }
.svc-act--spegni { background: var(--surface); color: var(--ink-2); border: 1.5px solid var(--line); }
.svc-act--spegni:hover { border-color: var(--ink-4); color: var(--ink); }

.booking {
  display: flex; align-items: center; gap: 14px; padding: 15px 16px; background: var(--surface);
  border-radius: var(--r-lg); border: 1px solid var(--line-2); box-shadow: var(--sh-1); width: 100%; text-align: left;
}
.booking + .booking { margin-top: 10px; }
.booking .bd {
  flex: none; width: 54px; align-self: stretch; border-radius: var(--r-sm);
  background: var(--pine-50); color: var(--pine-700);
  display: grid; place-items: center; align-content: center; padding: 10px 0; gap: 1px;
}
.booking .bd .dd { font-size: 21px; font-weight: 700; line-height: 1; }
.booking .bd .mm { font-size: 12.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
.booking .bt { flex: 1; min-width: 0; }
.booking .bt b { display: block; font-size: 15.8px; font-weight: 650; }
.booking .bt small { display: block; font-size: 14px; color: var(--ink-3); margin-top: 3px; line-height: 1.3; }

/* calendario */
.cal { background: var(--surface); border-radius: var(--r-lg); border: 1px solid var(--line-2); padding: 16px; box-shadow: var(--sh-1); }
.cal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-head b { font-size: 16.5px; font-weight: 650; text-transform: capitalize; }
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-dow { font-size: 12.5px; font-weight: 700; color: var(--ink-4); text-align: center; padding-bottom: 6px; text-transform: uppercase; }
.cal-day {
  aspect-ratio: 1; border-radius: 13px; display: grid; place-items: center; font-size: 15.5px; font-weight: 600;
  transition: background .2s, color .2s, transform .2s var(--e-spring); position: relative;
}
.cal-day:active { transform: scale(.9); }
.cal-day.out { color: var(--ink-4); opacity: .35; pointer-events: none; }
.cal-day.off { color: var(--ink-4); pointer-events: none; text-decoration: line-through; }
.cal-day.has::after { content: ''; position: absolute; bottom: 6px; width: 5px; height: 5px; border-radius: 99px; background: var(--copper-500); }
.cal-day.sel { background: var(--pine-700); color: #fff; }
.cal-day.sel.has::after { background: #E8A77E; }

.slots { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.slot {
  padding: 14px 10px; border-radius: var(--r-sm); font-size: 15.5px; font-weight: 600; text-align: center;
  background: var(--surface); border: 1.5px solid var(--line); transition: all .2s;
}
.slot.sel { background: var(--pine-700); color: #fff; border-color: var(--pine-700); }
.slot[disabled] { opacity: .4; text-decoration: line-through; pointer-events: none; }

/* scelte brevi su più righe: la categoria di una segnalazione */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 10px 14px; border-radius: var(--r-full); font-size: 14.5px; font-weight: 600;
  background: var(--surface); border: 1.5px solid var(--line); color: var(--ink-2); transition: all .2s;
}
.chip.on { background: var(--pine-700); border-color: var(--pine-700); color: #fff; }

/* ==========================================================================
   PAGAMENTI
   ========================================================================== */
.balance {
  border-radius: var(--r-xl); padding: 24px 22px 22px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(150deg, #1D5B59, #2A6F6C 55%, #153735);
  box-shadow: 0 14px 34px rgba(14,35,34,.3);
}
.balance::before {
  content: ''; position: absolute; top: -70px; right: -50px; width: 210px; height: 210px; border-radius: 50%;
  background: radial-gradient(circle, rgba(208,122,75,.38), transparent 70%);
}
.balance .bl-l { font-size: 14px; font-weight: 600; letter-spacing: .09em; text-transform: uppercase; color: #9DBDBB; }
.balance .bl-v { font-family: var(--font-display); font-size: 42px; font-weight: 400; letter-spacing: .015em; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
.balance .bl-d { font-size: 14.7px; color: #BAD2D0; display: flex; align-items: center; gap: 7px; }
.balance .bl-d svg { width: 16px; height: 16px; }
.balance .btn { margin-top: 20px; background: #fff; color: var(--pine-800); box-shadow: 0 6px 18px rgba(0,0,0,.2); }
.balance .bl-split { margin-top: 16px; display: flex; gap: 8px; }
.balance .bl-split div { flex: 1; background: rgba(255,255,255,.1); border-radius: var(--r-sm); padding: 10px 12px; }
.balance .bl-split small { display: block; font-size: 12.5px; color: #9DBDBB; margin-bottom: 3px; }
.balance .bl-split b { font-size: 15.5px; font-variant-numeric: tabular-nums; }

.pm-chips { display: flex; gap: 9px; overflow-x: auto; padding: 2px 22px 4px; margin: 0 -22px; scrollbar-width: none; }
.pm-chips::-webkit-scrollbar { display: none; }
.pm-chip {
  flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 15px; border-radius: var(--r-md);
  background: var(--surface); border: 1.5px solid var(--line); min-height: 60px; transition: all .22s;
}
.pm-chip.sel { border-color: var(--pine-700); background: var(--pine-50); }
.pm-chip svg { width: 22px; height: 22px; color: var(--ink-2); }
.pm-chip.sel svg { color: var(--pine-700); }
.pm-chip b { font-size: 15px; font-weight: 600; }
.pm-chip small { display: block; font-size: 13px; color: var(--ink-3); margin-top: 1px; }

/* ==========================================================================
   DOCUMENTI
   ========================================================================== */
.folders { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.folder {
  padding: 18px 16px 16px; border-radius: var(--r-lg); background: var(--surface);
  border: 1px solid var(--line-2); box-shadow: var(--sh-1); text-align: left;
  transition: transform .22s var(--e-spring), box-shadow .25s;
}
.folder:active { transform: scale(.975); }
.folder .fi { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; background: var(--copper-100); color: var(--copper-700); margin-bottom: 14px; }
.folder .fi svg { width: 24px; height: 24px; }
.folder b { display: block; font-size: 16px; font-weight: 650; }
.folder small { display: block; font-size: 14px; color: var(--ink-3); margin-top: 3px; }

/* ==========================================================================
   PROFILO
   ========================================================================== */
.prof-head { display: flex; align-items: center; gap: 15px; padding: 4px 22px 20px; }
.avatar {
  flex: none; width: 68px; height: 68px; border-radius: 22px; display: grid; place-items: center;
  background: linear-gradient(145deg, #2A6F6C, #153735); color: #fff;
  font-size: 23px; font-weight: 650; letter-spacing: .01em;
  box-shadow: 0 8px 20px rgba(14,35,34,.26);
}
.avatar.sm { width: 42px; height: 42px; border-radius: 14px; font-size: 15.5px; }
.prof-head .pt b { display: block; font-family: var(--font-display); font-size: 23px; font-weight: 400; letter-spacing: .015em; }
.prof-head .pt small { display: block; font-size: 14.5px; color: var(--ink-2); margin-top: 3px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-size: 14px; font-weight: 650; color: var(--ink-2); margin-bottom: 6px; letter-spacing: .01em; }
.field input, .field select, .field textarea {
  width: 100%; min-height: 54px; padding: 14px 16px; border-radius: var(--r-md);
  border: 1.5px solid var(--line); background: var(--surface); font-size: 16px;
  transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
  outline: none; border-color: var(--pine-500); box-shadow: 0 0 0 4px var(--pine-50);
}
.field .hint { font-size: 13.8px; color: var(--ink-3); margin-top: 6px; line-height: 1.4; }
.field input[readonly] { background: var(--paper-2); color: var(--ink-2); }

/* ==========================================================================
   TAB BAR
   ========================================================================== */
.tabbar {
  flex: none; position: absolute; bottom: 0; left: 0; right: 0; z-index: 40;
  display: flex; padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: blur(22px) saturate(1.6);
  box-shadow: 0 -1px 0 var(--line), 0 -8px 28px rgba(20,28,25,.06);
}
.tab {
  flex: 1; display: grid; place-items: center; gap: 4px; padding: 7px 2px 5px; border-radius: 14px;
  color: var(--ink-4); transition: color .25s;
}
.tab svg { width: 25px; height: 25px; transition: transform .35s var(--e-spring); stroke-width: 1.6; }
.tab span { font-size: 12.5px; font-weight: 650; letter-spacing: .005em; }
.tab.on { color: var(--pine-700); }
.tab.on svg { transform: translateY(-2px) scale(1.06); stroke-width: 2; }
.tab .tb-badge {
  position: absolute; margin: -22px 0 0 20px; min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 99px; background: var(--copper-600); color: #fff; font-size: 12px; font-weight: 700;
  display: grid; place-items: center;
}

/* FAB assistente */
.fab {
  position: absolute; right: 16px; bottom: 92px; z-index: 45;
  width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--ai-500), var(--ai-600)); color: #fff;
  box-shadow: 0 10px 26px rgba(76,58,122,.4);
  transition: box-shadow .3s, filter .2s;
  animation: atr-fade .5s .6s both;
}
.fab:active { filter: brightness(.92); }
.fab:hover { box-shadow: 0 14px 32px rgba(76,58,122,.5); }
.fab svg { width: 25px; height: 25px; }
.fab .spark { position: absolute; top: -5px; right: -5px; width: 19px; height: 19px; border-radius: 99px; background: #fff; color: var(--ai-600); display: grid; place-items: center; box-shadow: var(--sh-1); }
.fab .spark svg { width: 13px; height: 13px; }

/* ==========================================================================
   OVERLAY: sheet, toast, modale
   ========================================================================== */
.scrim {
  position: absolute; inset: 0; z-index: 70; background: rgba(10,22,21,.46);
  backdrop-filter: blur(3px); opacity: 0; transition: opacity .3s;
}
.scrim.show { opacity: 1; }

.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 80;
  background: var(--surface); border-radius: 30px 30px 0 0;
  box-shadow: 0 -10px 50px rgba(10,22,21,.26);
  transform: translateY(100%); transition: transform .42s var(--e-out);
  max-height: 88%; display: flex; flex-direction: column;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}
.sheet.show { transform: none; }
.sheet .grip { width: 42px; height: 5px; border-radius: 99px; background: var(--line); margin: 11px auto 2px; flex: none; }
.sheet .sh-body { overflow-y: auto; padding: 12px 22px 10px; }
.sheet .sh-foot { padding: 10px 22px 8px; display: grid; gap: 9px; flex: none; }
.sheet h3 { font-family: var(--font-display); font-size: 24px; font-weight: 400; letter-spacing: .015em; margin: 4px 0 8px; }
.sheet p { font-size: 15.2px; line-height: 1.55; color: var(--ink-2); margin: 0 0 14px; }
.sheet.full { top: calc(54px + env(safe-area-inset-top)); border-radius: 0; max-height: 100%; }

.toast-zone { position: absolute; left: 0; right: 0; top: 54px; z-index: 95; padding: 0 16px; pointer-events: none; display: grid; gap: 8px; }
.toast {
  display: flex; align-items: center; gap: 11px; padding: 14px 16px; border-radius: var(--r-md);
  background: var(--pine-800); color: #fff; box-shadow: var(--sh-3); font-size: 15.3px; font-weight: 500; line-height: 1.35;
  animation: toast-in .42s var(--e-spring) both;
}
.toast.out { animation: toast-out .3s var(--e-in-out) forwards; }
.toast svg { width: 20px; height: 20px; flex: none; }
.toast.ok svg { color: #86D9B0; }
.toast.warn { background: var(--copper-700); }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-12px) scale(.97); } }

/* riepilogo prezzo nei fogli */
.pricebox { background: var(--paper); border-radius: var(--r-md); padding: 16px 18px; margin-bottom: 16px; }
.pricebox .pr { display: flex; justify-content: space-between; align-items: baseline; font-size: 15.5px; padding: 5px 0; color: var(--ink-2); }
.pricebox .pr b { color: var(--ink); font-weight: 600; font-variant-numeric: tabular-nums; }
.pricebox .pr.tot { border-top: 1px solid var(--line); margin-top: 7px; padding-top: 12px; font-size: 17px; color: var(--ink); font-weight: 650; }
.pricebox .pr.tot b { font-size: 21px; font-family: var(--font-display); }

/* ==========================================================================
   LOGIN
   ========================================================================== */
.login {
  position: absolute; inset: 0; z-index: 90; display: flex; flex-direction: column;
  background: linear-gradient(170deg, #0E2322, #1D5B59 55%, #153735);
  color: #fff; padding: 0 28px max(28px, env(safe-area-inset-bottom)); overflow-y: auto;
}
.login.hide { animation: login-out .5s var(--e-in-out) forwards; }
@keyframes login-out { to { opacity: 0; transform: scale(1.06); visibility: hidden; } }
.login .lg-top { flex: 1; display: flex; flex-direction: column; justify-content: center; padding-top: 40px; }
.login .lg-logo { height: 46px; width: auto; margin-bottom: 26px; flex: none; align-self: flex-start; object-fit: contain; max-width: none; animation: atr-fade-up .6s var(--e-out) both; }
.login .lg-mark { width: 56px; height: 56px; border-radius: 18px; display: grid; place-items: center; background: rgba(255,255,255,.12); margin-bottom: 24px; animation: atr-pop .6s var(--e-spring) both; }
.login .lg-mark svg { width: 30px; height: 30px; color: #fff; }
.login h1 { font-family: var(--font-display); font-size: 34px; font-weight: 400; letter-spacing: .015em; margin: 0 0 10px; line-height: 1.1; animation: atr-fade-up .6s .08s var(--e-out) both; }
.login .lg-sub { font-size: 15.5px; color: #A6C5C3; line-height: 1.55; margin: 0 0 30px; animation: atr-fade-up .6s .14s var(--e-out) both; }
.login .field label { color: #9DBDBB; }
.login .field input { background: rgba(255,255,255,.09); border-color: rgba(255,255,255,.16); color: #fff; }
.login .field input::placeholder { color: #7D9C9A; }
.login .field input:focus { border-color: #E8A77E; box-shadow: 0 0 0 4px rgba(232,167,126,.16); }
.login .lg-form { animation: atr-fade-up .6s .2s var(--e-out) both; }
.login .lg-or { display: flex; align-items: center; gap: 14px; color: #7D9C9A; font-size: 14px; margin: 20px 0; }
.login .lg-or::before, .login .lg-or::after { content: ''; height: 1px; flex: 1; background: rgba(255,255,255,.14); }
.login .faceid {
  display: flex; align-items: center; justify-content: center; gap: 12px; width: 100%; min-height: 60px;
  border-radius: var(--r-md); background: rgba(255,255,255,.1); border: 1.5px solid rgba(255,255,255,.18);
  color: #fff; font-size: 16.5px; font-weight: 600; transition: all .25s;
}
.login .faceid:hover { background: rgba(255,255,255,.16); }
.login .faceid svg { width: 26px; height: 26px; color: #E8A77E; }
.login .lg-foot { font-size: 14px; color: #7D9C9A; text-align: center; line-height: 1.6; padding-top: 24px; }
.login .lg-foot b { color: #A6C5C3; }

/* scansione Face ID */
.faceid-scan { position: absolute; inset: 0; z-index: 93; background: rgba(14,35,34,.94); display: grid; place-items: center; animation: atr-fade .25s both; }
.faceid-scan .fs-box { display: grid; place-items: center; gap: 22px; color: #fff; text-align: center; padding: 0 40px; }
.faceid-scan .fs-ic { width: 110px; height: 110px; color: #E8A77E; position: relative; }
.faceid-scan .fs-ic svg { width: 110px; height: 110px; stroke-width: 1.2; }
.faceid-scan .fs-ic::after {
  content: ''; position: absolute; left: -6px; right: -6px; height: 2px; background: #E8A77E;
  box-shadow: 0 0 16px 3px rgba(232,167,126,.75); animation: scanline 1.1s var(--e-in-out) infinite;
}
@keyframes scanline { 0%,100% { top: 6px; } 50% { top: 100px; } }
.faceid-scan .fs-t { font-size: 17px; font-weight: 600; }
.faceid-scan .fs-s { font-size: 14.5px; color: #A6C5C3; }

/* codice 2FA */
.otp { display: flex; gap: 9px; justify-content: center; margin: 6px 0 18px; }
.otp i {
  width: 46px; height: 58px; border-radius: 14px; background: rgba(255,255,255,.09);
  border: 1.5px solid rgba(255,255,255,.16); display: grid; place-items: center;
  font-size: 24px; font-weight: 650; font-style: normal; color: #fff;
  transition: border-color .25s, background .25s, transform .3s var(--e-spring);
}
.otp i.fill { border-color: #E8A77E; background: rgba(232,167,126,.14); transform: translateY(-3px); }

/* ==========================================================================
   CHAT AI
   ========================================================================== */
.chat-head { display: flex; align-items: center; gap: 12px; padding: 4px 22px 14px; }
.chat-head .ci { width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: linear-gradient(145deg,var(--ai-500),var(--ai-600)); color: #fff; }
.chat-head .ci svg { width: 23px; height: 23px; }
.chat-head b { display: block; font-size: 17px; font-weight: 650; }
.chat-head small { display: block; font-size: 14px; color: var(--ok); font-weight: 600; margin-top: 2px; }
.chat-log { display: flex; flex-direction: column; gap: 11px; padding: 4px 0 8px; }
.bub { max-width: 84%; padding: 13px 16px; border-radius: 20px; font-size: 15.3px; line-height: 1.5; animation: atr-fade-up .35s var(--e-out) both; }
.bub.ai { background: var(--ai-100); border: 1px solid var(--ai-200); border-bottom-left-radius: 7px; align-self: flex-start; color: var(--ai-700); }
.bub.me { background: var(--pine-700); color: #fff; border-bottom-right-radius: 7px; align-self: flex-end; }
.bub b { font-weight: 650; }
.typing { display: flex; gap: 5px; padding: 15px 18px; }
.typing i { width: 8px; height: 8px; border-radius: 99px; background: var(--ai-500); animation: dot 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .18s } .typing i:nth-child(3) { animation-delay: .36s }
@keyframes dot { 0%,60%,100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-4px); } }
.quick {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px;
  padding: 8px; margin-bottom: 2px;
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--r-lg);
}
.quick button {
  padding: 12px 7px; border-radius: 14px; background: var(--surface);
  border: 1.5px solid var(--line); font-size: 14px; font-weight: 600;
  transition: all .2s; min-height: 48px; line-height: 1.25;
}
.quick button:last-child { grid-column: 1 / -1; }
.quick button:active { background: var(--pine-50); border-color: var(--pine-300); }
.quick button.qfull { grid-column: 1 / -1; }
.quick button.qai {
  background: var(--ai-100); border-color: var(--ai-200); color: var(--ai-700);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.quick button.qai svg { width: 17px; height: 17px; flex: none; }
/* bolla con dentro una scheda: la prenotazione preparata dall'assistente */
.bub.card { max-width: 94%; }
.bub.ai .pricebox { background: rgba(255,255,255,.66); margin: 0; }
.bub.ai .pricebox .pr { color: var(--ai-700); }
.bub.ai .pricebox .pr b, .bub.ai .pricebox .pr.tot { color: var(--ink); }
.bub-nota { margin-top: 9px; font-size: 14.3px; line-height: 1.45; opacity: .76; }
.bub.ai .pricebox.cm-mini { margin: 10px 0 0; padding: 11px 14px; }
.bub.ai .pricebox.cm-mini .pr { padding: 3px 0; font-size: 15px; }
.bub.ai .pricebox.cm-mini .pr.tot { margin-top: 5px; padding-top: 9px; font-size: 16px; }
.bub.ai .pricebox.cm-mini .pr.tot b { font-size: 19px; }
.bub .cm-cta { width: 100%; margin-top: 10px; min-height: 46px; padding: 11px 16px; }
.chat-input { display: flex; gap: 9px; align-items: center; padding: 12px 0 2px; border-top: 1px solid var(--line-2); margin-top: 12px; }
.chat-input .chat-field { flex: 1; position: relative; display: flex; }
.chat-input input { flex: 1; min-height: 50px; padding: 12px 54px 12px 16px; border-radius: 99px; border: 1.5px solid var(--line); background: var(--surface); font-size: 15.5px; }
.chat-input input:focus { outline: none; border-color: var(--pine-500); }
.chat-input .qtoggle {
  position: absolute; right: 5px; top: 50%; transform: translateY(-50%);
  width: 40px; height: 40px; border-radius: 99px; display: grid; place-items: center;
  background: var(--ai-100); color: var(--ai-700); transition: all .2s;
}
.chat-input .qtoggle svg { width: 19px; height: 19px; }
.chat-input .qtoggle.on { background: var(--ai-600); color: #fff; }
.chat-input .send { flex: none; width: 50px; height: 50px; border-radius: 99px; background: var(--pine-700); color: #fff; display: grid; place-items: center; }
.chat-input .send svg { width: 21px; height: 21px; }

/* dettagli vari */
.kv { display: flex; justify-content: space-between; gap: 16px; padding: 13px 0; font-size: 15.3px; }
.kv + .kv { border-top: 1px solid var(--line-2); }
.kv span { color: var(--ink-3); }
.kv b { font-weight: 600; text-align: right; }

.note {
  display: flex; gap: 11px; padding: 14px 16px; border-radius: var(--r-md); background: var(--info-bg);
  color: #255A79; font-size: 14.3px; line-height: 1.5;
}
.note svg { width: 19px; height: 19px; flex: none; margin-top: 1px; }
.note.warn { background: var(--warn-bg); color: #8A6213; }

.success-mark {
  width: 86px; height: 86px; border-radius: 50%; background: var(--ok-bg); color: var(--ok);
  display: grid; place-items: center; margin: 6px auto 18px; animation: atr-pop .5s var(--e-spring) both;
}
.success-mark svg { width: 44px; height: 44px; stroke-width: 2.4; }

/* --- chat a tutta altezza: i messaggi stanno in basso, come in una chat -- */
.sheet.full { display: flex; flex-direction: column; }
.sheet.full .sh-body { flex: 1; display: flex; flex-direction: column; overflow: hidden; padding-bottom: 4px; }
.sheet.full .chat-head { flex: none; }
.sheet.full .chat-log {
  flex: 1; overflow-y: auto; padding-bottom: 14px;
  /* quello che scorre sotto l'intestazione sfuma: una bolla tagliata
     netto sembra un errore di disegno */
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
          mask-image: linear-gradient(to bottom, transparent 0, #000 20px);
}
.sheet.full .chat-log > *:first-child { margin-top: auto; }
.sheet.full .chat-log::-webkit-scrollbar { width: 0; }
.sheet.full .quick { flex: none; }
.sheet.full .chat-input { flex: none; }

/* --- scelta del tipo di accesso (condivisione chiave) ------------------ */
.roles { display: grid; gap: 10px; }
.role {
  display: flex; align-items: flex-start; gap: 13px; width: 100%; text-align: left;
  padding: 14px 15px; border-radius: var(--r-md);
  background: var(--surface); border: 1.5px solid var(--line);
  transition: border-color .2s, background .2s, transform .18s var(--e-spring);
}
.role:active { transform: scale(.99); }
.role.sel { border-color: var(--pine-600); background: var(--pine-50); }
.role .ri {
  flex: none; width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center;
  background: var(--paper-2); color: var(--ink-3);
}
.role.sel .ri { background: var(--pine-700); color: #fff; }
.role .ri svg { width: 20px; height: 20px; }
.role .rt { flex: 1; min-width: 0; }
.role .rt b { display: block; font-size: 16px; font-weight: 650; }
.role .rt small { display: block; font-size: 14px; color: var(--ink-3); margin-top: 4px; line-height: 1.4; }
.role .rk { flex: none; width: 22px; color: var(--pine-700); }
.role .rk svg { width: 22px; height: 22px; stroke-width: 2.4; }

/* --- scelta della versione dell'app (solo nel prototipo) --------------- */
.pick {
  position: absolute; inset: 0; z-index: 95; display: flex; flex-direction: column; justify-content: center;
  background: linear-gradient(170deg, #0E2322, #1D5B59 55%, #153735);
  color: #fff; padding: 0 24px max(24px, env(safe-area-inset-bottom)); overflow-y: auto;
}
.pick.hide { animation: login-out .45s var(--e-in-out) forwards; }
.pick .pk-logo { height: 40px; width: auto; margin-bottom: 26px; flex: none; align-self: flex-start; object-fit: contain; max-width: none; animation: atr-fade-up .6s var(--e-out) both; }
.pick h1 { font-family: var(--font-display); font-size: 30px; font-weight: 400; letter-spacing: .015em; margin: 0 0 10px; line-height: 1.1; animation: atr-fade-up .6s .06s var(--e-out) both; }
.pick p { font-size: 15px; color: #A6C5C3; line-height: 1.55; margin: 0 0 26px; animation: atr-fade-up .6s .1s var(--e-out) both; }
.pick .opt {
  display: flex; align-items: flex-start; gap: 13px; width: 100%; text-align: left;
  padding: 17px 16px; border-radius: var(--r-lg); margin-bottom: 11px;
  background: rgba(255,255,255,.08); border: 1.5px solid rgba(255,255,255,.14);
  transition: background .22s, border-color .22s, transform .22s var(--e-spring);
  animation: atr-fade-up .6s .16s var(--e-out) both;
}
.pick .opt:nth-of-type(2) { animation-delay: .22s; }
.pick .opt:active { transform: scale(.985); }
.pick .opt:hover { background: rgba(255,255,255,.13); border-color: rgba(232,167,126,.6); }
.pick .opt .oi { flex: none; width: 44px; height: 44px; border-radius: 14px; display: grid; place-items: center; background: rgba(255,255,255,.12); color: #fff; }
.pick .opt .oi svg { width: 22px; height: 22px; }
.pick .opt .ot { flex: 1; min-width: 0; }
.pick .opt .ot b { display: block; font-size: 17px; font-weight: 650; }
.pick .opt .ot small { display: block; font-size: 13.8px; color: #A6C5C3; margin-top: 4px; line-height: 1.45; }
.pick .foot { font-size: 13px; color: #7D9C9A; text-align: center; line-height: 1.6; margin-top: 14px; }
