:root {
  --bg: #f6f7f8;
  --surface: #ffffff;
  --text: #16191d;
  --muted: #5f6b76;
  --border: #dde2e6;
  --accent: #0f766e;
  --accent-text: #ffffff;
  --warn-bg: #fff4d6;
  --warn-text: #7a5300;
  --danger: #b42318;
  --rec: #d92d20;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111416;
    --surface: #1b1f22;
    --text: #e8ecef;
    --muted: #9aa5ae;
    --border: #2d3439;
    --accent: #2dd4bf;
    --accent-text: #062b27;
    --warn-bg: #3a2e10;
    --warn-text: #f5d58a;
    --danger: #f97066;
    --rec: #f04438;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  padding-bottom: env(safe-area-inset-bottom);
}
main { max-width: 640px; margin: 0 auto; padding: 0 16px 32px; }

.topbar {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; gap: 8px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--surface); border-bottom: 1px solid var(--border);
}
.topbar h1 { font-size: 20px; margin: 0; flex: 1; color: var(--accent); }

.banner { background: var(--warn-bg); color: var(--warn-text); padding: 10px 16px; font-size: 14px; }

button, .file-btn { font: inherit; cursor: pointer; border-radius: 10px; border: 1px solid transparent; }
.primary { background: var(--accent); color: var(--accent-text); padding: 10px 16px; font-weight: 600; }
.secondary { background: var(--surface); color: var(--text); border-color: var(--border); padding: 10px 14px; }
.secondary.small { padding: 6px 10px; font-size: 14px; }
.danger { background: transparent; color: var(--danger); border-color: var(--danger); padding: 10px 14px; }
.link { background: none; color: var(--muted); padding: 10px 8px; }
.icon-btn { background: none; font-size: 20px; padding: 4px; }
.chip { background: var(--bg); color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 4px 10px; font-size: 13px; }
.chip.pending { color: var(--warn-text); background: var(--warn-bg); }

.capture { text-align: center; padding: 24px 0 8px; }
.record {
  width: 180px; height: 180px; border-radius: 50%;
  background: var(--accent); color: var(--accent-text);
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  font-weight: 600; box-shadow: 0 6px 20px rgb(0 0 0 / 0.18);
  -webkit-tap-highlight-color: transparent;
}
.record-icon { font-size: 48px; line-height: 1; }
.record.recording { background: var(--rec); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.04); } }
.hint { color: var(--muted); font-size: 14px; margin: 12px 0; }
.capture-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.file-btn.attached { border-color: var(--accent); color: var(--accent); }
.text-form { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }

textarea, input, select {
  font: inherit; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; width: 100%;
}

.list-section { margin-top: 16px; }
.list-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.tabs { display: flex; gap: 4px; }
.tab { background: none; color: var(--muted); padding: 6px 10px; }
.tab.active { background: var(--surface); color: var(--text); border-color: var(--border); font-weight: 600; }

.cards { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; cursor: pointer;
}
.card.review { border-left: 4px solid var(--warn-text); }
.card.queued { cursor: default; opacity: 0.85; border-style: dashed; }
.card .title { font-weight: 600; overflow-wrap: anywhere; }
.card .amount { font-weight: 700; text-align: right; white-space: nowrap; }
.card .meta { color: var(--muted); font-size: 13px; grid-column: 1 / -1; overflow-wrap: anywhere; }
.card .badges { grid-column: 1 / -1; display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.badge { font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); border: 1px solid var(--border); }
.badge.warn { background: var(--warn-bg); color: var(--warn-text); border-color: transparent; }
.badge.ok { color: var(--accent); }

dialog {
  width: min(560px, calc(100vw - 16px)); max-height: calc(100dvh - 32px);
  border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  background: var(--surface); color: var(--text);
}
dialog::backdrop { background: rgb(0 0 0 / 0.45); }
dialog h2 { margin: 0 0 12px; font-size: 18px; }
dialog label { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
dialog label.check { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 15px; }
dialog label.check input { width: auto; }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.grid .span2 { grid-column: 1 / -1; }
.issues { margin: 0 0 12px; padding: 8px 12px 8px 28px; background: var(--warn-bg); color: var(--warn-text); border-radius: 8px; font-size: 14px; }
.issues:empty { display: none; }
.dialog-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.receipt-dialog img { max-width: 100%; display: block; margin-bottom: 8px; border-radius: 8px; }
