/* Flow Web — estilos. Los colores salen de variables que fija theme.js. */

@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Regular.ttf") format("truetype");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Italic.ttf") format("truetype");
  font-weight: 400;
  font-style: italic;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Medium.ttf") format("truetype");
  font-weight: 500;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-SemiBold.ttf") format("truetype");
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: "Poppins";
  src: url("../fonts/Poppins-Bold.ttf") format("truetype");
  font-weight: 700;
  font-display: swap;
}

:root {
  --surface: #f5f6fa;
  --on-surface: #111111;
  --primary: #8600a5;
  --on-primary: #f5f6fa;
  --secondary: #f5ccff;
  --on-secondary: #33004f;
  --income: #15803d;
  --expense: #c42525;
  --semi: #6a666d;

  /* Derivados */
  --card: color-mix(in srgb, var(--on-surface) 5%, var(--surface));
  --card-hover: color-mix(in srgb, var(--on-surface) 9%, var(--surface));
  --line: color-mix(in srgb, var(--on-surface) 12%, transparent);
  --line-strong: color-mix(in srgb, var(--on-surface) 24%, transparent);
  --primary-soft: color-mix(in srgb, var(--primary) 14%, var(--surface));
  --overlay: rgb(0 0 0 / 0.45);
  --elevated: var(--surface);
  --warn: #b45309;

  --radius: 16px;
  --radius-sm: 10px;
  --gap: 16px;
  --nav-width: 232px;
  --nav-height: 68px;
  --page-max: 1080px;
  --font: "Poppins", system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
}
:root[data-theme="dark"] {
  --surface: #141414;
  --on-surface: #f5f6fa;
  --primary: #f2c0ff;
  --on-primary: #141414;
  --secondary: #050505;
  --on-secondary: #f5f6fa;
  --income: #32cc70;
  --expense: #ff4040;
  --semi: #97919b;
  --card: color-mix(in srgb, var(--on-surface) 7%, var(--surface));
  --card-hover: color-mix(in srgb, var(--on-surface) 12%, var(--surface));
  --elevated: color-mix(in srgb, var(--on-surface) 6%, var(--surface));
  --overlay: rgb(0 0 0 / 0.65);
  --warn: #fbbf24;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  margin: 0;
  min-height: 100dvh;
  background: var(--surface);
  color: var(--on-surface);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1 {
  font-size: 1.5rem;
  font-weight: 600;
  line-height: 1.25;
  text-wrap: balance;
}
h2 {
  font-size: 1.1rem;
  font-weight: 600;
}
h3 {
  font-size: 0.95rem;
  font-weight: 600;
}
a {
  color: inherit;
  text-decoration: none;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
  background: none;
  border: 0;
  padding: 0;
  text-align: inherit;
}
button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
img {
  max-width: 100%;
}
:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
[hidden] {
  display: none !important;
}
::selection {
  background: var(--primary);
  color: var(--on-primary);
}

/* Iconos ------------------------------------------------------------------ */
.msr {
  font-family: "Material Symbols Rounded";
  font-weight: normal;
  font-style: normal;
  font-size: 24px;
  line-height: 1;
  letter-spacing: normal;
  text-transform: none;
  display: inline-block;
  white-space: nowrap;
  word-wrap: normal;
  direction: ltr;
  flex: none;
  width: 1em;
  height: 1em;
  overflow: hidden;
  user-select: none;
  -webkit-font-feature-settings: "liga";
  font-feature-settings: "liga";
  font-variation-settings: "FILL" 0, "wght" 400, "GRAD" 0, "opsz" 24;
}
.flow-icon {
  --icon-size: 44px;
  --icon-bg: var(--primary-soft);
  --icon-fg: var(--primary);
  display: inline-grid;
  place-items: center;
  flex: none;
  width: var(--icon-size);
  height: var(--icon-size);
  color: var(--icon-fg);
  border-radius: calc(var(--icon-size) * 0.3);
}
.flow-icon.plated {
  background: var(--icon-bg);
}
.flow-icon .msr {
  font-size: calc(var(--icon-size) * 0.55);
}
.flow-icon .flow-emoji {
  font-size: calc(var(--icon-size) * 0.5);
  line-height: 1;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", var(--font);
}
.flow-icon .flow-brand {
  width: calc(var(--icon-size) * 0.5);
  height: calc(var(--icon-size) * 0.5);
  background: currentColor;
  -webkit-mask: center / contain no-repeat;
  mask: center / contain no-repeat;
}
.transfer-icon {
  --icon-bg: var(--card-hover);
  --icon-fg: var(--on-surface);
}

/* Estructura --------------------------------------------------------------- */
#app {
  min-height: 100dvh;
}
.nav {
  position: fixed;
  inset: 0 auto 0 0;
  width: var(--nav-width);
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 20px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface);
  z-index: 20;
}
.view {
  margin-left: var(--nav-width);
  min-height: 100dvh;
}
body.bare .nav {
  display: none;
}
body.bare .view {
  margin-left: 0;
}
.nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 12px 20px;
  font-size: 1.35rem;
  font-weight: 700;
}
.nav-brand img {
  border-radius: 10px;
}
.nav-item,
.nav-new {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px;
  border-radius: 999px;
  font-weight: 500;
  color: var(--semi);
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover {
  background: var(--card);
  color: var(--on-surface);
}
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
}
.nav-item.active .msr {
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}
.nav-new {
  order: -1;
  margin: 0 0 12px;
  background: var(--primary);
  color: var(--on-primary);
  justify-content: center;
  font-weight: 600;
}
.nav-brand {
  order: -2;
}
.nav-new:hover {
  filter: brightness(1.08);
}

