.login-stitch {
  --login-bg: #eff4ff;
  --login-bg-bright: #f8f9ff;
  --login-surface: #ffffff;
  --login-surface-soft: #f8f9ff;
  --login-text: #0b1c30;
  --login-muted: #434655;
  --login-outline: #c3c6d7;
  --login-outline-strong: #737686;
  --login-primary: #004ac6;
  --login-primary-hover: #0053db;
  --login-orange: rgb(236, 88, 41);
  --login-error: #ba1a1a;
  width: 100%;
  min-height: calc(100vh - 132px);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 28px 12px 52px;
  background: linear-gradient(180deg, var(--login-bg) 0%, var(--login-bg-bright) 100%);
  color: var(--login-text);
  font-family: Inter, Arial, Helvetica, sans-serif;
  box-sizing: border-box;
}

.login-stitch *,
.login-stitch *::before,
.login-stitch *::after {
  box-sizing: border-box;
}

/* Mobile: impedisce che un doppio-tap / pressione lunga selezioni tutta la
   pagina (highlight blu). La selezione resta attiva solo sui campi reali. */
.login-stitch {
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.login-stitch input,
.login-stitch textarea,
.login-stitch [contenteditable="true"] {
  -webkit-user-select: text;
  -moz-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}

body.login-stitch-page {
  margin: 0;
  padding: 0;
  background: var(--login-bg, #eff4ff);
}

body.cd-azienda-login-page {
  margin: 0;
  padding: 0;
  background: #eff4ff;
  min-height: 100vh;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

body.cd-azienda-login-page .container {
  width: 100%;
  max-width: none;
  margin: 0;
  padding: 0;
}

body.cd-azienda-login-page .login-stitch,
body.cd-azienda-login-page .login-stitch--compact {
  min-height: 100vh;
  min-height: 100dvh;
  height: 100vh;
  height: 100dvh;
  padding: 18px 16px 12px;
  align-items: flex-start;
  justify-content: center;
  background: #eff4ff;
  overflow: hidden;
}

body.cd-azienda-login-page .login-stitch--compact .login-stitch__shell {
  max-width: 390px;
  margin-top: clamp(12px, 5vh, 42px);
}

body.cd-azienda-login-page .login-stitch--compact .login-stitch__brand {
  margin-bottom: 12px;
}

body.cd-azienda-login-page .login-stitch--compact .login-stitch__logo {
  width: clamp(92px, 18vw, 128px);
}

body.cd-azienda-login-page .login-stitch--compact .login-stitch__card {
  padding: 18px;
}

.login-stitch--standalone {
  min-height: 100vh;
  align-items: center;
  padding: 32px 16px;
}

.login-stitch__shell {
  width: 100%;
  max-width: 424px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

.login-stitch__brand {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 0 auto 22px;
  text-decoration: none;
}

.login-stitch__logo {
  width: clamp(110px, 28vw, 156px);
  height: auto;
  display: block;
  border: 0;
  filter: drop-shadow(0 8px 18px rgba(11, 28, 48, 0.13));
}

.login-stitch__card {
  width: 100%;
  background: var(--login-surface);
  border: 1px solid var(--login-outline);
  border-radius: 8px;
  box-shadow: 0 14px 34px rgba(11, 28, 48, 0.11);
  padding: 24px;
  overflow: hidden;
}

.login-stitch__header {
  margin-bottom: 22px;
}

.login-stitch__title {
  margin: 0 0 6px;
  color: var(--login-text);
  font-size: 22px;
  line-height: 1.25;
  font-weight: 800;
  letter-spacing: 0;
}

.login-stitch__subtitle {
  margin: 0;
  color: var(--login-muted);
  font-size: 14px;
  line-height: 1.45;
  letter-spacing: 0;
}

.login-stitch__form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.login-stitch__field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-stitch__label {
  padding-left: 4px;
  color: var(--login-muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-stitch__control {
  position: relative;
  display: block;
}

.login-stitch__input-icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--login-outline-strong);
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

.login-stitch__input {
  width: 100%;
  height: 46px;
  border: 1px solid var(--login-outline);
  border-radius: 6px;
  background: var(--login-surface);
  color: var(--login-text);
  padding: 0 13px 0 42px;
  font-size: 15px;
  line-height: 1.2;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease, background 160ms ease;
  appearance: none;
}

.login-stitch__input::placeholder {
  color: var(--login-outline-strong);
  opacity: 0.78;
}

.login-stitch__input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.16);
  background: #ffffff;
}

.login-stitch__actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding-top: 2px;
}

.login-stitch__remember {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--login-muted);
  font-size: 13px;
  line-height: 1.3;
  cursor: pointer;
}

.login-stitch__remember input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--login-primary);
}

