/* ==========================================================================
   Aura Dashboard — Component Styles
   Client portal (client-area.html) for Fractional CFO platform
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. Grouped Tab Bar
   -------------------------------------------------------------------------- */

.tab-bar-grouped {
  display: flex;
  flex-direction: row;
  background: #ffffff;
  border-bottom: 1px solid #e0e0e0;
  padding: 0 32px;
  position: relative;
  z-index: 50;
}

.tab-section {
  position: relative;
  display: inline-block;
}

.tab-section-btn {
  background: none;
  border: none;
  padding: 14px 20px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  color: #636e72;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-bottom-color 0.2s;
  white-space: nowrap;
}

.tab-section-btn:hover {
  color: #2d3436;
}

.tab-section-btn.active {
  color: #0f3460;
  border-bottom-color: #0f3460;
}

.tab-dropdown {
  position: absolute;
  top: calc(100% + 1px);
  left: 0;
  background: #ffffff;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  min-width: 220px;
  z-index: 100;
  display: none;
  padding: 6px 0;
}

.tab-dropdown.open {
  display: block;
}

.tab-dropdown-item {
  padding: 10px 20px;
  font-size: 13px;
  color: #636e72;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.tab-dropdown-item:hover {
  background: #f5f6fa;
  color: #2d3436;
}

.tab-dropdown-item.active {
  color: #0f3460;
  font-weight: 600;
  background: #f0f3ff;
}

/* --------------------------------------------------------------------------
   2. KPI Cards
   -------------------------------------------------------------------------- */

.aura-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.aura-kpi-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  border-left: 4px solid #636e72;
}

.aura-kpi-card.positive {
  border-left-color: #00b894;
}

.aura-kpi-card.negative {
  border-left-color: #e74c3c;
}

.aura-kpi-card.warning {
  border-left-color: #f39c12;
}

.aura-kpi-card .kpi-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 4px;
  line-height: 1.2;
}

.aura-kpi-card .kpi-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #636e72;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.aura-kpi-card .kpi-trend {
  font-size: 12px;
  font-weight: 600;
}

.aura-kpi-card .kpi-trend.up {
  color: #00b894;
}

.aura-kpi-card .kpi-trend.down {
  color: #e74c3c;
}

.aura-kpi-card .kpi-trend.stable {
  color: #636e72;
}

.aura-kpi-card .kpi-comparison {
  font-size: 11px;
  color: #636e72;
}

/* --------------------------------------------------------------------------
   3. Chart Cards
   -------------------------------------------------------------------------- */

.aura-charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.aura-chart-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
}

.aura-chart-card h3 {
  font-size: 14px;
  font-weight: 600;
  color: #2d3436;
  margin-bottom: 4px;
  margin-top: 0;
}

.aura-chart-card .chart-subtitle {
  font-size: 12px;
  color: #636e72;
  margin-bottom: 16px;
}

.aura-chart-card.full {
  grid-column: span 2;
}

/* When inside the grid, remove individual margin-bottom */
.aura-charts-grid .aura-chart-card {
  margin-bottom: 0;
}

/* --------------------------------------------------------------------------
   4. Filter Bar
   -------------------------------------------------------------------------- */

.aura-filter-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 16px 20px;
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}

.aura-filter-bar select,
.aura-filter-bar input[type="text"] {
  padding: 8px 12px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  font-size: 13px;
  font-family: inherit;
  background: #ffffff;
  color: #2d3436;
  outline: none;
  transition: border-color 0.2s;
}

.aura-filter-bar select:focus,
.aura-filter-bar input[type="text"]:focus {
  border-color: #0f3460;
}

.filter-reset-btn {
  background: none;
  border: none;
  color: #e74c3c;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
  padding: 0;
  transition: opacity 0.2s;
}

.filter-reset-btn:hover {
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   5. Toggle
   -------------------------------------------------------------------------- */

.aura-toggle {
  display: inline-flex;
  background: #f0f0f0;
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}

.aura-toggle-btn {
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  color: #636e72;
  font-family: inherit;
}

.aura-toggle-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.05);
  color: #2d3436;
}

.aura-toggle-btn.active {
  background: #0f3460;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 52, 96, 0.3);
}

/* --------------------------------------------------------------------------
   6. Data Tables
   -------------------------------------------------------------------------- */

.aura-table-wrap {
  background: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
}

