/* ============================================================
   BGY MONITORING SUITE — Stili globali
   Versione 17 — Colori istituzionali D/A aggiornati (Arancione scuro)
   ============================================================ */

.bgy-widget {
  margin: 28px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.bgy-widget h3 {
  font-size: 20px; font-weight: 700; color: #1a2a6c;
  margin: 0 0 18px 0; padding-bottom: 8px; border-bottom: 2px solid #e9ecef;
}
.bgy-widget h4 {
  font-size: 15px; font-weight: 600; color: #495057;
  margin: 0 0 12px 0; text-transform: uppercase; letter-spacing: 0.5px;
}
.bgy-note {
  font-size: 12px; color: #6c757d; margin-top: 14px; line-height: 1.5;
}

/* Note sotto i grafici */
.bgy-chart-note {
  font-size: 12px;
  color: #7f8c8d;
  margin-top: 12px;
  text-align: center;
  font-style: italic;
  line-height: 1.4;
  border-top: 1px dashed #e9ecef;
  padding-top: 10px;
}

/* --- KPI grids --- */
.bgy-kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 14px;
}
.bgy-kpi-grid.col-1 { grid-template-columns: 1fr; }
.bgy-kpi-grid.col-2 { grid-template-columns: repeat(2, 1fr); }
.bgy-kpi-grid.col-3 { grid-template-columns: repeat(3, 1fr); }
.bgy-kpi-grid.col-4 { grid-template-columns: repeat(4, 1fr); }

.bgy-kpi-card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-left: 4px solid #adb5bd;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  min-height: 100px;
}
.bgy-kpi-card .lbl {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px;
  color: #6c757d; font-weight: 600; margin-bottom: 6px;
}
.bgy-kpi-card .val {
  font-size: 28px; font-weight: 700; color: #212529; line-height: 1;
}

