/* ============================================================
   app.css — estructura y componentes del Centro de Control
   Usa las variables de tokens.css. Reproduce el diseño de
   Claude Design (Avícola JW) en HTML/CSS/JS vanilla.
   ============================================================ */

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  font-family: var(--font-cuerpo);
  color: var(--texto);
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
button { font-family: inherit; }

@keyframes jwpulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }
@keyframes jwfade  { from{opacity:0;transform:translateY(8px);} to{opacity:1;transform:none;} }

.is-hidden { display: none !important; }

/* Emblema SVG reutilizable */
.emblem { display: block; }

/* Logo oficial en PNG (cuando upgradeLogos() reemplaza el SVG por <img>).
   El medallón es el logo real de marca; estas reglas lo encuadran por contexto. */
img.hdr__logo {            /* header casi blanco: el fondo blanco del PNG se funde */
  width: auto; height: 40px; object-fit: contain;
}
img.lock__emblem {         /* pantalla de PIN (azul): va en tarjeta blanca tipo insignia */
  width: 184px; height: auto; opacity: 1;
  background: #fff; border-radius: 22px; padding: 16px 20px; box-sizing: border-box;
  box-shadow: 0 16px 38px rgba(8,18,34,.34);
}
img.hero__bg {             /* marca de agua del hero: transparente, hereda opacity .06 */
  object-fit: contain;
}

