/* Variabili comuni. La dimensione di partenza dei pulsanti si cambia qui. */
:root {
  color-scheme: light;
  --ink: #233338;
  --muted: #59696b;
  --paper: #f4f6f5;
  --panel: #fff;
  --line: #cdd5d3;
  --accent: #164d52;
  --accent-dark: #0d383e;
  --focus: #187b8d;
  --danger: #962f2d;
  --tile-size: 118px;
  font-family: Inter, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

*, *::before, *::after { box-sizing: border-box; }
body { margin: 0; font-size: 15px; line-height: 1.45; }
button, input, select, textarea { font: inherit; }
button, a { touch-action: manipulation; }
a { color: var(--accent); text-underline-offset: .18em; }
button { cursor: pointer; }
button:disabled { cursor: default; }
:where(a, input, select, textarea, button):focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 3px;
}
input:not([type=checkbox]):not([type=radio]), select, textarea {
  min-width: 0;
  padding: .62rem .75rem;
  color: var(--ink);
  background: white;
  border: 1px solid #aebcba;
  border-radius: 5px;
}
label { font-weight: 590; }
.button-link {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--accent);
}
.button-link svg { width: 16px; height: 16px; fill: none; stroke: currentColor; stroke-width: 1.6; }
table { width: 100%; border-collapse: collapse; text-align: start; }
th, td { padding: .65rem .75rem; border-bottom: 1px solid #dbe1df; text-align: start; }
th { color: var(--muted); font-weight: 600; }
.notice { margin: 0; padding: .65rem .95rem; color: var(--ink); background: #e5efeb; border: 1px solid #bdcec6; border-radius: 5px; }
.page-messages { position: relative; z-index: 2; padding: .75rem; }

/* Il documento fa scorrere le immagini. La maschera di accesso usa il viewport. */
.login-page { background: #e7ebea; }
.gallery { overflow: hidden; }
.gallery-frame {
  position: relative;
  isolation: isolate;
  height: 100vh;
  height: 100svh;
  min-height: 260px;
  overflow: hidden;
  background: linear-gradient(133deg, #f3f6f4 0%, #e5ebea 68%, #d8e0de 100%);
}
.gallery-frame:nth-child(even) { background: linear-gradient(110deg, #e3e7e5, #f2f3ed 65%); }
.gallery-frame::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image: linear-gradient(to right, #2647400d 1px, transparent 1px),
                    linear-gradient(to bottom, #2647400d 1px, transparent 1px);
  background-size: 68px 68px;
  mask-image: linear-gradient(125deg, #000 0%, #0006 35%, #0001 58%, #0008 100%);
}
.gallery-image {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.16);
  mix-blend-mode: multiply;
  opacity: .94;
}
.crop-left { object-position: 20% center; transform-origin: 20% center; }
.crop-center { object-position: 50% center; transform-origin: 50% center; }
.crop-right { object-position: 80% center; transform-origin: 80% center; }
.login-layer {
  position: fixed;
  inset: var(--visible-top, 0) 0 auto;
  height: 100vh;
  height: var(--visible-height, 100dvh);
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(.75rem, env(safe-area-inset-top)) max(.8rem, env(safe-area-inset-right))
           max(.75rem, env(safe-area-inset-bottom)) max(.8rem, env(safe-area-inset-left));
  pointer-events: none;
  container-type: size;
}
.login-panel {
  margin: auto 0;
  flex: 0 1 auto;
  width: min(100%, 324px);
  max-height: 100%;
  min-height: 0;
  overflow-y: auto;
  padding: 31px 29px 19px;
  pointer-events: auto;
  background: #fcfdfcf7;
  border: 1px solid #ffffffdb;
  border-radius: 9px;
  box-shadow: 0 18px 54px #162c3029, 0 2px 8px #162c3014, 0 0 0 1px #2739341a;
}
.login-form { display: grid; gap: 17px; }
.login-field { display: grid; gap: 6px; }
.login-field label { font-size: 13px; font-weight: 620; }
.input-shell { position: relative; }
.input-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: #617576;
  stroke-width: 1.6;
  stroke-linecap: round;
}
.login-field input:not([type=checkbox]):not([type=radio]) {
  display: block;
  width: 100%;
  height: 44px;
  padding: 0 12px 0 38px;
  border-color: #afbdbb;
  background: #fff;
  font-size: 16px;
  line-height: 1.2;
}
.login-field input:focus-visible { outline-width: 2px; outline-offset: 1px; }
.login-submit {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 44px;
  margin-top: 3px;
  padding: .58rem 2.1rem;
  color: white;
  border: 1px solid #124448;
  border-radius: 5px;
  background: var(--accent);
  box-shadow: inset 0 1px 0 #ffffff12;
  font-size: 14px;
  font-weight: 650;
}
.login-submit:hover { background: var(--accent-dark); }
.login-submit:active { transform: translateY(1px); }
.login-submit svg {
  position: absolute;
  right: 13px;
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.public-links {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 13px;
  gap: 0;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1.2;
}
.public-links > * { position: relative; padding: 5px 10px; }
.public-links > * + *::before {
  content: "";
  position: absolute;
  left: 0;
  top: calc(50% - 4px);
  height: 8px;
  width: 1px;
  background: #c7cecc;
}
.public-links span { color: #667372; }
.public-links a { font-weight: 600; }
.form-error { margin: 0; font-size: 13px; line-height: 1.4; color: var(--danger); }

/* Il selettore conserva tre colonne anche su telefoni stretti. */
.selector-page { min-height: 100vh; min-height: 100svh; display: flex; flex-direction: column; }
.workspace-header {
  min-height: 59px;
  padding: 11px clamp(14px, 3.4vw, 55px);
  border-bottom: 1px solid #d3dbd8;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem 1.3rem;
  background: #fafbf9;
}
.workspace-brand {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  color: #213b3e;
  font-size: 14px;
  font-weight: 740;
  letter-spacing: .085em;
  text-decoration: none;
}
.workspace-controls { display: flex; align-items: center; gap: clamp(.55rem, 2.2vw, 1.8rem); }
.workspace-controls form { margin: 0; }
.workspace-controls a, .workspace-controls button {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  font-size: 13px;
  font-weight: 560;
  color: var(--accent);
  text-decoration: none;
}
.workspace-controls a:hover, .workspace-controls button:hover { text-decoration: underline; }
.selector-main {
  flex: 1;
  display: grid;
  place-content: center;
  padding: 24px 13px;
  background: radial-gradient(ellipse at 50% 36%, #fefffd 4%, #f2f5f2 70%);
}
.selector-section h1 {
  margin: 0 0 17px;
  font-size: 22px;
  font-weight: 620;
  line-height: 1.2;
  letter-spacing: -.035em;
}
.app-grid {
  --gap: clamp(5px, 2vw, 12px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--gap);
  width: min(calc(100vw - 26px), calc(var(--tile-size) * 3 + var(--gap) * 2));
}
.app-tile {
  aspect-ratio: 1/1;
  min-width: 0;
  overflow: hidden;
  padding: clamp(3px, 1vw, 10px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: clamp(3px, 1vw, 8px);
  color: #214b4e;
  border: 1px solid #b4c7c2;
  border-radius: 8px;
  background: linear-gradient(#fff, #f2f6f3);
  box-shadow: 0 2px 2px #203b3212, inset 0 1px 0 #fff;
  font-size: clamp(12px, 3.1vw, 13px);
  font-weight: 600;
  line-height: 1.12;
  text-align: center;
  text-decoration: none;
}
.app-tile span { max-width: 100%; overflow-wrap: anywhere; }
.app-tile.available:hover { border-color: var(--accent); background: #eef4f0; }
.app-tile.available:active { transform: translateY(1px); box-shadow: inset 0 1px 3px #203b3224; }
.app-tile.unavailable { color: #5d6b68; background: #f1f3f0; border-color: #c8d1cc; }
.app-tile.unavailable .app-icon { filter: grayscale(.85); opacity: .72; }
.app-icon { display: block; width: min(66px, 75%); height: auto; }
.app-tile.empty { border-color: #d8dfda; background: #ebeeea; box-shadow: inset 0 1px 2px #243c3207; }

@media (max-width: 480px) {
  .gallery-frame::after { background-size: 46px 46px; }
  .gallery-image { transform: none; }
  .login-panel { width: min(100%, 308px); padding: 27px 24px 17px; }
  .workspace-brand { font-size: 12px; gap: .35rem; }
  .workspace-brand img { width: 22px; height: 22px; }
  .workspace-controls a, .workspace-controls button { font-size: 12px; }
}
@media (max-height: 450px) {
  .login-layer { padding-top: 5px; padding-bottom: 5px; }
}
@container (max-height: 450px) {
  .login-panel { padding: 12px 21px 7px; }
  .login-form { gap: 7px; }
  .login-field { gap: 2px; }
  .public-links { margin-top: 4px; }
}
@media (forced-colors: active) {
  .login-panel, .app-tile { border: 1px solid CanvasText; }
  .app-tile:disabled { border-color: GrayText; color: GrayText; }
}

.portal-error {
  width: min(100%, 42rem);
  margin: max(55px, 17vh) auto 0;
  padding: 0 1.5rem;
  text-align: center;
}
.portal-error h1 { margin: 0 0 1rem; font-size: clamp(1.4rem, 4vw, 2rem); }
