/* Shared sizing: contain long user text without clipping interactive content. */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
.grid > *, .stack, .stack > *, .card, .row > *, .hero > *, .page-head > * { min-width: 0; }
.grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.hero { grid-template-columns: repeat(2, minmax(0, 1fr)); }
h1, h2, h3, p, .breadcrumb, .hint, .muted, .field, .pill, .api-key strong, .ingest-key strong { overflow-wrap: anywhere; }
.page-head { flex-wrap: wrap; align-items: flex-start; }
.page-head > div { max-width: 100%; flex: 1 1 320px; }
.page-head > .button { flex: 0 0 auto; }
.page-head > .row { flex: 0 1 auto; }
.card > .row, .metric-link > .row, .api-key > .row { flex-wrap: wrap; }
.pill { max-width: 100%; white-space: normal; }
.row, .form, .filters, .table-scroll, pre { min-width: 0; max-width: 100%; }
.button, button { max-width: 100%; overflow-wrap: anywhere; }
.field input, .field select, .field textarea { max-width: 100%; min-inline-size: 0; }
input[type="date"], input[type="datetime-local"] { display: block; min-width: 0; min-height: 44px; }
input::-webkit-date-and-time-value { text-align: left; }
.docs code, .location-item code { overflow-wrap: anywhere; }
.preview .stats-strip { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.preview .stats-strip > div { min-width: 0; }
.preview .stats-strip span { overflow-wrap: anywhere; }
.table-scroll { overscroll-behavior-x: contain; }
.project-title > h2 { flex: 1 1 220px; }
.metric-type-fields { flex-wrap: wrap; }
.metric-type-fields > .field { flex: 1 1 150px; }
.metric-type-fields > .field:last-child { flex: 0 0 85px; }
.chart { touch-action: pan-y pinch-zoom; }

@media (max-width: 1100px) {
    .grid.main-grid { grid-template-columns: minmax(0, 1fr); }
    .hero { gap: 26px; }
}
@media (max-width: 950px) {
    .grid.three { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 800px) {
    .hero { grid-template-columns: minmax(0, 1fr); }
    .preview { transform: none; }
    .hero > div:first-child { max-width: 620px; }
    .hero h1 { font-size: clamp(36px, 6.8vw, 48px); }
}
@media (max-width: 640px) {
    .metric-type-fields > .field { flex: 0 1 auto; }
    .grid.two, .grid.three { grid-template-columns: minmax(0, 1fr); }
    .hero h1 { font-size: clamp(36px, 11vw, 47px); }
    .preview .stats-strip { gap: 8px; }
    .preview .stats-strip strong { font-size: 22px; }
    .page-head > .row { width: 100%; flex-wrap: wrap; }
    .filters { gap: 12px; }
    .filters .field { flex: 1 1 calc(50% - 12px); min-width: 0; }
    .filters > button { flex: 1 1 100%; }
    .chart-range { grid-template-columns: minmax(0, 1fr); gap: 10px; }
    .chart-range > div:last-child { text-align: left; }
    .project-title > .row { width: 100%; flex-wrap: wrap; }

}
@media (max-width: 950px) {
    /* Keep a single, semantically labelled table while making rows fit a phone. */
    .measurements-table, .measurements-table tbody { display: block; width: 100%; }
    .measurements-table thead { position: absolute; width: 1px; height: 1px; padding: 0; overflow: hidden; clip-path: inset(50%); }
    .measurements-table tr { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; padding: 20px 0; border-bottom: 1px solid var(--line); }
    .measurements-table td { display: block; padding: 0; border: 0; min-width: 0; overflow-wrap: anywhere; }
    .measurements-table td:first-child, .measurements-table td:last-child, .measurements-table td[colspan] { grid-column: 1 / -1; }
    .measurements-table td[data-label]::before { content: attr(data-label); display: block; margin-bottom: 6px; font-size: 11px; color: var(--muted); }
    .measurements-table td summary { width: fit-content; min-width: 70px; }
    .measurements-table .form { max-width: 100%; }
}
@media (max-width: 1366px), (any-pointer: coarse) {
    .field input, .field select, .field textarea, .inline-form input { font-size: 16px; min-height: 46px; }
    .field input[type="file"] { padding: 10px; font-size: 16px; }
    button, .button, summary, .topbar nav > a, .pagination a, .locations-editor > a { min-height: 44px; }
    button, .button { padding-top: 11px; padding-bottom: 11px; }
    .compact { min-height: 44px; padding: 11px 13px; }
    summary { padding-top: 11px; padding-bottom: 11px; }
    .topbar nav > a, .pagination a { display: inline-flex; align-items: center; padding: 10px 4px; }
    .topbar nav > .button, .topbar nav button { min-height: 44px; padding-top: 11px; padding-bottom: 11px; }
    .location-actions { gap: 10px; }
    #toast-container > div { padding-right: 58px; }
    #toast-container .toast-close-button { top: 4px; right: 4px; width: 44px; height: 44px; min-height: 44px; padding: 0; }
    #locations-map .leaflet-bar a { width: 44px; height: 44px; line-height: 44px; }
    #locations-map .leaflet-popup-close-button { width: 44px; height: 44px; line-height: 44px; }
    #locations-map .leaflet-popup-content { margin-right: 44px; }
}
@media (prefers-reduced-motion: reduce) {
    .metric-link { transition: none; }
    .metric-link:hover { transform: none; }
}

@media (max-width: 420px) {
    .stats-strip strong { font-size: clamp(14px, 4.5vw, 18px); }
    .measurements-table td[data-label="Value"] { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
    .topbar { flex-wrap: wrap; gap: 15px; padding-top: 20px; padding-bottom: 20px; }
    .topbar nav { width: 100%; justify-content: space-between; flex-wrap: wrap; gap: 8px; }
}

/* Shared footer and contact form. */
.site-footer { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 16px 24px; }
.footer-brand { display: grid; gap: 8px; min-width: 0; }
.footer-links { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 24px; }
.footer-links a { display: inline-flex; align-items: center; min-height: 44px; }
.footer-partner { grid-column: 1 / -1; margin: 0; border-top: 1px solid var(--line); padding-top: 16px; font-size: 12px; overflow-wrap: anywhere; }
.footer-partner a { display: inline-block; padding: 10px 0; font-weight: 600; }
.contact-page { max-width: 680px; margin: 10px auto 40px; }
.contact-page textarea { resize: vertical; min-height: 180px; }
.field-error { color: #9b3c31; font-size: 12px; font-weight: 400; line-height: 1.5; }
@media (max-width: 640px) {
    .site-footer { grid-template-columns: minmax(0, 1fr); gap: 12px; }
    .footer-links { gap: 8px 24px; }
}

/* Optional analytics preferences, shared by public pages only. */
.analytics-consent[hidden], .analytics-preferences[hidden] { display: none; }
.analytics-consent, .analytics-status, .analytics-preferences { margin: 16px max(16px, calc((100% - 1120px) / 2)); }
.analytics-consent { max-width: 1120px; overflow-wrap: anywhere; }
.analytics-consent h2 { margin-top: 0; }
.analytics-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.analytics-actions .button, .analytics-preferences { min-height: 44px; white-space: normal; }
.analytics-status:empty { display: none; }
@media (max-width: 500px) {
    .analytics-actions .button { width: 100%; }
}
