:root {
  --fondo: #f5f4f0;
  --tarjeta: #ffffff;
  --tinta: #14161a;
  --tinta-2: #4b5059;
  --muted: #80858e;
  --linea: #e6e3dc;
  --acento: #ff6a3d;
  --acento-suave: #fff0ea;
  --acento-tinta: #b53d14;
  --ok: #17803d;
  --ok-suave: #e7f6ec;
  --alerta: #b42318;
  --radio: 14px;
  --sombra: 0 1px 2px rgba(20,22,26,.04), 0 4px 16px rgba(20,22,26,.05);
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--tinta);
  background: var(--fondo);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; font-size: 15px; line-height: 1.45; }
[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -.01em; }
a { color: inherit; }
.muted { color: var(--muted); }
.chico { font-size: 13px; }
.error { color: var(--alerta); font-size: 14px; min-height: 1em; margin: 6px 0 0; }
:focus-visible { outline: 3px solid var(--acento); outline-offset: 2px; border-radius: 6px; }

/* Controles */
input, select, textarea { font: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--linea); border-radius: 10px; background: #fff; color: var(--tinta); }
textarea { min-height: 76px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--acento); box-shadow: 0 0 0 3px var(--acento-suave); }
label { display: block; font-size: 13.5px; font-weight: 600; color: var(--tinta-2); }
label > input, label > select, label > textarea { display: block; margin-top: 6px; }
label .ayuda { font-weight: 400; color: var(--muted); font-size: 12.5px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 40px; padding: 8px 16px; border-radius: 10px; border: 1px solid var(--linea);
  background: #fff; color: var(--tinta); font: 600 14px inherit; font-family: inherit; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: #cfcbc2; }
.btn.primario { background: var(--tinta); border-color: var(--tinta); color: #fff; }
.btn.primario:hover { background: #2a2e35; }
.btn.acento { background: var(--acento); border-color: var(--acento); color: #fff; }
.btn.peligro { color: var(--alerta); }
.btn.ancho { width: 100%; }
.btn.mini { min-height: 32px; padding: 4px 10px; font-size: 13px; }
.btn[disabled] { opacity: .5; cursor: default; }
.icono-btn { width: 36px; height: 36px; border: 0; border-radius: 10px; background: none; cursor: pointer; font-size: 18px; color: var(--tinta-2); display: inline-grid; place-items: center; }
.icono-btn:hover { background: #f0eee9; }
.icono-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* Login */
.login { min-height: 100vh; display: grid; place-items: center; padding: 20px; background: radial-gradient(1200px 500px at 50% -10%, #ffe3d8, transparent), var(--fondo); }
.login-card { width: min(380px, 100%); background: #fff; border-radius: 20px; padding: 28px; box-shadow: var(--sombra); display: grid; gap: 14px; }
.marca { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-weight: 800; font-size: 19px; letter-spacing: -.02em; }
.marca.grande { font-size: 28px; }

/* Estructura */
.barra { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 24px; padding: 10px max(20px, calc((100vw - 1100px) / 2)); background: rgba(245,244,240,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--linea); }
#nav { display: flex; gap: 4px; }
#nav a { display: inline-flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 10px; text-decoration: none; color: var(--tinta-2); font-weight: 600; font-size: 14px; }
#nav a svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
#nav a:hover { background: #ecebe6; }
#nav a[aria-current="page"] { background: var(--tinta); color: #fff; }
main { max-width: 1100px; margin: 0 auto; padding: 24px 20px 100px; outline: none; }
.cab { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.cab h1 { font-size: 28px; font-weight: 800; }
.cab .espacio { flex: 1; }
.seccion { margin-top: 28px; }
.seccion > h2 { font-size: 17px; font-weight: 700; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.tarjeta { background: var(--tarjeta); border-radius: var(--radio); box-shadow: var(--sombra); padding: 16px; }
.grilla { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); }
.vacio { padding: 22px; text-align: center; color: var(--muted); background: #fff; border: 1px dashed var(--linea); border-radius: var(--radio); }

/* Próxima acción destacada */
.foco { background: var(--tinta); color: #fff; border-radius: 18px; padding: 18px 18px 16px; display: grid; gap: 10px; }
.foco .etq { font-size: 12px; letter-spacing: .08em; text-transform: uppercase; color: #ffb89f; font-weight: 700; }
.foco h2 { font-size: 21px; }
.foco .de { color: #b8bcc4; font-size: 13.5px; }
.foco .acciones { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
.foco .btn { border-color: #3a3f48; background: #22262d; color: #fff; }
.foco .btn.acento { background: var(--acento); border-color: var(--acento); }

/* Progreso */
.barra-prog { height: 8px; border-radius: 99px; background: #eceae4; overflow: hidden; }
.barra-prog > span { display: block; height: 100%; border-radius: inherit; background: var(--acento); transition: width .4s ease; }
.barra-prog.ok > span { background: var(--ok); }
.anillo { --p: 0; width: 64px; height: 64px; border-radius: 50%; display: grid; place-items: center; flex: none;
  background: conic-gradient(var(--acento) calc(var(--p) * 1%), #eceae4 0); }
.anillo.ok { background: conic-gradient(var(--ok) calc(var(--p) * 1%), #eceae4 0); }
.anillo > span { width: 50px; height: 50px; border-radius: 50%; background: #fff; display: grid; place-items: center; font-weight: 800; font-size: 14px; }
.anillo.grande { width: 92px; height: 92px; }
.anillo.grande > span { width: 74px; height: 74px; font-size: 20px; }

/* Objetivos */
.obj { display: grid; gap: 10px; text-decoration: none; color: inherit; cursor: pointer; transition: transform .1s; }
.obj:hover { transform: translateY(-1px); }
.obj-cab { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.obj h3 { font-size: 16px; font-weight: 700; }
.obj .pie { display: flex; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--muted); }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; background: #efede8; color: var(--tinta-2); white-space: nowrap; }
.chip .punto { width: 8px; height: 8px; border-radius: 50%; }
.chip.h-cinco_anios { background: #ede9fe; color: #5b21b6; }
.chip.h-anual { background: #e0f2fe; color: #075985; }
.chip.h-trimestral { background: #dcfce7; color: #166534; }
.chip.h-mensual { background: var(--acento-suave); color: var(--acento-tinta); }
.chip.e-pausado { background: #fef3c7; color: #92400e; }
.chip.e-completado { background: var(--ok-suave); color: var(--ok); }
.chip.e-archivado { background: #eee; color: #666; }
.filtros { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.pestanas { display: flex; gap: 4px; padding: 4px; background: #ebe9e3; border-radius: 12px; overflow-x: auto; }
.pestanas button { border: 0; background: none; padding: 7px 12px; border-radius: 9px; font: 600 13.5px inherit; font-family: inherit; color: var(--tinta-2); cursor: pointer; white-space: nowrap; }
.pestanas button[aria-pressed="true"] { background: #fff; color: var(--tinta); box-shadow: var(--sombra); }
.filtros select { width: auto; min-height: 40px; }
.arbol { display: grid; gap: 10px; }
.arbol .nivel-1 { margin-left: 22px; } .arbol .nivel-2 { margin-left: 44px; } .arbol .nivel-3 { margin-left: 66px; }
.arbol .nivel-1, .arbol .nivel-2, .arbol .nivel-3 { position: relative; }
.arbol .nivel-1::before, .arbol .nivel-2::before, .arbol .nivel-3::before { content: ''; position: absolute; left: -13px; top: -10px; bottom: 50%; width: 10px; border-left: 2px solid var(--linea); border-bottom: 2px solid var(--linea); border-bottom-left-radius: 8px; }

/* Detalle */
.migas { display: flex; flex-wrap: wrap; gap: 6px; font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.migas a { text-decoration: none; } .migas a:hover { text-decoration: underline; }
.det-cab { display: flex; gap: 18px; align-items: center; }
.det-cab h1 { font-size: 26px; font-weight: 800; }
.porque { margin-top: 14px; padding: 12px 14px; border-left: 3px solid var(--acento); background: #fff; border-radius: 0 10px 10px 0; font-size: 14.5px; }
.porque b { display: block; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--acento-tinta); margin-bottom: 2px; }
.barra-acciones { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.meta { display: grid; gap: 10px; }
.meta-cab { display: flex; justify-content: space-between; gap: 10px; align-items: flex-start; }
.meta h3 { font-size: 15.5px; font-weight: 700; }
.meta .cifra { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }
.meta .cifra small { font-size: 14px; font-weight: 600; color: var(--muted); }
.meta .botones { display: flex; gap: 6px; flex-wrap: wrap; }
.meta.cumplida { outline: 2px solid var(--ok-suave); }
.ultimos { margin: 0; padding: 0; list-style: none; font-size: 13px; color: var(--tinta-2); display: grid; gap: 3px; }
.semana-pts { display: flex; gap: 5px; }
.semana-pts i { width: 22px; height: 8px; border-radius: 99px; background: #eceae4; }
.semana-pts i.si { background: var(--acento); }

/* Acciones */
.lista-acc { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.acc { display: flex; align-items: center; gap: 10px; background: #fff; border-radius: 12px; padding: 8px 10px; box-shadow: var(--sombra); }
.acc.proxima { box-shadow: inset 0 0 0 2px var(--acento), var(--sombra); }
.acc .txt { flex: 1; min-width: 0; }
.acc .txt b { font-weight: 600; display: block; }
.acc .txt span { font-size: 12.5px; color: var(--muted); }
.acc.hecha .txt b { text-decoration: line-through; color: var(--muted); font-weight: 500; }
.check { width: 26px; height: 26px; border-radius: 50%; border: 2px solid #cfcbc2; background: #fff; cursor: pointer; flex: none; display: grid; place-items: center; color: #fff; font-size: 14px; }
.check[aria-pressed="true"] { background: var(--ok); border-color: var(--ok); }
.check.hito { border-radius: 7px; }
.vence { color: var(--alerta); font-weight: 600; }

/* Diálogo */
dialog { border: 0; border-radius: 18px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: calc(100vh - 24px); box-shadow: 0 20px 60px rgba(0,0,0,.25); color: var(--tinta); }
dialog::backdrop { background: rgba(20,22,26,.45); }
#dlg-form { display: grid; gap: 14px; padding: 18px 20px 20px; }
.dlg-cab { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.dlg-cab h2 { font-size: 19px; font-weight: 800; }
#dlg-cuerpo { display: grid; gap: 12px; }
.fila-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.dlg-pie { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.tipos { display: grid; gap: 8px; }
.tipos label { display: grid; grid-template-columns: auto 1fr; align-items: start; gap: 10px; padding: 10px 12px; border: 1px solid var(--linea); border-radius: 12px; cursor: pointer; font-weight: 600; }
.tipos label:has(input:checked) { border-color: var(--acento); background: var(--acento-suave); }
.tipos label > input { width: auto; margin-top: 3px; }
.tipos small { display: block; font-weight: 400; color: var(--muted); }
.historial { display: grid; gap: 6px; max-height: 50vh; overflow: auto; }
.historial .reg { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--linea); border-radius: 10px; }
.historial .reg .txt { flex: 1; min-width: 0; font-size: 14px; }

#toast { position: fixed; left: 50%; bottom: 88px; transform: translateX(-50%) translateY(20px); background: var(--tinta); color: #fff; padding: 11px 18px; border-radius: 12px; font-weight: 600; opacity: 0; pointer-events: none; transition: all .25s; z-index: 100; max-width: calc(100vw - 32px); }
#toast.ver { opacity: 1; transform: translateX(-50%); }
#toast.fiesta { background: var(--ok); }

/* Celular: navegación abajo */
@media (max-width: 760px) {
  body { font-size: 15.5px; }
  .barra { padding: 10px 16px; backdrop-filter: none; background: var(--fondo); } /* sin filtro: si no, el menú fijo queda atado a la barra */
  #nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; gap: 0; background: #fff; border-top: 1px solid var(--linea); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  #nav a { flex-direction: column; gap: 2px; font-size: 11.5px; padding: 6px 10px; min-width: 64px; min-height: 48px; }
  #nav a[aria-current="page"] { background: none; color: var(--acento-tinta); }
  main { padding: 18px 14px 110px; }
  .cab h1 { font-size: 24px; }
  .det-cab h1 { font-size: 22px; }
  .fila-2 { grid-template-columns: 1fr; }
  .arbol .nivel-1 { margin-left: 14px; } .arbol .nivel-2 { margin-left: 28px; } .arbol .nivel-3 { margin-left: 42px; }
  .arbol .nivel-1::before, .arbol .nivel-2::before, .arbol .nivel-3::before { left: -10px; width: 7px; }
  dialog { width: 100vw; max-width: 100vw; max-height: 92vh; margin: auto 0 0; border-radius: 18px 18px 0 0; }
  .btn, .icono-btn { min-height: 44px; }
  .icono-btn { width: 44px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
