/* Gastos · design tokens + componentes — fuente: Claude Design "Gastos App - Prototipo" */

/* ===== Tokens ===== */
:root {
  /* color */
  --color-accent: #4A2FBD;
  --color-accent-soft: #7C5CE0;
  --color-accent-bg: #EDEAF6;
  --color-accent-tint: #F4F1FD;
  --color-accent-line: #DDD5F5;
  --color-ink: #18122E;
  --color-body: #3F3A52;
  --color-muted: #8E8C99;
  --color-muted-2: #5B5670;
  --color-muted-3: #71717A;
  --color-bg: #FAFAFA;
  --color-surface: #FFFFFF;
  --color-line: #ECEAF4;
  --color-line-soft: #F1F0F7;
  --color-track: #EFEEF5;
  --color-ok: #15803D;
  --color-ok-bg: #E7F3EC;
  --color-warn: #D97706;
  --color-warn-bg: #FBF1E4;
  --color-over: #C2410C;
  --color-danger: #DC2626;
  --color-danger-bg: #FDECEC;
  --color-scrim: rgba(24, 18, 46, .4);
  /* type */
  --font-display: "Sora", sans-serif;
  --font-body: "IBM Plex Sans", system-ui, sans-serif;
  --text-hero: 600 34px/1.15 var(--font-display);
  --text-title: 600 19px/1.25 var(--font-display);
  --text-title-sm: 600 17px/1.25 var(--font-display);
  --text-section: 600 14px/1.3 var(--font-display);
  --text-num: 600 13px/1.3 var(--font-display);
  --text-body: 400 13px/1.45 var(--font-body);
  --text-label: 600 11.5px/1.3 var(--font-body);
  --text-caption: 400 11px/1.35 var(--font-body);
  /* shape / space */
  --radius-card: 16px;
  --radius-hero: 18px;
  --radius-field: 12px;
  --radius-chip: 99px;
  --radius-sheet: 24px;
  --space-page: 20px;
  --shadow-fab: 0 6px 16px rgba(74, 47, 189, .35);
  --shadow-dialog: 0 20px 50px rgba(0, 0, 0, .2);
}

/* ===== Base ===== */
* { box-sizing: border-box; margin: 0 }
html { -webkit-text-size-adjust: 100% }
body { background: var(--color-bg); color: var(--color-ink); font: var(--text-body); font-size: 14px }
button, input, select { font-family: var(--font-body); color: var(--color-ink) }
a { color: var(--color-accent); text-decoration: none }

#app { display: flex; flex-direction: column; min-height: 100dvh; max-width: 560px; margin: 0 auto }
main { flex: 1; padding-bottom: 92px }

/* ===== Componentes ===== */
.card { background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-card) }
.card--pad { padding: 2px 16px }

