:root {
  --bg: #111113; --bar: #151518; --surface: #18181b; --card: #1d1d21; --input: #25252a; --note: #222226;
  --line: #2c2c32; --line2: #34343b; --text: #ececef; --soft: #cfcfd6; --muted: #8e8e97; --dim: #6a6a72;
  --accent: #e4573d; --cta: #cf4328; --cta-press: #b93a22; --danger: #ff8b78; --ok: #6fd392; --warn: #f2b45a;
  --safe-top: env(safe-area-inset-top, 0px); --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font-family: Inter, -apple-system, "Segoe UI", sans-serif; font-size: 15px; -webkit-text-size-adjust: 100%; }
body { overscroll-behavior-y: none; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }
.hidden { display: none !important; }

/* ---------- estructura */
#app { min-height: 100%; }
#view { padding: calc(var(--safe-top) + 18px) 16px calc(var(--safe-bottom) + 108px); max-width: 640px; margin: 0 auto;
  display: flex; flex-direction: column; gap: 14px; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; background: var(--bar); border-top: 1px solid var(--line);
  display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); padding: 8px 4px calc(var(--safe-bottom) + 6px); }
.nav button { background: none; border: none; color: var(--muted); display: flex; flex-direction: column; align-items: center;
  gap: 3px; font-size: 11px; min-height: 48px; padding: 0; }
.nav button.on { color: var(--accent); font-weight: 600; }
.nav .plus { width: 54px; height: 54px; border-radius: 27px; background: var(--cta); color: #fff; margin: -6px auto 0;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 6px 18px rgba(207, 67, 40, .35); }
.nav button:active .plus { background: var(--cta-press); }

/* ---------- textos */
.date { font-size: 13px; color: var(--muted); }
h1 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -.3px; }
.greet { font-size: 24px; font-weight: 700; line-height: 1.18; letter-spacing: -.3px; margin: 0; }
.context { font-size: 14px; margin: 0; }
.label { font-size: 11px; font-weight: 700; letter-spacing: .8px; color: var(--muted); text-transform: uppercase; }
.sub { font-size: 13px; color: var(--muted); }
.ok { color: var(--ok); } .warn { color: var(--warn); } .danger { color: var(--danger); } .accent { color: var(--accent); }

/* ---------- piezas */
.row { display: flex; align-items: center; gap: 10px; }
.between { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 18px; padding: 16px; display: flex;
  flex-direction: column; gap: 10px; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tile { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex;
  flex-direction: column; gap: 4px; text-align: left; }
.tile .n { font-size: 25px; font-weight: 700; }
.tile .n.small { font-size: 18px; }
.iconbtn { width: 44px; height: 44px; border-radius: 14px; background: var(--card); border: 1px solid var(--line);
  color: var(--soft); display: inline-flex; align-items: center; justify-content: center; flex: none; position: relative; }
.iconbtn .dot { position: absolute; top: 8px; right: 8px; width: 8px; height: 8px; border-radius: 4px; }
.btn { height: 46px; border-radius: 13px; border: 1px solid var(--line2); background: var(--input); color: var(--text);
  font-weight: 600; font-size: 15px; padding: 0 16px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--cta); border-color: var(--cta); color: #fff; }
.btn.primary:active { background: var(--cta-press); }
.btn.ghost { background: transparent; border-color: transparent; color: var(--soft); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); }
.btn.block { width: 100%; }
.btn.small { height: 40px; font-size: 14px; padding: 0 12px; }
.pill { font-size: 12px; font-weight: 700; border-radius: 8px; padding: 4px 8px; white-space: nowrap; }
.pill.warn { background: #2e2a22; } .pill.ok { background: #1f2b24; }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 0 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip { height: 40px; padding: 0 14px; border-radius: 20px; background: var(--card); color: var(--soft);
  border: 1px solid var(--line); font-size: 14px; font-weight: 600; white-space: nowrap; flex: none; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; background: var(--input); border-radius: 12px; padding: 3px; }
