:root {
  --ink: oklch(24% 0.035 255);
  --ink-soft: oklch(45% 0.025 255);
  --ink-faint: oklch(50% 0.022 255);
  --bg: oklch(98% 0.006 85);
  --border: oklch(90% 0.012 255);
  --card-bg: oklch(95.5% 0.012 255);
  --surface: oklch(100% 0 0);

  --primary: oklch(56% 0.15 255);
  --primary-hover: oklch(45% 0.15 258);
  --primary-tint: oklch(93% 0.035 255);

  --debit: oklch(55% 0.16 25);
  --credit: oklch(50% 0.14 155);
  --alert-bg: oklch(96% 0.03 25);
  --alert-text: oklch(40% 0.15 25);

  --radius: 14px;
  --font-body: "Work Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-heading: "Newsreader", Georgia, serif;
  --font-mono: "JetBrains Mono", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

/* ---------- Nav ---------- */

.nav {
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.nav__inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 18px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.nav__brand {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--font-heading);
  font-weight: 600;
  font-size: 19px;
  letter-spacing: -0.01em;
  color: var(--ink);
  text-decoration: none;
}

.nav__links a {
  color: var(--ink-soft);
  text-decoration: none;
  font-weight: 500;
  font-size: 14.5px;
}

.nav__links a:hover {
  color: var(--primary);
}

/* ---------- Page / hero ---------- */

.page {
  max-width: 900px;
  margin: 0 auto;
  padding: 64px 28px 40px;
}

.stage {
  text-align: center;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 44px;
  font-weight: 500;
  line-height: 1.12;
  letter-spacing: -0.01em;
  margin: 0 0 18px;
}

.hero-subtitle {
  font-size: 17px;
  color: var(--ink-soft);
  max-width: 620px;
  margin: 0 auto 40px;
  line-height: 1.6;
}

/* ---------- Dropzone card ---------- */

.dropzone {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 32px;
  transition: background 0.15s ease, box-shadow 0.15s ease;
}

.dropzone.is-active {
  background: var(--primary-tint);
  box-shadow: inset 0 0 0 2px var(--primary);
}

.dz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.dz-hint {
  margin: 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.btn-cta {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 17px;
  color: #fff;
  background: var(--primary);
  border: none;
  border-radius: 8px;
  padding: 18px 36px;
  cursor: pointer;
  transition: background 0.12s ease, transform 0.08s ease;
}

.btn-cta:hover {
  background: var(--primary-hover);
}

.btn-cta:active {
  transform: scale(0.99);
}

.file-list {
  list-style: none;
  margin: 0 0 20px;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.file-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 13px;
}

.file-chip__name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-chip__size {
  color: var(--ink-soft);
}

.file-chip__remove {
  background: none;
  border: none;
  color: var(--debit);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
}

.dz-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 8px;
}

/* ---------- Buttons (shared) ---------- */

.btn {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 14px;
  padding: 11px 22px;
  border-radius: 8px;
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: background 0.12s ease, opacity 0.15s ease, border-color 0.12s ease;
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--primary);
  color: #fff;
}

.btn--primary:not(:disabled):hover {
  background: var(--primary-hover);
}

.btn--ghost {
  background: transparent;
  border-color: var(--border);
  color: var(--ink);
}

.btn--ghost:hover {
  border-color: var(--ink-faint);
}

/* ---------- How it works ---------- */

.how-it-works {
  margin-top: 72px;
  text-align: left;
}

.how-it-works h2 {
  font-family: var(--font-heading);
  font-weight: 500;
  text-align: center;
  font-size: 28px;
  margin-bottom: 32px;
}

.how-it-works__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 28px;
}

.step-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary-tint);
  color: var(--primary-hover);
  font-weight: 700;
  font-size: 13px;
  margin-bottom: 10px;
}

.how-it-works h3 {
  font-family: var(--font-heading);
  font-weight: 500;
  margin: 0 0 6px;
  font-size: 18px;
}

.how-it-works p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.55;
}

/* ---------- Loading ---------- */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
}

.panel--center {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 80px 40px;
}

.spinner {
  width: 30px;
  height: 30px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-text {
  color: var(--ink-soft);
  font-size: 14px;
}

/* ---------- Alerts ---------- */

.alert {
  margin: 18px 0 0;
  padding: 12px 16px;
  background: var(--alert-bg);
  color: var(--alert-text);
  border-radius: 8px;
  font-size: 13.5px;
  text-align: left;
}

/* ---------- Review stage ---------- */

#stage-review {
  text-align: left;
  max-width: 1100px;
}

.review__toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 24px;
}

.review__summary {
  font-family: var(--font-mono);
  font-size: 13.5px;
  color: var(--ink-soft);
  margin: 0;
}

.review__toolbar-actions {
  display: flex;
  gap: 10px;
}

.ledger-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin-bottom: 32px;
}

/* ---------- Statement card ---------- */

.ledger-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-top: 3px solid var(--primary);
  border-radius: var(--radius);
  padding: 20px;
}

.ledger-card__header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 14px;
}

.ledger-card__bank {
  margin: 0;
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--primary-hover);
}

