/* ============================================================
   FRIDGE - Material Design theme (Bootstrap 5)
   Design tokens: deep purple primary, cyan accent, Roboto,
   Material elevation shadows, rich components.
   ============================================================ */

:root {
    --bs-primary: #5e35b1;
    --bs-primary-rgb: 94, 53, 177;
    --bs-primary-dark: #4527a0;
    --bs-primary-light: #ede7f6;
    --bs-secondary: #26c6da;
    --bs-secondary-rgb: 38, 198, 218;
    --bs-body-bg: #f5f5f6;
    --bs-body-color: #1f2328;
    --bs-body-font-family: 'Roboto', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --bs-border-color: #e3e3e6;
    --bs-link-color: #5e35b1;
    --bs-link-hover-color: #4527a0;

    --mdc-gradient: linear-gradient(135deg, #5e35b1 0%, #7b1fa2 45%, #00bcd4 100%);
    --mdc-gradient-soft: linear-gradient(135deg, #ede7f6 0%, #e0f7fa 100%);
    --mdc-surface: #ffffff;
    --mdc-surface-dark: #263238;
    --mdc-surface-dark-2: #1c262b;
    --mdc-text-on-dark: #eceff1;
    --mdc-text-muted: #5f6368;

    --mdc-elevation-1: 0 1px 2px rgba(0,0,0,.12), 0 1px 1px rgba(0,0,0,.08);
    --mdc-elevation-2: 0 3px 6px rgba(0,0,0,.12), 0 2px 4px rgba(0,0,0,.08);
    --mdc-elevation-3: 0 10px 20px rgba(0,0,0,.12), 0 4px 8px rgba(0,0,0,.06);
    --mdc-elevation-4: 0 16px 32px rgba(0,0,0,.16), 0 6px 12px rgba(0,0,0,.08);
    --mdc-radius: 14px;
    --mdc-radius-sm: 10px;
}

body {
    background-color: var(--bs-body-bg);
    font-family: var(--bs-body-font-family);
    -webkit-font-smoothing: antialiased;
    scroll-behavior: smooth;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, .display-6 {
    font-family: var(--bs-body-font-family);
    color: var(--bs-primary-dark);
    letter-spacing: -.2px;
}

a {
    text-decoration: none;
}

/* ---------- Custom scrollbar ---------- */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #ececee; }
::-webkit-scrollbar-thumb {
    background: #b9b6c2;
    border-radius: 6px;
    border: 2px solid #ececee;
}
::-webkit-scrollbar-thumb:hover { background: var(--bs-primary); }

/* ---------- App bar / header ---------- */
#div_header {
    position: relative;
    background: #ffffff;
    box-shadow: var(--mdc-elevation-2);
    margin-bottom: 0;
    padding: 14px 0;
    min-height: 72px;
    border-bottom: none;
    z-index: 1030;
}

/* gradient accent bar under the app bar */
#div_header::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 4px;
    background: var(--mdc-gradient);
}

#div_header .navbar-brand {
    max-width: 150px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#div_header #nfo-brand {
    max-width: 240px;
}

#div_header #nfo-brand img {
    height: 74px;
    width: auto;
    transition: transform .2s ease;
}

#div_header .navbar-brand img {
    height: 46px;
    width: auto;
    transition: transform .2s ease;
}
#div_header .navbar-brand:hover img {
    transform: scale(1.05);
}

#div_header .navbar-collapse {
    flex-grow: 1;
    justify-content: center;
}

@media (max-width: 991.98px) {
    #div_header > .container-fluid {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
        align-items: center;
        gap: 10px;
    }

    #div_header #nfo-brand {
        grid-column: 1;
        justify-self: start;
        margin: 0;
    }

    #div_header .navbar-toggler {
        grid-column: 2;
        grid-row: 1;
        justify-self: center;
        margin: 0;
    }

    #div_header .epos-brand {
        grid-column: 3;
        grid-row: 1;
        justify-self: end;
        margin: 0 !important;
    }

    #div_header #navbarSupportedContent {
        grid-column: 1 / -1;
        grid-row: 2;
        width: 100%;
    }

    #div_header #navbarSupportedContent .navbar-nav {
        padding: 12px 0 8px;
    }

    #div_header #nfo-brand img {
        height: 62px;
        max-width: 100%;
        object-fit: contain;
    }

    #div_header .epos-brand img {
        height: 42px;
        max-width: 100%;
        object-fit: contain;
    }
}