.list-row { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--color-line-soft); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; cursor: pointer }
.list-row:last-child { border-bottom: none }
.list-row__body { flex: 1; min-width: 0 }
.list-row__title { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.list-row__sub { font-size: 11px; color: var(--color-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap }
.list-row__amt { font: var(--text-num); white-space: nowrap }
.list-row__amt--in { color: var(--color-ok) }

.avatar { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 600; flex: none }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none }

.hero { margin: 4px var(--space-page) 0; background: var(--color-accent); border-radius: var(--radius-hero); padding: 20px; color: #fff }
.hero__label { font-size: 12.5px; opacity: .75 }
.hero__value { font: var(--text-hero); margin: 4px 0 14px }
.hero__stats { display: flex; gap: 12px }
.hero__stat { flex: 1; background: rgba(255, 255, 255, .12); border-radius: 12px; padding: 10px 12px }
.hero__stat b { display: block; font: 600 15px/1.3 var(--font-display) }
.hero__stat span { font-size: 11px; opacity: .7 }

.insight { margin: 14px var(--space-page) 0; background: var(--color-accent-tint); border: 1px solid var(--color-accent-line); border-radius: var(--radius-card); padding: 14px 16px; display: flex; gap: 12px; align-items: flex-start }
.insight__tag { font-size: 12px; font-weight: 600; color: var(--color-accent); margin-bottom: 2px }
.insight__text { font-size: 12.5px; line-height: 1.45; color: var(--color-body) }

.section { margin: 18px var(--space-page) 0 }
.section__head { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 10px }
.section__title { font: var(--text-section) }
.section__link { font-size: 12px; font-weight: 600; cursor: pointer; background: none; border: none; color: var(--color-accent); padding: 0 }

.budget-row { display: flex; flex-direction: column; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--color-line-soft); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; text-align: left; font-family: inherit }
.budget-row:last-child { border-bottom: none }
.budget-row__line { display: flex; justify-content: space-between; font-size: 12.5px }
.budget-row__name { font-weight: 500 }
.budget-row__figure { color: var(--color-muted-3) }
.budget-row__figure--over { color: var(--color-over); font-weight: 600 }
.meter { height: 5px; background: var(--color-track); border-radius: 3px; overflow: hidden }
.meter > i { display: block; height: 5px; border-radius: 3px }

.chip { padding: 8px 14px; border-radius: var(--radius-chip); background: var(--color-surface); border: 1px solid var(--color-line); font-size: 12px; color: var(--color-muted-2); cursor: pointer; white-space: nowrap; font-family: inherit }
.chip--on { background: var(--color-ok-bg); color: var(--color-ok); font-weight: 600; border: 1.5px solid var(--color-ok) }
.chip--new { border: 1.5px dashed var(--color-accent); color: var(--color-accent); font-weight: 600; background: none }

.field-label { font: var(--text-label); color: var(--color-muted); margin: 16px 0 6px; text-transform: uppercase; letter-spacing: .02em }
.field { border: 1px solid var(--color-line); border-radius: var(--radius-field); padding: 12px 14px; font-size: 14px; width: 100%; background: var(--color-surface) }
.field:focus { outline: none; border: 1.5px solid var(--color-accent); padding: 11.5px 13.5px }
.field--amount { font: 600 20px/1.3 var(--font-display) }

.btn { display: block; width: 100%; text-align: center; padding: 14px; border-radius: 14px; background: var(--color-accent); color: #fff; font-size: 14px; font-weight: 600; border: none; cursor: pointer; font-family: inherit }
.btn--ghost { background: var(--color-surface); border: 1px solid var(--color-line); color: var(--color-muted-2) }
.btn--danger { background: var(--color-danger) }
.btn--sm { padding: 11px; border-radius: 10px; font-size: 12.5px }

.iconbtn { width: 34px; height: 34px; border-radius: 10px; background: var(--color-surface); border: 1px solid var(--color-line); display: flex; align-items: center; justify-content: center; color: var(--color-muted-2); cursor: pointer; flex: none; font-size: 15px }

.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px var(--space-page) 12px }
.page-head__group { display: flex; align-items: center; gap: 10px; min-width: 0 }
.page-title { font: var(--text-title) }
.day-label { font: var(--text-label); color: var(--color-muted); text-transform: uppercase; letter-spacing: .05em; margin: 14px 0 8px }

.month-nav { display: flex; align-items: center; gap: 10px; background: var(--color-surface); border: 1px solid var(--color-line); border-radius: var(--radius-chip); padding: 6px 12px; font-size: 12.5px; font-weight: 500; white-space: nowrap }
.month-nav button { background: none; border: none; color: var(--color-muted); cursor: pointer; font-size: 14px; padding: 0 4px }

.seg { display: flex; background: var(--color-accent-bg); border-radius: var(--radius-chip); padding: 3px }
.seg button { padding: 6px 14px; border-radius: var(--radius-chip); font-size: 12px; border: none; background: none; color: #6B6580; cursor: pointer; font-family: inherit }
.seg button.on { background: var(--color-accent); color: #fff; font-weight: 600 }

/* bottom nav */
.bottomnav { position: fixed; bottom: 0; left: 0; right: 0; display: flex; align-items: flex-start; justify-content: space-around; background: var(--color-surface); border-top: 1px solid var(--color-line); padding: 10px 8px calc(6px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; z-index: 10 }
.bottomnav__tab { display: flex; flex-direction: column; align-items: center; gap: 2px; color: var(--color-muted); width: 58px; font-size: 10.5px; background: none; border: none; font-family: inherit; cursor: pointer }
.bottomnav__tab.on { color: var(--color-accent); font-weight: 600 }
.bottomnav__fab { width: 54px; height: 54px; border-radius: 27px; background: var(--color-accent); color: #fff; border: none; font-size: 28px; font-weight: 300; margin-top: -24px; box-shadow: var(--shadow-fab); cursor: pointer }

/* sheets / dialogs */
.scrim { position: fixed; inset: 0; background: var(--color-scrim); display: flex; flex-direction: column; justify-content: flex-end; z-index: 50 }
.sheet { background: var(--color-surface); border-radius: var(--radius-sheet) var(--radius-sheet) 0 0; padding: 12px 22px calc(26px + env(safe-area-inset-bottom)); max-width: 560px; margin: 0 auto; width: 100%; max-height: 88dvh; overflow-y: auto }
.sheet__handle { width: 36px; height: 4px; border-radius: 2px; background: #DDDBE6; margin: 0 auto 16px }
.sheet__title { font: 600 16px/1.3 var(--font-display); margin-bottom: 4px }
.dialog { background: var(--color-surface); border-radius: 20px; padding: 24px 20px; text-align: center; width: 100%; max-width: 340px; margin: 0 16px }
.scrim--center { justify-content: center; flex-direction: row; align-items: center }

.menu-row { display: flex; align-items: center; gap: 14px; padding: 12px 0; border-bottom: 1px solid var(--color-line-soft); width: 100%; background: none; border-left: 0; border-right: 0; border-top: 0; cursor: pointer; text-align: left; font-family: inherit }
.menu-row:last-child { border-bottom: none }
.menu-row__icon { width: 38px; height: 38px; border-radius: 12px; background: var(--color-accent-bg); display: flex; align-items: center; justify-content: center; font-size: 17px; flex: none }
.menu-row__title { font-size: 13.5px; font-weight: 600 }
.menu-row__sub { font-size: 11px; color: var(--color-muted) }
.menu-row--disabled { opacity: .45; cursor: default }

.badge-soon { font-size: 9.5px; font-weight: 700; color: var(--color-accent); background: var(--color-accent-tint); border: 1px solid var(--color-accent-line); border-radius: 4px; padding: 2px 5px; margin-left: 6px; vertical-align: 1px }

.center-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 48px 32px; text-align: center; min-height: 60dvh }
.spinner { width: 26px; height: 26px; border: 3px solid var(--color-line); border-top-color: var(--color-accent); border-radius: 50%; animation: sp 1s linear infinite }
@keyframes sp { to { transform: rotate(360deg) } }
.error-text { color: var(--color-over); font-size: 12.5px; min-height: 18px }
.hidden { display: none !important }

.spinner--btn { width: 14px; height: 14px; border-width: 2px; border-color: rgba(255, 255, 255, .45); border-top-color: #fff; display: inline-block }
.btn__busy { display: inline-flex; align-items: center; justify-content: center; gap: 9px }
.btn:disabled { opacity: .85; cursor: default }

/* Banner offline: sobre la bottomnav en móvil, fijo abajo para no tapar el saldo. */
.offline-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(78px + env(safe-area-inset-bottom)); z-index: 40; max-width: calc(100% - 32px); padding: 9px 16px; border-radius: 99px; background: var(--color-warn-bg); color: var(--color-warn); border: 1px solid #F0DCC0; font-size: 12px; font-weight: 600; box-shadow: 0 4px 14px rgba(24, 18, 46, .10); text-align: center }
@media (min-width: 900px) { .offline-banner { bottom: 18px } }

.donut-wrap { display: flex; justify-content: center; padding: 8px 0 4px; position: relative }
.donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; pointer-events: none }

/* ===== Escritorio ===== */
@media (min-width: 900px) {
  #app { max-width: 1180px; padding: 0 28px }
  main { padding-bottom: 40px }
  .bottomnav { position: sticky; top: 0; bottom: auto; max-width: none; justify-content: flex-start; gap: 26px; padding: 14px 4px; border-top: none; border-bottom: 1px solid var(--color-line); margin-bottom: 8px }
  .bottomnav__tab { flex-direction: row; width: auto; font-size: 13px; gap: 7px }
  .bottomnav__tab svg { width: 17px; height: 17px }
  .bottomnav__fab { order: 9; margin: -6px 0 0 auto; width: auto; height: auto; border-radius: 10px; padding: 9px 16px; font-size: 12.5px; font-weight: 600; box-shadow: none }
  .bottomnav__fab::after { content: " Añadir gasto" }
  .scrim { justify-content: center; flex-direction: row; align-items: center }
  .sheet { border-radius: 18px; width: 420px; max-height: 86vh; box-shadow: var(--shadow-dialog); padding-bottom: 26px }
  .sheet__handle { display: none }
  .grid-2 { display: grid; grid-template-columns: 1.1fr 1fr; gap: 20px; align-items: start }
  .grid-2 > * { margin-left: 0 !important; margin-right: 0 !important }
  .balance-grid { display: grid; grid-template-columns: 340px 1fr; gap: 32px; align-items: center; margin: 0 var(--space-page) }
  .balance-grid .card { margin: 0 !important }
}
