/*
 * Roma Dashboard MVP — Design System
 * Bootstrap Italia 2.x inspired + AgID compliance
 * Font: Titillium Web (Google Fonts)
 * Palette: Roma/Bordeaux #8A1E41, Giallo Roma #FFC61E, Grigio AgID #F0F2F5
 */

/* === Google Fonts === */
@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:wght@300;400;600;700&display=swap');

/* === CSS Custom Properties (Design Tokens) === */
:root {
    /* Roma Institutional Colors */
    --roma-primary: #8A1E41;
    --roma-primary-dark: #6B1733;
    --roma-primary-light: #A82852;
    --roma-secondary: #FFC61E;
    --roma-secondary-dark: #E0AD00;

    /* Neutrals */
    --roma-bg: #F0F2F5;
    --roma-surface: #FFFFFF;
    --roma-surface-elevated: #FFFFFF;
    --roma-border: #D6D9DE;
    --roma-text: #1A1A2E;
    --roma-text-secondary: #5A6772;
    --roma-text-muted: #8E99A4;

    /* Semantic Colors */
    --roma-success: #008758;
    --roma-warning: #A66300;
    --roma-danger: #CC3300;
    --roma-info: #0066CC;

    /* Risk Colors */
    --risk-low: #4CAF50;
    --risk-medium: #FFC61E;
    --risk-high: #FF6B35;
    --risk-critical: #8A1E41;

    /* Triage Colors */
    --triage-rosso: #CC3300;
    --triage-giallo: #FFC61E;
    --triage-verde: #008758;
    --triage-bianco: #B0BEC5;

    /* Layout */
    --navbar-height: 56px;
    --tab-bar-height: 42px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 56px;
    --card-radius: 8px;
    --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.08), 0 1px 2px rgba(0, 0, 0, 0.06);
    --card-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.12);

    /* Typography */
    --font-family: 'Titillium Web', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-size-xs: 0.7rem;
    --font-size-sm: 0.8rem;
    --font-size-base: 0.9rem;
    --font-size-lg: 1.1rem;
    --font-size-xl: 1.3rem;
    --font-size-2xl: 1.8rem;
    --font-size-3xl: 2.4rem;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* === Reset & Base === */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    font-family: var(--font-family);
    font-size: 16px;
    color: var(--roma-text);
    background: var(--roma-bg);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
    height: 100vh;
}

/* === NAVBAR === */
.navbar-roma {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background: linear-gradient(135deg, var(--roma-primary) 0%, var(--roma-primary-dark) 100%);
    color: white;
    display: flex;
    align-items: center;
    padding: 0 20px;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: var(--font-size-lg);
    letter-spacing: 0.3px;
}

.navbar-brand .stemma {
    width: 32px;
    height: 32px;
    background: var(--roma-secondary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: var(--roma-primary-dark);
    flex-shrink: 0;
}

.navbar-subtitle {
    font-size: var(--font-size-xs);
    opacity: 0.7;
    font-weight: 300;
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-left: 4px;
}

.navbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: var(--font-size-sm);
}

.navbar-live-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.15);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.navbar-live-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4CAF50;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.3);
    }
}

/* === TAB BAR === */
.tab-bar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    height: var(--tab-bar-height);
    background: var(--roma-surface);
    border-bottom: 2px solid var(--roma-border);
    display: flex;
    align-items: center;
    gap: 0;
    padding: 0 20px 0 var(--sidebar-width);
    z-index: 950;
    overflow-x: auto;
}

.tab-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    font-family: var(--font-family);
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--roma-text-secondary);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    margin-bottom: -2px;
}

.tab-item:hover {
    color: var(--roma-primary);
    background: rgba(138, 30, 65, 0.04);
}

.tab-item.active {
    color: var(--roma-primary);
    font-weight: 600;
    border-bottom-color: var(--roma-primary);
}

.tab-icon {
    display: flex;
    align-items: center;
}

/* === SIDEBAR === */
.sidebar {
    position: fixed;
    top: calc(var(--navbar-height) + var(--tab-bar-height));
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--roma-surface);
    border-right: 1px solid var(--roma-border);
    overflow-y: auto;
    z-index: 900;
    transition: width var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.sidebar::-webkit-scrollbar {
    width: 4px;
}

.sidebar::-webkit-scrollbar-thumb {
    background: var(--roma-border);
    border-radius: 2px;
}

/* Sidebar Sections */
.sidebar-section {
    padding: 16px;
    border-bottom: 1px solid var(--roma-border);
}

