/* Omni Bilanci — estensioni a main.css (stile OmniTools) */

/* Rating badges */
.rating { display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 24px; border-radius: 4px; font-weight: 700; font-size: 13px; padding: 0 8px; color: #fff; }
.rating-A   { background: #16a34a; }
.rating-B   { background: #22c55e; }
.rating-C   { background: #eab308; color: #422006; }
.rating-D   { background: #f97316; }
.rating-E   { background: #ef4444; }
.rating-F   { background: #991b1b; }
.rating-AAA, .rating-AA  { background: #15803d; }
.rating-BBB, .rating-BB  { background: #ca8a04; color: #422006; }
.rating-CCC { background: #dc2626; }

/* Chip / status */
.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: .75rem; font-weight: 500;
  background: #f1f5f9; color: var(--text-muted); border: 1px solid var(--border); white-space: nowrap; }
.chip-success { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.chip-warn { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.chip-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }
.chip-mono { font-family: 'SFMono-Regular', Menlo, Consolas, monospace; font-size: .72rem; }

/* Numeric cells */
.num { font-variant-numeric: tabular-nums; text-align: right; }

/* KPI value coloring */
.kpi-value.kpi-rating { display: inline-flex; }

/* Modal */
.modal-backdrop { position: fixed; inset: 0; background: rgba(15,23,42,0.5); z-index: 200;
  display: none; align-items: center; justify-content: center; }
.modal-backdrop.show { display: flex; }
.modal { background: var(--card-bg); border-radius: var(--radius); width: 90%; max-width: 560px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25); overflow: hidden; }
.modal-header { padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { margin: 0; font-size: 1rem; font-weight: 600; }
.modal-body { padding: 1.25rem; }
.modal-footer { padding: .75rem 1.25rem; border-top: 1px solid var(--border);
  background: #fafafa; display: flex; gap: .5rem; justify-content: flex-end; }
.modal-close { background: transparent; border: none; cursor: pointer; padding: 4px 8px; font-size: 1.1rem; color: var(--text-muted); }
.modal-close:hover { color: var(--text); }

/* Tabs in modal */
.tabs { display: flex; gap: .25rem; margin-bottom: 1rem; border-bottom: 1px solid var(--border); }
.tab-btn { padding: .5rem 1rem; background: transparent; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; font-size: .875rem; font-weight: 500; color: var(--text-muted); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }

/* Grid utilities */
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.row-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1rem; }
@media (max-width: 900px) { .row, .row-3 { grid-template-columns: 1fr; } }

/* Loading overlay (globale, per fetch attive) */
#loading-overlay {
  position: fixed; inset: 0; z-index: 600;
  background: rgba(15, 23, 42, 0.35);
  display: none; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
#loading-overlay.show { display: flex; }
#loading-overlay .loading-box {
  background: white; padding: 1.5rem 2rem; border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0,0,0,.25);
  display: flex; align-items: center; gap: 1rem; min-width: 280px;
}
#loading-overlay .spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%;
  animation: spin .8s linear infinite;
}
#loading-overlay .loading-msg {
  font-weight: 500; color: var(--text);
}
#loading-overlay .loading-sub {
  font-size: .8rem; color: var(--text-muted); margin-top: .15rem;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Bottoni in stato loading */
.btn.is-loading {
  position: relative; pointer-events: none; opacity: .7;
}
.btn.is-loading::after {
  content: ''; display: inline-block; width: 12px; height: 12px;
  border: 2px solid currentColor; border-top-color: transparent;
  border-radius: 50%; margin-left: .5rem;
  animation: spin .7s linear infinite; vertical-align: -2px;
}

/* Toast */
#toast-container { position: fixed; top: 1rem; right: 1rem; z-index: 500; display: flex; flex-direction: column; gap: .5rem; }
.toast { padding: .65rem 1rem; border-radius: 6px; background: white; box-shadow: 0 4px 12px rgba(0,0,0,.1);
  font-size: .875rem; border-left: 3px solid var(--primary); animation: slideIn .2s ease-out; }
.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--error); }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Section heading */
.section-title { font-size: 1.05rem; font-weight: 600; margin: 1.25rem 0 .75rem; }

/* Voci sezione header */
.voci-sezione { background: #f1f5f9; font-weight: 600; font-size: .78rem; text-transform: uppercase;
  color: var(--text-muted); letter-spacing: .5px; }

/* Fattori list */
.fattore-row { display: flex; justify-content: space-between; align-items: center;
  padding: .65rem 0; border-bottom: 1px solid var(--border); }
.fattore-row:last-child { border-bottom: none; }
.racc-row { display: flex; gap: .75rem; padding: .85rem 0; border-bottom: 1px solid var(--border); }
.racc-row:last-child { border-bottom: none; }
.racc-num { width: 28px; height: 28px; border-radius: 50%; background: var(--primary); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: .8rem; flex-shrink: 0; }
