/* styles.css — CashFlow v1. Paleta calma, tinta sobre papel, un solo acento.
   Sin sombras, sin gradientes, sin fuentes remotas. */

:root {
  --paper: #FAFAF8;
  --ink: #23221E;
  --muted: #6E6C64;
  --faint: #9A978D;
  --line: #E7E4DC;

  --entra: #2F7A57; /* ingresos */
  --neg: #B23A2E;   /* saldo negativo / rojo */
  --accent: #3B6EA5; /* micrófono / toggle activo — único acento */

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  font-weight: 400;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden; /* la página nunca scrollea horizontal */
}

button {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
}

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

.num {
  font-variant-numeric: tabular-nums;
}

/* ---- Shell / routing ------------------------------------------------------ */

.app {
  max-width: 560px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.view {
  display: none;
  flex: 1;
  flex-direction: column;
}

.view.active {
  display: flex;
}

/* La grilla usa todo el ancho, no el contenedor angosto. */
body.route-grilla .app {
  max-width: none;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  border-bottom: 0.5px solid var(--line);
  min-height: 52px;
}

.topbar .iconbtn {
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  padding: 4px 6px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pill {
  color: var(--ink);
  font-weight: 500;
  padding: 4px 6px;
}

.pill .caret {
  color: var(--faint);
  margin-left: 4px;
}

.pad {
  padding: 18px;
}

/* ---- Menú simple (caja/billetera/mes) ------------------------------------- */

.menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(35, 34, 30, 0.18);
  display: none;
  z-index: 20;
}

.menu-backdrop.open {
  display: block;
}

.menu {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 560px;
  background: var(--paper);
  border-top: 0.5px solid var(--line);
  border-left: 0.5px solid var(--line);
  border-right: 0.5px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 8px 0;
}

.menu .menu-title {
  color: var(--muted);
  font-size: 14px;
  padding: 10px 20px 6px;
}

.menu .menu-item {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 20px;
  font-size: 17px;
}

.menu .menu-item.selected {
  color: var(--accent);
  font-weight: 500;
}

/* ---- Vista Registrar ------------------------------------------------------ */

.reg-context {
  padding: 8px 18px 0;
}

.reg-context .ctx {
  color: var(--ink);
  font-weight: 500;
}

.reg-context .caret {
  color: var(--faint);
  margin-left: 4px;
}

.toggle {
  display: inline-flex;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  margin: 18px 18px 0;
}

.toggle button {
  padding: 10px 22px;
  color: var(--muted);
  font-size: 16px;
}

.toggle button.active {
  color: #fff;
  background: var(--accent);
  font-weight: 500;
}

.amount-wrap {
  padding: 26px 18px 6px;
  display: flex;
  align-items: baseline;
  justify-content: center;
}

.amount-sign {
  font-size: 56px;
  font-weight: 500;
  letter-spacing: -1px;
  color: var(--ink);
}

.amount-input {
  flex: 0 1 auto;
  width: 8ch;
  border: none;
  outline: none;
  background: none;
  text-align: left;
  font-size: 56px;
  font-weight: 500;
  letter-spacing: -1px;
}

.amount-input::placeholder {
  color: var(--faint);
  font-weight: 400;
}

.dequefue {
  position: relative;
  padding: 22px 18px 0;
}

.dequefue label {
  display: block;
  color: var(--muted);
  font-size: 15px;
  margin-bottom: 8px;
}

.dequefue .field {
  display: flex;
  align-items: center;
  gap: 8px;
  border-bottom: 0.5px solid var(--line);
}

.dequefue input {
  flex: 1;
  border: none;
  outline: none;
  background: none;
  font-size: 19px;
  padding: 8px 0;
}

.micbtn-inline {
  color: var(--accent);
  font-size: 20px;
  padding: 6px;
}

.micbtn-inline.listening {
  color: var(--neg);
}

.suggestions {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  border: 0.5px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  display: none;
}

.suggestions.open {
  display: block;
}

.suggestions li {
  padding: 11px 14px;
  font-size: 16px;
  border-bottom: 0.5px solid var(--line);
}

.suggestions li:last-child {
  border-bottom: none;
}

.suggestions li.create {
  color: var(--accent);
}

.reg-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 34px 18px 10px;
}

.bigbtn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: 0.5px solid var(--line);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
}

.bigbtn.mic {
  color: var(--accent);
}

.bigbtn.mic.listening {
  color: #fff;
  background: var(--neg);
  border-color: var(--neg);
}

.bigbtn.confirm {
  color: #fff;
  background: var(--ink);
  border-color: var(--ink);
}

.reg-footer {
  margin-top: auto;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
  padding: 18px;
}

.saved-toast {
  text-align: center;
  color: var(--entra);
  font-size: 15px;
  min-height: 20px;
  padding-top: 6px;
}

.saved-toast.hint {
  color: var(--muted);
}

/* ---- Vista Home ----------------------------------------------------------- */

.hero {
  text-align: center;
  padding: 48px 18px 40px;
}

.hero .hero-label {
  color: var(--muted);
  font-size: 16px;
  margin-bottom: 10px;
}

.hero .hero-num {
  font-size: 52px;
  font-weight: 500;
  letter-spacing: -1px;
}

.hero .hero-num.neg {
  color: var(--neg);
}

.branch {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  width: 100%;
  padding: 18px 18px;
  border-top: 0.5px solid var(--line);
  font-size: 19px;
}

