/* =========================================================
   BPRE — BFL Design System v2.4 + App Styles
   ========================================================= */

:root {
    --primary: #fccb06;
    --primary-hover: #e6b800;
    --primary-dark: #1f2a3d;
    --background: #f6f7f7;
    --surface: #ffffff;
    --surface-hover: #f1f5f9;
    --bg-secondary: #f1f5f9;
    --sidebar-bg: #1f2a3d;
    --sidebar-text: rgba(255, 255, 255, 0.7);
    --sidebar-active-bg: #fccb06;
    --sidebar-active-text: #1f2a3d;
    --text-main: #1f2a3d;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --border-color: #e5e7eb;
    --success: #10b981;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    --radius: 0.75rem;
    --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.08), 0 4px 6px -2px rgba(0,0,0,0.04);
}


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

body {
    font-family: 'Inter', sans-serif;
    background: var(--background);
    color: var(--text-main);
    height: 100vh;
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* ---- Layout ---- */
.app-container { display: flex; height: 100%; }

/* ---- Sidebar ---- */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    padding: var(--spacing-lg);
    box-shadow: 2px 0 10px rgba(0,0,0,0.15);
    flex-shrink: 0;
    overflow-y: auto;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 0;
    margin-bottom: var(--spacing-xl);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}
.brand-badge {
    width: 46px; height: 46px;
    background: var(--primary);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 900; font-size: 1rem;
    color: #1f2a3d;
    flex-shrink: 0;
    box-shadow: 0 2px 8px rgba(252,203,6,0.35);
}
.brand-info { display: flex; flex-direction: column; gap: 2px; }
.brand-name {
    font-size: 1.4rem; font-weight: 800;
    color: var(--primary);
    letter-spacing: 1px; line-height: 1.1;
}
.brand-subtitle {
    font-size: 0.58rem;
    color: rgba(255,255,255,0.4);
    letter-spacing: 0.5px;
    text-transform: uppercase;
    line-height: 1.35;
}

.nav-section-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255,255,255,0.3);
    padding: 0 var(--spacing-md);
    margin: var(--spacing-md) 0 var(--spacing-xs);
}

.nav-links { list-style: none; flex: 1; }
.nav-links li {
    padding: 0.65rem var(--spacing-md);
    margin-bottom: 2px;
    border-radius: 0.5rem;
    cursor: pointer;
    display: flex; align-items: center; gap: var(--spacing-sm);
    transition: all 0.2s;
    font-weight: 500; font-size: 0.875rem;
    color: rgba(255,255,255,0.7);
    user-select: none;
}
.nav-links li:hover { background: rgba(255,255,255,0.1); color: #fff; }
.nav-links li.active {
    background: var(--sidebar-active-bg);
    color: var(--sidebar-active-text);
    font-weight: 600;
}
.nav-links li i { width: 18px; text-align: center; }

.sidebar-footer {
    margin-top: auto;
    padding-top: var(--spacing-lg);
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex; flex-direction: column;
    align-items: center; gap: var(--spacing-md);
}
.footer-logo { width: 60%; max-width: 140px; opacity: 0.7; transition: opacity 0.3s; }
.footer-logo:hover { opacity: 1; }
.app-version { font-size: 0.65rem; color: rgba(255,255,255,0.3); }

/* ---- Main Content ---- */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-xl);
    background-image:
        linear-gradient(rgba(31,42,61,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(31,42,61,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
}
.main-content::-webkit-scrollbar { width: 4px; }
.main-content::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 10px; }


/* ---- Viste ---- */
.view { display: none; animation: fadeIn 0.25s ease; }
.view.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---- Page Header ---- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: var(--spacing-xl);
    gap: var(--spacing-md);
}
.page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
}
.page-header p {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-top: 2px;
}
.page-actions { display: flex; gap: var(--spacing-sm); align-items: center; flex-shrink: 0; }

/* ---- Bottoni ---- */
.btn {
    display: inline-flex; align-items: center; gap: 0.4rem;
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font-size: 0.875rem; font-weight: 500;
    cursor: pointer; transition: all 0.15s;
    font-family: inherit; text-decoration: none;
    white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: var(--primary-dark); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: var(--surface); color: var(--text-main); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--surface-hover); }
