:root {
  --bg: #f4f2ee; --panel: #fff; --ink: #1d1b18; --muted: #77716a; --line: #e3dfd8;
  --accent: #c2410c; --accent-soft: #fff3ec; --ok: #15803d; --bad: #b91c1c; --btn: #fbfaf8;
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.4 system-ui, "Segoe UI", sans-serif; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3 { margin: 0; }

/* Botones y formularios */
.btn { text-decoration: none; color: var(--ink); display: inline-block; border: 1px solid var(--line); background: var(--btn); padding: 8px 14px; border-radius: 8px; }
.btn:hover { border-color: #cfc9bf; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
input, select, textarea { border: 1px solid var(--line); background: #fff; border-radius: 8px; padding: 8px 10px; }
label.f { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
label.f input, label.f select, label.f textarea { color: var(--ink); font-size: 15px; }
label.check { display: flex; gap: 8px; align-items: center; }
.form { display: grid; gap: 12px; }
.form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.hint { font-size: 12px; color: var(--muted); }
.error { color: var(--bad); font-size: 14px; min-height: 1em; }

/* Login */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login form { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 28px; width: min(360px, 100%); }
.login h1 { font-size: 22px; margin-bottom: 4px; }

/* Estructura */
.shell { display: grid; grid-template-rows: auto 1fr; height: 100%; }
.top { display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.top h1 { font-size: 17px; }
.top nav { display: flex; gap: 4px; }
.top nav a { padding: 7px 12px; border-radius: 8px; text-decoration: none; color: var(--muted); }
.top nav a.on { background: var(--ink); color: #fff; }
.top .who { margin-left: auto; display: flex; gap: 10px; align-items: center; font-size: 13px; color: var(--muted); }
.page { overflow: auto; padding: 16px; }
.page-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h2 { font-size: 20px; margin-right: auto; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; }

/* Botonera */
.pos { display: grid; grid-template-columns: 1fr 360px; height: 100%; min-height: 0; }
.pos-main { overflow: auto; padding: 14px 16px; }
.pos-tools { display: flex; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.pos-tools input[type=search] { flex: 1; min-width: 180px; max-width: 380px; }
.cats { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.cats button { border: 1px solid var(--line); background: var(--panel); padding: 7px 14px; border-radius: 999px; font-size: 14px; }
.cats button.on { background: var(--ink); color: #fff; border-color: var(--ink); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prod { border: 1px solid var(--line); background: var(--btn); border-radius: 10px; padding: 12px; min-height: 88px; text-align: left; display: flex; flex-direction: column; justify-content: space-between; }
.prod:active { transform: scale(.97); background: var(--accent-soft); }
.prod .p { font-weight: 700; color: var(--accent); margin-top: 6px; }
.prod .c { font-size: 11px; color: var(--muted); }
.cart { background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.cart h3 { padding: 12px 16px; border-bottom: 1px solid var(--line); font-size: 16px; }
.cart .items { flex: 1; overflow: auto; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 4px 8px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.row .n { font-weight: 600; }
.row .s { text-align: right; font-weight: 600; }
.row .q { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 14px; }
.row .q button { width: 30px; height: 30px; border: 1px solid var(--line); background: var(--btn); border-radius: 6px; }
.cart .foot { padding: 14px 16px; border-top: 1px solid var(--line); display: grid; gap: 10px; }
.total { display: flex; justify-content: space-between; font-size: 24px; font-weight: 800; }
.cart .foot .btn.primary { padding: 13px; font-size: 16px; }
.empty { color: var(--muted); padding: 24px 16px; }

/* Ventana de extras */
.mod-group { border: 0; padding: 0; margin: 0 0 16px; display: grid; gap: 6px; }
.mod-group legend { font-weight: 700; margin-bottom: 6px; padding: 0; }
.mod-opt { display: flex; justify-content: space-between; align-items: center; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--line); background: var(--btn); border-radius: 8px; padding: 10px 12px; }
.mod-opt.on { border-color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.mod-opt b { color: var(--accent); font-weight: 600; white-space: nowrap; }
.mod-opt .q { display: flex; gap: 8px; align-items: center; }
.mod-opt .q button { width: 30px; height: 30px; border: 1px solid var(--line); background: #fff; border-radius: 6px; }
#modal-body td { white-space: normal; }
.prod-list label { display: flex; gap: 10px; align-items: center; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.prod-list label span.pr { margin-left: auto; color: var(--muted); font-size: 13px; }
.prod-list h3 { font-size: 14px; margin: 14px 0 4px; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }

/* Tablas */
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); font-weight: 600; }
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr.click { cursor: pointer; }
tbody tr.click:hover { background: #faf8f5; }
tr.off td { color: var(--muted); text-decoration: line-through; }
.tag { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; background: #eee9e2; }
.tag.ok { background: #dcfce7; color: var(--ok); }
.tag.bad { background: #fee2e2; color: var(--bad); }
.stats { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 14px; }
.stat { padding: 12px 16px; min-width: 160px; }
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12px; color: var(--muted); }

/* Locales */
.stores { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 12px; }
.store { padding: 16px; display: grid; gap: 10px; }
.store h3 { font-size: 17px; }
.store dl { display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; margin: 0; font-size: 13px; }
.store dt { color: var(--muted); }
.store dd { margin: 0; overflow-wrap: anywhere; }
.store .btns { display: flex; gap: 6px; flex-wrap: wrap; }

/* Modal y avisos */
dialog { border: 0; border-radius: 14px; padding: 22px; width: min(520px, calc(100% - 32px)); max-height: calc(100% - 32px); }
dialog::backdrop { background: rgba(20, 18, 15, .45); }
dialog h2 { font-size: 19px; margin-bottom: 14px; }
#toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%) translateY(20px); background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 10px; opacity: 0; pointer-events: none; transition: .2s; z-index: 10; }
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.bad { background: var(--bad); }

@media (max-width: 800px) {
  .pos { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .cart { border-left: 0; border-top: 1px solid var(--line); max-height: 45vh; }
  .top .who span { display: none; }
  .form .two { grid-template-columns: 1fr; }
}
