*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green:      #1a472a;
  --green-mid:  #2d6a4f;
  --green-pale: #e8f5e9;
  --text:       #111827;
  --muted:      #6b7280;
  --border:     #e5e7eb;
  --bg:         #f9fafb;
  --white:      #ffffff;
  --red:        #dc2626;
  --red-pale:   #fee2e2;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
}

/* ── Header ── */
.header {
  background: var(--green);
  color: var(--white);
  padding-top: env(safe-area-inset-top, 0);
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 1px 4px rgba(0,0,0,.25);
}

.header-inner {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
}

.app-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -.3px;
}

.header-total {
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── Input ── */
.input-section {
  background: var(--white);
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 20;
}

.input-row {
  display: flex;
  gap: 8px;
}

.input-wrap {
  flex: 1;
  position: relative;
}

#expense-input {
  width: 100%;
  height: 48px;
  padding: 0 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 16px;
  color: var(--text);
  background: var(--bg);
  outline: none;
  transition: border-color .15s;
}

#expense-input:focus {
  border-color: var(--green-mid);
}

#expense-input::placeholder { color: #9ca3af; }

#add-btn {
  height: 48px;
  padding: 0 20px;
  background: var(--green);
  color: var(--white);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
  white-space: nowrap;
}

#add-btn:active, #add-btn:disabled { background: var(--green-mid); }

.input-error {
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--red-pale);
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: var(--red);
  font-size: 14px;
}

/* ── Autocomplete ── */
.autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
  overflow: hidden;
  z-index: 100;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 14px;
  font-size: 15px;
  cursor: pointer;
  transition: background .1s;
}

.autocomplete-item:not(:last-child) {
  border-bottom: 1px solid var(--border);
}

.autocomplete-item:active,
.autocomplete-item:hover {
  background: var(--bg);
}

.autocomplete-at {
  font-weight: 700;
  color: var(--green);
}

/* ── Tabs ── */
.tabs {
  display: flex;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.tab {
  flex: 1;
  padding: 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  font-size: 15px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s, border-color .15s;
}

.tab.active {
  color: var(--green);
  border-bottom-color: var(--green);
}

/* ── Panels ── */
.panel { display: none; }
.panel.active { display: block; }

/* ── Date filter ── */
.filter-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
}

.filter {
  flex: 1;
  padding: 7px 0;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s;
}

.filter.active {
  background: var(--green-pale);
  border-color: var(--green-mid);
  color: var(--green);
}

/* ── Category filter bar ── */
.category-bar {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.category-bar::-webkit-scrollbar { display: none; }

.cat-pill {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 5px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: var(--bg);
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all .15s;
  flex-shrink: 0;
}

.cat-pill.active {
  color: var(--white);
  border-color: transparent;
}

.cat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

/* ── Expense list ── */
#expense-list {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.expense-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--white);
  border-radius: 12px;
  padding: 14px 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
  gap: 12px;
}

.expense-left {
  flex: 1;
  min-width: 0;
}

.expense-desc-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.expense-desc {
  font-size: 15px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-transform: capitalize;
}

.cat-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  flex-shrink: 0;
}

.expense-date {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-top: 3px;
}

.expense-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.expense-amount {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.delete-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--red-pale);
  border: none;
  color: var(--red);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s;
}

.delete-btn:active { background: #fecaca; }

.empty-state {
  text-align: center;
  padding: 56px 20px;
  color: var(--muted);
}

.empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  display: block;
  opacity: .4;
}

.empty-state p { font-size: 15px; line-height: 1.5; }

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
  border-radius: 12px;
  height: 64px;
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── List footer (bottom sum) ── */
.list-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 4px 14px 20px;
  padding: 14px 18px;
  background: var(--white);
  border-radius: 12px;
  border: 1.5px solid var(--border);
}

.list-footer-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.list-footer-amount {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

/* ── Report ── */
#report-content {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.report-card {
  background: var(--white);
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.report-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .6px;
  margin-bottom: 6px;
}

.report-amount {
  font-size: 32px;
  font-weight: 700;
  color: var(--green);
  font-variant-numeric: tabular-nums;
}

.report-card--alltime .report-amount { font-size: 40px; }

.report-count {
  font-size: 13px;
  color: var(--muted);
  margin-top: 4px;
}

.report-breakdown {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.report-breakdown-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 14px;
}

.report-breakdown-cat {
  display: flex;
  align-items: center;
  gap: 7px;
}

.report-breakdown-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
