:root {
  --gold: #c9a44c;
  --gold-deep: #9a7a2e;
  --gold-soft: #f6efd8;
  --white: #ffffff;
  --paper: #fffcf9;
  --cream: #fbf7f2;
  --blush: #f6e8ec;
  --blush-mid: #e8c5ce;
  --blush-deep: #c48b96;
  --ink: #2c261f;
  --muted: #7a7168;
  --line: #eadfd4;
  --sand: #f3ebe3;
  --ok: #5f7f68;
  --warn: #9a6700;
  --due: #a05c5c;
  --navy: #2c261f;
  --teal: #c9a44c;
  --teal-deep: #9a7a2e;
  --teal-soft: #f6e8ec;
  --tab-h: 72px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --shadow: 0 8px 28px rgba(44, 38, 31, 0.06);
  --font: "Outfit", system-ui, sans-serif;
  --display: "Cormorant Garamond", "Georgia", serif;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: #1c1814;
  min-height: 100dvh;
}
button, input { font: inherit; }
button { cursor: pointer; border: 0; background: none; color: inherit; }
img { max-width: 100%; display: block; }
.hidden { display: none !important; }

.stage {
  min-height: 100dvh;
  display: flex;
  justify-content: center;
  background:
    radial-gradient(900px 420px at 50% -8%, rgba(201, 164, 76, 0.18) 0%, transparent 55%),
    #1c1814;
}

.shell {
  width: min(100%, 430px);
  min-height: 100dvh;
  background: var(--cream);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: 0 0 0 1px rgba(201, 164, 76, 0.18), 0 30px 80px rgba(0,0,0,0.35);
}

/* Splash */
.splash {
  flex: 1;
  min-height: 100dvh;
  padding: 24px 24px calc(28px + var(--safe-b));
  display: flex;
  flex-direction: column;
  background:
    linear-gradient(180deg, #ffffff 0%, var(--cream) 72%, var(--blush) 140%);
  color: var(--ink);
  box-shadow: inset 0 2px 0 var(--gold);
}
.splash-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.splash-brand img { height: 18px; width: 18px; border-radius: 50%; }
.splash-brand span {
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--muted);
}
.splash-hero {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 12px 0 8px;
}
.splash-logo {
  width: min(72%, 240px);
  height: auto;
  margin: 0 auto 10px;
  filter: drop-shadow(0 12px 24px rgba(201, 164, 76, 0.18));
}
.splash-kicker {
  color: var(--gold-deep);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 10px;
}
.splash-hero h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}
.splash-hero p {
  margin: 0 auto;
  font-size: 16px;
  line-height: 1.5;
  color: var(--muted);
  max-width: 32ch;
}
.splash-note {
  margin: 20px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--blush-mid);
  border-radius: 16px;
  background: rgba(246, 232, 236, 0.55);
  font-size: 13.5px;
  line-height: 1.45;
  color: var(--ink);
  text-align: left;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 52px;
  border-radius: 16px;
  font-weight: 600;
  font-size: 16px;
  padding: 0 18px;
  transition: transform 0.12s ease, opacity 0.12s ease;
}
.btn:active { transform: scale(0.98); }
.btn:focus-visible, .tab:focus-visible, .chip:focus-visible, .action:focus-visible, .search:focus-visible, .field input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}
.btn-primary { background: var(--gold); color: var(--ink); box-shadow: 0 8px 20px rgba(201, 164, 76, 0.22); }
.btn-teal { background: var(--gold); color: var(--ink); }
.btn-ghost { background: transparent; color: var(--gold-deep); border: 1px solid var(--gold); }
.btn-row { display: grid; gap: 10px; margin-top: 18px; }

/* App chrome */
.app { flex: 1; min-height: 100dvh; display: flex; flex-direction: column; background: var(--cream); }
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
  background: var(--white);
  color: var(--ink);
  border-bottom: 1px solid var(--line);
  box-shadow: inset 0 2px 0 var(--gold);
}
.brand-lockup { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-logo {
  height: 46px;
  width: auto;
  max-width: 190px;
  object-fit: contain;
  object-position: left center;
}
.brand-lockup small { display: block; font-size: 10px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--blush-deep); margin-top: 2px; font-weight: 600; }
.oq-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--white);
  border: 1px solid var(--gold-soft);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold-deep);
  flex: 0 0 auto;
}
.oq-pill img { width: 14px; height: 14px; border-radius: 50%; }