.mdc-brand-center {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    font-size: 26px;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--bs-primary-dark);
    background: var(--mdc-gradient-soft);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    padding: 4px 18px;
    border-radius: 24px;
    white-space: nowrap;
    pointer-events: none;
}

/* nav links as Material pills */
#div_header .nav-link {
    color: #3c4043;
    font-weight: 500;
    font-size: 14px;
    border-radius: 20px;
    margin: 0 2px;
    padding: 8px 16px;
    transition: background-color .18s ease, color .18s ease, box-shadow .18s ease;
}

#div_header .nav-link:hover,
#div_header .nav-link:focus {
    color: var(--bs-primary);
    background-color: var(--bs-primary-light);
}

#div_header .nav-item.active .nav-link {
    color: #ffffff;
    background: var(--bs-primary);
    box-shadow: var(--mdc-elevation-1);
}

#div_header .nav-item.active .nav-link:hover {
    color: #ffffff;
    background: var(--bs-primary-dark);
}

#div_header .dropdown-menu {
    border: none;
    border-radius: var(--mdc-radius-sm);
    box-shadow: var(--mdc-elevation-3);
    padding: 8px;
    margin-top: 8px;
    animation: mdc-dropdown-in .18s ease;
}

@keyframes mdc-dropdown-in {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

#div_header .dropdown-item {
    border-radius: 8px;
    padding: 9px 16px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#div_header .dropdown-item:hover {
    background-color: var(--bs-primary-light);
    color: var(--bs-primary-dark);
}

#div_header .dropdown-divider {
    border-color: var(--bs-border-color);
}

/* ---------- Privacy / disclaimer banner ---------- */
#div_header_pad {
    background: #263238;
}

#privacy_ad {
    background-color: #263238;
}

#privacy_ad > div {
    background-color: #263238;
    color: #eceff1;
}

/* ---------- Main layout ---------- */
#div_center {
    background-color: transparent;
    padding-top: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

.row.container_fix {
    flex: 1 1 auto;
    min-height: 0;
}

#home {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#historical_seism {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#div_content {
    padding: 16px 20px;
}

/* ---------- Hero (home page) ---------- */
.mdc-hero {
    position: relative;
    border-radius: var(--mdc-radius);
    background: #ffffff;
    color: var(--bs-body-color);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--mdc-elevation-2);
    border: 1px solid var(--bs-border-color);
}

.mdc-hero::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: var(--mdc-radius) 0 0 var(--mdc-radius);
    background: var(--mdc-gradient);
}

.mdc-hero-title {
    color: var(--bs-primary-dark);
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -.5px;
    margin: 0 0 6px;
}

.mdc-hero-subtitle {
    font-size: .95rem;
    font-weight: 300;
    color: var(--mdc-text-muted);
    max-width: 640px;
    margin-bottom: 0;
}

/* ---------- Section titles ---------- */
.mdc-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--bs-primary-dark);
    margin: 8px 0 16px;
}

.mdc-section-title i {
    color: var(--bs-primary);
    background: var(--bs-primary-light);
    border-radius: 10px;
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

/* ---------- Sidebar (Material navigation drawer) ---------- */
#div_sidebar {
    display: block;
    background-color: #ffffff;
    min-height: 600px;
    margin: 0 0 16px 0;
    padding: 16px 10px;
    color: #3c4043;
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-1);
    border: 1px solid var(--bs-border-color);
}

#div_sidebar ul {
    padding: 0;
    width: 100%;
    list-style-type: none;
}

#div_sidebar ul > :first-child {
    margin-top: 0;
}

