.budget-explorer {
  width: min(980px, calc(100vw - 2rem));
  margin: 2rem 0 2rem 50%;
  transform: translateX(-50%);
  font-family: var(--font-sans);
  font-size: 1rem;
  line-height: 1.45;
}

.budget-explorer * {
  box-sizing: border-box;
}

.budget-status,
.budget-error {
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: var(--color-background-subtle);
  padding: 1rem;
}

.budget-error {
  border-left: 4px solid var(--color-warning-border);
}

.budget-summary {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 1rem;
}

.budget-stat,
.budget-section,
.budget-department {
  border: 1px solid var(--color-border);
  border-radius: 0.75rem;
  background: #fff;
}

.budget-stat {
  padding: 0.9rem;
}

.budget-stat-label,
.budget-label {
  color: var(--color-text-muted);
  font-size: 0.74rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.budget-stat-value {
  display: block;
  font-size: 1.2rem;
  font-weight: 700;
  margin-top: 0.3rem;
}

.budget-departments {
  display: grid;
  gap: 0.75rem;
}

.budget-section[open],
.budget-department[open] {
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.12);
}

.budget-section-summary,
.budget-department-summary {
  cursor: pointer;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: minmax(16rem, 1.4fr) repeat(3, minmax(8rem, 1fr));
  list-style: none;
  padding: 1rem;
}

.budget-section-summary::-webkit-details-marker,
.budget-department-summary::-webkit-details-marker {
  display: none;
}

.budget-section-title,
.budget-department-title {
  display: grid;
  gap: 0.2rem;
}

.budget-section-name,
.budget-department-name {
  font-weight: 800;
}

.budget-section-note,
.budget-department-section {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.budget-section-departments {
  background: var(--color-background-subtle);
  border-top: 1px solid var(--color-border);
  display: grid;
  gap: 0.65rem;
  padding: 0.75rem;
}

.budget-section-departments .budget-department {
  border-radius: 0.65rem;
}

.budget-section-departments .budget-department-summary {
  padding: 0.85rem;
}

.budget-value {
  display: grid;
  gap: 0.25rem;
}

.budget-amount,
.budget-delta {
  font-weight: 700;
}

.budget-delta.positive {
  color: #047857;
}

.budget-delta.negative {
  color: #b91c1c;
}

.budget-detail {
  border-top: 1px solid var(--color-border);
  overflow-x: auto;
}

.budget-table {
  border-collapse: collapse;
  font-size: 0.88rem;
  margin: 0;
  min-width: 720px;
  width: 100%;
}

.budget-table th,
.budget-table td {
  border-bottom: 1px solid var(--color-border);
  padding: 0.65rem 0.75rem;
  vertical-align: top;
}

.budget-table tr:last-child td {
  border-bottom: 0;
}

.budget-table th {
  color: var(--color-text-secondary);
  font-size: 0.74rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.budget-table td:not(:first-child),
.budget-table th:not(:first-child) {
  text-align: right;
  white-space: nowrap;
}

@media (max-width: 820px) {
  .budget-summary,
  .budget-section-summary,
  .budget-department-summary {
    grid-template-columns: 1fr;
  }

  .budget-section-summary,
  .budget-department-summary {
    gap: 0.55rem;
  }
}
