:root {
  color-scheme: dark;
  --fondo: #0b0e1a; --panel: rgba(255,255,255,.045); --panel2: rgba(255,255,255,.075); --borde: rgba(255,255,255,.09);
  --tinta: #f2f4fb; --tinta2: #aab2c8; --tinta3: #78809a;
  --morado: #8b5cf6; --cian: #22d3ee; --naranja: #fb923c; --bien: #34d399; --mal: #f87171;
  --r: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: radial-gradient(900px 600px at 85% -10%, rgba(139,92,246,.28), transparent 65%),
              radial-gradient(800px 600px at -5% 105%, rgba(34,211,238,.16), transparent 65%), var(--fondo);
  background-attachment: fixed; color: var(--tinta);
  font: 14px/1.4 "Segoe UI Variable Text", "Segoe UI", system-ui, sans-serif; overflow: hidden;
}
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 16px; font-weight: 650; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: inherit; text-decoration: none; }
:focus-visible { outline: 2px solid var(--cian); outline-offset: 2px; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

#app { display: flex; height: 100%; gap: 14px; padding: 14px; }
#riel { width: 68px; flex: none; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 12px 0; background: var(--panel); border: 1px solid var(--borde); border-radius: 24px; }
#menu { display: flex; flex-direction: column; gap: 8px; flex: 1; margin-top: 8px; }
.marca img { width: 44px; height: 44px; border-radius: 50%; object-fit: cover; background: linear-gradient(135deg, var(--morado), var(--cian)); display: block; }
.item { width: 46px; height: 46px; border-radius: 50%; display: grid; place-items: center; color: var(--tinta2); transition: .15s; }
.item span { display: none; }
.item:hover { background: var(--panel2); color: var(--tinta); }
.item.on { background: linear-gradient(135deg, var(--morado), var(--cian)); color: #fff; }
#vista { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 14px; overflow: hidden; }
.scroll { overflow-y: auto; flex: 1; min-height: 0; padding-right: 4px; }
::-webkit-scrollbar { width: 8px; height: 8px; } ::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border-radius: 8px; }

.cabeza { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-height: 44px; }
.cabeza .sub { color: var(--tinta2); }
.espacio { flex: 1; }
.tarjeta { background: var(--panel); border: 1px solid var(--borde); border-radius: var(--r); padding: 16px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: 12px; background: var(--panel2); border: 1px solid var(--borde); font-weight: 600; white-space: nowrap; }
.btn:hover { background: rgba(255,255,255,.12); }
.btn.principal { background: linear-gradient(135deg, #7c4df0, #18b6d4); border-color: transparent; color: #fff; }
.btn.principal:hover { filter: brightness(1.12); }
.btn.peligro { color: var(--mal); }
.btn.chico { height: 32px; padding: 0 10px; font-size: 13px; border-radius: 10px; }
.redondo { width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--panel2); border: 1px solid var(--borde); }
.redondo:hover { background: rgba(255,255,255,.12); }
.seg { display: inline-flex; padding: 3px; background: var(--panel); border: 1px solid var(--borde); border-radius: 12px; }
.seg button { height: 30px; padding: 0 12px; border-radius: 9px; color: var(--tinta2); font-weight: 600; }
.seg button.on { background: var(--tinta); color: #10131f; }

/* Inicio */
.saludo { padding: 8px 4px 6px; } .saludo p { color: var(--tinta2); margin-top: 2px; }
.cuadros { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.cuadro { display: flex; flex-direction: column; gap: 6px; min-height: 170px; padding: 20px; border-radius: 20px; border: 1px solid var(--borde); background: var(--panel); transition: .15s; position: relative; overflow: hidden; }
a.cuadro:hover { transform: translateY(-2px); background: var(--panel2); }
.cuadro .ico { width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; color: #fff; margin-bottom: auto; }
.cuadro h2 { font-size: 19px; } .cuadro p { color: var(--tinta2); }
.cuadro.pronto { border-style: dashed; background: none; } .cuadro.pronto .ico { background: var(--panel2) !important; color: var(--tinta2); }

/* Calendario */
.calendario { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 300px; gap: 14px; }
.cal { display: flex; flex-direction: column; min-height: 0; padding: 12px; }
.dias { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; color: var(--tinta3); font-size: 12px; padding: 0 2px 6px; }
.mes { flex: 1; min-height: 0; display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); grid-auto-rows: minmax(0, 1fr); gap: 6px; }
.celda { min-height: 0; overflow: hidden; display: flex; flex-direction: column; gap: 2px; align-items: stretch; text-align: left; padding: 6px 7px; border-radius: 12px; background: var(--panel); border: 1px solid transparent; }
.celda:hover { background: var(--panel2); }
.celda.fuera { opacity: .38; }
.celda.sel { border-color: rgba(255,255,255,.5); }
.celda.hoy { background: linear-gradient(160deg, rgba(139,92,246,.55), rgba(34,211,238,.28)); }
.celda b { font-weight: 650; font-size: 14px; }
.chip { display: flex; align-items: center; gap: 5px; font-size: 11.5px; color: var(--tinta2); white-space: nowrap; overflow: hidden; }
.chip i { width: 7px; height: 7px; border-radius: 2px; flex: none; }
.chip span { overflow: hidden; text-overflow: ellipsis; }
.chip.hecho span { text-decoration: line-through; opacity: .6; }
.mas { font-size: 11px; color: var(--tinta3); }
.puntos { display: none; gap: 3px; flex-wrap: wrap; }
.puntos i { width: 6px; height: 6px; border-radius: 50%; }

.semana { flex: 1; min-height: 0; overflow-y: auto; }
.semCab, .semTodo { display: grid; grid-template-columns: 52px repeat(var(--n), minmax(0, 1fr)); gap: 6px; position: sticky; z-index: 3; background: #12162a; }
.semCab { top: 0; padding-bottom: 6px; } .semTodo { top: 50px; padding-bottom: 6px; }
.semCab button { padding: 6px 2px; border-radius: 12px; background: var(--panel); text-align: center; color: var(--tinta2); font-size: 12px; }
.semCab button b { display: block; font-size: 16px; color: var(--tinta); }
.semCab button.hoy { background: var(--tinta); color: #333a55; } .semCab button.hoy b { color: #10131f; }
.semTodo > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.semTodo .hora { font-size: 10.5px; color: var(--tinta3); text-align: right; padding-right: 4px; }
.barra { display: block; width: 100%; text-align: left; font-size: 11.5px; font-weight: 600; padding: 2px 6px; border-radius: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.rejilla { display: grid; grid-template-columns: 52px repeat(var(--n), minmax(0, 1fr)); gap: 6px; position: relative; }
.horas div { height: 52px; font-size: 11px; color: var(--tinta3); text-align: right; padding-right: 6px; transform: translateY(-7px); }
.col { position: relative; height: 1248px; background: repeating-linear-gradient(to bottom, rgba(255,255,255,.055) 0 1px, transparent 1px 52px); border-radius: 8px; cursor: copy; }
.bloque { position: absolute; padding: 5px 7px; border-radius: 10px; font-size: 12px; font-weight: 600; overflow: hidden; text-align: left; line-height: 1.25; box-shadow: 0 0 0 2px #12162a; cursor: pointer; }
.bloque small { display: block; font-weight: 500; opacity: .8; font-size: 11px; }
.bloque.hecho { opacity: .5; text-decoration: line-through; }
.ahora { position: absolute; left: 0; right: 0; height: 2px; background: var(--naranja); z-index: 2; pointer-events: none; }

.agenda { display: flex; flex-direction: column; min-height: 0; padding: 14px; gap: 10px; }
.agenda .lista { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 10px; }
.tarjEv { position: relative; display: block; flex: none; width: 100%; text-align: left; padding: 12px; border-radius: 14px; background: var(--panel2); overflow: hidden; }
.tarjEv::before { content: ''; display: block; height: 4px; border-radius: 4px; background: var(--c); margin-bottom: 9px; }
.tarjEv:hover { background: rgba(255,255,255,.12); }
.tarjEv h3 { font-size: 14px; font-weight: 650; } .tarjEv p { font-size: 12.5px; color: var(--tinta2); }
.vacio { color: var(--tinta2); text-align: center; padding: 26px 10px; display: flex; flex-direction: column; gap: 10px; align-items: center; }
.resumenLado { border-top: 1px solid var(--borde); padding-top: 10px; display: flex; justify-content: space-between; color: var(--tinta2); font-size: 13px; }
.resumenLado b { color: var(--tinta); }

/* Dinero y deudas */
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; }
.tile { padding: 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--borde); }
.tile span { color: var(--tinta2); font-size: 12.5px; display: block; }
.tile b { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.tile.grande { background: linear-gradient(135deg, rgba(139,92,246,.35), rgba(34,211,238,.18)); }
.dosCol { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 14px; align-items: start; margin-top: 14px; }
.fila { display: flex; align-items: center; gap: 10px; padding: 10px 6px; border-bottom: 1px solid var(--borde); }
.fila:last-child { border-bottom: 0; }
.fila .txt { flex: 1; min-width: 0; text-align: left; } .fila .txt b { display: block; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fila .txt small { color: var(--tinta2); } .fila .monto { font-weight: 650; font-variant-numeric: tabular-nums; }
.fila.hecho .txt b { text-decoration: line-through; opacity: .6; }
.check { width: 24px; height: 24px; border-radius: 8px; border: 2px solid var(--tinta3); display: grid; place-items: center; flex: none; color: transparent; }
.check svg { width: 15px; height: 15px; stroke-width: 3; }
.check.on { background: var(--bien); border-color: var(--bien); color: #06281c; }
.emoji { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--panel2); flex: none; font-size: 17px; }
.medidor { height: 8px; border-radius: 8px; background: rgba(255,255,255,.09); overflow: hidden; }
.medidor i { display: block; height: 100%; border-radius: 8px; min-width: 2px; }
.cat { margin-top: 12px; } .cat div:first-child { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; color: var(--tinta2); }
.cat b { color: var(--tinta); font-weight: 600; font-variant-numeric: tabular-nums; }
.deudas { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; margin-top: 14px; }
.deuda { display: flex; flex-direction: column; gap: 10px; }
.deuda .top { display: flex; gap: 10px; align-items: center; } .deuda h2 { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deuda .num { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; } .deuda .num b { font-size: 22px; font-variant-numeric: tabular-nums; } .deuda .num span, .deuda p { color: var(--tinta2); font-size: 13px; }
.acciones { display: flex; gap: 8px; flex-wrap: wrap; }
.historial { border-top: 1px solid var(--borde); padding-top: 4px; }
.aviso-mal { color: var(--naranja) !important; }

/* Formularios y ventanas */
#capa { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5,7,15,.6); backdrop-filter: blur(5px); }
.ventana { width: min(520px, 100%); max-height: calc(100vh - 32px); overflow-y: auto; background: #151a30; border: 1px solid var(--borde); border-radius: 20px; padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.ventana.chica { width: min(400px, 100%); }
.ventana header { display: flex; align-items: center; gap: 10px; } .ventana header h2 { flex: 1; font-size: 18px; }
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; } .campo > span { font-size: 12.5px; color: var(--tinta2); }
.dos { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
input:not([type=color]):not([type=checkbox]), select, textarea { width: 100%; height: 40px; padding: 0 12px; background: rgba(255,255,255,.06); border: 1px solid var(--borde); border-radius: 11px; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--cian); }
select option { background: #151a30; }
textarea { height: 68px; padding: 9px 12px; resize: vertical; }
.opciones { display: flex; flex-wrap: wrap; gap: 6px; }
.op { height: 32px; padding: 0 11px; border-radius: 16px; background: var(--panel2); border: 1px solid var(--borde); color: var(--tinta2); font-size: 13px; font-weight: 600; }
.op.on { background: var(--cian); color: #06222a; border-color: var(--cian); }
.colores { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.color { width: 28px; height: 28px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(0,0,0,.2); }
.color.on { outline: 2px solid #fff; outline-offset: 2px; }
input[type=color] { width: 32px; height: 32px; padding: 0; border: 0; background: none; border-radius: 50%; cursor: pointer; }
.emojis { display: grid; grid-template-columns: repeat(auto-fill, 36px); gap: 4px; }
.emojis button { height: 36px; border-radius: 9px; font-size: 18px; } .emojis button:hover { background: var(--panel2); } .emojis button.on { background: var(--panel2); box-shadow: inset 0 0 0 2px var(--cian); }
.interruptor { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 4px 0; cursor: pointer; }
.interruptor small { display: block; color: var(--tinta2); }
.interruptor input { appearance: none; width: 42px; height: 24px; border-radius: 12px; background: rgba(255,255,255,.16); position: relative; flex: none; cursor: pointer; transition: .15s; margin: 0; }
.interruptor input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: .15s; }
.interruptor input:checked { background: var(--morado); } .interruptor input:checked::after { left: 21px; }
.pie { display: flex; gap: 8px; align-items: center; position: sticky; bottom: -20px; background: #151a30; padding: 10px 0 0; }
.error { color: var(--mal); font-size: 13px; min-height: 18px; }
.ajustes { max-width: 640px; display: flex; flex-direction: column; gap: 14px; }
.ajustes .tarjeta { display: flex; flex-direction: column; gap: 12px; }
.stream { flex: 1; min-height: 0; border: 1px solid var(--borde); border-radius: var(--r); width: 100%; background: #0d161c; }
#toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 40; background: #f2f4fb; color: #10131f; font-weight: 600; padding: 10px 16px; border-radius: 12px; max-width: calc(100vw - 32px); }
#toast.mal { background: var(--mal); }

/* Teléfono */
@media (max-width: 900px) {
  .calendario { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(300px, 1.3fr) minmax(0, 1fr); }
  .dosCol { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  #app { flex-direction: column-reverse; padding: 10px 10px calc(8px + env(safe-area-inset-bottom)); gap: 8px; }
  #riel { width: 100%; flex-direction: row; justify-content: space-around; padding: 4px; border-radius: 18px; gap: 0; }
  #riel .marca { display: none; }
  #menu { flex-direction: row; flex: 5; justify-content: space-around; margin: 0; gap: 0; }
  .item { width: 54px; height: 50px; border-radius: 14px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
  .item span { display: block; font-size: 10px; }
  h1 { font-size: 21px; }
  .cal { padding: 8px; } .mes, .dias { gap: 3px; }
  .celda { padding: 3px 4px; border-radius: 9px; align-items: center; }
  .celda .chip, .celda .mas { display: none; } .celda .puntos { display: flex; justify-content: center; }
  .deudas, .cuadros { grid-template-columns: minmax(0, 1fr); } .cuadro { min-height: 112px; }
  .cuadro .ico { margin-bottom: 8px; }
  .tiles { grid-template-columns: 1fr 1fr; } .tile.grande { grid-column: 1 / -1; }
  #capa { place-items: end center; padding: 0; } .ventana, .ventana.chica { width: 100%; border-radius: 20px 20px 0 0; max-height: 92vh; }
  .solo-pc { display: none; }
}
