:root {
    --primary: #1E9E4B;
    --primary-dark: #17843E;
    --primary-light: #6fd68f;
    --text-primary: #15212B;
    --text-secondary: #6B7B8C;
    --bg: #F6F8FA;
    --surface: #ffffff;
    --border: #E3E8EE;
    --dark-card: #16212C;
    --danger: #DC3B3B;
    --danger-bg: #FBE6E6;
    --success-bg: #E7F7EC;
    --tip-bg: #E7F7EC;
    --disabled: #AEB7C2;
    --shadow: 0 8px 24px rgba(21, 33, 43, 0.08);
    font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--text-primary);
    background: var(--bg);
}

.sidebar .sidebar-nav-list a.sidebar-link,
.sidebar .sidebar-nav-list a.sidebar-link:any-link,
.sidebar .sidebar-nav-list a.sidebar-link:link,
.sidebar .sidebar-nav-list a.sidebar-link:visited,
.sidebar .sidebar-nav-list a.sidebar-link:hover,
.sidebar .sidebar-nav-list a.sidebar-link:active,
.sidebar .sidebar-nav-list a.sidebar-link:focus,
.sidebar .sidebar-nav-list a.sidebar-link.sidebar-link-active,
.sidebar .sidebar-nav-list a.sidebar-link .sidebar-link-label {
    color: #fff !important;
    text-decoration: none !important;
}

h1, h2, h3 {
    margin: 0 0 0.35rem;
}

.page-header {
    margin-bottom: 1.5rem;
}

.page-header-with-actions {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
}

.page-header-actions {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.extraction-compare-mismatch-alert {
    margin-bottom: 1rem;
}

.verifica-offerta-esito {
    margin: 0 0 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-align: center;
}

.verdict-fregatura {
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
}

.verdict-conveniente {
    background: #ecfdf5;
    color: #047857;
    border: 1px solid #a7f3d0;
}

.verdict-attenzione {
    background: #fffbeb;
    color: #b45309;
    border: 1px solid #fde68a;
}

.verifica-check-badge {
    display: inline-block;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 700;
}

.check-fail {
    background: #fee2e2;
    color: #b91c1c;
}

.check-pass {
    background: #dcfce7;
    color: #15803d;
}

.check-neutral {
    background: #fef3c7;
    color: #b45309;
}

.modal-panel-wide {
    max-width: 920px;
}

.modal-panel-verifica {
    max-width: min(1120px, calc(100vw - 2rem));
    width: 100%;
}

.verifica-tabs {
    padding: 0 1.5rem;
}

.verifica-discord-alert-tabs {
    margin: 0 1.5rem;
    margin-top: 0.75rem;
}

.verifica-modal-body {
    padding-top: 1rem;
}

.verifica-tab-panel {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.verifica-context-summary {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.verifica-context-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 1rem;
}

.verifica-context-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.verifica-context-label {
    font-size: 0.72rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.verifica-context-value {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary);
    word-break: break-word;
}

.verifica-checks-table-wrap {
    overflow-x: auto;
}

.verifica-checks-table {
    min-width: 760px;
}

.verifica-source-cell {
    max-width: 220px;
    word-break: break-word;
}

.verifica-dual-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    align-items: start;
}

.verifica-dual-column {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.verifica-discord-alert {
    margin-bottom: 1rem;
}

.verifica-reference-thresholds {
    margin-bottom: 1.25rem;
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.verifica-reference-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.65rem 1rem;
}

.verifica-reference-item {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    min-width: 0;
}

.verifica-reference-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.verifica-reference-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.verifica-summary {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.modal-panel-verifica-scelta {
    max-width: 34rem;
}

.verifica-scelta-summary {
    display: grid;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.verifica-scelta-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.verifica-scelta-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.verifica-scelta-item .verifica-offerta-esito {
    margin: 0;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    flex: 0 0 auto;
}

.verifica-scelta-hint {
    margin: 0;
}

.verifica-scelta-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0 1.25rem 1.25rem;
}

.verifica-loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.82);
}

.extraction-subtitle-sm {
    margin: 0 0 0.5rem;
    font-size: 0.88rem;
    font-weight: 700;
}

@media (max-width: 900px) {
    .verifica-context-grid,
    .verifica-reference-grid {
        grid-template-columns: 1fr;
    }

    .verifica-dual-grid {
        grid-template-columns: 1fr;
    }
}

.page-subtitle {
    color: var(--text-secondary);
    margin: 0;
}

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow);
}