@media (max-width: 860px) {
  .nav {
    inset: auto 0 0 0;
    width: auto;
    height: calc(var(--nav-height) + env(safe-area-inset-bottom));
    padding: 6px 8px env(safe-area-inset-bottom);
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    border-right: 0;
    border-top: 1px solid var(--line);
  }
  .nav-brand {
    display: none;
  }
  .nav-item {
    flex: 1;
    flex-direction: column;
    gap: 2px;
    padding: 6px 4px;
    font-size: 0.7rem;
    border-radius: 14px;
    min-width: 0;
  }
  .nav-item span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
  }
  .nav-new {
    order: 0;
    margin: 0 6px;
    width: 52px;
    height: 52px;
    padding: 0;
    flex: none;
    border-radius: 18px;
  }
  .nav-new span:not(.msr) {
    display: none;
  }
  .nav-new .msr {
    font-size: 30px;
  }
  .view {
    margin-left: 0;
    padding-bottom: calc(var(--nav-height) + env(safe-area-inset-bottom));
  }
  body.bare .view {
    padding-bottom: 0;
  }
}

.page {
  max-width: var(--page-max);
  margin: 0 auto;
  padding: 24px 24px 56px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.page-narrow {
  max-width: 680px;
}
@media (max-width: 600px) {
  .page {
    padding: 16px 16px 40px;
    gap: 20px;
  }
}
.page-header {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.page-header-titles {
  flex: 1;
  min-width: 0;
}
.page-header-titles p {
  color: var(--semi);
  font-size: 0.9rem;
}
.page-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.section {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.section-title {
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--semi);
}
.section-title-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

/* Utilidades */
.row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.row > .input {
  flex: 1;
  min-width: 0;
}
.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.grid {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
.grid-2 {
  display: grid;
  gap: var(--gap);
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (max-width: 720px) {
  .grid-2 {
    grid-template-columns: minmax(0, 1fr);
  }
}
.spacer {
  flex: 1;
}
.semi {
  color: var(--semi);
}
.small {
  font-size: 0.85rem;
}
.center {
  text-align: center;
}
.link {
  color: var(--primary);
  font-weight: 500;
  font-size: 0.9rem;
}
.link:hover {
  text-decoration: underline;
}
.nowrap {
  white-space: nowrap;
}
.big-number {
  font-size: clamp(1.8rem, 5vw, 2.5rem);
  font-weight: 700;
  line-height: 1.15;
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
}

/* Tarjetas y filas --------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  min-width: 0;
}
a.card,
button.card {
  display: block;
  width: 100%;
  transition: background 0.15s;
}
a.card:hover,
button.card:hover {
  background: var(--card-hover);
}
.card.tile-list {
  padding: 4px;
}
.tile-list {
  display: flex;
  flex-direction: column;
}
.tile {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  min-height: 56px;
  text-align: start;
  transition: background 0.12s;
}
a.tile:hover,
button.tile:hover,
label.tile:hover {
  background: var(--card-hover);
}
.tile.selected {
  background: var(--primary-soft);
}
.tile.danger {
  color: var(--expense);
}
.tile.relaxed {
  padding-block: 14px;
}
.tile-leading {
  display: grid;
  place-items: center;
  flex: none;
  min-width: 28px;
  color: var(--semi);
}
.tile.danger .tile-leading {
  color: inherit;
}
.tile-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.tile-title {
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-subtitle {
  color: var(--semi);
  font-size: 0.83rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.tile-subtitle.wrap,
.tile-switch .tile-subtitle {
  white-space: normal;
}
.tile-trailing {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--semi);
  font-size: 0.9rem;
  text-align: end;
  max-width: 50%;
}
.tile-trailing .money {
  font-weight: 600;
  font-size: 0.95rem;
}
.tile-check {
  color: var(--primary);
  display: grid;
}
.tile .msr.on {
  color: var(--primary);
  font-variation-settings: "FILL" 1, "wght" 400, "GRAD" 0, "opsz" 24;
}
.tile-switch {
  cursor: pointer;
}

/* Dinero ------------------------------------------------------------------- */
.money {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.money-income {
  color: var(--income);
}
.money-expense {
  color: var(--expense);
}
.money-neutral {
  color: var(--on-surface);
}

/* Botones ------------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 20px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  transition: filter 0.15s, background 0.15s;
  flex: none;
}
.btn .msr {
  font-size: 20px;
}
.btn-primary {
  background: var(--primary);
  color: var(--on-primary);
}
.btn-tonal {
  background: var(--primary-soft);
  color: var(--primary);
}
.btn-outline {
  box-shadow: inset 0 0 0 1.5px var(--line-strong);
}
.btn-text {
  color: var(--primary);
  padding-inline: 12px;
}
.btn-danger {
  background: var(--expense);
  color: #fff;
}
.btn-primary:hover:not(:disabled),
.btn-danger:hover:not(:disabled) {
  filter: brightness(1.1);
}
.btn-tonal:hover:not(:disabled) {
  background: color-mix(in srgb, var(--primary) 22%, var(--surface));
}
.btn-outline:hover:not(:disabled),
.btn-text:hover:not(:disabled) {
  background: var(--card);
}
.btn-block {
  display: flex;
  width: 100%;
}
.btn-small {
  min-height: 34px;
  padding: 0 14px;
  font-size: 0.85rem;
}
.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  flex: none;
  transition: background 0.15s;
}
.icon-btn:hover:not(:disabled) {
  background: var(--card-hover);
}
.confirm-btn {
  background: var(--primary-soft);
  color: var(--primary);
}

/* Formularios -------------------------------------------------------------- */
.form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}
.field-label {
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--semi);
}
.field-hint {
  font-size: 0.8rem;
  color: var(--semi);
}
.field-error {
  font-size: 0.8rem;
  color: var(--expense);
}
.field.has-error .input {
  box-shadow: inset 0 0 0 2px var(--expense);
}
.input {
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line);
  transition: box-shadow 0.15s;
}
.input::placeholder {
  color: var(--semi);
  opacity: 0.8;
}
.input:focus {
  outline: none;
  box-shadow: inset 0 0 0 2px var(--primary);
}
textarea.input {
  resize: vertical;
  min-height: 96px;
}
select.input {
  appearance: none;
  padding-right: 40px;
  background-image: linear-gradient(45deg, transparent 50%, var(--semi) 50%),
    linear-gradient(135deg, var(--semi) 50%, transparent 50%);
  background-position: calc(100% - 20px) 21px, calc(100% - 14px) 21px;
  background-size: 6px 6px;
  background-repeat: no-repeat;
}
.input-amount {
  font-size: 2rem;
  font-weight: 700;
  min-height: 72px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.picker-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 56px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--card);
  box-shadow: inset 0 0 0 1px var(--line);
  text-align: start;
}
.picker-btn:hover {
  background: var(--card-hover);
}
.picker-btn .picker-value {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.picker-btn .picker-placeholder {
  color: var(--semi);
  font-weight: 400;
}

.switch {
  position: relative;
  flex: none;
  width: 48px;
  height: 28px;
}
.switch input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  width: 100%;
  height: 100%;
  z-index: 1;
}
.switch-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.2s;
}
.switch-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface);
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgb(0 0 0 / 0.3);
}
.switch input:checked + .switch-track {
  background: var(--primary);
}
.switch input:checked + .switch-track::after {
  transform: translateX(20px);
}
.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.segmented {
  display: flex;
  padding: 4px;
  gap: 4px;
  background: var(--card);
  border-radius: 999px;
  max-width: 100%;
  overflow-x: auto;
}
.segmented button {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 40px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--semi);
  white-space: nowrap;
}
.segmented button .msr {
  font-size: 20px;
}
.segmented button.active {
  background: var(--primary);
  color: var(--on-primary);
}