.branch:last-of-type {
  border-bottom: 0.5px solid var(--line);
}

.branch .b-label {
  font-weight: 500;
}

.branch.ingresos .b-amount {
  color: var(--entra);
}

.branch .b-amount {
  font-weight: 500;
}

.branch .chev {
  color: var(--faint);
  margin-left: 8px;
}

.home-actions {
  padding: 30px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.btn-registrar {
  background: var(--accent);
  color: #fff;
  padding: 14px 26px;
  border-radius: 12px;
  font-size: 18px;
  font-weight: 500;
}

.link-mes {
  color: var(--muted);
  font-size: 17px;
}

/* Drill (detalle de Ingresos/Salidas) */
.drill {
  border-top: 0.5px solid var(--line);
}

.drill-back {
  color: var(--muted);
  padding: 14px 18px;
  font-size: 16px;
  display: block;
}

.drill-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 13px 18px;
  border-top: 0.5px solid var(--line);
  font-size: 17px;
  width: 100%;
  text-align: left;
}

.drill-row.group {
  font-weight: 500;
}

.drill-row.child {
  padding-left: 34px;
  color: var(--muted);
}

.drill-row .dr-amount.ingreso {
  color: var(--entra);
}

.drill-row .chev {
  color: var(--faint);
  margin-left: 8px;
}

/* ---- Vista Grilla --------------------------------------------------------- */

.grid-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table.grid {
  border-collapse: collapse;
  font-size: 13px;
  white-space: nowrap;
}

table.grid th,
table.grid td {
  border-bottom: 0.5px solid var(--line);
  padding: 7px 8px;
  text-align: right;
  font-weight: 400;
}

table.grid thead th {
  color: var(--muted);
  font-weight: 500;
  position: sticky;
  top: 0;
  background: var(--paper);
  border-bottom: 0.5px solid var(--line);
}

table.grid th.col-item,
table.grid td.col-item {
  text-align: left;
  position: sticky;
  left: 0;
  background: var(--paper);
  min-width: 160px;
  z-index: 2;
}

table.grid thead th.col-item {
  z-index: 3;
}

table.grid td.col-plan,
table.grid th.col-plan {
  color: var(--faint);
  min-width: 76px;
}

table.grid td.col-real,
table.grid th.col-real {
  min-width: 76px;
}

table.grid td.day {
  min-width: 56px;
  color: var(--ink);
}

table.grid td.day.plan-val {
  color: var(--faint);
}

table.grid td.day.real-val {
  color: var(--ink);
}

table.grid td.day.real-val.ingreso {
  color: var(--entra);
}

table.grid tr.cashflow td {
  font-weight: 500;
}

table.grid tr.cashflow td.day.neg {
  color: var(--neg);
}

table.grid tr.group-header td {
  font-weight: 500;
  background: var(--paper);
}

table.grid tr.group-header td.col-item {
  cursor: pointer;
}

table.grid .chevron {
  display: inline-block;
  width: 14px;
  color: var(--faint);
}

table.grid tr.item-row td.col-item {
  cursor: pointer;
}

table.grid tr.atom-row td.col-item {
  padding-left: 30px;
  color: var(--muted);
}

table.grid td.col-item .indent {
  padding-left: 16px;
  display: inline-block;
}

table.grid td.day.editing {
  padding: 0;
}

.cell-input {
  width: 100%;
  min-width: 44px;
  border: 0.5px solid var(--accent);
  outline: none;
  background: var(--paper);
  text-align: right;
  font-size: 13px;
  padding: 6px;
  font-variant-numeric: tabular-nums;
}

/* ---- Editor de celda (previsto/real) -------------------------------------- */

.cell-editor {
  position: fixed;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 420px;
  background: var(--paper);
  border-top: 0.5px solid var(--line);
  border-left: 0.5px solid var(--line);
  border-right: 0.5px solid var(--line);
  border-radius: 14px 14px 0 0;
  padding: 16px 20px 24px;
  display: none;
  z-index: 30;
}

.cell-editor.open {
  display: block;
}

.cell-editor .ce-title {
  color: var(--muted);
  font-size: 14px;
  margin-bottom: 12px;
}

.cell-editor .ce-amount-wrap {
  display: flex;
  align-items: baseline;
  justify-content: center;
  border-bottom: 0.5px solid var(--line);
  padding: 6px 0;
}

.cell-editor .ce-amount-sign {
  font-size: 34px;
  font-weight: 500;
  color: var(--ink);
}

.cell-editor .ce-amount {
  width: 6ch;
  border: none;
  outline: none;
  background: none;
  font-size: 34px;
  font-weight: 500;
  text-align: left;
  padding: 0;
}

.cell-editor .ce-toggle {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}

.cell-editor .ce-toggle .toggle {
  margin: 0;
}

.cell-editor .ce-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.cell-editor .ce-actions button {
  flex: 1;
  padding: 12px;
  border-radius: 10px;
  border: 0.5px solid var(--line);
  font-size: 16px;
}

.cell-editor .ce-save {
  background: var(--entra);
  color: #fff;
  border-color: var(--entra);
  font-weight: 500;
}

.cell-editor .ce-clear {
  color: var(--neg);
}

/* ---- Discreto: limpiar datos de ejemplo ----------------------------------- */

.footer-tools {
  text-align: center;
  padding: 24px 18px 40px;
}

.footer-tools button {
  color: var(--faint);
  font-size: 13px;
}
