:root {
  --bg: #f4f6fa;
  --card: #ffffff;
  --text: #1a2233;
  --muted: #6b7280;
  --border: #e5e7eb;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 16px 48px;
}

.app-header {
  text-align: center;
  margin-bottom: 24px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card {
  background: var(--card);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow);
}

.card-title {
  margin: 0 0 16px;
  font-size: 1.1rem;
}

.field {
  display: flex;
  flex-direction: column;
  margin-bottom: 14px;
  flex: 1;
}

.field label {
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.field input,
.field select {
  padding: 10px 12px;
  font-size: 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  width: 100%;
  font-family: inherit;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.field input[aria-invalid="true"],
.field select[aria-invalid="true"] {
  border-color: var(--danger);
}

.error {
  margin: 6px 0 0;
  color: var(--danger);
  font-size: 0.85rem;
}

.row {
  display: flex;
  gap: 12px;
}

@media (max-width: 480px) {
  .row { flex-direction: column; gap: 0; }
}

.btn-primary {
  width: 100%;
  padding: 12px 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover { background: var(--primary-hover); }
.btn-primary:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  gap: 12px;
  flex-wrap: wrap;
}

.list-header .card-title { margin: 0; }

.total {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.total-label {
  color: var(--muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.total-amount {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.empty-state {
  text-align: center;
  color: var(--muted);
  padding: 24px 8px;
  margin: 0;
  border: 1px dashed var(--border);
  border-radius: 8px;
  background: #fafbfd;
}

.expense-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.expense-item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 12px;
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

.expense-item:last-child { border-bottom: none; }

.expense-main {
  min-width: 0;
}

.expense-description {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.expense-category {
  display: inline-block;
  margin-top: 4px;
  font-size: 0.75rem;
  color: var(--muted);
  background: #eef2ff;
  color: #4338ca;
  padding: 2px 8px;
  border-radius: 999px;
}

.expense-amount {
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.btn-delete {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  font-size: 0.85rem;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-delete:hover {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
}

.btn-delete:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.25);
}

@media (max-width: 480px) {
  .container { padding: 16px 12px 40px; }
  .card { padding: 16px; }
  .app-header h1 { font-size: 1.5rem; }
  .expense-item {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "main amount"
      "main delete";
    row-gap: 4px;
  }
  .expense-main { grid-area: main; }
  .expense-amount { grid-area: amount; text-align: right; }
  .btn-delete { grid-area: delete; justify-self: end; }
}
