:root {
  --orange: #F05A28;
  --orange-soft: rgba(240, 90, 40, 0.12);
  --bg: #F5F5F7;
  --surface: #FFFFFF;
  --surface-alt: #ECECEF;
  --surface-muted: #F2F2F4;
  --border: #E4E4E8;
  --text: #111114;
  --muted: #6E6E73;
  --shadow: 0 18px 45px rgba(17, 17, 20, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  height: 100%;
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
}

body {
  min-height: 100dvh;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", sans-serif;
  touch-action: manipulation;
}

button,
input,
textarea,
select {
  font: inherit;
}

input,
textarea,
select {
  font-size: 16px;
}

.is-hidden {
  display: none !important;
}

.splash-screen {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.35s ease, visibility 0.35s ease;
}

.splash-screen.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.splash-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.splash-logo {
  width: 96px;
  height: 96px;
  object-fit: contain;
}

.splash-spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(17, 17, 20, 0.16);
  border-top-color: rgba(17, 17, 20, 0.65);
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  padding:
    calc(env(safe-area-inset-top, 0px) + 20px)
    22px
    calc(env(safe-area-inset-bottom, 0px) + 24px);
}

.auth-close-row {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 12px;
}

.auth-close-btn,
.top-icon-button {
  width: 52px;
  height: 52px;
  border: 1px solid rgba(17, 17, 20, 0.1);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(17, 17, 20, 0.05);
  backdrop-filter: blur(20px);
}

.auth-close-btn svg,
.top-icon-button svg {
  width: 24px;
  height: 24px;
}