.btn-danger { background: transparent; color: var(--error); border-color: var(--error); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.08); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { opacity: 0.9; }
.btn-sm { padding: 0.3rem 0.6rem; font-size: 0.8rem; }
.btn-icon { padding: 0.4rem 0.5rem; }

/* ---- KPI Cards ---- */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: var(--spacing-md); margin-bottom: var(--spacing-xl); }
.kpi-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-lg);
    border-top: 3px solid var(--primary);
}
.kpi-card .kpi-label { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 0.4rem; text-transform: uppercase; letter-spacing: 0.5px; }
.kpi-card .kpi-value { font-size: 1.7rem; font-weight: 800; color: var(--text-main); }
.kpi-card .kpi-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }
.kpi-card .kpi-icon { float: right; font-size: 1.5rem; color: var(--primary); opacity: 0.6; }

/* ---- Card generica ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-lg);
}
.card-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}
.card-title i { color: var(--primary); }

/* ---- Controls Bar ---- */
.controls-bar {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: var(--spacing-lg);
    gap: var(--spacing-md);
    flex-wrap: wrap;
}
.controls-left { display: flex; align-items: center; gap: var(--spacing-md); flex-wrap: wrap; }
.controls-right { display: flex; align-items: center; gap: var(--spacing-sm); }
.total-label { font-size: 0.85rem; color: var(--text-muted); }
.total-count { font-weight: 700; color: var(--text-main); }

/* ---- Search ---- */
.search-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.4rem 0.75rem;
}
.search-box i { color: var(--text-muted); font-size: 0.85rem; }
.search-box input {
    border: none; background: transparent; outline: none;
    font-size: 0.875rem; color: var(--text-main); font-family: inherit;
    width: 200px;
}
.search-box input::placeholder { color: var(--text-muted); }

/* ---- Select filter ---- */
.filter-select {
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
    cursor: pointer;
    outline: none;
}

