:root {
    --color-background-primary: #ffffff;
    --color-background-secondary: #f8f9fa;
    --color-background-tertiary: #e9ecef;
    --color-border-primary: #007bff;
    --color-border-secondary: #dee2e6;
    --color-border-tertiary: #ced4da;
    --color-text-primary: #212529;
    --color-text-secondary: #6c757d;
    --color-text-danger: #dc3545;
    --color-accent: #f1c40f;
    --border-radius-lg: 12px;
    --border-radius-md: 8px;
    --font-mono: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f4f7f6;
    color: var(--color-text-primary);
    line-height: 1.5;
    padding-bottom: 50px;
}

.wrap { padding: 2rem 1rem; max-width: 1100px; margin: 0 auto; }

/* Area Caricamento */
.upload-zone {
    border: 2px dashed var(--color-border-secondary);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    text-align: center;
    background: white;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.upload-zone:hover { border-color: var(--color-border-primary); background: #fcfdfe; }
.upload-icon { font-size: 40px; margin-bottom: 1rem; }

.btn {
    display: inline-block; margin-top: 1rem; padding: 10px 24px;
    font-size: 14px; font-weight: 600; border: 1px solid var(--color-border-secondary);
    border-radius: var(--border-radius-md); background: white; cursor: pointer;
}

.btn-pdf {
    background-color: #e74c3c;
    color: white;
    border: none;
    margin-bottom: 20px;
    display: none;
}

.btn-pdf:hover { background-color: #c0392b; }
.btn-pdf:disabled { background-color: #95a5a6; cursor: not-allowed; }
#fileInput { display: none; }

/* Tabella */
.matrix-section { margin-top: 3rem; background: white; padding: 1.5rem; border-radius: var(--border-radius-lg); box-shadow: 0 4px 15px rgba(0,0,0,0.05); }
.section-label { font-size: 12px; font-weight: 700; color: var(--color-text-secondary); margin-bottom: 1rem; letter-spacing: 0.1em; text-transform: uppercase; border-left: 4px solid var(--color-border-primary); padding-left: 10px; }
.table-scroll { overflow-x: auto; border: 1px solid var(--color-border-tertiary); border-radius: 8px; }

table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 10px; border: 1px solid var(--color-border-tertiary); text-align: center; }
th { background: var(--color-background-secondary); color: var(--color-text-secondary); }

.name-col { text-align: left; min-width: 160px; font-weight: 600; }
.self-cell { background: #eee; }
.mark-v { color: #28a745; font-weight: bold; }
.mark-x { color: #dc3545; font-weight: bold; }
.total-row { background: #f8f9fa; font-weight: bold; }

/* Analisi Profili */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.profile-card {
    background: #fff;
    border-radius: var(--border-radius-md);
    padding: 1.25rem;
    border: 1px solid var(--color-border-secondary);
    transition: transform 0.2s;
}

.profile-card:hover { transform: translateY(-3px); box-shadow: 0 4px 12px rgba(0,0,0,0.08); }
.profile-title { font-weight: 800; font-size: 14px; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; }
.profile-desc { font-size: 12px; color: var(--color-text-secondary); margin-bottom: 12px; font-style: italic; line-height: 1.4; }
.profile-list { font-weight: 600; color: var(--color-border-primary); font-size: 15px; }
.empty-msg { font-weight: normal; color: #ccc; font-size: 13px; }

.p-leader { border-top: 4px solid #9b59b6; }
.p-popolare { border-top: 4px solid #3498db; }
.p-accettato { border-top: 4px solid #2ecc71; }
.p-controverso { border-top: 4px solid #f1c40f; }
.p-rifiutato { border-top: 4px solid #e74c3c; }
.p-isolato { border-top: 4px solid #95a5a6; }

.example-box { margin-top: 1.5rem; background: #fff9db; border: 1px solid #ffe066; padding: 1rem; border-radius: 8px; font-size: 13px; }

/* Container per cattura PDF */
.pdf-page-container { background: white !important; padding: 20px !important; }

/* Stile per matrici compatte */
.compact-table table {
    font-size: 9px !important;
}

.super-compact-table table {
    font-size: 9px !important;
    table-layout: auto;
}

.super-compact-table th, .super-compact-table td {
    padding: 8px 1px !important;
}

.super-compact-table .name-col {
    min-width: 90px !important;
    max-width: 120px;
    font-size: 9px !important;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
    padding-left: 4px !important;
}