.auth-panel {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.auth-card {
  width: min(100%, 440px);
  background: var(--surface);
  border-radius: 32px;
  padding: 30px 24px 24px;
  box-shadow: var(--shadow);
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-bottom: 26px;
}

.auth-brand img {
  width: 132px;
  height: 132px;
  object-fit: contain;
}

.auth-brand h2 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.16em;
  color: var(--muted);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-input {
  width: 100%;
  height: 58px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: var(--surface-muted);
  color: var(--text);
  padding: 0 18px;
  outline: none;
}

.login-input::placeholder {
  color: #8E8E93;
}

.login-input:focus {
  border-color: rgba(240, 90, 40, 0.45);
  background: #FFFFFF;
}

.login-btn,
.logout-btn {
  height: 58px;
  border: none;
  border-radius: 999px;
  background: var(--text);
  color: #FFFFFF;
  font-size: 17px;
  font-weight: 700;
  cursor: pointer;
}

.logout-btn {
  background: var(--surface-muted);
  color: var(--text);
  border: 1px solid var(--border);
  width: 100%;
}

.login-status {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-error {
  min-height: 20px;
  margin-top: 10px;
  font-size: 14px;
  color: var(--orange);
  text-align: center;
}

.app-shell {
  height: 100dvh;
  max-width: 860px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.app-shell.has-bottom-nav .content {
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 82px);
}

.header {
  position: relative;
  padding:
    calc(env(safe-area-inset-top, 0px) + 14px)
    24px
    2px;
  background: var(--bg);
  flex-shrink: 0;
}

.header img {
  width: 136px;
  height: 136px;
  object-fit: contain;
  display: block;
  margin: 0 auto;
}

.header-auth {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  right: 24px;
}

.content {
  flex: 1;
  overflow-y: auto;
  padding: 0 24px calc(env(safe-area-inset-bottom, 0px) + 20px);
  -webkit-overflow-scrolling: touch;
}

.content-head {
  padding: 1px 0 8px;
}

.content-head-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.screen-title {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.admin-plus {
  border: none;
  background: transparent;
  color: var(--orange);
  font-size: 34px;
  font-weight: 800;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.search-wrap {
  position: relative;
  margin-bottom: 10px;
}

.search-input {
  width: 100%;
  height: 44px;
  border: none;
  border-radius: 16px;
  background: #EBEBEB;
  color: #1A1A1A;
  padding: 0 14px 0 40px;
  outline: none;
}

.search-input::placeholder {
  color: #9A9A9A;
}

.search-input:focus {
  border-color: rgba(240, 90, 40, 0.35);
  background: #FFFFFF;
}

.search-wrap .icon {
  position: absolute;
  left: 13px;
  top: 50%;
  transform: translateY(-50%);
  color: #9A9A9A;
  width: 17px;
  height: 17px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.search-wrap .icon svg {
  width: 17px;
  height: 17px;
  stroke: currentColor;
}

.section {
  display: none;
}

.section.active {
  display: block;
}

.accordion-paese {
  border-radius: 22px;
  overflow: hidden;
  background: #E8E8E8;
  border: none;
  margin-bottom: 6px;
}

.acc-paese-header,
.acc-regione-header,
.acc-comune-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.acc-paese-header {
  min-height: 64px;
  padding: 0 16px;
}

.acc-paese-title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  padding-right: 12px;
  color: #1A1A1A;
}

.acc-arrow,
.acc-arrow-sm,
.acc-arrow-xs {
  color: #7B7B80;
  font-size: 18px;
  flex-shrink: 0;
  transition: transform 0.2s ease;
}

.acc-paese-header.open .acc-arrow,
.acc-regione-header.open .acc-arrow-sm,
.acc-comune-header.open .acc-arrow-xs {
  transform: rotate(90deg);
}

.acc-paese-body {
  display: none;
  padding-bottom: 6px;
}

.acc-paese-body.open {
  display: block;
}

.accordion-regione {
  margin: 8px 8px 10px;
  border-radius: 18px;
  background: #D7D7D7;
  overflow: hidden;
  border: none;
  box-shadow: 0 6px 18px rgba(17, 17, 20, 0.04);
}

.acc-regione-header {
  min-height: 44px;
  padding: 0 12px;
  border-bottom: 1px solid transparent;
}

.acc-regione-header.open {
  border-bottom-color: #C7C7C7;
}

.acc-regione-title {
  font-size: 13px;
  font-weight: 700;
  color: #1A1A1A;
}

.acc-regione-body {
  display: none;
  padding: 4px 0 8px;
}

.acc-regione-body.open {
  display: block;
}

.accordion-comune {
  margin: 8px 8px 10px;
  border-radius: 16px;
  background: #F0F0F0;
  overflow: hidden;
  border: none;
}

.acc-comune-header {
  min-height: 40px;
  padding: 0 12px;
  border-bottom: 1px solid transparent;
}

.acc-comune-header.open {
  border-bottom-color: #DEDEDE;
}

.acc-comune-title {
  font-size: 12px;
  font-weight: 700;
  color: #1A1A1A;
}

.acc-arrow-xs {
  font-size: 16px;
}

.acc-comune-body {
  display: none;
  padding: 4px 0 8px;
}

.acc-comune-body.open {
  display: block;
}

.producer-card {
  margin: 8px;
  border-radius: 16px;
  overflow: hidden;
  background: #F8F8F8;
  cursor: pointer;
  border: none;
}

.producer-card-header {
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.producer-name {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.3;
  color: #1A1A1A;
}

.producer-denom {
  font-size: 12px;
  color: #888888;
  line-height: 1.45;
  margin-top: 3px;
}

.producer-expand-icon {
  font-size: 17px;
  color: var(--orange);
  line-height: 1;
  transition: transform 0.2s ease;
}

.producer-card.expanded .producer-expand-icon {
  transform: rotate(45deg);
}

.producer-detail {
  display: none;
  border-top: 0.5px solid #E8E8E8;
  background: #FFFFFF;
  position: relative;
}

.producer-card.expanded .producer-detail {
  display: block;
}

.detail-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 34px;
  margin-bottom: 8px;
}

.detail-section-head .detail-label,
.detail-section-head .modal-section-label {
  margin-bottom: 0;
  line-height: 1;
}

.detail-edit-button {
  min-height: 34px;
  padding: 0 14px;
  border: 0.5px solid var(--orange);
  border-radius: 999px;
  background: var(--orange-soft);
  color: var(--orange);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.modal-edit-button {
  background: var(--surface-muted);
}

.detail-section,
.modal-section {
  padding: 14px 16px;
  border-bottom: 1px solid #EFEFF2;
}

.detail-section:last-child,
.modal-section:last-child {
  border-bottom: none;
}

.detail-label,
.modal-section-label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
  margin-bottom: 8px;
}

.detail-text,
.modal-section-text {
  font-size: 15px;
  line-height: 1.6;
  color: #2A2A2A;
  white-space: pre-wrap;
}

.maps-link,
.modal-maps {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  background: var(--orange);
  color: #FFFFFF;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
  margin: 14px 16px 16px;
}

.search-results {
  padding-bottom: 8px;
}

.search-result-item {
  background: var(--surface);
  border-radius: 16px;
  padding: 14px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  cursor: pointer;
}

.search-result-name {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.35;
}

.search-result-meta {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  margin-top: 4px;
}

.search-result-field {
  margin-top: 10px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--orange);
}

.search-result-snippet {
  margin-top: 4px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.no-results {
  text-align: left;
  padding: 14px 4px;
  color: var(--muted);
  font-size: 14px;
}

.bottom-nav {
  flex-shrink: 0;
  display: flex;
  justify-content: center;
  gap: 12px;
  padding: 4px 14px calc(env(safe-area-inset-bottom, 0px) + 4px);
  background: rgba(249, 249, 251, 0.94);
  border-top: 1px solid rgba(17, 17, 20, 0.06);
  backdrop-filter: blur(20px);
  position: relative;
  z-index: 4;
}

.bottom-nav-button {
  flex: 0 0 auto;
  min-width: 108px;
  min-height: 40px;
  padding: 2px 10px;
  border: none;
  border-radius: 14px;
  background: transparent;
  color: #8E8E93;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  cursor: pointer;
}

.bottom-nav-button svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
}

.bottom-nav-button span {
  font-size: 11px;
  font-weight: 600;
}

.bottom-nav-button.active {
  color: var(--orange);
}

.admin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1050;
  display: none;
  align-items: flex-end;
  background: rgba(10, 10, 12, 0.44);
  backdrop-filter: blur(10px);
}

.admin-overlay.open {
  display: flex;
}

.admin-sheet {
  width: 100%;
  max-height: 88dvh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  color: var(--text);
  border-radius: 28px 28px 0 0;
  overflow: hidden;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
  box-shadow: var(--shadow);
}

.admin-sheet-handle {
  width: 56px;
  height: 5px;
  border-radius: 999px;
  background: #D5D5DA;
  margin: 10px auto 0;
}

.admin-sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px 10px;
}

.admin-sheet-title {
  font-size: 18px;
  font-weight: 800;
  color: var(--text);
  text-transform: uppercase;
}

.admin-sheet-close {
  width: 42px;
  height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
}

.admin-sheet-close svg {
  width: 20px;
  height: 20px;
}

.admin-sheet-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 18px 0;
  -webkit-overflow-scrolling: touch;
}