/* ---- Badge ---- */
.badge {
    display: inline-flex; align-items: center;
    padding: 0.2rem 0.7rem;
    border-radius: 10rem;
    font-size: 0.72rem; font-weight: 600;
    letter-spacing: 0.3px;
    white-space: nowrap;
}
.badge-success { background: rgba(16,185,129,0.12); color: #059669; }
.badge-warning { background: rgba(245,158,11,0.12); color: #d97706; }
.badge-danger  { background: rgba(239,68,68,0.12);  color: #dc2626; }
.badge-info    { background: rgba(59,130,246,0.12);  color: #2563eb; }
.badge-neutral { background: var(--bg-secondary); color: var(--text-muted); }
.badge-gold    { background: rgba(252,203,6,0.15); color: #92660a; }

/* ---- Tabelle ---- */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.875rem; }
thead th {
    background: var(--bg-secondary);
    padding: 0.7rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border);
    color: var(--text-main);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: var(--surface-hover); }
tbody tr.row-best td { background: rgba(16,185,129,0.06); }
tbody tr.row-best:hover td { background: rgba(16,185,129,0.1); }

/* ---- Form ---- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-md); }
.form-grid.cols-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-grid.cols-1 { grid-template-columns: 1fr; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span-2 { grid-column: span 2; }
.form-group.span-3 { grid-column: span 3; }
label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
}
input[type="text"], input[type="number"], input[type="date"], input[type="email"],
input[type="tel"], select, textarea {
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--surface);
    color: var(--text-main);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.15s;
    width: 100%;
}
input:focus, select:focus, textarea:focus { border-color: var(--primary); }
textarea { resize: vertical; min-height: 80px; }
input.field-uncertain { border-color: var(--warning); background: rgba(245,158,11,0.06); }
input.field-uncertain:focus { border-color: var(--warning); }
.field-hint { font-size: 0.72rem; color: var(--text-muted); }
.field-hint.uncertain { color: var(--warning); }

/* ---- Range / Slider ---- */
.slider-group { display: flex; align-items: center; gap: var(--spacing-sm); }
.slider-group input[type="range"] {
    flex: 1; padding: 0; border: none;
    accent-color: var(--primary);
}
.slider-value {
    min-width: 40px;
    text-align: right;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--primary);
}
.weights-total {
    font-size: 0.85rem;
    font-weight: 700;
    margin-top: var(--spacing-sm);
}
.weights-total.ok { color: var(--success); }
.weights-total.error { color: var(--error); }

/* ---- Modal ---- */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(31,42,61,0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 100;
    overflow-y: auto; padding: 1.5rem;
    backdrop-filter: blur(2px);
}
.modal-overlay.hidden { display: none; }
.modal {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 90%; max-width: 560px;
    display: flex; flex-direction: column;
    max-height: calc(100vh - 3rem);
}
.modal.modal-lg { max-width: 780px; }
.modal.modal-xl { max-width: 1000px; }

/* Confirm-extract modal sections */
.ce-section { margin-bottom: var(--spacing-lg); }
.ce-section-title {
    font-size: .8rem; font-weight: 700; text-transform: uppercase;
    letter-spacing: .06em; color: var(--text-muted);
    margin-bottom: var(--spacing-sm);
    padding-bottom: 6px; border-bottom: 1px solid var(--border);
}
.ce-section .data-table input {
    background: transparent; border: 1px solid transparent;
    border-radius: 4px; padding: 3px 6px; width: 100%;
    font-size: .8rem; color: var(--text-primary);
    transition: border-color .15s;
}
.ce-section .data-table input:focus {
    border-color: var(--primary); outline: none;
    background: var(--bg-secondary);
}
.modal-header {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: space-between;
}
.modal-header h2 { font-size: 1.05rem; font-weight: 700; }
.modal-close {
    background: none; border: none; cursor: pointer;
    font-size: 1.1rem; color: var(--text-muted);
    padding: 4px 8px; border-radius: 4px;
    transition: color 0.15s;
}
.modal-close:hover { color: var(--error); }
.modal-body { padding: var(--spacing-lg); overflow-y: auto; flex: 1; }
.modal-footer {
    padding: var(--spacing-lg);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
    display: flex; gap: var(--spacing-sm); justify-content: flex-end;
}

/* ---- Toast ---- */
#toast-container {
    position: fixed;
    bottom: var(--spacing-xl);
    right: var(--spacing-xl);
    z-index: 200;
    display: flex; flex-direction: column; gap: 8px;
}
.toast {
    background: var(--primary-dark);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    display: flex; align-items: center; gap: 10px;
    min-width: 280px;
    animation: slideIn 0.25s ease;
    border-left: 4px solid var(--primary);
}
.toast.toast-success { border-left-color: var(--success); }
.toast.toast-error { border-left-color: var(--error); }
.toast.toast-warning { border-left-color: var(--warning); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: none; } }

/* ---- Drop Zone ---- */
.detail-top-row { display: flex; gap: var(--spacing-md); align-items: stretch; margin-bottom: var(--spacing-lg); }
.detail-top-row .kpi-card { flex-shrink: 0; width: 160px; margin-bottom: 0; }
.upload-compact { flex: 1; margin-bottom: 0; }
.drop-zone-sm { padding: var(--spacing-md) var(--spacing-lg) !important; }
.drop-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: var(--spacing-xl) var(--spacing-xl);
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface);
    position: relative;
}
.drop-zone:hover, .drop-zone.drag-over {
    border-color: var(--primary);
    background: rgba(252,203,6,0.04);
}
.drop-zone input[type="file"] {
    position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; height: 100%;
}
.drop-zone-icon { font-size: 2.5rem; color: var(--primary); margin-bottom: var(--spacing-sm); }
.drop-zone-title { font-size: 1rem; font-weight: 600; margin-bottom: 4px; }
.drop-zone-sub { font-size: 0.8rem; color: var(--text-muted); }
.drop-zone-formats { font-size: 0.72rem; color: var(--text-muted); margin-top: 8px; opacity: 0.7; }