.table-card {
    overflow: hidden;
}

.table-filters-panel {
    border-bottom: 1px solid var(--border);
}

.table-filters-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.85rem 1rem;
    border: none;
    background: var(--primary);
    cursor: pointer;
    font: inherit;
    color: #fff;
    text-align: left;
}

.table-filters-toggle:hover {
    background: var(--primary-dark);
}

.table-filters-toggle-label {
    font-weight: 600;
}

.table-filters-toggle-badge {
    padding: 0.15rem 0.5rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.22);
    color: #fff;
    font-size: 0.75rem;
    font-weight: 600;
}

.table-filters-chevron {
    margin-left: auto;
    width: 0.55rem;
    height: 0.55rem;
    border-right: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(45deg);
    transition: transform 0.15s ease;
}

.table-filters-chevron.expanded {
    transform: rotate(-135deg);
    margin-top: 0.2rem;
}

.table-filters-body.is-collapsed {
    display: none;
}

.table-filters {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    padding: 0 1rem;
}

.table-card > .table-filters {
    padding: 1rem 1rem 0.85rem;
    margin-bottom: 0;
    background: #f4f7f5;
    border-bottom: 2px solid var(--border);
}

.table-filters-users {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-filters-pair {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.table-filters-news-pair {
    grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr);
}

.table-filters .form-group {
    margin-bottom: 1rem;
}

.status-filter {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    padding: 0.3rem;
    min-height: 48px;
    align-items: center;
    background: #f8fafb;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.status-filter-compact {
    flex-wrap: nowrap;
}

.status-filter-compact .status-filter-btn {
    flex: 1 1 auto;
    white-space: nowrap;
}

.status-filter-btn {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.55rem 0.65rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.status-filter-btn:hover:not(.active) {
    background: rgba(255, 255, 255, 0.7);
    color: var(--text-primary);
}

.status-filter-btn.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(21, 33, 43, 0.08);
}

.status-filter-btn-success.active {
    color: var(--primary-dark);
    background: var(--success-bg);
    box-shadow: inset 0 0 0 1px #c9ebd4;
}

.status-filter-btn-danger.active {
    color: var(--danger);
    background: var(--danger-bg);
    box-shadow: inset 0 0 0 1px #f0caca;
}

.status-filter-btn-info.active {
    color: #1565c0;
    background: #e8f4fd;
    box-shadow: inset 0 0 0 1px #bbdefb;
}

.role-picker {
    width: 100%;
    max-width: 320px;
}

.role-picker .status-filter-btn {
    min-height: 44px;
}

.form-select,
select.form-control:not(.page-size-select) {
    appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236B7B8C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    padding-right: 2.25rem;
    cursor: pointer;
}

.form-select:focus,
select.form-control:not(.page-size-select):focus {
    outline: 2px solid rgba(30, 158, 75, 0.25);
    border-color: var(--primary);
}

.table-empty-state {
    padding: 1.25rem 1rem 0;
}

.table-inline-alert {
    margin: 0 1rem 0.75rem;
}

.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 0.85rem 1rem 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

.pagination-summary {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    flex-wrap: wrap;
}

.pagination-page-size {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
}

.page-size-select {
    width: auto;
    min-width: 4.5rem;
    padding: 0.45rem 0.65rem;
    font-size: 0.9rem;
    appearance: none;
    background-color: #fff;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12' fill='none'%3E%3Cpath d='M3 4.5L6 7.5L9 4.5' stroke='%236B7B8C' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.55rem center;
    padding-right: 1.75rem;
}

.pagination-page-label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 600;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .table-pagination {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination-controls {
        justify-content: space-between;
    }
}

@media (max-width: 900px) {
    .table-filters,
    .table-filters-users,
    .table-filters-pair,
    .table-filters-news-pair {
        grid-template-columns: 1fr;
    }
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 0.9rem 1rem;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    background: #fafbfc;
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--text-secondary);
}

