:root {
  color-scheme: dark;
  --bg: #10131f;
  --bg-elevated: #171c2f;
  --card: #1a2036;
  --text: #f3efe4;
  --text-soft: #e7e1d2;
  --muted: #9aa0ba;
  --muted-soft: #6b7290;
  --border: #2b3154;
  --border-soft: #232a48;

  --ink: #090b14;
  --ink-soft: #131829;

  --accent: #cda545;
  --accent-2: #e8ca7d;
  --accent-soft: rgba(205, 165, 69, .16);
  --on-accent: #1a1406;
  --danger: #f87171;
  --success: #4ade80;
  --whatsapp: #25d366;

  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --radius-pill: 999px;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .25), 0 1px 1px rgba(0, 0, 0, .18);
  --shadow-md: 0 8px 24px -8px rgba(0, 0, 0, .45);
  --shadow-lg: 0 16px 40px -12px rgba(0, 0, 0, .55);

  --font: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-display: 'Manrope', var(--font);
  --font-serif: 'Playfair Display', 'Georgia', serif;
}

/* La app siempre usa esta paleta oscura marino + dorado, sin importar
   si el celular está en modo claro/oscuro — es la identidad ARV, no
   un tema que dependa del sistema. */

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  scroll-behavior: smooth;
}

body {
  padding-bottom: 96px;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

::selection { background: var(--accent); color: white; }

.bg-decor {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(600px circle at 100% -10%, rgba(205, 165, 69, .10), transparent 60%),
    radial-gradient(500px circle at -10% 10%, rgba(205, 165, 69, .06), transparent 55%);
}

/* ============ CANDADO ============ */
.lock-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: radial-gradient(circle at 50% 20%, var(--ink-soft) 0%, var(--ink) 65%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lock-card {
  width: 100%;
  max-width: 340px;
  text-align: center;
}

.lock-mark {
  width: 60px;
  height: 60px;
  margin: 0 auto 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 19px;
  letter-spacing: .04em;
  color: var(--on-accent);
  box-shadow: 0 10px 26px -8px rgba(205, 165, 69, .55);
}

.lock-card h2 {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 700;
  color: var(--accent-2);
  margin: 0 0 6px;
}

.lock-card p {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 22px;
}

.lock-input {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 15px;
  background: var(--card);
  color: var(--text);
  text-align: center;
  letter-spacing: .05em;
}

.lock-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.lock-btn {
  width: 100%;
  margin-top: 12px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 14.5px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(205, 165, 69, .5);
  transition: transform .12s ease;
}

.lock-btn:active { transform: scale(0.985); }

.lock-error {
  min-height: 18px;
  margin-top: 12px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--danger);
}

/* ============ HEADER ============ */
header.app-header {
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-soft) 100%);
  color: white;
  padding: 20px 18px 22px;
  position: sticky;
  top: 0;
  z-index: 20;
  border-radius: 0 0 26px 26px;
  box-shadow: var(--shadow-lg);
}

.app-header-top { margin-bottom: 16px; }

.brand { display: flex; align-items: center; gap: 12px; }

.brand-mark {
  width: 44px;
  height: 44px;
  flex: none;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-serif);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: .04em;
  color: var(--on-accent);
  box-shadow: 0 6px 16px -4px rgba(205, 165, 69, .5);
}

.brand h1 {
  font-family: var(--font-serif);
  font-size: 16.5px;
  line-height: 1.28;
  font-weight: 700;
  margin: 0 0 3px;
  letter-spacing: .01em;
  color: var(--accent-2);
}

.brand p {
  margin: 0;
  font-size: 11px;
  color: #8b91ac;
  font-weight: 500;
  letter-spacing: .1em;
  text-transform: uppercase;
}

/* Línea decorativa animada bajo la marca, como el ornamento de la placa */
.brand-divider {
  position: relative;
  height: 1px;
  margin: 16px 1px 0;
  background: linear-gradient(90deg, transparent, rgba(232, 202, 125, .45) 50%, transparent);
  overflow: hidden;
}

.brand-divider span {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--ink-soft);
  padding: 0 9px;
  font-size: 9px;
  color: var(--accent-2);
  line-height: 1;
}

.brand-divider::after {
  content: '';
  position: absolute;
  inset: 0;
  width: 45%;
  background: linear-gradient(90deg, transparent, rgba(255, 246, 224, .9), transparent);
  animation: shineSweep 4s ease-in-out infinite;
}

@keyframes shineSweep {
  0% { transform: translateX(-120%); }
  55%, 100% { transform: translateX(320%); }
}

.header-stat {
  background: rgba(255, 255, 255, .06);
  border: 1px solid rgba(255, 255, 255, .08);
  backdrop-filter: blur(6px);
  border-radius: var(--radius-md);
  padding: 12px 14px;
}

.hs-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #94a3b8;
  font-weight: 700;
  margin-bottom: 4px;
}

.hs-monto {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--accent-2);
}