.seg button { height: 38px; border: none; background: transparent; color: var(--soft); border-radius: 10px; font-size: 13px; }
.seg button.on { background: var(--accent); color: #fff; font-weight: 600; }
.empty { color: var(--dim); font-size: 14px; padding: 6px 0; }

/* ---------- listas */
.item { display: flex; align-items: center; gap: 12px; min-height: 46px; background: none; border: none; padding: 2px 0;
  text-align: left; width: 100%; color: var(--text); }
.item .ic { color: var(--accent); flex: none; display: flex; }
.item .t { font-size: 15px; } .item .s { font-size: 12px; color: var(--muted); }
.daytitle { font-size: 13px; font-weight: 700; color: var(--soft); margin-top: 4px; }
.daytitle.today { color: var(--accent); }

/* ---------- calendario */
.month { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 12px 8px; }
.month .wd, .month .grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); text-align: center; }
.month .wd { font-size: 11px; font-weight: 600; color: var(--muted); padding-bottom: 6px; }
.month .day { height: 44px; background: none; border: none; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 3px; color: var(--soft); padding: 0; }
.month .day .num { width: 32px; height: 32px; line-height: 32px; border-radius: 16px; font-size: 15px; }
.month .day.out { color: var(--dim); }
.month .day.today .num { background: var(--accent); color: #fff; font-weight: 700; }
.month .day.sel:not(.today) .num { box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); font-weight: 600; }
.month .day .mark { width: 5px; height: 5px; border-radius: 3px; background: transparent; }
.month .day .mark.on { background: var(--accent); }
.month .day.today .mark.on { background: transparent; }
.evcard { background: var(--card); border: 1px solid var(--line); border-radius: 16px; padding: 14px; display: flex; gap: 12px;
  align-items: flex-start; text-align: left; color: var(--text); width: 100%; }
.evcard .body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.evcard .note { font-size: 13px; color: var(--soft); white-space: pre-line; }

/* ---------- trabajos */
.job .actions { display: flex; gap: 8px; margin-top: 4px; }
.job .actions .btn { flex: 1; }
.job h3 { margin: 0; font-size: 16px; font-weight: 700; }

/* ---------- ideas */
.notes { columns: 2; column-gap: 10px; }
.notecard { break-inside: avoid; margin: 0 0 10px; background: var(--note); border: 1px solid var(--line); border-radius: 16px;
  padding: 14px; display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%; color: var(--text); }
.notecard .bar { height: 4px; width: 32px; border-radius: 2px; background: var(--accent); }
.notecard .tt { font-size: 15px; font-weight: 700; word-break: break-word; }
.notecard .bd { font-size: 13px; color: var(--soft); line-height: 1.4; white-space: pre-line; word-break: break-word;
  display: -webkit-box; -webkit-line-clamp: 9; -webkit-box-orient: vertical; overflow: hidden; }
.search { display: flex; align-items: center; gap: 10px; background: var(--card); border: 1px solid var(--line);
  border-radius: 14px; padding: 0 14px; height: 46px; color: var(--muted); }
.search input { background: transparent; border: none; outline: none; flex: 1; font-size: 16px; color: var(--text); }