#div_sidebar .sidebar-brand {
    text-align: center;
    margin-bottom: 8px;
}

#div_sidebar .sidebar-brand .mdc-brand-name {
    display: block;
    width: 100%;
    white-space: nowrap;
    font-family: 'Roboto', 'Segoe UI', system-ui, sans-serif;
    font-size: 48px;
    font-weight: 500;
    letter-spacing: -1px;
    line-height: 1;
    text-transform: uppercase;
    color: var(--bs-primary-dark);
    background: linear-gradient(180deg, #5e35b1 0%, #7b1fa2 55%, #00bcd4 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    transform: scale(1, 1.09);
    transform-origin: center;
}

#div_sidebar .sidebar-parent {
    color: var(--bs-primary-dark) !important;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: .3px;
    margin: 18px 0 6px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

#div_sidebar .sidebar-parent hr {
    display: none;
}

#div_sidebar .icon-chip {
    flex: 0 0 auto;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--bs-primary-light);
    color: var(--bs-primary);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    box-shadow: inset 0 0 0 1px rgba(94, 53, 177, .12);
}

#div_sidebar .icon-chip.gd { background: #e0f7fa; color: #00838f; }
#div_sidebar .icon-chip.sd { background: #ede7f6; color: var(--bs-primary); }
#div_sidebar .icon-chip.gg { background: #e8f5e9; color: #2e7d32; }
#div_sidebar .icon-chip.gp { background: #fff3e0; color: #ef6c00; }

#div_sidebar ul.sidebar-child {
    margin: 2px 0 8px;
    padding-left: 6px;
    border-left: 2px solid #ede7f6;
}

#div_sidebar ul.sidebar-child li {
    margin: 2px 0;
    border-radius: 10px;
    position: relative;
}

#div_sidebar ul.sidebar-child li a {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border-radius: 8px;
    color: #4a4f57;
    font-weight: 400;
    font-size: 13px;
    transition: background-color .15s ease, color .15s ease, padding-left .15s ease;
}

#div_sidebar ul.sidebar-child li a i {
    font-size: 10px;
    color: var(--bs-primary);
    opacity: .7;
}

#div_sidebar ul.sidebar-child li a:hover {
    background-color: var(--bs-primary-light);
    color: var(--bs-primary-dark);
    padding-left: 16px;
}

#div_sidebar a:link, #div_sidebar a:visited {
    color: #4a4f57;
}

#div_sidebar a:active, #div_sidebar a:hover {
    color: var(--bs-primary-dark);
}

#div_sidebar .lastvisited {
    color: var(--bs-primary) !important;
    font-weight: 600 !important;
    background: var(--bs-primary-light);
}

/* ---------- Bottom navbar (small screens) ---------- */
#div_navbar {
    display: none;
    margin: 0 0 12px;
    padding: 0;
}

#div_navbar > nav {
    background-color: #ffffff;
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-1);
    border: 1px solid var(--bs-border-color);
    padding: 6px;
}

#div_navbar .nav-link {
    color: #3c4043;
    font-weight: 500;
    border-radius: 20px;
    padding: 8px 16px;
}

#div_navbar .nav-link:hover,
#div_navbar .nav-link:focus {
    color: var(--bs-primary);
    background-color: var(--bs-primary-light);
}

#div_navbar .nav-item.active .nav-link {
    color: #ffffff;
    background: var(--bs-primary);
}

#div_navbar .dropdown-menu {
    border: none;
    box-shadow: var(--mdc-elevation-3);
    border-radius: var(--mdc-radius-sm);
}

#div_navbar .dropdown-item:hover {
    background-color: var(--bs-primary-light);
}

@media screen and (max-width: 1200px) {
    #div_navbar { display: block; }
    #div_sidebar { display: none; }
}

/* ---------- Cards & panels ---------- */
.card,
.mdc-card {
    border: none;
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-1);
    transition: box-shadow .25s ease, transform .25s ease;
}

.mdc-card {
    background: var(--mdc-surface);
    padding: 20px;
}

