[data-online] #local-nav { display: none; }
#notifiche-portale {
  position: fixed;
  inset: var(--masthead-offset, 72px) max(12px, env(safe-area-inset-right)) auto auto;
  z-index: 8;
  display: grid;
  gap: 8px;
  width: min(390px, calc(100% - 24px));
  max-height: calc(100dvh - var(--masthead-offset, 72px) - 16px);
  overflow: auto;
  pointer-events: none;
}
.portal-notice {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 12px;
  color: #fff;
  background: #17243b;
  border: 1px solid var(--line);
  border-inline-start: 3px solid #a6c9ff;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgb(3 9 23 / 34%);
  pointer-events: auto;
}
.portal-notice[data-state=errore] { border-inline-start-color: var(--error); }
.portal-notice[data-state=avviso] { border-inline-start-color: #ffc889; }
.portal-notice[data-state=ok] { border-inline-start-color: var(--success); }
.portal-notice > div { min-width: 0; }
.portal-notice strong { font-size: 13px; }
.portal-notice p { margin-top: 2px; color: var(--muted); font-size: 13px; }
.portal-notice button {
  flex: none;
  min-height: 44px;
  padding: 0 10px;
  color: inherit;
  background: var(--glass);
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 12px;
}
.portal-notice button:hover { background: var(--glass-active); }
.portal-live { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.portal-loader {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: 0;
  z-index: 20;
  background: rgb(5 10 24 / 78%);
  color: inherit;
}
.portal-loader[open] { display: grid; place-items: center; }
.portal-loader::backdrop { background: transparent; }
.portal-loader-status {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(100%, 400px);
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #141d31;
  box-shadow: 0 12px 32px rgb(0 0 0 / 35%);
}
.portal-loader-status::before { margin: 0; width: 1.15em; height: 1.15em; }
.portal-loader-status:focus { outline: none; }
[data-online] #inizio { padding-block-end: calc(36px + var(--workflow-footer-size, 84px)); }
[data-online] .workflow-footer {
  position: fixed;
  inset: auto 0 0;
  z-index: 2;
  margin: 0;
  padding-block: 8px max(8px, env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: #0a1020;
}
#stato-bozza { margin-block: 0 6px; }
.draft-toolbar { display: grid; justify-items: end; gap: 8px; margin-bottom: 12px; }
.draft-toolbar .portal-feedback { max-inline-size: 32rem; }
.draft-dialog { width: min(460px, calc(100% - 32px)); color: inherit; background: #141d31; }
.draft-dialog::backdrop { background: rgb(5 10 24 / 78%); }
.draft-dialog .button-group { justify-content: flex-end; }
.draft-dialog .primary { width: auto; }
.masthead-session {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-inline-start: auto;
  min-width: 0;
  max-width: min(22rem, 32vw);
}
.masthead-identity, .masthead-logout, .masthead-menu-toggle {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: inherit;
  background: transparent;
}
.masthead-identity {
  display: grid;
  align-content: center;
  min-width: 0;
  padding: 5px 10px;
  text-align: start;
  line-height: 1.35;
}
.masthead-identity :first-child { font-weight: 600; }
.masthead-identity :last-child { color: var(--muted); font-size: 12px; }
.masthead-identity:hover, .masthead-logout:hover, .masthead-menu-toggle:hover, .masthead-identity[aria-current=page] {
  background: var(--glass-active);
}
.masthead-identity[aria-current=page] { box-shadow: inset 0 -2px var(--accent); }
.masthead-logout, .masthead-menu-toggle {
  flex: 0 0 44px;
  width: 44px;
  display: grid;
  place-items: center;
  color: var(--muted);
}
.masthead-menu-toggle { display: none; }
.masthead-logout[aria-busy=true] svg { display: none; }
.masthead-logout[aria-busy=true]::after { margin: 0; }

.mobile-menu {
  inset: 0;
  width: 100%;
  height: 100%;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: max(12px, env(safe-area-inset-top)) 0 max(20px, env(safe-area-inset-bottom));
  border: 0;
  border-radius: 0;
  overflow: auto;
  overscroll-behavior: contain;
  color: inherit;
  background: radial-gradient(ellipse at top left, #1a2e52, #0d1426 72%);
}
body:has(.mobile-menu[open]) { overflow: hidden; }
.mobile-menu .shell { max-width: 520px; }
.mobile-menu-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding-block-end: 14px;
  border-bottom: 1px solid var(--line);
}
.mobile-menu-top h2 { margin: 0; }
.mobile-menu-body { display: grid; gap: 18px; padding-block-start: 18px; }
.mobile-menu-account { display: grid; gap: 2px; overflow-wrap: anywhere; }
.mobile-menu-account span { color: var(--muted); font-size: 13px; }
.mobile-menu .masthead-nav { display: grid; gap: 8px; padding: 0; border: 0; }
.mobile-menu .masthead-nav button {
  min-height: 50px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  text-align: start;
}

.cloud-area .panel { margin-block: clamp(20px, 4vw, 40px) 32px; }
.cloud-login { max-width: 430px; margin-inline: auto; }
body[data-online]:has(#cloud-area:not([hidden]) > #cloud-login:not([hidden])) {
  display: flex;
  flex-direction: column;
}
.cloud-area:has(> #cloud-login:not([hidden])) {
  display: grid;
  flex: 1;
  place-items: center;
  padding-block: 20px max(20px, env(safe-area-inset-bottom));
}
.cloud-area > #cloud-login { width: min(100%, 430px); margin: 0; }
#cloud-login-form, #cloud-password, #cloud-content, #cloud-content form { display: grid; gap: 16px; }
#cloud-login-form { margin-top: 18px; }
#cloud-password { margin-top: 20px; }
#cloud-password-title { color: var(--muted); font-size: 15px; }
#cloud-content > p:not(.portal-feedback), .cloud-history-row p:not(.portal-feedback) { color: var(--muted); }
#cloud-content > .secondary, #cloud-content form .secondary { justify-self: start; }
#cloud-content .panel { margin-block: 0; }
#cloud-content form { max-width: 480px; border-top: 1px solid var(--line); padding-top: 18px; }
#cloud-user-edit-form { display: grid; gap: 14px; margin-top: 16px; }
#cloud-user-edit-form .button-group { margin: 0; }
.portal-feedback {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--field);
  font-size: 13px;
}
.portal-feedback[data-state=errore],
:is(#messaggio, #stato-conferma, #stato-convocazioni)[data-state=errore]:not(:empty) {
  border: 1px solid rgb(255 170 170 / 38%);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgb(189 10 10 / 13%);
}
.portal-feedback[data-state=ok] {
  border-color: rgb(167 228 194 / 34%);
  background: rgb(24 110 67 / 16%);
}
.portal-feedback.masthead-feedback { margin: 0 auto 8px; }
.portal-feedback:empty {
  display: block;
  position: absolute;
  inline-size: 1px;
  block-size: 1px;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  clip-path: inset(50%);
}
.portal-feedback:focus { outline: 2px solid currentColor; outline-offset: 2px; }
.cloud-history-row { padding-bottom: 14px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.cloud-history-row p { margin-top: 6px; }
.cloud-history-row .button-group { margin-top: 10px; }
.cloud-history-row .portal-feedback:not(:empty) { margin-top: 10px; }
.cloud-user-summary { display: flex; align-items: baseline; gap: 10px; }
.cloud-user-role { margin-inline-start: 8px; color: var(--muted); font-size: 13px; }
.cloud-user-status {
  flex: 0 0 10px;
  width: 10px;
  height: 10px;
  border: 2px solid #70dfa5;
  border-radius: 50%;
  background: #70dfa5;
}
.cloud-user-status[data-state=disattivato] { border-color: #ff828c; background: transparent; }
.history-draft-actions { display: flex; flex-wrap: wrap; gap: 6px; max-inline-size: 100%; }
.history-delete { color: var(--error); border-color: rgb(255 170 170 / 38%); }

body.audit-view { display: flex; flex-direction: column; block-size: 100dvh; }
.audit-view > .masthead { flex: none; }
.audit-view .cloud-area, .audit-view #cloud-account {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-block-size: 0;
}
.audit-view .cloud-area { padding-block-end: 10dvh; }
.audit-view #cloud-content {
  flex: 1;
  min-block-size: 0;
  grid-template-rows: auto minmax(0, 1fr) auto;
  margin-block-end: 0;
}
.audit-toolbar { display: grid; justify-items: start; gap: 12px; }
.audit-toolbar > .portal-feedback { justify-self: stretch; flex-basis: 100%; }
.audit-scroll {
  min-block-size: 0;
  overflow: auto;
  overscroll-behavior-y: contain;
  scrollbar-gutter: stable;
}
.audit-scroll:focus-visible { outline-offset: -2px; }
.audit-scroll .audit-list { max-height: none; overflow: visible; }

@media (max-height: 500px) {
  .audit-view #cloud-content { margin-block-start: 12px; padding-block: 12px; gap: 10px; }
  .audit-toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
}

@media (max-width: 780px) {
  [data-online] .masthead-inner {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    min-height: 60px;
    gap: 8px;
    padding-block: 8px;
  }
  [data-online] .masthead-brand { grid-column: 1; grid-row: 1; width: auto; min-width: 0; min-height: 44px; }
  #cloud-nav { grid-column: 1 / -1; grid-row: 2; }
  .masthead-session { grid-column: 2; grid-row: 1; max-width: min(37vw, 260px); }
}
@media (max-width: 520px) {
  [data-online] .masthead-inner { min-height: 52px; row-gap: 2px; padding-block: 4px; }
  [data-online] .masthead-brand { gap: 8px; }
  [data-online] .masthead-logo { width: clamp(62px, 19vw, 84px); }
  [data-online] .masthead-label { min-width: 0; border: 0; padding: 0; font-size: clamp(12px, 3.2vw, 14px); line-height: 1.25; text-wrap: balance; }
  .masthead-identity { font-size: 12px; padding-inline: 6px; }
  .masthead-identity span { min-width: 0; overflow-wrap: anywhere; }

  #cloud-login {
    padding: clamp(16px, 5vw, 24px);
    border-radius: 20px;
    background: linear-gradient(145deg, #1a2a46, #151d30);
    box-shadow: 0 14px 32px rgb(4 9 22 / 26%);
  }
  #cloud-login h2 { font-size: clamp(20px, 6vw, 25px); }
  #cloud-login-form { gap: 14px; }
  #cloud-login-form input { min-height: 48px; margin-top: 6px; }
  #cloud-login-form .primary { justify-content: center; min-height: 48px; background: #294770; font-weight: 600; }
  #cloud-login-form .primary:hover:not(:disabled) { background: #345681; }
  #cloud-login-form .primary:disabled { background: var(--glass); }
}

@media (max-width: 640px), (max-height: 520px) and (pointer: coarse) {
  .masthead #cloud-nav { display: none; }
  .masthead-menu-toggle { display: grid; place-items: center; padding: 0; }
  .masthead-session { max-width: min(62vw, 22rem); gap: 4px; }
  [data-online] .masthead-inner:has(.masthead-menu-toggle:not([hidden])) .masthead-brand { gap: 6px; }
  [data-online] .masthead-inner:has(.masthead-menu-toggle:not([hidden])) .masthead-logo { width: clamp(44px, 14vw, 84px); }
  [data-online] .masthead-inner:has(.masthead-menu-toggle:not([hidden])) .masthead-label {
    font-size: clamp(11px, 3vw, 14px);
  }
}

@media (max-width: 520px), (max-height: 520px) and (pointer: coarse) {
  [data-online] #inizio { padding-block: 16px calc(20px + var(--workflow-footer-size, 72px)); }
  [data-online] .workflow-footer { padding-block: 4px max(4px, env(safe-area-inset-bottom)); }
  [data-online] .workflow-steps {
    display: flex;
    justify-content: center;
    gap: 4px;
    max-inline-size: 22rem;
  }
  [data-online] .workflow-steps li { flex: 0 0 44px; min-width: 0; }
  [data-online] .workflow-steps li:has([aria-current=step]) { flex: 0 1 auto; }
  [data-online] .workflow-steps button {
    justify-content: center;
    min-height: 44px;
    padding: 0;
    background: transparent;
  }
  [data-online] .workflow-steps .workflow-number { width: 24px; height: 24px; }
  [data-online] .workflow-steps button:not([aria-current]):enabled:hover { background: transparent; }
  [data-online] .workflow-steps button:enabled:hover .workflow-number { border-color: currentColor; }
  [data-online] .workflow-label { display: none; }
  [data-online] .workflow-steps button[aria-current=step] {
    gap: 4px;
    padding: 4px 10px 4px 8px;
    border-radius: var(--radius-pill);
    background: var(--accent);
  }
  [data-online] .workflow-steps [aria-current=step] .workflow-number {
    border: 0;
    background: transparent;
  }
  [data-online] .workflow-steps [aria-current=step] .workflow-label {
    display: block;
    min-width: 0;
    line-height: 1.2;
    overflow-wrap: anywhere;
  }
  #stato-bozza { margin-bottom: 2px; font-size: 11px; }
}

@media (max-width: 360px) {
  .masthead-identity { font-size: 11px; padding-inline: 5px; }
  .masthead-logout, .masthead-menu-toggle { flex-basis: 40px; width: 40px; }
}