.data-table.compact th,
.data-table.compact td {
    padding: 0.7rem 0.85rem;
}

.clickable-row {
    cursor: pointer;
    transition: background 0.12s ease;
}

.clickable-row:hover {
    background: #f3faf5;
}

.nested-detail-row > td {
    padding: 0 0.85rem 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: top;
}

.nested-detail-row .nested-detail {
    margin-top: 0;
}

.badge {
    display: inline-block;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--primary-dark);
}

.badge-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.badge-info {
    background: #e8f4fd;
    color: #1565c0;
}

.badge-neutral {
    background: #eef1f4;
    color: #5c6b7a;
}

.badge-warning {
    background: #fff3e0;
    color: #e65100;
}

.news-category-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.news-category-group,
.news-flags-group {
    margin-bottom: 0.25rem;
}

.news-choice-grid {
    display: grid;
    gap: 0.65rem;
}

.news-category-picker {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.news-flags-picker {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.news-choice-card {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    width: 100%;
    margin: 0;
    padding: 0.85rem 0.95rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #f8fafb;
    color: var(--text-secondary);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, color 0.15s ease, transform 0.15s ease;
}

.news-choice-card:hover {
    background: #fff;
    border-color: #cfd8e3;
    color: var(--text-primary);
}

.news-choice-card.is-selected {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 1px 6px rgba(21, 33, 43, 0.08);
}

.news-choice-dot {
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    flex-shrink: 0;
    background: currentColor;
    opacity: 0.45;
}

.news-choice-label {
    font-size: 0.92rem;
    font-weight: 700;
    line-height: 1.2;
}

.news-category-card {
    justify-content: center;
    min-height: 3rem;
}

.news-category-card-arera.is-selected {
    color: #5c6b7a;
    background: #eef1f4;
    border-color: #d5dde6;
    box-shadow: inset 0 0 0 1px #d5dde6;
}

.news-category-card-consiglio.is-selected {
    color: #1565c0;
    background: #e8f4fd;
    border-color: #bbdefb;
    box-shadow: inset 0 0 0 1px #bbdefb;
}

.news-category-card-mercato.is-selected {
    color: #e65100;
    background: #fff3e0;
    border-color: #ffe0b2;
    box-shadow: inset 0 0 0 1px #ffe0b2;
}

.news-category-card-diritti.is-selected {
    color: #3949ab;
    background: #e8eaf6;
    border-color: #c5cae9;
    box-shadow: inset 0 0 0 1px #c5cae9;
}

.news-category-card.is-selected .news-choice-dot {
    opacity: 1;
}

.news-flag-card {
    min-height: 4.25rem;
    align-items: flex-start;
}

.news-flag-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: 10px;
    flex-shrink: 0;
    background: #eef1f4;
    color: var(--text-secondary);
}

.news-flag-icon svg {
    width: 1.15rem;
    height: 1.15rem;
}

.news-flag-copy {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    flex: 1;
}

.news-flag-desc {
    font-size: 0.78rem;
    font-weight: 500;
    line-height: 1.35;
    color: var(--text-secondary);
}

.news-flag-switch {
    position: relative;
    width: 2.4rem;
    height: 1.35rem;
    margin-top: 0.15rem;
    border-radius: 999px;
    background: #d5dde6;
    flex-shrink: 0;
    transition: background 0.15s ease;
}

.news-flag-switch-knob {
    position: absolute;
    top: 0.15rem;
    left: 0.15rem;
    width: 1.05rem;
    height: 1.05rem;
    border-radius: 999px;
    background: #fff;
    box-shadow: 0 1px 3px rgba(21, 33, 43, 0.18);
    transition: transform 0.15s ease;
}

.news-flag-card.is-selected .news-flag-switch-knob {
    transform: translateX(1.05rem);
}

.news-flag-alert.is-selected {
    color: #e65100;
    background: #fff8f1;
    border-color: #ffcc80;
    box-shadow: inset 0 0 0 1px #ffe0b2;
}

.news-flag-alert.is-selected .news-flag-icon {
    background: #ffe0b2;
    color: #e65100;
}

.news-flag-alert.is-selected .news-flag-switch {
    background: #fb8c00;
}

.news-flag-tip.is-selected {
    color: #1565c0;
    background: #f3f9fe;
    border-color: #90caf9;
    box-shadow: inset 0 0 0 1px #bbdefb;
}

.news-flag-tip.is-selected .news-flag-icon {
    background: #bbdefb;
    color: #1565c0;
}

.news-flag-tip.is-selected .news-flag-switch {
    background: #1e88e5;
}

.news-flag-card.is-selected .news-flag-desc {
    color: inherit;
    opacity: 0.75;
}

.news-flag-card.is-disabled,
.news-flag-card:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    box-shadow: none;
}