/* ---- File Queue ---- */
.file-queue { margin-top: var(--spacing-md); display: flex; flex-direction: column; gap: 8px; }
.file-item {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    display: flex; align-items: center; gap: var(--spacing-sm);
}
.file-item-icon { font-size: 1.1rem; width: 24px; text-align: center; flex-shrink: 0; }
.file-item-icon.pdf { color: #dc2626; }
.file-item-icon.docx { color: #2563eb; }
.file-item-icon.img { color: #7c3aed; }
.file-item-info { flex: 1; min-width: 0; }
.file-item-name { font-size: 0.875rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { font-size: 0.72rem; color: var(--text-muted); }
.file-item-status { flex-shrink: 0; }
.progress-bar-wrap { width: 100%; background: var(--bg-secondary); border-radius: 10px; height: 4px; margin-top: 6px; }
.progress-bar { height: 4px; border-radius: 10px; background: var(--primary); transition: width 0.3s; }

/* ---- Offers Table (lista a righe) ---- */
.offers-table { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
.offers-table th {
    text-align: left; padding: 8px 12px;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted); font-weight: 600;
    font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.4px;
    white-space: nowrap;
}
.offers-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.offer-row { cursor: pointer; transition: background 0.12s; }
.offer-row:hover { background: var(--bg-secondary); }
.offer-row:last-child td { border-bottom: none; }
.offer-row.best-offer-row { background: color-mix(in srgb, var(--success) 6%, transparent); }
.offer-row.best-offer-row:hover { background: color-mix(in srgb, var(--success) 12%, transparent); }
.offer-row-supplier { font-weight: 700; }
.offer-row-muted { color: var(--text-muted); font-size: 0.82rem; }
.offer-row-price { font-weight: 800; color: var(--primary-dark); white-space: nowrap; }
.offer-row-actions { display: flex; gap: 4px; }
.score-badge {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px;
    border-radius: 50%;
    font-weight: 800; font-size: 0.85rem;
    flex-shrink: 0;
}
.score-badge.high { background: rgba(16,185,129,0.15); color: #059669; }
.score-badge.mid  { background: rgba(245,158,11,0.15); color: #d97706; }
.score-badge.low  { background: rgba(239,68,68,0.15);  color: #dc2626; }

/* ---- Comparazione ---- */
.comparison-header {
    display: grid;
    gap: 1px;
    background: var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    margin-bottom: var(--spacing-xl);
}
.comparison-table-wrap { overflow-x: auto; margin-bottom: var(--spacing-xl); }
.comparison-table { min-width: 600px; width: 100%; border-collapse: collapse; font-size: 0.875rem; }
.comparison-table th:first-child { width: 160px; background: var(--bg-secondary); text-align: left; }
.comparison-table th { padding: 0.75rem 1rem; background: var(--primary-dark); color: #fff; font-weight: 600; font-size: 0.8rem; text-align: center; }
.comparison-table td:first-child { font-weight: 600; font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.3px; background: var(--bg-secondary); }
.comparison-table td { padding: 0.65rem 1rem; border-bottom: 1px solid var(--border); text-align: center; }
.comparison-table tr:last-child td { border-bottom: none; font-weight: 800; font-size: 1rem; }
.comparison-table td.best-cell { color: var(--success); font-weight: 700; }
.comparison-table td.worst-cell { color: var(--error); }
.comparison-table thead th.winner { background: var(--success); }

.best-offer-box {
    background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(16,185,129,0.02));
    border: 2px solid var(--success);
    border-radius: var(--radius);
    padding: var(--spacing-xl);
    margin-bottom: var(--spacing-xl);
    display: flex; align-items: center; gap: var(--spacing-xl);
}
.best-offer-box .best-icon { font-size: 2.5rem; color: var(--success); flex-shrink: 0; }
.best-offer-box .best-name { font-size: 1.3rem; font-weight: 800; margin-bottom: 4px; }
.best-offer-box .best-score { font-size: 2rem; font-weight: 900; color: var(--success); }
.best-offer-box .best-reasons { font-size: 0.85rem; color: var(--text-muted); margin-top: var(--spacing-sm); }

.charts-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-lg); margin-bottom: var(--spacing-xl); }

.chart-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-md);
    height: 320px;
    display: flex; flex-direction: column;
    overflow: hidden;
}
.chart-container .chart-title { font-size: 0.85rem; font-weight: 700; margin-bottom: var(--spacing-sm); color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; }
.chart-wrapper { position: relative; flex: 1; min-height: 0; width: 100%; }

/* ---- Dashboard Charts ---- */
.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: var(--spacing-lg); margin-bottom: var(--spacing-xl); }

/* ---- Project List ---- */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: var(--spacing-md); }
.project-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: var(--spacing-lg);
    cursor: pointer;
    transition: all 0.15s;
    display: flex; flex-direction: column;
}
.project-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-1px); }
.project-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: var(--spacing-sm); }
.project-card-name { font-weight: 700; font-size: 1rem; margin-bottom: 2px; }
.project-card-desc { font-size: 0.8rem; color: var(--text-muted); line-height: 1.4; margin-bottom: var(--spacing-sm); }
.project-card-meta { display: flex; align-items: center; gap: var(--spacing-sm); flex-wrap: wrap; margin-top: auto; padding-top: var(--spacing-sm); border-top: 1px solid var(--border); font-size: 0.78rem; color: var(--text-muted); }