.card:hover,
.mdc-card:hover {
    box-shadow: var(--mdc-elevation-3);
}

.mdc-elevated { box-shadow: var(--mdc-elevation-3); }

/* Map container card */
#map_div, #map_card {
    background: #ffffff;
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-2);
    padding: 12px;
    margin-top: 0;
    margin-bottom: 12px;
}

#map_div {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
}

#map_div .mdc-map-toolbar {
    flex: 0 0 auto;
}

#map_div #mapLegend {
    flex: 0 0 auto;
}

#map_div .mdc-map-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 6px 10px;
}

#map_div .mdc-map-toolbar .mdc-map-title {
    font-weight: 600;
    font-size: 15px;
    color: var(--bs-primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

#map_div .mdc-map-toolbar .mdc-map-title i {
    color: var(--bs-primary);
}

#map_div .mdc-map-hint {
    font-size: 12px;
    color: var(--mdc-text-muted);
    font-style: italic;
}

#map {
    width: 100%;
    flex: 1 1 auto;
    height: auto;
    min-height: 420px;
    margin-top: 0;
    border-radius: var(--mdc-radius-sm);
    border: 1px solid var(--bs-border-color);
}

/* Historical seismicity: mappa altezza fissa + tabella scrollabile sotto */
#historical_seism #map_div {
    flex: 0 0 auto;
    height: 650px;
    margin-bottom: 12px;
}

#historical_seism #map {
    flex: 1 1 auto;
    height: 100%;
    min-height: 0;
    margin-top: 0;
}

#historical_seism #historical_seism_nfo {
    flex: 1 1 auto;
    min-height: 0;
    max-height: 650px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#historical_seism #hist_table_wrap {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--mdc-radius-sm);
}

#historical_seism #hist_table {
    margin: 0;
    font-size: 13px;
}

@media (max-width: 991.98px) {
    #historical_seism #map_div {
        height: 420px;
    }
    #historical_seism #historical_seism_nfo {
        max-height: 400px;
    }
}

#mapLegend {
    background-color: #ffffff;
    border: 1px solid var(--bs-border-color);
    box-shadow: var(--mdc-elevation-1);
    border-radius: var(--mdc-radius-sm);
    padding: 8px 14px;
    margin: 8px 0 4px;
}

/* ============================================================
   Station type selector — Material card overlay (Leaflet control)
   ============================================================ */
.leaflet-hidden {
    display: none !important;
}

.station-type-ctl {
    position: relative;
    width: 34px;
    height: 34px;
    background: #ffffff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--mdc-radius-sm);
    box-shadow: var(--mdc-elevation-2);
    font-size: 13px;
}

.station-type-ctl .stc-trigger {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--bs-primary-dark);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    border-radius: inherit;
    transition: background .12s;
}

.station-type-ctl .stc-trigger:hover {
    background: rgba(var(--bs-primary-rgb), .08);
}

.station-type-ctl .stc-trigger i {
    color: var(--bs-primary);
    font-size: 15px;
}

.station-type-ctl .stc-panel {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    width: 220px;
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid var(--bs-border-color);
    border-radius: var(--mdc-radius-sm);
    box-shadow: var(--mdc-elevation-3);
    transition: max-height .25s ease, opacity .2s ease;
    z-index: 1000;
}

.station-type-ctl.stc-open .stc-panel {
    max-height: 320px;
    opacity: 1;
    overflow-y: auto;
}

.station-type-ctl .stc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-weight: 600;
    color: var(--bs-primary-dark);
    border-bottom: 1px solid var(--bs-border-color);
    position: sticky;
    top: 0;
    background: #ffffff;
    white-space: nowrap;
}

.station-type-ctl .stc-head .stc-count {
    font-size: 11px;
    font-weight: 700;
    color: var(--bs-primary);
    background: rgba(var(--bs-primary-rgb), .12);
    border-radius: 999px;
    padding: 1px 8px;
    margin-left: 8px;
}

.station-type-ctl .stc-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 12px;
    cursor: pointer;
    white-space: nowrap;
    transition: background .12s;
}

