:root {
  --dark: #062f49;
  --dark-2: #0a3a58;
  --accent: #049bee;
  --accent-ink: #ffffff;
  --white: #ffffff;
  --muted: rgba(255, 255, 255, 0.62);
  --line: rgba(255, 255, 255, 0.14);
  --good: #34d399;
  --warn: #fbbf24;
  --bad: #f87171;
  --radius: 16px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Inter", system-ui, -apple-system, sans-serif;
  background: var(--dark);
  color: var(--white);
  min-height: 100vh;
}

.serif { font-family: "Instrument Serif", Georgia, serif; font-weight: 400; }
.muted { color: var(--muted); }
.error { color: var(--bad); font-size: 0.9rem; }

.view { min-height: 100vh; }
[hidden] { display: none !important; }

/* ---------- Login ---------- */
#login-view {
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-card {
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--dark-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 40px 32px;
  text-align: center;
}
.login-card h1 { font-size: 2.6rem; margin: 0; }
.login-card p { margin: 0; }

input, select {
  width: 100%;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--white);
  padding: 12px 14px;
  font-size: 1rem;
  font-family: inherit;
}
input:focus, select:focus { outline: 2px solid var(--accent); border-color: transparent; }
select option { color: #000; }

.cta {
  background: var(--accent);
  color: var(--accent-ink);
  border: none;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}
.cta:hover { filter: brightness(1.08); }
.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--white);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
}
.ghost:hover { background: rgba(255, 255, 255, 0.06); }

/* ---------- Review layout ---------- */
#app-view { display: flex; flex-direction: column; }
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
}
.brand { font-size: 1.5rem; }
.progress { flex: 1; display: flex; align-items: center; gap: 12px; }
.progress-track {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  max-width: 460px;
}
.progress-fill { height: 100%; width: 0%; background: var(--accent); transition: width 0.3s ease; }

.stage {
  flex: 1;
  display: grid;
  place-items: center;
  padding: 40px 20px;
  position: relative;
}

/* ---------- Card ---------- */
.card {
  width: min(640px, 94vw);
  background: var(--dark-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}
.flow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  font-size: 1.4rem;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.flow .acct { font-weight: 600; }
.flow .arrow { color: var(--accent); font-size: 1.6rem; }

.amount { text-align: center; font-size: 2.6rem; margin: 4px 0 2px; }
.amount.pos { color: var(--good); }
.amount.neg { color: var(--white); }
.txn-date { text-align: center; margin-bottom: 22px; }

.feedline {
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px 18px;
  margin-bottom: 20px;
  font-size: 0.95rem;
  line-height: 1.55;
}
.feedline .k { color: var(--muted); display: inline-block; width: 92px; }

.proposal { font-size: 1.05rem; line-height: 1.5; margin-bottom: 18px; }
.proposal.proposal-none { color: var(--muted); font-style: italic; }
.pair-note { color: var(--muted); font-size: 0.85rem; font-weight: 400; }

/* ---------- Inline categorization form ---------- */
.cat-form {
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 18px;
}
.cat-form label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.f-section { display: flex; flex-direction: column; gap: 10px; }
.f-hint { margin: 0; font-size: 0.82rem; color: var(--muted); }
.cand {
  flex-direction: row !important;
  align-items: center;
  gap: 10px !important;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--white) !important;
}
.cand:has(input:checked) { border-color: var(--accent); background: rgba(4, 155, 238, 0.12); }
.cand input { width: auto; }

