/* Demo app (iframe at /demos/). Self-hosted: no CDN, no external request. The first block is the
   reset and the small utility set the markup uses (it was Tailwind in the standalone prototype). */
*, ::before, ::after { box-sizing: border-box; }
body { margin: 0; }
button { background: none; border: 0; padding: 0; color: inherit; }
b { font-weight: 700; }
.absolute { position: absolute; } .relative { position: relative; } .inset-0 { inset: 0; }
.flex { display: flex; } .grid { display: grid; } .flex-1 { flex: 1 1 0%; } .flex-col { flex-direction: column; } .flex-none { flex: none; }
.grid-cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .col-span-2 { grid-column: span 2 / span 2; }
.content-between { align-content: space-between; } .items-center { align-items: center; } .justify-between { justify-content: space-between; } .place-items-center { place-items: center; }
.g-1 { gap: 4px; } .g-15 { gap: 6px; } .g-2 { gap: 8px; } .g-25 { gap: 10px; }
.px-15 { padding-inline: 6px; } .px-2 { padding-inline: 8px; } .px-25 { padding-inline: 10px; } .px-3 { padding-inline: 12px; } .px-4 { padding-inline: 16px; }
.py-0\.5 { padding-block: 2px; } .py-1\.5 { padding-block: 6px; } .py-2 { padding-block: 8px; }
.mb-1 { margin-bottom: 4px; } .mb-15 { margin-bottom: 6px; } .mx-auto { margin-inline: auto; }
.min-h-0 { min-height: 0; } .min-w-0 { min-width: 0; } .w-full { width: 100%; } .w-9 { width: 36px; } .h-9 { height: 36px; }
.mw-app { max-width: 480px; } .h-dvh { height: 100dvh; } .h-48 { height: 48px; } .h-50 { height: 50px; } .h-65 { height: 65%; } .h-35 { height: 35%; }
.overflow-hidden { overflow: hidden; } .overflow-x-auto { overflow-x: auto; } .overflow-y-auto { overflow-y: auto; } .overflow-y-hidden { overflow-y: hidden; }
.rounded { border-radius: 4px; } .rounded-md { border-radius: 6px; } .rounded-full { border-radius: 9999px; }
.border { border: 1px solid; } .border-b { border-bottom: 1px solid; } .border-t { border-top: 1px solid; }
.border-slate-200 { border-color: #e2e8f0; } .border-zinc-300 { border-color: #d4d4d8; }
.bg-white { background: #fff; } .bg-w15 { background: rgba(255,255,255,.15); } .bg-slate-300 { background: #cbd5e1; } .bg-emerald-200 { background: #a7f3d0; }
.t-95 { font-size: 9.5px; } .t-11 { font-size: 11px; } .t-115 { font-size: 11.5px; } .t-12 { font-size: 12px; } .t-125 { font-size: 12.5px; } .t-14 { font-size: 14px; } .t-145 { font-size: 14.5px; } .t-15 { font-size: 15px; }
.text-slate-400 { color: #94a3b8; } .text-slate-500 { color: #64748b; } .text-slate-600 { color: #475569; } .text-emerald-900 { color: #064e3b; } .tx-soft { color: rgba(209,250,229,.9); }
.font-medium { font-weight: 500; } .font-semibold { font-weight: 600; } .font-bold { font-weight: 700; }
.leading-tight { line-height: 1.25; } .tracking-wide { letter-spacing: .025em; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.shadow-xl { box-shadow: 0 20px 25px -5px rgba(0,0,0,.1), 0 8px 10px -6px rgba(0,0,0,.1); }
.hov-dark:hover { color: #334155; }
.safe-b { padding-bottom: env(safe-area-inset-bottom); }
.w-rn { width: 26px; } .w-fecha { width: 78px; } .w-prov { width: 170px; } .w-cif { width: 84px; } .w-imp { width: 76px; } .w-est { width: 190px; }
/* invoice photo (was inline) */
.ph-wrap { padding: 2px; }
.ph-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 6px; }
.ph-name { font-size: 9.5px; }
.ph-r { text-align: right; }
.ph-concept { margin: 6px 0 3px; font-weight: 700; border-bottom: 1px solid #9ca3af; }
.ph-sum { margin-top: 6px; }
.ph-tot { font-size: 10px; }
.meta.meta-img { float: none; justify-content: flex-end; margin: 2px 2px 0 0; }

/* --- app --- */
:root {
    --wa-dark: #075e54;
    --wa-bg: #ece5dd;
    --wa-out: #dcf8c6;
    --wa-tick: #53bdeb;
    --ink: #0f172a;
    --ok: #16a34a;
  }
  html, body { height: 100%; margin: 0; }
  body { background: #e2e8f0; font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; color: var(--ink); -webkit-tap-highlight-color: transparent; overflow: hidden; }
  button { font: inherit; cursor: pointer; }
  button:focus-visible { outline: 2px solid #2563eb; outline-offset: 2px; }

  /* --- WhatsApp --- */
  .wa-head { background: var(--wa-dark); color: #fff; }
  .wa-chat {
    background-color: var(--wa-bg);
    background-image: radial-gradient(rgba(0,0,0,.045) 1px, transparent 1.2px);
    background-size: 14px 14px;
    scroll-behavior: smooth;
  }
  .msg { display: flex; margin: 3px 0; }
  .msg.out { justify-content: flex-end; }
  .bubble {
    max-width: 82%; padding: 6px 8px 4px; border-radius: 8px; font-size: 14px; line-height: 1.35;
    box-shadow: 0 1px 1px rgba(0,0,0,.13); background: #fff; position: relative;
    animation: pop .22s ease-out both;
  }
  .msg.out .bubble { background: var(--wa-out); border-top-right-radius: 2px; }
  .msg.in .bubble { border-top-left-radius: 2px; }
  .meta { float: right; margin: 6px 0 -2px 10px; font-size: 10.5px; color: #667781; display: inline-flex; align-items: center; gap: 3px; }
  .tick { color: #8696a0; transition: color .3s; display: inline-flex; }
  .tick.read { color: var(--wa-tick); }
  .typing .bubble { padding: 10px 12px; display: flex; gap: 4px; }
  .dot { width: 6px; height: 6px; border-radius: 50%; background: #8696a0; animation: bounce 1s infinite ease-in-out; }
  .dot:nth-child(2) { animation-delay: .15s; }
  .dot:nth-child(3) { animation-delay: .3s; }
  @keyframes bounce { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }
  @keyframes pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

  /* --- start overlay --- */
  .start-wrap { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(15,23,42,.18); backdrop-filter: blur(1.5px); transition: opacity .25s; z-index: 5; }
  .start-wrap.hide { opacity: 0; pointer-events: none; }
  .start-btn { background: var(--ink); color: #fff; border: 0; padding: 14px 22px; border-radius: 999px; font-weight: 600; font-size: 15px; box-shadow: 0 8px 24px rgba(15,23,42,.35); animation: ring 2s infinite; }
  .start-btn:active { transform: scale(.97); }
  @keyframes ring { 0% { box-shadow: 0 8px 24px rgba(15,23,42,.35), 0 0 0 0 rgba(15,23,42,.35); } 70%, 100% { box-shadow: 0 8px 24px rgba(15,23,42,.35), 0 0 0 14px rgba(15,23,42,0); } }

  /* --- panels --- */
  .panel { background: #fff; border-top: 1px solid #e2e8f0; }
  .live { width: 7px; height: 7px; border-radius: 50%; background: var(--ok); animation: live 1.6s infinite; }
  @keyframes live { 0%, 100% { opacity: 1; } 50% { opacity: .3; } }

  .slot { position: relative; display: flex; align-items: center; gap: 10px; height: 40px; padding: 0 10px; border-radius: 8px; border: 1px solid transparent; transition: background-color .7s ease, border-color .7s ease, color .7s ease; }
  .slot .t { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 12px; width: 38px; color: #64748b; }
  .slot .lbl { font-size: 12.5px; flex: 1; min-width: 0; transition: opacity .25s; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .slot.busy { background: repeating-linear-gradient(135deg, #f1f5f9 0 6px, #e8edf3 6px 12px); color: #64748b; }
  .slot.free { background: #f3f4f6; border: 1px dashed #cbd5e1; color: #6b7280; }
  .slot.free.pulse { animation: slotpulse 1s ease-in-out 2; }
  .slot.booked { background: #dcfce7; border: 1px solid #86efac; color: #14532d; }
  .slot.booked .lbl { font-weight: 600; white-space: normal; line-height: 1.15; font-size: 12px; }
  .fade { opacity: 0; }
  @keyframes slotpulse { 50% { border-color: #16a34a; background: #ecfdf5; } }

  .field { border: 1px solid #e2e8f0; border-radius: 8px; padding: 5px 8px; min-width: 0; transition: background-color .4s, border-color .4s; }
  .field .k { font-size: 10px; text-transform: uppercase; letter-spacing: .04em; color: #64748b; }
  .field .v { font-size: 13px; font-weight: 600; color: #94a3b8; min-height: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .field.on { background: #f0fdf4; border-color: #bbf7d0; }
  .field.on .v { color: var(--ink); }
  .badge { font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; background: #fef3c7; color: #92400e; transition: background-color .5s, color .5s; white-space: nowrap; }
  .badge.ok { background: #dcfce7; color: #166534; }

  /* --- invoice --- */
  .photo { position: relative; width: 190px; border-radius: 6px; overflow: hidden; background: #fffdf7; color: #1f2937; padding: 9px 10px; font-size: 8.5px; line-height: 1.4; box-shadow: inset 0 0 0 1px #e5e7eb; }
  .photo b { font-weight: 700; }
  .photo .ln { display: flex; justify-content: space-between; border-bottom: 1px dotted #d1d5db; padding: 1.5px 0; }
  .photo .hit { transition: background-color .4s, outline-color .4s; outline: 1.5px solid transparent; border-radius: 2px; }
  .photo.done .hit { background: rgba(250,204,21,.28); outline-color: #eab308; }
  .scan { position: absolute; inset: 0; overflow: hidden; pointer-events: none; opacity: 0; }
  .scan.go { opacity: 1; }
  .scan::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 36px; background: linear-gradient(180deg, rgba(16,185,129,0), rgba(16,185,129,.45)); border-bottom: 2px solid #10b981; }
  .scan.go::before { animation: sweep 1.5s linear forwards; }
  @keyframes sweep { from { top: -36px; } to { top: 100%; } }
  .scan-chip { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: rgba(15,23,42,.88); color: #fff; font-size: 10px; padding: 3px 8px; border-radius: 999px; white-space: nowrap; opacity: 0; transition: opacity .2s; }
  .scan-chip.go { opacity: 1; }

  table.sheet { border-collapse: collapse; font-size: 12px; width: 100%; min-width: 560px; table-layout: fixed; }
  .sheet th, .sheet td { border: 1px solid #d4d4d8; padding: 4px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; height: 28px; }
  .sheet th { background: #f4f4f5; color: #52525b; font-weight: 600; text-align: left; font-size: 11px; }
  .sheet td.rn, .sheet th.rn { width: 26px; text-align: center; background: #f4f4f5; color: #71717a; padding: 4px 0; }
  .sheet td.c { transition: background-color .9s; }
  .sheet td.c span { display: inline-block; opacity: 0; transform: translateY(3px); transition: opacity .3s, transform .3s; }
  .sheet td.c.filled span { opacity: 1; transform: none; }
  .sheet td.c.flash { background: #bbf7d0; }
  .sheet td.num { text-align: right; font-variant-numeric: tabular-nums; }
  .sheet td.st.filled { color: #166534; font-weight: 600; }

  /* --- toast --- */
  .toast { position: absolute; left: 12px; right: 12px; top: 10px; z-index: 20; background: #0f172a; color: #fff; border-radius: 14px; padding: 10px 12px; display: flex; gap: 10px; align-items: center; box-shadow: 0 10px 30px rgba(0,0,0,.3); transform: translateY(-140%); opacity: 0; transition: transform .45s cubic-bezier(.2,.9,.3,1.2), opacity .3s; pointer-events: none; }
  .toast.show { transform: none; opacity: 1; }
  .toast .ico { width: 30px; height: 30px; border-radius: 8px; background: #16a34a; display: grid; place-items: center; font-size: 15px; flex: none; }
  .toast .tt { font-size: 12.5px; font-weight: 600; line-height: 1.25; }
  .toast .ts { font-size: 11.5px; color: #cbd5e1; line-height: 1.25; }

  /* --- tabs --- */
  .tab { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 7px; border: 0; background: none; color: #94a3b8; font-size: 11px; font-weight: 600; position: relative; transition: color .2s; }
  .tab[aria-selected="true"] { color: var(--ink); }
  .tab[aria-selected="true"]::before { content: ""; position: absolute; top: 0; left: 28%; right: 28%; height: 3px; border-radius: 0 0 3px 3px; background: var(--ink); }
  .demo { display: none; }
  .demo.active { display: flex; }

  @media (prefers-reduced-motion: reduce) {
    .bubble, .dot, .start-btn, .live, .slot.free.pulse { animation-duration: .01s; animation-iteration-count: 1; }
    .scan.go::before { animation-duration: .01s; }
  }
