  :root {
    --navy: #11203f;
    --navy-2: #17284c;
    --navy-3: #1d3157;
    --blue: #259dcb;
    --red: #ee203a;
    --ink: #f2f5fa;
    --ink-dim: #9fb2cc;
    --ink-mute: #6d80a0;
    --line: #2a3c63;
  }
  * { box-sizing: border-box; }
  body {
    margin: 0;
    background: var(--navy);
    color: var(--ink);
    font-family: -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    padding: 24px 14px 60px;
    display: flex;
    justify-content: center;
  }
  .wrap { width: 100%; max-width: 480px; }
  a { color: var(--blue); }

  /* ---------- Login ---------- */
  #login-screen {
    min-height: 70vh;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .login-card {
    width: 100%;
    max-width: 320px;
    text-align: center;
  }
  .login-card img { width: 120px; margin-bottom: 24px; }
  .login-card input {
    width: 100%;
    margin-bottom: 10px;
  }
  .login-card button {
    width: 100%;
    margin-top: 6px;
  }
  #login-error {
    color: var(--red);
    font-size: 13px;
    margin-top: 10px;
    min-height: 16px;
  }

  /* ---------- App shell ---------- */
  #app-screen { display: none; }
  header.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
  }
  header.app-header .brand { display: flex; align-items: center; gap: 10px; }
  header.app-header img { width: 34px; }
  header.app-header .name {
    font-size: 15px;
    font-weight: 600;
    line-height: 1.2;
  }
  header.app-header .name span {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--ink-mute);
  }
  #logout {
    background: none;
    border: 1px solid var(--line);
    color: var(--ink-dim);
    font-size: 12px;
    padding: 6px 10px;
  }

  .summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  .summary .box {
    background: var(--navy-2);
    border-radius: 10px;
    padding: 12px;
  }
  .summary .box .label { font-size: 11px; color: var(--ink-mute); letter-spacing: 0.3px; }
  .summary .box .val { font-size: 18px; font-weight: 600; margin-top: 4px; }
  .summary .box.gastos .val { color: var(--red); }
  .summary .box.ingresos .val { color: var(--blue); }
  .summary .box.balance .val { color: var(--ink); }

  .tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 16px;
    background: var(--navy-2);
    padding: 4px;
    border-radius: 10px;
  }
  .tab-btn {
    flex: 1;
    background: none;
    border: none;
    color: var(--ink-dim);
    font-size: 13px;
    padding: 9px 4px;
    border-radius: 7px;
    cursor: pointer;
  }
  .tab-btn.active { background: var(--blue); color: #071824; font-weight: 600; }

  .panel { display: none; }
  .panel.active { display: block; }

  .card {
    background: var(--navy-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 18px;
  }
  .row { display: flex; gap: 8px; margin-bottom: 8px; }
  .row:last-of-type { margin-bottom: 0; }
  input {
    background: var(--navy-3);
    border: 1px solid var(--line);
    color: var(--ink);
    border-radius: 6px;
    padding: 10px;
    font-size: 14px;
    width: 100%;
  }
  input::placeholder { color: var(--ink-mute); }
  input:focus { outline: none; border-color: var(--blue); }
  input[type="date"] { color-scheme: dark; width: 140px; flex-shrink: 0; }
  .err { border-color: var(--red) !important; }

  button {
    font-family: inherit;
    cursor: pointer;
  }
  button.primary {
    width: 100%;
    margin-top: 10px;
    background: var(--blue);
    color: #071824;
    border: none;
    border-radius: 6px;
    padding: 11px;
    font-size: 14px;
    font-weight: 600;
  }
  button.primary:active { transform: scale(0.98); }

  .empty {
    text-align: center;
    color: var(--ink-mute);
    font-size: 13px;
    padding: 26px 0;
  }

  .ticket {
    background: var(--navy-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 4px 16px;
  }
  .entry {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 0;
    border-bottom: 1px dashed var(--line);
  }
  .entry:last-child { border-bottom: none; }
  .tag {
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: var(--navy-3);
    color: var(--blue);
    border: 1px solid var(--line);
    white-space: nowrap;
    flex-shrink: 0;
  }
  .mid { flex: 1; min-width: 0; }
  .note { font-size: 13px; color: var(--ink); margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sub { font-size: 11px; color: var(--ink-mute); margin: 2px 0 0; }
  .amt { font-size: 14px; font-weight: 600; flex-shrink: 0; }
  .amt.gasto { color: var(--red); }
  .amt.ingreso { color: var(--blue); }
  .del {
    background: none; border: none; color: var(--ink-mute);
    font-size: 14px; padding: 4px; flex-shrink: 0;
  }
  .del:hover { color: var(--red); }

  /* ---------- Balance ---------- */
  .month-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
  }
  .month-picker label { font-size: 12px; color: var(--ink-mute); }
  .month-picker input[type="month"] { width: auto; flex: 1; }

  .bal-detail {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 20px;
  }
  .bal-detail .box {
    background: var(--navy-2);
    border-radius: 10px;
    padding: 12px;
    text-align: center;
  }
  .bal-detail .box .label { font-size: 11px; color: var(--ink-mute); }
  .bal-detail .box .val { font-size: 16px; font-weight: 600; margin-top: 4px; }
  .bal-detail .box.gastos .val { color: var(--red); }
  .bal-detail .box.ingresos .val { color: var(--blue); }

  .chart-card {
    background: var(--navy-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 16px 10px;
    margin-bottom: 18px;
  }
  .chart-legend {
    display: flex;
    gap: 16px;
    justify-content: center;
    font-size: 11px;
    color: var(--ink-mute);
    margin-top: 8px;
  }
  .chart-legend span { display: flex; align-items: center; gap: 5px; }
  .chart-legend i { width: 8px; height: 8px; border-radius: 2px; display: inline-block; }

  table.bal-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--navy-2);
    border: 1px solid var(--line);
    border-radius: 10px;
    overflow: hidden;
    font-size: 13px;
  }
  table.bal-table th, table.bal-table td {
    padding: 10px 12px;
    text-align: right;
  }
  table.bal-table th:first-child, table.bal-table td:first-child { text-align: left; }
  table.bal-table th {
    font-size: 10px;
    color: var(--ink-mute);
    font-weight: 500;
    letter-spacing: 0.3px;
    border-bottom: 1px solid var(--line);
  }
  table.bal-table td { border-bottom: 1px dashed var(--line); }
  table.bal-table tr:last-child td { border-bottom: none; }
  table.bal-table td.g { color: var(--red); }
  table.bal-table td.i { color: var(--blue); }
