:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --surface2: #334155;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --accent: #7c3aed;
  --accent-hover: #8b5cf6;
  --danger: #ef4444;
  --radius: 12px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 16px calc(24px + var(--safe-bottom));
  line-height: 1.4;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-top: 8px;
}

header h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.badge {
  font-size: 0.7rem;
  color: var(--accent);
  background: rgba(124, 58, 237, 0.18);
  padding: 4px 8px;
  border-radius: 999px;
  font-weight: 600;
}

.card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 16px;
}

label {
  display: block;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 6px;
  font-weight: 500;
}

.field { margin-bottom: 12px; }

input[type="text"],
input[type="number"],
input[type="date"],
textarea,
select {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--surface2);
  color: var(--text);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
  -webkit-appearance: none;
  appearance: none;
}

textarea { resize: vertical; min-height: 56px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2394a3b8' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--accent);
}

.photo-zone {
  border: 2px dashed var(--surface2);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  background: var(--bg);
  position: relative;
  overflow: hidden;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 8px;
}

.photo-zone.has-photo { border-style: solid; border-color: var(--accent); padding: 0; }

.photo-zone img {
  width: 100%;
  max-height: 220px;
  object-fit: cover;
  display: block;
  border-radius: 10px;
}

.photo-zone .placeholder { color: var(--muted); font-size: 0.9rem; }

.photo-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

button {
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  border: none;
  border-radius: 10px;
  padding: 12px 16px;
  cursor: pointer;
  -webkit-appearance: none;
}

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  margin-top: 4px;
}

.btn-primary:active { background: var(--accent-hover); }
.btn-primary:disabled { opacity: 0.5; }

.filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
}

.chip {
  flex-shrink: 0;
  background: var(--surface);
  color: var(--muted);
  border: 1px solid var(--surface2);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 0.8rem;
  font-weight: 600;
}

.chip.active {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

section h2 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin: 8px 0 10px;
  font-weight: 600;
}

.receipt-list { list-style: none; }

.receipt {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.receipt-thumb {
  width: 64px;
  height: 64px;
  border-radius: 8px;
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}

.receipt-body { flex: 1; min-width: 0; }

.receipt-amount {
  font-weight: 700;
  font-size: 1.05rem;
}

.receipt-cat {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 600;
  color: var(--accent);
  background: rgba(124, 58, 237, 0.18);
  padding: 2px 8px;
  border-radius: 999px;
  margin-top: 4px;
}

.receipt-meta {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 4px;
}

.receipt-note {
  font-size: 0.85rem;
  margin-top: 4px;
  color: var(--text);
  word-break: break-word;
}

.receipt-del {
  background: transparent;
  color: var(--danger);
  padding: 8px;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.empty {
  text-align: center;
  color: var(--muted);
  padding: 32px 16px;
  font-size: 0.9rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + var(--safe-bottom));
  transform: translateX(-50%) translateY(120%);
  background: var(--surface2);
  color: var(--text);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 500;
  transition: transform 0.25s ease;
  z-index: 100;
  pointer-events: none;
}

.toast.show { transform: translateX(-50%) translateY(0); }

.modal {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.85);
  z-index: 50;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.modal.open { display: flex; }

.modal img {
  max-width: 100%;
  max-height: 90vh;
  border-radius: 8px;
}