.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.chip {
  --chip-bg: var(--card);
  --chip-fg: var(--on-surface);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-fg);
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
}
.chip .msr {
  font-size: 18px;
}
button.chip:hover {
  filter: brightness(0.95);
}
.chip.active {
  background: var(--primary);
  color: var(--on-primary);
}
.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--card-hover);
  color: var(--semi);
  font-size: 0.72rem;
  font-weight: 500;
  max-width: 160px;
  overflow: hidden;
  white-space: nowrap;
}
.badge .msr {
  font-size: 13px;
}
.badge-pending {
  background: color-mix(in srgb, var(--warn) 18%, transparent);
  color: var(--warn);
}

/* Diálogos ----------------------------------------------------------------- */
dialog.sheet {
  border: 0;
  padding: 0;
  background: transparent;
  color: inherit;
  width: min(480px, calc(100vw - 24px));
  max-width: none;
  max-height: none;
  margin: auto;
  overflow: visible;
}
dialog.sheet.sheet-wide {
  width: min(680px, calc(100vw - 24px));
}
dialog.sheet::backdrop {
  background: var(--overlay);
}
.sheet-inner {
  display: flex;
  flex-direction: column;
  max-height: min(86dvh, 760px);
  background: var(--elevated);
  border-radius: 24px;
  box-shadow: 0 24px 60px rgb(0 0 0 / 0.3);
  overflow: hidden;
}
.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 12px 8px 22px;
  min-height: 60px;
}
.sheet-body {
  padding: 4px 22px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overscroll-behavior: contain;
}
.sheet-footer {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 18px 16px;
  border-top: 1px solid var(--line);
}
.sheet-message {
  color: var(--semi);
  white-space: pre-line;
}
.sheet-subtitle {
  margin-top: 6px;
  color: var(--semi);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.sheet-body .tile-list {
  margin-inline: -10px;
}
.pick-empty {
  padding: 20px 10px;
  text-align: center;
  color: var(--semi);
}
@media (max-width: 600px) {
  dialog.sheet,
  dialog.sheet.sheet-wide {
    width: 100vw;
    margin: auto 0 0;
  }
  .sheet-inner {
    border-radius: 24px 24px 0 0;
    max-height: 90dvh;
    padding-bottom: env(safe-area-inset-bottom);
  }
}

.toast-host {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  width: min(480px, calc(100vw - 24px));
  z-index: 100;
  pointer-events: none;
}
@media (max-width: 860px) {
  body:not(.bare) .toast-host {
    bottom: calc(var(--nav-height) + 16px + env(safe-area-inset-bottom));
  }
}
.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--on-surface);
  color: var(--surface);
  font-size: 0.9rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgb(0 0 0 / 0.25);
  animation: toast-in 0.2s ease-out;
}
.toast button {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
  flex: none;
}
.toast-error {
  background: var(--expense);
  color: #fff;
}
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

