/* Shared elevation/fill tier consumed by content, grouping, navigation, and
   dashboard surfaces. Each component retains ownership of its own structure. */
:where(.section-block, .asset-group, .chart-card, .table-card, .planner-nav, .dashboard-next-action) {
  background: var(--color-surface);
  border: var(--border-thin);
  box-shadow: var(--shadow);
}

/* Shared content containers. Their chart/table internals remain page-owned. */
.chart-card,
.table-card {
  border-radius: var(--radius-xl);
  padding: var(--space-7);
}

.chart-card h3,
.table-card h3 {
  margin-bottom: var(--space-1);
}

.chart-card p,
.table-card p {
  margin-bottom: var(--space-5);
  color: var(--color-text-muted);
}

.table-card {
  overflow-x: auto;
}

/* Form and grouping panels sit between the page and their recessed controls. */
.section-block,
.asset-group {
  background: var(--color-surface-soft);
  border-radius: var(--radius-md);
  padding: var(--space-5);
  box-shadow: none;
}

.section-block .section-title,
.asset-group .section-title {
  margin: 0 0 12px;
  padding: 0;
  border: 0;
}

.section-copy {
  margin: 0 0 var(--space-4);
  color: var(--color-text-muted);
}

.section-block {
  margin-bottom: 14px;
}

/* Trailing field/copy margins must not erode the panel's bottom padding. */
.section-block > *:last-child {
  margin-bottom: 0;
}

/* Metric card used by Summary and Actual vs Plan. Page layout variants only
   position or densify it; the visual hierarchy and semantic states live here. */
.card {
  background: #fff;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  transition: transform 0.2s, box-shadow 0.2s;
}

.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

.card-label {
  color: var(--grey);
  margin-bottom: 8px;
}

.card-value {
  margin-bottom: 4px;
}

.card-sub {
  color: var(--text-light);
}

.card-facts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-top: 1px;
}

.card-facts span {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(240,242,247,0.8);
  color: var(--text-light);
  font-size: var(--font-size-compact);
  line-height: 1.2;
  white-space: nowrap;
}

.card.highlight { background: var(--navy); border-color: var(--navy); }
.card.highlight .card-label { color: var(--accent); }
.card.highlight .card-value { color: #fff; }
.card.highlight .card-sub { color: rgba(255,255,255,0.6); }

.card.good { border-top: 3px solid var(--color-positive); }
.card.warn { border-top: 3px solid var(--color-warning-accent); }
.card.danger { border-top: 3px solid var(--color-danger); }

/* Shared dense metric group used by Summary and Actual vs Plan. */
.stat-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stat-strip .card {
  padding: 10px 14px;
}

/* One accessible type size at both breakpoints; density is expressed through
   layout and spacing instead of shrinking supporting text. */
.stat-strip .card-label {
  margin-bottom: 2px;
}

.stat-strip .card-value { margin-bottom: 2px; }

@media (min-width: 1025px) {
  .planner-workspace .stat-strip {
    flex-shrink: 0;
  }

  .planner-workspace .chart-card,
  .planner-workspace .table-card {
    border-radius: var(--radius-md);
    box-shadow: none;
  }

  .stat-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 0;
    margin-bottom: 16px;
    padding: 14px 6px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: rgba(255,255,255,0.7);
    box-shadow: none;
  }

  .stat-strip .card {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-height: 90px;
    padding: 4px 16px;
    border: 0;
    border-left: 1px solid rgba(138,154,181,0.28);
    border-radius: 0;
    background: transparent;
    box-shadow: none;
  }

  .stat-strip .card:first-child {
    border-left: 0;
  }

  .stat-strip .card.warn {
    border-top: 0;
    border-left: 2px solid var(--color-warning-accent);
  }

  .stat-strip .card:hover {
    transform: none;
    box-shadow: 0 2px 12px rgba(15,30,60,0.07);
  }

  .stat-strip .card-label {
    margin-bottom: 6px;
    line-height: 1.15;
    letter-spacing: 0.9px;
  }

  .stat-strip .card-value {
    margin-bottom: 5px;
    line-height: 1.08;
  }

  .stat-strip .card-sub {
    line-height: 1.28;
  }

  .stat-strip .card-facts {
    gap: 4px;
  }

  .stat-strip .card-facts span {
    padding: 2px 5px;
  }
}

/* Tablet and compact layouts avoid the six-column desktop metric strip. */
@media (max-width: 1024px) {
  .content-page.active .stat-strip {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 0;
  }
}

@media (max-width: 767px) {
  .section-block {
    margin-bottom: var(--space-2);
  }

  .section-block .section-title,
  .asset-group .section-title {
    margin-bottom: var(--space-2);
  }

  .section-block,
  .asset-group {
    padding: var(--space-4);
  }
}