.news-flag-card.is-disabled:hover,
.news-flag-card:disabled:hover {
    background: #f8fafb;
    border-color: var(--border);
    color: var(--text-secondary);
}

@media (max-width: 720px) {
    .news-category-picker,
    .news-flags-picker {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 480px) {
    .news-category-picker,
    .news-flags-picker {
        grid-template-columns: 1fr;
    }
}

.badge-primary {
    background: #e8eaf6;
    color: #3949ab;
}

.form-group-wide {
    grid-column: 1 / -1;
}

.configuration-table .config-key {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text-primary, #1a2e22);
}

.config-value-input {
    max-width: 12rem;
}

.configuration-table .table-actions {
    white-space: nowrap;
}

.card-section-title {
    margin: 0 0 1rem;
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary, #1a2e22);
}

.push-compose-card {
    margin-bottom: 1.25rem;
    padding: 1.25rem 1.5rem;
}

.push-history-card {
    padding-top: 1.25rem;
}

.push-compose-form {
    display: grid;
    gap: 1rem;
}

.push-body-input {
    min-height: 6rem;
    resize: vertical;
}

.push-body-cell {
    max-width: 28rem;
    white-space: pre-wrap;
}

.push-history-card .card-section-title,
.push-compose-card .card-section-title {
    padding: 0 0.25rem;
}

.btn {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, opacity 0.15s ease;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-outline {
    background: #fff;
    color: var(--danger);
    border: 1px solid #f0caca;
}

.btn-outline-neutral {
    background: #fff;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline-neutral:hover:not(:disabled) {
    color: var(--text-primary);
    border-color: #cfd6de;
    background: #fafbfc;
}

.btn-sm {
    padding: 0.4rem 0.75rem;
    font-size: 0.85rem;
}

.btn-block {
    width: 100%;
}

.btn-icon {
    background: transparent;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--text-secondary);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.35rem;
    font-weight: 600;
    font-size: 0.9rem;
}

.form-group label.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    cursor: pointer;
}

.form-group label.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-control {
    width: 100%;
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 1rem;
}

.form-control:focus {
    outline: 2px solid rgba(30, 158, 75, 0.25);
    border-color: var(--primary);
}

.form-textarea {
    min-height: 180px;
    resize: vertical;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.92rem;
}

.field-hint {
    margin: 0.45rem 0 0;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.rich-text-editor {
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    background: #fff;
}

.rich-text-editor-host {
    min-height: 220px;
}

.rich-text-editor .ql-toolbar.ql-snow {
    border: none;
    border-bottom: 1px solid var(--border);
    background: #f8fafb;
}

.rich-text-editor .ql-container.ql-snow {
    border: none;
    font-family: inherit;
    font-size: 0.95rem;
}

.rich-text-editor .ql-editor {
    min-height: 180px;
}

.rich-text-editor .ql-editor.ql-blank::before {
    color: #9aa7b5;
    font-style: normal;
}

.preview-cell {
    color: var(--text-secondary);
    max-width: 320px;
}

.table-actions {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
    white-space: nowrap;
}

.alert {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    margin-bottom: 1rem;
}

.alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
}

.delete-account-panel p {
    margin: 0 0 0.75rem;
}

.delete-account-panel .modal-header-actions {
    margin-top: 0.5rem;
    gap: 0.5rem;
}

.loading-state,
.empty-state {
    color: var(--text-secondary);
    padding: 1rem 0;
}

.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: linear-gradient(160deg, #e7f7ec 0%, var(--bg) 45%, #ffffff 100%);
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 2rem;
    box-shadow: var(--shadow);
}