/* ============ LAYOUT ============ */
main {
  padding: 18px 16px 6px;
  max-width: 480px;
  margin: 0 auto;
}

.screen { display: none; }
.screen.active {
  display: block;
  animation: screenIn .32s cubic-bezier(.2, .7, .2, 1);
}

@keyframes screenIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--muted);
  margin: 26px 0 11px;
  display: flex;
  align-items: center;
  gap: 7px;
}

.section-title em {
  font-style: normal;
  text-transform: none;
  font-weight: 500;
  letter-spacing: 0;
  color: var(--muted-soft);
  font-size: 11.5px;
}

.st-icon { font-size: 14px; }

/* ============ CHIPS ============ */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  border: 1.5px solid var(--border);
  background: var(--card);
  padding: 10px 15px;
  border-radius: var(--radius-pill);
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  color: var(--text-soft);
  transition: all .12s ease;
  box-shadow: var(--shadow-sm);
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.chip:active { transform: scale(0.96); }

.chip.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: 700;
  box-shadow: 0 8px 18px -6px rgba(205, 165, 69, .5);
}

.otro-input {
  margin-top: 10px;
}

.otro-input.hidden { display: none; }

.sub-row {
  margin-top: 10px;
  padding: 10px 10px 4px;
  background: var(--border-soft);
  border-radius: var(--radius-md);
  gap: 7px;
}

.sub-row.hidden { display: none; }

.sub-row .chip {
  background: var(--card);
  padding: 8px 13px;
  font-size: 12.5px;
}

.sub-row .chip.selected {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  border-color: var(--accent);
}

.sugerencias-row {
  margin-top: 8px;
  gap: 6px;
}

.sugerencias-row.hidden { display: none; }

/* Línea con movimiento — un destello dorado recorriéndola sin parar */
.shine-divider {
  position: relative;
  height: 2px;
  margin: 16px 2px 0;
  border-radius: var(--radius-pill);
  background: rgba(205, 165, 69, .18);
  overflow: hidden;
}

.shine-divider::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: -35%;
  width: 35%;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, transparent, var(--accent-2), transparent);
  animation: shineTravel 2.6s ease-in-out infinite;
}

@keyframes shineTravel {
  0% { left: -35%; }
  100% { left: 100%; }
}

.sugerencias-row .chip-sug {
  border: 1.5px dashed var(--border);
  background: transparent;
  padding: 7px 12px;
  border-radius: var(--radius-pill);
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  cursor: pointer;
}

.sugerencias-row .chip-sug:active { transform: scale(0.96); }
.sugerencias-row .chip-sug::before { content: '↺ '; }

/* ============ INPUTS ============ */
.amount-wrap {
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-sm);
  transition: border-color .15s ease, box-shadow .15s ease;
}

.amount-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

.amount-wrap span {
  font-size: 26px;
  font-weight: 700;
  color: var(--muted-soft);
}

.amount-wrap input {
  border: none;
  outline: none;
  font-size: 30px;
  font-weight: 700;
  font-family: var(--font-serif);
  width: 100%;
  background: transparent;
  color: var(--accent-2);
}

input[type="text"], textarea, select {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  font-size: 14.5px;
  font-family: inherit;
  background: var(--card);
  color: var(--text);
  transition: border-color .15s ease, box-shadow .15s ease;
}

input[type="text"]:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 4px var(--accent-soft);
}

textarea { resize: none; min-height: 60px; }

.metodo-grid { display: flex; gap: 8px; }
.metodo-grid .chip { flex: 1; justify-content: center; }

/* ============ BOTONES ============ */
.submit-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--on-accent);
  border: none;
  border-radius: var(--radius-md);
  padding: 17px;
  font-size: 15.5px;
  font-weight: 700;
  margin-top: 26px;
  cursor: pointer;
  box-shadow: 0 12px 24px -10px rgba(205, 165, 69, .5);
  transition: transform .12s ease, box-shadow .12s ease;
}

.submit-btn:active { transform: scale(0.985); }
.submit-btn:disabled { opacity: .5; box-shadow: none; }

.status-msg {
  text-align: center;
  font-size: 13px;
  font-weight: 600;
  margin-top: 12px;
  min-height: 18px;
}

.status-msg.ok { color: var(--success); }
.status-msg.error { color: var(--danger); }
.status-msg.pending { color: #d97706; }

/* ============ RESUMEN ============ */
.periodo-toggle {
  display: flex;
  gap: 8px;
  background: var(--border-soft);
  padding: 4px;
  border-radius: var(--radius-pill);
  margin-bottom: 16px;
}

.periodo-btn {
  flex: 1;
  border: none;
  background: transparent;
  border-radius: var(--radius-pill);
  padding: 10px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  transition: all .15s ease;
}

.periodo-btn.active {
  background: var(--card);
  color: var(--accent);
  box-shadow: var(--shadow-sm);
}

.month-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 6px;
  margin-bottom: 16px;
}

