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

html {
  min-width: 0;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 0;
  overflow-x: hidden;
}

img,
svg,
canvas,
video {
  max-width: 100%;
}

img,
svg,
video {
  height: auto;
}

button,
input,
select,
textarea {
  max-width: 100%;
  font: inherit;
}

textarea {
  resize: vertical;
}

.mobile-multiselect {
  display: none;
}

table {
  max-width: 100%;
}

.container,
.login-card,
.signup-card,
.card,
.card-wrap,
.panel,
.family-section,
.page-hero,
.mode-banner,
.profile-zones,
.products-summary,
.onboarding-panel,
.structure-catalog,
.cta,
.hero,
.grid,
.topbar {
  min-width: 0;
}

.table-wrap,
.template-scroll-shell,
.products-editor-scroll,
.profile-editor-scroll,
.quick-results,
.selected-tags {
  -webkit-overflow-scrolling: touch;
}

.table-wrap table,
.template-scroll-shell table {
  max-width: none;
}

.btn,
.btn-light,
.btn-main,
.btn-inline,
.btn-ghost,
.btn-mini,
.export-btn,
button,
input[type="submit"],
input[type="button"] {
  overflow-wrap: anywhere;
}

.site-footer-inner {
  padding-inline: 12px;
}

@media (max-width: 900px) {
  .container {
    width: 100%;
    max-width: 100% !important;
  }

  .filters-grid,
  .annual-filter-bar,
  .fields-grid,
  .profile-editor-grid,
  .profile-readonly-grid,
  .products-editor-grid,
  .picker-grid,
  .product-proposal-fields,
  .summary-strip,
  .profile-products,
  .profile-grid,
  .technical-contacts,
  .grid,
  .grid-2,
  .cards {
    grid-template-columns: 1fr !important;
  }

  .identity-top,
  .zone-list,
  .panel-head,
  .profile-head,
  .products-summary-head,
  .referents-head,
  .editor-head,
  .editor-footer,
  .picker-toolbar,
  .quick-head,
  .product-proposal-actions,
  .actions,
  .controls,
  .year-form,
  .selectors,
  .toolbar {
    align-items: stretch;
  }
}

