/* ===========================================================
   gastaker — Monarch-style: summary band + full-width table.
   white mode, ink + categorical accents. ledger, no cards.
   =========================================================== */

:root {
  --bg: #ffffff;
  --ink: #0b0b0c;
  --ink-2: #6b6b72;
  --ink-3: #a4a4ac;
  --ink-4: #c9c9d0;

  --line: rgba(11, 11, 12, 0.09);
  --line-soft: rgba(11, 11, 12, 0.05);
  --hover: rgba(11, 11, 12, 0.035);
  --press: rgba(11, 11, 12, 0.06);

  /* categorical accents (tech) — fuente de verdad en app.js (CATS) */
  --c-comida: #ff6b35;
  --c-super: #06b6d4;
  --c-transporte: #4f46e5;
  --c-servicios: #a855f7;
  --c-suscripciones: #ec4899;
  --c-salud: #10b981;
  --c-otros: #64748b;

  /* moneda extranjera (USD) — color propio para distinguirla de los pesos */
  --usd: #2563eb;

  --radius: 9px;
  --radius-sm: 6px;
  --maxw: 1060px;
  --cols: 116px 1fr 184px 150px; /* fecha · comercio · categoría · monto */
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
html {
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body {
  font-family: "Geist", -apple-system, system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 14px;
  line-height: 1.5;
  background-image: radial-gradient(120% 45% at 50% -10%, rgba(11, 11, 12, 0.02), transparent 60%);
  min-height: 100vh;
}

.hidden {
  display: none !important;
}
.muted {
  color: var(--ink-3);
}

.wordmark {
  font-weight: 600;
  letter-spacing: -0.03em;
}
.wordmark .caret {
  color: var(--ink-4);
  font-weight: 400;
}
.wordmark.sm {
  font-size: 15px;
}

.overline {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ===========================================================
   LOGIN
   =========================================================== */

.login {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
.login-form {
  width: 100%;
  max-width: 320px;
  text-align: center;
  animation: rise 0.5s var(--ease) both;
}
.login .wordmark {
  font-size: 34px;
  letter-spacing: -0.045em;
}
.login-sub {
  color: var(--ink-3);
  font-size: 14px;
  margin-top: 8px;
  margin-bottom: 36px;
}
.field {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 4px 4px 16px;
  transition: border-color 0.18s var(--ease), box-shadow 0.18s var(--ease);
}
.field:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11, 11, 12, 0.06);
}
.field input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font: inherit;
  color: var(--ink);
  padding: 10px 0;
}
.field input::placeholder {
  color: var(--ink-3);
}
.field button {
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--ink);
  color: #fff;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.15s var(--ease), opacity 0.15s var(--ease);
}
.field button:hover {
  transform: translateX(2px);
}
.login-error {
  margin-top: 14px;
  font-size: 13px;
  color: #ff6b35;
}

/* ===========================================================
   SHELL + TOPBAR
   =========================================================== */

.app {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 0 32px 96px;
  animation: fade 0.4s var(--ease) both;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  background: rgba(255, 255, 255, 0.82);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line-soft);
  z-index: 20;
}
.monthnav {
  display: flex;
  align-items: center;
  gap: 2px;
}
.month-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  min-width: 104px;
  text-align: center;
  text-transform: capitalize;
  font-variant-numeric: tabular-nums;
}
.step {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: none;
  background: none;
  color: var(--ink-2);
  font-size: 17px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}
.step:hover {
  background: var(--hover);
  color: var(--ink);
}

/* ===========================================================
   SUMMARY BAND (total · proportion bar · horizontal legend)
   =========================================================== */

.summary {
  padding: 44px 0 32px;
}
.total {
  font-size: 48px;
  font-weight: 600;
  letter-spacing: -0.04em;
  line-height: 1;
  margin-top: 12px;
  font-variant-numeric: tabular-nums;
}
.total .cents {
  color: var(--ink-3);
  font-weight: 500;
}
/* total en dólares: número más chico que el de pesos, sin pill ni label.
   El prefijo "U$S" ya indica que son dólares; el color lo refuerza. */
.total-usd {
  margin-top: 8px;
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 28px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.025em;
  font-variant-numeric: tabular-nums;
}
.total-usd .cents {
  color: var(--ink-3);
}

/* montos en dólares en la tabla: en el color de moneda extranjera */
.row-amount.usd {
  color: var(--usd);
}
.row-amount.usd .cents {
  color: var(--usd);
  opacity: 0.55;
}

.bar {
  display: flex;
  gap: 3px;
  height: 10px;
  margin: 28px 0 18px;
}
.bar span {
  height: 100%;
  border-radius: 3px;
  width: 0;
  transition: width 0.7s var(--ease);
}

.legend {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 10px 26px;
}
.legend li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
}
.legend .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}
.legend .lg-name {
  color: var(--ink-2);
}
.legend .lg-amount {
  color: var(--ink);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* ===========================================================
   MOVIMIENTOS (full-width table)
   =========================================================== */

.ledger-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-top: 1px solid var(--line);
  padding-top: 28px;
}
.ledger-head-left {
  display: flex;
  align-items: baseline;
  gap: 10px;
}
.movs-count {
  font-size: 12px;
  color: var(--ink-3);
  font-variant-numeric: tabular-nums;
}