/* ===================== LOCK / PIN ===================== */
.lock {
  position: fixed; inset: 0; z-index: 50;
  background: linear-gradient(160deg, #163356 0%, var(--azul) 55%, #0b1d34 100%);
  display: flex; align-items: center; justify-content: center; padding: 24px;
}
.lock__card { width: 100%; max-width: 380px; text-align: center; animation: jwfade .4s ease; }
.lock__emblem { width: 96px; height: auto; margin: 0 auto 18px; opacity: .95; }
.lock__eyebrow {
  font-family: var(--font-titular); font-weight: 600; font-size: 12px;
  letter-spacing: .22em; color: var(--dorado); text-transform: uppercase; margin-bottom: 8px;
}
.lock__title {
  font-family: var(--font-titular); font-weight: 800; font-size: 30px;
  color: #fff; margin: 0 0 6px; letter-spacing: -.01em;
}
.lock__lema { font-family: var(--font-serif); font-style: italic; font-size: 15px; color: rgba(255,255,255,.7); margin: 0 0 28px; }
.lock__form { display: flex; flex-direction: column; gap: 12px; }
.lock__input {
  width: 100%; text-align: center; font-family: var(--font-titular); font-weight: 600;
  font-size: 24px; letter-spacing: .12em; padding: 16px; border-radius: 12px;
  border: 2px solid rgba(255,255,255,.18); background: rgba(255,255,255,.06); color: #fff; outline: none;
}
.lock__input::placeholder { letter-spacing: normal; font-weight: 500; color: rgba(255,255,255,.45); }
.lock__input:focus { border-color: var(--dorado); background: rgba(255,255,255,.1); }
.lock__btn {
  width: 100%; appearance: none; border: none; cursor: pointer; font-family: var(--font-titular);
  font-weight: 700; font-size: 16px; padding: 16px; border-radius: 12px;
  background: var(--dorado); color: var(--azul); transition: filter .15s;
}
.lock__btn:hover { filter: brightness(1.06); }
.lock__btn:disabled { opacity: .6; cursor: default; }
.lock__error { margin-top: 14px; font-size: 14px; color: #F0B7B0; }
.lock__foot {
  margin-top: 26px; font-family: var(--font-titular); font-weight: 500; font-size: 12px;
  letter-spacing: .16em; color: rgba(255,255,255,.4); text-transform: uppercase;
}

/* ===================== HEADER ===================== */
.hdr {
  position: sticky; top: 0; z-index: 30;
  background: rgba(255,255,255,.86); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--borde);
}
.hdr__inner {
  max-width: 1200px; margin: 0 auto; padding: 14px clamp(16px,4vw,40px);
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.hdr__brand { display: flex; align-items: center; gap: 13px; }
.hdr__logo { width: 44px; height: 44px; }
.hdr__titles { display: flex; flex-direction: column; line-height: 1.1; }
.hdr__name { font-family: var(--font-titular); font-weight: 800; font-size: 18px; color: var(--primario); letter-spacing: -.01em; }
.hdr__sub  { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .18em; color: var(--dorado); text-transform: uppercase; }
.hdr__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.sync {
  display: flex; align-items: center; gap: 8px; appearance: none; cursor: default;
  font-weight: 600; font-size: 13px; padding: 8px 13px; border-radius: var(--radio-pill);
  border: 1px solid var(--borde-fuerte); background: #fff; color: var(--texto);
}
.sync__dot { width: 9px; height: 9px; border-radius: 50%; background: var(--ok); }
.sync[data-state="guardando"]    .sync__dot { background: var(--dorado); animation: jwpulse 1s ease-in-out infinite; }
.sync[data-state="sin-conexion"] .sync__dot { background: #9aa0a6; }
.sync[data-state="conflicto"]    .sync__dot { background: var(--alerta); }

.btn-refresh, .btn-lock {
  display: flex; align-items: center; gap: 8px; appearance: none; cursor: pointer;
  font-weight: 600; font-size: 13px; padding: 8px 13px; border-radius: var(--radio-pill);
  border: 1px solid transparent; background: rgba(16,40,72,.06); color: var(--primario); transition: background .15s;
}
.btn-refresh:hover, .btn-lock:hover { background: rgba(16,40,72,.1); }

/* ===================== MAIN ===================== */
.main { max-width: 1200px; margin: 0 auto; padding: 0 clamp(16px,4vw,40px) 64px; }

/* HERO */
.hero {
  position: relative; overflow: hidden; margin-top: 24px; border-radius: 22px;
  background: linear-gradient(150deg, #173657 0%, var(--azul) 60%, #0c1f38 100%);
  color: #fff; padding: clamp(26px,4vw,44px);
}
.hero__bg { position: absolute; right: -40px; top: 50%; transform: translateY(-50%); width: 340px; height: auto; opacity: .06; pointer-events: none; }
.hero__inner { position: relative; max-width: 760px; }
.hero__eyebrow { font-family: var(--font-titular); font-weight: 600; font-size: 12px; letter-spacing: .22em; text-transform: uppercase; color: var(--dorado); margin-bottom: 14px; }
.hero__title { font-family: var(--font-titular); font-weight: 900; font-size: clamp(30px,5vw,46px); line-height: 1.04; letter-spacing: -.02em; margin: 0 0 12px; }
.hero__lema { font-family: var(--font-serif); font-style: italic; font-size: clamp(16px,2.2vw,20px); color: rgba(255,255,255,.78); margin: 0 0 28px; max-width: 560px; }
.hero__stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px,1fr)); gap: 12px; }
.stat { background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.12); border-radius: 14px; padding: 15px 16px; }
.stat__k { font-family: var(--font-titular); font-weight: 600; font-size: 10.5px; letter-spacing: .16em; text-transform: uppercase; color: var(--dorado); margin-bottom: 6px; }
.stat__v { font-family: var(--font-titular); font-weight: 700; font-size: 17px; }

/* FRANJA ANUNCIO */
.note {
  margin-top: 16px; border-radius: 14px; background: var(--primario); color: #fff;
  padding: 14px 20px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
}
.note__badge {
  display: inline-flex; align-items: center; gap: 8px; font-family: var(--font-titular); font-weight: 700;
  font-size: 11px; letter-spacing: .14em; text-transform: uppercase; color: var(--azul);
  background: var(--dorado); padding: 5px 11px; border-radius: var(--radio-pill); white-space: nowrap;
}
.note__text { font-size: 15.5px; font-weight: 500; flex: 1; min-width: 200px; }
.note__date { font-family: var(--font-titular); font-weight: 700; font-size: 14px; color: var(--dorado); white-space: nowrap; }