.admin-sheet-empty {
  min-height: 80px;
}

.admin-sheet-footer {
  display: flex;
  gap: 12px;
  padding: 16px 18px 0;
}

.admin-sheet-footer:empty {
  display: none;
}

.admin-actions {
  display: grid;
  gap: 10px;
  padding-bottom: 6px;
}

.admin-action-button,
.admin-footer-button {
  min-height: 54px;
  border-radius: 16px;
  border: none;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

.admin-action-button {
  width: 100%;
  background: var(--surface-alt);
  color: var(--text);
  text-align: left;
  padding: 0 18px;
}

.admin-footer-button {
  flex: 1;
}

.admin-footer-button.secondary {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
}

.admin-footer-button.primary {
  background: var(--orange);
  color: #FFFFFF;
}

.admin-footer-button.primary:disabled {
  opacity: 0.45;
  cursor: default;
}

.admin-sheet-note,
.admin-sheet-message {
  font-size: 13px;
  line-height: 1.5;
}

.admin-sheet-note {
  color: rgba(255, 255, 255, 0.58);
  padding: 4px 2px 2px;
}

.admin-sheet-message {
  margin-top: 10px;
  color: var(--muted);
}

.admin-sheet-message.is-error {
  color: #B44E28;
}

.admin-sheet-message.is-success {
  color: #417A33;
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding-bottom: 10px;
}

.admin-form-group {
  display: flex;
  flex-direction: column;
}

.admin-form-input,
.admin-form-textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface-alt);
  color: var(--text);
  outline: none;
  padding: 14px 16px;
}

.admin-form-input::placeholder,
.admin-form-textarea::placeholder {
  color: #909099;
}

.admin-form-input:focus,
.admin-form-textarea:focus {
  border-color: rgba(240, 90, 40, 0.7);
}

.admin-form-textarea {
  min-height: 108px;
  resize: vertical;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(17, 17, 20, 0.28);
  display: none;
  align-items: flex-end;
  backdrop-filter: blur(8px);
}

.modal-overlay.open {
  display: flex;
}

