/* =========================================================================
   Gastos del Hogar — sistema visual
   Display: Fraunces (serif con carácter, para montos y títulos)
   Body/UI: Outfit (sans redondeada, cálida)
   Paleta "papel cálido": fondo crema, teal como primario, coral/lavanda/ámbar
   ========================================================================= */

:root {
  --paper:      #FBF7F0;
  --paper-2:    #F4EEE3;
  --surface:    #FFFFFF;
  --ink:        #233038;
  --ink-soft:   #5C6B73;
  --ink-faint:  #94A3A8;
  --line:       #E8DFD0;

  --teal:       #0EA5A4;
  --teal-soft:  #CFF3F0;
  --coral:      #FB7185;
  --coral-soft: #FFE0E3;
  --lavender:   #A78BFA;
  --amber:      #F59E0B;
  --mint:       #34D399;

  --shadow-sm: 0 1px 2px rgba(35,48,56,.05), 0 1px 3px rgba(35,48,56,.06);
  --shadow-md: 0 8px 24px rgba(35,48,56,.08);
  --shadow-lg: 0 18px 48px rgba(35,48,56,.12);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 24px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: "Outfit", system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(1200px 600px at 100% -10%, rgba(167,139,250,.10), transparent 60%),
    radial-gradient(900px 500px at -10% 110%, rgba(14,165,164,.10), transparent 55%),
    var(--paper);
  min-height: 100vh;
  font-size: 16px;
  line-height: 1.5;
}

h1, h2, h3 { font-family: "Fraunces", Georgia, serif; margin: 0; font-weight: 600; letter-spacing: -.01em; }

a { color: inherit; }

/* ---------------------------------------------------------------- layout */
.shell { max-width: 1120px; margin: 0 auto; padding: 0 22px 80px; }

.topbar {
  display: flex; align-items: center; gap: 18px;
  padding: 22px 0 18px;
  flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; margin-right: auto; }
.brand .glyph {
  width: 42px; height: 42px; border-radius: 13px;
  display: grid; place-items: center; font-size: 22px;
  background: linear-gradient(150deg, var(--teal), var(--mint));
  box-shadow: var(--shadow-sm);
}
.brand b { font-family: "Fraunces", serif; font-size: 1.35rem; font-weight: 600; }
.brand small { display: block; color: var(--ink-soft); font-size: .78rem; margin-top: -2px; }

.nav { display: flex; gap: 4px; background: var(--surface); padding: 5px; border-radius: 999px;
       box-shadow: var(--shadow-sm); border: 1px solid var(--line); }
.nav a {
  text-decoration: none; padding: 9px 18px; border-radius: 999px;
  font-weight: 500; color: var(--ink-soft); font-size: .94rem; transition: .18s;
}
.nav a:hover { color: var(--ink); }
.nav a.active { background: var(--ink); color: #fff; }

/* ------------------------------------------------------------- month pill */
.month-bar { display: flex; align-items: center; gap: 10px; margin: 8px 0 26px; }
.month-pill {
  display: inline-flex; align-items: center; gap: 14px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 999px; padding: 6px 8px; box-shadow: var(--shadow-sm);
}
.month-pill .navbtn {
  width: 34px; height: 34px; border-radius: 999px; cursor: pointer;
  background: var(--paper-2); color: var(--ink); font-size: 1.2rem; line-height: 1;
  text-decoration: none; display: grid; place-items: center; transition: .15s;
}
.month-pill .navbtn:hover { background: var(--teal-soft); }
.month-pill .label {
  font-family: "Fraunces", serif; font-size: 1.05rem; min-width: 168px;
  text-align: center; font-weight: 600;
}
.month-bar .hint { color: var(--ink-faint); font-size: .85rem; }

/* ---------------------------------------------------------------- cards */
.grid { display: grid; gap: 18px; }
/* Las tarjetas de stats se acomodan solas: 3 si entran, si no 2, y en celular 1. */
.stats { grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); }
.cols-2 { grid-template-columns: 1.15fr .85fr; }

.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-lg); padding: 22px; box-shadow: var(--shadow-sm);
}
.card h2 { font-size: 1.12rem; margin-bottom: 4px; }
.card .sub { color: var(--ink-soft); font-size: .85rem; margin-bottom: 16px; }

