/* Zuky Hub – estilos. Móvil primero; barra lateral en pantallas anchas. */
:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --panel: #171717;
  --panel2: #222222;
  --line: #2b2b2b;
  --text: #f5f5f5;
  --muted: #9b9b9b;
  --accent: #ff2b26;
  --accent-ink: #ffffff;
  --ok: #3ddc84;
  --bad: #ff6b5e;
  --warn: #ffb020;
  --info: #5aa9ff;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  --tex: url("../textura.jpg");
  --r: 18px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --nav-h: 58px;
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html { background: var(--bg); }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: linear-gradient(color-mix(in srgb, var(--bg) 55%, transparent), color-mix(in srgb, var(--bg) 55%, transparent)), var(--tex) center top / 540px repeat, var(--bg);
  color: var(--text);
  line-height: 1.4;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
}
body.lock { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; }
h1, h3 { font-weight: 800; letter-spacing: -0.01em; }
img { display: block; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ── Estructura ── */
.app { min-height: 100dvh; }
.shell { max-width: 720px; margin: 0 auto; padding-bottom: calc(var(--nav-h) + var(--safe-b) + 90px); }
.sidebar { display: none; }
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top, 0px)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.top-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.top-brand img { width: 38px; height: 38px; border-radius: 11px; flex: none; }
.top-brand h1 { font-size: 1.15rem; line-height: 1.1; font-weight: 900; text-transform: uppercase; letter-spacing: 0.04em; text-shadow: 2px 2px 0 var(--accent); }
.top-brand p { font-size: 0.76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; align-items: center; gap: 6px; flex: none; }
.sync { font-size: 0.95rem; width: 28px; text-align: center; }
.icon-btn {
  width: 38px; height: 38px; border-radius: 12px; display: grid; place-items: center;
  background: var(--panel); border: 1px solid var(--line); font-size: 0.95rem; flex: none;
}
.icon-btn:active { transform: scale(0.94); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; background: transparent; border-color: transparent; font-size: 0.85rem; opacity: 0.75; }
.icon-btn.sm:hover { background: var(--panel2); opacity: 1; }
.main { padding: 14px 16px 0; }
.view { display: none; animation: in 0.22s ease; }
.view.active { display: block; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; justify-content: space-around; max-width: 720px; margin: 0 auto;
  height: calc(var(--nav-h) + var(--safe-b)); padding: 6px 6px var(--safe-b);
  background: color-mix(in srgb, var(--bg2) 92%, transparent);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--line);
}
.bottom-nav button { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); border-radius: 14px; }
.bottom-nav .ni { font-size: 1.15rem; line-height: 1; filter: grayscale(0.7); transition: transform 0.15s; }
.bottom-nav .nl { font-size: 0.64rem; font-weight: 700; }
.bottom-nav button.on { color: var(--accent); }
.bottom-nav button.on .ni { filter: none; transform: translateY(-1px) scale(1.08); }

.fab {
  position: fixed; z-index: 45; right: max(16px, calc(50% - 344px));
  bottom: calc(var(--nav-h) + var(--safe-b) + 16px);
  width: 56px; height: 56px; border-radius: 18px; font-size: 1.7rem; font-weight: 300; line-height: 1;
  background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px color-mix(in srgb, var(--accent) 45%, transparent);
  display: grid; place-items: center; transition: transform 0.12s;
}
.fab:active { transform: scale(0.92); }

/* ── Componentes base ── */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin-bottom: 14px; box-shadow: var(--shadow); }
.panel h3 { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin-bottom: 8px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.panel-head h3 { margin: 0; }
.m { font-size: 0.78rem; color: var(--muted); }
.m.pad { padding: 6px 2px; }
.bad { color: var(--bad) !important; }
.pos { color: var(--ok) !important; }
.t { font-weight: 650; font-size: 0.92rem; overflow-wrap: anywhere; }
.t.strike { text-decoration: line-through; opacity: 0.55; }
.lbl { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 700; }
.link { color: var(--accent); font-size: 0.8rem; font-weight: 700; padding: 4px 0; }
.sp { flex: 1; }
.grow { flex: 1; min-width: 0; }

.empty { text-align: center; padding: 22px 10px; color: var(--muted); }
.empty span { font-size: 1.8rem; display: block; margin-bottom: 4px; }
.empty p { font-size: 0.85rem; }

.row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; border-bottom: 1px solid var(--line); cursor: pointer; }
.row:last-child { border-bottom: 0; }
.row.plain { cursor: default; }
.row.done .t { text-decoration: line-through; opacity: 0.5; }
.ico { width: 40px; height: 40px; border-radius: 12px; background: var(--panel2); display: grid; place-items: center; font-size: 1.2rem; flex: none; }
.amt { font-weight: 800; font-size: 0.95rem; white-space: nowrap; }
.day-head { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.07em; color: var(--muted); font-weight: 800; margin: 14px 2px 6px; }
.panel .day-head:first-of-type { margin-top: 4px; }