.aura-table-wrap h3 {
  font-size: 14px;
  font-weight: 600;
  padding: 20px 24px 12px;
  color: #2d3436;
  margin: 0;
}

table.aura-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.aura-table thead {
  background: #1a1a2e;
  color: #dfe6e9;
}

table.aura-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 500;
  white-space: nowrap;
  transition: background 0.15s;
}

table.aura-table th[data-sort],
table.aura-table th.sortable {
  cursor: pointer;
}

table.aura-table th:hover {
  background: rgba(255, 255, 255, 0.1);
}

table.aura-table td {
  padding: 10px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: #2d3436;
}

table.aura-table tbody tr:last-child td {
  border-bottom: none;
}

table.aura-table tbody tr:hover td {
  background: #f8f9ff;
}

.forecast-row td,
table.aura-table .forecast-bg {
  background: #f0f8ff;
}

table.aura-table tbody .forecast-row:hover td {
  background: #e6f4ff;
}

/* Pagination */
.aura-pagination {
  display: flex;
  gap: 8px;
  justify-content: center;
  padding: 16px;
  flex-wrap: wrap;
}

.aura-pagination button {
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid #e0e0e0;
  background: #ffffff;
  cursor: pointer;
  font-size: 13px;
  font-family: inherit;
  color: #2d3436;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.aura-pagination button:hover:not(.active) {
  background: #f5f6fa;
}

.aura-pagination button.active {
  background: #0f3460;
  color: #ffffff;
  border-color: #0f3460;
}

/* --------------------------------------------------------------------------
   7. Alert Cards
   -------------------------------------------------------------------------- */

.aura-alert-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 12px;
  border-left: 4px solid #e0e0e0;
}

.aura-alert-card.severity-red {
  border-left-color: #e74c3c;
}

.aura-alert-card.severity-yellow {
  border-left-color: #f39c12;
}

.aura-alert-card.severity-green {
  border-left-color: #00b894;
}

.aura-alert-card .alert-title {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #1a1a2e;
}

.aura-alert-card .alert-desc {
  font-size: 13px;
  color: #636e72;
  margin-bottom: 8px;
}

.aura-alert-card .alert-meta {
  font-size: 11px;
  color: #999999;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* --------------------------------------------------------------------------
   8. Timeline
   -------------------------------------------------------------------------- */

.aura-timeline {
  position: relative;
  padding-left: 40px;
  margin-top: 32px;
}

.aura-timeline::before {
  content: '';
  position: absolute;
  left: 15px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: #e0e0e0;
}

.timeline-event {
  position: relative;
  padding-bottom: 24px;
}

.timeline-dot {
  position: absolute;
  left: -33px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid #e0e0e0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  top: 0;
}

.timeline-date {
  font-size: 11px;
  color: #999999;
  margin-bottom: 4px;
}

.timeline-text {
  font-size: 14px;
  color: #2d3436;
}

/* --------------------------------------------------------------------------
   9. Gauge
   -------------------------------------------------------------------------- */

.aura-gauge {
  text-align: center;
  margin-bottom: 16px;
}

.aura-gauge .gauge-label {
  font-size: 12px;
  color: #636e72;
  margin-top: 8px;
}

/* --------------------------------------------------------------------------
   10. Sparkline
   -------------------------------------------------------------------------- */

.sparkline-container {
  display: inline-block;
  vertical-align: middle;
}

.sparkline-container svg {
  width: 80px;
  height: 24px;
}

/* --------------------------------------------------------------------------
   11. CdG Product Cards
   -------------------------------------------------------------------------- */

.aura-cdg-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
  margin-bottom: 24px;
}

.aura-cdg-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: box-shadow 0.2s, transform 0.2s;
}

.aura-cdg-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.cdg-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}

.cdg-card-title {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
}

.cdg-margin-bar {
  height: 8px;
  border-radius: 4px;
  background: #f0f0f0;
  overflow: hidden;
  margin-top: 12px;
}