.login-stitch__link {
  color: var(--login-primary);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 800;
  text-decoration: none;
}

.login-stitch__link:hover,
.login-stitch__link:focus {
  text-decoration: underline;
}

.login-stitch__submit {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 6px;
  background: var(--login-primary);
  color: #ffffff;
  padding: 0 18px;
  font-size: 17px;
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 9px 18px rgba(0, 74, 198, 0.26);
  transition: background 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.login-stitch__submit:hover,
.login-stitch__submit:focus {
  background: var(--login-primary-hover);
  color: #ffffff;
  box-shadow: 0 11px 22px rgba(0, 74, 198, 0.32);
}

.login-stitch__submit:active {
  transform: translateY(1px);
}

.login-stitch__submit .mif-enter {
  font-size: 18px;
  line-height: 1;
}

.login-stitch__message {
  margin: 2px 0 0;
  color: var(--login-error);
  font-size: 13px;
  line-height: 1.35;
  font-weight: 700;
}

.login-stitch__secondary {
  margin-top: 22px;
  padding-top: 20px;
  border-top: 1px solid var(--login-outline);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
}

.login-stitch__secondary-text {
  margin: 0;
  color: var(--login-muted);
  font-size: 14px;
  line-height: 1.4;
}

.login-stitch__key-form {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.login-stitch__key-control {
  position: relative;
  min-width: 0;
}

.login-stitch__key-icon {
  position: absolute;
  right: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--login-primary);
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.login-stitch__key-input {
  width: 100%;
  height: 44px;
  border: 1px solid var(--login-outline);
  border-radius: 6px;
  background: #ffffff;
  color: var(--login-text);
  padding: 0 42px 0 12px;
  font-size: 15px;
  line-height: 1.2;
  font-weight: 600;
  outline: none;
  appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.login-stitch__key-input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.16);
}

.login-stitch__key-submit {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 6px;
  background: var(--login-orange);
  color: #ffffff;
  padding: 0 16px;
  font-size: 13px;
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 7px 15px rgba(236, 88, 41, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.login-stitch__key-submit:hover,
.login-stitch__key-submit:focus {
  color: #ffffff;
  opacity: 0.95;
  box-shadow: 0 9px 18px rgba(236, 88, 41, 0.3);
}

.login-stitch__key-submit:active {
  transform: translateY(1px);
}

.login-stitch__key-form.is-loading {
  opacity: 0.72;
}

.login-stitch__key-form.is-loading .login-stitch__key-submit {
  cursor: wait;
}

.login-stitch__key-result {
  display: none;
  width: 100%;
  text-align: left;
}

.login-stitch__key-result.is-visible {
  display: block;
  margin-top: 2px;
  border: 1px solid var(--login-outline);
  border-radius: 12px;
  background: #ffffff;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(11, 28, 48, 0.08);
}

.login-stitch__key-result.is-error {
  border-color: #ffb4ab;
  background: #fff7f6;
}

.login-stitch__key-result-title {
  padding: 10px 12px;
  border-bottom: 1px solid var(--login-outline);
  color: var(--login-text);
  font-size: 13px;
  line-height: 1.3;
  font-weight: 800;
}

.login-stitch__key-result.is-error .login-stitch__key-result-title {
  color: var(--login-error);
  border-bottom-color: #ffdad6;
}

.login-stitch__key-result-content {
  color: var(--login-muted);
  font-size: 13px;
  line-height: 1.4;
}

.login-stitch__key-result.is-error .login-stitch__key-result-content {
  padding: 12px;
  color: var(--login-error);
  font-weight: 700;
}

.login-stitch__key-result .token-client-picker {
  max-height: min(46vh, 390px);
  border-radius: 12px;
}

.login-stitch__key-result .client-modal-search {
  padding: 12px;
  border-bottom-color: #b4c5ff;
  background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
}

.login-stitch__key-result .client-modal-search__icon {
  left: 26px;
}

.login-stitch__key-result .client-modal-search input {
  border-color: #b4c5ff;
  box-shadow: inset 0 0 0 1px rgba(0, 74, 198, 0.06);
}

.login-stitch__key-result .client-modal-search input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.16);
}

.login-stitch__key-result .client-province-block {
  padding: 0 12px 8px;
}

.login-stitch__key-result .client-name {
  font-size: 15px;
}

.login-stitch__key-result .client-address {
  font-size: 12px;
}

.login-stitch__register-btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 0 18px;
  font-size: 14px;
  line-height: 1;
  font-weight: 800;
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.login-stitch__register-btn {
  background: #e5eeff;
  color: var(--login-primary);
  border: 1px solid #b4c5ff;
}

.login-stitch__register-btn:hover,
.login-stitch__register-btn:focus {
  color: var(--login-primary);
  opacity: 0.95;
  transform: translateY(-1px);
}

.login-stitch__register-btn span {
  font-size: 16px;
  line-height: 1;
}

.login-stitch__register {
  margin: 0;
  color: var(--login-muted);
  font-size: 13px;
  line-height: 1.4;
}

.login-stitch__legal {
  margin: 22px auto 0;
  max-width: 390px;
  text-align: center;
  color: var(--login-muted);
}

.login-stitch__legal-head {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--login-error);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.login-stitch__legal-head span {
  font-size: 16px;
  line-height: 1;
}

.login-stitch__legal-text {
  margin: 0;
  font-size: 12px;
  line-height: 1.55;
}

.login-stitch__legal-text strong {
  color: var(--login-text);
}

.login-stitch--compact {
  min-height: auto;
  padding: 18px 8px 28px;
}

.login-stitch--compact .login-stitch__shell {
  max-width: 390px;
}

.login-stitch--compact .login-stitch__card {
  padding: 20px;
}

.login-stitch--compact .login-stitch__legal {
  display: none;
}

@media (max-width: 640px) {
  .login-stitch {
    min-height: calc(100vh - 116px);
    padding: 20px 10px 36px;
  }

  .login-stitch--standalone {
    min-height: 100vh;
    padding: 24px 10px;
  }

  .login-stitch__logo {
    width: 112px;
  }

  .login-stitch__card {
    padding: 18px;
  }

  .login-stitch__title {
    font-size: 20px;
  }

  .login-stitch__actions {
    align-items: flex-start;
  }

  .login-stitch__submit {
    min-height: 46px;
    font-size: 16px;
  }

  .login-stitch__legal-text {
    font-size: 11px;
  }
}

.login-token-dialog {
  --login-bg: #eff4ff;
  --login-surface: #ffffff;
  --login-surface-soft: #f8f9ff;
  --login-text: #0b1c30;
  --login-muted: #434655;
  --login-outline: #c3c6d7;
  --login-primary: #004ac6;
  --login-primary-hover: #0053db;
  --login-orange: rgb(236, 88, 41);
  --login-error: #ba1a1a;
  max-width: calc(100vw - 28px);
  border: 1px solid var(--login-outline);
  border-radius: 10px;
  overflow: hidden;
  background: var(--login-surface);
  color: var(--login-text);
  font-family: Inter, Arial, Helvetica, sans-serif;
}

.login-token-dialog.shadow-on {
  box-shadow: 0 24px 64px rgba(11, 28, 48, 0.22);
}

.login-token-dialog__title {
  margin: 0;
  padding: 24px 28px 20px;
  border-bottom: 1px solid var(--login-outline);
  background: var(--login-surface);
  color: var(--login-text);
  font-size: 26px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
}

.login-token-dialog__content {
  margin-top: 0 !important;
  padding: 24px 28px 22px;
  background: linear-gradient(180deg, var(--login-surface) 0%, var(--login-surface-soft) 100%);
}

.login-token-dialog__actions {
  margin-top: 0 !important;
  padding: 14px 28px 18px;
  border-top: 1px solid var(--login-outline);
  background: var(--login-surface);
}

.login-token-dialog__ok {
  min-width: 78px;
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  background: #e5eeff;
  color: var(--login-primary);
  font-weight: 800;
  letter-spacing: 0;
}

.login-token-dialog__ok:hover,
.login-token-dialog__ok:focus {
  background: #dbe1ff;
  color: var(--login-primary);
}

.login-token-dialog .closer {
  top: 12px;
  right: 12px;
  border-radius: 999px;
  background: #eef3ff;
  color: var(--login-primary);
}

.token-key-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}

