/* Norte — prototipo visual. Datos de ejemplo en app.js. */

@font-face {
  font-family: "Inter";
  src: url("fonts/Inter-Variable.ttf") format("truetype");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root,
:root[data-theme="dark"] {
  --bg: #070a0c;
  --bg-glow: rgba(62, 224, 176, 0.075);
  --surface: #141a1d;
  --surface-2: #1c2327;
  --surface-3: #242c31;
  --text: #f3f6f5;
  --text-2: #a7b2ae;
  --text-3: #7d8884;
  --separator: rgba(255, 255, 255, 0.08);
  --hairline: rgba(255, 255, 255, 0.07);
  --accent: #3ee0b0;
  --accent-strong: #7aecd0;
  --accent-dim: rgba(62, 224, 176, 0.14);
  --accent-ink: #06211a;
  --income: #5ee9b8;
  --warning: #e6b65c;
  --warning-dim: rgba(230, 182, 92, 0.16);
  --danger: #f07178;
  --hero-bg:
    radial-gradient(120% 90% at 100% 0%, rgba(62, 224, 176, 0.18), transparent 52%),
    linear-gradient(165deg, #17332c 0%, #101e1b 100%);
  --hero-inset: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  --card-inset: inset 0 1px 0 rgba(255, 255, 255, 0.055);
  --tabbar-bg: rgba(12, 16, 18, 0.78);
  --tab-inactive: #8b9491;
  --home-indicator: rgba(255, 255, 255, 0.32);
  --ring-track: rgba(255, 255, 255, 0.1);
  --search-bg: #1c2327;
  --pill-active-bg: #f3f6f5;
  --pill-active-fg: #070a0c;
  --shadow-card: none;
  --icon-btn-bg: rgba(255, 255, 255, 0.06);
  --status-fg: #f3f6f5;
  color-scheme: dark;
}

:root[data-theme="light"] {
  --bg: #eef1f0;
  --bg-glow: rgba(11, 125, 98, 0.06);
  --surface: #ffffff;
  --surface-2: #f3f6f5;
  --surface-3: #e7ecea;
  --text: #14201c;
  --text-2: #5c6b67;
  --text-3: #5f6d69;
  --separator: rgba(20, 32, 28, 0.08);
  --hairline: rgba(20, 32, 28, 0.07);
  --accent: #0b7d62;
  --accent-strong: #0a6b54;
  --accent-dim: rgba(11, 125, 98, 0.12);
  --accent-ink: #ffffff;
  --income: #0b7d62;
  --warning: #9a6700;
  --warning-dim: rgba(154, 103, 0, 0.12);
  --danger: #c0363c;
  --hero-bg:
    radial-gradient(120% 90% at 100% 0%, rgba(11, 125, 98, 0.12), transparent 54%),
    linear-gradient(180deg, #e5f4ee 0%, #f4faf7 100%);
  --hero-inset: inset 0 1px 0 rgba(255, 255, 255, 0.8);
  --card-inset: inset 0 0 0 0.5px rgba(20, 32, 28, 0.06);
  --tabbar-bg: rgba(255, 255, 255, 0.82);
  --tab-inactive: #6b7874;
  --home-indicator: rgba(20, 32, 28, 0.28);
  --ring-track: rgba(20, 32, 28, 0.1);
  --search-bg: #e4e9e7;
  --pill-active-bg: #14201c;
  --pill-active-fg: #ffffff;
  --shadow-card: 0 1px 2px rgba(20, 32, 28, 0.04), 0 10px 24px rgba(20, 32, 28, 0.05);
  --icon-btn-bg: rgba(20, 32, 28, 0.06);
  --status-fg: #14201c;
  color-scheme: light;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: #1c1c1e;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
    "SF Pro Display", "Segoe UI", system-ui, sans-serif;
  font-feature-settings: "ss01" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  min-height: 100dvh;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

button {
  appearance: none;
  border: 0;
  background: none;
  padding: 0;
  cursor: pointer;
}

input {
  appearance: none;
  border: 0;
  outline: none;
}

h1,
h2,
p {
  margin: 0;
}

/* En ventanas mayores al iPhone, el prototipo se presenta como dispositivo. */
@media (min-width: 391px) {
  body {
    display: grid;
    place-items: center;
    padding: 40px 20px;
    background:
      radial-gradient(50% 40% at 50% 0%, rgba(62, 224, 176, 0.08), transparent 70%),
      #2c2c2e;
  }

  .phone {
    border-radius: 44px;
    box-shadow:
      0 0 0 1px rgba(255, 255, 255, 0.08),
      0 28px 80px rgba(0, 0, 0, 0.48);
  }
}

.phone {
  position: relative;
  width: 390px;
  height: 844px;
  overflow: hidden;
  background-color: var(--bg);
  background-image:
    radial-gradient(120% 55% at 50% -8%, var(--bg-glow), transparent 58%);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.statusbar {
  flex: none;
  height: 47px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 26px 0 22px;
  color: var(--status-fg);
  z-index: 4;
}

.statusbar-time {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.statusbar-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

.sb-battery {
  margin-left: 1px;
}

.screens {
  position: relative;
  flex: 1;
  min-height: 0;
}

.screen {
  position: absolute;
  inset: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 6px 20px 96px;
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: opacity 280ms ease, transform 280ms ease;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.screen::-webkit-scrollbar {
  display: none;
}

.screen.is-active {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.page-head h1 {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.035em;
}

.eyebrow {
  font-size: 13px;
  line-height: 1.3;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 3px;
}

.greeting {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.035em;
}

.icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--icon-btn-bg);
  color: var(--text);
  flex: none;
  margin-top: 2px;
}

.icon-btn:focus-visible,
.tab:focus-visible,
.pill:focus-visible,
.search-input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ——— Patrimonio + sparkline ——— */
.wealth {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.wealth-copy {
  min-width: 0;
}

.wealth-amount {
  font-size: 28px;
  line-height: 1.15;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.wealth-delta {
  margin-top: 4px;
  font-size: 13px;
  font-weight: 500;
  color: var(--income);
  font-variant-numeric: tabular-nums;
}

.wealth-chart {
  flex: none;
  width: 124px;
  height: 44px;
}

.wealth-chart svg {
  display: block;
  width: 124px;
  height: 44px;
}

/* ——— Hero: disponible para gastar ——— */
.hero-card {
  background: var(--hero-bg);
  border-radius: 20px;
  padding: 18px 18px 16px;
  box-shadow: var(--hero-inset), var(--shadow-card);
  margin-bottom: 12px;
}

.hero-label {
  font-size: 13px;
  font-weight: 550;
  color: var(--accent-strong);
  letter-spacing: -0.01em;
}

.hero-amount {
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.hero-amount .currency {
  display: inline-block;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0;
  margin-right: 6px;
  opacity: 0.72;
  transform: translateY(-7px);
}

.hero-amount .digits {
  font-size: 40px;
  font-weight: 650;
}

.hero-hint {
  margin-top: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--text-2);
}

.hero-bar {
  margin-top: 14px;
  height: 6px;
  border-radius: 100px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

:root[data-theme="light"] .hero-bar {
  background: rgba(11, 125, 98, 0.14);
}

.hero-bar-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent);
}

/* ——— Tarjetas genéricas ——— */
.card {
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--card-inset), var(--shadow-card);
}

.spend-card {
  padding: 14px 16px 15px;
  margin-bottom: 16px;
}

.spend-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.spend-amount {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.delta-badge {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 8px;
  border-radius: 100px;
  background: var(--accent-dim);
  color: var(--income);
  font-size: 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.spend-note {
  margin-top: 6px;
  font-size: 12px;
  color: var(--text-3);
}

/* ——— Secciones y filas ——— */
.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 8px;
}

.section-head h2 {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.section-link {
  font-size: 13px;
  font-weight: 500;
  color: var(--accent-strong);
}

.row-list {
  padding: 4px 8px;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 50px;
  padding: 7px 8px;
}

.row + .row {
  box-shadow: inset 0 0.5px 0 var(--separator);
}

.cat-icon {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  flex: none;
  color: var(--cat);
  background: color-mix(in srgb, var(--cat) 18%, transparent);
}

:root[data-theme="light"] .cat-icon {
  background: color-mix(in srgb, var(--cat) 15%, transparent);
}

.row-body {
  min-width: 0;
  flex: 1;
}

.row-title {
  font-size: 15px;
  font-weight: 550;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  margin-top: 1px;
  font-size: 12px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-amount {
  flex: none;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  text-align: right;
}

.row-amount.is-income {
  color: var(--income);
}

.pill-hoy {
  display: inline-block;
  margin-right: 4px;
  padding: 1px 6px;
  border-radius: 100px;
  background: var(--accent-dim);
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.01em;
}

/* ——— Insight ——— */
.insight {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-top: 12px;
  padding: 13px 14px;
}

.insight-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: none;
  background: var(--accent-dim);
  color: var(--accent-strong);
}

.insight p {
  font-size: 13px;
  line-height: 1.4;
  color: var(--text);
  padding-top: 4px;
}

/* ——— Movimientos ——— */
.search {
  position: relative;
  margin: -4px 0 12px;
}

.search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 36px;
  padding: 0 12px 0 36px;
  border-radius: 10px;
  background: var(--search-bg);
  color: var(--text);
  font-size: 15px;
}

.search-input::placeholder {
  color: var(--text-3);
}

.filters {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.pill {
  height: 32px;
  padding: 0 14px;
  border-radius: 100px;
  background: var(--surface);
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
  box-shadow: var(--card-inset), var(--shadow-card);
}

.pill[aria-pressed="true"] {
  background: var(--pill-active-bg);
  color: var(--pill-active-fg);
  box-shadow: none;
}

.day-group + .day-group {
  margin-top: 16px;
}

.day-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin: 0 4px 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}

.day-total {
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  color: var(--text-3);
}

.empty-state {
  text-align: center;
  color: var(--text-3);
  font-size: 14px;
  padding: 36px 12px;
}

/* ——— Presupuestos ——— */
.summary-card {
  padding: 16px;
  margin-bottom: 14px;
}

.summary-kicker {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}

.summary-spent {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.03em;
  font-variant-numeric: tabular-nums;
}

.summary-of {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-3);
  letter-spacing: -0.01em;
}

.bar {
  height: 6px;
  border-radius: 100px;
  background: var(--surface-3);
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
}

.bar-fill.is-ahead {
  background: var(--warning);
}

.bar-fill.is-over {
  background: var(--danger);
}

.summary-bar {
  margin: 12px 0 8px;
}

.summary-pace {
  font-size: 12px;
  line-height: 1.4;
  color: var(--text-2);
}

.budget-list {
  padding: 2px 0;
}

.budget-row {
  display: flex;
  gap: 12px;
  padding: 11px 16px 12px;
}

.budget-row + .budget-row {
  box-shadow: inset 0 0.5px 0 var(--separator);
}

.budget-row .cat-icon {
  margin-top: 1px;
}

.budget-main {
  flex: 1;
  min-width: 0;
}

.budget-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.budget-name {
  font-size: 14px;
  font-weight: 550;
  letter-spacing: -0.015em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.budget-amt {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.015em;
}

.budget-meta {
  margin-top: 2px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.budget-meta .pace {
  flex: none;
  font-weight: 550;
  max-width: 64%;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pace.is-under {
  color: var(--income);
}

.pace.is-ahead {
  color: var(--warning);
}

.pace.is-over {
  color: var(--danger);
}

.pace.is-ok {
  color: var(--text-2);
}

.budget-bar {
  margin-top: 7px;
}

/* ——— Metas ——— */
.goals-sub {
  margin: -10px 0 14px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.goal-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 16px;
  margin-bottom: 12px;
}

.ring {
  flex: none;
  display: block;
}

.ring-bg {
  fill: none;
  stroke: var(--ring-track);
}

.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-linecap: round;
}

.ring text {
  fill: var(--text);
  font-size: 13px;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}

.goal-body {
  min-width: 0;
  flex: 1;
}

.goal-name {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-amt {
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
}

.goal-amt strong {
  color: var(--text);
  font-weight: 600;
}

.goal-est {
  margin-top: 8px;
  font-size: 12px;
  color: var(--text-3);
}

.goal-est span {
  color: var(--text-2);
  font-weight: 550;
}

/* ——— Tab bar ——— */
.tabbar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 83px;
  display: flex;
  align-items: flex-start;
  justify-content: space-around;
  padding: 7px 4px 0;
  background: var(--tabbar-bg);
  backdrop-filter: saturate(180%) blur(22px);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  border-top: 0.5px solid var(--separator);
  z-index: 5;
}

.tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  color: var(--tab-inactive);
  min-height: 46px;
  transition: color 180ms ease;
}

.tab svg {
  display: block;
}

.tab span {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: -0.01em;
  white-space: nowrap;
}

.tab[aria-selected="true"] {
  color: var(--accent);
}

.tab[aria-selected="true"] span {
  font-weight: 600;
}

.home-indicator {
  position: absolute;
  left: 50%;
  bottom: 8px;
  transform: translateX(-50%);
  width: 134px;
  height: 5px;
  border-radius: 100px;
  background: var(--home-indicator);
}

@media (prefers-reduced-motion: reduce) {
  .screen,
  .tab {
    transition: none;
  }
}

/* ——— PWA / iPhone: pantalla completa y zonas seguras ———
   En escritorio (navegador ancho) se mantiene el marco de iPhone.
   En móvil o en modo instalado (standalone) la app ocupa toda la
   pantalla y respeta la isla dinámica y la barra inferior. */

@media (max-width: 390px), (display-mode: standalone), (display-mode: fullscreen) {
  html,
  body {
    background: var(--bg);
    width: 100%;
    height: 100%;
    min-height: 100dvh;
    min-height: 100svh;
    overflow: hidden;
    padding: 0;
    display: block;
  }

  .phone {
    width: 100%;
    width: 100vw;
    height: 100%;
    height: 100dvh;
    height: 100svh;
    max-width: none;
    border-radius: 0;
    box-shadow: none;
    /* Evita que el contenido quede bajo la isla o el home indicator. */
    padding-top: env(safe-area-inset-top, 0px);
    padding-left: env(safe-area-inset-left, 0px);
    padding-right: env(safe-area-inset-right, 0px);
  }

  /* El sistema ya dibuja la barra de estado y el indicador de inicio. */
  .statusbar {
    display: none;
  }

  .home-indicator {
    display: none;
  }

  .tabbar {
    height: auto;
    min-height: 49px;
    padding-top: 7px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  }

  .screen {
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0px));
  }
}