.login-brand {
    text-align: center;
    margin-bottom: 1.75rem;
}

.login-brand .app-logo {
    margin: 0 auto 0.75rem;
}

.login-brand p {
    color: var(--text-secondary);
    margin: 0.5rem 0 0;
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(21, 33, 43, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
}

.modal-panel {
    width: min(920px, 100%);
    max-height: 90vh;
    overflow: auto;
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1.25rem 1.5rem 0.75rem;
    border-bottom: 1px solid var(--border);
}

.modal-header-main {
    min-width: 0;
    flex: 1;
}

.modal-header-main h2 {
    margin: 0;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* User detail: dense action row must not cover header email on desktop. */
.modal-panel-user-detail .modal-header {
    flex-wrap: wrap;
    align-items: flex-start;
    row-gap: 0.75rem;
}

.modal-panel-user-detail .modal-header-main {
    flex: 1 1 12rem;
}

.modal-panel-user-detail .modal-header-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    max-width: 100%;
}

.modal-panel-user-detail .modal-subtitle {
    overflow-wrap: anywhere;
}

@media (max-width: 768px) {
    .modal-header {
        flex-direction: column;
        align-items: stretch;
    }

    .modal-header-actions {
        flex-wrap: wrap;
        justify-content: flex-end;
    }
}

.modal-subtitle {
    color: var(--text-secondary);
    margin: 0;
}

.tabs {
    display: flex;
    gap: 0.35rem;
    padding: 0.75rem 1.5rem 0;
    border-bottom: 1px solid var(--border);
}

.tab {
    background: transparent;
    border: none;
    padding: 0.65rem 0.9rem;
    border-radius: 10px 10px 0 0;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 600;
}

.tab.active {
    color: var(--primary-dark);
    background: var(--tip-bg);
}

.modal-body {
    padding: 1.25rem 1.5rem 1.5rem;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.profile-form {
    margin-bottom: 1.25rem;
}

.modal-detail-grid {
    margin-top: 0.5rem;
}

.modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}

.alert-success {
    background: var(--success-bg);
    color: var(--primary-dark);
    border: 1px solid #c9ebd4;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.alert-warning {
    background: #fff8e6;
    color: #8a6d00;
    border: 1px solid #f0e0a0;
    border-radius: 10px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
}

.operation-message {
    margin: 0 0 0.75rem;
}

.password-reset-link-block {
    margin-top: 0.75rem;
}

.password-reset-link-block label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.password-reset-link-block .form-hint {
    margin: 0.5rem 0 0;
    font-size: 0.875rem;
    opacity: 0.85;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.detail-item.full-width {
    grid-column: 1 / -1;
}

.detail-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    font-weight: 600;
}

.mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.85rem;
    word-break: break-all;
}

.nested-detail {
    margin-top: 1.25rem;
    padding: 1rem;
    border-radius: 12px;
    background: var(--tip-bg);
    border: 1px solid #c9ebd4;
}

.link-action {
    color: var(--primary-dark);
    font-weight: 600;
    text-decoration: none;
}

.link-action:hover {
    text-decoration: underline;
}

.warnings {
    margin-top: 1rem;
}

.warning-item {
    padding: 0.5rem 0.75rem;
    background: #fff8e6;
    border-radius: 8px;
    margin-bottom: 0.35rem;
    font-size: 0.9rem;
}

.extraction-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
}

.extraction-compare-upload-bar {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.25rem;
    padding: 1rem 1.25rem;
    margin-bottom: 0.5rem;
}

.extraction-compare-upload-item {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    min-width: 0;
}

.extraction-compare-upload-label {
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 700;
    color: var(--text-secondary);
    margin: 0;
}

.extraction-compare-upload-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 2rem;
}

.extraction-reload-btn {
    align-self: flex-start;
}

.extraction-reload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.extraction-saved-hint {
    margin: 0;
}

.extraction-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    padding: 2.5rem 1rem;
    border-radius: 12px;
    background: #f8fafc;
    border: 1px solid #e6ebf0;
}