.station-type-ctl .stc-row:hover {
    background: rgba(var(--bs-primary-rgb), .08);
}

.station-type-ctl .stc-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--bs-primary);
    cursor: pointer;
}

.station-type-ctl .stc-row img {
    width: 16px;
    height: 16px;
}

/* ---------- Forms: fieldset -> Material card ---------- */
fieldset.scheduler-border {
    border: 1px solid var(--bs-border-color) !important;
    border-radius: var(--mdc-radius) !important;
    background: #ffffff;
    box-shadow: var(--mdc-elevation-1);
    padding: 0 1.4em 1.4em 1.4em !important;
    margin: 0 0 1.6em 0 !important;
    transition: box-shadow .25s ease;
}

fieldset.scheduler-border:hover {
    box-shadow: var(--mdc-elevation-2);
}

legend.scheduler-border {
    font-size: 1.05em !important;
    font-weight: 600 !important;
    color: var(--bs-primary-dark) !important;
    text-align: left !important;
    width: auto;
    padding: 4px 14px;
    border-bottom: none;
    background: var(--bs-primary-light);
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

legend.scheduler-border i {
    color: var(--bs-primary);
}

.form-control, .form-select, .custom-select {
    border-radius: 10px;
    border-color: #cfd1d6;
    min-height: 44px;
    font-size: 14px;
    transition: border-color .15s ease, box-shadow .15s ease;
}

.form-control:focus, .form-select:focus, .custom-select:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .15);
}

.leaflet-control-layers-toggle {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 36 36' width='36' height='36'%3E%3Cpath d='M18 4L3 13l15 9 15-9L18 4z' fill='%234a148c' stroke='%232d2d2d' stroke-width='0.8'/%3E%3Cpath d='M3 18l15 9 15-9' fill='none' stroke='%232d2d2d' stroke-width='1.8'/%3E%3Cpath d='M3 23l15 9 15-9' fill='none' stroke='%232d2d2d' stroke-width='1.8'/%3E%3C/svg%3E") !important;
    background-size: 26px 26px;
    background-color: #fff;
    border-radius: 8px;
    box-shadow: 0 1px 5px rgba(0,0,0,.4);
    width: 44px !important;
    height: 44px !important;
}
.leaflet-touch .leaflet-control-layers-toggle {
    width: 44px !important;
    height: 44px !important;
}
.leaflet-control-layers {
    border-radius: 12px;
    box-shadow: 0 1px 5px rgba(0,0,0,.4);
}
.leaflet-control-zoom {
    border-radius: 8px;
}
.leaflet-control-zoom a {
    border-radius: 8px;
}
.leaflet-bar a {
    border-radius: 8px;
}
.leaflet-bar a:first-child {
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}
.leaflet-bar a:last-child {
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    border-bottom: none;
}


.col-form-label.field_label {
    font-weight: 500;
    font-size: 14px;
    color: var(--mdc-text-muted);
}

input[type="checkbox"], input[type="radio"] {
    accent-color: var(--bs-primary);
}

/* ---------- Buttons (Material filled / tonal / icon) ---------- */
.btn {
    border-radius: 10px;
    font-weight: 500;
    letter-spacing: .3px;
    text-transform: none;
    padding: 9px 18px;
    transition: box-shadow .2s ease, transform .1s ease, background-color .15s ease;
}

.btn:active {
    transform: scale(.98);
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary-dark);
    --bs-btn-hover-border-color: var(--bs-primary-dark);
    --bs-btn-active-bg: var(--bs-primary-dark);
    --bs-btn-active-border-color: var(--bs-primary-dark);
    box-shadow: var(--mdc-elevation-1);
}

.btn-primary:hover {
    box-shadow: var(--mdc-elevation-2);
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
}

.btn-secondary {
    --bs-btn-bg: var(--bs-secondary);
    --bs-btn-border-color: var(--bs-secondary);
    --bs-btn-color: #00363d;
    --bs-btn-hover-bg: #00acc1;
    --bs-btn-hover-border-color: #00acc1;
}

