/* Don Giovanni — Hacer Las Cuentas */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  --bg: #FAF9F7;
  --bg-elev: #FFFFFF;
  --bg-sunk: #F2F1ED;
  --ink: #0E0E0C;
  --ink-2: #38362F;
  --ink-3: #6E6B62;
  --ink-4: #A6A299;
  --hairline: rgba(14,14,12,0.08);
  --hairline-2: rgba(14,14,12,0.14);
  --good: oklch(0.52 0.09 155);
  --good-bg: oklch(0.96 0.03 155);
  --bad: oklch(0.54 0.16 25);
  --bad-bg: oklch(0.96 0.03 25);
  --warn: oklch(0.7 0.12 80);
  --accent: #0E0E0C;
}

.dark {
  --bg: #0E0E0C;
  --bg-elev: #1A1A17;
  --bg-sunk: #06060A;
  --ink: #FAF9F7;
  --ink-2: #DBD9D2;
  --ink-3: #95918A;
  --ink-4: #5C5953;
  --hairline: rgba(255,255,255,0.08);
  --hairline-2: rgba(255,255,255,0.14);
  --good: oklch(0.72 0.12 155);
  --good-bg: oklch(0.22 0.04 155);
  --bad: oklch(0.72 0.16 25);
  --bad-bg: oklch(0.22 0.05 25);
}

* { box-sizing: border-box; -webkit-font-smoothing: antialiased; }
html, body { margin: 0; padding: 0; background: #E8E6E0; font-family: 'Inter', system-ui, sans-serif; color: var(--ink); }

.app {
  width: 100%; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: 'Inter', system-ui, sans-serif;
  display: flex; flex-direction: column;
  letter-spacing: -0.01em;
}

.num { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.mono { font-family: 'JetBrains Mono', ui-monospace, monospace; font-variant-numeric: tabular-nums; }

/* App chrome */
.appbar {
  padding: 56px 20px 0;
  display: flex; flex-direction: column; gap: 4px;
}
.appbar .eyebrow {
  font-size: 11px; font-weight: 600; letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--ink-3);
}
.appbar h1 {
  margin: 0; font-size: 30px; font-weight: 600; letter-spacing: -0.02em;
  line-height: 1.1;
}
.appbar .date {
  font-size: 14px; color: var(--ink-3); margin-top: 2px;
}

/* Headline numbers (extracto bancario) */
.headline {
  padding: 20px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
  border-bottom: 0.5px solid var(--hairline);
}
.headline .col { display: flex; flex-direction: column; gap: 4px; }
.headline .label {
  font-size: 11px; font-weight: 500; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
}
.headline .amount {
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
}
.headline .sub {
  font-size: 12px; color: var(--ink-3);
}

/* Rider list */
.section-label {
  padding: 24px 20px 8px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3);
  display: flex; justify-content: space-between; align-items: baseline;
}
.section-label .count { font-weight: 500; color: var(--ink-4); letter-spacing: 0.04em; }

.rider-row {
  display: flex; align-items: center; gap: 14px;
  padding: 14px 20px;
  border-top: 0.5px solid var(--hairline);
  background: var(--bg);
  cursor: pointer;
}
.rider-row:last-child { border-bottom: 0.5px solid var(--hairline); }
.rider-row.compact { padding: 10px 20px; }

.avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--bg-sunk);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  flex-shrink: 0;
  border: 0.5px solid var(--hairline);
}

