/* Lya Suite · Control Interno — iPad primero, también iPhone */
:root {
  --bg: #FFF9FB; --surface: #FFFFFF; --soft: #FDEEF4; --tint: #F9DCE8;
  --primary: #D95B8A; --primary-dark: #B93D6C; --primary-light: #F3A6C3;
  --text: #2E1E26; --muted: #6E5561; --border: #F0D4E0;
  --ok: #1F8A5B; --warn: #B9770E; --bad: #B42335;
  --shadow: 0 10px 28px rgba(185, 61, 108, .10); --radius: 18px;
  --nav: 232px; --top: 64px;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body { font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; -webkit-tap-highlight-color: transparent; }
h1, h2, h3, .serif { font-family: 'Playfair Display', Georgia, serif; letter-spacing: -.01em; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- Estructura ---------- */
.app { display: grid; grid-template-columns: var(--nav) minmax(0, 1fr); min-height: 100vh; }
.lateral { background: var(--surface); border-right: 1px solid var(--border); padding: 18px 12px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.marca { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; }
.marca-l { width: 40px; height: 40px; border-radius: 12px; background: linear-gradient(135deg, var(--primary), var(--primary-dark)); color: #fff; display: grid; place-items: center; font-family: 'Playfair Display', serif; font-size: 1.3rem; font-weight: 700; }
.marca strong { display: block; font-family: 'Playfair Display', serif; font-size: 1.02rem; line-height: 1.1; }
.marca span { font-size: .72rem; color: var(--muted); }
.nav-btn { display: flex; align-items: center; gap: 12px; min-height: 46px; padding: 10px 12px; border: 0; border-radius: 12px; background: transparent; font-weight: 600; font-size: .93rem; text-align: left; color: var(--muted); position: relative; }
.nav-btn .ico { font-size: 1.15rem; width: 24px; text-align: center; }
.nav-btn[aria-current="page"] { background: var(--soft); color: var(--primary-dark); }
.nav-btn .contador { margin-left: auto; background: var(--primary); color: #fff; border-radius: 999px; font-size: .72rem; font-weight: 800; min-width: 22px; height: 22px; display: grid; place-items: center; padding: 0 6px; }
.lateral .pie { margin-top: auto; font-size: .72rem; color: var(--muted); padding: 8px; }

.principal { min-width: 0; display: flex; flex-direction: column; }
.barra { position: sticky; top: 0; z-index: 20; height: var(--top); display: flex; align-items: center; gap: 12px; padding: 0 22px; background: rgba(255, 249, 251, .92); backdrop-filter: blur(10px); border-bottom: 1px solid var(--border); }
.barra h1 { font-size: 1.35rem; margin-right: auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.barra .fecha-hoy { font-size: .82rem; color: var(--muted); }
.contenido { padding: 22px; display: flex; flex-direction: column; gap: 18px; padding-bottom: 40px; }
.inferior { display: none; }

/* ---------- Piezas ---------- */
.btn { min-height: 44px; padding: 10px 16px; border-radius: 12px; border: 1.5px solid transparent; font-weight: 700; font-size: .9rem; display: inline-flex; align-items: center; justify-content: center; gap: 6px; text-decoration: none; white-space: nowrap; }
.btn-p { background: var(--primary); color: #fff; }
.btn-p:active { background: var(--primary-dark); }
.btn-o { background: #fff; border-color: var(--border); color: var(--text); }
.btn-s { background: var(--soft); color: var(--primary-dark); }
.btn-ok { background: var(--ok); color: #fff; }
.btn-bad { background: #fff; border-color: #F2C3CB; color: var(--bad); }
.btn-wa { background: #1FA855; color: #fff; }
.btn-sm { min-height: 36px; padding: 6px 12px; font-size: .82rem; border-radius: 10px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.fila-btn { display: flex; flex-wrap: wrap; gap: 8px; }

.tarjeta { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; min-width: 0; }
.tarjeta > h2, .tarjeta > header h2 { font-size: 1.15rem; }
.tarjeta > header { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.kpis { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 16px; padding: 14px 16px; box-shadow: var(--shadow); text-align: left; border-left: 4px solid var(--primary-light); }
.kpi small { display: block; font-size: .74rem; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.kpi b { display: block; font-family: 'Playfair Display', serif; font-size: 1.7rem; line-height: 1.2; font-variant-numeric: tabular-nums; }
.kpi span { font-size: .78rem; color: var(--muted); }
button.kpi { cursor: pointer; }
.dos-col { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 18px; align-items: start; }
.lista { display: flex; flex-direction: column; gap: 10px; }
.vacio { color: var(--muted); font-size: .9rem; background: var(--soft); border-radius: 12px; padding: 14px; }

.item { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 14px; background: #fff; text-align: left; width: 100%; }
.item .hora { font-weight: 800; font-variant-numeric: tabular-nums; min-width: 54px; }
.item .cuerpo { flex: 1; min-width: 0; }
.item .cuerpo strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .cuerpo span { font-size: .82rem; color: var(--muted); }
.item .der { text-align: right; font-size: .82rem; }
.franja { width: 5px; align-self: stretch; border-radius: 4px; flex: none; }
.chip { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 999px; font-size: .72rem; font-weight: 800; white-space: nowrap; }
.dinero { font-variant-numeric: tabular-nums; font-weight: 700; }

/* ---------- Calendario ---------- */
.cal-barra { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.seg { display: inline-flex; background: var(--soft); border-radius: 12px; padding: 3px; }
.seg button { border: 0; background: transparent; min-height: 38px; padding: 6px 14px; border-radius: 10px; font-weight: 700; color: var(--muted); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--primary-dark); box-shadow: 0 2px 8px rgba(185, 61, 108, .12); }
.cal-titulo { font-family: 'Playfair Display', serif; font-size: 1.15rem; margin-right: auto; text-transform: capitalize; }
.cal-leyenda { display: flex; gap: 12px; flex-wrap: wrap; font-size: .76rem; color: var(--muted); }
.cal-leyenda i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.rejilla { display: grid; position: relative; overflow-x: auto; }
.rejilla-int { display: grid; min-width: 0; }
.col-horas { position: relative; }
.col-horas div { position: absolute; right: 8px; font-size: .72rem; color: var(--muted); transform: translateY(-50%); font-variant-numeric: tabular-nums; }
.col-dia { position: relative; border-left: 1px solid var(--border); }
.col-dia .ranura { position: absolute; left: 0; right: 0; border-top: 1px solid #F7E6EE; border-radius: 0; background: transparent; border-left: 0; border-right: 0; border-bottom: 0; }
.col-dia .ranura:hover { background: var(--soft); }
.col-dia .ranura.hora-entera { border-top-color: var(--border); }
.col-dia.cerrado { background: repeating-linear-gradient(45deg, #FBF3F6, #FBF3F6 8px, #fff 8px, #fff 16px); }
.cab-dia { text-align: center; padding: 6px 0 8px; font-size: .78rem; color: var(--muted); font-weight: 700; border-bottom: 1px solid var(--border); }
.cab-dia b { display: block; font-family: 'Playfair Display', serif; font-size: 1.3rem; color: var(--text); }
.cab-dia.es-hoy b { color: var(--primary); }
.bloque { position: absolute; left: 4px; right: 4px; border-radius: 10px; padding: 6px 8px; color: #fff; overflow: hidden; text-align: left; border: 0; font-size: .78rem; line-height: 1.25; box-shadow: 0 4px 10px rgba(46, 30, 38, .15); }
.bloque strong { display: block; font-size: .82rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bloque span { display: block; opacity: .92; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bloque.pendiente { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.18) 0 6px, transparent 6px 12px); }
.ahora-linea { position: absolute; left: 0; right: 0; height: 2px; background: var(--bad); z-index: 3; pointer-events: none; }
.ahora-linea::before { content: ''; position: absolute; left: -4px; top: -4px; width: 10px; height: 10px; border-radius: 50%; background: var(--bad); }
.mes { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.mes .cab { text-align: center; font-size: .74rem; font-weight: 800; color: var(--muted); text-transform: uppercase; padding: 4px 0; }
.mes-dia { min-height: 104px; border: 1px solid var(--border); border-radius: 12px; background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 3px; text-align: left; overflow: hidden; }
.mes-dia.fuera { opacity: .45; }
.mes-dia.es-hoy { border-color: var(--primary); box-shadow: 0 0 0 2px var(--primary-light); }
.mes-dia.cerrado { background: #FBF3F6; }
.mes-dia > b { font-size: .85rem; }
.pildora { font-size: .7rem; color: #fff; border-radius: 6px; padding: 1px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Formularios y modales ---------- */
.campo { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.campo > span { font-size: .74rem; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.in { width: 100%; min-height: 46px; border: 1.5px solid var(--border); border-radius: 12px; padding: 10px 12px; background: #fff; }
.in:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(217, 91, 138, .15); }
textarea.in { min-height: 70px; resize: vertical; }
.rejilla-campos { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
.rejilla-campos .ancho { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 10px; font-size: .9rem; min-height: 40px; }
.check input { width: 22px; height: 22px; accent-color: var(--primary); }
.horas-sel { display: grid; grid-template-columns: repeat(auto-fill, minmax(76px, 1fr)); gap: 6px; }
.hora-btn { min-height: 40px; border: 1.5px solid var(--border); background: #fff; border-radius: 10px; font-weight: 700; font-variant-numeric: tabular-nums; }
.hora-btn[aria-pressed="true"] { background: var(--primary); color: #fff; border-color: var(--primary); }
.buscar { min-width: 220px; flex: 1; max-width: 360px; }

dialog { border: 0; border-radius: 22px; padding: 0; width: min(720px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); box-shadow: 0 30px 80px rgba(46, 30, 38, .35); color: var(--text); background: var(--bg); }
dialog::backdrop { background: rgba(46, 30, 38, .45); backdrop-filter: blur(2px); }
.modal-cab { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 10px; padding: 16px 20px; background: var(--surface); border-bottom: 1px solid var(--border); }
.modal-cab h2 { font-size: 1.2rem; margin-right: auto; }
.cerrar { width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--soft); font-size: 1.1rem; }
.modal-cuerpo { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.modal-pie { position: sticky; bottom: 0; display: flex; gap: 8px; justify-content: flex-end; padding: 14px 20px; background: var(--surface); border-top: 1px solid var(--border); flex-wrap: wrap; }
.cuentas { background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 6px 14px; }
.cuentas div { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px dashed var(--border); font-size: .9rem; }
.cuentas div:last-child { border-bottom: 0; }
.cuentas div > span:last-child { white-space: nowrap; flex: none; }
.cuentas .total { font-weight: 800; font-size: 1.02rem; color: var(--primary-dark); }
.aviso { border-radius: 12px; padding: 10px 14px; font-size: .86rem; background: #FFF4E0; color: #7A4E06; }
.aviso.ok { background: #E7F6EE; color: #12583A; }
.aviso.bad { background: #FDE8EC; color: var(--bad); }
.historial { font-size: .8rem; color: var(--muted); display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; }
.fotos { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.foto { position: relative; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; background: var(--soft); }
.foto img { width: 100%; height: 100%; object-fit: cover; display: block; }
.foto span { position: absolute; left: 6px; bottom: 6px; background: rgba(46, 30, 38, .7); color: #fff; font-size: .68rem; font-weight: 800; padding: 2px 8px; border-radius: 999px; text-transform: uppercase; }

.tabla { width: 100%; border-collapse: collapse; font-size: .88rem; }
.tabla th { text-align: left; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 8px; border-bottom: 1px solid var(--border); }
.tabla td { padding: 10px 8px; border-bottom: 1px solid #F7E6EE; vertical-align: middle; }
.tabla td.num, .tabla th.num { text-align: right; font-variant-numeric: tabular-nums; }
.barras { display: flex; flex-direction: column; gap: 8px; }
.barra-h { display: grid; grid-template-columns: 150px minmax(0, 1fr) 70px; gap: 10px; align-items: center; font-size: .84rem; }
.barra-h .pista { height: 12px; background: var(--soft); border-radius: 999px; overflow: hidden; }
.barra-h .relleno { height: 100%; background: var(--primary); border-radius: 999px; }
.barra-h b { text-align: right; font-variant-numeric: tabular-nums; }

.toast { position: fixed; z-index: 100; right: 18px; bottom: 18px; background: var(--text); color: #fff; padding: 12px 16px; border-radius: 14px; font-weight: 600; font-size: .9rem; box-shadow: 0 12px 30px rgba(46, 30, 38, .3); max-width: min(420px, calc(100vw - 36px)); }

/* ---------- Recibo ---------- */
.recibo { background: #fff; border: 1px solid var(--border); border-radius: 16px; padding: 22px; }
.recibo .r-cab { display: flex; justify-content: space-between; gap: 12px; border-bottom: 2px solid var(--primary); padding-bottom: 12px; margin-bottom: 12px; }
.recibo .r-cab h3 { font-size: 1.4rem; color: var(--primary-dark); }
.recibo .r-cab small { display: block; color: var(--muted); font-size: .78rem; }
.recibo .r-pie { margin-top: 14px; font-size: .74rem; color: var(--muted); display: flex; flex-direction: column; gap: 3px; }

@media print {
  body * { visibility: hidden; }
  #imprimible, #imprimible * { visibility: visible; }
  #imprimible { position: absolute; inset: 0; border: 0; padding: 10mm; }
  dialog { box-shadow: none; }
}

@media (max-width: 1280px) { .dos-col { grid-template-columns: 1fr; } }
/* ---------- iPad vertical ---------- */
@media (max-width: 1100px) {
  :root { --nav: 76px; }
  .lateral { padding: 14px 8px; align-items: center; }
  .marca { padding: 4px 0 14px; }
  .marca div:last-child, .nav-btn .txt, .lateral .pie { display: none; }
  .nav-btn { justify-content: center; width: 56px; padding: 10px 0; }
  .nav-btn .contador { position: absolute; top: 2px; right: 0; min-width: 18px; height: 18px; font-size: .64rem; }
  .kpis { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .dos-col { grid-template-columns: 1fr; }
}
/* ---------- iPhone ---------- */
@media (max-width: 680px) {
  .app { grid-template-columns: 1fr; }
  .lateral { display: none; }
  .barra { padding: 0 14px; }
  .barra h1 { font-size: 1.15rem; }
  .barra .fecha-hoy { display: none; }
  .contenido { padding: 14px; padding-bottom: 96px; gap: 14px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .kpi b { font-size: 1.35rem; }
  .rejilla-campos { grid-template-columns: 1fr; }
  .inferior { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: rgba(255, 255, 255, .96); backdrop-filter: blur(10px); border-top: 1px solid var(--border); padding: 6px 4px calc(6px + env(safe-area-inset-bottom)); }
  .inferior button { border: 0; background: transparent; display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: .64rem; font-weight: 700; color: var(--muted); min-height: 50px; position: relative; }
  .inferior button .ico { font-size: 1.2rem; }
  .inferior button[aria-current="page"] { color: var(--primary-dark); }
  .inferior .contador { position: absolute; top: 0; right: 18%; background: var(--primary); color: #fff; border-radius: 999px; font-size: .6rem; min-width: 16px; height: 16px; display: grid; place-items: center; padding: 0 4px; }
  .mes-dia { min-height: 64px; padding: 4px; }
  .pildora { font-size: .6rem; padding: 0 4px; }
  .barra-h { grid-template-columns: 96px minmax(0, 1fr) 60px; }
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; }
  .toast { left: 14px; right: 14px; bottom: 84px; }
  /* Radar y listas con botones: los botones bajan a su propio renglón para no aplastar el texto */
  .item:has(.fila-btn) { flex-wrap: wrap; }
  .item > .fila-btn { width: 100%; justify-content: flex-end; }
  .item .cuerpo strong { white-space: normal; }
  /* Inventario en el teléfono: cada artículo es una tarjeta (sin deslizar de lado) */
  .tabla-inv, .tabla-inv tbody { display: block; }
  .tabla-inv thead { display: none; }
  .tabla-inv tr { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 2px 10px; padding: 12px; margin-bottom: 10px; border: 1px solid var(--border); border-radius: 14px; background: #fff; }
  .tabla-inv td { border: 0; padding: 2px 0; text-align: left !important; }
  .tabla-inv td:nth-child(1) { grid-column: 1 / -1; }
  .tabla-inv td:nth-child(4)::before { content: 'Stock '; color: var(--muted); font-size: .78rem; }
  .tabla-inv td:nth-child(5)::before { content: 'Mínimo '; color: var(--muted); font-size: .78rem; }
  .tabla-inv td:nth-child(6) { grid-column: 1 / -1; }
  .tabla-inv td:nth-child(6) .fila-btn { justify-content: flex-start !important; }
  .buscar { max-width: none; }
}