.btn-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.btn-icon i {
    font-size: 15px;
}

/* ---------- FAB (back to top) ---------- */
.mdc-fab {
    position: fixed;
    right: 28px;
    bottom: 28px;
    z-index: 1040;
    width: 54px;
    height: 54px;
    border-radius: 50%;
    border: none;
    background: var(--bs-primary);
    color: #ffffff;
    box-shadow: var(--mdc-elevation-3);
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transform: translateY(14px);
    transition: opacity .25s ease, transform .25s ease, visibility .25s, background-color .15s ease;
    cursor: pointer;
}

.mdc-fab.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.mdc-fab:hover {
    background: var(--bs-primary-dark);
    box-shadow: var(--mdc-elevation-4);
}

/* ---------- Tables ---------- */
.table {
    --bs-table-hover-bg: var(--bs-primary-light);
    border-radius: var(--mdc-radius-sm);
    overflow: hidden;
}

.table > :not(caption) > * > * {
    padding: .65rem .85rem;
    vertical-align: middle;
}

.table thead th {
    background: var(--bs-primary-light);
    color: var(--bs-primary-dark);
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: .4px;
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: rgba(var(--bs-primary-rgb), .06);
}

/* ---------- Modals ---------- */
.modal-content {
    border: none;
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-4);
    overflow: hidden;
}

#stationDataModal .chart-canvas-wrap {
    position: relative;
    width: 100%;
    height: 320px;
}

@media (min-width: 576px) {
    #stationDataModal .chart-canvas-wrap { height: 420px; }
}

@media (min-width: 992px) {
    #stationDataModal .chart-canvas-wrap { height: 520px; }
}

.modal-header {
    border-bottom-color: var(--bs-border-color);
    background: var(--bs-primary-light);
}

.modal-header .modal-title {
    color: var(--bs-primary-dark);
    font-weight: 600;
}

.modal-header .close {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--bs-primary-dark);
    opacity: 1;
    cursor: pointer;
    outline: none;
    transition: background-color .2s ease;
}

.modal-header .close:hover {
    background-color: rgba(var(--bs-primary-rgb), .12);
}

.modal-header .close:active {
    background-color: rgba(var(--bs-primary-rgb), .24);
}

.modal-header .close:focus-visible {
    background-color: rgba(var(--bs-primary-rgb), .12);
    box-shadow: 0 0 0 2px var(--bs-primary);
}

.modal-header .close svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.modal-footer {
    border-top-color: var(--bs-border-color);
}

/* ---------- Footer (dark) ---------- */
#div_footer {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 120px;
    background-color: var(--mdc-surface-dark);
    background: linear-gradient(180deg, #2b3a41 0%, var(--mdc-surface-dark) 60%);
    margin-top: 28px;
    padding: 0;
    border-radius: var(--mdc-radius) var(--mdc-radius) 0 0;
    box-shadow: var(--mdc-elevation-2);
    border: none;
    text-align: center;
    color: var(--mdc-text-on-dark);
}

#div_footer::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: var(--mdc-gradient);
}

#div_footer .mdc-footer {
    padding: 24px 20px 16px;
}

#div_footer .mdc-footer-cc a {
    color: #80cbc4;
    font-size: 13px;
}

#div_footer .mdc-footer-logos {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 8px;
    margin: 18px 0;
}

#div_footer .mdc-footer-logos a {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #ffffff;
    border-radius: 10px;
    padding: 6px;
    box-shadow: var(--mdc-elevation-1);
    transition: transform .18s ease, box-shadow .18s ease;
}

#div_footer .mdc-footer-logos a:hover {
    transform: translateY(-3px);
    box-shadow: var(--mdc-elevation-3);
}

#div_footer .mdc-footer-logos img {
    height: 44px;
    width: 56px;
    object-fit: contain;
    margin: 0;
    float: none;
    filter: none;
}