.disclaimer {
  background: var(--blush);
  color: #8d5b66;
  font-size: 12px;
  font-weight: 500;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.disclaimer button { color: var(--blush-deep); font-size: 12px; font-weight: 700; padding: 4px 6px; }

.views {
  flex: 1;
  overflow: auto;
  padding: 16px 16px calc(var(--tab-h) + var(--safe-b) + 16px);
  -webkit-overflow-scrolling: touch;
}
.view { display: none; animation: rise 0.28s ease; }
.view.active { display: block; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.hello { margin: 0 0 4px; font-size: 13px; color: var(--muted); font-weight: 500; }
.hello + h2 { margin: 0 0 14px; font-family: var(--display); font-size: 30px; font-weight: 600; line-height: 1.12; color: var(--ink); }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.kpi .label { font-size: 12px; color: var(--muted); font-weight: 500; }
.kpi .value { font-size: 22px; font-weight: 700; margin-top: 6px; letter-spacing: -0.03em; }
.kpi.ingresos .value { color: var(--ok); }
.kpi.gastos .value { color: var(--due); }
.kpi.full { grid-column: 1 / -1; }

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 18px 0 8px;
  font-size: 14px;
  font-weight: 650;
}
.section-title span { color: var(--muted); font-weight: 500; font-size: 12px; }
.linkish { color: var(--gold-deep); font-weight: 650; font-size: 13px; }

.appt {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 0;
}
.appt + .appt, .list .row + .row { margin-top: 8px; }
.time {
  flex: 0 0 58px;
  font-weight: 700;
  font-size: 13px;
  color: var(--gold-deep);
}
.appt-body, .row-body { flex: 1; min-width: 0; }
.appt-body strong, .row-body strong { display: block; font-size: 14.5px; }
.appt-body small, .row-body small { color: var(--muted); font-size: 12px; }
.badge {
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  padding: 4px 8px;
  white-space: nowrap;
}
.badge-ok { background: #eef4ef; color: var(--ok); }
.badge-wait { background: var(--gold-soft); color: var(--gold-deep); }
.badge-now { background: var(--blush); color: var(--blush-deep); }
.badge-due { background: #f8e8e8; color: var(--due); }

.actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 16px; }
.action {
  background: var(--gold);
  color: var(--ink);
  border-radius: 16px;
  min-height: 48px;
  font-weight: 650;
}
.action.alt { background: var(--blush); color: #8d5b66; }

.row {
  display: flex;
  gap: 12px;
  align-items: center;
  width: 100%;
  text-align: left;
}
.dot {
  width: 10px; height: 10px; border-radius: 50%; flex: 0 0 10px;
}
.dot.in { background: var(--ok); }
.dot.out { background: var(--due); }
.amount { font-weight: 700; font-size: 14px; white-space: nowrap; }
.amount.in { color: var(--ok); }
.amount.out { color: var(--due); }

.avatar {
  width: 40px; height: 40px; border-radius: 14px;
  display: grid; place-items: center;
  background: var(--blush); color: var(--blush-deep);
  font-weight: 700; font-size: 13px; flex: 0 0 40px;
}

.chips { display: flex; gap: 8px; overflow: auto; padding-bottom: 4px; margin-bottom: 12px; }
.chip {
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 999px;
  padding: 8px 12px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
}
.chip.on { background: var(--gold); color: var(--ink); border-color: var(--gold); }

.search {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--paper);
  border-radius: 14px;
  padding: 12px 14px;
  margin-bottom: 12px;
  outline: none;
}
.search:focus { border-color: var(--gold); }

.balance {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 12px;
}
.balance small { color: var(--muted); }
.balance strong { font-size: 28px; letter-spacing: -0.04em; }

.bars { display: flex; align-items: flex-end; gap: 8px; height: 120px; margin-top: 8px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bar {
  width: 100%;
  border-radius: 8px 8px 4px 4px;
  background: linear-gradient(180deg, var(--gold), var(--blush-mid));
  min-height: 8px;
}
.bar-col span { font-size: 10px; color: var(--muted); }

.note {
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  line-height: 1.45;
  background: var(--sand);
  border-radius: 14px;
  padding: 12px 14px;
}

.fab-space { height: 8px; }
.fab {
  position: sticky;
  bottom: 8px;
  width: 100%;
  margin-top: 16px;
}

.tabbar {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  height: calc(var(--tab-h) + var(--safe-b));
  padding: 8px 6px var(--safe-b);
  background: rgba(255,252,249,0.94);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--line);
  display: grid;
  grid-template-columns: repeat(5, 1fr);
}
.tab {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  color: var(--muted); font-size: 11px; font-weight: 650;
  min-height: 52px; justify-content: center;
}
.tab svg { width: 22px; height: 22px; }
.tab.on { color: var(--gold-deep); }
.tab.on svg { stroke: var(--gold); }
.tab.on::after {
  content: "";
  width: 14px;
  height: 2px;
  border-radius: 2px;
  background: var(--gold);
}

/* Sheets */
.backdrop {
  position: absolute; inset: 0;
  background: rgba(44, 38, 31, 0.36);
  z-index: 20;
}
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0;
  background: var(--paper);
  border-radius: 24px 24px 0 0;
  z-index: 21;
  padding: 12px 18px calc(20px + var(--safe-b));
  max-height: 86%;
  overflow: auto;
  animation: slide 0.28s ease;
}
@keyframes slide { from { transform: translateY(24px); opacity: 0; } to { transform: none; opacity: 1; } }
.handle { width: 42px; height: 4px; border-radius: 99px; background: var(--line); margin: 4px auto 12px; }
.sheet h3 { margin: 0 0 6px; font-family: var(--display); font-size: 24px; }
.sheet .btn { margin-top: 14px; }
.sheet .meta { color: var(--muted); font-size: 13px; margin: 0 0 14px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 650; color: var(--muted); margin-bottom: 6px; }
.field input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  background: #fff;
  outline: none;
}
.field input:focus { border-color: var(--gold); }
.toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.toggle button {
  border: 1px solid var(--line);
  border-radius: 12px;
  min-height: 44px;
  font-weight: 650;
}
.toggle button.on.in { background: #eef4ef; border-color: var(--ok); color: var(--ok); }
.toggle button.on.out { background: var(--blush); border-color: var(--blush-deep); color: var(--due); }
.toast {
  position: absolute;
  left: 16px; right: 16px;
  bottom: calc(var(--tab-h) + var(--safe-b) + 12px);
  background: var(--ink);
  color: var(--white);
  border-left: 3px solid var(--gold);
  border-radius: 14px;
  padding: 12px 14px;
  font-size: 13px;
  z-index: 30;
  animation: rise 0.2s ease;
}

.empty { text-align: center; color: var(--muted); padding: 24px 8px; font-size: 14px; }

@media (min-width: 520px) {
  .shell { height: 844px; min-height: 844px; margin: 24px 0; border-radius: 28px; }
  .splash, .app { min-height: 0; height: 100%; flex: 1; }
  .splash { border-radius: 28px; }
}