.rider-meta { flex: 1; min-width: 0; }
.rider-name { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.rider-sub { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

.rider-amount {
  text-align: right; font-size: 16px; font-weight: 500;
}
.rider-amount .small { font-size: 11px; color: var(--ink-3); font-weight: 400; }

.status-dot {
  width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0;
  margin-left: 8px;
}
.status-dot.pending { background: var(--ink-4); }
.status-dot.balanced { background: var(--good); }
.status-dot.short { background: var(--bad); }

.status-tag {
  font-size: 10px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 3px 7px; border-radius: 3px;
  margin-top: 4px; display: inline-block;
}
.status-tag.pending { background: var(--bg-sunk); color: var(--ink-3); }
.status-tag.balanced { background: var(--good-bg); color: var(--good); }
.status-tag.short { background: var(--bad-bg); color: var(--bad); }

/* Bottom CTA */
.cta-bar {
  margin-top: auto;
  padding: 12px 20px 36px;
  background: var(--bg);
  border-top: 0.5px solid var(--hairline);
}
.cta {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 12px;
  background: var(--ink);
  color: var(--bg);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
}
.cta:disabled { background: var(--bg-sunk); color: var(--ink-4); }
.cta.secondary { background: transparent; color: var(--ink); border: 0.5px solid var(--hairline-2); }

/* Tab bar inferior */
.tabbar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  border-top: 0.5px solid var(--hairline);
  padding: 8px 8px 28px;
  gap: 4px;
}
.tab {
  appearance: none;
  border: none;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 8px 4px;
  border-radius: 10px;
  cursor: pointer;
  color: var(--ink-3);
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.02em;
  transition: background 120ms ease, color 120ms ease;
  -webkit-tap-highlight-color: transparent;
}
.tab svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.tab:hover { color: var(--ink-2); }
.tab.active { color: var(--ink); }
.tab.active svg { stroke-width: 1.9; }

/* Cuando hay tabbar, el cta-bar pierde su padding inferior */
.app.has-tabbar .cta-bar { padding-bottom: 12px; }

/* Form (Hacer cuentas) */
.form-back {
  padding: 56px 20px 0;
  display: flex; align-items: center; gap: 8px;
  font-size: 14px; color: var(--ink-3); cursor: pointer;
}
.form-head {
  padding: 12px 20px 20px;
  border-bottom: 0.5px solid var(--hairline);
}
.form-head .who { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.form-head .who .avatar { width: 44px; height: 44px; font-size: 15px; }
.form-head h2 {
  margin: 0; font-size: 24px; font-weight: 600; letter-spacing: -0.02em;
}
.form-head .who-sub { font-size: 13px; color: var(--ink-3); }

.balance-card {
  margin: 16px 20px 0;
  padding: 16px;
  border-radius: 14px;
  background: var(--bg-sunk);
  display: flex; flex-direction: column; gap: 10px;
}
.balance-card.good { background: var(--good-bg); }
.balance-card.bad { background: var(--bad-bg); }
.balance-card .row {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; color: var(--ink-2);
}
.balance-card .row .label { color: var(--ink-3); }
.balance-card .divider { height: 0.5px; background: var(--hairline); margin: 4px -16px; }
.balance-card .total {
  display: flex; justify-content: space-between; align-items: baseline;
}
.balance-card .total .label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
}
.balance-card.good .total .label { color: var(--good); }
.balance-card.bad .total .label { color: var(--bad); }
.balance-card .total .amount {
  font-size: 22px; font-weight: 600; letter-spacing: -0.02em;
}
.balance-card.good .total .amount { color: var(--good); }
.balance-card.bad .total .amount { color: var(--bad); }

.field-group {
  padding: 0 20px;
  margin-top: 8px;
}
.field {
  padding: 14px 0;
  display: flex; flex-direction: column; gap: 4px;
  border-bottom: 0.5px solid var(--hairline);
}
.field:last-child { border-bottom: none; }
.field .field-label {
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
}
.field .field-input {
  display: flex; align-items: baseline; gap: 6px;
  font-size: 22px; font-weight: 500; letter-spacing: -0.01em;
}
.field .field-input input {
  border: none; background: transparent; outline: none;
  font: inherit; color: var(--ink);
  width: 100%; padding: 0;
  font-variant-numeric: tabular-nums;
}
.field .field-input .unit { color: var(--ink-3); font-weight: 400; }
.field .field-hint { font-size: 12px; color: var(--ink-4); margin-top: 2px; }

.field.compact .field-input { font-size: 18px; }

/* Subgroup card (efectivo, tarjeta etc.) */
.subgroup {
  margin: 16px 20px 0;
  border: 0.5px solid var(--hairline);
  border-radius: 14px;
  background: var(--bg-elev);
  overflow: hidden;
}
.subgroup .subgroup-head {
  padding: 10px 16px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-3);
  border-bottom: 0.5px solid var(--hairline);
}
.subgroup .field { padding: 12px 16px; }
.subgroup .field:last-child { border-bottom: none; }