/* PESTAÑAS */
.tabs { margin-top: 24px; display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; border-bottom: 1px solid var(--borde); }
.tab {
  appearance: none; border: none; cursor: pointer; font-family: var(--font-titular); font-weight: 600;
  font-size: 14px; letter-spacing: .01em; padding: 11px 18px; border-radius: 10px 10px 0 0;
  white-space: nowrap; transition: all .15s; margin-bottom: -1px; background: transparent;
  color: var(--texto-suave); border-bottom: 1px solid transparent;
}
.tab:hover { color: var(--primario); }
.tab--active { background: var(--primario); color: #fff; }

/* PANELES */
.panel { margin-top: 24px; }
.col { display: flex; flex-direction: column; gap: 18px; }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px,1fr)); gap: 18px; }
.grid-300 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px,1fr)); gap: 18px; }

/* CARD */
.card { background: var(--superficie); border: 1px solid var(--borde); border-radius: 16px; box-shadow: var(--sombra); padding: clamp(20px,3vw,28px); }
.card__eyebrow { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--dorado); margin-bottom: 16px; }
.card__title { font-family: var(--font-titular); font-weight: 800; font-size: 22px; color: var(--primario); margin: 0; }

/* AVANCE */
.avance__head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 18px; }
.avance__eyebrow { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--dorado); margin-bottom: 6px; }
.avance__num { font-family: var(--font-titular); font-weight: 900; font-size: 46px; line-height: 1; color: var(--primario); }
.bar { width: 100%; height: 16px; border-radius: var(--radio-pill); background: #EDEAE0; overflow: hidden; }
.bar__fill { height: 100%; border-radius: var(--radio-pill); background: linear-gradient(90deg, var(--verde), var(--oliva)); transition: width .6s ease; }
.avance__meta { margin-top: 10px; font-size: 13.5px; color: var(--texto-suave); }

/* ROWS (etiqueta → valor) */
.rows { display: flex; flex-direction: column; }
.row { display: flex; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--borde); }
.row:last-child { border-bottom: none; }
.row__k { color: var(--texto-suave); font-size: 14.5px; }
.row__v { font-family: var(--font-titular); font-weight: 600; font-size: 14.5px; color: var(--primario); text-align: right; }