@media (max-width: 720px) {
  body {
    min-height: 100dvh;
  }

  .container {
    padding: 76px 8px 48px !important;
  }

  .login-card,
  .signup-card,
  main.card,
  .card-wrap {
    width: min(100%, calc(100vw - 16px)) !important;
  }

  .login-card,
  .signup-card,
  main.card,
  .panel,
  .family-section,
  .page-hero,
  .mode-banner,
  .profile-zones,
  .products-summary,
  .onboarding-panel,
  .structure-catalog,
  .cta,
  .hero {
    border-radius: 10px !important;
  }

  .login-card,
  .signup-card,
  main.card {
    padding: 16px !important;
  }

  .topbar {
    width: auto !important;
    max-width: none !important;
    margin: 0 !important;
    position: fixed !important;
    top: 6px !important;
    left: 8px !important;
    right: 8px !important;
    z-index: 5000 !important;
    max-height: calc(100dvh - 12px);
    overflow-y: auto;
    overscroll-behavior: contain;
  }

  .topbar-user,
  .topbar-user-text,
  .topbar-user-primary,
  .topbar-user-secondary {
    min-width: 0;
    max-width: 100%;
  }

  .topbar-user-primary,
  .topbar-user-secondary {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .panel-actions,
  .annual-filter-actions,
  .annual-filter-tools,
  .entry-action-buttons,
  .footer-actions,
  .editor-head-actions,
  .editor-footer-actions,
  .picker-actions,
  .selected-product-actions,
  .contact-actions,
  .identity-card-actions,
  .product-proposal-actions,
  .confirm-actions,
  .multi-actions,
  .table-controls-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
    width: 100%;
  }

  .panel-actions > *,
  .annual-filter-actions > *,
  .annual-filter-tools > *,
  .entry-action-buttons > *,
  .footer-actions > *,
  .editor-head-actions > *,
  .editor-footer-actions > *,
  .picker-actions > *,
  .selected-product-actions > *,
  .contact-actions > *,
  .identity-card-actions > *,
  .product-proposal-actions > *,
  .confirm-actions > *,
  .multi-actions > *,
  .table-controls-actions > * {
    width: 100% !important;
  }

  .btn,
  .btn-light,
  .btn-main,
  .btn-inline,
  .btn-ghost,
  .btn-mini,
  .export-btn,
  button,
  input[type="submit"],
  input[type="button"] {
    min-height: 40px;
    justify-content: center;
    white-space: normal !important;
  }

  input:not([type="checkbox"]):not([type="radio"]),
  select,
  textarea {
    min-height: 40px;
  }

  select[multiple][data-mobile-multiselect-enhanced="true"] {
    display: none !important;
  }

  .mobile-multiselect {
    display: block;
    width: 100%;
    padding: 8px;
    border: 1px solid #d9d9cf;
    border-radius: 8px;
    background: #ffffff;
  }

  .mobile-multiselect-summary {
    margin-bottom: 7px;
    color: #425246;
    font-size: 0.84rem;
    font-weight: 700;
  }

  .mobile-multiselect-search {
    width: 100%;
    min-height: 38px !important;
    margin-bottom: 8px;
    padding: 7px 9px;
    border: 1px solid #cbd8cf;
    border-radius: 8px;
    background: #fbfdfb;
  }

  .mobile-multiselect-search[hidden] {
    display: none !important;
  }

  .mobile-multiselect-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
    gap: 6px;
    max-height: min(230px, 36dvh);
    overflow-y: auto;
    padding-right: 2px;
    -webkit-overflow-scrolling: touch;
  }

  .mobile-multiselect.is-long .mobile-multiselect-list {
    grid-template-columns: 1fr;
    max-height: min(260px, 38dvh);
  }

  .mobile-multiselect-option {
    display: flex;
    min-width: 0;
    min-height: 36px;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border: 1px solid #d8e1da;
    border-radius: 8px;
    background: #f9fbf8;
    color: #172419;
    font-size: 0.88rem;
    line-height: 1.2;
  }

  .mobile-multiselect-option.is-selected {
    border-color: #7eaa8a;
    background: #edf6ef;
    color: #174326;
  }

  .mobile-multiselect-option.is-disabled {
    color: #778178;
    background: #f3f4f0;
  }

  .mobile-multiselect-option input {
    width: 17px;
    height: 17px;
    flex: 0 0 auto;
    accent-color: #255f38;
  }

  .mobile-multiselect-option span {
    min-width: 0;
    overflow-wrap: anywhere;
  }

  .multi-select-help {
    display: none !important;
  }

  .chart-wrap {
    height: clamp(240px, 46vh, 360px) !important;
  }

  .chart-wrap-compare {
    height: clamp(220px, 42vh, 340px) !important;
  }

  .table-wrap {
    max-width: 100%;
    overflow-x: auto;
  }

  .table-wrap th,
  .table-wrap td {
    white-space: normal;
    overflow-wrap: anywhere;
  }

  #indicatorsTable th:nth-child(n+6),
  #indicatorsTable td:nth-child(n+6),
  #annualSummaryTable th:nth-child(n+5),
  #annualSummaryTable td:nth-child(n+5),
  .period-cell,
  .period-cell input[type="text"] {
    white-space: nowrap !important;
    overflow-wrap: normal !important;
    word-break: normal !important;
  }

  .profile-editor-dialog,
  .products-editor-dialog,
  .confirm-dialog,
  .confirm-modal,
  .proposal-notification-dialog {
    width: calc(100vw - 16px) !important;
    max-height: calc(100dvh - 16px) !important;
  }

  .profile-editor-scroll,
  .products-editor-scroll,
  .confirm-body,
  .proposal-notification-dialog {
    max-height: calc(100dvh - 120px);
  }

  .identity-top,
  .zone-list,
  .annual-row,
  .profile-head,
  .products-summary-head,
  .referents-head,
  .quick-head,
  .selected-product-head,
  .editor-head,
  .editor-footer,
  .picker-toolbar,
  .product-proposal-actions {
    display: grid !important;
    grid-template-columns: 1fr !important;
  }

  .structure-logo,
  .identity-logo {
    justify-self: start;
  }
}

@media (max-width: 430px) {
  .container {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .panel,
  .family-section,
  .profile-zones,
  .products-summary,
  .onboarding-panel,
  .structure-catalog {
    padding: 9px !important;
  }

  .topbar-actions {
    grid-template-columns: 1fr !important;
  }

  .summary-tag,
  .selected-tag,
  .product-tag,
  .meta-pill,
  .contact-chip {
    max-width: 100%;
    overflow-wrap: anywhere;
  }
}
