/* Cornice: telefono (barra in basso) e desktop (barra laterale chiara, come l'intestazione di azienda.borz.it). */

.app { min-height: 100dvh; }
.shell { min-height: 100dvh; }

.main {
  padding: calc(16px + var(--safe-t)) max(18px, env(safe-area-inset-right)) calc(var(--tabbar-h) + 28px) max(18px, env(safe-area-inset-left));
  outline: none;
  max-width: 100%;
}

/* ---- Barra laterale (desktop) ---- */
.side { display: none; }

/* ---- Barra in basso (telefono): bianca, voce attiva con indicatore blu ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  height: var(--tabbar-h); padding: 0 max(4px, env(safe-area-inset-right)) var(--safe-b) max(4px, env(safe-area-inset-left));
  background: var(--surface); border-top: 1px solid var(--line);
}
.tab {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  min-height: 64px; color: var(--muted); text-decoration: none; font: 600 12.5px/1.1 var(--font-d); letter-spacing: .025em;
  position: relative;
}
.tab::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: transparent; }
.tab .ico { width: 24px; height: 24px; }
.tab-ico { position: relative; display: grid; place-items: center; width: 48px; height: 30px; border-radius: var(--pill); }
.tab.on { color: var(--ink); }
.tab.on::before { background: var(--indicator); }
.tab.on .ico { color: var(--link); }
.tab-new .tab-ico { background: var(--primary); color: var(--on-primary); }
.tab-new.on .ico, .tab-new .ico { color: var(--on-primary); }
.badge {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 7px; border-radius: var(--pill);
  background: var(--tint); color: var(--link); font: 600 12px/1 var(--font-d);
}
.badge-dot { position: absolute; top: -5px; right: 0; min-width: 20px; height: 20px; font-size: 11px; background: var(--primary); color: var(--on-primary); }

/* ---- Intestazioni di pagina: titolo grande e pulito, Info in alto a destra ---- */
.page-head {
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "back titles tools" "actions actions actions";
  align-items: start; column-gap: 8px; margin: 4px 0 22px;
}
.page-head .back { grid-area: back; margin-left: -10px; }
.page-titles { grid-area: titles; min-width: 0; }
.page-tools { grid-area: tools; display: flex; gap: 6px; align-items: center; }
.page-actions { grid-area: actions; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 14px; }
.page-actions:empty { display: none; }
.page-title { font: 600 30px/1.08 var(--font-d); letter-spacing: -.025em; }
.page-sub { color: var(--muted); margin-top: 8px; max-width: 64ch; }

.mobile-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.mobile-brand { display: flex; align-items: center; gap: 12px; font: 600 26px/1.1 var(--font-d); letter-spacing: -.025em; }
.mobile-brand .brand-logo { height: 34px; }

/* Pulsante Info: anello sottile come i pulsanti secondari del sito */
.info-btn {
  display: inline-grid; place-items: center; width: 44px; height: 44px; flex: none; padding: 0;
  border: 0; border-radius: 50%; background: var(--surface); color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s, color .2s;
}
.info-btn:hover, .info-btn[aria-expanded="true"] { box-shadow: inset 0 0 0 1px var(--ring-hover); color: var(--link-hover); }
.info-i { font: 600 19px/1 var(--font-d); font-style: normal; }
@media (max-width: 899px) { .info-btn { width: 48px; height: 48px; } }

/* ---- Accesso ---- */
.app-auth { display: grid; place-items: center; padding: calc(24px + var(--safe-t)) 18px calc(24px + var(--safe-b)); }
.auth-wrap { width: 100%; display: grid; place-items: center; }
.auth-card {
  width: min(440px, 100%); background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl);
  padding: 28px 28px 26px; box-shadow: var(--shadow);
}
.auth-brand { display: flex; align-items: center; gap: 14px; margin: 0 0 28px; }
.auth-brand .brand-logo { height: 52px; }
.auth-brand-name { flex: 1; font: 600 12px/1.2 var(--font-d); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
.auth-title { font: 600 34px/1.05 var(--font-d); letter-spacing: -.025em; margin-bottom: 10px; }
.auth-intro { color: var(--muted); margin-bottom: 24px; }
.auth-foot { margin-top: 24px; padding-top: 18px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.auth-foot a { font-weight: 600; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 256px minmax(0, 1fr); }
  .tabbar { display: none; }
  .main { padding: 36px 40px 56px; }

  .side {
    display: flex; flex-direction: column; position: sticky; top: 0; height: 100dvh; overflow-y: auto;
    background: var(--surface); color: var(--nav-ink); padding: 22px 14px 16px; border-right: 1px solid var(--line);
  }
  .side-brand { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; padding: 0 12px 26px; text-decoration: none; color: var(--muted); }
  .side-brand .brand-logo { height: 46px; }
  .side-app { font: 600 11.5px/1.2 var(--font-d); letter-spacing: .2em; text-transform: uppercase; color: var(--muted); }
  .side-list { display: grid; gap: 2px; }
  .side-link {
    display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px; border-radius: var(--r);
    color: var(--nav-ink); text-decoration: none; font: 500 15px var(--font-d); letter-spacing: .01em; position: relative;
    transition: background-color .2s, color .2s;
  }
  .side-link .ico { width: 20px; height: 20px; color: var(--muted); }
  .side-link:hover { background: var(--surface-2); color: var(--ink); }
  .side-link.on { background: var(--tint); color: var(--ink); font-weight: 600; }
  .side-link.on::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 2px; background: var(--indicator); }
  .side-link.on .ico { color: var(--link); }
  .side-label { flex: 1; }
  .side-foot { margin-top: auto; padding: 16px 4px 0; display: grid; gap: 12px; border-top: 1px solid var(--line); }
  .side-user { display: grid; padding: 0 8px; font: 600 14px var(--font-d); color: var(--ink); }
  .side-role { font: 400 13px var(--font); color: var(--muted); }
  .side-theme { display: flex; }
  .side-theme .seg { flex: 1; justify-content: center; gap: 4px; padding: 0 4px; font-size: 13px; }
  .side-theme .seg .ico { width: 16px; height: 16px; }

  /* titolo a sinistra, azioni a destra, Info in fondo; se manca spazio le azioni vanno sotto */
  .page-head { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-bottom: 28px; }
  .page-head .back { order: 0; }
  .page-titles { order: 1; flex: 1 1 260px; }
  .page-actions { order: 2; margin-top: 0; justify-content: flex-end; }
  .page-tools { order: 3; }
  .page-title { font-size: 40px; }
  .mobile-top { display: none; }
}