.sidebar-section-title {
    font-size: var(--font-size-xs);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: var(--roma-text-muted);
    margin-bottom: 10px;
}

/* Navigation Items */
.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: var(--font-size-sm);
    font-weight: 400;
    color: var(--roma-text-secondary);
    transition: all var(--transition-fast);
    text-decoration: none;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
}

.nav-item:hover {
    background: var(--roma-bg);
    color: var(--roma-text);
}

.nav-item.active {
    background: rgba(138, 30, 65, 0.08);
    color: var(--roma-primary);
    font-weight: 600;
}

.nav-item .nav-icon {
    font-size: 18px;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.nav-item .nav-badge {
    margin-left: auto;
    background: var(--roma-primary);
    color: white;
    font-size: var(--font-size-xs);
    padding: 2px 7px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-item .nav-badge.mock {
    background: var(--roma-text-muted);
}

/* Layer Toggles */
.layer-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 0;
    font-size: var(--font-size-sm);
    color: var(--roma-text-secondary);
}

.layer-toggle label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
}

.layer-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Custom Toggle Switch */
.toggle-switch-btn {
    position: relative;
    width: 36px;
    height: 20px;
    flex-shrink: 0;
    background: var(--roma-border);
    border-radius: 20px;
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
}

.toggle-slider-dot {
    position: absolute;
    width: 16px;
    height: 16px;
    left: 2px;
    top: 2px;
    background: white;
    border-radius: 50%;
    transition: var(--transition-fast);
    pointer-events: none;
}

.toggle-switch-btn.active {
    background: var(--roma-primary);
}

.toggle-switch-btn.active .toggle-slider-dot {
    transform: translateX(16px);
}

/* Filter Controls */
.filter-group {
    margin-bottom: 12px;
}

.filter-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--roma-text-secondary);
    margin-bottom: 4px;
    display: block;
}

/* === MAIN CONTENT === */
.main-content {
    margin-left: var(--sidebar-width);
    width: calc(100vw - var(--sidebar-width));
    margin-top: calc(var(--navbar-height) + var(--tab-bar-height));
    height: calc(100vh - var(--navbar-height) - var(--tab-bar-height));
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* === KPI CARDS === */
.kpi-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
}

.kpi-card {
    background: var(--roma-surface);
    border-radius: var(--card-radius);
    padding: 16px;
    box-shadow: var(--card-shadow);
    border-left: 4px solid var(--roma-primary);
    transition: box-shadow var(--transition-fast);
}

.kpi-card:hover {
    box-shadow: var(--card-shadow-hover);
}

.kpi-card.alert {
    border-left-color: var(--roma-danger);
}

.kpi-card.warning {
    border-left-color: var(--roma-warning);
}

.kpi-card.success {
    border-left-color: var(--roma-success);
}

.kpi-card.info {
    border-left-color: var(--roma-info);
}

.kpi-label {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--roma-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    color: var(--roma-text);
    line-height: 1.1;
}

.kpi-delta {
    font-size: var(--font-size-xs);
    margin-top: 4px;
    font-weight: 600;
}

.kpi-delta.positive {
    color: var(--roma-success);
}

.kpi-delta.negative {
    color: var(--roma-danger);
}

.kpi-source {
    font-size: var(--font-size-xs);
    color: var(--roma-text-muted);
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.source-badge {
    display: inline-block;
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.source-badge.real {
    background: rgba(0, 135, 88, 0.12);
    color: var(--roma-success);
}

.source-badge.mock {
    background: rgba(142, 153, 164, 0.15);
    color: var(--roma-text-muted);
}

.source-badge.proxy {
    background: rgba(255, 198, 30, 0.15);
    color: var(--roma-warning);
}

/* === MAP AREA === */
.map-container {
    min-height: 300px;
    height: 300px;
    background: transparent;
    border-radius: var(--card-radius);
    overflow: hidden;
    box-shadow: var(--card-shadow);
    position: relative;
    display: flex;
    flex-direction: column;
}

.map-container iframe {
    flex: 1;
    width: 100% !important;
    height: 100% !important;
    min-height: 300px;
    border: none;
    border-radius: var(--card-radius);
    display: block;
}

.map-overlay-info {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: var(--font-size-xs);
    font-weight: 600;
    z-index: 10;
    backdrop-filter: blur(4px);
}

/* === CHARTS ROW === */
.charts-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.charts-row.charts-row-3col {
    grid-template-columns: 1fr 1fr 1fr;
}

.chart-card {
    background: var(--roma-surface);
    border-radius: var(--card-radius);
    padding: 16px;
    box-shadow: var(--card-shadow);
}

.chart-title {
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--roma-text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chart-title .chart-icon {
    color: var(--roma-primary);
}

/* === COMING SOON (Shell) === */
.coming-soon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    min-height: 400px;
    text-align: center;
    gap: 16px;
}

.coming-soon .icon {
    font-size: 64px;
    opacity: 0.3;
}

.coming-soon h2 {
    font-size: var(--font-size-xl);
    color: var(--roma-text-secondary);
    font-weight: 600;
}

.coming-soon p {
    font-size: var(--font-size-sm);
    color: var(--roma-text-muted);
    max-width: 400px;
}

/* === DATA TRANSPARENCY PANEL === */
.transparency-panel {
    background: var(--roma-surface);
    border-radius: var(--card-radius);
    padding: 20px;
    box-shadow: var(--card-shadow);
}

.transparency-table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--font-size-sm);
}

