/* ===== Mi Agenda y Finanzas · diseño sobrio ===== */
:root {
  --bg: #f7f6f3; --card: #ffffff; --card2: #f1f0ec; --text: #1f2123; --muted: #8b8a85;
  --line: #ebe9e4; --line2: #d9d6cf;
  --pri: #1f2123; --pri-soft: #efeee9; --on-pri: #ffffff;
  --green: #4f7d6f; --green-soft: #e8efeb; --red: #b4544a; --red-soft: #f6e9e6; --amber: #a87a32; --amber-soft: #f4eee2; --blue: #5b6b8c;
  --q1: #b4544a; --q2: #5b6b8c; --q3: #a87a32; --q4: #b5b3ad;
  --shadow: none;
  --r: 16px; --nav-h: 62px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #131313; --card: #1b1b1b; --card2: #232322; --text: #ecebe7; --muted: #8f8e89;
    --line: #272726; --line2: #3a3a38;
    --pri: #ecebe7; --pri-soft: #262625; --on-pri: #131313;
    --green: #8db5a5; --green-soft: #1d2a25; --red: #d98a80; --red-soft: #2e1f1d; --amber: #d1a65a; --amber-soft: #2b2519; --blue: #95a3c2;
    --q1: #d98a80; --q2: #95a3c2; --q3: #d1a65a; --q4: #6d6c68;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #131313; --card: #1b1b1b; --card2: #232322; --text: #ecebe7; --muted: #8f8e89;
  --line: #272726; --line2: #3a3a38;
  --pri: #ecebe7; --pri-soft: #262625; --on-pri: #131313;
  --green: #8db5a5; --green-soft: #1d2a25; --red: #d98a80; --red-soft: #2e1f1d; --amber: #d1a65a; --amber-soft: #2b2519; --blue: #95a3c2;
  --q1: #d98a80; --q2: #95a3c2; --q3: #d1a65a; --q4: #6d6c68;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font); font-feature-settings: "cv11", "ss01";
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
  -webkit-font-smoothing: antialiased; -webkit-tap-highlight-color: transparent; overflow-x: hidden;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 96px);
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, h4 { letter-spacing: -.015em; font-weight: 600; }
small { font-size: 12.5px; color: var(--muted); }
b { font-weight: 600; }
.muted { color: var(--muted); }
.red { color: var(--red); } .green { color: var(--green); } .amber { color: var(--amber); }
.b { font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }
.empty { color: var(--muted); text-align: center; padding: 18px 8px; margin: 0; font-size: 14px; }
.hidden { display: none !important; }
.summary { color: var(--muted); font-size: 13.5px; margin: 4px 2px 18px; }

