:root {
      --bg: #e8e2d4;
      --bg-2: #f3eee3;
      --paper: #faf7f0;
      --ink: #2b2924;
      --muted: #5c574c;
      --line: #d4ccb8;
      --sage: #3f5d4e;
      --sage-soft: #d7e3db;
      --rose-soft: #f3ddd8;
      --rose: #8a4a42;
      --gold-soft: #efe3c4;
      --gold: #6f5a28;
      --shadow: 0 8px 24px rgba(43, 41, 36, 0.08);
      --safe-b: env(safe-area-inset-bottom, 0px);
      --safe-t: env(safe-area-inset-top, 0px);
    }
    * { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
    html, body { margin: 0; }
    body {
      font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
      background: var(--bg);
      color: var(--ink);
      font-size: 18px;
      line-height: 1.4;
    }
    button, input { font: inherit; color: inherit; }
    button { border: 0; background: none; cursor: pointer; }
    .app {
      max-width: 520px;
      margin: 0 auto;
      min-height: 100dvh;
      padding: calc(16px + var(--safe-t)) 16px calc(28px + var(--safe-b));
    }
    h1, h2 { margin: 0; font-weight: 700; letter-spacing: -0.03em; }
    p { margin: 0; }
    .top {
      display: flex;
      align-items: center;
      justify-content: space-between;
      gap: 8px;
      margin-bottom: 16px;
    }
    .icon {
      min-width: 52px;
      min-height: 52px;
      border-radius: 16px;
      background: var(--paper);
      box-shadow: var(--shadow);
      font-size: 26px;
    }
    .title { flex: 1; text-align: center; font-size: 32px; }
    .hint { color: var(--muted); font-size: 16px; }
    .cards {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 10px;
      margin: 14px 0 18px;
    }
    .card {
      background: var(--paper);
      border-radius: 22px;
      padding: 16px;
      box-shadow: var(--shadow);
    }
    .card.wide { grid-column: 1 / -1; }
    .label { color: var(--muted); font-size: 15px; margin-bottom: 6px; }
    .num { font-size: 24px; font-weight: 750; letter-spacing: -0.03em; }
    .num.soft { font-size: 17px; font-weight: 550; color: var(--muted); }
    .months { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
    .month {
      text-align: left;
      background: var(--paper);
      border-radius: 18px;
      padding: 16px 14px;
      min-height: 96px;
      box-shadow: var(--shadow);
    }
    .month b { display: block; font-size: 20px; margin-bottom: 6px; }
    .month span { color: var(--muted); font-size: 14px; }
    label { display: block; color: var(--muted); font-size: 15px; margin-bottom: 8px; }
    .field, .amount {
      width: 100%;
      border: 2px solid var(--line);
      background: var(--paper);
      border-radius: 16px;
      padding: 14px;
    }
    .amount { font-size: 40px; font-weight: 750; letter-spacing: -0.03em; }
    .field { font-size: 18px; }
    .field:focus, .amount:focus {
      outline: 3px solid var(--sage-soft);
      border-color: var(--sage);
    }
    .btns2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 8px 0 18px; }
    .add {
      min-height: 62px;
      border-radius: 20px;
      font-size: 20px;
      font-weight: 700;
    }
    .add.in { background: var(--sage); color: #f7faf8; }
    .add.out { background: #5a4a3a; color: #faf7f0; }
    .sec { margin: 8px 0 10px; font-size: 18px; }
    .empty {
      background: var(--bg-2);
      border-radius: 18px;
      padding: 18px 16px;
      text-align: center;
      color: var(--muted);
      margin-bottom: 12px;
    }
    .list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 18px; }
    .item {
      background: var(--paper);
      border-radius: 18px;
      padding: 14px;
      box-shadow: var(--shadow);
      display: grid;
      grid-template-columns: 1fr auto;
      gap: 6px 10px;
    }
    .desc { font-weight: 700; }
    .meta { font-size: 14px; color: var(--muted); }
    .amt { font-weight: 750; font-size: 20px; }
    .actions { display: flex; gap: 6px; justify-content: flex-end; }
    .tiny {
      min-height: 44px;
      padding: 0 12px;
      border-radius: 12px;
      background: var(--bg-2);
      font-size: 15px;
    }
    .danger { color: var(--rose); background: var(--rose-soft); }
    .pill {
      display: inline-block;
      font-size: 13px;
      font-weight: 650;
      border-radius: 999px;
      padding: 2px 8px;
      margin-left: 6px;
    }
    .pill.bueno { background: var(--sage-soft); color: var(--sage); }
    .pill.tonto { background: var(--gold-soft); color: var(--gold); }
    .form { display: flex; flex-direction: column; gap: 14px; }
    .cats { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
    .cat, .kind {
      min-height: 54px;
      border-radius: 16px;
      background: var(--paper);
      border: 2px solid var(--line);
      font-weight: 650;
    }
    .cat.on, .kind.on { border-width: 2px; }
    .cat.on { background: var(--sage-soft); border-color: var(--sage); }
    .kind.bueno.on { background: var(--sage-soft); border-color: var(--sage); }
    .kind.tonto.on { background: var(--gold-soft); border-color: var(--gold); }
    .form-actions { display: grid; grid-template-columns: 1fr 1.4fr; gap: 10px; }
    .cancel, .save { min-height: 58px; border-radius: 16px; }
    .cancel { background: var(--bg-2); border: 1px solid var(--line); }
    .save { background: var(--sage); color: #f7faf8; font-weight: 700; }
    .tools { margin-top: 28px; display: flex; gap: 8px; flex-wrap: wrap; }
    .ghost {
      background: var(--bg-2);
      border: 1px solid var(--line);
      border-radius: 999px;
      padding: 10px 14px;
      color: var(--muted);
      font-size: 15px;
    }
    dialog {
      border: 0;
      border-radius: 22px;
      padding: 22px 18px;
      width: min(92vw, 360px);
      background: var(--paper);
    }
    dialog::backdrop { background: rgba(43,41,36,.35); }
    .dlg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
    .check {
      display: flex;
      align-items: center;
      gap: 12px;
      background: var(--paper);
      border: 2px solid var(--line);
      border-radius: 16px;
      padding: 14px;
      min-height: 56px;
    }
    .check input { width: 24px; height: 24px; }
    .toast {
      position: fixed;
      left: 50%;
      bottom: calc(18px + var(--safe-b));
      transform: translateX(-50%);
      background: var(--ink);
      color: #faf7f0;
      padding: 12px 16px;
      border-radius: 14px;
      font-size: 15px;
      max-width: 90vw;
      z-index: 20;
    }
