/* Kachingot — entregas 1 y 2 */
:root {
  --ink: #1B2A4A;
  --ink-2: #2B3E66;
  --gold: #F5B700;
  --gold-deep: #C98F00;
  --mint: #1FA971;
  --amber: #E9822B;
  --coral: #D9434A;
  --paper: #F4F6FA;
  --surface: #FFFFFF;
  --line: #D8DFEA;
  --text: #16213A;
  --muted: #5A6A82;
  --focus: 0 0 0 3px rgba(245, 183, 0, .55);
  --display: "Bricolage Grotesque", "Avenir Next", "Segoe UI", system-ui, sans-serif;
  --body: "Figtree", "Segoe UI", system-ui, -apple-system, sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0E1628;
    --surface: #16213A;
    --line: #2A3A5C;
    --text: #E7EDF7;
    --muted: #9AA9C2;
    --ink-2: #22355C;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--text);
  font: 400 1rem/1.55 var(--body);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
h1, h2, h3 { font-family: var(--display); font-weight: 800; line-height: 1.1; letter-spacing: -0.01em; margin: 0 0 .5em; }
h1 { font-size: clamp(1.75rem, 4vw, 2.4rem); }
h2 { font-size: 1.25rem; font-weight: 600; }
p { margin: 0 0 1em; }
a { color: inherit; text-underline-offset: 3px; }
:focus-visible { outline: none; box-shadow: var(--focus); border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.muted { color: var(--muted); }
.lead { color: var(--muted); font-size: 1.05rem; max-width: 60ch; }

/* Barra superior */
.topbar {
  display: flex; align-items: center; gap: 1rem; flex-wrap: wrap;
  padding: calc(.75rem + env(safe-area-inset-top, 0px)) clamp(1rem, 4vw, 2rem) .75rem;
  background: var(--ink); color: #fff;
}
.brand { display: inline-flex; align-items: center; gap: .55rem; text-decoration: none; font-family: var(--display); font-weight: 800; font-size: 1.25rem; }
.brand-mark { width: 34px; height: 34px; flex: none; }
.nav { display: flex; gap: .25rem; align-items: center; margin-left: auto; overflow-x: auto; scrollbar-width: none; }
.nav a, .nav .link { color: rgba(255,255,255,.78); text-decoration: none; padding: .4rem .7rem; border-radius: 999px; white-space: nowrap; font: 500 .95rem var(--body); }
.nav a:hover, .nav .link:hover { color: #fff; background: rgba(255,255,255,.08); }
.nav a[aria-current="page"] { color: var(--ink); background: var(--gold); }
.inline { display: inline; margin: 0; }
.lang { display: inline-flex; border: 1px solid currentColor; border-radius: 999px; overflow: hidden; font-size: .8rem; opacity: .9; }
.lang a { padding: .2rem .55rem; text-decoration: none; }
.lang a.is-active { background: var(--gold); color: var(--ink); font-weight: 600; }
.topbar .lang { color: rgba(255,255,255,.7); }
.household-strip {
  display: flex; gap: .75rem; align-items: center; justify-content: space-between;
  padding: .45rem clamp(1rem, 4vw, 2rem); background: var(--ink-2); color: #fff; font-size: .9rem;
}
.role-tag { display: inline-block; padding: .1rem .55rem; border-radius: 999px; background: rgba(245,183,0,.18); color: var(--gold-deep); font-size: .8rem; font-weight: 600; }
.household-strip .role-tag { color: var(--gold); }

/* Contenido */
.wrap { width: 100%; max-width: 920px; margin: 0 auto; padding: clamp(1.25rem, 4vw, 2.5rem) clamp(1rem, 4vw, 2rem); flex: 1; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: clamp(1.1rem, 3vw, 1.6rem); margin-bottom: 1.5rem; }
.split { display: grid; gap: 1.5rem; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); align-items: start; }
.split .panel { margin: 0; }
.foot { text-align: center; color: var(--muted); font-size: .8rem; padding: 1.5rem 1rem; }

/* Portada */
.hero {
  display: flex; align-items: center; justify-content: space-between; gap: 1.5rem;
  background: var(--ink); color: #fff; border-radius: 20px; padding: clamp(1.4rem, 5vw, 2.5rem); margin-bottom: 1.75rem; overflow: hidden;
}
.hero h1 { font-size: clamp(2rem, 6vw, 3.2rem); color: #fff; }
.hero p { color: rgba(255,255,255,.8); margin: 0; max-width: 46ch; }
.hero-coin { width: clamp(84px, 18vw, 140px); height: auto; flex: none; animation: coin-in .9s cubic-bezier(.2,.8,.2,1) both; }
@keyframes coin-in { from { transform: translateY(-40px) rotate(-25deg); opacity: 0; } 60% { transform: translateY(6px) rotate(6deg); opacity: 1; } to { transform: none; } }
.roadmap { margin: 0; padding-left: 1.4rem; }
.roadmap li { padding: .3rem 0; }
.roadmap li::marker { font-family: var(--display); font-weight: 800; color: var(--gold-deep); }
.plain { list-style: none; margin: 0; padding: 0; }
.hh-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-top: 1px solid var(--line); }
.hh-row:first-child { border-top: 0; }

/* Formularios */
label { display: block; font-weight: 600; font-size: .92rem; margin: 1rem 0 .35rem; }
input, select {
  width: 100%; font: inherit; color: var(--text); background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 10px; padding: .7rem .85rem; min-height: 46px;
}
input:focus, select:focus { border-color: var(--gold-deep); outline: none; box-shadow: var(--focus); }
input:disabled { opacity: .65; }
.row { display: flex; gap: .75rem; }
.row .grow { flex: 1; min-width: 0; }
.row .narrow { width: 7.5rem; }
.hint { color: var(--muted); font-size: .85rem; margin: .35rem 0 0; }
.field-error { color: var(--coral); font-size: .88rem; font-weight: 500; margin: .35rem 0 0; }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 400; }
.check input { width: 1.15rem; min-height: 0; height: 1.15rem; accent-color: var(--gold-deep); }
fieldset { border: 0; padding: 0; margin: 1rem 0 0; }
legend { font-weight: 600; font-size: .92rem; margin-bottom: .35rem; }
.role-option { display: flex; gap: .7rem; align-items: flex-start; font-weight: 400; margin: 0 0 .5rem; padding: .7rem .85rem; border: 1.5px solid var(--line); border-radius: 10px; cursor: pointer; }
.role-option input { width: 1.1rem; min-height: 0; height: 1.1rem; margin-top: .2rem; accent-color: var(--gold-deep); }
.role-option span { display: flex; flex-direction: column; }
.role-option:has(input:checked) { border-color: var(--gold-deep); background: rgba(245,183,0,.08); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  font: 600 1rem var(--body); text-decoration: none; cursor: pointer;
  border: 1.5px solid var(--line); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: .7rem 1.3rem; min-height: 46px; margin-top: 1.25rem;
}
.btn:hover { border-color: var(--muted); }
.btn-primary { background: var(--gold); border-color: var(--gold); color: var(--ink); width: 100%; }
.btn-primary:hover { background: #FFC61A; border-color: #FFC61A; }
.btn-small { min-height: 36px; padding: .35rem .9rem; font-size: .9rem; margin: 0; }
.link { background: none; border: 0; padding: 0; font: inherit; color: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--coral); }

/* Avisos */
.flash { border-radius: 10px; padding: .8rem 1rem; margin-bottom: 1rem; border-left: 4px solid; background: var(--surface); }
.flash-success { border-color: var(--mint); }
.flash-error { border-color: var(--coral); }
.flash-warn { border-color: var(--amber); }

/* Usuarios */
.members { list-style: none; margin: 0 0 1.75rem; padding: 0; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.member { display: grid; grid-template-columns: 1fr auto; gap: .75rem 1rem; align-items: center; padding: 1rem 1.1rem; border-top: 1px solid var(--line); }
.member:first-child { border-top: 0; }
.member-id { display: flex; gap: .8rem; align-items: center; min-width: 0; }
.member-id p { margin: 0; overflow-wrap: anywhere; }
.member-name { font-weight: 600; }
.avatar { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; flex: none; background: var(--ink); color: var(--gold); font: 800 .85rem var(--display); }
.member-form { display: flex; gap: .5rem; align-items: center; }
.member-form select { width: auto; min-height: 38px; padding: .35rem .6rem; }
.member-form .short { width: 5.5rem; min-height: 38px; padding: .35rem .6rem; }
.member-actions { grid-column: 1 / -1; display: flex; gap: 1.25rem; font-size: .9rem; }
.member-actions form { margin: 0; }
.member-role { margin: 0; }
@media (max-width: 640px) {
  .member { grid-template-columns: 1fr; }
  .member-form { flex-wrap: wrap; }
}
.reveal { border: 2px dashed var(--gold-deep); background: rgba(245,183,0,.08); border-radius: 14px; padding: 1.2rem 1.3rem; margin-bottom: 1.5rem; }
.secret-row { display: flex; gap: .75rem; align-items: center; flex-wrap: wrap; }
.secret-row code { font: 600 1.35rem/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .06em; background: var(--surface); padding: .55rem .8rem; border-radius: 8px; border: 1px solid var(--line); }

/* Pantallas de acceso */
.bare .wrap { max-width: 1040px; display: flex; flex-direction: column; justify-content: center; }
.auth { display: grid; grid-template-columns: 1fr 1fr; border-radius: 22px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); }
.auth-brand { background: var(--ink); color: #fff; padding: clamp(2rem, 6vw, 3.5rem); display: flex; flex-direction: column; justify-content: center; }
.auth-brand .big { width: clamp(72px, 14vw, 120px); height: auto; margin-bottom: 1.25rem; }
.wordmark { font: 800 clamp(2.4rem, 6vw, 3.6rem)/1 var(--display); letter-spacing: -0.02em; margin: 0 0 .75rem; }
.tagline { color: rgba(255,255,255,.78); font-size: 1.1rem; max-width: 26ch; margin: 0; }
.auth-panel { padding: clamp(1.5rem, 5vw, 3rem); }
.auth-panel .lang { color: var(--muted); float: right; }
@media (max-width: 760px) {
  .auth { grid-template-columns: 1fr; }
  .auth-brand { padding: 1.75rem 1.5rem; flex-direction: row; align-items: center; gap: 1rem; flex-wrap: wrap; }
  .auth-brand .big { width: 56px; margin: 0; }
  .wordmark { font-size: 2.1rem; margin: 0; }
  .tagline { flex-basis: 100%; font-size: 1rem; }
}

@media (max-width: 640px) {
  .topbar { display: grid; grid-template-columns: 1fr auto; row-gap: .6rem; }
  .topbar .lang { grid-column: 2; grid-row: 1; }
  .nav { grid-column: 1 / -1; margin: 0; justify-content: space-between; }
  .nav a { padding: .4rem .6rem; }
  .nav .logout-item { display: none; }
}
.account-logout { margin-top: 1.5rem; }
@media (prefers-color-scheme: dark) {
  .hero, .auth-brand { box-shadow: inset 0 0 0 1px rgba(245,183,0,.25); }
}


/* ===== Entrega 2: configuración ===== */
.crumb { margin: 0 0 .5rem; font-size: .9rem; color: var(--muted); }
.crumb a::before { content: "‹ "; }
.empty { color: var(--muted); }
.small { font-size: .82rem; }
.tag { display: inline-block; font-size: .75rem; font-weight: 600; padding: .05rem .5rem; border-radius: 999px; background: var(--paper); border: 1px solid var(--line); color: var(--muted); vertical-align: middle; }
.tag-gold { background: rgba(245,183,0,.16); border-color: transparent; color: var(--gold-deep); }
.tag-muted { opacity: .8; }
.is-inactive { opacity: .55; }
.is-hidden { display: none !important; }
.actions { display: flex; flex-wrap: wrap; gap: .75rem; align-items: center; margin-top: 1.25rem; }
.actions .btn, .actions form { margin: 0; }
.actions .btn-primary { width: auto; }
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 1rem; }
.grid3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0 1rem; }
@media (max-width: 560px) { .grid2, .grid3 { grid-template-columns: 1fr; } }
input.short { width: 7rem; }

