@media (max-width: 480px) {
  .add-label {
    display: none;
  }
  #addBtn.btn-sm {
    padding: 0 10px;
  }
}

main {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px 28px 64px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ---------- Summary cards ---------- */
.summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
}

.summary-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px 20px;
}

.summary-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.summary-icon .icon {
  width: 20px;
  height: 20px;
}

.summary-icon-primary {
  background: var(--primary-soft);
  color: var(--primary);
}
.summary-icon-success {
  background: var(--success-soft);
  color: var(--success);
}
.summary-icon-warning {
  background: var(--warning-soft);
  color: var(--warning);
}

.summary-card .label {
  display: block;
  color: var(--text-muted);
  font-size: 12.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.summary-card .value {
  display: block;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin-top: 2px;
}

/* ---------- Charts grid ---------- */
.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.donut-wrap {
  display: flex;
  align-items: center;
  gap: 22px;
  flex-wrap: wrap;
}

.donut-wrap canvas {
  flex-shrink: 0;
}

.legend {
  flex: 1;
  min-width: 160px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-label {
  flex: 1;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend-pct {
  color: var(--text-faint);
  font-size: 12px;
  width: 32px;
}

.legend-value {
  color: var(--text-muted);
  font-weight: 600;
  width: 84px;
  text-align: right;
}

.inline-empty {
  color: var(--text-muted);
  font-size: 13px;
}

.bar-chart-wrap {
  width: 100%;
}

.bar-chart-wrap canvas {
  width: 100%;
  display: block;
}

.chart-tooltip {
  position: fixed;
  z-index: 60;
  background: var(--text);
  color: var(--bg);
  padding: 8px 11px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.1s var(--ease), transform 0.1s var(--ease);
  box-shadow: var(--shadow-md);
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

.chart-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}

.chart-tooltip strong {
  font-size: 12.5px;
}

.chart-tooltip span {
  opacity: 0.85;
  font-size: 11.5px;
}

/* ---------- Section head ---------- */
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.no-margin {
  margin-bottom: 0 !important;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Filters ---------- */
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 18px;
}

.filter-search {
  flex: 1;
  min-width: 200px;
}

.filters select,
.filters input[type='date'] {
  min-width: 0;
}

/* ---------- Table ---------- */
.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

thead th {
  text-align: left;
  color: var(--text-faint);
  font-weight: 700;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

th.sortable {
  cursor: pointer;
  user-select: none;
  transition: color 0.15s var(--ease);
}

th.sortable:hover {
  color: var(--text-muted);
}

th.sortable.active-sort {
  color: var(--primary);
}

.sort-arrow {
  display: inline-block;
  width: 10px;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tbody tr {
  transition: background 0.1s var(--ease);
}

tbody tr:hover {
  background: var(--bg-subtle);
}

.nowrap {
  white-space: nowrap;
}

.note-cell {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

td.right,
th.right {
  text-align: right;
}

.amount {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.muted {
  color: var(--text-faint);
}

.actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}

.icon-btn {
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease), border-color 0.15s var(--ease);
}

.icon-btn .icon {
  width: 15px;
  height: 15px;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.icon-btn.danger:hover {
  background: var(--danger-soft);
  color: var(--danger);
  border-color: transparent;
}

.skel-row td {
  padding: 14px 12px;
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10, 11, 20, 0.5);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
  animation: fade-in 0.15s var(--ease);
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s var(--ease);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 18px;
}

.modal-head h2 {
  margin: 0;
}

.modal-close {
  width: 32px;
  height: 32px;
}

#expenseForm {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 6px;
}

.modal-actions-center {
  justify-content: center;
}

.modal-box-sm {
  max-width: 360px;
  text-align: center;
}

.confirm-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--danger-soft);
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.confirm-icon .icon {
  width: 22px;
  height: 22px;
}

.confirm-message {
  color: var(--text-muted);
  font-size: 13.5px;
  margin: 8px 0 4px;
}

.btn-danger-solid {
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0 16px;
  height: 38px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s var(--ease);
}

.btn-danger-solid:hover {
  background: var(--danger-hover);
}