/* CHECKLIST */
.check__list { display: flex; flex-direction: column; gap: 2px; }
.check__item { display: flex; align-items: center; gap: 12px; padding: 9px 0; }
.check__box {
  width: 22px; height: 22px; flex: none; border-radius: 6px; display: flex; align-items: center; justify-content: center;
  transition: all .15s; border: 2px solid #CBCED3; background: #fff; cursor: pointer;
}
.check__box--done { border-color: var(--primario); background: var(--primario); }
.check__box svg { display: none; }
.check__box--done svg { display: block; }
.check__label { font-size: 15px; line-height: 1.4; color: var(--texto); cursor: pointer; flex: 1; }
.check__label--done { text-decoration: line-through; color: #9aa0a6; }
.check__del {
  appearance: none; border: none; background: transparent; color: #c2c6cc; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; opacity: 0; transition: all .15s;
}
.check__item:hover .check__del { opacity: 1; }
.check__del:hover { color: var(--alerta); background: rgba(176,70,59,.08); }

.add-btn {
  margin-top: 14px; display: inline-flex; align-items: center; gap: 7px; appearance: none; cursor: pointer;
  font-family: var(--font-titular); font-weight: 600; font-size: 13.5px; padding: 9px 14px; border-radius: 10px;
  border: 1px dashed var(--borde-fuerte); background: transparent; color: var(--primario); transition: all .15s;
}
.add-btn:hover { background: rgba(16,40,72,.05); border-color: var(--primario); }

/* TIMELINE / FASES */
.timeline { position: relative; padding-left: 34px; }
.timeline__line { position: absolute; left: 11px; top: 8px; bottom: 8px; width: 2px; background: var(--borde-fuerte); }
.timeline__items { display: flex; flex-direction: column; gap: 18px; }
.fase { position: relative; }
.fase__dot { position: absolute; left: -29px; top: 22px; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--bg); }
.fase__card { background: var(--superficie); border: 1px solid var(--borde); border-radius: 16px; box-shadow: var(--sombra); padding: 22px 24px; }
.fase__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.fase__headL { display: flex; align-items: baseline; gap: 12px; }
.fase__n { font-family: var(--font-titular); font-weight: 900; font-size: 18px; color: var(--borde-fuerte); }
.fase__name { font-family: var(--font-titular); font-weight: 700; font-size: 19px; color: var(--primario); margin: 0; }
.fase__badge { font-family: var(--font-titular); font-weight: 700; font-size: 11px; letter-spacing: .08em; text-transform: uppercase; padding: 5px 11px; border-radius: var(--radio-pill); white-space: nowrap; cursor: pointer; }
.fase__nota { font-size: 14.5px; color: var(--texto-suave); margin: 0 0 16px; line-height: 1.5; }
.fase__barwrap { display: flex; align-items: center; gap: 12px; }
.fase__bar { flex: 1; height: 9px; border-radius: var(--radio-pill); background: #EDEAE0; overflow: hidden; }
.fase__bar__fill { height: 100%; border-radius: var(--radio-pill); transition: width .6s ease; }
.fase__pct { font-family: var(--font-titular); font-weight: 700; font-size: 14px; color: var(--primario); min-width: 42px; text-align: right; cursor: pointer; }

/* estados (fase + badges) */
.st-hecho       { color: var(--ok);          background: rgba(63,125,60,.12); }
.st-en_progreso { color: #9a7415;            background: rgba(192,154,67,.16); }
.st-pendiente   { color: var(--texto-suave); background: rgba(113,117,124,.12); }
.dot-hecho       { background: var(--ok);  box-shadow: 0 0 0 2px var(--ok); }
.dot-en_progreso { background: var(--dorado); box-shadow: 0 0 0 2px var(--dorado); }
.dot-pendiente   { background: #C2C6CC; box-shadow: 0 0 0 2px #C2C6CC; }
.fill-hecho       { background: var(--ok); }
.fill-en_progreso { background: var(--dorado); }
.fill-pendiente   { background: #C2C6CC; }

/* NEGOCIO */
.cobro { background: var(--primario); color: #fff; border-radius: 16px; box-shadow: var(--sombra); padding: clamp(20px,3vw,28px); }
.cobro__eyebrow { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--dorado); margin-bottom: 16px; }
.cobro__title { font-family: var(--font-titular); font-weight: 900; font-size: 30px; line-height: 1.1; margin-bottom: 8px; }
.cobro__desc { font-size: 15px; color: rgba(255,255,255,.78); margin: 0 0 18px; line-height: 1.5; }
.tags { display: flex; gap: 10px; flex-wrap: wrap; }
.tag { font-family: var(--font-titular); font-weight: 600; font-size: 13px; padding: 7px 13px; border-radius: var(--radio-pill); background: rgba(255,255,255,.1); border: 1px solid rgba(255,255,255,.16); }

.proj__rows { display: flex; flex-direction: column; gap: 14px; }
.proj__row { display: flex; justify-content: space-between; gap: 12px; }
.proj__k { color: var(--texto-suave); font-size: 14.5px; }
.proj__v { font-family: var(--font-titular); font-weight: 700; font-size: 15px; color: var(--primario); }
.proj__sep { border-top: 1px dashed var(--borde-fuerte); margin: 2px 0; }
.proj__sub { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-suave); }
.proj__list { margin: 0; padding-left: 18px; color: var(--texto-suave); font-size: 14px; line-height: 1.6; }

.costos-wrap { overflow-x: auto; }
.costos { width: 100%; border-collapse: collapse; min-width: 480px; }
.costos th { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .1em; text-transform: uppercase; color: var(--texto-suave); padding-bottom: 12px; }
.costos th.l { text-align: left; padding-right: 12px; }
.costos th.r { text-align: right; padding: 0 12px 12px; }
.costos th.c { text-align: center; }
.costos td { border-top: 1px solid var(--borde); }
.costos td.concepto { padding: 13px 12px 13px 0; font-size: 15px; color: var(--texto); }
.costos td.valor { padding: 13px 12px; text-align: right; font-family: var(--font-titular); font-weight: 700; font-size: 15px; color: var(--primario); white-space: nowrap; }
.costos td.tipo { padding: 13px 0; text-align: center; }
.tipo-chip { font-family: var(--font-titular); font-weight: 700; font-size: 10.5px; letter-spacing: .08em; padding: 4px 10px; border-radius: var(--radio-pill); }
.tipo-capex { color: var(--azul); background: rgba(16,40,72,.1); }
.tipo-opex  { color: var(--oliva); background: rgba(93,116,54,.14); }

/* EQUIPO */
.socio { border-top: 4px solid var(--azul); }
.socio--verde { border-top-color: var(--verde); }
.socio__head { display: flex; align-items: center; gap: 12px; margin-bottom: 4px; }
.socio__avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--azul); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--font-titular); font-weight: 800; font-size: 18px; }
.socio--verde .socio__avatar { background: var(--verde); }
.socio__name { font-family: var(--font-titular); font-weight: 800; font-size: 18px; color: var(--primario); line-height: 1; cursor: pointer; }
.socio__rol { font-size: 13px; color: var(--texto-suave); cursor: pointer; }
.socio__eyebrow { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--dorado); margin: 18px 0 10px; }