.chips { display: flex; gap: 8px; overflow-x: auto; padding: 2px 0 12px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; padding: 8px 14px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); font-size: 0.82rem; font-weight: 700; color: var(--muted); }
.chip.on { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip.ghost { border-style: dashed; }
.chips.tabs { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(max-content, 1fr); gap: 6px; }
.chips.tabs .chip { padding: 9px 4px; font-size: 0.76rem; text-align: center; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 11px 18px; border-radius: 13px; font-weight: 800; font-size: 0.88rem; background: var(--accent); color: var(--accent-ink); border: 1px solid transparent; }
.btn:active { transform: scale(0.97); }
.btn.ghost { background: transparent; color: var(--text); border-color: var(--line); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.danger.ghost { background: transparent; color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }
.btn.mini { padding: 7px 12px; font-size: 0.76rem; border-radius: 10px; }
.btn.full { width: 100%; margin-top: 10px; }

.badge { display: inline-block; font-size: 0.7rem; font-weight: 800; padding: 3px 9px; border-radius: 999px; background: var(--panel2); color: var(--muted); white-space: nowrap; align-self: flex-start; }
.badge.ok { background: color-mix(in srgb, var(--ok) 20%, transparent); color: var(--ok); }
.badge.bad { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.badge.hot { background: color-mix(in srgb, var(--bad) 20%, transparent); color: var(--bad); }
.badge.warn { background: color-mix(in srgb, var(--warn) 22%, transparent); color: var(--warn); }
.badge.past { opacity: 0.7; }

.bar { height: 8px; border-radius: 99px; background: var(--panel2); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bar.thin { height: 6px; margin-top: 8px; }
.bar-row { display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; margin: 10px 0; font-size: 0.85rem; }
.bar-row .bar { grid-column: 1 / -1; }
.bar-row .bv { font-weight: 800; }

/* ── Inicio / saldos / stats ── */
.saldos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.saldos.one { grid-template-columns: 1fr; }
.saldos.one .big { font-size: 1.9rem; }
.saldo-card {
  border-radius: var(--r); padding: 14px; color: #fff;
  background: linear-gradient(160deg, #222222, #131313);
  box-shadow: var(--shadow); border: 1px solid var(--line); border-top: 3px solid var(--c);
}
.saldo-head { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin: -6px -6px 0 0; }
.saldo-card .lbl { color: var(--muted); font-size: 0.66rem; }
.saldo-card .lbl::first-letter { color: var(--c); }
.saldo-card .big { font-size: 1.45rem; font-weight: 900; margin: 6px 0 2px; letter-spacing: -0.02em; }
.saldo-card .link { color: var(--accent); font-size: 0.74rem; }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 14px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 13px; box-shadow: var(--shadow); }
.stat[data-act] { cursor: pointer; }
.stat .num { font-size: 1.5rem; font-weight: 900; margin: 3px 0 1px; letter-spacing: -0.02em; }
.stat .t { margin-top: 4px; }

.month-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.month-nav p { font-weight: 800; font-size: 1.02rem; }

/* ── Tareas ── */
.check { width: 26px; height: 26px; border-radius: 9px; border: 2px solid var(--line); display: grid; place-items: center; flex: none; font-weight: 900; color: var(--accent-ink); font-size: 0.8rem; }
.check.on { background: var(--ok); border-color: var(--ok); }

/* ── DAM ── */
.card-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 13px; margin-bottom: 12px; box-shadow: var(--shadow); }
.ci-top { display: flex; gap: 10px; align-items: flex-start; }
.ci-top .grow { cursor: pointer; }
.ci-foot { display: flex; align-items: center; gap: 8px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line); flex-wrap: wrap; }
.big-t { font-size: 1rem; margin: 6px 0 2px; }
.chip-asig { display: inline-block; font-size: 0.7rem; font-weight: 800; padding: 3px 9px; border-radius: 8px; color: var(--c); background: color-mix(in srgb, var(--c) 17%, transparent); }
.hero-grade { text-align: center; padding: 20px 14px; border-radius: var(--r); margin-bottom: 14px; background: linear-gradient(150deg, color-mix(in srgb, var(--accent) 50%, #000), color-mix(in srgb, var(--accent) 18%, #000)); color: #fff; box-shadow: var(--shadow); }
.hero-grade .lbl, .hero-grade .m { color: rgba(255, 255, 255, 0.8); }
.giant { font-size: 3rem; font-weight: 900; letter-spacing: -0.03em; line-height: 1.1; }
.hero-grade .giant.bad { color: #ffd2cb !important; }
.avg { font-size: 1.35rem; font-weight: 900; }
.mini-row { display: flex; justify-content: space-between; gap: 10px; font-size: 0.82rem; padding: 7px 0; border-bottom: 1px solid var(--line); }
.mini-row:last-child { border-bottom: 0; }
.mini-row small { color: var(--muted); }
.slot { display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 8px; background: var(--panel); border: 1px solid var(--line); border-left: 4px solid var(--c); border-radius: 14px; }
.slot.now { background: color-mix(in srgb, var(--c) 14%, var(--panel)); box-shadow: 0 0 0 1px var(--c); }
.hora { display: flex; flex-direction: column; align-items: center; min-width: 46px; font-weight: 800; font-size: 0.88rem; }
.hora small { font-size: 0.66rem; color: var(--muted); font-weight: 600; }
.recreo { text-align: center; font-size: 0.76rem; color: var(--muted); padding: 6px; border: 1px dashed var(--line); border-radius: 10px; margin-bottom: 8px; }

/* ── Calendario ── */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.cal-grid.heads { margin-bottom: 4px; text-align: center; font-size: 0.7rem; font-weight: 800; color: var(--muted); }
.cal-day { aspect-ratio: 1 / 1.05; border-radius: 12px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-weight: 700; font-size: 0.88rem; background: transparent; border: 1px solid transparent; }
.cal-day.empty { pointer-events: none; }
.cal-day:not(.empty):hover { background: var(--panel2); }
.cal-day.today { border-color: var(--accent); color: var(--accent); }
.cal-day.sel, .cal-day.sel:hover { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.dots { display: flex; gap: 2px; height: 6px; }
.dots i, .legend i { width: 6px; height: 6px; border-radius: 50%; display: inline-block; }
.d-ex { background: var(--bad); } .d-tr { background: var(--warn); } .d-tk { background: var(--info); } .d-gs { background: var(--ok); }
.cal-day.sel .dots i { box-shadow: 0 0 0 1px var(--accent-ink); }
.legend { display: flex; justify-content: center; gap: 14px; margin-top: 12px; font-size: 0.7rem; color: var(--muted); font-weight: 700; }
.legend span { display: inline-flex; align-items: center; gap: 5px; }
.agenda { display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: 8px 0; background: var(--panel2); border-left: 4px solid var(--c); border-radius: 12px; cursor: pointer; }

/* ── Modal y formularios ── */
.modal-bg { position: fixed; inset: 0; z-index: 80; background: rgba(0, 0, 0, 0.55); display: none; align-items: flex-end; justify-content: center; backdrop-filter: blur(3px); }
.modal-bg.open { display: flex; }
.modal { width: 100%; max-width: 520px; max-height: 92dvh; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 24px 24px 0 0; padding: 20px 18px calc(20px + var(--safe-b)); animation: up 0.2s ease; }
@keyframes up { from { transform: translateY(40px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal h3 { font-size: 1.1rem; margin-bottom: 14px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { grid-column: 1 / -1; }
.field.half { grid-column: auto; }
.field label { display: block; font-size: 0.76rem; font-weight: 800; color: var(--muted); margin-bottom: 5px; }
.field label small { font-weight: 500; }
.field input:not([type="radio"]), .field select, .field textarea, .cat-add input {
  width: 100%; padding: 12px 13px; border-radius: 12px; background: var(--bg2); border: 1px solid var(--line); font-size: 1rem;
}
.field input:focus, .field select:focus, .field textarea:focus, .cat-add input:focus { outline: none; border-color: var(--accent); }
.seg { display: flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: 3px; gap: 3px; }
.seg label { flex: 1; margin: 0; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg span { display: block; text-align: center; padding: 9px 6px; border-radius: 9px; font-size: 0.86rem; font-weight: 800; color: var(--muted); cursor: pointer; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); }
.seg input:focus-visible + span { outline: 2px solid var(--accent); }
.err { color: var(--bad); font-size: 0.82rem; font-weight: 700; min-height: 1.2em; margin-top: 8px; }
.btns { display: flex; gap: 10px; align-items: center; margin-top: 12px; }
.choose { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.choose.one { grid-template-columns: 1fr; }
.filebtn { cursor: pointer; }
.catlist { max-height: 40dvh; overflow-y: auto; margin-bottom: 8px; }
.cat-add { display: grid; grid-template-columns: 64px 1fr auto; gap: 8px; margin-top: 8px; }
.cat-add input[name="icono"] { text-align: center; }

.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + var(--safe-b) + 84px); transform: translate(-50%, 20px); z-index: 99; background: #1c1c1c; color: #fff; padding: 11px 18px; border-radius: 14px; font-size: 0.86rem; font-weight: 700; opacity: 0; pointer-events: none; transition: 0.22s; max-width: 90vw; text-align: center; box-shadow: var(--shadow); border: 1px solid var(--line); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--bad); border-color: var(--bad); }

/* ── Recordatorios, bus en Inicio y aviso de versión ── */
.avisos { border-left: 3px solid var(--accent); }
.bus-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.bus-tile { position: relative; display: flex; align-items: flex-start; background: var(--panel2); border-radius: 12px; }
.bus-tile a { flex: 1; min-width: 0; padding: 10px 4px 10px 12px; color: inherit; text-decoration: none; }
.bus-tile .t { font-size: 0.84rem; }
.bus-tile .m { color: var(--accent); font-weight: 700; }
.bus-tile .icon-btn.sm { width: 28px; height: 28px; margin: 4px; font-size: 0.75rem; opacity: 0.55; }
.icon-btn.on { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 18%, var(--panel)); }
.update { position: fixed; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top, 0px) + 66px); z-index: 98; display: flex; align-items: center; gap: 12px; padding: 8px 8px 8px 16px; border-radius: 14px; background: #1c1c1c; color: #fff; font-size: 0.84rem; font-weight: 700; box-shadow: var(--shadow); border: 1px solid var(--accent); width: max-content; max-width: calc(100vw - 32px); }
.update[hidden] { display: none; }

/* ── Pantallas anchas ── */
@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 180px 1fr; }
  .sidebar { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 0; height: 100dvh; padding: 18px 10px; background: var(--bg2); border-right: 1px solid var(--line); }
  .side-brand { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: 1.05rem; padding: 0 6px; letter-spacing: 0.02em; }
  .side-brand img { width: 32px; height: 32px; border-radius: 12px; }
  .side-brand em { font-style: normal; color: var(--accent); }
  .side-nav { display: flex; flex-direction: column; gap: 4px; }
  .side-nav button { display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; font-weight: 700; font-size: 0.9rem; color: var(--muted); text-align: left; }
  .side-nav button:hover { background: var(--panel); }
  .side-nav button.on { background: var(--panel); color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); }
  .side-nav .ni { font-size: 1rem; }
  .bottom-nav { display: none; }
  .shell { max-width: 960px; width: 100%; padding-bottom: 60px; }
  .top-brand img { display: none; }
  .main { padding: 20px 24px 0; }
  .topbar { padding-left: 24px; padding-right: 24px; }
  .fab { right: 32px; bottom: 32px; }
  .toast { bottom: 32px; }
  .modal-bg { align-items: center; }
  .modal { border-radius: 24px; }
}
@media (max-width: 380px) {
  .saldo-card .big { font-size: 1.2rem; }
  .fields { grid-template-columns: 1fr; }
  .field.half { grid-column: 1 / -1; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
.top-brand > div { min-width: 0; }
.chips.tabs .chip { white-space: nowrap; padding: 9px 2px; font-size: 0.72rem; }

a.btn { text-decoration: none; }
.bottom-nav .nl { white-space: nowrap; }
.todo-day { display: flex; align-items: center; gap: 8px; }
.todo-lugar { font-size: 0.72rem !important; margin: 10px 4px 0 !important; }
.todo-lugar:first-child { margin-top: 0 !important; }
.todo-prog .bar { margin-top: 6px; }
.bottom-nav .nl { font-size: 0.6rem; }

/* ── Pantalla de entrada ── */
body.sin-sesion .app { display: none; }
.login { min-height: 100dvh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; padding: 24px; text-align: center; }
.login img { width: 120px; height: 120px; border-radius: 28px; }
.login h1 { font-size: 2rem; font-weight: 900; letter-spacing: 0.02em; }
.login h1 em { font-style: normal; color: var(--accent); }
.login .btn { min-width: 220px; }
.login .chaval { display: block; font-size: 1.6rem; font-weight: 900; color: var(--text); text-shadow: 2px 2px 0 var(--accent); text-transform: uppercase; letter-spacing: 0.03em; }
.login .intento { display: block; font-size: 1rem; color: var(--muted); margin-top: 4px; }
.login.echado img { animation: sacudir 0.4s; }
@keyframes sacudir { 25% { transform: translateX(-8px); } 75% { transform: translateX(8px); } }

.login .nope-gif { display: block; width: min(240px, 70vw); height: auto; aspect-ratio: 1; object-fit: cover; border-radius: 18px; margin: 0 auto 10px; border: 2px solid var(--accent); }