.token-key-form__label {
  padding-left: 4px;
  color: var(--login-muted);
  font-size: 12px;
  line-height: 1.35;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
}

.token-key-form__control {
  position: relative;
}

.token-key-form__icon {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--login-primary);
  font-size: 20px;
  line-height: 1;
  pointer-events: none;
}

.token-key-form__input {
  width: 100%;
  height: 50px;
  border: 1px solid var(--login-outline);
  border-radius: 6px;
  background: #ffffff;
  color: var(--login-text);
  padding: 0 48px 0 14px;
  font-size: 20px;
  line-height: 1.2;
  font-weight: 600;
  outline: none;
  appearance: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.token-key-form__input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.16);
}

.token-key-form__submit {
  min-height: 46px;
  align-self: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 0;
  border-radius: 6px;
  background: var(--login-orange);
  color: #ffffff;
  padding: 0 24px;
  font-size: 15px;
  line-height: 1;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 9px 18px rgba(236, 88, 41, 0.24);
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}

.token-key-form__submit:hover,
.token-key-form__submit:focus {
  color: #ffffff;
  opacity: 0.95;
  box-shadow: 0 11px 22px rgba(236, 88, 41, 0.3);
}

.token-key-form__submit:active {
  transform: translateY(1px);
}

.login-token-dialog--client .login-token-dialog__content {
  padding: 0;
  background: var(--login-surface);
}