/* ---- Breadcrumb ---- */
.breadcrumb {
    display: flex; align-items: center; gap: 8px;
    font-size: 0.82rem; color: var(--text-muted);
    margin-bottom: var(--spacing-lg);
}
.breadcrumb a { color: var(--info); cursor: pointer; text-decoration: none; }
.breadcrumb a:hover { text-decoration: underline; }
.breadcrumb i { font-size: 0.65rem; }

/* ---- Line Items Table (editor offerta) ---- */
.line-items-table { width: 100%; border-collapse: collapse; font-size: 0.82rem; margin-top: var(--spacing-sm); }
.line-items-table th { background: var(--bg-secondary); padding: 0.5rem 0.6rem; font-size: 0.72rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; border-bottom: 1px solid var(--border); }
.line-items-table td { padding: 0.4rem 0.4rem; border-bottom: 1px solid var(--border); }
.line-items-table input { padding: 0.3rem 0.5rem; font-size: 0.82rem; }
.line-items-table tfoot td { padding: 0.6rem 0.6rem; font-weight: 700; border-top: 2px solid var(--border); }
.btn-add-row { margin-top: var(--spacing-sm); }

/* ---- Confidence indicator ---- */
.confidence-bar-wrap { display: flex; align-items: center; gap: var(--spacing-sm); margin-bottom: var(--spacing-md); padding: var(--spacing-sm) var(--spacing-md); background: var(--bg-secondary); border-radius: 0.5rem; }
.confidence-label { font-size: 0.78rem; font-weight: 600; color: var(--text-muted); white-space: nowrap; }
.confidence-bar-bg { flex: 1; height: 8px; background: var(--border); border-radius: 10px; overflow: hidden; }
.confidence-bar-fill { height: 100%; border-radius: 10px; transition: width 0.5s; }
.confidence-bar-fill.high { background: var(--success); }
.confidence-bar-fill.mid  { background: var(--warning); }
.confidence-bar-fill.low  { background: var(--error); }
.confidence-pct { font-size: 0.85rem; font-weight: 700; min-width: 36px; text-align: right; }

/* ---- Settings ---- */
.settings-section { margin-bottom: var(--spacing-xl); }
.settings-section-title { font-size: 0.9rem; font-weight: 700; margin-bottom: var(--spacing-md); padding-bottom: var(--spacing-sm); border-bottom: 1px solid var(--border); }

/* ---- Empty state ---- */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl) var(--spacing-xl);
    color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: var(--spacing-md); opacity: 0.3; }
.empty-state h3 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--text-main); }
.empty-state p { font-size: 0.85rem; }