/* ---------- finanzas */
.bars { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 10px; align-items: end; height: 130px; }
.bars .col { display: flex; flex-direction: column; align-items: center; gap: 6px; height: 100%; justify-content: flex-end; }
.bars .b { width: 100%; border-radius: 5px; background: #3a3a42; }
.bars .b.on { background: var(--accent); }
.bars .m { font-size: 11px; color: var(--muted); } .bars .m.on { color: var(--text); font-weight: 700; }
.bars .v { font-size: 10px; color: var(--soft); }
.track { height: 6px; border-radius: 3px; background: var(--input); overflow: hidden; }
.track span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* ---------- hoja que sube desde abajo */
.backdrop { position: fixed; inset: 0; background: rgba(0, 0, 0, .55); z-index: 40; opacity: 0; transition: opacity .2s; }
.backdrop.show { opacity: 1; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; top: calc(var(--safe-top) + 34px); z-index: 41; background: var(--surface);
  border-radius: 22px 22px 0 0; display: flex; flex-direction: column; transform: translateY(100%); transition: transform .25s ease;
  max-width: 640px; margin: 0 auto; }
.sheet.show { transform: none; }
.sheet.short { top: auto; max-height: 80%; }
.sheet .grab { width: 40px; height: 5px; border-radius: 3px; background: var(--line2); margin: 8px auto 0; flex: none; }
.sheet .head { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; padding: 6px 8px 6px 12px; flex: none; }
.sheet .head .title { font-size: 17px; font-weight: 700; text-align: center; }
.sheet .head button { background: none; border: none; font-size: 16px; min-height: 44px; padding: 0 8px; }
.sheet .head .cancel { color: var(--soft); justify-self: start; }
.sheet .head .save { color: var(--accent); font-weight: 700; justify-self: end; }
.sheet .content { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 8px 16px calc(var(--safe-bottom) + 24px);
  display: flex; flex-direction: column; gap: 12px; }
.sheet .content > * { flex-shrink: 0; }
.group { background: var(--card); border: 1px solid var(--line); border-radius: 16px; overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 4px; padding: 11px 14px; border-bottom: 1px solid var(--line); }
.field:last-child { border-bottom: none; }
.field span { font-size: 12px; color: var(--muted); }
.field input, .field textarea, .field select { background: transparent; border: none; outline: none; font-size: 16px; padding: 0;
  color: var(--text); width: 100%; }
.field textarea { resize: none; min-height: 72px; line-height: 1.4; }
.fields2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.fields2 .field:first-child { border-right: 1px solid var(--line); }
.box { background: var(--input); border-radius: 12px; padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.box span { font-size: 12px; color: var(--muted); }
.box input { background: transparent; border: none; outline: none; font-size: 16px; font-weight: 600; padding: 0; width: 100%; color: var(--text); }
.switch { display: flex; justify-content: space-between; align-items: center; min-height: 40px; gap: 12px; }
.switch input { appearance: none; -webkit-appearance: none; width: 51px; height: 31px; border-radius: 16px; background: #3a3a40;
  position: relative; transition: background .2s; flex: none; margin: 0; }
.switch input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 27px; height: 27px; border-radius: 14px;
  background: #fff; transition: transform .2s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(20px); }
.preview { background: var(--input); border-radius: 12px; padding: 12px; font-size: 14px; color: var(--soft); white-space: pre-line; }
.check { display: flex; align-items: center; gap: 10px; min-height: 42px; }
.check input[type=checkbox] { width: 22px; height: 22px; accent-color: var(--accent); flex: none; }
.check input[type=text] { flex: 1; background: transparent; border: none; border-bottom: 1px solid var(--line); outline: none;
  font-size: 15px; padding: 6px 0; color: var(--text); }
.x { background: none; border: none; color: var(--dim); width: 36px; height: 36px; font-size: 20px; flex: none; }
.menu { display: flex; flex-direction: column; gap: 8px; }
.menu button { display: flex; align-items: center; gap: 14px; height: 58px; padding: 0 16px; border-radius: 16px; background: var(--card);
  border: 1px solid var(--line); color: var(--text); font-size: 16px; font-weight: 600; text-align: left; }
.menu button .ic { color: var(--accent); display: flex; }
.menu button small { display: block; font-size: 12px; color: var(--muted); font-weight: 400; }

/* ---------- avisos */
#toast { position: fixed; left: 12px; right: 12px; bottom: calc(var(--safe-bottom) + 92px); z-index: 60; background: #26262b;
  border: 1px solid var(--line2); border-radius: 16px; padding: 12px 14px; display: flex; align-items: center; gap: 12px;
  transform: translateY(calc(100% + 140px)); transition: transform .25s ease, visibility 0s .25s; max-width: 600px; margin: 0 auto;
  visibility: hidden; pointer-events: none; }
#toast.show { transform: none; visibility: visible; pointer-events: auto; transition: transform .25s ease; }
#toast .msg { flex: 1; font-size: 14px; }
#toast button { background: none; border: none; color: var(--accent); font-weight: 700; font-size: 14px; min-height: 40px; }
.login { min-height: 100vh; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 18px;
  padding: 32px; text-align: center; }
.login .logo { font-size: 26px; font-weight: 700; letter-spacing: 2px; }

/* ---------- armar presupuesto (pantalla completa, 4 pasos) */
.builder-open { overflow: hidden; }
.builder-open .nav { visibility: hidden; }
.builder-open #toast { bottom: calc(var(--safe-bottom) + 178px); }
.builder { position: fixed; inset: 0; z-index: 30; background: var(--bg); display: flex; flex-direction: column;
  max-width: 640px; margin: 0 auto; }
.bhead { display: flex; align-items: center; gap: 8px; padding: calc(var(--safe-top) + 10px) 12px 6px 6px; flex: none; }
.iconbtn.plain { background: none; border: none; }
.btitle { display: flex; flex-direction: column; flex: 1; min-width: 0; align-items: flex-start; }
.btitle > span { font-size: 18px; font-weight: 700; }
.btitle .tpl { background: none; border: none; padding: 2px 0; color: var(--muted); font-size: 13px; text-align: left;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; min-height: 28px; }
.btitle .tpl:not(:disabled) { color: var(--soft); }
.bsteps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; padding: 4px 16px 8px; flex: none; }
.bsteps button { background: none; border: none; padding: 6px 0 0; display: flex; flex-direction: column; gap: 6px;
  font-size: 11px; color: var(--muted); text-align: left; min-height: 40px; }
.bsteps button span { height: 4px; border-radius: 2px; background: var(--line); }
.bsteps button.done span { background: var(--accent); }
.bsteps button.on { color: var(--text); font-weight: 700; }
.bbody { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 16px 24px; display: flex; flex-direction: column; gap: 12px; }
.bbody > * { flex-shrink: 0; }
.bbody h2 { margin: 4px 0 0; font-size: 22px; font-weight: 700; letter-spacing: -.2px; }
.bbody .label { padding: 4px 4px 0; }
.bfoot { flex: none; background: var(--bar); border-top: 1px solid var(--line); padding: 12px 16px calc(var(--safe-bottom) + 12px);
  display: flex; flex-direction: column; gap: 10px; }
