* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: Arial, sans-serif;
    background: #f5f7fb;
    color: #1f2937;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px;
}

.wide-container {
    max-width: 1680px;
}

.topbar {
    background: #111827;
    color: #fff;
}

.topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
    padding-top: 0;
    padding-bottom: 0;
}

.brand {
    font-weight: 700;
    font-size: 20px;
}

.brand-with-logo {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-logo {
    height: 34px;
    width: auto;
    object-fit: contain;
}

.login-logo-wrap {
    text-align: center;
    margin-bottom: 20px;
}

.home-splash {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 64px);
}

.home-logo {
    width: 420px;
    max-width: 80vw;
    height: auto;
}

.login-logo {
    height: 64px;
    width: auto;
    display: inline-block;
}

.nav a {
    color: #fff;
    text-decoration: none;
    margin-left: 16px;
}

.page-header {
    margin-bottom: 24px;
}

.muted {
    color: #6b7280;
}

.card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stats-grid-5 {
    grid-template-columns: repeat(5, 1fr);
}

.stat-card {
    text-align: center;
}

.stat-label {
    color: #6b7280;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
}

.auth-wrapper {
    min-height: calc(100vh - 120px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.auth-card {
    width: 100%;
    max-width: 420px;
}

.form-group {
    margin-bottom: 16px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
}

input,
select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
}

.btn {
    background: #2563eb;
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 10px 16px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    display: inline-block;
}

.btn-secondary {
    background: #4b5563;
    color: #fff;
}

.btn-danger {
    background: #dc2626;
    color: #fff;
}

.btn-success {
    background: #16a34a;
    color: #fff;
}

.btn-warning {
    background: #d97706;
    color: #fff;
}

.btn-neutral {
    background: #9ca3af;
    color: #fff;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 13px;
}

/* Pulsante solo icona (es. cestino) */
.btn-icon {
    padding: 6px 9px;
    line-height: 1;
    background: transparent;
    color: #dc2626;
    border: 1px solid #dc2626;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #dc2626;
    color: #fff;
}

.alert {
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    text-align: left;
    padding: 12px;
    border-bottom: 1px solid #e5e7eb;
    vertical-align: top;
}

.inline-form {
    display: inline;
}

.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(17, 24, 39, 0.45);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-overlay.hidden {
    display: none;
}

.loading-box {
    background: #fff;
    padding: 24px 28px;
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    text-align: center;
    min-width: 260px;
}

.spinner {
    width: 38px;
    height: 38px;
    border: 4px solid #dbeafe;
    border-top-color: #2563eb;
    border-radius: 50%;
    margin: 0 auto 14px auto;
    animation: spin 0.9s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

body.loading-active {
    overflow: hidden;
}

.breadcrumbs {
    display: flex;
    gap: 8px;
    align-items: center;
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 18px;
    flex-wrap: wrap;
}

.breadcrumbs a {
    color: #2563eb;
    text-decoration: none;
}

.action-group {
    display: flex;
    flex-wrap: nowrap;
    gap: 6px;
    align-items: center;
}

.action-group-column {
    align-items: flex-start;
    flex-direction: column;
}

.documents-table .actions-col {
    width: 260px;
}

.actions-cell {
    white-space: nowrap;
}

.table-responsive {
    overflow-x: auto;
}

.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-green {
    background: #dcfce7;
    color: #166534;
}

.badge-red {
    background: #fee2e2;
    color: #991b1b;
}

.badge-orange {
    background: #ffedd5;
    color: #9a3412;
}

.badge-blue {
    background: #dbeafe;
    color: #1d4ed8;
}

.badge-neutral {
    background: #e5e7eb;
    color: #374151;
}

.analysis-toolbar {
    display: flex;
    justify-content: space-between;
    gap: 24px;
    align-items: flex-start;
    flex-wrap: wrap;
}

.analysis-table th,
.analysis-table td {
    font-size: 14px;
}

.documents-table a {
    text-decoration: none;
}

.documents-table a:hover,
.breadcrumbs a:hover,
.nav a:hover {
    text-decoration: underline;
}

.btn.is-loading {
    opacity: 0.75;
}

.analysis-info p {
    margin: 4px 0;
}

.action-note {
    margin: 8px 0 0 0;
    max-width: 380px;
}

.csv-status-box {
    margin-top: 16px;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid transparent;
    line-height: 1.45;
}

.csv-status-box.hidden {
    display: none;
}

.csv-status-box.is-info {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1e3a8a;
}

.csv-status-box.is-success {
    background: #ecfdf5;
    border-color: #bbf7d0;
    color: #166534;
}

.csv-status-box.is-error {
    background: #fef2f2;
    border-color: #fecaca;
    color: #991b1b;
}

.csv-status-timing,
.csv-status-note {
    margin-top: 6px;
}
.calc-details {
    margin-top: 6px;
}

.calc-details summary {
    cursor: pointer;
    color: #2563eb;
    font-size: 12px;
    font-weight: 600;
    user-select: none;
}

.calc-details summary:hover {
    text-decoration: underline;
}

.calc-details-content {
    margin-top: 6px;
    padding: 8px 10px;
    border-radius: 8px;
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    color: #4b5563;
    font-size: 12px;
    line-height: 1.45;
    white-space: normal;
}