/* Selectores de icono y color --------------------------------------------- */
.icon-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.icon-group-title {
  color: var(--semi);
  font-size: 0.8rem;
  margin-top: 6px;
}
.icon-group {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}
.icon-choice {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 12px;
  background: var(--card);
}
.icon-choice:hover {
  background: var(--card-hover);
}
.icon-choice.selected {
  background: var(--primary);
  color: var(--on-primary);
}
.emoji-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.emoji-row .field {
  flex: 1;
}
.color-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
  gap: 10px;
}
.color-swatch {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 50%;
  border: 2px solid transparent;
}
.color-swatch.selected {
  border-style: solid;
}
.icon-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}
.icon-editor-preview {
  border-radius: 28px;
  position: relative;
}
.icon-editor-preview:hover {
  filter: brightness(0.96);
}

/* Barra de rango ----------------------------------------------------------- */
.range-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  background: var(--card);
  border-radius: 999px;
  padding: 2px;
  max-width: 100%;
}
.range-bar-label {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 40px;
  min-width: 0;
  padding: 0 8px;
  border-radius: 999px;
  font-weight: 600;
}
.range-bar-label span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.range-bar-label:hover {
  background: var(--card-hover);
}
.range-bar .icon-btn {
  width: 40px;
  height: 40px;
}