#div_footer .mdc-footer-bottom {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 22px;
    border-top: 1px solid rgba(255, 255, 255, .12);
    padding-top: 14px;
    font-size: 12px;
    color: rgba(236, 239, 241, .7);
}

#div_footer a {
    font-family: var(--bs-body-font-family);
    font-size: 12px;
    color: var(--bs-primary);
}

/* ---------- Badges / status ---------- */
.mdc-badge {
    display: inline-block;
    background: var(--bs-primary-light);
    color: var(--bs-primary-dark);
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    padding: 3px 12px;
}

.mdc-badge.accent {
    background: #e0f7fa;
    color: #00838f;
}

.action-label {
    color: var(--bs-primary);
    font-weight: 600;
}

/* ---------- Misc ---------- */
.loading-modal {
    background: rgba(33, 33, 33, .35);
}

.loading-modal > .imgdiv {
    border-radius: var(--mdc-radius);
    box-shadow: var(--mdc-elevation-4);
}

.slider.round {
    border-radius: 22px;
}

/* Ripple */
.ripple {
    position: relative;
    overflow: hidden;
}

.ripple-ink {
    position: absolute;
    border-radius: 50%;
    background: currentColor;
    opacity: .18;
    transform: scale(0);
    animation: ripple-anim .5s ease-out forwards;
    pointer-events: none;
}

@keyframes ripple-anim {
    to { transform: scale(3); opacity: 0; }
}

/* History page scroll container */
.scroll-container {
    border-radius: var(--mdc-radius-sm);
    background: #ffffff;
}

/* ============================================================
   Data Map Modal (Instrumental Earthquakes) — fullscreen layout
   come tabooweb: map flex-1 tra header e paletta, palette
   responsiva (flex box, si adatta alla larghezza del device)
   ============================================================ */
#dataMapModal .modal-dialog {
    width: 95vw;
    height: 95vh;
    max-width: none;
}

#dataMapModal .modal-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#dataMapModal .modal-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    padding: 0;
    display: flex;
}

#dataMapModal .modal-footer {
    flex: 0 0 auto;
}

#dataMapContainer {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
    min-height: 0;
}

#dataMapModal #mapHead {
    flex: 0 0 auto;
    padding: 12px 16px 2px;
}
#dataMapModal #mapHead p {
    margin: 0;
}

#dataMapModal #map {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    height: auto;
    margin: 8px 0 0;
    border: none;
    border-radius: var(--mdc-radius-sm);
}

/* palette (magnitude key) responsive — come tabooweb */
#palette {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 14px;
    margin: 0;
    padding: 10px 16px 12px;
    border: none;
    border-top: 1px solid var(--bs-border-color);
    background: #ffffff;
}
.palette_title {
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    color: var(--mdc-text-muted);
}
.palette_bar {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-width: 0;
    max-width: 760px;
    margin: 0 auto;
}
.palette_ticks {
    position: relative;
    height: 14px;
    margin-bottom: 2px;
}
.palette_ticks span {
    position: absolute;
    top: 0;
    transform: translateX(-50%);
    font-size: 10px;
    color: var(--mdc-text-muted);
}
.palette_col {
    display: flex;
    width: 100%;
    height: 14px;
    border-radius: 3px;
    overflow: hidden;
}
.palette_col span {
    flex: 1 1 0;
    min-width: 0;
    height: 100%;
}

/* ============================================================
   Custom select — replaces native <select> for full-width
   purple highlight on options
   ============================================================ */