.token-client-picker {
  max-height: min(62vh, 520px);
  overflow: auto;
  border-radius: 10px;
  scrollbar-width: thin;
  scrollbar-color: #b4c5ff transparent;
}

.client-modal-search {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--login-outline);
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(8px);
}

.client-modal-search__icon {
  position: absolute;
  left: 34px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--login-primary);
  font-size: 18px;
  line-height: 1;
  pointer-events: none;
}

.client-modal-search input {
  width: 100%;
  height: 48px;
  border: 1px solid #b4c5ff;
  border-radius: 8px;
  background: #ffffff;
  color: var(--login-text);
  padding: 0 14px 0 42px;
  font-size: 15px;
  line-height: 1.2;
  outline: none;
  appearance: none;
  box-sizing: border-box;
}

.client-modal-search input:focus {
  border-color: var(--login-primary);
  box-shadow: 0 0 0 3px rgba(0, 74, 198, 0.16);
}

.client-province-block {
  padding: 0 20px 10px;
}

.token-client-province {
  min-height: 38px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 0 8px;
  padding: 0 14px;
  border: 1px solid #dbe1ff;
  border-radius: 10px;
  background: #e5eeff;
  color: var(--login-primary);
  font-size: 14px;
  line-height: 1.2;
  font-weight: 800;
  cursor: pointer;
}

.token-client-province::after {
  content: "+";
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: #ffffff;
  color: var(--login-primary);
  font-weight: 900;
}

.client-link {
  display: block;
  margin: 0 0 8px;
  padding: 12px 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: #ffffff;
  color: var(--login-primary);
  text-decoration: none;
  transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

/* nearby (geolocation) suggestion */
.token-client-province--near {
  background: #fff3ec;
  border-color: #f3b89f;
  color: #b4461f;
  cursor: default;
}
.token-client-province--near::after { content: ""; background: transparent; }
.client-link--near { border-color: #f3b89f; background: #fff8f4; }

.client-link:hover,
.client-link:focus {
  border-color: #dbe1ff;
  background: #f8f9ff;
  color: var(--login-primary);
  box-shadow: 0 8px 18px rgba(11, 28, 48, 0.08);
  transform: translateY(-1px);
}

.client-row-top {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.client-dot {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--login-primary);
}

.client-tag {
  max-width: 150px;
  min-height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0 11px;
  border-radius: 999px;
  background: #ffca28;
  color: #111827;
  font-size: 11px;
  line-height: 1;
  font-weight: 900;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-name {
  min-width: 0;
  color: var(--login-primary);
  font-size: 18px;
  line-height: 1.25;
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.client-address {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  margin: 8px 0 0 25px;
  color: var(--login-muted);
  font-size: 13px;
  line-height: 1.35;
}

.client-address .mif-location {
  flex: 0 0 auto;
  margin-top: 1px;
  color: #9aa3b8;
}

@media (max-width: 640px) {
  .login-token-dialog__title {
    padding: 20px 18px 16px;
    font-size: 22px;
  }

  .login-token-dialog__content {
    padding: 18px;
  }

  .login-token-dialog__actions {
    padding: 12px 18px 16px;
  }

  .token-key-form__input {
    height: 48px;
    font-size: 18px;
  }

  .client-modal-search {
    padding: 14px 14px 12px;
  }

  .client-modal-search__icon {
    left: 28px;
  }

  .client-province-block {
    padding: 0 14px 8px;
  }

  .client-row-top {
    align-items: flex-start;
    flex-wrap: wrap;
  }

  .client-dot {
    align-self: center;
  }

  .client-name {
    width: 100%;
    padding-left: 16px;
    font-size: 16px;
    white-space: normal;
  }

  .client-address {
    margin-left: 16px;
    font-size: 12px;
  }
}
