:root {
  --brand: #f28c1a;
  --dark: #3a0d0d;
  --cream: #f3e3c8;
  --bg: #fbf6ee;
  --card: #ffffff;
  --text: #2b1a14;
  --muted: #7a6a60;
  --line: #eadfce;
  --danger: #b3261e;
  --ok: #2e7d32;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
button, input, select { font: inherit; }

/* Marca VilcamTech: tipografía del logo */
body { font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }

/* Pantalla de inicio: código de negocio */
.home {
  position: relative; overflow: hidden; isolation: isolate;
  min-height: 100dvh; padding: 32px 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 30px;
  background: #0a1a3b; color: #fff; text-align: center;
}
.home::before {
  content: ""; position: absolute; z-index: -1; left: 50%; bottom: -22%;
  width: min(1100px, 170vw); aspect-ratio: 1.45; transform: translateX(-50%);
  background: url(/assets/vilcamtech-icono.svg) center / contain no-repeat;
  opacity: .07; pointer-events: none;
}
.home-logo { width: min(440px, 86vw); height: auto; animation: home-rise .8s cubic-bezier(.22, 1, .36, 1) both; }
.home-form { width: 100%; max-width: 420px; text-align: left; }
.home-form label { margin: 0 0 8px; font-size: .95rem; font-weight: 500; color: #bcd0ee; }
.keyfield { display: flex; gap: 8px; }
.keyfield input {
  flex: 1; min-width: 0; min-height: 54px; padding: 0 14px 0 44px;
  border: 1px solid rgba(34, 211, 238, .35); border-radius: 14px;
  background: rgba(255, 255, 255, .07) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Ccircle cx='8' cy='5' r='3' fill='%23F5B841'/%3E%3Cpath d='M6.8 7.5h2.4L10 14H6z' fill='%23F5B841'/%3E%3C/svg%3E") no-repeat 15px center / 16px;
  color: #fff; font-size: 1.05rem; letter-spacing: .04em;
}
.keyfield input::placeholder { color: rgba(255, 255, 255, .38); letter-spacing: 0; }
.keyfield input:focus { outline: 2px solid #22d3ee; outline-offset: 0; border-color: #22d3ee; }
.home .btn {
  width: auto; margin: 0; min-height: 54px; padding: 0 24px; border-radius: 14px;
  background: #f5b841; color: #0a1a3b;
}
.home .msg { color: #ff9aa8; margin-top: 10px; }
.home-help { margin: 0; max-width: 340px; font-size: .9rem; line-height: 1.45; color: #8fa6c8; }
@keyframes home-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .home-logo { animation: none; } }

/* Firma VilcamTech bajo el login de cada negocio */
.poweredby { margin-top: 26px; display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: .78rem; color: #d9c4a3; opacity: .85; }
.poweredby img { height: 24px; width: auto; }

/* Pantallas de entrada */
.center {
  min-height: 100dvh;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 50% 0%, #5a1818 0%, var(--dark) 60%);
  color: var(--cream);
}
.center .logo { width: 150px; height: 150px; border-radius: 50%; box-shadow: 0 6px 24px rgba(0,0,0,.4); margin-bottom: 20px; }
.center h1 { margin: 0 0 4px; font-size: 1.5rem; }
.center p.sub { margin: 0 0 20px; color: #d9c4a3; text-align: center; }
.panel {
  width: 100%; max-width: 360px;
  background: var(--card); color: var(--text);
  border-radius: 16px; padding: 20px;
  box-shadow: 0 8px 30px rgba(0,0,0,.35);
}
label { display: block; font-size: .85rem; font-weight: 600; margin: 12px 0 4px; }
input, select {
  width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; min-height: 46px;
}
input:focus, select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  width: 100%; min-height: 48px; margin-top: 16px; padding: 0 16px;
  border: 0; border-radius: 12px; cursor: pointer;
  background: var(--brand); color: #2b1400; font-weight: 700;
}
.btn:hover { filter: brightness(1.05); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.secondary { background: transparent; border: 1px solid var(--line); color: var(--text); }
.btn.small { width: auto; min-height: 36px; margin: 0; padding: 0 12px; font-size: .85rem; }
.btn.danger { background: var(--danger); color: #fff; }
.msg { margin-top: 12px; font-size: .9rem; color: var(--danger); min-height: 1.2em; }
.msg.ok { color: var(--ok); }
.link { background: none; border: 0; color: var(--muted); text-decoration: underline; cursor: pointer; margin-top: 14px; }

/* Dashboard */
.topbar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; background: var(--dark); color: var(--cream);
}
.topbar img { width: 38px; height: 38px; border-radius: 50%; }
.topbar .who { flex: 1; line-height: 1.15; }
.topbar .who small { color: #d9c4a3; }
.topbar .btn { color: var(--cream); border-color: #6b3a3a; }
.layout { display: flex; max-width: 1100px; margin: 0 auto; }
nav.side { width: 200px; padding: 14px 10px; }
nav.side button {
  display: block; width: 100%; text-align: left; padding: 11px 12px; margin-bottom: 4px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; color: var(--text);
}
nav.side button.active { background: var(--brand); color: #2b1400; font-weight: 700; }
main { flex: 1; padding: 16px; min-width: 0; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 16px; margin-bottom: 14px; }
.card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.muted { color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 99px; font-size: .75rem; background: var(--cream); }
.badge.off { background: #eee; color: #888; }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: .92rem; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Listas, formularios y ventanas (Fase 2) */
.list { display: flex; flex-direction: column; }
.item { display: flex; align-items: center; gap: 10px; padding: 12px 2px; border-bottom: 1px solid var(--line); }
.item:last-child { border-bottom: 0; }
.item.col { flex-direction: column; align-items: stretch; }
.item.dim { opacity: .6; }
.item-main { display: flex; align-items: flex-start; gap: 12px; justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.name { font-weight: 600; }
.price { text-align: right; font-weight: 700; white-space: nowrap; }
.price .badge { font-weight: 500; margin-top: 4px; }
small.block { display: block; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.toolbar h2 { margin: 0; }
.badge.warn { background: #fde7c2; color: #7a4a00; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.stat { display: flex; flex-direction: column; gap: 2px; margin: 0; }
.stat strong { font-size: 1.8rem; line-height: 1.1; }
.stat span { color: var(--muted); font-size: .85rem; }
.stat.warn strong { color: #b35a00; }
.field { margin-bottom: 4px; }
.inline { display: flex; gap: 8px; }
.inline select { flex: 1; min-width: 0; }
.check { display: flex; gap: 10px; align-items: flex-start; font-weight: 500; margin: 14px 0 8px; }
.check input { width: 22px; min-height: 22px; margin-top: 2px; flex: none; }
textarea { width: 100%; padding: 12px; border: 1px solid var(--line); border-radius: 10px; font: inherit; resize: vertical; }
textarea:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.recipe-row { display: grid; grid-template-columns: 1fr 90px 34px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.recipe-row .unit { font-size: .85rem; }
dialog.modal { border: 0; padding: 0; border-radius: 16px; width: min(560px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); color: var(--text); box-shadow: 0 20px 60px rgba(0,0,0,.35); }
dialog.modal::backdrop { background: rgba(20, 8, 8, .55); }
.modal-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 14px 16px; background: var(--card); border-bottom: 1px solid var(--line); }
.modal-head h2 { margin: 0; font-size: 1.05rem; }
.modal-body { padding: 14px 16px 18px; }
.modal-body h3 { margin: 18px 0 4px; font-size: .95rem; }
.toast { position: fixed; left: 50%; bottom: 90px; transform: translateX(-50%); z-index: 50; padding: 12px 18px; border-radius: 12px; background: #1f3d24; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.3); }
.toast.err { background: var(--danger); }

/* Venta (POS) y listado de ventas (Fase 3) */
.posbar { position: sticky; top: 59px; z-index: 4; background: var(--bg); padding-bottom: 8px; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chip { flex: none; padding: 8px 14px; border: 1px solid var(--line); border-radius: 99px; background: var(--card); cursor: pointer; }
.chip.on { background: var(--brand); border-color: var(--brand); color: #2b1400; font-weight: 700; }
.pgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; padding-bottom: 80px; }
.pcard { position: relative; display: flex; flex-direction: column; gap: 4px; text-align: left; min-height: 104px; padding: 12px; border: 1px solid var(--line); border-radius: 14px; background: var(--card); cursor: pointer; color: var(--text); }
.pcard:active { transform: scale(.98); }
.pcard.out { opacity: .5; cursor: not-allowed; }
.pname { font-weight: 600; line-height: 1.2; }
.pdesc { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pprice { margin-top: auto; font-weight: 700; }
.pbadge { position: absolute; top: 8px; right: 8px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 99px; background: var(--brand); color: #2b1400; font-weight: 700; font-size: .85rem; display: flex; align-items: center; justify-content: center; }
.cartbar { position: fixed; left: 12px; right: 12px; bottom: 76px; z-index: 7; display: flex; justify-content: space-between; align-items: center; min-height: 52px; padding: 0 18px; border: 0; border-radius: 14px; background: var(--dark); color: var(--cream); font-size: 1rem; box-shadow: 0 8px 24px rgba(0,0,0,.3); cursor: pointer; }
.qty { display: flex; align-items: center; gap: 4px; }
.qty button { width: 38px; height: 38px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); font-size: 1.2rem; cursor: pointer; }
.qty span { min-width: 28px; text-align: center; font-weight: 700; }
.itemnote { margin-top: 8px; min-height: 40px; font-size: .9rem; }
.total { font-size: 1.15rem; text-align: right; margin: 12px 0 0; }
.seg { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.seg button { flex: 1 1 0; min-width: 90px; min-height: 44px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; color: var(--text); }
.seg button.on { background: var(--brand); border-color: var(--brand); color: #2b1400; font-weight: 700; }
.change { font-weight: 700; font-size: 1.1rem; margin: 4px 0 0; }
.stats4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stats4 .stat { margin: 0; }
.stats4 .stat strong { font-size: 1.25rem; }
.rowbtn { width: 100%; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; cursor: pointer; color: var(--text); }
.paycard { margin: 12px 0 0; }
.proof { display: block; max-width: 100%; max-height: 360px; margin: 8px auto; border-radius: 10px; border: 1px solid var(--line); }
.filebtn { display: inline-flex; align-items: center; min-height: 40px; padding: 0 14px; margin-top: 8px; border: 1px solid var(--line); border-radius: 10px; cursor: pointer; font-weight: 600; }
.filebtn input { display: none; }

/* Panel central y suscripción */
.badge.danger { background: #fbd9d6; color: #8a1c14; }
.tlogo { width: 46px; height: 46px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--line); flex: none; }
.tlogo.ph { display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; background: var(--cream); }
.secret { font-family: Consolas, monospace; font-size: 1.15rem; background: #fff3cd; padding: 2px 8px; border-radius: 6px; user-select: all; }
.subbanner { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; padding: 8px 14px; background: #fff3cd; color: #5c4400; font-size: .92rem; }
.subbanner.late { background: #fbd9d6; color: #8a1c14; }
.subbanner .btn { text-decoration: none; margin: 0; }

/* Entregas y selección de mesa en la venta */
.deliv { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ordercard { margin-bottom: 10px; }
.ordercard .seg { margin: 0 0 8px; }
.ordercard select { min-height: 48px; }

/* Compras y gastos */
.purline { display: grid; grid-template-columns: 1fr 100px 100px auto; gap: 8px; align-items: center; margin-bottom: 8px; }
.purline small { grid-column: 1 / -1; margin-top: -4px; }
@media (max-width: 700px) {
  .purline { grid-template-columns: 1fr 1fr; }
  .purline > select { grid-column: 1 / -1; }
  .purline > button { grid-column: 1 / -1; justify-self: start; }
}

/* Mesas, cuenta y cocina */
.tables-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.tcard { display: flex; flex-direction: column; align-items: flex-start; gap: 4px; min-height: 120px; padding: 12px; text-align: left; border-radius: 14px; cursor: pointer; border: 2px solid var(--line); background: var(--card); color: var(--text); }
.tcard .tnum { font-size: 1.7rem; font-weight: 700; line-height: 1; }
.tcard.free { border-style: dashed; color: var(--muted); }
.tcard.free .tnum { color: var(--text); }
.tcard.busy { border-color: var(--brand); background: #fff3e2; }
.tcard.ready { border-color: #2e7d32; background: #e9f6ea; animation: pulse-ready 2s ease-in-out infinite; }
.tcard:active { transform: scale(.98); }
.tbadges { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
@keyframes pulse-ready { 0%, 100% { box-shadow: 0 0 0 0 rgba(46,125,50,.35); } 50% { box-shadow: 0 0 0 6px rgba(46,125,50,0); } }
@media (prefers-reduced-motion: reduce) { .tcard.ready { animation: none; } }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 10px 14px; margin-bottom: 10px; border-radius: 12px; background: var(--dark); color: var(--cream); }
.totals { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.totals > div { flex: 1 1 90px; display: flex; flex-direction: column; padding: 8px 10px; border-radius: 10px; background: var(--cream); font-size: .85rem; }
.totals strong { font-size: 1.15rem; }
.totals .due { background: #fff0cf; }
.kgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 8px 0 18px; }
.ksec { margin: 18px 0 2px; font-size: 1.1rem; }
.kcard { display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; background: var(--card); border: 2px solid var(--line); }
.kcard.nuevo { border-color: var(--brand); }
.kcard.listo { border-color: #2e7d32; background: #e9f6ea; }
.kcard.late { border-color: var(--danger); background: #fdecea; }
.khead { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; }
.ktitle { font-size: 1.35rem; }
.kmin { padding: 2px 10px; border-radius: 99px; background: var(--cream); font-weight: 700; white-space: nowrap; }
.kmin.late { background: var(--danger); color: #fff; }
.kitems { display: flex; flex-direction: column; gap: 6px; font-size: 1.1rem; }
.kitem .knote, .kcard > .knote { margin-top: 2px; padding: 4px 8px; border-radius: 8px; background: #fff3cd; font-size: .95rem; }
.kactions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kactions .btn { margin: 0; flex: 1 1 110px; min-height: 52px; font-size: 1.05rem; }

/* Menú del día */
.menucard { background: var(--dark); color: var(--cream); border-radius: 14px; padding: 12px; margin-bottom: 12px; }
.menucard-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 8px; }
.menucard small { color: #d9c4a3; }
.menucard .seg { margin: 6px 0; }
.menucard .seg button { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 10px; background: var(--cream); border-color: var(--cream); color: #2b1400; }
.menucard .seg button strong { font-size: 1.05rem; }
.optlist { display: flex; flex-direction: column; gap: 6px; }
.opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; padding: 8px 12px; text-align: left; border: 1px solid var(--line); border-radius: 10px; background: var(--card); color: var(--text); cursor: pointer; }
.opt.on { border-color: var(--brand); background: #fff3e2; font-weight: 700; box-shadow: inset 0 0 0 1px var(--brand); }
.opt.out { opacity: .45; cursor: not-allowed; }
.opt small { color: var(--muted); font-weight: 500; }
.combo-row { display: grid; grid-template-columns: 1fr 100px; gap: 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--line); }
.combo-row .combo-flags { grid-column: 1 / -1; display: flex; gap: 14px; flex-wrap: wrap; }
.combo-row > button { grid-column: 1 / -1; justify-self: start; }
.miniCheck { display: inline-flex; align-items: center; gap: 6px; margin: 0; font-weight: 500; }
.miniCheck input { width: 20px; min-height: 20px; }
.addrow { display: grid; grid-template-columns: 1fr 110px auto; gap: 8px; margin-top: 10px; align-items: center; }
.portion { width: 110px; }
.portion input { min-height: 40px; }
.chips.wrap { flex-wrap: wrap; overflow: visible; }
@media (min-width: 701px) {
  .combo-row { grid-template-columns: 1fr 110px auto auto; }
  .combo-row .combo-flags { grid-column: auto; }
  .combo-row > button { grid-column: auto; }
}

/* Reportes y caja (Fase 4) */
.chart { display: block; width: 100%; height: auto; }
.chart .bar { fill: var(--brand); }
.chart .bar:hover { fill: var(--dark); }
.chart .bar.peak { fill: var(--dark); }
.chart .axis { stroke: var(--line); stroke-width: 1; }
.chart .tick { fill: var(--muted); font-size: 11px; font-family: inherit; }
.hbars { display: flex; flex-direction: column; gap: 12px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: .92rem; margin-bottom: 4px; }
.hbar-top .name { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar-top span:last-child { color: var(--muted); white-space: nowrap; }
.hbar-track { height: 10px; border-radius: 99px; background: var(--cream); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 99px; background: var(--brand); }
.grid2.cols > .card { margin-bottom: 14px; }
.badge.ok { background: #d9efdb; color: #1f5a25; }
.warnbox { background: #fff4de; border-color: #f1d49a; }
a.btn { text-decoration: none; }

@media (max-width: 700px) {
  .stats { grid-template-columns: 1fr; }
  .recipe-row { grid-template-columns: 1fr 80px auto; }
  .recipe-row .unit { display: none; }
  .layout { flex-direction: column; }
  nav.side {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; width: auto;
    display: flex; gap: 4px; padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--card); border-top: 1px solid var(--line); overflow-x: auto;
  }
  nav.side button { flex: 0 0 auto; width: auto; margin: 0; padding: 10px 14px; text-align: center; white-space: nowrap; }
  nav.side { scrollbar-width: none; }
  nav.side::-webkit-scrollbar { display: none; }
  main { padding: 12px 12px 90px; }
  .grid2 { grid-template-columns: 1fr; }
}