/* Progreso ----------------------------------------------------------------- */
.progress {
  height: 10px;
  border-radius: 999px;
  background: var(--card-hover);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--primary);
  transition: width 0.3s;
}
.progress.warn .progress-fill {
  background: var(--warn);
}
.progress.over .progress-fill {
  background: var(--expense);
}

/* Lista de transacciones --------------------------------------------------- */
.txn-list {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.txn-day {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.txn-day-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 12px;
  color: var(--semi);
  font-size: 0.85rem;
  font-weight: 500;
}
.txn-day-total {
  font-variant-numeric: tabular-nums;
}
.txn-tile.pending .tile-title,
.txn-tile.pending .money {
  opacity: 0.7;
}
.flow-summary {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.flow-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}
.flow-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 14px;
}
.flow-card .money {
  font-size: 1.15rem;
  font-weight: 700;
  white-space: normal;
  overflow-wrap: anywhere;
}
.flow-card-label {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--semi);
  font-size: 0.8rem;
  font-weight: 500;
}
.flow-card-label .msr {
  font-size: 18px;
}
.flow-summary-note {
  color: var(--semi);
  font-size: 0.8rem;
  padding: 0 4px;
}
@media (max-width: 520px) {
  .flow-cards {
    gap: 8px;
  }
  .flow-card {
    padding: 10px;
  }
  .flow-card .money {
    font-size: 0.95rem;
  }
}

/* Estados ------------------------------------------------------------------ */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 40px 16px;
  text-align: center;
}
.empty-icon {
  font-size: 56px;
  color: var(--semi);
  opacity: 0.6;
}
.empty-title {
  font-weight: 600;
  font-size: 1.05rem;
}
.empty-subtitle {
  color: var(--semi);
  max-width: 420px;
}
.empty .btn {
  margin-top: 8px;
}
.splash,
.boot-error {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
  text-align: center;
}
.splash img {
  border-radius: 18px;
}
.spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid var(--line-strong);
  border-top-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
.notice {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--warn) 14%, transparent);
  color: var(--on-surface);
  font-size: 0.88rem;
}
.notice .msr {
  color: var(--warn);
  font-size: 20px;
}
.notice.notice-error {
  background: color-mix(in srgb, var(--expense) 14%, transparent);
}
.notice.notice-error .msr {
  color: var(--expense);
}

/* Pantallas de acceso ------------------------------------------------------ */
.auth {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
}
.auth-card {
  width: min(440px, 100%);
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.auth-brand img {
  border-radius: 20px;
}
.auth-brand p {
  color: var(--semi);
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
@media print {
  .nav,
  .toast-host {
    display: none !important;
  }
  .view {
    margin: 0 !important;
  }
}

/* Fila con una acción al lado (p. ej. confirmar pendiente) */
.tile-row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 8px;
}
.tile-row > .tile {
  flex: 1;
  min-width: 0;
}