.month-nav.hidden { display: none; }

.month-nav button {
  width: 34px;
  height: 34px;
  flex: none;
  border: none;
  background: var(--border-soft);
  border-radius: 50%;
  font-size: 17px;
  font-weight: 700;
  color: var(--accent-2);
  cursor: pointer;
  transition: transform .12s ease;
}

.month-nav button:active { transform: scale(0.9); }
.month-nav button:disabled { opacity: .35; cursor: default; }

.month-nav-label {
  font-family: var(--font-serif);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-soft);
  text-transform: capitalize;
}

.combinado-card {
  position: relative;
  overflow: hidden;
  background: linear-gradient(160deg, var(--ink) 0%, var(--ink-soft) 100%);
  color: white;
  border-radius: var(--radius-lg);
  padding: 24px 20px;
  margin-bottom: 8px;
  text-align: center;
  box-shadow: var(--shadow-lg);
}

.cc-decor {
  position: absolute;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(205, 165, 69, .3), transparent 70%);
  top: -110px;
  right: -60px;
}

.cc-label {
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #8b91ac;
  font-weight: 700;
  position: relative;
}

.cc-sub { font-size: 12px; color: #626890; margin-top: 2px; position: relative; }

.cc-monto {
  font-family: var(--font-serif);
  font-size: 38px;
  font-weight: 700;
  margin: 10px 0 4px;
  letter-spacing: -.01em;
  position: relative;
  color: var(--accent-2);
}

.cc-desde { font-size: 11.5px; color: #626890; position: relative; }

.breakdown-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 8px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  border-left: 2px solid var(--accent);
}

.breakdown-item .bi-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13.5px;
  margin-bottom: 8px;
}

.breakdown-item .bi-nombre { font-weight: 600; display: flex; align-items: center; color: var(--text-soft); }
.breakdown-item .bi-monto { font-weight: 700; font-family: var(--font-display); }
.breakdown-item .bi-pct { font-weight: 600; color: var(--muted-soft); font-size: 11.5px; margin-left: 6px; }

.breakdown-bar {
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--border-soft);
  overflow: hidden;
}

.breakdown-bar > div {
  height: 100%;
  border-radius: var(--radius-pill);
  transition: width .5s cubic-bezier(.2, .7, .2, 1);
}

.icon-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 8px;
  font-size: 12px;
  margin-right: 8px;
  flex: none;
}

.whatsapp-btn {
  width: 100%;
  background: var(--whatsapp);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 16px;
  font-size: 14.5px;
  font-weight: 700;
  margin-top: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  box-shadow: 0 12px 24px -10px rgba(37, 211, 102, .55);
  transition: transform .12s ease;
}

.whatsapp-btn:active { transform: scale(0.985); }
.whatsapp-btn:disabled { opacity: .5; box-shadow: none; }

/* ============ HISTORIAL ============ */
.historial-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gasto-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-soft);
  border-left: 2px solid var(--accent);
}

.gasto-item .left { flex: 1; min-width: 0; }
.gasto-item .categoria { font-size: 11.5px; color: var(--muted); display: flex; align-items: center; font-weight: 600; }
.gasto-item .descripcion { font-size: 14.5px; font-weight: 700; margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--text-soft); }
.gasto-item .fecha { font-size: 11.5px; color: var(--muted-soft); }
.gasto-item .monto { font-size: 15.5px; font-weight: 800; font-family: var(--font-display); white-space: nowrap; }

.empty-state {
  text-align: center;
  color: var(--muted);
  font-size: 13.5px;
  padding: 44px 16px;
  background: var(--card);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border);
}

.pending-tag {
  display: inline-block;
  font-size: 10px;
  background: #fef3c7;
  color: #92400e;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  margin-left: 6px;
  font-weight: 700;
}

.refresh-btn {
  background: var(--card);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 36px;
  height: 36px;
  font-size: 16px;
  color: var(--accent);
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: transform .15s ease;
}

.refresh-btn:active { transform: rotate(180deg); }

/* ============ NAV ============ */
nav.bottom-nav {
  position: fixed;
  bottom: 14px;
  left: 14px;
  right: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  display: flex;
  padding: 6px;
  z-index: 20;
  box-shadow: var(--shadow-lg);
  max-width: 452px;
  margin: 0 auto;
}

nav.bottom-nav button {
  flex: 1;
  background: none;
  border: none;
  padding: 9px 0;
  font-size: 11px;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-weight: 600;
  position: relative;
  z-index: 2;
  transition: color .15s ease;
  border-radius: var(--radius-md);
}

nav.bottom-nav button .icon { font-size: 19px; }
nav.bottom-nav button.active { color: var(--accent); font-weight: 800; }

.nav-pill {
  position: absolute;
  top: 6px;
  bottom: 6px;
  left: 6px;
  width: calc((100% - 12px) / 3);
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  z-index: 1;
  transition: transform .28s cubic-bezier(.2, .8, .2, 1);
}