/* ===== Barra superior ===== */
#top {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  padding: calc(env(safe-area-inset-top) + 10px) 20px 6px;
}
.top-in { max-width: 560px; margin: 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.mini-timer { border: 1px solid var(--line2); background: transparent; color: var(--text); border-radius: 999px; padding: 4px 12px; font-weight: 500; font-size: 13.5px; font-variant-numeric: tabular-nums; }
.ptitle { max-width: 560px; margin: 14px auto 2px; font-size: 28px; font-weight: 600; letter-spacing: -.025em; }

.secswitch { display: flex; gap: 22px; }
.secswitch button { border: 0; background: transparent; padding: 6px 0; font-weight: 500; font-size: 15px; color: var(--muted); position: relative; transition: color .2s; }
.secswitch button.on { color: var(--text); }
.secswitch button.on::after { content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px; background: var(--text); border-radius: 2px; }
.gear { width: 38px; height: 38px; }
.gear.on { color: var(--text); background: var(--card2); }

main { max-width: 560px; margin: 0 auto; padding: 0 20px; }

/* ===== Tarjetas ===== */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--r); padding: 18px; margin: 14px 0; }
.card > h3, .card-h { margin: 0 0 12px; font-size: 15px; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-h h3 { margin: 0; font-size: 15px; }
.sec-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 500; margin: 24px 2px 8px; }
.hero { padding: 0 0 4px; }
.hero h2 { margin: 0; font-size: 17px; font-weight: 500; color: var(--muted); letter-spacing: -.01em; }
.hero p { display: none; }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 14px 0; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.stats.two { grid-template-columns: repeat(2, 1fr); }
.stat { background: var(--card); padding: 14px; min-width: 0; }
.stat small { display: block; margin-bottom: 2px; }
.stat b { display: block; font-size: 18px; font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat b.green, .stat b.red { color: var(--text); }

/* ===== Botones ===== */
.btn { border: 1px solid var(--line2); border-radius: 12px; padding: 10px 16px; font-weight: 500; background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; transition: background .15s, opacity .15s; }
.btn:hover { background: var(--card2); }
.btn.primary { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
.btn.primary:hover { opacity: .9; }
.btn.ghost { border: 0; background: transparent; color: var(--muted); padding: 4px 2px; min-height: 0; font-size: 14px; }
.btn.ghost:hover { color: var(--text); background: transparent; }
.btn.danger { border-color: transparent; background: var(--red-soft); color: var(--red); }
.btn.green { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
.btn.outline { background: transparent; border-color: var(--line2); color: var(--text); }
.btn.sm { padding: 6px 12px; min-height: 34px; font-size: 13.5px; border-radius: 10px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .45; }
.ic { border: 0; background: transparent; width: 36px; height: 36px; border-radius: 10px; display: inline-grid; place-items: center; color: var(--muted); flex: none; font-size: 15px; }
.ic:hover { color: var(--text); }
.ic:active, .btn:active { transform: scale(.98); }
.ic svg, .btn svg { width: 19px; height: 19px; stroke-width: 1.7; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.cta {
  width: 100%; border: 1px solid var(--line); text-align: left; border-radius: var(--r); padding: 14px 18px; margin: 14px 0;
  background: var(--card); color: var(--text); display: flex; align-items: center; gap: 12px; position: relative;
}
.cta::after { content: "›"; margin-left: auto; color: var(--muted); font-size: 20px; }
.cta b { display: block; font-size: 15px; font-weight: 500; }
.cta span { color: var(--muted); font-size: 13px; }

/* ===== Chips y selector ===== */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 6px; scrollbar-width: none; margin: 10px 0 6px; }
.chips::-webkit-scrollbar { display: none; }
.chip { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 14px; font-size: 13.5px; font-weight: 500; white-space: nowrap; color: var(--muted); }
.chip.on { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
.seg { display: flex; background: var(--card2); border-radius: 12px; padding: 3px; gap: 2px; margin: 12px 0; }
.seg > * { flex: 1 1 0; min-width: 0; border: 0; background: transparent; border-radius: 9px; padding: 8px 6px; font-weight: 500; font-size: 13.5px; color: var(--muted); text-align: center; }
.seg > .on, .seg input:checked + span { background: var(--card); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,.06); }
.seg label { padding: 0; display: flex; }
.seg label input { position: absolute; opacity: 0; pointer-events: none; }
.seg label span { flex: 1; border-radius: 9px; padding: 8px 6px; }
.seg.mini { margin: 0 0 12px; }
.pill { display: inline-block; font-size: 11.5px; font-weight: 500; padding: 1px 8px; border-radius: 999px; background: var(--card2); color: var(--muted); }
.pill.red { background: var(--red-soft); color: var(--red); }
.pill.green { background: var(--green-soft); color: var(--green); }
.pill.amber { background: var(--amber-soft); color: var(--amber); }

/* ===== Tira semanal ===== */
.weeknav { display: flex; align-items: center; gap: 2px; margin: 10px -8px 0; }
.week { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.wd { border: 0; background: transparent; border-radius: 12px; padding: 6px 0 9px; display: flex; flex-direction: column; align-items: center; position: relative; }
.wd small { font-size: 11px; text-transform: capitalize; }
.wd b { font-size: 16px; font-weight: 500; }
.wd i { position: absolute; bottom: 3px; width: 4px; height: 4px; border-radius: 50%; background: var(--line2); }
.wd.today b { color: var(--text); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1.5px; }
.wd.sel { background: var(--pri); }
.wd.sel b, .wd.sel small { color: var(--on-pri); text-decoration: none; }
.wd.sel i { background: var(--on-pri); opacity: .6; }

/* ===== Bloques de tiempo ===== */
.blk { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.blk:last-child { border-bottom: 0; }
.blk-time { width: 62px; text-align: right; font-weight: 500; font-size: 13.5px; font-variant-numeric: tabular-nums; flex: none; }
.blk-time small { font-weight: 400; }
.blk-body { flex: 1; min-width: 0; border-left: 2px solid var(--c); padding-left: 12px; cursor: pointer; }
.blk-body b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.blk.now { background: var(--card2); border-radius: 12px; margin: 0 -10px; padding-left: 10px; padding-right: 10px; border-bottom-color: transparent; }
.blk.done .blk-body b { text-decoration: line-through; color: var(--muted); }
.blk.past:not(.done) { opacity: .55; }
.gap { width: 100%; border: 1px dashed var(--line2); background: transparent; border-radius: 12px; padding: 8px 12px; margin: 8px 0; color: var(--muted); font-size: 13px; text-align: left; display: flex; justify-content: space-between; }
.gap b { color: var(--text); font-weight: 500; }

/* ===== Tareas ===== */
.quick { display: flex; flex-direction: column; gap: 10px; }
.quick-in { display: flex; gap: 8px; }
.quick-in input { flex: 1; }
.tog { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 5px 12px; font-size: 13px; font-weight: 500; color: var(--muted); }
.tog.on.imp { background: var(--q2); border-color: var(--q2); color: #fff; }
.tog.on.urg { background: var(--q1); border-color: var(--q1); color: #fff; }
.qhead { display: flex; align-items: center; gap: 8px; margin: 22px 2px 6px; font-weight: 500; font-size: 13px; color: var(--muted); }
.qhead i { width: 6px; height: 6px; border-radius: 50%; background: var(--qc); }
.qhead small { font-weight: 400; }
.task { display: flex; align-items: center; gap: 12px; padding: 12px 4px 12px 0; border-bottom: 1px solid var(--line); }
.card .task:last-child { border-bottom: 0; }
.task-body { flex: 1; min-width: 0; cursor: pointer; }
.task-body b { display: block; font-weight: 500; overflow-wrap: anywhere; }
.task-body small { display: flex; flex-wrap: wrap; gap: 0 6px; align-items: center; }
.task.done .task-body b { text-decoration: line-through; color: var(--muted); }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; flex: none; }
.chk { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line2); background: transparent; flex: none; display: grid; place-items: center; padding: 0; transition: .15s; }
.chk:hover { border-color: var(--muted); }
.chk.on { background: var(--pri); border-color: var(--pri); }
.chk.on::after { content: ""; width: 5px; height: 9px; border: solid var(--on-pri); border-width: 0 1.8px 1.8px 0; transform: rotate(45deg) translate(-1px, -1px); }
.star { font-size: 17px; color: var(--line2); }
.star.on { color: var(--text); }

/* ===== Matriz ===== */
.matrix { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 8px; }
.mq { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 12px; min-height: 170px; display: flex; flex-direction: column; min-width: 0; }
.mq h4 { margin: 0; font-size: 13.5px; display: flex; justify-content: space-between; gap: 4px; align-items: center; }
.mq h4 > span:first-child::before { content: ""; display: inline-block; width: 6px; height: 6px; border-radius: 50%; background: var(--qc); margin-right: 7px; vertical-align: 2px; }
.mq > small { margin-bottom: 8px; }
.mq .mi { border: 0; background: var(--card2); border-radius: 8px; padding: 7px 9px; margin: 3px 0; font-size: 13px; text-align: left; overflow-wrap: anywhere; }
.axis { display: flex; justify-content: space-around; font-size: 11px; color: var(--muted); font-weight: 500; text-transform: uppercase; letter-spacing: .08em; }

/* ===== Temporizador ===== */
.timer { position: relative; width: min(250px, 70vw); aspect-ratio: 1; margin: 18px auto 8px; }
.timer svg { width: 100%; height: 100%; }
.timer .trk { fill: none; stroke: var(--line); stroke-width: 4; }
.timer .prog { fill: none; stroke: var(--text); stroke-width: 4; stroke-linecap: round; transition: stroke-dashoffset .9s linear; }
.timer.short .prog, .timer.long .prog { stroke: var(--green); }
.tcenter { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
#tleft { font-size: 52px; font-weight: 300; font-variant-numeric: tabular-nums; letter-spacing: -.03em; }
.tbtns { display: flex; align-items: center; justify-content: center; gap: 22px; margin: 10px 0 18px; }
.tbtns .play { width: 64px; height: 64px; border-radius: 50%; border: 0; background: var(--pri); color: var(--on-pri); display: grid; place-items: center; }
.tbtns .play svg { width: 24px; height: 24px; }
.tbtns .ic { width: 44px; height: 44px; border: 1px solid var(--line2); border-radius: 50%; font-weight: 500; color: var(--text); }
.focus-task { text-align: center; font-weight: 500; margin: 0 0 8px; }

/* ===== Formularios ===== */
input[type=text], input[type=number], input[type=date], input[type=time], input:not([type]), input[type=search], select, textarea {
  width: 100%; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 10px 12px; font-size: 16px; min-height: 46px; outline: none; transition: border-color .15s;
}
.card input[type=text], .card input:not([type]), .card input[type=search], .card select, .card input[type=date], .card input[type=number] { background: var(--bg); }
textarea { min-height: 70px; resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--muted); }
.f { display: block; margin: 0 0 14px; }
.f > span { display: block; font-size: 13px; color: var(--muted); margin: 0 0 6px 2px; font-weight: 500; }
.f > small { display: block; margin: 5px 2px 0; }
.amount { font-size: 30px !important; font-weight: 400; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.switch { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; margin: 0 0 8px; cursor: pointer; }
.switch input { width: 19px; height: 19px; accent-color: var(--pri); flex: none; }
.switch span { font-weight: 500; }
.switch small { margin-left: auto; text-align: right; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.catchip { display: block; }
.catchip input { position: absolute; opacity: 0; pointer-events: none; }
.catchip span { display: block; padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line); font-size: 13.5px; color: var(--muted); cursor: pointer; text-align: center; }
.catchip input:checked + span { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
form[data-type="income"] .cats-expense, form[data-type="expense"] .cats-income { display: none; }
form[data-fixed="off"] .only-fixed, form[data-fixed="on"] .only-once,
form[data-scope="one"] .only-all, form[data-scope="all"] .only-one { display: none; }
.daychips { display: grid; grid-template-columns: repeat(7, 1fr); gap: 5px; }
.daychips .catchip span { padding: 9px 0; font-weight: 500; border-radius: 10px; }

/* ===== Listas ===== */
.li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line); }
.li:last-child { border-bottom: 0; }
.li .em { width: 34px; height: 34px; border-radius: 50%; background: color-mix(in srgb, var(--c, var(--muted)) 14%, transparent); color: var(--c, var(--muted)); display: grid; place-items: center; font-size: 13px; font-weight: 600; flex: none; }
.li .mid { flex: 1; min-width: 0; }
.li .mid b { display: block; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .mid small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.li .amt { font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; text-align: right; }
.li.tap, .tap { cursor: pointer; }
.day-h { font-size: 12px; font-weight: 500; color: var(--muted); margin: 16px 0 2px; display: flex; justify-content: space-between; }
.day-h span:first-child::first-letter { text-transform: uppercase; }
.day-h:first-child { margin-top: 8px; }

/* ===== Progreso ===== */
.bar { height: 4px; border-radius: 99px; background: var(--card2); overflow: hidden; margin: 8px 0 5px; position: relative; }
.bar > i { display: block; height: 100%; border-radius: 99px; background: var(--c, var(--text)); max-width: 100%; }
.bar.thin { height: 3px; }
.bucket { margin: 16px 0; }
.bucket-h { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.bucket-h b { font-size: 14.5px; font-weight: 500; }
.prog-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12.5px; color: var(--muted); }

/* ===== Selector de mes ===== */
.monthbar { display: flex; align-items: center; justify-content: space-between; padding: 0; margin: 4px -8px 6px; }
.monthbar b { font-size: 15px; font-weight: 500; }

/* ===== Gráficos ===== */
.chart { width: 100%; height: auto; display: block; }
.chart text { fill: var(--muted); font-size: 10.5px; font-family: var(--font); }
.chart text.hl { fill: var(--text); font-weight: 600; }
.donut-wrap { display: flex; align-items: center; gap: 18px; }
.donut-wrap svg { flex: none; }
.legend { flex: 1; min-width: 0; font-size: 13px; }
.legend div { display: flex; align-items: center; gap: 8px; padding: 3px 0; }
.legend span { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.legend span.dot { flex: none; }
.legend b { font-variant-numeric: tabular-nums; font-weight: 500; color: var(--muted); }
.donut-c { fill: var(--text); font-weight: 600; }

/* ===== Observaciones ===== */
.ins { padding: 10px 0; border-bottom: 1px solid var(--line); font-size: 14px; color: var(--muted); }
.ins b { color: var(--text); }
.ins:last-child { border-bottom: 0; }

/* ===== Consejos plegables ===== */
details.tip { margin: 18px 2px; font-size: 14px; color: var(--muted); }
details.tip summary { cursor: pointer; list-style: none; font-weight: 500; color: var(--muted); display: flex; align-items: center; gap: 8px; }
details.tip summary::-webkit-details-marker { display: none; }
details.tip summary::before { content: "+"; width: 18px; height: 18px; border: 1px solid var(--line2); border-radius: 50%; display: grid; place-items: center; font-size: 13px; line-height: 1; }
details.tip[open] summary::before { content: "−"; }
details.tip p { margin: 8px 0 0 26px; line-height: 1.55; }

/* ===== Ruta ===== */
.steps { list-style: none; margin: 0; padding: 0; }
.steps li { display: flex; gap: 14px; padding: 9px 0; position: relative; }
.steps li::before { content: ""; position: absolute; left: 11px; top: 34px; bottom: -9px; width: 1px; background: var(--line); }
.steps li:last-child::before { display: none; }
.steps .n { width: 23px; height: 23px; border-radius: 50%; display: grid; place-items: center; font-weight: 500; font-size: 12px; border: 1px solid var(--line2); color: var(--muted); flex: none; z-index: 1; background: var(--card); }
.steps .ok .n { background: var(--card2); border-color: var(--card2); color: var(--muted); }
.steps .cur .n { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
.steps b { display: block; font-size: 14.5px; font-weight: 500; }
.steps small { display: block; }
.steps .ok b { color: var(--muted); text-decoration: line-through; }
.steps .pill { display: none; }

/* ===== Deudas ===== */
.debt-hero { text-align: left; padding: 2px 0; }
.debt-hero .big { font-size: 34px; font-weight: 400; letter-spacing: -.03em; color: var(--text) !important; font-variant-numeric: tabular-nums; margin: 2px 0 4px; }
.counter { display: flex; align-items: center; gap: 14px; border-top: 1px solid var(--line); padding: 14px 0 0; margin-top: 14px; }
.counter .d { font-size: 26px; font-weight: 400; color: var(--text); font-variant-numeric: tabular-nums; }
.counter b { font-weight: 500; }
.cmp { width: 100%; border-collapse: collapse; font-size: 13.5px; margin-top: 10px; }
.cmp th, .cmp td { padding: 8px 4px; border-bottom: 1px solid var(--line); text-align: right; }
.cmp th:first-child, .cmp td:first-child { text-align: left; }
.cmp th { color: var(--muted); font-weight: 500; font-size: 12px; }
.cmp tr.best td { color: var(--green); font-weight: 500; }

/* ===== Botón flotante / navegación ===== */
#fab {
  position: fixed; z-index: 9; right: max(20px, calc(50vw - 260px));
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 18px);
  width: 54px; height: 54px; padding: 0; border-radius: 50%; border: 0;
  background: var(--pri); color: var(--on-pri);
  box-shadow: 0 6px 20px rgba(0,0,0,.14); display: grid; place-items: center;
}
#fab[hidden] { display: none; }
#fab svg { width: 22px; height: 22px; stroke-width: 1.8; }
#fab span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; background: color-mix(in srgb, var(--bg) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
#nav .in { max-width: 560px; margin: 0 auto; display: grid; grid-template-columns: repeat(5, 1fr); height: var(--nav-h); }
#nav button { background: none; border: 0; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 10.5px; font-weight: 500; transition: color .15s; }
#nav button.on { color: var(--text); }
#nav svg { width: 22px; height: 22px; stroke-width: 1.5; }

/* ===== Hoja (diálogo) ===== */
dialog#sheet { border: 0; padding: 0; width: 100%; max-width: 560px; max-height: 92vh; margin: auto auto 0; border-radius: 22px 22px 0 0; background: var(--card); color: var(--text); overflow: hidden; }
dialog#sheet[open] { animation: up .24s cubic-bezier(.2,.8,.2,1); }
dialog::backdrop { background: rgba(0,0,0,.32); }
@keyframes up { from { transform: translateY(30px); opacity: .5; } to { transform: none; opacity: 1; } }
@media (min-width: 640px) { dialog#sheet { margin: auto; border-radius: 22px; } }
.sheet-form { display: flex; flex-direction: column; max-height: 92vh; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 14px 8px 22px; }
.sheet-head h2 { margin: 0; font-size: 18px; font-weight: 600; }
.sheet-body { overflow: auto; padding: 10px 22px 8px; -webkit-overflow-scrolling: touch; }
.sheet-foot { padding: 12px 22px calc(16px + env(safe-area-inset-bottom)); display: flex; gap: 8px; flex-wrap: wrap; }
.sheet-foot .primary { flex: 1; min-width: 120px; }
.sheet-body p { margin: 0 0 12px; }
.sheet-body input[type=text], .sheet-body input:not([type]), .sheet-body select, .sheet-body input[type=date], .sheet-body input[type=time], .sheet-body input[type=number] { background: var(--bg); }
.note { background: var(--card2); border: 0; border-radius: 12px; padding: 12px 14px; font-size: 13.5px; margin: 0 0 12px; color: var(--text); }
.note.warn { background: var(--amber-soft); }
.card.note { border: 0; }

/* ===== Aviso ===== */
#toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 86px); transform: translateX(-50%) translateY(16px); background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 500; opacity: 0; pointer-events: none; transition: .25s; z-index: 50; max-width: calc(100vw - 40px); text-align: center; }
#toast.show { opacity: 1; transform: translateX(-50%); }

/* ===== Ajustes ===== */
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.set-row:last-child { border-bottom: 0; }
.set-row > span { font-weight: 500; }
.set-row > span small { display: block; font-weight: 400; }
.set-row input, .set-row select { width: 46%; max-width: 200px; }
.rule-in { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.tipbox { font-size: 14px; }
.tipbox b { display: block; margin-bottom: 2px; }

/* ===== Calendario semanal ===== */
.weekbar { display: flex; align-items: center; gap: 6px; margin: 4px -8px 6px; }
.weekbar b { flex: 1; text-align: center; font-size: 15px; font-weight: 500; text-transform: capitalize; }
.wgrid { padding: 10px 8px 12px 4px; overflow: hidden; }
.wrow { display: flex; }
.wrow > :first-child { width: 34px; flex: none; }
.wheads { padding-bottom: 8px; }
.wdh { flex: 1; border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; padding: 2px 0; border-radius: 10px; min-width: 0; }
.wdh small { font-size: 10.5px; text-transform: capitalize; }
.wdh b { font-size: 14px; font-weight: 500; width: 26px; height: 26px; display: grid; place-items: center; }
.wdh.today b { background: var(--pri); color: var(--on-pri); border-radius: 50%; }
.whours { position: relative; }
.wh { position: absolute; right: 4px; transform: translateY(-50%); font-size: 9px; white-space: nowrap; color: var(--muted); font-variant-numeric: tabular-nums; }
.wh:first-child { transform: none; }
.wcols { flex: 1; display: grid; grid-template-columns: repeat(7, 1fr); border-top: 1px solid var(--line); }
.wcol { position: relative; border-left: 1px solid var(--line); cursor: copy;
  background-image: repeating-linear-gradient(to bottom, transparent 0, transparent calc(var(--hh) - 1px), var(--line) calc(var(--hh) - 1px), var(--line) var(--hh)); }
.wcol.today { background-color: color-mix(in srgb, var(--text) 3%, transparent); }
.wblk { position: absolute; border: 0; border-radius: 4px; padding: 2px 2px 2px 4px; text-align: left; overflow: hidden; font-size: 10.5px; line-height: 1.2;
  background: color-mix(in srgb, var(--c) 16%, var(--card)); border-left: 2px solid var(--c); color: var(--text); display: flex; flex-direction: column; }
.wblk b { font-weight: 500; font-size: 9.5px; letter-spacing: -.01em; word-break: keep-all; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wblk small { font-size: 9.5px; }
.wblk i { display: none; }
.wblk.ov { outline: 1px dashed var(--c); outline-offset: -2px; }
.wblk.done { opacity: .45; }
.wblk.done b { text-decoration: line-through; }
.wnow { position: absolute; left: -1px; right: 0; height: 1.5px; background: var(--red); z-index: 2; pointer-events: none; }
.wnow::before { content: ""; position: absolute; left: -3px; top: -2.5px; width: 6px; height: 6px; border-radius: 50%; background: var(--red); }

/* ===== Calendario mensual ===== */
.mgrid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; padding: 10px; }
.mh { text-align: center; font-size: 11px; font-weight: 500; color: var(--muted); padding: 2px 0 6px; }
.mcell { border: 0; background: transparent; border-radius: 10px; aspect-ratio: 1 / 1.1; padding: 5px 2px; display: flex; flex-direction: column; align-items: center; gap: 3px; position: relative; min-width: 0; }
.mcell:hover { background: var(--card2); }
.mcell b { font-size: 14px; font-weight: 500; }
.mcell.out { opacity: .3; }
.mcell.today { background: var(--pri); }
.mcell.today b, .mcell.today small { color: var(--on-pri); }
.mdots { display: flex; gap: 2px; flex-wrap: wrap; justify-content: center; }
.mdots i { width: 4px; height: 4px; border-radius: 50%; }
.mcell small { display: none; }
.mcell em { position: absolute; top: 5px; right: 6px; width: 4px; height: 4px; border-radius: 50%; background: var(--red); }

/* ===== Finanzas ===== */
.fdate { margin: 0 2px 8px; color: var(--muted); font-size: 13px; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; margin: 10px 0 14px; background: var(--line); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.kpi { background: var(--card); padding: 14px 12px; min-width: 0; }
.kpi small { display: block; margin-bottom: 4px; line-height: 1.3; }
.kpi b { display: block; font-size: clamp(16px, 4.8vw, 21px); font-weight: 500; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; letter-spacing: -.02em; }
.kpi.hl b.red { color: var(--red); }
.spend { display: flex; align-items: center; justify-content: space-between; gap: 14px; }
.spend small.lbl { display: block; }
.spend b { display: block; font-size: 24px; font-weight: 400; letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.spend b.red { color: var(--red); }
.spend > small { text-align: right; max-width: 52%; }
.seg.mini button.on { background: var(--card); color: var(--text); }
.qamount { width: 100%; border: 0; background: transparent; font-size: 30px; font-weight: 400; padding: 4px 2px 10px; color: var(--text); outline: none; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.qamount::placeholder { color: var(--line2); }
.pchips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.pchip input { position: absolute; opacity: 0; pointer-events: none; }
.pchip span { display: inline-block; padding: 6px 12px; border-radius: 999px; border: 1px solid var(--line); font-size: 13px; color: var(--muted); cursor: pointer; }
.pchip input:checked + span { background: var(--pri); border-color: var(--pri); color: var(--on-pri); }
#quickTx[data-type="expense"] .pc-income, #quickTx[data-type="income"] .pc-expense { display: none; }
.bgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.bitem { min-width: 0; }
.bitem .bucket-h { font-size: 13px; }
.bitem .bucket-h span:first-child { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bitem .bucket-h .num { font-size: 11.5px; color: var(--muted); white-space: nowrap; }
.hint { display: block; text-align: right; margin-top: 10px; font-size: 11px; }
.li.mv { gap: 12px; }
.card input.qamount { background: transparent; border: 0; border-bottom: 1px solid var(--line); border-radius: 0; min-height: 0; padding: 4px 2px 10px; margin-bottom: 14px; font-size: 30px; }
.pchips { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -18px 14px; padding: 0 18px; }
.pchips::-webkit-scrollbar { display: none; }
.pchip span { white-space: nowrap; }
.blk .ic svg, .task .ic svg { width: 15px; height: 15px; }
.blk .ic, .task .ic { color: var(--line2); }
.blk .ic:hover, .task .ic:hover { color: var(--text); }
.row2 > * { min-width: 0; }
input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-width: 0; max-width: 100%; display: block; text-align: left; }
input[type=date]::-webkit-date-and-time-value, input[type=time]::-webkit-date-and-time-value { text-align: left; }
