:root {
  font-family: "Aptos", "Segoe UI", ui-sans-serif, system-ui, sans-serif;
  color: #263739;
  background: #f8f8f5;
  font-synthesis: none;
  --ink: #263739;
  --muted: #78878a;
  --line: #e8ecea;
  --sage: #e8f2eb;
  --blue: #e8f1f7;
  --peach: #fff0e5;
  --accent: #3c7168;
  --coral: #be7163;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, [tabindex]:focus-visible { outline: 2px solid #7da79b; outline-offset: 3px; }
[hidden] { display: none !important; }

.login-view {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at 18% 16%, #e6f1f6 0, transparent 30%), radial-gradient(circle at 84% 88%, #f9eade 0, transparent 30%), #f8f8f5;
}
.login-card {
  width: min(100%, 420px);
  padding: 38px;
  background: #fff;
  border: 1px solid #edf0ed;
  border-radius: 30px;
  box-shadow: 0 22px 70px #314b4510;
}
.brand-mark, .small-mark { display: inline-grid; place-items: center; background: #dff0e9; color: #315e57; font-weight: 800; letter-spacing: -.09em; }
.brand-mark { display: inline-flex; align-items: center; justify-content: center; width: 60px; height: 60px; border-radius: 19px; font-size: 33px; }
.brand-mark span { color: #e28f78; }
.login-card h1 { margin: 25px 0 30px; font-size: clamp(32px, 8vw, 39px); line-height: 1.09; letter-spacing: -.055em; }
.login-card form { display: grid; gap: 10px; }
.password-field { position: relative; }
.password-field input { padding-right: 58px; }
.password-field button { position: absolute; top: 2px; right: 2px; display: grid; place-items: center; width: 44px; height: 43px; padding: 0; border: 0; border-radius: 12px; background: transparent; color: #627771; }
.password-field button:hover, .password-field button[aria-pressed="true"] { background: #eef5f0; color: #326c60; }
.password-field .eye-slash { display: none; }
.password-field button[aria-pressed="true"] .eye-slash { display: block; }
label { font-size: 13px; font-weight: 700; color: #536564; }
input, select { min-height: 47px; width: 100%; padding: 11px 14px; border: 1px solid #e0e8e3; border-radius: 14px; background: #fbfcfb; color: var(--ink); }
input:focus, select:focus { border-color: #86afa3; }
.primary, .secondary, .danger-button { min-height: 46px; padding: 11px 20px; border: 0; border-radius: 14px; font-weight: 750; }
.primary { background: #38746a; color: #fff; box-shadow: 0 6px 14px #38746a1c; }
.primary:hover { background: #2d655c; }
.primary:disabled { cursor: wait; opacity: .7; }
.secondary { background: #edf3ef; color: #3f605a; }
.danger-button { background: #b9675c; color: #fff; }
.wide { width: 100%; margin-top: 15px; }
.text-button { width: 100%; margin-top: 15px; border: 0; background: transparent; color: #3c7168; padding: 12px 5px; font-weight: 750; }
.error { margin: 6px 0 0; padding: 12px 14px; border-radius: 12px; background: #fff0eb; color: #a64d43; font-size: 13px; line-height: 1.4; text-align: left; }
.error:empty { display: none; }

.app-view { min-height: 100vh; }
.topbar { padding: 0 max(20px, calc((100vw - 1100px) / 2)); background: #fff; border-bottom: 1px solid var(--line); }
.topline, .period-bar { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.topline { min-height: 78px; }
.brand-small { display: flex; align-items: center; gap: 12px; font-size: 15px; font-weight: 800; letter-spacing: -.025em; }
.small-mark { width: 36px; height: 36px; border-radius: 12px; font-size: 21px; }
.account { display: flex; align-items: center; gap: 12px; color: #637673; font-size: 13px; }
#user-name { display: inline-flex; align-items: center; gap: 7px; font-weight: 700; }
#user-name::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #96c2af; }
.account button, .device-button { min-height: 37px; padding: 7px 14px; border: 1px solid #e3eae5; border-radius: 12px; background: #f8faf8; color: #49635c; font-weight: 700; }
.account button:hover, .device-button:hover { background: #edf4ef; }
.period-bar { padding: 14px 0 20px; }
.period-picker { display: flex; gap: 9px; }
.period-picker select { width: auto; min-width: 128px; border-color: #e5ece8; border-radius: 999px; background: #f8faf8; font-weight: 750; }
.period-picker select:last-child { min-width: 100px; }
nav { display: flex; gap: 8px; padding: 0 0 18px; overflow-x: auto; scrollbar-width: none; }
nav::-webkit-scrollbar { display: none; }
nav button { flex: none; padding: 11px 17px; border: 1px solid transparent; border-radius: 999px; background: transparent; color: #74837e; font-size: 14px; font-weight: 750; }
nav button:hover { background: #f5f8f5; }
nav button.active { background: #e5f1ec; color: #2e6c60; border-color: #dcebe3; }

.content { max-width: 1100px; margin: auto; padding: 33px 20px 82px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 20px; }
.section-head h2 { margin: 0; font-size: clamp(24px, 4vw, 29px); letter-spacing: -.045em; }
.section-head .add { width: 44px; height: 44px; border: 0; border-radius: 15px; background: #39766b; color: #fff; font-size: 29px; line-height: 1; box-shadow: 0 7px 16px #39766b22; }
.section-head .add:hover { background: #2e655b; transform: translateY(-1px); }
.hero { position: relative; isolation: isolate; overflow: hidden; min-height: 165px; padding: 31px 34px; margin-bottom: 25px; border: 1px solid #dae7e6; border-radius: 25px; background: linear-gradient(115deg, #e9f3f5, #e9f2e9); }
.hero::after { content: ""; position: absolute; z-index: -1; right: -45px; top: -100px; width: 280px; height: 280px; border-radius: 50%; background: #ffffff73; box-shadow: -48px 74px 0 -69px #9cc6b080; }
.balance-hero { border-color: #efe4d7; background: linear-gradient(115deg, #fff0e1, #f7eee9); }
.balance-hero::after { background: #fff8efaa; box-shadow: -48px 74px 0 -69px #e6b69265; }
.hero .value { font-size: clamp(35px, 6vw, 52px); line-height: 1; font-weight: 800; letter-spacing: -.065em; font-variant-numeric: tabular-nums; }
.hero .caption { margin-top: 13px; font-size: 14px; color: #627d79; font-weight: 700; }
.balance-hero .caption { color: #947664; }
.card, .table-card { overflow: hidden; border: 1px solid #e9eeea; border-radius: 21px; background: #fff; box-shadow: 0 10px 35px #344b3c08; }
.record { display: flex; align-items: center; gap: 16px; min-height: 78px; padding: 16px 20px; border-bottom: 1px solid #f0f2ef; touch-action: pan-y; user-select: none; }
.record:last-child { border-bottom: 0; }
.record:hover, .record:active { background: #fafbf9; }
.record .day { width: 44px; height: 44px; flex: none; display: grid; place-items: center; border-radius: 15px; background: #eaf3f7; color: #5c8094; font-weight: 800; }
.record.expense .day { background: #fff0e8; color: #b47c65; }
.record.subscription .day { background: #f1edf7; color: #8b78a8; }
.record .name { min-width: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 750; }
.record .subline { margin-top: 3px; font-size: 12px; font-weight: 500; color: var(--muted); }
.record .amount { flex: none; font-weight: 800; font-variant-numeric: tabular-nums; white-space: nowrap; }
.empty { padding: 48px 20px; color: #8a9791; font-size: 14px; text-align: center; }
.balance-row { display: grid; grid-template-columns: 1fr 180px; align-items: center; gap: 16px; min-height: 77px; padding: 14px 20px; border-bottom: 1px solid #f0f2ef; }
.balance-row:last-child { border-bottom: 0; }
.balance-row strong { font-size: 14px; }
.balance-row input { text-align: right; }
.money-input { display: flex; align-items: center; position: relative; width: 100%; }
.money-input b { position: absolute; left: 12px; z-index: 1; color: #8a9691; font-size: 13px; pointer-events: none; }
.money-input input { padding-left: 24px; }
.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px; }
.credit-card { position: relative; overflow: hidden; min-height: 168px; padding: 22px; border: 1px solid #e6ebe5; border-radius: 22px; background: linear-gradient(140deg, #edf3ef, #e9f0f4); touch-action: pan-y; user-select: none; }
.credit-card:nth-child(2n) { background: linear-gradient(140deg, #f9eee5, #f4edf0); }
.credit-card::after { content: ""; position: absolute; width: 130px; height: 130px; right: -57px; top: -48px; border-radius: 50%; background: #ffffff6b; }
.credit-card .card-name { position: relative; z-index: 1; font-weight: 800; }
.credit-card .card-limit { margin-top: 23px; font-size: 28px; font-weight: 800; letter-spacing: -.05em; }
.credit-card .card-meta { margin-top: 10px; color: #738581; font-size: 12px; font-weight: 650; }

.table-card { margin-bottom: 18px; }
.table-title { padding: 18px 22px; border-bottom: 1px solid #edf1ed; font-weight: 800; }
.table-scroll { overflow-x: auto; }
.summary-table { width: 100%; min-width: 650px; border-collapse: collapse; text-align: left; }
.summary-table th { background: #fbfcfa; color: #84918d; font-size: 12px; font-weight: 750; }
.summary-table th, .summary-table td { padding: 12px 16px; border-bottom: 1px solid #eff2ee; }
.summary-table td { font-size: 13px; }
.summary-table tr:last-child td { border-bottom: 0; }
.summary-table th:nth-child(4), .summary-table td:nth-child(4) { width: 30%; }
.summary-table .positive { color: #3b806b; font-weight: 800; }
.summary-table .negative { color: #b57565; font-weight: 800; }
.summary-table .money-input, .summary-table .money-input input { width: 112px; }
.summary-table .money-input input { min-height: 38px; padding-top: 6px; padding-bottom: 6px; text-align: right; }
.summary-table .subtotal { background: #f6f9f6; font-weight: 800; }
.summary-table .subtotal td { padding: 15px 16px; }

.sheet, .actions-sheet { padding: 26px; border: 0; border-radius: 24px; background: #fff; color: var(--ink); box-shadow: 0 28px 90px #20372b38; }
.sheet { width: min(440px, calc(100% - 24px)); max-height: calc(100vh - 36px); overflow-y: auto; }
.actions-sheet { width: min(360px, calc(100% - 24px)); }
.sheet::backdrop, .actions-sheet::backdrop { background: #243b366e; backdrop-filter: blur(3px); }
.dialog-head, .dialog-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.dialog-head h2, .actions-sheet h2 { margin: 0 0 22px; font-size: 22px; letter-spacing: -.035em; }
.close { margin-top: -18px; border: 0; background: transparent; color: #7c8c87; font-size: 27px; line-height: 1; }
.form-grid { display: grid; gap: 16px; }
.form-grid label { display: grid; gap: 7px; }
.dialog-actions { justify-content: flex-end; margin-top: 26px; }
.actions-sheet > button { display: block; width: 100%; padding: 16px 2px; border: 0; border-top: 1px solid #eef1ed; background: #fff; color: #3e6e64; font-weight: 750; text-align: left; }
.actions-sheet > button.danger { color: #b26861; }
.actions-sheet > button.muted { color: #899691; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 22px; transform: translateX(-50%); max-width: 90vw; padding: 12px 18px; border-radius: 13px; background: #294c46; color: #fff; box-shadow: 0 10px 30px #1118; font-size: 13px; text-align: center; }

@media (max-width: 700px) {
  .topbar { padding: 0 16px; }
  .topline { min-height: 66px; }
  .brand-small { gap: 8px; font-size: 13px; }
  .small-mark { width: 32px; height: 32px; border-radius: 10px; font-size: 18px; }
  .period-bar { align-items: flex-start; padding: 10px 0 18px; }
  .period-picker select { min-width: 108px; }
  .period-picker select:last-child { min-width: 81px; }
  .device-button { max-width: 120px; font-size: 12px; }
  nav { gap: 6px; margin-right: -16px; padding-bottom: 15px; }
  nav button { padding: 10px 14px; font-size: 13px; }
  .content { padding: 27px 16px 70px; }
  .hero { min-height: 155px; padding: 28px 26px; }
  .hero::after { right: -115px; }
  .balance-row { grid-template-columns: 1fr 140px; }
  .summary-table { min-width: 0; display: block; }
  .summary-table thead { display: none; }
  .summary-table tbody { display: block; }
  .summary-table tr:not(.subtotal) { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px 14px; padding: 17px 19px; border-bottom: 1px solid #edf1ed; }
  .summary-table tr:not(.subtotal) td { width: auto; padding: 0; border: 0; }
  .summary-table tr:not(.subtotal) td:nth-child(4) { grid-column: 1; grid-row: 1; font-size: 15px; font-weight: 800; }
  .summary-table tr:not(.subtotal) td:nth-child(5) { grid-column: 2; grid-row: 1; color: #83958e; font-weight: 700; }
  .summary-table tr:not(.subtotal) td:nth-child(5)::before { content: "Día "; }
  .summary-table tr:not(.subtotal) td:nth-child(1) { grid-column: 1 / -1; grid-row: 2; font-size: 16px; }
  .summary-table tr:not(.subtotal) td:nth-child(2), .summary-table tr:not(.subtotal) td:nth-child(3) { display: grid; gap: 5px; margin-top: 5px; color: #596d67; }
  .summary-table tr:not(.subtotal) td:nth-child(2) { grid-column: 1; grid-row: 3; }
  .summary-table tr:not(.subtotal) td:nth-child(3) { grid-column: 2; grid-row: 3; justify-items: end; align-content: end; }
  .summary-table tr:not(.subtotal) td:nth-child(2)::before, .summary-table tr:not(.subtotal) td:nth-child(3)::before { content: attr(data-label); color: #95a29b; font-size: 11px; font-weight: 750; }
  .summary-table .subtotal { display: block; background: #f1f7f2; }
  .summary-table .subtotal td { display: block; padding: 14px 19px; font-size: 16px; }
  .summary-table .subtotal td:first-child::before { content: "Balance del bloque"; display: block; margin-bottom: 5px; color: #73887b; font-size: 11px; }
  .summary-table .subtotal td:last-child { display: none; }
}
@media (max-width: 390px) {
  .login-card { padding: 30px 25px; }
}
