/* Finanzas OVA.
   Verde bosque de la marca + dorado de violín. Max lleva el verde (65%),
   Luis el dorado (35%): el mismo color en todos los gráficos y tarjetas,
   para que el reparto se lea sin leyenda. */

:root {
  --ground: #f5f3ee;
  --surface: #ffffff;
  --surface-2: #f0ede5;
  --line: #e2ddd1;
  --ink: #18201d;
  --ink-2: #4c5852;
  --ink-3: #7f8a84;
  --brand: #12332c;
  --max: #1f7a62;
  --max-soft: #e1f1eb;
  --luis: #b58a2a;
  --luis-soft: #f7eed9;
  --ok: #2f7d32;
  --ok-soft: #e4f2e4;
  --warn: #9a6708;
  --warn-soft: #faefda;
  --bad: #b03a3a;
  --bad-soft: #fbe9e9;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(18, 32, 28, 0.05), 0 8px 24px rgba(18, 32, 28, 0.06);
  --mono: "IBM Plex Mono", ui-monospace, monospace;
  --serif: "Fraunces", Georgia, serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ground: #0f1513;
    --surface: #161e1b;
    --surface-2: #1c2622;
    --line: #2a3631;
    --ink: #eef2ef;
    --ink-2: #b4c0ba;
    --ink-3: #85928b;
    --brand: #dcebe5;
    --max: #4fc19d;
    --max-soft: #173229;
    --luis: #e2b75a;
    --luis-soft: #33290f;
    --ok: #79c77d;
    --ok-soft: #1a2e1b;
    --warn: #e7b45a;
    --warn-soft: #352914;
    --bad: #f08a8a;
    --bad-soft: #3a1e1e;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.3);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 15px/1.5 "IBM Plex Sans", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--max); }
h1, h2, h3 { font-family: var(--serif); font-weight: 700; letter-spacing: -0.01em; margin: 0; }
h1 { font-size: 30px; line-height: 1.15; }
h2 { font-size: 21px; }
h3 { font-size: 16px; }
.muted { color: var(--ink-3); }
.small { font-size: 13px; }
.num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.neg { color: var(--bad); }
.pos { color: var(--ok); }

/* --- acceso --- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.gate-card {
  width: min(400px, 100%);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 28px;
  box-shadow: var(--shadow);
}
.gate-card .brand-mark { margin-bottom: 22px; }

.brand-mark { display: flex; gap: 12px; align-items: center; text-decoration: none; color: inherit; }
.brand-mark small { display: block; color: var(--ink-3); font-size: 12px; }
.logo {
  width: 38px; height: 38px; border-radius: 10px;
  display: grid; place-items: center;
  background: #12332c; color: #d9b45a;
  font: 700 15px var(--serif);
}

/* --- estructura --- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 20px;
  padding: 12px 24px;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
  padding: 7px 12px; border-radius: 9px; text-decoration: none;
  color: var(--ink-2); font-weight: 500; white-space: nowrap; font-size: 14px;
}
.nav a:hover { background: var(--surface-2); }
.nav a.on { background: var(--brand); color: var(--surface); }
.who { display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--ink-2); white-space: nowrap; }
.view { max-width: 1200px; margin: 0 auto; padding: 28px 24px 80px; }

.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin-bottom: 22px; }
.page-head p { margin: 4px 0 0; color: var(--ink-2); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, 1fr); }
.g3 { grid-template-columns: repeat(3, 1fr); }
.g2 { grid-template-columns: repeat(2, 1fr); }
.span2 { grid-column: span 2; }
@media (max-width: 900px) {
  .g4 { grid-template-columns: repeat(2, 1fr); }
  .g3, .g2 { grid-template-columns: 1fr; }
  .span2 { grid-column: auto; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr 1fr; gap: 10px; }
  .g4 .card { padding: 14px; }
  .kpi .value { font-size: 20px; }
  .topbar { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .topbar .brand-mark { flex: 1; }
  .nav { order: 3; flex: 1 1 100%; }
  #who-name { display: none; }
  .view { padding: 20px 16px 60px; }
  h1 { font-size: 25px; }
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: var(--shadow);
  min-width: 0;
}
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.section { margin-top: 28px; }
.section > h2 { margin-bottom: 12px; }

/* --- indicadores --- */
.kpi .label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-3); font-weight: 600; }
.kpi .value { font: 600 28px/1.2 var(--mono); margin-top: 6px; font-variant-numeric: tabular-nums; }
.kpi .sub { font-size: 13px; color: var(--ink-2); margin-top: 4px; }
.kpi.max { border-top: 3px solid var(--max); }
.kpi.luis { border-top: 3px solid var(--luis); }

.meter { height: 10px; background: var(--surface-2); border-radius: 99px; overflow: hidden; margin-top: 10px; }
.meter > i { display: block; height: 100%; background: var(--max); border-radius: 99px; }

.chart-box { position: relative; height: 280px; }
.chart-box.short { height: 220px; }

/* --- reparto --- */
.split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
@media (max-width: 560px) { .split { grid-template-columns: 1fr; } }
.socio { border-radius: 12px; padding: 14px 16px; }
.socio.max { background: var(--max-soft); }
.socio.luis { background: var(--luis-soft); }
.socio h3 { display: flex; justify-content: space-between; }
.socio .row { display: flex; justify-content: space-between; font-size: 14px; padding: 3px 0; }
.socio .row.total { border-top: 1px solid color-mix(in srgb, var(--ink) 15%, transparent); margin-top: 6px; padding-top: 8px; font-weight: 600; }