/* Colori direzione */
.bgy-kpi-card.d { border-left-color: #049161; }
.bgy-kpi-card.d .val { color: #049161; }
.bgy-kpi-card.a { border-left-color: #d35400; } /* Arancione scuro */
.bgy-kpi-card.a .val { color: #d35400; }

/* Colori categoria */
.bgy-kpi-card.linea { border-left-color: #4e79a7; }
.bgy-kpi-card.linea .val { color: #4e79a7; }
.bgy-kpi-card.cargo { border-left-color: #59a14f; }
.bgy-kpi-card.cargo .val { color: #59a14f; }
.bgy-kpi-card.charter { border-left-color: #e15759; }
.bgy-kpi-card.charter .val { color: #e15759; }
.bgy-kpi-card.altro { border-left-color: #f28e2b; }
.bgy-kpi-card.altro .val { color: #f28e2b; }

/* Section header card */
.bgy-kpi-card.section-header {
  background: #f1f3f5;
  border-left-color: #1a2a6c;
  text-align: center;
  padding: 10px 16px;
}
.bgy-kpi-card.section-header .lbl {
  color: #1a2a6c;
  font-size: 13px;
  letter-spacing: 1.5px;
  margin-bottom: 0;
}

/* --- Riga anomalie --- */
.bgy-anomalies-line {
  margin-top: 8px; padding: 12px 16px; border-radius: 8px;
  font-size: 14px; background: #f8f9fa;
  border-left: 4px solid #adb5bd; line-height: 1.5;
}
.bgy-anomalies-line .bgy-anom-ok { color: #049161; font-weight: bold; margin-right: 6px; }
.bgy-anomalies-line .bgy-anom-warn { color: #d35400; font-weight: bold; margin-right: 6px; }

/* --- Chart box --- */
.bgy-chart-box {
  position: relative; height: 420px; width: 100%;
}
.bgy-chart-box canvas {
  display: block;
  width: 100% !important; height: 100% !important;
}

/* --- Layout 2 colonne --- */
.bgy-charts-2col,
.bgy-dest-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 28px;
}

/* --- Chart block --- */
.bgy-chart-block {
  background: #fff; border: 1px solid #e9ecef; border-radius: 8px;
  padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  margin-bottom: 16px;
}
.bgy-chart-block h5 {
  font-size: 14px; font-weight: 600; color: #495057; margin: 0 0 12px 0;
}

/* --- A3: Pista utilizzata --- */
.bgy-sides-container,
#bgy-sides-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
}
.bgy-side-item {
  background: #fff;
  border: 1px solid #e9ecef;
  border-left: 4px solid #adb5bd;
  border-radius: 8px;
  padding: 14px 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.bgy-side-item .name {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #6c757d;
  font-weight: 600;
  margin-bottom: 6px;
}
.bgy-side-item .n {
  font-size: 28px;
  font-weight: 700;
  color: #212529;
  line-height: 1;
  margin-bottom: 10px;
}
.bgy-side-item .da {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
}
.bgy-side-item .da span {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.bgy-side-item .da strong {
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
.bgy-side-item .da .d { color: #049161; }
.bgy-side-item .da .a { color: #d35400; }
.bgy-side-item .sub {
  font-size: 12px;
  color: #6c757d;
}

@media (max-width: 900px) {
  .bgy-sides-container,
  #bgy-sides-container {
    grid-template-columns: 1fr;
  }
}

/* ============================================================
   GEO DRILL-DOWN
   ============================================================ */

.bgy-geo-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: #f8f9fa;
  border: 1px solid #e9ecef;
  border-radius: 6px;
  font-size: 13px;
  color: #495057;
}
.bgy-geo-legend > span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.bgy-geo-legend i {
  display: inline-block;
  width: 12px;
  height: 12px;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,0.08);
}

.bgy-geo-breadcrumb {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  margin-bottom: 10px;
  background: #f1f3f5;
  border: 1px solid #dee2e6;
  border-radius: 6px;
  font-size: 13px;
}
.bgy-geo-breadcrumb .bgy-geo-back {
  color: #1a2a6c;
  font-weight: 600;
  text-decoration: none;
  transition: color 0.15s;
}
.bgy-geo-breadcrumb .bgy-geo-back:hover {
  color: #0d1642;
  text-decoration: underline;
}
.bgy-geo-breadcrumb .bgy-geo-current {
  color: #495057;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-size: 12px;
}
.bgy-geo-breadcrumb .bgy-geo-current::before {
  content: "\2192  ";
  color: #adb5bd;
  font-weight: 400;
  margin-right: 2px;
}

/* ============================================================
   PERIOD FILTER
   ============================================================ */
.bgy-period-filter {
  border: 1px solid #e9ecef;
  border-radius: 10px;
  background: #fff;
  padding: 14px 18px;
  margin-bottom: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.bgy-period-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.bgy-period-label {
  font-size: 14px;
  font-weight: 700;
  color: #1a2a6c;
  margin-right: 4px;
}
.bgy-period-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.bgy-period-btn {
  appearance: none;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #495057;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
}
.bgy-period-btn:hover { border-color: #1a2a6c; color: #1a2a6c; }
.bgy-period-btn.active {
  background: #1a2a6c;
  border-color: #1a2a6c;
  color: #fff;
  font-weight: 600;
}
.bgy-period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f3f5;
}
.bgy-period-nav-btn {
  appearance: none;
  border: 1px solid #dee2e6;
  background: #fff;
  color: #1a2a6c;
  width: 34px;
  height: 34px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  font-family: inherit;
  padding: 0;
  line-height: 1;
}
.bgy-period-nav-btn:hover:not(:disabled) {
  background: #1a2a6c;
  border-color: #1a2a6c;
  color: #fff;
}
.bgy-period-nav-btn:disabled { opacity: 0.35; cursor: not-allowed; }
.bgy-period-nav-text {
  font-size: 14px;
  color: #495057;
  font-weight: 500;
}
.bgy-period-nav-text strong { color: #1a2a6c; font-weight: 700; }
.bgy-period-custom {
  display: none;
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid #f1f3f5;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.bgy-period-custom.visible { display: flex; }
.bgy-period-custom label {
  font-size: 13px;
  color: #495057;
  display: flex;
  align-items: center;
  gap: 6px;
}
.bgy-period-custom input[type="date"] {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

/* ============================================================
   KPI SUMMARY + DETTAGLIO D/A
   ============================================================ */

.bgy-delays-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.bgy-delays-summary .card {
  background: #fff;
  border: 1px solid #e9ecef;
  border-left: 5px solid #1a2a6c;
  border-radius: 8px;
  padding: 16px 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.bgy-delays-summary .card.total { border-left-color: #1a2a6c; }
.bgy-delays-summary .card.d     { border-left-color: #049161; }
.bgy-delays-summary .card.a     { border-left-color: #d35400; }
.bgy-delays-summary .lbl {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #1a2a6c;
  font-weight: 700;
  margin-bottom: 10px;
}
.bgy-delays-summary .val {
  font-size: 32px;
  font-weight: 700;
  color: #1a2a6c;
  line-height: 1;
}

.bgy-kpi-block {
  background: #fff;
  border: 1px solid #e9ecef;
  border-radius: 8px;
  padding: 16px 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.bgy-kpi-block-d { border-left: 5px solid #049161; }
.bgy-kpi-block-a { border-left: 5px solid #d35400; }
.bgy-kpi-block-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 0 0 12px 0;
  color: #1a2a6c;
}
.bgy-kpi-block-d .bgy-kpi-block-title { color: #049161; }
.bgy-kpi-block-a .bgy-kpi-block-title { color: #d35400; }

.bgy-chart-block.bgy-chart-block-d {
  border: 1px solid #e9ecef;
  border-left: 5px solid #049161;
}
.bgy-chart-block.bgy-chart-block-a {
  border: 1px solid #e9ecef;
  border-left: 5px solid #d35400;
}

/* ============================================================
   Disclaimer unificato
   ============================================================ */
.bgy-disclaimer {
  background: #fff3cd;
  border: 1px solid #ffe69c;
  border-left: 5px solid #f39c12;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.55;
  color: #664d03;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}
.bgy-disclaimer .bgy-disclaimer-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
  letter-spacing: 0.5px;
  color: #856404;
}
.bgy-disclaimer .bgy-disclaimer-body {
  font-size: 13px;
  color: #664d03;
}
.bgy-disclaimer .bgy-disclaimer-extra {
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px dashed #ffe69c;
  font-style: italic;
}
@media (max-width: 700px) {
  .bgy-disclaimer { padding: 12px 14px; font-size: 12px; }
  .bgy-disclaimer .bgy-disclaimer-title { font-size: 13px; }
}

/* ============================================================
   RESPONSIVE
   ============================================================ */

.bgy-kpi-desktop { display: block; }
.bgy-kpi-mobile { display: none; }

@media (max-width: 900px) {
  .bgy-charts-2col,
  .bgy-dest-grid { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .bgy-kpi-desktop { display: none; }
  .bgy-kpi-mobile { display: block; }

  .bgy-kpi-grid { gap: 10px; margin-bottom: 10px; }
  .bgy-kpi-grid.col-1 { grid-template-columns: 1fr; }
  .bgy-kpi-grid.col-2 { grid-template-columns: repeat(2, 1fr); }

  .bgy-kpi-card { padding: 12px 14px; min-height: 88px; }
  .bgy-kpi-card .val { font-size: 22px; }
  .bgy-kpi-card .lbl { font-size: 11px; }
  .bgy-kpi-card.section-header { padding: 8px 14px; }
  .bgy-kpi-card.section-header .lbl { font-size: 11px; letter-spacing: 1.2px; }

  .bgy-side-item .n { font-size: 22px; }

  .bgy-widget h3 { font-size: 17px; }
  .bgy-chart-box { height: 340px; }
  .bgy-widget { margin: 20px 0; }

  .bgy-geo-legend { font-size: 12px; gap: 10px; }
  .bgy-geo-breadcrumb { font-size: 12px; }

  .bgy-period-label { width: 100%; }
  .bgy-period-btn { font-size: 13px; padding: 7px 12px; }
  .bgy-period-nav { gap: 12px; }

  .bgy-delays-summary { grid-template-columns: 1fr; }
  .bgy-delays-summary .val { font-size: 26px; }
}

@media (max-width: 480px) {
  .bgy-kpi-card .val { font-size: 20px; }
  .bgy-side-item .n { font-size: 20px; }
}

/* ============================================================
 * Modal toast + KPI cliccabile
 * ============================================================ */

.bgy-kpi-card-clickable {
    cursor: pointer;
    transition: background 0.15s ease, box-shadow 0.15s ease;
    position: relative;
}
.bgy-kpi-card-clickable:hover {
    background: #f0f4f8;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}
.bgy-kpi-card-clickable::after {
    content: "ⓘ";
    position: absolute;
    top: 6px;
    right: 8px;
    font-size: 13px;
    color: #7f8c8d;
    opacity: 0.6;
}
.bgy-kpi-card-clickable:hover::after {
    opacity: 1;
    color: #049161;
}

.bgy-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.15);
    display: none;
    z-index: 9999;
    pointer-events: none;
}
.bgy-modal-overlay.visible {
    display: block;
    pointer-events: auto;
}

.bgy-modal-toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 420px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #dfe6ec;
    border-left: 4px solid #049161; /* Default: verde */
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    padding: 16px 18px 18px 18px;
    font-size: 13px;
    color: #2c3e50;
    line-height: 1.5;
    animation: bgy-modal-in 0.18s ease-out;
}

@keyframes bgy-modal-in {
    from { transform: translateY(12px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

.bgy-modal-close {
    position: absolute;
    top: 8px;
    right: 10px;
    background: transparent;
    border: none;
    font-size: 22px;
    line-height: 1;
    color: #7f8c8d;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: 4px;
}
.bgy-modal-close:hover {
    background: #f0f4f8;
    color: #2c3e50;
}

.bgy-modal-title {
    margin: 0 0 4px 0;
    font-size: 15px;
    font-weight: 600;
    color: #1a2a6c;
    padding-right: 26px;
}

.bgy-modal-period {
    font-size: 12px;
    color: #7f8c8d;
    margin-bottom: 12px;
}

.bgy-modal-section {
    margin-bottom: 14px;
}
.bgy-modal-section:last-child {
    margin-bottom: 0;
}

.bgy-modal-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #049161; /* Default: verde */
    margin-bottom: 6px;
}

.bgy-modal-text {
    margin: 0;
    font-size: 13px;
    color: #34495e;
}

.bgy-modal-stats {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 14px;
}
.bgy-modal-stats > div {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 8px;
    padding: 3px 0;
    border-bottom: 1px dashed #ecf0f1;
}
.bgy-modal-stat-lbl {
    color: #7f8c8d;
    font-size: 12px;
}
.bgy-modal-stat-val {
    font-weight: 600;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

.bgy-modal-row {
    display: grid;
    grid-template-columns: 90px 1fr 40px;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    font-size: 12px;
}
.bgy-modal-row-label {
    color: #34495e;
}
.bgy-modal-row-bar {
    background: #ecf0f1;
    height: 14px;
    border-radius: 7px;
    overflow: hidden;
    position: relative;
}
.bgy-modal-row-bar-fill {
    height: 100%;
    border-radius: 7px;
    transition: width 0.25s ease;
    min-width: 2px;
}
.bgy-modal-row-count {
    text-align: right;
    font-weight: 600;
    color: #2c3e50;
    font-variant-numeric: tabular-nums;
}

@media (max-width: 480px) {
    .bgy-modal-toast {
        left: 10px;
        right: 10px;
        bottom: 10px;
        width: auto;
        max-height: 70vh;
    }
    .bgy-modal-stats {
        grid-template-columns: 1fr;
    }
}

/* Accent dinamico del modal */
.bgy-modal-toast {
    --bgy-modal-accent: #049161;
    border-left-color: var(--bgy-modal-accent);
}
.bgy-modal-toast .bgy-modal-section-title {
    color: var(--bgy-modal-accent);
}
.bgy-modal-toast .bgy-modal-title {
    color: #1a2a6c;
}
.bgy-modal-note {
    margin: 8px 0 0 0;
    font-size: 11.5px;
    color: #7f8c8d;
    font-style: italic;
    line-height: 1.4;
}

/* ============================================================
 * Stili WEB-12.Q/R (Peggior Ritardo)
 * ============================================================ */

.bgy-worst-card {
    background: #fff;
    border: 2px solid #e74c3c; /* Rosso per gli allarmi è ok */
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    margin-bottom: 20px;
    box-shadow: 0 4px 12px rgba(231, 76, 60, 0.15);
}
.bgy-worst-title {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #e74c3c;
    font-weight: 700;
    margin-bottom: 8px;
}
.bgy-worst-value {
    font-size: 56px;
    font-weight: 800;
    color: #e74c3c;
    line-height: 1;
    margin-bottom: 12px;
}
.bgy-worst-details {
    font-size: 15px;
    color: #2c3e50;
    line-height: 1.5;
}
.bgy-worst-details strong {
    font-size: 18px;
    color: #1a2a6c;
}
.bgy-worst-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.bgy-worst-list li {
    display: flex;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #ecf0f1;
    font-size: 14px;
    color: #34495e;
}
.bgy-worst-list li:last-child {
    border-bottom: none;
}
.bgy-worst-list .rank {
    font-weight: 700;
    color: #95a5a6;
    width: 24px;
    flex-shrink: 0;
}
.bgy-worst-list strong {
    color: #1a2a6c;
    margin-right: 4px;
}
.bgy-worst-list .delta {
    margin-left: auto;
    font-weight: 700;
    color: #e74c3c;
    font-size: 16px;
}
.bgy-worst-empty {
    text-align: center;
    color: #7f8c8d;
    padding: 20px;
    font-style: italic;
}

/* Filtri periodo: riga personalizzata separata */
.bgy-custom-row {
  display: none;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px dashed #e9ecef;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}
.bgy-custom-row.visible {
  display: flex;
}
.bgy-custom-row .bgy-label {
  font-size: 14px;
  font-weight: 700;
  color: #1a2a6c;
}
.bgy-custom-row input[type="date"] {
  border: 1px solid #dee2e6;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  font-family: inherit;
}

/* Assicura che le frecce di navigazione siano nascoste se nav-row è display:none */
#bgy-nav-row {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #f1f3f5;
}