/* Confirmation / summary */
.summary-card {
  margin: 16px 20px;
  padding: 20px;
  border: 0.5px solid var(--hairline);
  border-radius: 14px;
  background: var(--bg-elev);
}
.summary-card .stamp {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 11px; font-weight: 600; letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--ink-3);
  padding-bottom: 12px;
  border-bottom: 0.5px solid var(--hairline);
}
.summary-card h3 {
  margin: 16px 0 4px;
  font-size: 28px; font-weight: 600; letter-spacing: -0.02em;
}
.summary-card .delta {
  font-size: 13px; color: var(--ink-3);
}
.summary-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 10px 0;
  font-size: 14px;
  border-top: 0.5px solid var(--hairline);
}
.summary-row .label { color: var(--ink-3); }
.summary-row.total {
  font-size: 16px; font-weight: 600; padding-top: 14px; margin-top: 6px;
  border-top: 1px solid var(--hairline-2);
}

/* Success illustration (minimal) */
.success-mark {
  margin: 32px auto 16px;
  width: 56px; height: 56px;
  border-radius: 50%; background: var(--good-bg);
  color: var(--good);
  display: flex; align-items: center; justify-content: center;
}

/* History */
.history-row {
  padding: 16px 20px;
  border-top: 0.5px solid var(--hairline);
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.history-row:last-child { border-bottom: 0.5px solid var(--hairline); }
.history-row .left { display: flex; flex-direction: column; gap: 4px; }
.history-row .day { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.history-row .meta { font-size: 12px; color: var(--ink-3); }
.history-row .right { text-align: right; }
.history-row .amt { font-size: 16px; font-weight: 500; letter-spacing: -0.01em; }
.history-row .delta-pos { font-size: 12px; color: var(--good); margin-top: 2px; }
.history-row .delta-neg { font-size: 12px; color: var(--bad); margin-top: 2px; }
.history-row .delta-zero { font-size: 12px; color: var(--ink-4); margin-top: 2px; }

/* Tabs at top of history */
.tabs {
  display: flex; gap: 4px;
  padding: 8px 20px 0;
  border-bottom: 0.5px solid var(--hairline);
}
.tab {
  padding: 8px 0; margin-right: 20px;
  font-size: 14px; font-weight: 500; color: var(--ink-3);
  border-bottom: 2px solid transparent;
  cursor: pointer;
}
.tab.active { color: var(--ink); border-bottom-color: var(--ink); }

/* Numpad */
.numpad {
  margin-top: auto;
  background: var(--bg-sunk);
  border-top: 0.5px solid var(--hairline);
  padding: 12px 8px 36px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.np-key {
  height: 52px; border-radius: 10px;
  background: var(--bg-elev);
  border: 0.5px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; font-weight: 500; color: var(--ink);
  cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.np-key.fn { background: transparent; border: none; font-size: 14px; color: var(--ink-3); font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; }
.np-key.done { background: var(--ink); color: var(--bg); border-color: var(--ink); }

/* Receipt-style summary */
.receipt {
  background: var(--bg);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  padding: 20px;
}
.receipt h4 {
  margin: 0; font-size: 11px; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--ink-3); text-align: center;
}
.receipt .stamp-line {
  text-align: center; font-size: 11px; color: var(--ink-4);
  margin: 4px 0 16px;
}
.receipt-row {
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
  padding: 4px 0;
  font-size: 12px; color: var(--ink-2);
}
.receipt-row > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.receipt-row > span:last-child { white-space: nowrap; flex-shrink: 0; text-align: right; }
.receipt-row.bold { font-weight: 600; color: var(--ink); }
.receipt-row.dashed { border-top: 1px dashed var(--hairline-2); margin-top: 8px; padding-top: 8px; }

/* Subtle scroll fade */
.scroll {
  flex: 1; overflow-y: auto;
  scrollbar-width: thin;
}
.scroll::-webkit-scrollbar { width: 0; }