.mdc-select {
    position: relative;
    width: 100%;
    font-size: 14px;
}
.mdc-select .mdc-select-trigger {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 38px 10px 14px;
    border: 2px solid var(--bs-primary);
    border-radius: 12px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: var(--bs-body-color);
    cursor: pointer;
    box-shadow: var(--mdc-elevation-1);
    transition: border-color .2s, box-shadow .2s;
    user-select: none;
    -webkit-user-select: none;
}
.mdc-select .mdc-select-trigger:focus,
.mdc-select.open .mdc-select-trigger {
    border-color: var(--bs-primary-dark);
    box-shadow: 0 0 0 .25rem rgba(var(--bs-primary-rgb), .2);
    outline: none;
}
.mdc-select .mdc-select-trigger::after {
    content: '';
    width: 10px;
    height: 10px;
    border-right: 2px solid var(--bs-primary);
    border-bottom: 2px solid var(--bs-primary);
    transform: rotate(45deg);
    flex-shrink: 0;
    margin-left: 8px;
    margin-top: -4px;
    transition: transform .2s;
}
.mdc-select.open .mdc-select-trigger::after {
    transform: rotate(-135deg);
    margin-top: 4px;
}
.mdc-select .mdc-select-trigger .mdc-select-text {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.mdc-select .mdc-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 9000;
    margin-top: 4px;
    background: #fff;
    border: 1px solid var(--bs-border-color);
    border-radius: 12px;
    box-shadow: var(--mdc-elevation-3);
    max-height: 260px;
    overflow-y: auto;
    padding: 4px 0;
    list-style: none;
    margin: 4px 0 0;
}
.mdc-select.open .mdc-select-dropdown {
    display: block;
}
.mdc-select .mdc-select-option {
    display: block;
    width: 100%;
    padding: 10px 16px;
    font-size: 14px;
    color: var(--bs-body-color);
    background: transparent;
    cursor: pointer;
    border: none;
    text-align: left;
    white-space: nowrap;
    transition: background .12s;
}
.mdc-select .mdc-select-option.active {
    background: var(--bs-primary);
    color: #fff;
    font-weight: 500;
}
.mdc-select .mdc-select-option.disabled {
    color: var(--bs-secondary-color);
    cursor: not-allowed;
    opacity: .6;
}
.mdc-select .mdc-select-option.kb-hover {
    background: rgba(var(--bs-primary-rgb), .25);
    box-shadow: inset 3px 0 0 var(--bs-primary);
}
.mdc-select-ghost {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    opacity: 0;
    pointer-events: none;
}

/* ============================================================
   Flatpickr — visible calendar, editable month/year, full z-index
   ============================================================ */
.flatpickr-calendar {
    z-index: 100000 !important;
    border-radius: 14px;
    box-shadow: var(--mdc-elevation-3);
    border: 1px solid var(--bs-border-color);
}
.flatpickr-calendar.animate.open {
    animation: none;
}
.flatpickr-day.selected,
.flatpickr-day.selected:hover,
.flatpickr-day.startRange,
.flatpickr-day.endRange {
    background: var(--bs-primary);
    border-color: var(--bs-primary);
}
.flatpickr-day.today {
    border-color: var(--bs-primary);
}
.flatpickr-day.flatpickr-disabled,
.flatpickr-day.notAllowed {
    color: var(--bs-secondary-color);
}
.flatpickr-current-month {
    font-size: 16px;
    font-weight: 600;
}
.flatpickr-current-month .flatpickr-monthDropdown-months,
.flatpickr-current-month input.cur-year {
    font-size: 16px;
    font-weight: 600;
    color: var(--bs-body-color);
    background: #fff;
}
.flatpickr-current-month .numInputWrapper:hover {
    background: transparent;
}
.flatpickr-months .flatpickr-prev-month,
.flatpickr-months .flatpickr-next-month {
    color: var(--bs-primary);
    border-radius: 6px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.flatpickr-months .flatpickr-prev-month:hover,
.flatpickr-months .flatpickr-next-month:hover {
    background: rgba(var(--bs-primary-rgb), .1);
    color: var(--bs-primary);
}
.flatpickr-weekday {
    font-weight: 600;
    color: var(--mdc-text-muted);
}
.flatpickr-time input {
    font-size: 15px;
    color: var(--bs-body-color);
}
.flatpickr-time .flatpickr-time-separator,
.flatpickr-time .flatpickr-am-pm {
    color: var(--bs-primary);
}
.flatpickr-day {
    border-radius: 8px;
    font-size: 14px;
    line-height: 34px;
}

/* Accessibility: visible keyboard focus */
:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.mail-icon:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 3px;
    border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