.bfoot.two { flex-direction: row; }
.bfoot.two > .btn { flex: 1; height: 50px; }
.bfoot .row .btn { height: 48px; font-size: 14px; padding: 0 10px; }
.bfoot .btn.big { height: 54px; font-size: 16px; }
.field select { background: transparent; border: none; outline: none; font-size: 16px; color: var(--text); padding: 0; }
.field .inline { display: flex; align-items: center; gap: 6px; font-size: 16px; color: var(--soft); }
.field .inline input { width: 52px; text-align: center; background: var(--input); border-radius: 8px; padding: 4px 0; font-weight: 600; }
.group.pad { padding: 6px 14px 10px; display: flex; flex-direction: column; }
.deliv { border-bottom: 1px solid var(--line); padding: 4px 0; }
.deliv:last-of-type { border-bottom: none; }
.switch small { display: block; font-size: 12px; color: var(--muted); }
.switch > span { font-size: 15px; }
.dur { display: flex; align-items: center; gap: 8px; padding: 2px 0 10px; font-size: 13px; color: var(--muted); }
.dur input { width: 56px; height: 40px; text-align: center; background: var(--input); border: none; border-radius: 10px;
  font-size: 16px; font-weight: 600; color: var(--text); outline: none; }
.dur .step { width: 40px; height: 40px; border-radius: 12px; background: var(--input); border: none; color: var(--text); font-size: 20px; }
.lrow { display: flex; align-items: center; gap: 6px; border-bottom: 1px solid var(--line); }
.lrow input { flex: 1; min-width: 0; background: transparent; border: none; outline: none; font-size: 16px; padding: 12px 0; color: var(--text); }
.add { align-self: flex-start; color: var(--accent); padding: 0; margin-top: 6px; }
.pages { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 0; border-radius: 8px; scrollbar-width: none;
  background: #0f0f11; box-shadow: 0 10px 30px rgba(0, 0, 0, .45); }
.pages::-webkit-scrollbar { display: none; }
.pages .pg { flex: 0 0 100%; scroll-snap-align: start; display: flex; }
.pages canvas { display: block; border-radius: 6px; }
.pdots { display: flex; align-items: center; gap: 6px; justify-content: center; }
.pdots span:not(.sub) { width: 6px; height: 6px; border-radius: 3px; background: var(--line2); transition: width .2s; }
.pdots span.on { width: 18px; background: var(--accent); }
.pdots .sub { margin-left: 6px; }
.warnbox { background: #2e2a22; border-color: #4a3d26; color: var(--warn); gap: 4px; font-size: 14px; }
.picker { position: fixed; inset: 0; z-index: 50; background: rgba(0, 0, 0, .55); display: flex; align-items: flex-start;
  justify-content: center; padding: calc(var(--safe-top) + 64px) 12px 12px; }
.pbox { background: var(--card); border: 1px solid var(--line2); border-radius: 18px; padding: 8px; width: 100%; max-width: 420px;
  display: flex; flex-direction: column; box-shadow: 0 18px 40px rgba(0, 0, 0, .5); max-height: 80vh; overflow-y: auto; }
.pbox button { display: flex; justify-content: space-between; align-items: center; min-height: 48px; padding: 0 12px; border: none;
  background: none; color: var(--text); font-size: 16px; border-radius: 12px; text-align: left; }
.pbox button.on { color: var(--accent); font-weight: 700; background: var(--input); }
@media (orientation: landscape) and (max-height: 520px) {
  .bhead { padding-top: calc(var(--safe-top) + 4px); padding-bottom: 2px; }
  .btitle > span { font-size: 16px; }
  .bfoot { flex-direction: row; flex-wrap: nowrap; padding-top: 8px; padding-bottom: calc(var(--safe-bottom) + 8px);
    padding-left: max(16px, env(safe-area-inset-left)); padding-right: max(16px, env(safe-area-inset-right)); }
  .bfoot .btn, .bfoot .btn.big { height: 44px; font-size: 14px; white-space: nowrap; padding: 0 10px; }
  .bfoot .hint { display: none; }
  .bfoot .row { flex: 2; }
  .bfoot > .btn.big { flex: 2; }
  .bfoot > .btn.ghost { flex: 1; }
  .bsteps { padding-bottom: 2px; }
  .builder-open #toast { bottom: calc(var(--safe-bottom) + 72px); }
}