/* ---- Offline banner ---- */
#offline-banner {
    display: none;
    position: fixed; top: 0; left: 0; right: 0; z-index: 300;
    background: var(--warning);
    color: #1f2a3d;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.875rem; font-weight: 600;
}
#offline-banner.visible { display: block; }

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .sidebar { width: 220px; }
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid.span-2, .form-group.span-2, .form-group.span-3 { grid-column: span 1; }
    .charts-grid, .dashboard-grid { grid-template-columns: 1fr; }
    .projects-grid { grid-template-columns: 1fr; }
    .detail-top-row { flex-direction: column; }
    .detail-top-row .kpi-card { width: 100%; }
    .offers-table th { display: none; }
    .offers-table td { display: block; padding: 4px 12px; border-bottom: none; }
    .offer-row td:first-child { padding-top: 10px; }
    .offer-row td:last-child { padding-bottom: 10px; border-bottom: 1px solid var(--border); }
    .best-offer-box { flex-direction: column; }
}
@media (max-width: 540px) {
    .sidebar { display: none; }
    .main-content { padding: var(--spacing-md); }
}

/* ---- Confronto per Articolo ---- */
.item-cmp-table td, .item-cmp-table th { vertical-align: top; }
.item-cmp-label { font-weight: 500; font-size: .88rem; margin-bottom: 2px; }
.item-cmp-sub   { font-size: .72rem; color: var(--text-muted); }
.item-cmp-detail{ font-size: .75rem; color: var(--text-muted); margin-bottom: 2px; }
.item-cmp-total { font-weight: 700; font-size: .95rem; }
.item-cmp-disc  { font-size: .7rem; color: var(--success); }
.item-cmp-absent{ text-align: center; color: var(--text-muted); vertical-align: middle !important; }
.item-cmp-unlink{ font-size: .65rem !important; padding: 2px 6px !important; margin-top: 5px; opacity: .7; }
.item-cmp-unlink:hover { opacity: 1; }
.item-cmp-empty { text-align: center; color: var(--text-muted); padding: 1.5rem; font-size: .9rem; }

.item-cmp-badge { display: inline-block; font-size: .62rem; padding: 1px 6px; border-radius: 3px; margin-top: 4px; font-weight: 600; text-transform: uppercase; letter-spacing: .3px; }
.item-cmp-badge-code        { background: #dbeafe; color: #1d4ed8; }
.item-cmp-badge-description { background: #f3e8ff; color: #7e22ce; }
.item-cmp-badge-manual      { background: #dcfce7; color: #15803d; }
.item-cmp-badge-singleton   { background: var(--bg-secondary); color: var(--text-muted); }


.item-cmp-unmatched-wrap  { background: var(--bg-secondary); border: 1px dashed var(--border-color); border-radius: var(--radius); padding: 1rem; }
.item-cmp-unmatched-title { font-size: .85rem; font-weight: 600; color: var(--text-muted); margin-bottom: .75rem; display: flex; align-items: baseline; gap: .5rem; flex-wrap: wrap; }
.item-cmp-unmatched-hint  { font-size: .75rem; font-weight: 400; color: var(--text-muted); }
.item-cmp-unmatched-grid  { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 1rem; }
.item-cmp-unmatched-col   { }
.item-cmp-unmatched-col-title { font-weight: 600; font-size: .8rem; padding-bottom: .4rem; margin-bottom: .4rem; border-bottom: 1px solid var(--border-color); }
.item-cmp-unmatched-row   { display: flex; align-items: center; gap: .5rem; padding: .3rem 0; border-bottom: 1px solid var(--border-color); }
.item-cmp-unmatched-info  { flex: 1; min-width: 0; }
.item-cmp-select          { font-size: .72rem !important; padding: 3px 4px !important; min-width: 0; width: 130px; flex-shrink: 0; }

/* ---- Modal selezione offerte ---- */
.offer-select-item { display: flex; align-items: center; gap: .75rem; padding: .65rem .75rem; border: 1px solid var(--border-color); border-radius: var(--radius); cursor: pointer; transition: background .15s; }
.offer-select-item:hover { background: var(--bg-secondary); }
.offer-select-item input[type="checkbox"] { width: 16px; height: 16px; accent-color: var(--primary); flex-shrink: 0; cursor: pointer; }
.offer-select-info { flex: 1; min-width: 0; }
.offer-select-name { font-weight: 600; font-size: .9rem; }
.offer-select-meta { font-size: .78rem; color: var(--text-muted); margin-top: 2px; }