.extraction-spinner {
    width: 2.25rem;
    height: 2.25rem;
    border: 3px solid #dbeafe;
    border-top-color: var(--primary, #1f7a4d);
    border-radius: 50%;
    animation: extraction-spin 0.75s linear infinite;
}

.extraction-loading-text {
    font-size: 0.92rem;
    color: var(--text-secondary);
    text-align: center;
}

@keyframes extraction-spin {
    to {
        transform: rotate(360deg);
    }
}

.extraction-compare-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1.5rem;
    align-items: start;
}

.extraction-compare-column {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.extraction-compare-column-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.extraction-compare-title {
    margin: 0 0 0.75rem;
    font-size: 1rem;
    font-weight: 700;
}

.extraction-compare-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.25rem 0.65rem;
    border-radius: 999px;
    border: 1px solid transparent;
}

.extraction-upload-card-compact {
    margin-bottom: 0;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.extraction-compare-hint {
    margin-top: 1rem;
    text-align: center;
}

.extraction-compare-column .extraction-grid {
    grid-template-columns: 1fr;
}

.extraction-compare-column .extraction-result {
    margin-top: 0;
}

.extraction-compare-column .extraction-supply-banner {
    flex-direction: column;
    align-items: flex-start;
}

.extraction-compare-column .extraction-table .mono {
    max-width: 100%;
    word-break: break-word;
}

.extraction-tab {
    border: 1px solid var(--border-color, #d8dee9);
    background: #fff;
    color: var(--text-primary);
    border-radius: 999px;
    padding: 0.45rem 1rem;
    font-weight: 600;
    cursor: pointer;
}

.extraction-tab.active {
    background: var(--primary, #1f7a4d);
    border-color: var(--primary, #1f7a4d);
    color: #fff;
}

.extraction-upload-card {
    margin-bottom: 1.25rem;
    padding: 1.25rem;
}

.extraction-upload-row {
    display: flex;
    flex-wrap: wrap;
    gap: 1.25rem;
    align-items: flex-end;
    justify-content: space-between;
}

.extraction-file-group {
    flex: 1 1 320px;
    margin: 0;
}

.extraction-upload-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.extraction-selected-file {
    margin: 0.5rem 0 0;
    font-size: 0.9rem;
}

.extraction-result {
    margin-top: 1rem;
}

.extraction-section-title {
    margin: 0 0 1rem;
    font-size: 1.15rem;
}

.extraction-subsection {
    margin-top: 1.5rem;
}

.extraction-subtitle {
    margin: 0 0 0.75rem;
    font-size: 1rem;
}

.extraction-grid {
    margin-bottom: 0.5rem;
}

.extraction-field {
    padding: 0.85rem 1rem;
    border-radius: 10px;
    background: #fff;
    border: 1px solid #e6ebf0;
}

.extraction-field-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.extraction-value {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.extraction-raw {
    margin-top: 0.35rem;
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.extraction-children {
    margin-top: 0.75rem;
    display: grid;
    gap: 0.75rem;
}

.confidence-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 0.15rem 0.45rem;
    border-radius: 999px;
    white-space: nowrap;
}

.confidence-high {
    background: #e6f6ec;
    color: #1f7a4d;
}

.confidence-medium {
    background: #fff8e6;
    color: #9a6700;
}

.confidence-low {
    background: #fdecec;
    color: #b42318;
}

.confidence-unknown {
    background: #eef2f7;
    color: #5b6777;
}

.extraction-table .mono {
    max-width: 280px;
}

.extraction-supply-banner {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem 1.25rem;
    padding: 1rem 1.25rem;
    border-radius: 14px;
    margin-bottom: 1.25rem;
    border: 1px solid transparent;
}

.extraction-supply-kicker {
    display: block;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    opacity: 0.85;
    margin-bottom: 0.15rem;
}

.extraction-supply-title {
    font-size: 1.25rem;
}

.extraction-supply-provider {
    font-weight: 600;
    opacity: 0.9;
}

.supply-luce {
    background: linear-gradient(135deg, #fff9e6 0%, #fff3cc 100%);
    border-color: #f0d878;
    color: #7a5b00;
}

.supply-gas {
    background: linear-gradient(135deg, #eef6ff 0%, #dbeafe 100%);
    border-color: #93c5fd;
    color: #1e3a8a;
}

.supply-unknown {
    background: #f3f4f6;
    border-color: #d1d5db;
    color: #374151;
}

.extraction-result-sections {
    display: grid;
    gap: 1.25rem;
}

.extraction-result-section {
    padding: 1rem 1.1rem;
    border-radius: 12px;
    background: #fff;
    border: 1px solid #e6ebf0;
}

#blazor-error-ui {
    display: none;
}

.extraction-prompt-version-badge {
    margin: 0 0 0.75rem;
}

.extraction-prompt-editor-compact .extraction-prompt-textarea {
    min-height: 280px;
}

.modal-panel-extraction-prompt {
    width: min(960px, 100%);
}

.btn-icon-prompt {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.65rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #fff;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.btn-icon-prompt svg {
    width: 1.15rem;
    height: 1.15rem;
    flex-shrink: 0;
}

.btn-icon-prompt:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(30, 158, 75, 0.06);
}

.btn-icon-prompt:focus-visible {
    outline: 2px solid rgba(30, 158, 75, 0.35);
    outline-offset: 2px;
}

@media (max-width: 640px) {
    .btn-icon-prompt-label {
        display: none;
    }

    .btn-icon-prompt {
        padding: 0.5rem;
    }
}

.extraction-prompts-section {
    margin: 1.25rem 0 1.75rem;
}

.extraction-prompts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 0.75rem;
}

.extraction-prompt-card {
    padding: 1rem 1.1rem;
}

.extraction-prompt-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.extraction-prompt-title {
    margin: 0;
    font-size: 1.05rem;
}

.extraction-prompt-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.35rem;
}

.extraction-prompt-textarea {
    min-height: 220px;
    margin-bottom: 0.75rem;
}

.extraction-prompt-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.extraction-prompt-history {
    margin-top: 0.5rem;
    table-layout: fixed;
}

.extraction-prompt-history th.extraction-prompt-history-status-col,
.extraction-prompt-history td.extraction-prompt-history-status-col {
    width: 7.5rem;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}

.extraction-prompt-history th.extraction-prompt-history-view-col,
.extraction-prompt-history td.extraction-prompt-history-view-col {
    width: 4.75rem;
    text-align: right;
    white-space: nowrap;
    vertical-align: middle;
}

.extraction-prompt-history-row-selected {
    background: #f3faf5;
}

.extraction-prompt-version-preview-backdrop {
    z-index: 1100;
}

.modal-panel-extraction-prompt-preview {
    width: min(960px, 100%);
}

.extraction-prompt-preview-textarea {
    min-height: min(60vh, 480px);
    background: #fff;
    color: var(--text-primary);
    cursor: default;
}

@media (max-width: 1100px) {
    .extraction-compare-grid,
    .extraction-compare-upload-bar,
    .extraction-prompts-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 640px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

/* —— Statistiche backoffice —— */
.stats-page {
    position: relative;
    min-height: 100%;
    margin: -2rem;
    padding: 2rem;
    background:
        radial-gradient(ellipse 80% 50% at 0% 0%, rgba(30, 158, 75, 0.08), transparent 55%),
        radial-gradient(ellipse 60% 40% at 100% 10%, rgba(29, 78, 216, 0.06), transparent 50%),
        linear-gradient(180deg, #f3f7f5 0%, var(--bg) 45%, #eef3f7 100%);
}

.stats-hero {
    margin-bottom: 1.5rem;
    padding: 1.25rem 1.35rem;
    border-radius: 16px;
    border: 1px solid rgba(30, 158, 75, 0.18);
    background:
        linear-gradient(135deg, rgba(255, 255, 255, 0.92), rgba(231, 247, 236, 0.65));
    box-shadow: var(--shadow);
}

.stats-hero-eyebrow {
    margin: 0 0 0.35rem;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--primary-dark);
}

.stats-kpi-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}

.stats-kpi-tile {
    position: relative;
    display: flex;
    overflow: hidden;
    min-height: 9.5rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: 0 4px 16px rgba(21, 33, 43, 0.05);
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.35s ease, transform 0.35s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.stats-kpi-tile.is-ready,
.stats-kpi-tile[aria-busy="true"] {
    opacity: 1;
    transform: none;
}

.stats-kpi-tile:hover {
    box-shadow: 0 10px 28px rgba(21, 33, 43, 0.08);
    border-color: #d5dde6;
}

.stats-kpi-tile-accent {
    width: 4px;
    flex-shrink: 0;
    background: var(--primary);
}

.stats-kpi-tile-primary .stats-kpi-tile-accent { background: var(--primary); }
.stats-kpi-tile-blue .stats-kpi-tile-accent { background: #1d4ed8; }
.stats-kpi-tile-success .stats-kpi-tile-accent { background: #047857; }
.stats-kpi-tile-danger .stats-kpi-tile-accent { background: #b91c1c; }
.stats-kpi-tile-neutral .stats-kpi-tile-accent { background: #64748b; }

.stats-kpi-tile-body {
    flex: 1;
    min-width: 0;
    padding: 1rem 1.1rem 1.05rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.stats-kpi-tile-header {
    display: flex;
    align-items: center;
    gap: 0.55rem;
}

.stats-kpi-tile-icon {
    display: inline-flex;
    width: 1.65rem;
    height: 1.65rem;
    color: var(--text-secondary);
}

.stats-kpi-tile-primary .stats-kpi-tile-icon { color: var(--primary-dark); }
.stats-kpi-tile-blue .stats-kpi-tile-icon { color: #1d4ed8; }
.stats-kpi-tile-success .stats-kpi-tile-icon { color: #047857; }
.stats-kpi-tile-danger .stats-kpi-tile-icon { color: #b91c1c; }

.stats-kpi-tile-icon svg {
    width: 100%;
    height: 100%;
}

.stats-kpi-tile-title {
    margin: 0;
    font-size: 0.82rem;
    font-weight: 650;
    color: var(--text-secondary);
    letter-spacing: 0.01em;
}

.stats-kpi-tile-value-row {
    display: flex;
    align-items: baseline;
    gap: 0.45rem;
    margin-top: auto;
}

.stats-kpi-tile-value {
    font-size: 2rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
}

.stats-kpi-tile-unit {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.stats-kpi-tile-loading,
.stats-trend-loading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    margin-top: auto;
    color: var(--text-secondary);
    font-size: 0.85rem;
}

.stats-kpi-spinner {
    width: 1.15rem;
    height: 1.15rem;
    border: 2px solid #dbeafe;
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: extraction-spin 0.75s linear infinite;
}

.stats-kpi-tile-error,
.stats-trend-error {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.55rem;
    margin-top: auto;
    color: var(--danger);
    font-size: 0.85rem;
}

.stats-kpi-tile-error p,
.stats-trend-error p {
    margin: 0;
}

.stats-trend-panel {
    padding: 1.25rem 1.35rem 1.5rem;
    border-radius: 16px;
    border: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    box-shadow: var(--shadow);
}

.stats-trend-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.15rem;
}

.stats-section-title {
    margin: 0 0 0.25rem;
    font-size: 1.15rem;
}

.stats-section-subtitle {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.stats-trend-range {
    display: inline-flex;
    padding: 0.2rem;
    border-radius: 999px;
    background: #eef2f6;
    gap: 0.15rem;
}

.stats-range-btn {
    border: none;
    background: transparent;
    padding: 0.4rem 0.75rem;
    border-radius: 999px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
}

.stats-range-btn.active {
    background: #fff;
    color: var(--text-primary);
    box-shadow: 0 1px 4px rgba(21, 33, 43, 0.1);
}

.stats-trend-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 1rem;
}

.stats-chart-card {
    padding: 0.9rem 1rem 0.65rem;
    border-radius: 12px;
    border: 1px solid var(--border);
    background: #fbfcfd;
}

.stats-chart-card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.35rem;
}

.stats-chart-card-header h3 {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stats-chart-total {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    font-variant-numeric: tabular-nums;
}

.stats-chart-svg-wrap svg {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 1100px) {
    .stats-kpi-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 720px) {
    .stats-page {
        margin: -1rem;
        padding: 1rem;
    }

    .stats-kpi-grid,
    .stats-trend-grid {
        grid-template-columns: 1fr;
    }
}