/* REUNIONES */
.reunion__head { display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; margin-bottom: 12px; }
.reunion__title { font-family: var(--font-titular); font-weight: 700; font-size: 19px; color: var(--primario); margin: 0; cursor: pointer; }
.reunion__date { font-family: var(--font-titular); font-weight: 700; font-size: 12px; letter-spacing: .06em; color: var(--dorado); background: rgba(192,154,67,.12); padding: 6px 12px; border-radius: var(--radio-pill); white-space: nowrap; cursor: pointer; }
.reunion__notas { font-size: 15px; color: var(--texto-suave); line-height: 1.55; margin: 0 0 18px; cursor: pointer; }
.reunion__acuerdos-label { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--texto-suave); margin-bottom: 6px; }
.reunion__del {
  appearance: none; border: 1px solid var(--borde-fuerte); background: transparent; color: var(--texto-suave);
  cursor: pointer; font-family: var(--font-titular); font-weight: 600; font-size: 12px; padding: 5px 10px; border-radius: 8px;
}
.reunion__del:hover { color: var(--alerta); border-color: var(--alerta); }
.reunion__foot { margin-top: 14px; display: flex; gap: 10px; flex-wrap: wrap; }

/* FOOTER */
.foot { margin-top: 48px; padding-top: 22px; border-top: 1px solid var(--borde); display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap; }
.foot__l { font-family: var(--font-titular); font-weight: 600; font-size: 11px; letter-spacing: .16em; text-transform: uppercase; color: var(--texto-suave); }
.foot__r { font-size: 12px; color: var(--texto-suave); }

/* Editable hint */
.editable { cursor: text; }
.editable:hover { background: rgba(16,40,72,.04); border-radius: 4px; }

/* Toast */
.toast {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  background: var(--primario); color: #fff; padding: 11px 18px; border-radius: var(--radio-pill);
  font-size: 14px; font-weight: 600; box-shadow: var(--sombra); z-index: 60; animation: jwfade .25s ease;
  max-width: 90vw;
}
.toast--alerta { background: var(--alerta); }