.modal {
  width: 100%;
  max-height: 86dvh;
  background: var(--surface);
  border-radius: 32px 32px 0 0;
  overflow-y: auto;
  padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 20px);
}

.modal-handle {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: #D6D6DB;
  margin: 12px auto 0;
}

.modal-header {
  padding: 16px 20px 14px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid #EFEFF2;
}

.modal-title {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.25;
}

.modal-subtitle {
  margin-top: 6px;
  font-size: 14px;
  line-height: 1.45;
  color: var(--muted);
}

.modal-close {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--surface-muted);
  color: var(--text);
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.modal-body {
  padding-bottom: 6px;
}

mark {
  background: rgba(240, 90, 40, 0.18);
  color: inherit;
  border-radius: 6px;
  padding: 0 2px;
}

@media (min-width: 821px) {
  body {
    padding: 18px;
  }

  .app-shell {
    min-height: calc(100vh - 36px);
    height: calc(100vh - 36px);
    max-height: calc(100vh - 36px);
    border-radius: 34px;
    overflow: hidden;
    box-shadow: 0 24px 70px rgba(17, 17, 20, 0.12);
    border: 1px solid rgba(17, 17, 20, 0.05);
  }

  .app-shell.has-bottom-nav .content {
    padding-bottom: 20px;
  }

  .header {
    padding-top: 18px;
  }

  .header-auth {
    top: 18px;
  }

  .admin-overlay {
    align-items: center;
    justify-content: center;
    padding: 28px;
    background: rgba(17, 17, 20, 0.16);
    backdrop-filter: blur(12px);
  }

  .admin-sheet {
    width: min(100%, 760px);
    max-height: min(78dvh, 760px);
    background: var(--surface);
    color: var(--text);
    border-radius: 32px;
    box-shadow: var(--shadow);
    padding-bottom: 18px;
  }

  .admin-sheet-handle {
    background: #D5D5DA;
    margin-top: 12px;
  }

  .admin-sheet-header {
    padding: 14px 22px 10px;
  }

  .admin-sheet-title {
    color: var(--text);
    font-size: 18px;
    text-transform: uppercase;
  }

  .admin-sheet-close {
    background: var(--surface-muted);
    color: var(--text);
  }

  .admin-sheet-body {
    padding: 10px 22px 0;
  }

  .admin-sheet-footer {
    padding: 18px 22px 0;
  }

  .admin-action-button {
    background: var(--surface-alt);
    color: var(--text);
  }

  .admin-sheet-message {
    color: var(--muted);
  }

  .admin-sheet-message.is-error {
    color: #B44E28;
  }

  .admin-sheet-message.is-success {
    color: #417A33;
  }

  .admin-form-input,
  .admin-form-textarea {
    border: 1px solid var(--border);
    background: var(--surface-alt);
    color: var(--text);
  }

  .admin-form-input::placeholder,
  .admin-form-textarea::placeholder {
    color: #909099;
  }

  .admin-footer-button.secondary {
    color: var(--text);
    border-color: var(--border);
  }

  .admin-footer-button.primary {
    background: var(--orange);
    color: #FFFFFF;
  }

  .modal-overlay {
    align-items: center;
    justify-content: center;
    padding: 28px;
  }

  .modal {
    width: min(100%, 780px);
    max-height: min(82dvh, 820px);
    border-radius: 32px;
    padding-bottom: 18px;
  }

  .bottom-nav {
    min-height: 60px;
    padding: 6px 18px 8px;
    gap: 14px;
  }

  .bottom-nav-button {
    min-width: 116px;
    min-height: 44px;
  }
}

@media (max-width: 820px) {
  .header {
    padding-left: 18px;
    padding-right: 18px;
  }

  .header img {
    width: 124px;
    height: 124px;
  }

  .header-auth {
    right: 18px;
  }

  .content {
    padding-left: 18px;
    padding-right: 18px;
  }

  .app-shell.has-bottom-nav .content {
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 62px);
  }

  .acc-paese-header {
    min-height: 60px;
    padding: 0 14px;
  }

  .acc-paese-title {
    font-size: 15px;
  }

  .bottom-nav {
    gap: 8px;
    padding: 2px 12px calc(env(safe-area-inset-bottom, 0px) + 2px);
  }

  .bottom-nav-button {
    min-width: 96px;
    min-height: 36px;
    gap: 2px;
  }

  .bottom-nav-button svg {
    width: 17px;
    height: 17px;
  }
}