/* dropdown de filtro por categoría (estilo Lunch Money / Mercury) */
.cat-filter {
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  background-color: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 32px 7px 12px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 10 10'%3E%3Cpath d='M2 4l3 3 3-3' stroke='%23a4a4ac' stroke-width='1.4' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  transition: border-color 0.15s var(--ease), box-shadow 0.15s var(--ease);
}
.cat-filter:hover {
  border-color: var(--ink-3);
}
.cat-filter:focus {
  outline: none;
  border-color: var(--ink);
  box-shadow: 0 0 0 3px rgba(11, 11, 12, 0.06);
}

.thead {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 20px;
  padding: 10px 10px;
  border-bottom: 1px solid var(--line);
}
.thead span {
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-3);
}
.thead .right {
  text-align: right;
}

.row {
  display: grid;
  grid-template-columns: var(--cols);
  gap: 20px;
  align-items: center;
  padding: 13px 10px;
  margin: 0;
  border-radius: var(--radius-sm);
  border-bottom: 1px solid var(--line-soft);
  transition: background 0.13s var(--ease);
  animation: rise 0.45s var(--ease) both;
}
.row:hover {
  background: var(--hover);
}
.row:last-child {
  border-bottom: none;
}

/* fecha */
.cell-date {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 12.5px;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
  display: flex;
  gap: 8px;
  white-space: nowrap;
}
.cell-date .d-time {
  color: var(--ink-4);
}

/* comercio */
.cell-merchant {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}
.row-merchant {
  font-weight: 500;
  letter-spacing: -0.005em;
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.row-card {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 11px;
  color: var(--ink-4);
  flex: none;
}

/* categoría — único color del chrome, e interactivo */
.cat {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: none;
  background: none;
  font: inherit;
  font-size: 12.5px;
  color: var(--ink-2);
  padding: 5px 9px;
  margin-left: -9px;
  border-radius: 100px;
  cursor: pointer;
  transition: background 0.13s var(--ease);
  white-space: nowrap;
}
.cat:hover {
  background: var(--press);
}
.cat .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex: none;
}

/* monto */
.row-amount {
  font-family: "Geist Mono", ui-monospace, monospace;
  font-size: 13.5px;
  font-weight: 500;
  letter-spacing: -0.01em;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}
.row-amount .cents {
  color: var(--ink-3);
}
/* anulación / devolución: monto negativo, en verde "crédito" */
.row-amount.refund {
  color: #16a34a;
}
.row-amount.refund .cents {
  color: #16a34a;
  opacity: 0.6;
}

/* ===========================================================
   CATEGORY POPOVER
   =========================================================== */

.catmenu {
  position: fixed;
  z-index: 50;
  min-width: 184px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px;
  box-shadow:
    0 1px 2px rgba(11, 11, 12, 0.06),
    0 12px 32px -8px rgba(11, 11, 12, 0.18);
  animation: pop 0.14s var(--ease) both;
  transform-origin: top left;
}
.catmenu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: none;
  background: none;
  font: inherit;
  font-size: 13px;
  color: var(--ink);
  text-align: left;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.1s var(--ease);
}
.catmenu button:hover {
  background: var(--hover);
}
.catmenu button .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex: none;
}
.catmenu button .check {
  margin-left: auto;
  color: var(--ink-3);
  font-size: 12px;
  opacity: 0;
}
.catmenu button[aria-current="true"] .check {
  opacity: 1;
}

/* ===========================================================
   EMPTY STATE
   =========================================================== */

.empty {
  text-align: center;
  padding: 64px 0;
  color: var(--ink-2);
}
.empty-mark {
  display: block;
  font-size: 30px;
  color: var(--ink-4);
  margin-bottom: 16px;
  font-weight: 300;
}
.empty p {
  font-size: 14px;
  line-height: 1.7;
}

/* ===========================================================
   MOTION
   =========================================================== */

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fade {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes pop {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(-2px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
@media (prefers-reduced-motion: reduce) {
  *,
  .bar span {
    animation: none !important;
    transition: none !important;
  }
}

/* ===========================================================
   MOBILE — la tabla colapsa a filas apiladas
   =========================================================== */

@media (max-width: 620px) {
  .app {
    padding: 0 18px 80px;
  }
  .total {
    font-size: 40px;
  }
  .thead {
    display: none;
  }
  .row {
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "merchant amount"
      "meta     meta";
    gap: 6px 16px;
    padding: 14px 8px;
  }
  .cell-merchant {
    grid-area: merchant;
  }
  .row-amount {
    grid-area: amount;
  }
  .cell-date {
    grid-area: meta;
    order: 2;
  }
  .cat {
    grid-area: meta;
    justify-self: start;
  }
  /* en mobile: fecha + categoría comparten la fila inferior */
  .row {
    grid-template-areas:
      "merchant amount"
      "cat      date";
  }
  .cell-date {
    grid-area: date;
    justify-self: end;
    align-self: center;
  }
  .cat {
    grid-area: cat;
    margin-left: -9px;
  }
}