/* --- tablas --- */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-3); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.r, th.r { text-align: right; }
tr.click { cursor: pointer; }
tr.click:hover td { background: var(--surface-2); }
tfoot td { font-weight: 600; border-top: 1px solid var(--line); }

.pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600;
  background: var(--surface-2); color: var(--ink-2); white-space: nowrap;
}
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.max { background: var(--max-soft); color: var(--max); }
.pill.luis { background: var(--luis-soft); color: var(--luis); }
.nav .pill { background: var(--bad); color: #fff; padding: 0 7px; margin-left: 4px; }

/* --- alertas --- */
.alerts { display: grid; gap: 8px; }
.alert { display: flex; gap: 10px; align-items: flex-start; padding: 11px 14px; border-radius: 11px; font-size: 14px; }
.alert.bloquea { background: var(--bad-soft); color: var(--bad); }
.alert.aviso { background: var(--warn-soft); color: var(--warn); }
.alert.ok { background: var(--ok-soft); color: var(--ok); }
.alert a { color: inherit; font-weight: 600; }

/* --- formularios --- */
label { display: grid; gap: 5px; font-size: 13px; font-weight: 500; color: var(--ink-2); }
input, select, textarea {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 9px; padding: 9px 11px; width: 100%;
}
input:focus, select:focus, textarea:focus { outline: 2px solid color-mix(in srgb, var(--max) 40%, transparent); border-color: var(--max); }
textarea { min-height: 90px; resize: vertical; }
.stack { display: grid; gap: 14px; }
.row-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 500; }
.check input { width: auto; }

.btn {
  font: 600 14px "IBM Plex Sans", sans-serif;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--surface); color: var(--ink); cursor: pointer; white-space: nowrap;
  text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
}
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--brand); color: var(--surface); border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.1); }
.btn.gold { background: var(--luis); color: #fff; border-color: var(--luis); }
.btn.danger { color: var(--bad); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.small { padding: 5px 10px; font-size: 13px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.error { color: var(--bad); font-size: 14px; }

/* --- asistente --- */
.steps { display: flex; gap: 6px; margin-bottom: 20px; flex-wrap: wrap; }
.steps button {
  border: 1px solid var(--line); background: var(--surface); color: var(--ink-2);
  border-radius: 99px; padding: 6px 13px; font: 500 13px "IBM Plex Sans"; cursor: pointer;
}
.steps button.on { background: var(--brand); color: var(--surface); border-color: var(--brand); }
.steps button.done { border-color: var(--max); color: var(--max); }
.q { padding: 16px 0; border-bottom: 1px solid var(--line); }
.q:last-child { border-bottom: 0; }
.q-title { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; align-items: baseline; }
.q-title strong { font-size: 16px; }
.q-body { margin-top: 10px; display: grid; gap: 10px; }
.choice { display: flex; gap: 8px; flex-wrap: wrap; }
.choice .btn.on { background: var(--max); border-color: var(--max); color: #fff; }
.wizard-nav { display: flex; justify-content: space-between; margin-top: 20px; gap: 10px; }

.thumbs { display: flex; gap: 8px; flex-wrap: wrap; }
.thumb {
  width: 64px; height: 64px; border-radius: 8px; border: 1px solid var(--line);
  overflow: hidden; display: grid; place-items: center; background: var(--surface-2);
  font-size: 11px; color: var(--ink-3); text-decoration: none; position: relative;
}
.thumb img { width: 100%; height: 100%; object-fit: cover; }

/* --- historial --- */
.timeline { display: grid; gap: 2px; }
.ev { display: grid; grid-template-columns: 150px 1fr; gap: 14px; padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.ev time { color: var(--ink-3); font-size: 13px; font-family: var(--mono); }
.ev b { font-weight: 600; }
@media (max-width: 560px) { .ev { grid-template-columns: 1fr; gap: 2px; } }

/* --- modal y aviso --- */
.modal {
  border: 1px solid var(--line); border-radius: 16px; padding: 0;
  width: min(560px, calc(100vw - 32px)); background: var(--surface); color: var(--ink);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}
.modal::backdrop { background: rgba(10, 20, 16, 0.45); }
.modal form, .modal .inner { padding: 22px; display: grid; gap: 14px; }
.modal .foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--brand); color: var(--surface); padding: 11px 18px;
  border-radius: 11px; font-size: 14px; box-shadow: var(--shadow); z-index: 100; max-width: calc(100vw - 32px);
}
.empty { padding: 26px; text-align: center; color: var(--ink-3); font-size: 14px; }
.tag-rec { font-size: 11px; color: var(--warn); font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; }

/* --- checklist de gastos fijos en el mes --- */
.checklist { background: var(--surface-2); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; }
.ck-row { display: grid; grid-template-columns: minmax(200px, 1.6fr) repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; align-items: end; padding: 10px 0; border-bottom: 1px solid var(--line); }
.ck-row:last-of-type { border-bottom: 0; }
.ck-name { align-self: center; }
@media (max-width: 560px) { .ck-row { grid-template-columns: 1fr 1fr; } .ck-name { grid-column: 1 / -1; } }
