/* ══════════════════════════════════════════════════════════════════════════
   GARDEN RIVER · TEMA CONDIVISO
   Foglio di stile unico per tutte le pagine della Hub e dei moduli.
   Prima di questo file, le stesse variabili e gli stessi componenti erano
   incollati identici in 11 file HTML: qui si aggiornano una volta sola.
   I nomi delle variabili restano quelli originali (--orange, --amber, --blue…)
   per compatibilità con il CSS specifico già presente in ogni pagina — solo
   alcuni valori sono stati raffinati (vedi accento unico sotto).
   ══════════════════════════════════════════════════════════════════════════ */

:root {
  --green-900: #0D2B1E;
  --green-700: #1B4332;
  --green-600: #25523D;
  --green-500: #2D6A4F;
  --green-400: #40916C;
  --green-200: #95D5B2;
  --green-100: #D8F3DC;
  --green-50:  #F0FAF4;
  --gray-900:  #111827;
  --gray-700:  #374151;
  --gray-500:  #6B7280;
  --gray-400:  #9CA3AF;
  --gray-300:  #D1D5DB;
  --gray-100:  #F3F4F6;
  --gray-50:   #F9FAFB;
  --white:     #FFFFFF;

  /* ── accento unico — prima "arancio" (#E07B00) e "ambra" semantica
       coesistevano con toni diversi; l'arancio decorativo ora è terracotta,
       la stessa tonalità ovunque compaia (badge, notifiche, ticket) ── */
  --orange:    #B85C2C;
  --orange-lt: #E0A72E;
  --orange-bg: #FBEADD;
  --terracotta:   #B85C2C;
  --terracotta-2: #E0A72E;
  --terracotta-soft: #FBEADD;

  --red:       #DC2626; --red-bg: #FEF2F2; --red-bd: #FECACA;
  --amber:     #D97706; --amber-bg: #FFFBEB; --amber-bd: #FDE68A;
  --green-ok:  #16A34A; --green-bg: #F0FAF4; --green-bd: #BBF7D0;
  --blue:      #2563EB; --blue-bg: #EFF6FF; --blue-bd: #BFDBFE;

  --radius-sm: 12px;
  --radius:    16px;
  --radius-lg: 22px;
  --radius-xl: 32px;
  --shadow-sm: 0 2px 10px rgba(0,0,0,0.07);
  --shadow:    0 4px 20px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 36px rgba(0,0,0,0.14);

  --font: 'Inter', -apple-system, sans-serif;
  --font-display: 'Fraunces', Georgia, serif;

  --grad-forest: linear-gradient(135deg,#163A29 0%,#1B4332 45%,#357A57 100%);
  --grad-sun:    linear-gradient(135deg,#B85C2C 0%,#E0A72E 100%);
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
body { font-family: var(--font); background: var(--white); color: var(--gray-900); min-height: 100vh; -webkit-font-smoothing: antialiased; overscroll-behavior-y: none; }

/* ══ LOGIN ══════════════════════════════════════════════════════════════════ */
.login-screen {
  position: fixed; inset: 0; z-index: 999;
  background: var(--green-700);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 32px 24px;
}
.login-screen.hidden { display: none; }
.login-logo { height: 72px; width: auto; max-width: 140px; margin-bottom: 16px; object-fit: contain; }
.login-title { font-size: 24px; font-weight: 800; color: var(--white); margin-bottom: 4px; }
.login-sub   { font-size: 13px; color: rgba(255,255,255,0.6); margin-bottom: 32px; text-align: center; }
.login-card  { background: var(--white); border-radius: var(--radius-lg); padding: 24px 20px; width: 100%; max-width: 340px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); }
.login-label { font-size: 17px; font-weight: 800; color: var(--gray-900); text-align: center; margin-bottom: 14px; display: block; }
.login-select { width: 100%; height: 48px; padding: 0 14px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 15px; font-family: var(--font); color: var(--gray-900); background: var(--white); outline: none; margin-bottom: 14px; transition: border-color .15s; }
.login-select:focus { border-color: var(--green-400); }
.pin-label { font-size: 13px; font-weight: 700; color: var(--gray-700); margin-bottom: 16px; display: block; text-align: center; }
.pin-dots { display: flex; gap: 10px; justify-content: center; margin-bottom: 24px; }
.pin-dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--gray-300); background: var(--white); transition: all .15s; }
.pin-dot.filled { background: var(--green-700); border-color: var(--green-700); }
.pin-dot.error  { background: var(--red); border-color: var(--red); }
.pin-keypad { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-bottom: 6px; }
.pin-key { height: 56px; border: 1.5px solid #E5E7EB; border-radius: var(--radius-sm); background: var(--white); font-size: 22px; font-weight: 600; color: var(--gray-900); cursor: pointer; font-family: var(--font); display: flex; align-items: center; justify-content: center; transition: background .1s; -webkit-tap-highlight-color: transparent; }
.pin-key:active { background: var(--gray-100); }
.pin-key.del    { font-size: 18px; color: var(--gray-500); }
.pin-key.empty  { border: none; background: none; cursor: default; }
.login-error { font-size: 12px; color: var(--red); font-weight: 600; text-align: center; margin-top: 8px; min-height: 18px; }
.btn-primary { width: 100%; height: 50px; background: var(--green-700); color: var(--white); border: none; border-radius: var(--radius-xl); font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: opacity .15s; margin-top: 4px; }
.btn-primary:active   { opacity: .85; }
.btn-primary:disabled { opacity: .45; pointer-events: none; }

/* ══ HEADER ═══════════════════════════════════════════════════════════════ */
.top-bar { position: sticky; top: 0; z-index: 100; background: var(--white); border-bottom: 1px solid var(--gray-100); padding-top: env(safe-area-inset-top); }
.header-inner { display: flex; align-items: center; justify-content: space-between; max-width: 750px; margin: 0 auto; padding: 16px 16px; gap: 14px; }
.header-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.header-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--green-700); display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; color: var(--white); flex-shrink: 0; box-shadow: 0 0 0 2px var(--white), 0 0 0 3.5px var(--terracotta); }
.header-name  { font-size: 17px; font-weight: 800; color: var(--gray-900); line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.header-role  { font-size: 12px; color: var(--gray-500); margin-top: 2px; }
.header-btns  { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.hbtn { height: 36px; padding: 0 14px; border: none; border-radius: 18px; font-size: 12px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: opacity .15s, background .15s; white-space: nowrap; }
.hbtn.icon    { width: 36px; padding: 0; font-size: 16px; display: flex; align-items: center; justify-content: center; }
.hbtn.ghost   { background: var(--gray-100); color: var(--gray-700); border: none; }
.hbtn:active  { opacity: .8; }
.hbtn:hover   { background: var(--green-50); color: var(--green-700); }

/* ══ SIDEBAR DESKTOP + RAIL TABLET + DRAWER MOBILE ═══════════════════════════
   Solo Hub e Calendario usano questa navigazione a tre livelli; le altre
   pagine restano a singola vista con top-bar. Le categorie si aprono e
   chiudono singolarmente (nav-group-header). */
.app-shell { position: relative; }
.sidebar { display: none; }
.rail { display: none; }
@media (min-width: 1024px) {
  .app-shell { display: flex; align-items: flex-start; }
  /* .rail è "position:fixed" (non sticky): con "sticky" il suo contenitore
     .nav-zone, dentro un flex con align-items:flex-start, resta alto solo
     quanto il rail stesso — appena la pagina è più lunga di 100vh lo sticky
     "finisce" e il rail scompare scorrendo invece di restare agganciato.
     .nav-zone mantiene comunque le stesse dimensioni (78px × 100vh) così la
     larghezza resta riservata nel flex e l'hover per aprire la sidebar
     funziona su tutta l'altezza. */
  .nav-zone { position: relative; width: 78px; flex-shrink: 0; height: 100vh; }
  .rail {
    display: flex; flex-direction: column; align-items: center;
    width: 78px; height: 100vh; position: fixed; top: 0; left: 0; z-index: 40;
    background: #FBFCF9; border-right: 1px solid var(--gray-100);
    padding: 16px 8px; gap: 4px; overflow-y: auto;
  }
  /* Da desktop il rail compatto (icone, come da tablet) resta il layout di
     base e non sposta mai il contenuto: la sidebar coi nomi si apre solo al
     passaggio del mouse, sovrapposta sopra il resto — così il menu non
     rimane fisso aperto a occupare spazio quando non serve. */
  .sidebar {
    display: flex; flex-direction: column;
    width: 240px; height: 100vh;
    /* z-index sopra il .top-bar (100): essendo un overlay che si apre sopra
       tutto il resto, prima era più basso (45) e l'header sticky ci finiva
       sempre sopra per costruzione, non solo in casi intermittenti. */
    position: fixed; top: 0; left: 0; z-index: 150;
    background: #FBFCF9; border-right: 1px solid var(--gray-100);
    padding: 20px 14px; overflow-y: auto;
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%); opacity: 0; pointer-events: none;
    transition: transform .15s ease, opacity .15s ease;
  }
  .nav-zone:hover .sidebar, .nav-zone:focus-within .sidebar {
    transform: translateX(0); opacity: 1; pointer-events: auto;
  }
  .hamburger { display: none !important; }
  .main-col { flex: 1; min-width: 0; }
}
@media (min-width: 768px) and (max-width: 1023.98px) {
  .app-shell { display: flex; align-items: flex-start; }
  .nav-zone { width: 78px; flex-shrink: 0; height: 100vh; }
  .rail {
    display: flex; flex-direction: column; align-items: center;
    width: 78px; height: 100vh; position: fixed; top: 0; left: 0; z-index: 40;
    background: #FBFCF9; border-right: 1px solid var(--gray-100);
    padding: 16px 8px; gap: 4px; overflow-y: auto;
  }
  .hamburger { display: none !important; }
  .main-col { flex: 1; min-width: 0; }
}
.sidebar-brand { display: flex; align-items: center; gap: 10px; padding: 2px 8px 18px; margin-bottom: 8px; border-bottom: 1px solid var(--gray-100); }
.sidebar-brand img { width: 32px; height: 32px; border-radius: 9px; object-fit: cover; flex-shrink: 0; }
.sidebar-brand-mark { width: 36px; height: 36px; border-radius: 11px; background: var(--grad-forest); display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 3px 10px rgba(27,67,50,.35); }
.sidebar-brand-mark svg { width: 19px; height: 19px; color: #fff; }
.sidebar-brand-title { font-size: 15px; font-weight: 800; color: var(--gray-900); line-height: 1.15; }
.sidebar-brand-sub { font-size: 10.5px; color: var(--gray-500); font-weight: 600; margin-top: 1px; }

.nav-group { margin-bottom: 4px; }
.nav-group-header { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: none; padding: 9px 10px; cursor: pointer; font-size: 10.5px; font-weight: 800; letter-spacing: .08em; color: var(--gray-400); text-transform: uppercase; opacity: .85; -webkit-tap-highlight-color: transparent; transition: opacity .15s; font-family: var(--font); }
.nav-group-header:hover { opacity: 1; }
.nav-group-header svg { width: 13px; height: 13px; flex-shrink: 0; transition: transform .2s ease; }
.nav-group-header.collapsed svg { transform: rotate(-90deg); }
.nav-group-items { display: flex; flex-direction: column; overflow: hidden; max-height: 320px; transition: max-height .25s ease; }
.nav-group-items.collapsed { max-height: 0; }

.nav-item, .sidebar-item { display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 999px; color: var(--gray-500); font-size: 13px; font-weight: 700; cursor: pointer; text-decoration: none; margin-bottom: 2px; transition: background .15s, color .15s; -webkit-tap-highlight-color: transparent; }
.nav-item svg, .sidebar-item svg { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover, .sidebar-item:hover { background: var(--gray-50); color: var(--gray-700); }
.nav-item.active, .sidebar-item.active { background: var(--green-700); color: #fff; font-weight: 800; box-shadow: 0 4px 14px rgba(27,67,50,.28); }
.nav-item-exit { margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--gray-100); }
.sidebar-spacer { flex: 1; }

.rail-item { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 100%; padding: 9px 4px; border-radius: 14px; color: var(--gray-500); cursor: pointer; text-decoration: none; transition: background .15s, color .15s; }
.rail-item svg { width: 20px; height: 20px; }
.rail-item span { font-size: 9px; font-weight: 700; text-align: center; line-height: 1.1; }
.rail-item:hover { background: var(--gray-50); color: var(--gray-700); }
.rail-item.active { background: var(--green-700); color: #fff; }
.rail-spacer { flex: 1; }

.hamburger { width: 38px; height: 38px; border-radius: 11px; border: none; background: var(--gray-100); display: flex; align-items: center; justify-content: center; cursor: pointer; flex-shrink: 0; color: var(--gray-900); }
.hamburger svg { width: 19px; height: 19px; }
.drawer-overlay { position: fixed; inset: 0; background: rgba(10,20,15,.55); z-index: 900; opacity: 0; pointer-events: none; transition: opacity .2s; }
.drawer-overlay.open { opacity: 1; pointer-events: auto; }
.drawer { position: fixed; top: 0; left: 0; bottom: 0; width: 78%; max-width: 280px; background: #FBFCF9; z-index: 901; transform: translateX(-100%); transition: transform .3s cubic-bezier(.4,0,.2,1); padding: 20px 14px; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); overflow-y: auto; }
.drawer.open { transform: translateX(0); }
/* Un .top-bar "sticky" agganciato in cima, se la pagina è scrollata quando
   si apre il drawer, a volte viene ridisegnato dal browser sopra il drawer
   nonostante lo z-index più basso (bug intermittente di compositing dei
   browser sugli elementi sticky "agganciati"). Passare a "position:static"
   non basta: l'elemento torna al suo posto nel flusso del documento, cioè
   dove si trovava la pagina PRIMA di scrollare, e resta visibile a metà
   schermo sopra il drawer. toggleDrawer() aggiunge questa classe al body:
   nascondere del tutto la barra (nessun layout, nessun repaint sopra il
   drawer) è l'unico modo per evitare l'ambiguità invece di rincorrerla. */
body.drawer-open { overflow: hidden; }
body.drawer-open .top-bar { visibility: hidden; }

/* ══ MAIN / HOME ═══════════════════════════════════════════════════════════ */
main { max-width: 750px; margin: 0 auto; padding: 18px 16px 100px; }
.home-headline { font-family: var(--font-display); font-size: 34px; font-weight: 600; color: var(--gray-900); line-height: 1.15; margin: 4px 0 24px; letter-spacing: -.01em; }
/* Mobile-first: ogni soglia successiva è dichiarata DOPO quella precedente,
   così la cascata vince sempre nell'ordine giusto (nessuna regola base
   dichiarata più in basso nel file può più annullare queste). */
@media (min-width: 768px) {
  main { max-width: none; margin: 0; padding: 22px 26px 56px; }
  .header-inner, .search-header-inner { max-width: none; margin: 0; }
  .home-headline { font-size: 40px; }
}
@media (min-width: 1024px) {
  main { padding: 24px 32px 60px; }
  .home-headline { font-size: 44px; }
}

.page-head { position: relative; margin-bottom: 28px; }
.page-head-motif { position: absolute; top: -10px; right: -10px; width: 300px; height: 170px; opacity: .55; pointer-events: none; color: var(--green-400); z-index: -1; }
@media (max-width: 479.98px) { .page-head-motif { display: none; } }
@media (min-width: 768px) { .page-head-motif { width: 440px; height: 210px; top: -14px; right: -14px; } }
@media (min-width: 1024px) { .page-head-motif { width: 600px; height: 240px; top: -18px; right: -18px; } }
.page-eyebrow { display: flex; align-items: center; gap: 6px; font-size: 11.5px; font-weight: 700; letter-spacing: .03em; color: var(--terracotta); margin-bottom: 8px; position: relative; }
.page-eyebrow svg { width: 14px; height: 14px; }
.page-title { font-family: var(--font-display); font-weight: 600; font-size: 30px; letter-spacing: -.01em; line-height: 1.08; position: relative; }
@media (min-width: 768px) { .page-title { font-size: 36px; } }
@media (min-width: 1024px) { .page-title { font-size: 42px; } }

/* search collassabile nella header */
.search-header-row { overflow: hidden; max-height: 0; transition: max-height .25s ease, padding .25s ease; padding: 0 16px; }
.search-header-row.open { max-height: 80px; padding: 0 16px 12px; }
.search-header-inner { display: flex; align-items: center; gap: 10px; max-width: 750px; margin: 0 auto; }
.search-wrap { position: relative; flex: 1; }
.search-wrap input { width: 100%; height: 44px; padding: 0 40px; border: none; border-radius: var(--radius-xl); font-size: 14px; font-family: var(--font); color: var(--gray-900); outline: none; background: var(--gray-100); transition: box-shadow .15s; }
.search-wrap input:focus { box-shadow: 0 0 0 2px var(--green-200); }
.search-wrap input::placeholder { color: var(--gray-500); font-style: normal; }
.search-icon { position: absolute; left: 14px; top: 50%; transform: translateY(-50%); color: var(--gray-500); pointer-events: none; display: flex; align-items: center; }
.search-icon svg { width: 16px; height: 16px; }
.search-clear { position: absolute; right: 12px; top: 50%; transform: translateY(-50%); color: var(--gray-500); font-size: 18px; cursor: pointer; padding: 4px; line-height: 1; }
.search-clear.hidden { display: none; }
.search-cancel-btn { background: none; border: none; color: var(--gray-500); font-size: 14px; font-weight: 600; cursor: pointer; font-family: var(--font); white-space: nowrap; padding: 4px; }

/* ══ KPI STRIP ════════════════════════════════════════════════════════════ */
.kpi-strip { display: grid; grid-template-columns: repeat(2,1fr); gap: 10px; margin-bottom: 20px; }
@media (min-width: 768px) { .kpi-strip { grid-template-columns: repeat(4,1fr); gap: 12px; } }
.kpi-chip { background: var(--white); border: 1px solid var(--gray-100); border-radius: var(--radius-lg); padding: 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 10px; }
.kpi-icon { width: 48px; height: 48px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.kpi-icon svg { width: 26px; height: 26px; }
.kpi-label { font-size: 11px; font-weight: 700; color: var(--gray-500); }
.kpi-value { font-size: 21px; font-weight: 800; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi-value small { font-size: 12.5px; font-weight: 600; color: var(--gray-500); }
.kpi-bar { height: 5px; border-radius: 3px; background: var(--gray-100); overflow: hidden; }
.kpi-bar i { display: block; height: 100%; border-radius: 3px; }

/* ══ BENTO GRID MODULI ════════════════════════════════════════════════════
   Tre tipi di card, sempre gli stessi: verde pieno testo bianco per i moduli
   in primo piano, arancio pieno testo bianco per ciò che richiede attenzione,
   bianco testo verde per tutto il resto — nessuna via di mezzo. */
.module-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); grid-auto-rows: 132px; gap: 12px; }
.module-tile { position: relative; border-radius: 22px; padding: 18px; display: flex; flex-direction: column; justify-content: space-between; cursor: pointer; transition: transform .15s, box-shadow .18s; -webkit-tap-highlight-color: transparent; overflow: hidden; }
.module-tile:hover { transform: translateY(-3px); box-shadow: var(--shadow); }
.module-tile:active { transform: scale(.97); }
.module-tile.feature { grid-row: span 2; }
.module-tile.solo    { grid-column: span 2; }
.module-icon-chip { width: 42px; height: 42px; border-radius: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.module-icon-chip svg { width: 22px; height: 22px; }
.module-tile.feature .module-icon-chip { width: 48px; height: 48px; border-radius: 15px; }
.module-tile.feature .module-icon-chip svg { width: 25px; height: 25px; }
.module-title { font-size: 14px; font-weight: 800; line-height: 1.25; }
.module-tile.feature .module-title { font-size: 19px; margin-bottom: 4px; }
.module-sub { font-size: 11.5px; margin-top: 4px; color: var(--gray-500); font-weight: 500; }
.module-tile.feature .module-sub { font-size: 12.5px; }
.module-badge { position: absolute; top: 14px; right: 14px; font-size: 10px; font-weight: 700; padding: 3px 9px; border-radius: 10px; color: var(--white); background: var(--terracotta); }
.tile-green .module-badge, .tile-orange .module-badge { background: rgba(255,255,255,.95); color: var(--green-700); }
.module-empty { text-align: center; padding: 60px 20px; color: var(--gray-500); font-size: 14px; line-height: 1.7; }

.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 10px; position: relative; }
.hero-ring { flex-shrink: 0; }
.hero-ring svg { width: 60px; height: 60px; }
.hero-ring text { font-family: var(--font); font-weight: 800; fill: #fff; }

.tile-green { background: var(--grad-forest); color: #fff; position: relative; }
.tile-green::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.12), transparent 55%); }
.tile-green .module-icon-chip { background: rgba(255,255,255,.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.tile-green .module-sub { color: rgba(255,255,255,.72); }

.tile-orange { background: var(--grad-sun); color: #fff; position: relative; }
.tile-orange::after { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 85% 15%, rgba(255,255,255,.14), transparent 55%); }
.tile-orange .module-icon-chip { background: rgba(255,255,255,.22); color: #fff; box-shadow: inset 0 0 0 1px rgba(255,255,255,.18); }
.tile-orange .module-sub { color: rgba(255,255,255,.78); }

.tile-white { background: var(--white); border: 1px solid var(--gray-100); color: var(--gray-900); box-shadow: var(--shadow-sm); }
.tile-white .module-icon-chip { background: rgba(27,67,50,.11); color: var(--green-700); }

/* La card "in evidenza" (Alloggi) resta grande e con l'anello a ogni
   larghezza — non viene più annullata sopra gli 860px come in passato.
   Griglia mobile-first: 2 col di base, 3 dai 768px, 4 dai 1024px —
   ogni soglia dichiarata dopo la precedente, nessuna sovrapposizione. */
@media (min-width: 768px) {
  .module-icon-chip, .module-tile.feature .module-icon-chip { width: 48px; height: 48px; border-radius: 14px; }
  .module-icon-chip svg, .module-tile.feature .module-icon-chip svg { width: 24px; height: 24px; }
  .module-title, .module-tile.feature .module-title { font-size: 16px; }
  .module-grid { grid-template-columns: repeat(3, minmax(0,1fr)); grid-auto-rows: 168px; gap: 16px; }
}
@media (min-width: 1024px) {
  .module-grid { grid-template-columns: repeat(4, minmax(0,1fr)); }
}

/* ══ SEZIONI / SETTINGS / SCHEDA MODULO ═══════════════════════════════════ */
.section { display: none; }
.section.active { display: block; }
.back-header, .back-row { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
.back-btn { width: 40px; height: 40px; border-radius: 50%; background: var(--white); border: none; cursor: pointer; font-size: 18px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.back-btn svg { width: 16px; height: 16px; }
.back-title { font-size: 19px; font-weight: 800; }
.back-eyebrow { font-size: 10.5px; font-weight: 700; color: var(--gray-500); text-transform: uppercase; letter-spacing: .06em; }
.card { background: var(--white); border-radius: var(--radius-lg); padding: 18px; box-shadow: var(--shadow-sm); margin-bottom: 14px; }
.card h3 { font-size: 16px; font-weight: 800; color: var(--gray-900); margin-bottom: 4px; }
.card .subtitle { font-size: 12px; color: var(--gray-500); margin-bottom: 16px; line-height: 1.5; }

.op-row { display: flex; align-items: center; gap: 8px; padding: 12px 0; border-bottom: 1px solid var(--gray-100); flex-wrap: wrap; }
.op-row:last-child { border-bottom: none; }
.op-avatar { width: 34px; height: 34px; border-radius: 50%; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.op-name { font-size: 14px; font-weight: 700; flex: 1; min-width: 90px; }
.op-ruolo-select { height: 32px; padding: 0 8px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 12px; font-family: var(--font); background: var(--white); outline: none; }
.op-pin-status { font-size: 11px; font-weight: 600; white-space: nowrap; }
.op-btn { height: 28px; padding: 0 10px; border-radius: 20px; font-size: 11px; font-weight: 700; cursor: pointer; font-family: var(--font); border: none; white-space: nowrap; }
.op-btn.reset { border: 1px solid var(--amber-bd); background: var(--amber-bg); color: var(--amber); }
.op-del { width: 28px; height: 28px; border: none; background: var(--red-bg); color: var(--red); border-radius: 50%; font-size: 12px; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

.perm-op-select { width: 100%; height: 48px; padding: 0 14px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); background: var(--white); outline: none; margin-bottom: 16px; }
.perm-module { margin-bottom: 16px; }
.perm-module-title { font-size: 12px; font-weight: 800; text-transform: uppercase; letter-spacing: .06em; color: var(--green-700); border-bottom: 2px solid var(--green-100); padding-bottom: 6px; margin-bottom: 8px; }
.perm-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-size: 14px; font-weight: 600; cursor: pointer; }
.perm-row input { width: 18px; height: 18px; accent-color: var(--green-700); cursor: pointer; }
.perm-hint { font-size: 12px; color: var(--gray-500); text-align: center; padding: 16px 0; line-height: 1.6; }

.new-op-form { display: flex; gap: 8px; margin-bottom: 6px; flex-wrap: wrap; }
.new-op-input { flex: 1; min-width: 140px; height: 48px; padding: 0 14px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 14px; font-family: var(--font); outline: none; transition: border-color .15s; }
.new-op-input:focus { border-color: var(--green-400); }
.new-op-ruolo { height: 48px; padding: 0 10px; border: 1.5px solid var(--gray-300); border-radius: var(--radius-sm); font-size: 13px; font-family: var(--font); background: var(--white); }
.new-op-btn { height: 48px; padding: 0 18px; background: var(--green-700); color: var(--white); border: none; border-radius: var(--radius-sm); font-size: 14px; font-weight: 700; cursor: pointer; font-family: var(--font); transition: opacity .15s; }
.new-op-btn:active { opacity: .85; }

/* ══ MODAL ═══════════════════════════════════════════════════════════════════ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.45); z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 24px; }
.modal-overlay.hidden { display: none; }
.modal-box { background: var(--white); border-radius: var(--radius-lg); padding: 24px 20px; width: 100%; max-width: 400px; box-shadow: var(--shadow-lg); }
.modal-title { font-size: 17px; font-weight: 800; color: var(--gray-900); margin-bottom: 8px; }
.modal-body  { font-size: 14px; color: var(--gray-500); line-height: 1.6; margin-bottom: 20px; white-space: pre-line; }
.modal-actions { display: flex; gap: 10px; }
.modal-btn-cancel  { flex: 1; height: 48px; background: var(--gray-100); color: var(--gray-700); border: none; border-radius: var(--radius-xl); font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--font); }
.modal-btn-confirm { flex: 1; height: 48px; background: var(--green-700); color: var(--white); border: none; border-radius: var(--radius-xl); font-size: 15px; font-weight: 700; cursor: pointer; font-family: var(--font); }

.toast { position: fixed; top: calc(env(safe-area-inset-top) + 16px); left: 50%; transform: translateX(-50%) translateY(-10px); background: var(--green-700); color: var(--white); padding: 11px 20px; border-radius: 24px; font-size: 13px; font-weight: 600; opacity: 0; transition: all .25s; pointer-events: none; white-space: nowrap; z-index: 1200; box-shadow: var(--shadow-lg); }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.hidden { display: none !important; }

/* ══ NOTIFICA IN-APP ═══════════════════════════════════════════════════════ */
.notif-banner {
  position: fixed; top: calc(env(safe-area-inset-top) + 8px); left: 50%;
  transform: translateX(-50%) translateY(calc(-100% - env(safe-area-inset-top) - 20px));
  z-index: 1000; max-width: 360px; width: calc(100% - 32px);
  background: var(--white); border-radius: 18px;
  box-shadow: 0 8px 32px rgba(0,0,0,.18); border: 1.5px solid var(--orange-bg);
  display: flex; align-items: center; gap: 12px; padding: 13px 16px;
  transition: transform .35s cubic-bezier(.34,1.56,.64,1); pointer-events: none;
}
.notif-banner.show { transform: translateX(-50%) translateY(0); pointer-events: auto; }
.notif-icon { width: 38px; height: 38px; border-radius: 11px; background: var(--orange-bg); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.notif-icon svg { width: 18px; height: 18px; color: var(--orange); }
.notif-text { flex: 1; min-width: 0; }
.notif-label { font-size: 11px; font-weight: 700; color: var(--orange); text-transform: uppercase; letter-spacing: .04em; }
.notif-msg   { font-size: 13px; font-weight: 600; color: var(--gray-900); margin-top: 1px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.notif-close { width: 26px; height: 26px; border-radius: 50%; background: var(--gray-100); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--gray-500); flex-shrink: 0; font-size: 14px; line-height: 1; -webkit-tap-highlight-color: transparent; }
.notif-close:active { background: var(--gray-200); }

/* ══ SHIMMER LOADING ═════════════════════════════════════════════════════════ */
@keyframes gr-shimmer { 0%,100% { opacity:.15 } 50% { opacity:.38 } }
.stat-loading { display: inline-block; width: 72px; height: 9px; border-radius: 5px; background: currentColor; animation: gr-shimmer 1.5s ease-in-out infinite; vertical-align: middle; }
@keyframes gr-spin { to { transform: rotate(360deg) } }

/* ══ HEADER LOGOUT HINT ══════════════════════════════════════════════════════ */
.header-logout-hint { display: flex; align-items: center; flex-shrink: 0; color: var(--gray-300); margin-left: 4px; transition: color .15s; pointer-events: none; }
.header-left:active .header-logout-hint { color: var(--gray-700); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
