:root {
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --bg: #f4f6f8;
  --card: #ffffff;
  --text: #1a222c;
  --muted: #6b7684;
  --border: #dde3ea;
  --danger: #b3261e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12161b;
    --card: #1c232b;
    --text: #e8edf2;
    --muted: #94a1b0;
    --border: #313c48;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.8rem; }
code { font-size: 0.85em; word-break: break-all; }

.screen {
  max-width: 520px;
  margin: 0 auto;
  padding: 20px 16px calc(84px + env(safe-area-inset-bottom));
}
#screen-setup, #screen-signin { padding-bottom: 40px; }

.hero { text-align: center; padding: 36px 8px 20px; }
.hero-icon { font-size: 56px; }
.hero h1 { margin: 8px 0 6px; font-size: 1.6rem; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 34ch; }

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  margin: 14px 0;
}
.card h2 { margin: 0 0 6px; font-size: 1.05rem; }

.page-title { font-size: 1.35rem; margin: 8px 0 14px; }

label { display: block; font-weight: 600; font-size: 0.9rem; margin: 14px 0 6px; }
input[type="text"], input[type="number"], input[type="date"], select {
  width: 100%;
  padding: 12px 14px;
  font-size: 1rem;
  color: var(--text);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  appearance: none;
}
input:focus, select:focus { outline: 2px solid var(--brand); border-color: transparent; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 12px 16px;
  margin-top: 12px;
  font-size: 1rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
}
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:active { background: var(--brand-dark); }
.btn.big { padding: 15px 16px; font-size: 1.05rem; }
.btn.ghost { background: transparent; }
.btn.link { background: none; border: none; color: var(--brand); font-weight: 500; }
.btn.tiny { width: auto; padding: 6px 12px; margin: 0; font-size: 0.8rem; }
.btn:disabled { opacity: 0.55; cursor: default; }

.file-btn { margin-top: 0; }
.receipt-row { display: flex; flex-direction: column; gap: 10px; }
.ocr-status {
  font-size: 0.85rem;
  color: var(--muted);
  background: var(--card);
  border: 1px dashed var(--border);
  border-radius: 10px;
  padding: 8px 12px;
}
.ocr-status.busy { color: var(--brand); }
.receipt-preview {
  max-width: 160px;
  max-height: 160px;
  border-radius: 10px;
  border: 1px solid var(--border);
  object-fit: cover;
}

.demo-banner, .pending-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 0.85rem;
  padding: 9px 14px;
  border-radius: 10px;
  margin-bottom: 10px;
}
.demo-banner { background: #fef3c7; color: #713f12; }
.pending-banner { background: #dbeafe; color: #1e3a8a; }
@media (prefers-color-scheme: dark) {
  .demo-banner { background: #4a3a10; color: #fde68a; }
  .pending-banner { background: #1e3a5f; color: #bfdbfe; }
}

.summary-row { display: flex; gap: 10px; margin-bottom: 14px; }
.summary-card {
  flex: 1;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
}
.summary-label { font-size: 0.78rem; color: var(--muted); }
.summary-value { font-size: 1.3rem; font-weight: 700; margin-top: 2px; }

.history-list { display: flex; flex-direction: column; gap: 8px; }
.claim-item {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex;
  justify-content: space-between;
  gap: 10px;
}
.claim-main { min-width: 0; }
.claim-cat { font-weight: 600; }
.claim-desc { color: var(--muted); font-size: 0.85rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.claim-date { color: var(--muted); font-size: 0.78rem; }
.claim-side { text-align: right; flex-shrink: 0; }
.claim-amount { font-weight: 700; }
.claim-receipt { font-size: 0.8rem; color: var(--brand); text-decoration: none; }

.category-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.category-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 14px;
}
.cat-del { background: none; border: none; color: var(--danger); font-size: 1rem; cursor: pointer; padding: 4px 8px; }
.add-cat-row { display: flex; gap: 8px; align-items: stretch; }
.add-cat-row input { flex: 1; }
.add-cat-row .btn { width: auto; margin-top: 0; }

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  background: var(--card);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px 10px;
  background: none;
  border: none;
  font-size: 0.72rem;
  color: var(--muted);
  cursor: pointer;
}
.nav-btn span { font-size: 1.25rem; }
.nav-btn.active { color: var(--brand); font-weight: 700; }

.toast {
  position: fixed;
  top: 14px; left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  max-width: 90vw;
  background: #1a222c;
  color: #fff;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
}
.toast.error { background: var(--danger); }