.hub { list-style: none; margin: 0; padding: 0; display: grid; gap: .75rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.hub a { display: flex; flex-direction: column; gap: .3rem; height: 100%; padding: 1.1rem 1.2rem; text-decoration: none; background: var(--surface); border: 1px solid var(--line); border-left: 4px solid var(--gold); border-radius: 12px; }
.hub a:hover { border-color: var(--gold-deep); }
.hub-title { font: 600 1.1rem var(--display); display: flex; align-items: center; gap: .5rem; }
.hub-count { font: 600 .8rem var(--body); background: var(--ink); color: var(--gold); border-radius: 999px; padding: .05rem .5rem; }

.rows { list-style: none; margin: 0 0 1.75rem; padding: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.row-item { display: flex; gap: .9rem; align-items: center; padding: .9rem 1.1rem; border-top: 1px solid var(--line); flex-wrap: wrap; }
.row-item:first-child { border-top: 0; }
.row-main { flex: 1; min-width: 200px; }
.row-main p { margin: 0; }
.row-title { font-weight: 600; }
.row-note { font-size: .88rem; color: var(--muted); font-style: italic; }
.row-form { display: flex; gap: .5rem; align-items: center; flex: 1; min-width: 240px; }
.row-form input { min-height: 38px; padding: .35rem .6rem; }
.row-form input:not(.short) { flex: 1; }
.row-meta { display: flex; gap: 1rem; align-items: center; font-size: .9rem; margin-left: auto; }
.row-meta form { margin: 0; }
.acct-type { width: 42px; height: 42px; border-radius: 10px; display: grid; place-items: center; flex: none; font: 800 1rem var(--display); background: var(--ink); color: var(--gold); }
.acct-credit_card, .acct-credit_line, .acct-loan, .acct-mortgage, .acct-financing { background: var(--coral); color: #fff; }
.acct-cash, .acct-savings { background: var(--mint); color: #fff; }

/* Resumen ¿Alcanza? */
.summary { background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: clamp(1.1rem, 3vw, 1.6rem); margin-bottom: 1.75rem; border-top: 6px solid var(--mint); }
.summary.is-short { border-top-color: var(--coral); }
.summary h2 { font-size: 1rem; color: var(--muted); font-family: var(--body); font-weight: 600; margin-bottom: .25rem; }
.summary-verdict { font: 800 clamp(1.6rem, 5vw, 2.4rem)/1.1 var(--display); margin: 0 0 1rem; color: var(--mint); }
.is-short .summary-verdict { color: var(--coral); }
.bars { margin: 0 0 .75rem; display: grid; gap: .55rem; }
.bar-row { display: grid; grid-template-columns: 7rem 1fr; gap: .75rem; align-items: center; }
.bar-row dt { font-weight: 600; font-size: .92rem; }
.bar-row dd { margin: 0; display: flex; align-items: center; gap: .6rem; }
.bar { display: block; height: 14px; border-radius: 999px; min-width: 4px; flex: none; max-width: calc(100% - 7.5rem); }
.bar-income { background: var(--mint); }
.bar-expense { background: var(--amber); }
.bar-val { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.w-0 { width: 0%; }
.w-5 { width: 5%; }
.w-10 { width: 10%; }
.w-15 { width: 15%; }
.w-20 { width: 20%; }
.w-25 { width: 25%; }
.w-30 { width: 30%; }
.w-35 { width: 35%; }
.w-40 { width: 40%; }
.w-45 { width: 45%; }
.w-50 { width: 50%; }
.w-55 { width: 55%; }
.w-60 { width: 60%; }
.w-65 { width: 65%; }
.w-70 { width: 70%; }
.w-75 { width: 75%; }
.w-80 { width: 80%; }
.w-85 { width: 85%; }
.w-90 { width: 90%; }
.w-95 { width: 95%; }
.w-100 { width: 100%; }

/* Grupos y partidas */
.panel-focus { border: 2px solid var(--gold); }
.empty-state p { font-size: 1.05rem; }
.group { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; margin-bottom: 1.25rem; overflow: hidden; }
.group-head { display: flex; justify-content: space-between; align-items: baseline; gap: 1rem; padding: .9rem 1.1rem; border-bottom: 1px solid var(--line); }
.group-head h2 { margin: 0; font-size: 1.15rem; }
.group-income .group-head { box-shadow: inset 4px 0 0 var(--mint); }
.group-expense .group-head { box-shadow: inset 4px 0 0 var(--amber); }
.group-total { color: var(--muted); font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
.lines { list-style: none; margin: 0; padding: 0; }
.line { display: grid; grid-template-columns: 1fr auto; gap: .2rem 1rem; padding: .8rem 1.1rem; border-top: 1px solid var(--line); }
.line:first-child { border-top: 0; }
.line p { margin: 0; }
.line-name { font-weight: 600; display: flex; gap: .4rem; align-items: center; flex-wrap: wrap; }
.line-amount { text-align: right; }
.amount { font-weight: 600; font-variant-numeric: tabular-nums; }
.line-actions { grid-column: 1 / -1; display: flex; gap: 1rem; font-size: .85rem; }
.line-actions form { margin: 0; }
.group-foot { display: flex; gap: 1rem; align-items: flex-start; justify-content: space-between; flex-wrap: wrap; padding: .75rem 1.1rem; background: var(--paper); border-top: 1px solid var(--line); }
.group-edit summary { cursor: pointer; font-size: .9rem; list-style: none; }
.group-edit summary::-webkit-details-marker { display: none; }
.group-edit[open] { flex-basis: 100%; }
.inline-form { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; margin-top: .6rem; }
.inline-form input { flex: 1; min-width: 160px; min-height: 38px; padding: .35rem .6rem; }
.inline-form select { width: auto; min-height: 38px; padding: .35rem .6rem; }
.inline-links { display: flex; gap: 1rem; margin-top: .6rem; font-size: .9rem; }
.inline-links form { margin: 0; }

/* Importación */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; }
.preview { width: 100%; border-collapse: collapse; font-size: .92rem; }
.preview th, .preview td { padding: .55rem .75rem; text-align: left; border-bottom: 1px solid var(--line); }
.preview th { font-weight: 600; background: var(--paper); }
.preview .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.flash ul { margin: .4rem 0 0; padding-left: 1.2rem; }
.flash p { margin: 0; }
.roadmap li.done { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--gold-deep); }
input[type="file"] { padding: .55rem; }

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