.ledger-card__holder {
  margin: 2px 0 0;
  font-family: var(--font-heading);
  font-size: 19px;
  font-weight: 500;
  line-height: 1.3;
}

.ledger-card__stamp {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  background: var(--primary-tint);
  color: var(--primary-hover);
  padding: 3px 10px;
  border-radius: 999px;
  white-space: nowrap;
}

.ledger-card__meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 14px;
  margin: 0 0 16px;
  padding: 14px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.ledger-card__meta dt {
  margin: 0 0 2px;
  font-size: 11px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.ledger-card__meta dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ledger-card__totals {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ledger-card__total-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-mono);
  font-size: 13.5px;
}

.ledger-card__total-label {
  width: 46px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.ledger-card__total-label--debit { color: var(--debit); }
.ledger-card__total-label--credit { color: var(--credit); }

.ledger-card__total-value {
  font-weight: 600;
}

.ledger-card__diff {
  margin-left: auto;
  font-size: 11px;
  color: var(--ink-soft);
}

.ledger-card__diff.is-off {
  color: var(--debit);
  font-weight: 600;
}

.ledger-card__warning {
  margin: 12px 0 0;
  font-size: 12px;
  color: #b45309;
}

/* ---------- Transaction table ---------- */

.txn-table-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}

.txn-table-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.txn-table-controls select,
.txn-table-controls input {
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--ink);
}

.txn-table-controls input {
  flex: 1;
  min-width: 200px;
}

.txn-table-scroll {
  overflow-x: auto;
  max-height: 560px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.txn-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.txn-table thead th {
  position: sticky;
  top: 0;
  background: var(--ink);
  color: #fff;
  text-align: left;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 1;
}

.txn-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.txn-table tbody tr:hover {
  background: var(--primary-tint);
}

.txn-table .num {
  text-align: right;
  white-space: nowrap;
  font-family: var(--font-mono);
}

.txn-table .debit { color: var(--debit); }
.txn-table .credit { color: var(--credit); }

.narration-cell {
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-cell {
  font-size: 11.5px;
  color: var(--ink-soft);
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.empty-row {
  text-align: center;
  color: var(--ink-soft);
  padding: 32px;
}

.txn-table-pager {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-top: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.txn-table-pager button {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: 12.5px;
}

.txn-table-pager button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.nav__links {
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav__user {
  font-size: 13.5px;
  color: var(--ink-soft);
  font-weight: 500;
}

.nav__logout {
  background: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
}

.nav__logout:hover {
  border-color: var(--ink-faint);
}

/* ---------- Auth pages (login / register) ---------- */

.auth-page {
  display: flex;
  justify-content: center;
  padding-top: 72px;
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 32px;
  text-align: left;
}

.auth-title {
  font-family: var(--font-heading);
  margin: 0 0 6px;
  font-size: 26px;
  font-weight: 500;
}

.auth-subtitle {
  margin: 0 0 28px;
  font-size: 14px;
  color: var(--ink-soft);
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-form label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--ink);
}

.auth-form .optional {
  font-weight: 400;
  color: var(--ink-soft);
}

.auth-form input {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 400;
  padding: 11px 13px;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--ink);
  background: var(--surface);
}

.auth-form input:focus {
  outline: 2px solid var(--primary-tint);
  border-color: var(--primary);
}

.auth-checkbox {
  flex-direction: row !important;
  align-items: center;
  gap: 8px !important;
  font-weight: 400 !important;
  cursor: pointer;
}

.auth-checkbox input {
  width: auto;
}

.field-hint {
  margin: -10px 0 0;
  font-size: 12px;
  color: var(--ink-soft);
}

.btn--block {
  width: 100%;
  padding: 13px 0;
  font-size: 15px;
}

.auth-switch {
  margin: 22px 0 0;
  text-align: center;
  font-size: 13.5px;
  color: var(--ink-soft);
}

.auth-switch a {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
}

.auth-switch a:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* ---------- Activity page ---------- */

.activity-page {
  max-width: 1100px;
  text-align: left;
}

.activity-title {
  font-family: var(--font-heading);
  font-size: 30px;
  font-weight: 500;
  margin: 0 0 6px;
}

.activity-subtitle {
  margin: 0 0 28px;
  color: var(--ink-soft);
  font-size: 14.5px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.stat-card__value {
  margin: 0 0 4px;
  font-family: var(--font-heading);
  font-size: 32px;
  font-weight: 500;
  color: var(--primary-hover);
}

.stat-card__label {
  margin: 0;
  font-size: 12.5px;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* ---------- Admin page ---------- */

.mono {
  font-family: var(--font-mono);
}

.admin-section {
  margin-bottom: 32px;
}

.admin-section__title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 500;
  margin: 0 0 14px;
}

/* ---------- Footer ---------- */

.foot-note {
  text-align: center;
  padding: 24px 0 40px;
  font-size: 12px;
  color: var(--ink-faint);
}

@media (max-width: 640px) {
  .hero-title {
    font-size: 32px;
  }
  .dropzone {
    padding: 36px 20px;
  }
}
