:host {
  display: block;
  padding: 2rem clamp(1rem, 4vw, 3rem);
  background: #f8fafc;
  min-height: 100%;
}

.report {
  max-width: 1280px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.report__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  align-items: flex-end;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.8rem;
  color: #94a3b8;
  margin: 0 0 0.25rem;
}

.report__header h1 {
  margin: 0 0 0.25rem;
  font-size: clamp(1.8rem, 4vw, 2.4rem);
  color: #0f172a;
}

.muted {
  margin: 0;
  color: #94a3b8;
  font-size: 0.95rem;
}

.report__actions {
  display: inline-flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn {
  border: none;
  border-radius: 999px;
  padding: 0.65rem 1.4rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.btn--primary {
  background: linear-gradient(135deg, #22d3ee, #0ea5e9);
  color: #0f172a;
  box-shadow: 0 15px 30px rgba(14, 165, 233, 0.25);
}

.btn--ghost {
  background: #fff;
  color: #0f172a;
  border: 1px solid #cbd5f5;
}

.btn--compact {
  padding: 0.45rem 1.1rem;
  font-size: 0.9rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.summary-card {
  position: relative;
  background: #fff;
  border-radius: 20px;
  padding: 1.25rem;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.08);
}

.summary-card__label {
  margin: 0;
  color: #64748b;
  font-size: 0.9rem;
}

.summary-card h2 {
  margin: 0.4rem 0;
  font-size: 1.6rem;
  color: #0f172a;
}

.summary-card__detail {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.summary-card__tone {
  position: absolute;
  inset: 0;
  border-radius: 20px;
  pointer-events: none;
  opacity: 0.15;
}

.tone-mint { background: linear-gradient(135deg, #a7f3d0, #34d399); }
.tone-amber { background: linear-gradient(135deg, #fde68a, #fbbf24); }
.tone-indigo { background: linear-gradient(135deg, #c4b5fd, #818cf8); }
.tone-slate { background: linear-gradient(135deg, #cbd5f5, #94a3b8); }

.report__content {
  display: grid;
  grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
  gap: 1.5rem;
}

.panel {
  background: #fff;
  border-radius: 24px;
  padding: 1.5rem;
  box-shadow: 0 15px 45px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.panel__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: center;
}

.panel__header h2 {
  margin: 0;
}

.panel__header p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.9rem;
}

.table {
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  overflow: hidden;
}

.table__head,
.table__row {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.6fr 1fr 0.8fr;
  padding: 0.85rem 1rem;
  gap: 1rem;
  align-items: center;
}

.table__head {
  background: #f1f5f9;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
}

.table__row:nth-child(even) {
  background: rgba(15, 23, 42, 0.015);
}

.table__row strong {
  display: block;
}

.table__row small {
  display: block;
  font-size: 0.85rem;
}

.mono {
  font-family: 'JetBrains Mono', 'Fira Code', Consolas, monospace;
  font-size: 0.9rem;
}

.amount-col {
  text-align: right;
  font-weight: 600;
}

.income {
  color: #16a34a;
}

.expense {
  color: #dc2626;
}

.pie-panel__content {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  justify-content: center;
}

.pie-chart {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  position: relative;
  box-shadow: inset 0 0 20px rgba(15, 23, 42, 0.08);
}

.pie-chart__center {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.1);
}

.pie-chart__center p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.85rem;
}

.pie-chart__center strong {
  color: #0f172a;
}

.pie-legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}

.pie-legend li {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.swatch {
  width: 14px;
  height: 14px;
  border-radius: 4px;
}

.legend-label {
  margin: 0;
  font-weight: 600;
}

.legend-value {
  margin: 0;
  color: #94a3b8;
  font-size: 0.85rem;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.preview-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
}

.preview-modal__content {
  position: relative;
  background: #fff;
  border-radius: 24px;
  padding: 1.5rem;
  width: min(1100px, 100%);
  max-height: 90vh;
  overflow: auto;
  box-shadow: 0 25px 60px rgba(15, 23, 42, 0.35);
}

.preview-modal__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.preview-modal__actions {
  display: inline-flex;
  gap: 0.5rem;
}

.preview-sheet {
  margin-top: 1.5rem;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 1.5rem;
  font-size: 0.95rem;
}

.preview-sheet__header {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

.preview-totals {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.preview-totals p {
  margin: 0;
  color: #94a3b8;
  font-size: 0.85rem;
}

.preview-totals strong {
  display: block;
  color: #0f172a;
}

.preview-pie {
  margin: 1.5rem 0;
  display: flex;
  gap: 1.5rem;
  align-items: center;
}

.mini-pie {
  width: 140px;
  height: 140px;
  border-radius: 50%;
  box-shadow: inset 0 0 20px rgba(15, 23, 42, 0.08);
}

.preview-pie ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.preview-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.preview-table th,
.preview-table td {
  padding: 0.65rem 0.75rem;
  border: 1px solid #e2e8f0;
  text-align: left;
}

.preview-table th {
  background: #f1f5f9;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  color: #64748b;
}

.preview-table td:last-child {
  text-align: right;
  font-weight: 600;
}

@media (max-width: 900px) {
  .report__content {
    grid-template-columns: 1fr;
  }

  .table__head,
  .table__row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    text-align: left;
  }

  .amount-col {
    text-align: left;
  }

  .pie-panel__content {
    flex-direction: column;
  }
}

@media (max-width: 640px) {
  :host {
    padding: 1.5rem 1rem 2rem;
  }

  .report__actions {
    width: 100%;
    justify-content: flex-start;
  }

  .preview-modal {
    padding: 1rem;
  }
}
