:root {
  --bs-primary: #005B9F;
}

body {
  background-color: #F5F5F5;
}

.kpi-card {
  min-height: 78px;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-radius: 0.6rem;
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.kpi-card .card-title {
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
}

.kpi-card .kpi-value {
  font-size: 18px;
  font-weight: 600;
}
/* kpi-title standard definito in ui_standards.css */

.kpi-card .kpi-subtext {
  font-size: 0.75rem;
}

.chart-container {
  position: relative;
  width: 100%;
  height: 360px;
  margin-bottom: 1.5rem;
  overflow-y: auto;
}

@media (max-width: 576px) {
  .chart-container {
    height: 280px;
  }
}

canvas {
  height: 100% !important;
}

.kpi-chart-wrap {
  position: relative;
  height: 220px;
  width: 100%;
}
.kpi-chart-wrap-lg {
  height: 260px;
}
.kpi-chart-wrap canvas {
  max-height: 100%;
}

.chart-title {
  font-weight: 600;
}

@media (max-width: 576px) {
  .chart-title {
    font-size: 1.25rem;
  }
}

#det-prop-c.badge {
  font-size: 1rem;
  padding: 0.25rem 0.6rem;
}

/* KPI summary chip styles – leggeri e coerenti con palette (Rev. 3.6.362b) */
.kpi-strip { align-items: stretch; }
.kpi-chip {
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  padding: .35rem .6rem;
  border-radius: 999px;
  border: 1px solid rgba(0,0,0,.06);
  background: #f8fafc; /* neutro */
  font-size: .9rem;
  line-height: 1.1;
}
.kpi-chip .kpi-chip-label { color: #475569; }      /* slate-600 */
.kpi-chip .kpi-chip-value { font-weight: 600; }

.kpi-chip-neutral { background: #f8fafc; }         /* neutro */
.kpi-chip-warn    { background: #fff7ed; }         /* amber-50 */
.kpi-chip-ok      { background: #ecfdf5; }         /* emerald-50 */
.kpi-chip-info    { background: #f0f9ff; }         /* sky-50 */
.kpi-chip-accent  { background: #e0f2fe; }         /* cyan-100 */

@media (max-width: 1366px) {
  .kpi-chip { font-size: .85rem; padding: .3rem .55rem; }
}

/* Spaziatura minima uniforme nelle tre colonne KPI della card */
#kpi-riordino-card .row.g-3 > div { padding-top: .25rem; padding-bottom: .25rem; }

/* Cornici compatte per KPI nella griglia */
.kpi-frame {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: .25rem;
  padding: .35rem .5rem;
  min-height: 78px;
  border-radius: .6rem;
  border: 1px solid rgba(0,0,0,.08);
  background: #fff;
  box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,.04);
}
.kpi-frame .text-muted.small {
  color: #64748b; /* slate-500 */
  font-size: .75rem;
  margin-bottom: 0;
}
.kpi-frame .fs-5.fw-semibold {
  font-size: .95rem;
  line-height: 1.2;
}

/* === POSIZIONAMENTO LIVELLI ARTICOLO === */
.pos-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  display: inline-block;
  vertical-align: middle;
  margin-right: 4px;
  border: 1px solid #ffffff;
  box-shadow:
    inset 0 2px 3px rgba(255,255,255,0.6),
    inset 0 -3px 5px rgba(0,0,0,0.25),
    0 2px 4px rgba(0,0,0,0.25);
}
.dot-lv0 { background: #999; }
.dot-lv1 { background: #ff4d4d; }
.dot-lv2 { background: #ff944d; }
.dot-lv3 { background: #ffd24d; }
.dot-lv4 { background: #a3d977; }
.dot-lv5 { background: #2ecc71; }

/* Varianti colore leggere, in linea con le chip */
.kpi-frame-neutral { background: #f8fafc; border-color: #e2e8f0; }
.kpi-frame-info    { background: #f0f9ff; border-color: #bae6fd; }
.kpi-frame-ok      { background: #ecfdf5; border-color: #a7f3d0; }
.kpi-frame-warn    { background: #fff7ed; border-color: #fed7aa; }
.kpi-frame-accent  { background: #e0f2fe; border-color: #b6e3fa; }

@media (max-width: 1366px) {
  .kpi-frame { padding: .3rem .45rem; }
  .kpi-frame .fs-5.fw-semibold { font-size: .92rem; }
}

/* === B9-UX Famiglia → Mercato (vista informativa) === */
.b9-mercato-table th,
.b9-mercato-table td {
  padding: 0.4rem 0.85rem;
}
.b9-mercato-table tbody tr.b9-mercato-row:nth-of-type(odd) {
  background-color: #f8f9fb;
}
.b9-mercato-table tbody tr.b9-mercato-row td,
.b9-mercato-table tbody tr.b9-mercato-row th {
  vertical-align: middle;
}
.b9-toggle-link {
  border: 0;
  background: transparent;
  padding: 0;
  font-size: 0.85rem;
  color: #6c757d;
  text-decoration: none;
}
.b9-toggle-link:hover,
.b9-toggle-link:focus {
  color: #495057;
  text-decoration: underline;
}
.b9-secondary-link {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
  color: #6c757d;
  text-decoration: none;
}
.b9-secondary-link:hover,
.b9-secondary-link:focus {
  color: #495057;
  text-decoration: underline;
}
.b9-assenza-badge {
  font-size: 0.75rem;
  padding: 0.1rem 0.45rem;
  border-radius: 999px;
  border: 1px solid #e2e8f0;
  color: #64748b;
  background: transparent;
}
.b9-detail-row td {
  padding-top: 0;
}
.b9-detail-card {
  margin-left: 1.25rem;
  padding: 0.75rem 1rem;
  background: #f7f8fb;
  border-radius: 0.6rem;
  border: 1px solid #eef1f4;
}
.b9-detail-panel {
  font-size: 0.85rem;
}
.b9-detail-title {
  font-size: 0.8rem;
  color: #6c757d;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.02em;
}
.b9-detail-table th,
.b9-detail-table td {
  padding: 0.35rem 0.6rem;
  vertical-align: middle;
}

/* Griglia KPI: 2 righe da 5 su viewport ampie */
#kpi-riordino-card .kpi-grid {
  display: grid;
  gap: .5rem;
}
@media (min-width: 992px) { /* lg+ */
  #kpi-riordino-card .kpi-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
}
@media (min-width: 768px) and (max-width: 991.98px) { /* md */
  #kpi-riordino-card .kpi-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 767.98px) { /* sm */
  #kpi-riordino-card .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* === KPI Direttore – Margine con barra e target === */
.margin-bar-container {
  position: relative;
  width: 100%;
  height: 8px;
  background: #eee;
  border-radius: 4px;
  margin-top: 10px;
}
.margin-bar {
  height: 100%;
  width: 0%;
  border-radius: 4px;
  transition: width 0.4s ease;
  background-color: #6c757d;
}
.margin-target-line {
  position: absolute;
  left: 30%;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: #000;
}
#kpi-margine-card.kpi-success {
  border-color: #198754;
  background: #ecfdf5;
}
#kpi-margine-card.kpi-warning {
  border-color: #ff9800;
  background: #fff7ed;
}
#kpi-margine-card.kpi-danger {
  border-color: #dc3545;
  background: #f8d7da;
}

.kpi-value-row { display: flex; align-items: center; gap: 8px; }
.kpi-margin-inline { display: flex; align-items: center; gap: 6px; }
.kpi-dot { width: 10px; height: 10px; border-radius: 50%; }
.kpi-dot-green { background-color: #28a745; }
.kpi-dot-red { background-color: #dc3545; }
.kpi-dot-orange { background-color: #fd7e14; }
.info-icon { font-size: 0.9rem; font-weight: 700; color: #555; opacity: 0.9; margin-left: 4px; }
.kpi-percent { font-size: 14px; font-weight: 600; opacity: 0.85; }

/* === UX Governance: Dropdown Reparti (multi-select) === */
.reparto-dropdown { position: relative; overflow: visible; }
.reparto-dropdown-menu {
  width: 100%;
  min-width: 420px;
  max-width: 480px;
  max-height: 320px;
  overflow-y: auto;
  padding: 12px 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.15);
  z-index: 1055;
}
.reparto-dropdown-menu .dropdown-header {
  padding-left: 0;
  padding-right: 0;
}
.reparto-select-all {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid #e5e5e5;
}
.reparto-dropdown-menu .form-check {
  padding-left: 28px;
  margin-bottom: 6px;
}
.reparto-dropdown-menu .form-check-input {
  margin-left: -18px;
}
.reparto-count {
  background-color: #6c757d;
  color: #fff;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: 12px;
}

/* === ASBI-04 – Compattazione KPI su singola riga reale === */
.kpi-row {
  display: flex;
  flex-wrap: nowrap;
  gap: .5rem;
}
.kpi-row .kpi-col {
  flex: 0 0 calc(100% / 7);
  max-width: calc(100% / 7);
}
.kpi-row .kpi-card {
  padding: 0.6rem 0.8rem;
  border-radius: 6px;
}
.kpi-row .kpi-value {
  font-size: 1.25rem;
  font-weight: 600;
  line-height: 1.1;
}
.kpi-row .kpi-label {
  font-size: 0.75rem;
  opacity: 0.8;
}