.cdg-margin-fill {
  height: 100%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Green if margin > 30%, yellow if 15–30%, red if < 15% */
.cdg-margin-fill.margin-high {
  background: #00b894;
}

.cdg-margin-fill.margin-mid {
  background: #f39c12;
}

.cdg-margin-fill.margin-low {
  background: #e74c3c;
}

.cdg-card-detail {
  display: none;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #f0f0f0;
}

.cdg-card-detail.expanded {
  display: block;
}

/* --------------------------------------------------------------------------
   12. World Map
   -------------------------------------------------------------------------- */

.aura-map-container {
  background: #ffffff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  margin-bottom: 24px;
  position: relative;
}

.aura-map-container svg {
  width: 100%;
  max-height: 400px;
  display: block;
}

.map-tooltip {
  position: absolute;
  background: #1a1a2e;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 12px;
  pointer-events: none;
  z-index: 10;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   13. Infografica
   -------------------------------------------------------------------------- */

.aura-infografica-preview {
  background: linear-gradient(135deg, #1a1a2e, #0f3460);
  border-radius: 16px;
  padding: 40px;
  color: #ffffff;
  margin-bottom: 24px;
}

.infografica-score {
  font-size: 64px;
  font-weight: 800;
  line-height: 1;
}

.infografica-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  margin-top: 24px;
}

.infografica-item .value {
  font-size: 24px;
  font-weight: 700;
}

.infografica-item .label {
  font-size: 12px;
  opacity: 0.7;
}

.infografica-archive {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.archive-card {
  background: #ffffff;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  color: #1a1a2e;
}

.archive-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
}

/* --------------------------------------------------------------------------
   14. Period Selector
   -------------------------------------------------------------------------- */

.aura-period-selector {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.aura-period-selector .aura-toggle-btn {
  padding: 8px 20px;
  border-radius: 6px;
  border: none;
  background: #f0f0f0;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
  color: #636e72;
  font-family: inherit;
}

.aura-period-selector .aura-toggle-btn:hover:not(.active) {
  background: rgba(0, 0, 0, 0.08);
  color: #2d3436;
}

.aura-period-selector .aura-toggle-btn.active {
  background: #0f3460;
  color: #ffffff;
  box-shadow: 0 2px 4px rgba(15, 52, 96, 0.3);
}

/* --------------------------------------------------------------------------
   15. Insight AI Box
   -------------------------------------------------------------------------- */

.aura-insight-box {
  background: linear-gradient(135deg, #f8f9ff 0%, #f0f3ff 100%);
  border: 1px solid #d5dcf5;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 24px;
}
.insight-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid #d5dcf5;
}
.insight-icon { font-size: 20px; }
.insight-title { font-size: 14px; font-weight: 700; color: #0f3460; }
.insight-date { margin-left: auto; font-size: 11px; color: #999; }
.insight-body { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.insight-section { }
.insight-section:first-child { grid-column: 1 / -1; }
.insight-label { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 6px; color: #636e72; }
.insight-label.good { color: #00b894; }
.insight-label.warning { color: #f39c12; }
.insight-label.action { color: #0f3460; }
.insight-section p { font-size: 13px; line-height: 1.7; color: #2d3436; margin: 0; }

/* --------------------------------------------------------------------------
   16. Responsive
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
  .aura-kpi-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .aura-charts-grid {
    grid-template-columns: 1fr;
  }

  .aura-chart-card.full {
    grid-column: span 1;
  }

  .aura-cdg-grid {
    grid-template-columns: 1fr;
  }

  .infografica-archive {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .tab-bar-grouped {
    flex-direction: column;
    padding: 0;
  }

  .tab-section {
    width: 100%;
  }

  .tab-section-btn {
    width: 100%;
    text-align: left;
    padding: 14px 20px;
    border-bottom: 1px solid #e0e0e0;
    border-bottom-color: #e0e0e0;
  }

  .tab-section-btn.active {
    border-bottom-color: #e0e0e0;
    color: #0f3460;
  }

  .tab-dropdown {
    position: static;
    box-shadow: none;
    border: none;
    border-radius: 0;
    background: #f5f6fa;
  }

  .tab-dropdown-item {
    padding-left: 40px;
  }

  .aura-kpi-grid {
    grid-template-columns: 1fr;
  }

  .aura-table-wrap {
    overflow-x: auto;
  }

  .aura-cdg-grid {
    grid-template-columns: 1fr;
  }

  .infografica-grid {
    grid-template-columns: 1fr;
  }

  .infografica-archive {
    grid-template-columns: 1fr;
  }

  .aura-filter-bar {
    flex-direction: column;
    align-items: stretch;
  }

  .aura-filter-bar select,
  .aura-filter-bar input[type="text"] {
    width: 100%;
    box-sizing: border-box;
  }

  .infografica-score {
    font-size: 48px;
  }

  .aura-infografica-preview {
    padding: 24px;
  }

  .aura-charts-grid {
    grid-template-columns: 1fr;
  }

  .aura-chart-card.full {
    grid-column: span 1;
  }

  .insight-body {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------------------------------
   17. Conto Economico (CE) Table
   -------------------------------------------------------------------------- */

.ce-table-wrap {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow-x: auto;
  margin-bottom: 24px;
}
.ce-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
  min-width: 1400px;
}
.ce-table thead th {
  background: #0f3460;
  color: white;
  padding: 8px 12px;
  font-weight: 600;
  font-size: 11px;
  text-align: right;
  white-space: nowrap;
  border-right: 1px solid rgba(255,255,255,0.1);
}
.ce-table thead th:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 2;
  background: #0f3460;
  min-width: 280px;
}
.ce-table thead .col-group-header {
  background: #1a1a2e;
  text-align: center;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.ce-table tbody td {
  padding: 6px 12px;
  text-align: right;
  border-bottom: 1px solid #f0f0f0;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.ce-table tbody td:first-child {
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 1;
  background: inherit;
  font-size: 13px;
}
.ce-table .row-header td {
  background: #1a1a2e;
  color: white;
  font-weight: 700;
  border-bottom: none;
}
.ce-table .row-header td:first-child {
  background: #1a1a2e;
}
.ce-table .row-margin td {
  background: #f0f8ff;
  font-weight: 700;
  color: #0f3460;
}
.ce-table .row-margin td:first-child {
  background: #f0f8ff;
}
.ce-table .row-margin-pct td {
  background: #f0f8ff;
  font-weight: 600;
  color: #0f3460;
  font-style: italic;
  font-size: 11px;
}
.ce-table .row-margin-pct td:first-child {
  background: #f0f8ff;
  padding-left: 24px;
}
.ce-table .row-normal td:first-child {
  padding-left: 24px;
}
.ce-table .variance-positive { color: #00b894; }
.ce-table .variance-negative { color: #e74c3c; }
.ce-table .col-vdp { color: #999; font-size: 11px; }
.ce-table .row-separator td { height: 8px; border: none; background: #fafafa; }

/* ==========================================================================
   Castelletto Fidi
   ========================================================================== */
.fidi-bar-container { margin-bottom: 24px; }
.fidi-bar-row { display: flex; align-items: center; margin-bottom: 8px; }
.fidi-bar-label { width: 140px; font-size: 13px; font-weight: 600; color: #2d3436; flex-shrink: 0; }
.fidi-bar-track { flex: 1; height: 24px; background: #e8f5e9; border-radius: 6px; overflow: hidden; position: relative; }
.fidi-bar-fill { height: 100%; border-radius: 6px 0 0 6px; transition: width 0.3s; }
.fidi-bar-fill.green { background: #00b894; }
.fidi-bar-fill.yellow { background: #f39c12; }
.fidi-bar-fill.red { background: #e74c3c; }
.fidi-bar-amounts { width: 200px; text-align: right; font-size: 12px; color: #636e72; flex-shrink: 0; padding-left: 12px; }
.fidi-badge-scadenza { display: inline-block; background: #fff3cd; color: #856404; font-size: 10px; padding: 2px 6px; border-radius: 4px; font-weight: 600; margin-left: 6px; }

/* --------------------------------------------------------------------------
   18. CdG Accordion
   -------------------------------------------------------------------------- */

.cdg-accordion-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 4px;
  transition: all 0.2s;
  font-weight: 600;
  font-size: 14px;
  color: #2d3436;
}
.cdg-accordion-header:hover { background: #f5f6fa; }
.cdg-accordion-header.open { border-radius: 8px 8px 0 0; background: #f0f3ff; color: #0f3460; border-bottom-color: transparent; }
.cdg-accordion-header .arrow { transition: transform 0.2s; }
.cdg-accordion-header.open .arrow { transform: rotate(90deg); }
.cdg-accordion-body {
  display: none;
  padding: 20px;
  background: white;
  border: 1px solid #e0e0e0;
  border-top: none;
  border-radius: 0 0 8px 8px;
  margin-bottom: 16px;
}
.cdg-accordion-body.open { display: block; }

/* --------------------------------------------------------------------------
   19. BOM Table
   -------------------------------------------------------------------------- */

.bom-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.bom-table thead th { background: #0f3460; color: white; padding: 8px 10px; font-weight: 500; font-size: 11px; text-align: right; white-space: nowrap; }
.bom-table thead th:first-child { text-align: left; }
.bom-table tbody td { padding: 6px 10px; text-align: right; border-bottom: 1px solid #f0f0f0; font-variant-numeric: tabular-nums; }
.bom-table tbody td:first-child { text-align: left; }
.bom-table .total-row td { font-weight: 700; background: #f5f6fa; border-top: 2px solid #e0e0e0; }

/* --------------------------------------------------------------------------
   20. Ratio Analysis (Analisi di Bilancio)
   -------------------------------------------------------------------------- */

.ratio-category { margin-bottom: 32px; }
.ratio-category-title { font-size: 16px; font-weight: 700; color: #0f3460; margin-bottom: 16px; padding-bottom: 8px; border-bottom: 2px solid #0f3460; }
.ratio-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.ratio-card { background: white; border-radius: 10px; padding: 16px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); border-left: 4px solid #636e72; }
.ratio-card.green { border-left-color: #00b894; }
.ratio-card.yellow { border-left-color: #f39c12; }
.ratio-card.red { border-left-color: #e74c3c; }
.ratio-card .ratio-name { font-size: 13px; font-weight: 700; color: #2d3436; margin-bottom: 4px; }
.ratio-card .ratio-formula { font-size: 11px; color: #999; margin-bottom: 8px; font-style: italic; }
.ratio-card .ratio-value { font-size: 24px; font-weight: 800; color: #1a1a2e; }
.ratio-card .ratio-benchmark { font-size: 11px; color: #636e72; margin-top: 4px; }
.ratio-card .ratio-trend { font-size: 12px; margin-top: 6px; }
.ratio-card .ratio-comment { font-size: 12px; color: #636e72; margin-top: 6px; line-height: 1.5; }

/* SP Riclassificato */
.sp-visual { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 32px; }
.sp-column { background: white; border-radius: 12px; padding: 20px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); }
.sp-column h3 { font-size: 14px; font-weight: 700; margin-bottom: 16px; color: #0f3460; }
.sp-bar-row { display: flex; align-items: center; margin-bottom: 8px; }
.sp-bar-label { width: 180px; font-size: 12px; color: #2d3436; }
.sp-bar-track { flex: 1; height: 20px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.sp-bar-fill { height: 100%; border-radius: 4px; }
.sp-bar-value { width: 100px; text-align: right; font-size: 12px; font-weight: 600; color: #2d3436; }

/* --------------------------------------------------------------------------
   21. Backlog Detail Table
   -------------------------------------------------------------------------- */

.backlog-status-badge { display: inline-block; padding: 3px 10px; border-radius: 12px; font-size: 11px; font-weight: 600; white-space: nowrap; }
.backlog-status-badge.prod { background: #e8f5e9; color: #2e7d32; }
.backlog-status-badge.conf { background: #e3f2fd; color: #1565c0; }
.backlog-status-badge.plan { background: #f5f5f5; color: #757575; }
.backlog-progress-track { width: 100%; height: 8px; background: #f0f0f0; border-radius: 4px; overflow: hidden; }
.backlog-progress-fill { height: 100%; border-radius: 4px; background: #0f3460; transition: width 0.3s; }

/* --------------------------------------------------------------------------
   22. Bubble Map
   -------------------------------------------------------------------------- */

.bubble-map-legend { display: flex; gap: 16px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.bubble-map-legend-item { display: flex; align-items: center; gap: 6px; font-size: 11px; color: #636e72; }

@media (max-width: 768px) {
  .sp-visual { grid-template-columns: 1fr; }
  .ratio-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   23. Home Landing Page
   ========================================================================== */

.view-home {
  display: none;
  margin-left: 72px;
  padding: 32px;
  transition: margin-left 0.3s;
  background: #f5f6fa;
  min-height: calc(100vh - 64px);
}
.portal.sidebar-collapsed .view-home { margin-left: 0; }

.home-welcome {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, #0f3460 0%, #1a1a2e 100%);
  border-radius: 16px;
  padding: 32px 40px;
  color: white;
  margin-bottom: 24px;
}
.home-welcome-text h1 {
  font-size: 24px;
  font-weight: 800;
  margin-bottom: 8px;
}
.home-welcome-text p {
  font-size: 14px;
  opacity: 0.7;
}
.home-fp-score {
  text-align: center;
}
.home-score-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #00b894;
  margin-top: 4px;
}

.home-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.home-kpi-card {
  background: white;
  border-radius: 12px;
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.home-kpi-card.warning {
  border-left: 4px solid #f39c12;
}
.home-kpi-icon {
  font-size: 28px;
}
.home-kpi-value {
  font-size: 22px;
  font-weight: 800;
  color: #1a1a2e;
}
.home-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #636e72;
  letter-spacing: 0.5px;
  margin-bottom: 2px;
}
.home-kpi-trend {
  font-size: 12px;
  font-weight: 600;
}
.home-kpi-trend.up { color: #00b894; }
.home-kpi-trend.down { color: #e74c3c; }
.home-kpi-trend.stable { color: #636e72; }

.home-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}
.home-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.home-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.home-card-header h3 {
  font-size: 15px;
  font-weight: 700;
  color: #2d3436;
}
.home-link {
  font-size: 12px;
  color: #0f3460;
  text-decoration: none;
  font-weight: 600;
}
.home-link:hover { text-decoration: underline; }

.home-alert-list { display: flex; flex-direction: column; gap: 12px; }
.home-alert {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px;
  border-radius: 8px;
  background: #fafafa;
}
.home-alert-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}
.home-alert.red .home-alert-dot { background: #e74c3c; }
.home-alert.yellow .home-alert-dot { background: #f39c12; }
.home-alert.green .home-alert-dot { background: #00b894; }
.home-alert strong { font-size: 13px; color: #2d3436; display: block; margin-bottom: 2px; }
.home-alert p { font-size: 12px; color: #636e72; margin: 0; }

.home-activity-list { display: flex; flex-direction: column; gap: 8px; }
.home-activity {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  color: #2d3436;
  background: #fafafa;
}
.home-activity-date {
  font-size: 11px;
  font-weight: 700;
  color: #0f3460;
  min-width: 40px;
}

.home-quick-access {
  margin-bottom: 24px;
}
.home-quick-access h3 {
  font-size: 15px;
  font-weight: 700;
  color: #2d3436;
  margin-bottom: 16px;
}
.home-quick-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 12px;
}
.home-quick-card {
  background: white;
  border-radius: 12px;
  padding: 20px 16px;
  text-align: center;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  transition: all 0.2s;
}
.home-quick-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(0,0,0,0.1);
}
.home-quick-icon {
  font-size: 28px;
  display: block;
  margin-bottom: 8px;
}
.home-quick-label {
  font-size: 12px;
  font-weight: 600;
  color: #2d3436;
}

.home-partner {
  background: white;
  border-radius: 12px;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.home-partner-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #0f3460;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}
.home-partner-label {
  font-size: 11px;
  text-transform: uppercase;
  color: #636e72;
  letter-spacing: 0.5px;
}
.home-partner-name {
  font-size: 16px;
  font-weight: 700;
  color: #1a1a2e;
}
.home-partner-contact {
  font-size: 12px;
  color: #636e72;
  margin-top: 2px;
}
.home-partner-btn {
  margin-left: auto;
  padding: 10px 20px;
  background: #0f3460;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}
.home-partner-btn:hover { background: #1a4a8a; }

@media (max-width: 1024px) {
  .home-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .home-quick-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 768px) {
  .view-home { margin-left: 0; padding: 16px; }
  .home-welcome { flex-direction: column; text-align: center; padding: 24px; }
  .home-kpi-row { grid-template-columns: 1fr; }
  .home-grid { grid-template-columns: 1fr; }
  .home-quick-grid { grid-template-columns: repeat(2, 1fr); }
  .home-partner { flex-direction: column; text-align: center; }
  .home-partner-btn { margin-left: 0; }
}

/* Partner Section Expanded */
.home-partner-section {
  margin-bottom: 24px;
}
.home-partner-section > h3 {
  font-size: 15px;
  font-weight: 700;
  color: #2d3436;
  margin-bottom: 16px;
}
.home-partner-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.home-partner-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}
.home-partner-card .home-partner-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: #0f3460;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 20px;
  margin-bottom: 12px;
}
.home-partner-card .home-partner-name {
  font-size: 18px;
  font-weight: 700;
  color: #1a1a2e;
  margin-bottom: 2px;
}
.home-partner-role {
  font-size: 12px;
  color: #636e72;
  margin-bottom: 16px;
}
.home-partner-contacts {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}
.home-contact-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: #0f3460;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s;
}
.home-contact-btn:hover { background: #1a4a8a; }
.home-contact-btn.secondary {
  background: white;
  color: #0f3460;
  border: 1px solid #e0e0e0;
}
.home-contact-btn.secondary:hover { background: #f5f6fa; }

.home-appointments-card {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.home-appointments-card h4 {
  font-size: 14px;
  font-weight: 700;
  color: #2d3436;
  margin-bottom: 16px;
}
.home-appointment-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.home-appointment {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: #fafafa;
  border-radius: 8px;
}
.home-appt-date {
  width: 48px;
  height: 48px;
  background: #0f3460;
  color: white;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.appt-day {
  font-size: 18px;
  font-weight: 800;
  line-height: 1;
}
.appt-month {
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 1px;
  opacity: 0.8;
}
.home-appt-info strong {
  display: block;
  font-size: 13px;
  color: #2d3436;
  margin-bottom: 2px;
}
.home-appt-info span {
  font-size: 12px;
  color: #636e72;
}

/* Document Checklist */
.home-docs-checklist {
  background: white;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  margin-bottom: 24px;
}
.home-docs-checklist .home-card-header {
  margin-bottom: 16px;
}
.home-docs-status {
  font-size: 13px;
  font-weight: 600;
  color: #f39c12;
}
.home-docs-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}
.home-doc-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 8px;
  background: #fafafa;
}
.home-doc-item.received { background: #f0faf6; }
.home-doc-item.missing { background: #fffbf0; }
.home-doc-item.overdue { background: #fff5f5; }
.home-doc-check {
  font-size: 16px;
  flex-shrink: 0;
}
.home-doc-info {
  flex: 1;
}
.home-doc-info strong {
  display: block;
  font-size: 13px;
  color: #2d3436;
}
.home-doc-info span {
  font-size: 11px;
  color: #636e72;
}
.home-doc-upload {
  font-size: 12px;
  font-weight: 600;
  color: #0f3460;
  text-decoration: none;
  white-space: nowrap;
}
.home-doc-upload:hover { text-decoration: underline; }
.home-docs-progress {
  display: flex;
  align-items: center;
  gap: 12px;
}
.home-docs-bar {
  flex: 1;
  height: 8px;
  background: #f0f0f0;
  border-radius: 4px;
  overflow: hidden;
}
.home-docs-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #00b894, #f39c12);
  border-radius: 4px;
  transition: width 0.3s;
}
.home-docs-pct {
  font-size: 12px;
  font-weight: 600;
  color: #636e72;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .home-partner-grid { grid-template-columns: 1fr; }
}

/* ==========================================================================
   Cash Flow Rolling — Budget vs Forecast vs Actual
   ========================================================================== */

/* Chart legend */
.cf-legend {
  display: flex;
  gap: 20px;
  justify-content: center;
  padding: 12px 0;
  margin-bottom: 16px;
  font-size: 12px;
  color: #636e72;
  flex-wrap: wrap;
}
.cf-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
}
.cf-legend-bar {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  flex-shrink: 0;
}
.cf-legend-bar.green { background: rgba(0, 184, 148, 0.8); }
.cf-legend-bar.red   { background: rgba(231, 76, 60, 0.8); }
.cf-legend-line {
  width: 20px;
  height: 0;
  border-top: 3px solid;
  flex-shrink: 0;
}
.cf-legend-line.solid.green  { border-color: #00b894; border-style: solid; }
.cf-legend-line.dashed.blue  { border-color: #0f3460; border-style: dashed; }
.cf-legend-line.dashed.gray  { border-color: #b2bec3; border-style: dashed; }

/* Rendiconto table row variants */
.cf-budget-row td   { color: #999; font-style: italic; font-size: 12px; }
.cf-forecast-row td { color: #0f3460; font-style: italic; border-top: 1px dashed #d5dcf5; }
.cf-delta-row td    { font-weight: 600; font-size: 12px; }

/* ═══ Bandi & Agevolazioni ═══ */

/* Home mini-widget */
.home-bandi-widget { grid-column: 1 / -1; }

.home-bandi-list {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.home-bando-card {
  background: #f8f9fc;
  border: 1px solid #e8ecf1;
  border-radius: 8px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: box-shadow 0.2s;
}
.home-bando-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}
.home-bando-title {
  font-weight: 600;
  font-size: 13px;
  color: #2d3436;
  line-height: 1.4;
}
.home-bando-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.home-bando-ente {
  font-size: 11px;
  color: #636e72;
}

.bandi-badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 2px 8px;
  border-radius: 10px;
}
.bandi-badge.aperto {
  background: rgba(0,184,148,0.1);
  color: #00b894;
}
.bandi-badge.in_apertura {
  background: rgba(243,156,18,0.1);
  color: #f39c12;
}
.bandi-badge.nuovo {
  background: rgba(15,52,96,0.1);
  color: #0f3460;
}

.home-bando-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  font-size: 11px;
  color: #636e72;
}
.home-bando-importo {
  font-weight: 700;
  color: #0f3460;
  font-size: 13px;
}

.bandi-count-badge {
  display: inline-block;
  background: #0f3460;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
}

/* Tab - Bandi full view */
.bandi-kpi-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.bandi-kpi-card {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
}
.bandi-kpi-value {
  font-size: 28px;
  font-weight: 800;
  color: #0f3460;
}
.bandi-kpi-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: #636e72;
  margin-top: 4px;
  font-weight: 600;
}

.bandi-table-card {
  background: #fff;
  border-radius: 8px;
  padding: 24px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.bandi-table-card h3 {
  margin-bottom: 16px;
  font-size: 16px;
  color: #2d3436;
}

.bandi-table {
  width: 100%;
  border-collapse: collapse;
}
.bandi-table thead th {
  background: #1a1a2e;
  color: #fff;
  padding: 10px 14px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  text-align: left;
}
.bandi-table thead th:first-child { border-radius: 6px 0 0 0; }
.bandi-table thead th:last-child { border-radius: 0 6px 0 0; }
.bandi-table tbody td {
  padding: 12px 14px;
  font-size: 13px;
  border-bottom: 1px solid #f0f0f0;
  color: #2d3436;
}
.bandi-table tbody tr:hover { background: #f8f9fc; }
.bandi-table tbody tr:nth-child(even) { background: #fafbfd; }
.bandi-table tbody tr:nth-child(even):hover { background: #f0f3ff; }

.bandi-btn-partner {
  display: inline-block;
  background: #0f3460;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.2s;
  cursor: pointer;
  border: none;
}
.bandi-btn-partner:hover { background: #1a4a8a; }

.bandi-disclaimer {
  margin-top: 20px;
  padding: 16px;
  background: #f8f9fc;
  border-radius: 8px;
  font-size: 12px;
  color: #636e72;
  line-height: 1.6;
}

@media (max-width: 1200px) {
  .home-bandi-list { grid-template-columns: repeat(2, 1fr); }
  .bandi-kpi-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .home-bandi-list { grid-template-columns: 1fr; }
  .bandi-kpi-grid { grid-template-columns: 1fr; }
  .bandi-table { font-size: 12px; }
}

/* ═══ Report Center ═══ */
.rc-section-title {
  font-size: 14px;
  font-weight: 700;
  color: #2d3436;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #0f3460;
  display: inline-block;
}

.rc-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 8px;
}

.rc-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  gap: 14px;
  transition: box-shadow 0.2s, transform 0.2s;
}
.rc-card:hover {
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
  transform: translateY(-2px);
}

.rc-card-icon {
  font-size: 28px;
  flex-shrink: 0;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f5f6fa;
  border-radius: 10px;
}

.rc-card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.rc-card-title {
  font-size: 14px;
  font-weight: 700;
  color: #2d3436;
  margin-bottom: 4px;
}

.rc-card-desc {
  font-size: 12px;
  color: #636e72;
  line-height: 1.5;
  flex: 1;
}

.rc-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 12px;
}

.rc-freq-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 10px;
}
.rc-freq-badge.periodic {
  background: rgba(0,184,148,0.1);
  color: #00b894;
}
.rc-freq-badge.ondemand {
  background: rgba(15,52,96,0.1);
  color: #0f3460;
}
.rc-freq-badge.export {
  background: rgba(243,156,18,0.1);
  color: #f39c12;
}

.rc-download-btn {
  background: #0f3460;
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  font-family: inherit;
}
.rc-download-btn:hover {
  background: #1a4a8a;
}

@media (max-width: 1200px) {
  .rc-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 768px) {
  .rc-grid { grid-template-columns: 1fr; }
}