.transparency-table th {
    text-align: left;
    padding: 8px 12px;
    border-bottom: 2px solid var(--roma-primary);
    font-weight: 700;
    font-size: var(--font-size-xs);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--roma-text-secondary);
}

.transparency-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--roma-border);
}

.transparency-table tr:hover td {
    background: var(--roma-bg);
}

/* === FOOTER === */
.footer-roma {
    padding: 12px 16px;
    text-align: center;
    font-size: var(--font-size-xs);
    color: var(--roma-text-muted);
    border-top: 1px solid var(--roma-border);
    background: var(--roma-surface);
}

/* === RESPONSIVE === */
@media (max-width: 1200px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.open {
        width: var(--sidebar-width);
    }

    .main-content {
        margin-left: 0;
    }

    .kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* === DASH OVERRIDES === */
/* Override Dash default styles */
.dash-graph .js-plotly-plot {
    border-radius: var(--card-radius);
}

._dash-loading {
    display: none !important;
}

/* Dropdown styling */
.Select-control {
    border-radius: 6px !important;
    border-color: var(--roma-border) !important;
    font-family: var(--font-family) !important;
    font-size: var(--font-size-sm) !important;
}

.Select-control:hover {
    border-color: var(--roma-primary) !important;
}

.Select-value-label {
    font-family: var(--font-family) !important;
}

/* RangeSlider override */
.rc-slider-track {
    background-color: var(--roma-primary) !important;
}

.rc-slider-handle {
    border-color: var(--roma-primary) !important;
}

.rc-slider-dot-active {
    border-color: var(--roma-primary) !important;
}

/* DatePicker overrides */
.DateInput_input {
    font-family: var(--font-family) !important;
    font-size: var(--font-size-sm) !important;
}

/* === ANIMATIONS === */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.3s ease forwards;
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-16px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.slide-in {
    animation: slideInLeft 0.3s ease forwards;
}

/* === INSIGHT PANELS === */
.insight-panel {
    background: var(--roma-surface);
    border-radius: var(--card-radius);
    box-shadow: var(--card-shadow);
    overflow: hidden;
}

.insight-panel-header {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: var(--roma-bg);
    border-bottom: 1px solid var(--roma-border);
    font-size: var(--font-size-sm);
    color: var(--roma-text);
}

.insight-panel-body {
    padding: 16px;
}

/* KPI sublabel for context */
.kpi-sublabel {
    font-size: 10px;
    color: var(--roma-text-muted);
    margin-top: 2px;
    line-height: 1.3;
    font-weight: 400;
}

/* Charts row — allow 3-column layout */
.charts-row.three-col {
    grid-template-columns: repeat(3, 1fr);
}

@media (max-width: 1400px) {
    .charts-row.three-col {
        grid-template-columns: 1fr 1fr;
    }
}

/* Insight grid — two columns of panels */
.insight-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

@media (max-width: 1200px) {
    .insight-grid {
        grid-template-columns: 1fr;
    }
}

/* ── IMP-1: KPI Tooltip — self-contained hover ────────── */
.kpi-card {
    position: relative;
    cursor: pointer;
    overflow: visible;
}

/* Tooltip wrapper: inline element positioned relative */
.kpi-tooltip {
    position: relative;
    display: inline-flex;
    align-items: center;
    cursor: help;
    z-index: 100;
}

/* The ℹ icon — always visible */
.kpi-tooltip-icon {
    background: var(--roma-secondary, #FFC61E);
    color: var(--roma-text, #1A1A2E);
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.kpi-tooltip:hover .kpi-tooltip-icon {
    transform: scale(1.15);
    box-shadow: 0 0 8px rgba(255, 198, 30, 0.5);
}

/* The tooltip text — hidden by default, appears on hover */
.kpi-tooltip-text {
    display: none;
    position: absolute;
    top: calc(100% + 10px);
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    max-width: 360px;
    background: var(--roma-text, #1A1A2E);
    color: #fff;
    padding: 12px 14px;
    border-radius: var(--card-radius, 8px);
    border: 1px solid var(--roma-secondary, #FFC61E);
    font-size: var(--font-size-xs, 11px);
    font-weight: 400;
    line-height: 1.55;
    letter-spacing: 0.01em;
    z-index: 9999;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
    animation: tooltipFadeIn 0.2s ease-out;
    white-space: normal;
    text-align: left;
    pointer-events: none;
}

/* Arrow pointing up */
.kpi-tooltip-text::after {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: var(--roma-text, #1A1A2E);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* Show text on hover of the .kpi-tooltip wrapper */
.kpi-tooltip:hover .kpi-tooltip-text {
    display: block;
}

/* Backward compat: .kpi-card:hover also shows tooltip-text for legacy cards */
.kpi-card:hover .kpi-tooltip .kpi-tooltip-text {
    display: block;
}

/* ── Customizable KPI Cards ── */
.kpi-card {
    position: relative;
}

.kpi-dismiss {
    position: absolute;
    top: 4px;
    right: 6px;
    width: 20px;
    height: 20px;
    border: none;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 50%;
    font-size: 13px;
    line-height: 1;
    color: #999;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
    opacity: 0;
    padding: 0;
}

.kpi-card:hover .kpi-dismiss {
    opacity: 1;
}

.kpi-dismiss:hover {
    background: var(--roma-danger);
    color: #fff;
}

.kpi-manage-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border: 2px dashed var(--roma-border);
    background: transparent;
    cursor: pointer;
    min-height: 100px;
    transition: all 0.2s ease;
}

.kpi-manage-card:hover {
    border-color: var(--roma-primary);
    background: rgba(138, 30, 65, 0.04);
}

/* ── KPI Config Modal ── */
.kpi-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(26, 26, 46, 0.55);
    backdrop-filter: blur(4px);
    z-index: 2000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 80px;
    animation: modalFadeIn 0.2s ease-out;
}

@keyframes modalFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.kpi-modal-card {
    background: #fff;
    border-radius: 14px;
    width: 420px;
    max-width: 92vw;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: modalSlideUp 0.25s ease-out;
    overflow: hidden;
}

@keyframes modalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.kpi-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--roma-border, #D6D9DE);
    background: linear-gradient(135deg, #8A1E41 0%, #6B1834 100%);
}

.kpi-modal-title {
    font-weight: 700;
    font-size: 15px;
    color: #fff;
    letter-spacing: 0.02em;
}

.kpi-modal-close-btn {
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 6px;
    transition: background 0.15s;
}

.kpi-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.kpi-modal-counter {
    padding: 10px 20px;
    font-size: 12px;
    color: #666;
    font-weight: 600;
    border-bottom: 1px solid #f0f0f0;
    background: var(--roma-bg, #F0F2F5);
}

.kpi-modal-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 0;
}

.kpi-modal-item {
    display: flex;
    align-items: center;
    padding: 10px 20px;
    gap: 12px;
    border-bottom: 1px solid #f5f5f5;
    transition: background 0.15s;
}

.kpi-modal-item:last-child {
    border-bottom: none;
}

.kpi-modal-item:hover {
    background: rgba(138, 30, 65, 0.03);
}

.kpi-modal-item.active {
    background: rgba(138, 30, 65, 0.05);
}

.kpi-modal-check {
    width: 26px;
    height: 26px;
    min-width: 26px;
    border-radius: 6px;
    border: 2px solid #ccc;
    background: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    transition: all 0.15s ease;
    padding: 0;
}

.kpi-modal-check.on {
    background: var(--roma-primary, #8A1E41);
    border-color: var(--roma-primary, #8A1E41);
    color: #fff;
}

.kpi-modal-check.off {
    background: #fff;
    border-color: #ccc;
    color: transparent;
}

.kpi-modal-check:hover {
    border-color: var(--roma-primary, #8A1E41);
}

.kpi-modal-label {
    flex: 1;
    font-size: 13px;
    font-weight: 500;
    color: var(--roma-text, #1A1A2E);
}

.kpi-modal-arrows {
    display: none;
}

.kpi-modal-arrow {
    border: none;
    background: #e9ecef;
    border-radius: 4px;
    width: 24px;
    height: 20px;
    font-size: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: all 0.15s;
    padding: 0;
}

.kpi-modal-arrow:hover {
    background: var(--roma-primary, #8A1E41);
    color: #fff;
}

.kpi-modal-actions {
    display: flex;
    gap: 10px;
    padding: 14px 20px;
    border-top: 1px solid var(--roma-border, #D6D9DE);
    justify-content: flex-end;
    background: var(--roma-bg, #F0F2F5);
}

.kpi-modal-btn {
    border: none;
    border-radius: 8px;
    padding: 8px 20px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s ease;
    letter-spacing: 0.02em;
}

.kpi-modal-btn.primary {
    background: var(--roma-primary, #8A1E41);
    color: #fff;
}

.kpi-modal-btn.primary:hover {
    background: #6B1834;
    box-shadow: 0 2px 8px rgba(138, 30, 65, 0.3);
}

.kpi-modal-btn.secondary {
    background: #fff;
    color: #666;
    border: 1px solid #ccc;
}

.kpi-modal-btn.secondary:hover {
    background: #f0f0f0;
    color: #333;
}

/* ============================================================
   Environmental Map Cards (Point 8)
   ============================================================ */

.env-map-card {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    background: #1A1A2E;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin: 4px 0;
}

.env-map-card iframe {
    display: block;
}

.env-map-expand-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 100;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    background: rgba(26, 26, 46, 0.85);
    color: #FFC61E;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
}

.env-map-expand-btn:hover {
    background: rgba(138, 30, 65, 0.9);
    border-color: rgba(255, 198, 30, 0.5);
    transform: scale(1.1);
    box-shadow: 0 2px 12px rgba(138, 30, 65, 0.4);
}

/* Fullscreen state */
.env-map-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 2000 !important;
    border-radius: 0 !important;
    margin: 0 !important;
}

.env-map-fullscreen .env-map-expand-btn {
    top: 16px;
    right: 16px;
    width: 44px;
    height: 44px;
    font-size: 22px;
}

.env-map-fullscreen .env-map-expand-btn::after {
    content: '✕';
    position: absolute;
    font-size: 14px;
}

.env-map-fullscreen .env-map-expand-btn {
    font-size: 0;
    /* hide ⛶ */
}

.env-map-fullscreen .env-map-expand-btn::after {
    font-size: 18px;
}

/* Coordinate overlay */
.env-map-card .map-overlay-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 10px;
    background: rgba(26, 26, 46, 0.8);
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    border-radius: 4px;
    font-family: 'Titillium Web', monospace;
    pointer-events: none;
    z-index: 50;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ═══════════════════════════════════════
   Urban Map — Checkbox Panel (Sicurezza Urbana)
   ═══════════════════════════════════════ */

.urban-map-card {
    position: relative;
    background: #1A1A2E;
}

.urban-map-card .map-overlay-info {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 4px 10px;
    background: rgba(26, 26, 46, 0.8);
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
    border-radius: 4px;
    font-family: 'Titillium Web', monospace;
    pointer-events: none;
    z-index: 50;
    backdrop-filter: blur(4px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Floating glassmorphism checkbox panel */
.urban-map-checkbox-panel {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(26, 26, 46, 0.88);
    backdrop-filter: blur(10px);
    border-radius: 10px;
    padding: 10px 14px;
    z-index: 100;
    min-width: 180px;
    border: 1px solid rgba(255, 198, 30, 0.2);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

/* Checklist layout */
.urban-map-checklist {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.urban-map-checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
    transition: background 0.15s ease;
    color: #fff;
    font-size: 12px;
}

.urban-map-checkbox-label:hover {
    background: rgba(255, 255, 255, 0.08);
}

.urban-map-checkbox {
    accent-color: var(--roma-secondary);
    width: 14px;
    height: 14px;
    cursor: pointer;
    flex-shrink: 0;
}

/* Sub-tab buttons share env styling */
.urban-subtab-bar {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    padding: 8px 0;
    border-bottom: 1px solid #e8e8e8;
    margin-bottom: 8px;
}