/* ---------- Approved view ---------- */
.approved { width: min(760px, 94vw); align-self: start; }
.approved-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.approved-head h2 { font-size: 2rem; margin: 0; }
.approved-sub { margin: 6px 0 20px; }
.arow {
  display: flex; justify-content: space-between; align-items: center; gap: 14px;
  background: var(--dark-2); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px 18px; margin-bottom: 10px;
}
.arow-partner { opacity: 0.55; }
.arow-line1 { display: flex; gap: 12px; align-items: baseline; font-size: 0.95rem; }
.arow-amt { font-weight: 700; min-width: 90px; }
.arow-amt.pos { color: var(--good); }
.arow-acct { font-weight: 600; }
.arow-line2 { font-size: 0.85rem; color: rgba(255,255,255,0.8); margin-top: 4px; }
.arow-side { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.chip { font-size: 0.72rem; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; }
.chip-ready { background: rgba(4, 155, 238, 0.18); color: var(--accent); }
.chip-wait { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.chip-ok { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.chip-bad { background: rgba(248, 113, 113, 0.16); color: var(--bad); }
.chip-pair { background: rgba(255, 255, 255, 0.08); color: var(--muted); }

/* ---------- Grouped review list ---------- */
.list-actions { display: flex; gap: 10px; }
.selall { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
.selall input, .list-check { width: auto; accent-color: var(--accent); }
.lrow { cursor: pointer; }
.lrow:has(.list-check:checked) { border-color: var(--accent); background: rgba(4, 155, 238, 0.08); }
.lrow-manual { opacity: 0.55; }
.lrow .list-check { flex-shrink: 0; width: 18px; height: 18px; }

.meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 26px; }
.pill {
  font-size: 0.8rem;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
}
.pill.conf-hi { background: rgba(52, 211, 153, 0.16); color: var(--good); }
.pill.conf-mid { background: rgba(251, 191, 36, 0.16); color: var(--warn); }
.pill.conf-lo { background: rgba(248, 113, 113, 0.16); color: var(--bad); }
.badge {
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 700;
}
.badge.code { background: rgba(4, 155, 238, 0.18); color: var(--accent); }
.badge.ai { background: rgba(167, 139, 250, 0.2); color: #c4b5fd; }
.rationale { color: var(--muted); font-size: 0.88rem; margin-left: auto; flex-basis: 100%; }

.actions { display: flex; gap: 12px; }
.actions .cta { flex: 2; }
.actions .ghost { flex: 1; }

/* ---------- Empty / toast ---------- */
.empty { text-align: center; }
.empty h2 { font-size: 2.4rem; margin: 0 0 6px; }
.toast {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--dark-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 18px;
  font-size: 0.9rem;
}
.toast.bad { border-color: var(--bad); color: var(--bad); }

.keyhints {
  display: flex;
  justify-content: center;
  gap: 22px;
  padding: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 0.82rem;
}
kbd {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 5px;
  padding: 2px 7px;
  font-family: inherit;
  font-size: 0.78rem;
}

/* ---------- Stats drawer ---------- */
.drawer {
  position: fixed;
  top: 0; right: 0;
  height: 100vh;
  width: min(360px, 90vw);
  background: var(--dark-2);
  border-left: 1px solid var(--line);
  padding: 20px;
  overflow-y: auto;
  box-shadow: -20px 0 50px rgba(0, 0, 0, 0.4);
}
.drawer-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.drawer-head h3 { font-size: 1.6rem; margin: 0; }
.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 0.9rem;
}
.stat-row .n { color: var(--muted); }

/* ---------- Edit modal ---------- */
.backdrop {
  position: fixed; inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: grid; place-items: center;
  padding: 20px;
}
.modal {
  width: min(460px, 94vw);
  background: var(--dark-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 26px;
  display: flex; flex-direction: column; gap: 14px;
}
.modal h3 { font-size: 1.7rem; margin: 0; }
.modal label { display: flex; flex-direction: column; gap: 6px; font-size: 0.85rem; color: var(--muted); }
.candidates { display: flex; flex-wrap: wrap; gap: 8px; }
.candidates button {
  background: rgba(4, 155, 238, 0.14);
  border: 1px solid var(--line);
  color: var(--white);
  border-radius: 8px; padding: 6px 10px; font-size: 0.8rem; cursor: pointer;
}
.modal-actions { display: flex; gap: 12px; justify-content: flex-end; }