.stat .eyebrow {
  font-size: .72rem; text-transform: uppercase; letter-spacing: .12em;
  color: var(--ink-faint); font-weight: 600;
}
.stat .amount {
  font-family: "Fraunces", serif; font-size: 2rem; font-weight: 600;
  margin-top: 6px; line-height: 1.1; letter-spacing: -.02em;
}
.stat .amount.sm { font-size: 1.6rem; }
.stat .meta { color: var(--ink-soft); font-size: .82rem; margin-top: 6px; }
.stat.accent-teal   { border-top: 3px solid var(--teal); }
.stat.accent-coral  { border-top: 3px solid var(--coral); }
.stat.accent-amber  { border-top: 3px solid var(--amber); }
.stat.accent-lav    { border-top: 3px solid var(--lavender); }

/* --------------------------------------------------------- signature: saldo */
.saldo {
  background: linear-gradient(150deg, #20303a, #2c4350);
  color: #fff; border: 0;
}
.saldo .eyebrow { color: rgba(255,255,255,.6); }
.saldo .flow {
  display: flex; align-items: center; gap: 14px; margin-top: 14px; flex-wrap: wrap;
}
.saldo .who {
  display: flex; align-items: center; gap: 9px; font-weight: 500;
}
.saldo .dot { width: 12px; height: 12px; border-radius: 999px; }
.saldo .arrow { font-size: 1.4rem; color: var(--mint); }
.saldo .amount { font-family: "Fraunces", serif; font-size: 1.7rem; font-weight: 600; margin-left: auto; }
.saldo.settled .amount { color: var(--mint); font-size: 1.3rem; }

/* --------------------------------------------------------------- charts */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap.donut { height: 240px; }

.legend { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 9px; }
.legend li { display: flex; align-items: center; gap: 10px; font-size: .9rem; }
.legend .swatch { width: 11px; height: 11px; border-radius: 4px; flex: none; }
.legend .name { color: var(--ink-soft); }
.legend .val { margin-left: auto; font-variant-numeric: tabular-nums; font-weight: 500; }

/* ---------------------------------------------------------------- table */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--ink-faint); font-weight: 600; padding: 8px 12px; border-bottom: 1px solid var(--line);
}
.table td { padding: 12px; border-bottom: 1px solid var(--paper-2); font-size: .92rem; vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table td.num { text-align: right; font-variant-numeric: tabular-nums; font-weight: 500; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 3px 10px; border-radius: 999px; font-size: .82rem; font-weight: 500;
  white-space: nowrap;
}
.tag-cuota { font-size: .72rem; color: var(--ink-faint); margin-left: 6px; }
.tag-own {
  font-size: .72rem; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: #F59E0B22; color: #B45309; white-space: nowrap; font-weight: 600;
}
.tag-fijo {
  font-size: .72rem; margin-left: 6px; padding: 1px 8px; border-radius: 999px;
  background: #0EA5A422; color: #0E7490; white-space: nowrap; font-weight: 600;
}
.row-paused { opacity: .5; }
.check { display: inline-flex; align-items: center; gap: 7px; font-size: .92rem; color: var(--ink); cursor: pointer; }

.icon-btn {
  border: 0; background: transparent; cursor: pointer; padding: 6px;
  border-radius: 8px; color: var(--ink-faint); font-size: .95rem; transition: .15s;
}
.icon-btn:hover { background: var(--paper-2); color: var(--coral); }

/* ----------------------------------------------------------------- forms */
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 14px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field.full { grid-column: 1 / -1; }
label { font-size: .82rem; font-weight: 500; color: var(--ink-soft); }
input, select {
  font-family: inherit; font-size: .95rem; padding: 11px 13px;
  border: 1px solid var(--line); border-radius: var(--r-sm); background: var(--paper);
  color: var(--ink); transition: .15s; width: 100%;
}
input:focus, select:focus {
  outline: none; border-color: var(--teal); background: #fff;
  box-shadow: 0 0 0 3px var(--teal-soft);
}
.hint-inline { font-size: .78rem; color: var(--ink-faint); }

.btn {
  font-family: inherit; font-weight: 600; font-size: .95rem; cursor: pointer;
  border: 0; border-radius: var(--r-sm); padding: 12px 22px; transition: .15s;
}
.btn-primary { background: var(--ink); color: #fff; }
.btn-primary:hover { background: #0f1c24; transform: translateY(-1px); }
.btn-ghost { background: var(--paper-2); color: var(--ink); }
.btn-ghost:hover { background: var(--line); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-sm { padding: 7px 14px; font-size: .85rem; }

/* --------------------------------------------------------------- login/user */
.user-box { display: inline-flex; align-items: center; gap: 10px; margin-left: auto; }
.user-name { font-size: .9rem; font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { width: 100%; max-width: 380px; }
.login-error {
  background: var(--coral-soft); color: #9F1239; border-radius: var(--r-sm);
  padding: 10px 14px; font-size: .88rem; margin-bottom: 16px; text-align: center;
}

/* --------------------------------------------------------- category cards */
.cat-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px; }
.cat-item {
  display: flex; align-items: center; gap: 14px; padding: 16px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md);
  box-shadow: var(--shadow-sm);
}
.cat-emoji { width: 46px; height: 46px; border-radius: 13px; display: grid; place-items: center; font-size: 22px; flex: none; }
.cat-item .nm { font-weight: 600; }
.cat-item .actions { margin-left: auto; display: flex; gap: 2px; }

.payer-chips { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 14px; }
.payer-chip { display: inline-flex; align-items: center; gap: 8px; padding: 7px 12px; border-radius: 999px;
              background: var(--paper); border: 1px solid var(--line); font-weight: 500; font-size: .9rem; }

/* ---------------------------------------------------------------- misc */
.section-title { display: flex; align-items: baseline; gap: 12px; margin: 30px 0 16px; }
.section-title h2 { font-size: 1.3rem; }
.section-title .sub { color: var(--ink-soft); font-size: .88rem; }

.empty { text-align: center; color: var(--ink-faint); padding: 38px 16px; }
.empty .big { font-size: 2rem; margin-bottom: 8px; }

/* ----------------------------------------------------------- SVG charts */
.donut-wrap { display: grid; place-items: center; padding: 6px 0 2px; }
.donut-svg { width: 200px; height: 200px; }
.donut-cap { fill: var(--ink-faint); font: 600 9px "Outfit", sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.donut-mid { fill: var(--ink); font: 600 17px "Fraunces", serif; }

.bars-wrap { margin-top: 6px; }
.bars-svg { width: 100%; height: auto; display: block; }
.bar-val { fill: var(--ink-soft); font: 600 11px "Outfit", sans-serif; }
.bar-lab { fill: var(--ink-faint); font: 500 11px "Outfit", sans-serif; }

/* ------------------------------------------------------- inline forms */
.inline-form { display: inline; margin: 0; }
.del-all { font-size: .72rem; color: var(--ink-faint); cursor: pointer; margin-right: 4px; }
.del-all input { width: auto; }

.table tfoot .foot { font-weight: 600; border-top: 2px solid var(--line); border-bottom: 0; padding-top: 12px; }

/* --------------------------------------------------------- category cards */
.cat-item.editing-now { border-color: var(--teal); box-shadow: 0 0 0 3px var(--teal-soft); }
.cat-list-card { padding: 18px; }

/* ----------------------------------------- radio pickers (sin JS) */
.pick { display: flex; flex-wrap: wrap; gap: 7px; }
.pick .opt { cursor: pointer; line-height: 0; }
.pick .opt input { position: absolute; opacity: 0; width: 0; height: 0; }
.opt-emoji {
  display: grid; place-items: center; width: 40px; height: 40px; font-size: 1.2rem;
  border: 1px solid var(--line); background: var(--paper); border-radius: 9px; transition: .12s;
}
.opt-color {
  display: block; width: 30px; height: 30px; border-radius: 999px;
  border: 2px solid transparent; transition: .12s;
}
.pick .opt input:checked + .opt-emoji { border-color: var(--teal); background: var(--teal-soft); }
.pick .opt input:checked + .opt-color { border-color: var(--ink); transform: scale(1.08); }
.pick .opt input:focus-visible + .opt-emoji,
.pick .opt input:focus-visible + .opt-color { outline: 2px solid var(--teal); outline-offset: 2px; }

/* --------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .cols-2 { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .form-grid { grid-template-columns: 1fr; }
  .topbar { gap: 12px; }
  .nav { width: 100%; justify-content: space-between; flex-wrap: wrap; }
  .nav a { padding: 9px 12px; font-size: .88rem; }
  .user-box { margin-left: 0; }
  .month-pill .label { min-width: 120px; font-size: .95rem; }
  .table .hide-sm { display: none; }
  .table th, .table td { padding-left: 8px; padding-right: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
