/* =============================================================
   BRUTAL – TORTAS EXPLOSIVAS · Identidad visual
   Para usar la tipografía original BabyDoll: copiá el archivo a
   public/fonts/BabyDoll.ttf (o .otf / .woff2) y recargá la página.
   ============================================================= */
@font-face { font-family: 'Brutal Display'; src: url('fonts/BabyDoll.woff2') format('woff2'), url('fonts/BabyDoll.woff') format('woff'), url('fonts/BabyDoll.ttf') format('truetype'), url('fonts/BabyDoll.otf') format('opentype'), local('BabyDoll'), local('BabyDoll Regular'), local('BabyDoll-Regular'); font-display: swap; unicode-range: U+0020-007E; }
@font-face { font-family: 'Titan One'; src: url('fonts/titan-one-latin-400-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Titan One'; src: url('fonts/titan-one-latin-ext-400-normal.woff2') format('woff2'); unicode-range: U+0100-024F; font-display: swap; }
@font-face { font-family: 'Comfortaa'; font-weight: 700; src: url('fonts/comfortaa-latin-700-normal.woff2') format('woff2'); font-display: swap; }
@font-face { font-family: 'Comfortaa'; font-weight: 700; src: url('fonts/comfortaa-latin-ext-700-normal.woff2') format('woff2'); unicode-range: U+0100-024F; font-display: swap; }
@font-face { font-family: 'Comfortaa'; font-weight: 400; src: url('fonts/comfortaa-latin-400-normal.woff2') format('woff2'); font-display: swap; }

:root {
  --brown: #492A15; --orange: #9E4A16; --cream: #FCE4C3; --lavender: #A5AED4; --sage: #798E73;
  --brown-2: #5d3a20; --cream-2: #fff6ea; --cream-3: #f6d7ae; --orange-2: #c0621f;
  --ink: #3a2414; --muted: #8a6d55; --line: #ecd3b0; --white: #fffdf9;
  --ok: #5f7a58; --warn: #c27b14; --bad: #a8321e; --ok-bg: #e6eee2; --warn-bg: #fbeacc; --bad-bg: #f8dcd4; --lav-bg: #e5e8f4;
  --f-display: 'Brutal Display', 'Titan One', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --f-head: 'Comfortaa', 'Arial Rounded MT Bold', system-ui, sans-serif;
  --f-body: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  --radius: 16px; --shadow: 0 2px 0 rgba(73, 42, 21, .08), 0 8px 24px rgba(73, 42, 21, .07);
  --side: 248px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--cream); color: var(--ink); font-family: var(--f-body); font-size: 15px; line-height: 1.45; -webkit-font-smoothing: antialiased; }
h1, h2, h3, .display { font-family: var(--f-display); text-transform: uppercase; letter-spacing: .02em; color: var(--brown); font-weight: 400; margin: 0; }
h1 { font-size: 30px; } h2 { font-size: 22px; } h3 { font-size: 17px; }
.head, label, th, .nav a, .btn, .tag, .tabs button, .kpi .k-label { font-family: var(--f-head); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
a { color: var(--orange); }
.muted { color: var(--muted); } .small { font-size: 12.5px; } .right { text-align: right; } .center { text-align: center; } .nowrap { white-space: nowrap; }
.pos { color: var(--ok); } .neg { color: var(--bad); }
.hidden { display: none !important; }

/* ---------- Login ---------- */
.login-wrap { min-height: 100%; display: grid; place-items: center; padding: 24px; background:
  radial-gradient(circle at 15% 20%, rgba(158, 74, 22, .18) 0 120px, transparent 121px),
  radial-gradient(circle at 85% 80%, rgba(165, 174, 212, .35) 0 160px, transparent 161px), var(--cream); }
.login { width: 100%; max-width: 380px; background: var(--white); border: 3px solid var(--brown); border-radius: 24px; padding: 32px 28px; box-shadow: 8px 8px 0 var(--brown); }
.brand-big { text-align: center; margin-bottom: 22px; }
.brand-big .b1 { font-family: var(--f-display); font-size: 56px; color: var(--brown); line-height: .95; letter-spacing: .04em; }
.brand-big .b2 { font-family: var(--f-head); font-weight: 700; letter-spacing: .35em; color: var(--orange); font-size: 12px; margin-top: 6px; }

/* ---------- Layout ---------- */
.app { display: grid; grid-template-columns: var(--side) 1fr; min-height: 100%; }
.side { background: var(--brown); color: var(--cream); position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column; padding: 18px 12px; }
.side .brand { padding: 6px 12px 18px; border-bottom: 1px dashed rgba(252, 228, 195, .25); margin-bottom: 10px; }
.side .brand .b1 { font-family: var(--f-display); font-size: 34px; letter-spacing: .05em; color: var(--cream); line-height: 1; }
.side .brand .b2 { font-family: var(--f-head); font-weight: 700; font-size: 9.5px; letter-spacing: .32em; color: #e9a46d; margin-top: 5px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .sep { font-family: var(--f-head); font-size: 10px; letter-spacing: .2em; color: rgba(252, 228, 195, .45); padding: 14px 12px 4px; text-transform: uppercase; }
.nav a { display: flex; align-items: center; gap: 11px; padding: 9px 12px; color: var(--cream); text-decoration: none; border-radius: 12px; font-size: 12px; }
.nav a svg { width: 19px; height: 19px; flex: none; opacity: .9; }
.nav a:hover { background: rgba(252, 228, 195, .09); }
.nav a.active { background: var(--orange); color: #fff; box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .15); }
.nav a .badge { margin-left: auto; background: var(--cream); color: var(--brown); border-radius: 99px; padding: 0 7px; font-size: 10px; }
.side .foot { margin-top: auto; padding: 14px 12px 4px; font-size: 12px; color: rgba(252, 228, 195, .7); }
.side .foot button { background: none; border: 1px solid rgba(252, 228, 195, .35); color: var(--cream); border-radius: 10px; padding: 6px 10px; cursor: pointer; font-family: var(--f-head); font-weight: 700; font-size: 10.5px; letter-spacing: .08em; }
.main { min-width: 0; padding: 26px 30px 60px; }
.topbar { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 20px; }
.topbar h1 { flex: 1; min-width: 200px; }
.topbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }
.mobile-bar { display: none; }

/* ---------- Componentes ---------- */
.card { background: var(--white); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px 20px; border: 1px solid var(--line); min-width: 0; }
.card > h3 { margin-bottom: 12px; }
.card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; flex-wrap: wrap; }
.card-head h3 { flex: 1; margin: 0; }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } .g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.span2 { grid-column: span 2; } .mt { margin-top: 16px; } .mb { margin-bottom: 16px; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 14px; }
.kpi { background: var(--white); border-radius: var(--radius); padding: 15px 17px; border: 1px solid var(--line); box-shadow: var(--shadow); position: relative; overflow: hidden; }
.kpi::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--accent, var(--orange)); }
.kpi .k-label { font-size: 10.5px; color: var(--muted); }
.kpi .k-value { font-family: var(--f-display); font-size: 26px; color: var(--brown); margin-top: 4px; line-height: 1.1; word-break: break-word; }
.kpi .k-sub { font-size: 12px; color: var(--muted); margin-top: 3px; }
.kpi.hero { background: var(--brown); border-color: var(--brown); }
.kpi.hero .k-label, .kpi.hero .k-sub { color: #e9c79e; } .kpi.hero .k-value { color: var(--cream); }
.delta { font-size: 11.5px; font-weight: 700; padding: 1px 7px; border-radius: 99px; margin-left: 4px; white-space: nowrap; }
.delta.up { background: var(--ok-bg); color: var(--ok); } .delta.down { background: var(--bad-bg); color: var(--bad); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 2px solid var(--brown); background: var(--white); color: var(--brown); padding: 8px 14px; border-radius: 12px; cursor: pointer; font-size: 11.5px; text-decoration: none; transition: transform .05s, background .15s; white-space: nowrap; }
.btn:hover { background: var(--cream-2); } .btn:active { transform: translateY(1px); }
.btn.primary { background: var(--orange); border-color: var(--orange); color: #fff; box-shadow: 0 3px 0 var(--brown); }
.btn.primary:hover { background: var(--orange-2); }
.btn.dark { background: var(--brown); color: var(--cream); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.danger { border-color: var(--bad); color: var(--bad); }
.btn.sm { padding: 5px 9px; font-size: 10.5px; border-radius: 9px; border-width: 1.5px; }
.btn.lg { padding: 13px 22px; font-size: 14px; border-radius: 14px; }
.btn svg { width: 16px; height: 16px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.tag { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 10px; background: var(--cream); color: var(--brown); white-space: nowrap; }
.tag.ok { background: var(--ok-bg); color: var(--ok); } .tag.warn { background: var(--warn-bg); color: var(--warn); } .tag.bad { background: var(--bad-bg); color: var(--bad); } .tag.lav { background: var(--lav-bg); color: #4b5487; }

/* formularios */
.form { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form .full { grid-column: 1 / -1; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
label { font-size: 10.5px; color: var(--brown); }
input, select, textarea { font: inherit; color: var(--ink); background: #fff; border: 1.5px solid var(--line); border-radius: 11px; padding: 9px 11px; width: 100%; min-width: 0; }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--orange); box-shadow: 0 0 0 3px rgba(158, 74, 22, .15); }
input[type=checkbox] { width: auto; accent-color: var(--orange); }
textarea { min-height: 70px; resize: vertical; }
.hint { font-size: 12px; color: var(--muted); }
.inline { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.inline > .field { flex: 1; }
.check { display: flex; gap: 8px; align-items: center; font-family: var(--f-body); text-transform: none; font-weight: 400; letter-spacing: 0; font-size: 14px; color: var(--ink); cursor: pointer; }
.input-money { position: relative; } .input-money::before { content: '$'; position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--muted); }
.input-money input { padding-left: 24px; }

/* tablas */
.table-wrap { overflow-x: auto; margin: 0 -4px; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { font-size: 10px; color: var(--muted); text-align: left; padding: 9px 10px; border-bottom: 2px solid var(--line); white-space: nowrap; cursor: default; background: var(--white); position: sticky; top: 0; }
th.sortable { cursor: pointer; } th.sortable:hover { color: var(--orange); }
td { padding: 9px 10px; border-bottom: 1px solid #f4e4cd; vertical-align: middle; }
tr.click { cursor: pointer; } tr.click:hover td { background: var(--cream-2); }
tr.total td { font-weight: 700; background: var(--cream); border-top: 2px solid var(--brown); color: var(--brown); }
tr.dim td { opacity: .5; text-decoration: line-through; }
td.num, th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 14px; }
.filters .field { min-width: 140px; flex: 0 1 180px; }
.filters .grow { flex: 1 1 220px; }
.empty { text-align: center; color: var(--muted); padding: 30px 10px; }
.empty .display { font-size: 20px; color: var(--cream-3); display: block; margin-bottom: 6px; }

.tabs { display: flex; gap: 6px; margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 2px solid var(--brown); background: transparent; color: var(--brown); border-radius: 99px; padding: 6px 14px; cursor: pointer; font-size: 11px; }
.tabs button.on { background: var(--brown); color: var(--cream); }

/* modal */
.modal-bg { position: fixed; inset: 0; background: rgba(46, 26, 12, .55); display: flex; align-items: flex-start; justify-content: center; padding: 40px 16px; overflow-y: auto; z-index: 50; }
.modal { background: var(--cream-2); border-radius: 20px; width: 100%; max-width: 640px; border: 3px solid var(--brown); box-shadow: 8px 8px 0 var(--brown); }
.modal.wide { max-width: 980px; }
.modal-h { display: flex; align-items: center; padding: 16px 20px; border-bottom: 2px dashed var(--line); gap: 10px; }
.modal-h h2 { flex: 1; font-size: 20px; }
.modal-b { padding: 18px 20px; }
.modal-f { padding: 14px 20px; display: flex; justify-content: flex-end; gap: 8px; border-top: 2px dashed var(--line); flex-wrap: wrap; }
.x { background: none; border: 0; font-size: 26px; cursor: pointer; color: var(--brown); line-height: 1; }

.toasts { position: fixed; right: 18px; bottom: 18px; display: flex; flex-direction: column; gap: 8px; z-index: 80; max-width: calc(100vw - 36px); }
.toast { background: var(--brown); color: var(--cream); padding: 12px 16px; border-radius: 14px; box-shadow: var(--shadow); max-width: 420px; font-size: 14px; animation: pop .2s ease-out; }
.toast.err { background: var(--bad); color: #fff; } .toast.warn { background: var(--warn); color: #fff; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.alert { padding: 11px 14px; border-radius: 12px; font-size: 14px; margin-bottom: 12px; border: 1.5px solid; }
.alert.warn { background: var(--warn-bg); color: #7a4c08; border-color: #ecc78a; }
.alert.info { background: var(--lav-bg); color: #3c4475; border-color: var(--lavender); }
.alert.bad { background: var(--bad-bg); color: var(--bad); border-color: #e9b1a4; }
.alert.ok { background: var(--ok-bg); color: #3e5538; border-color: #b9c9b3; }

/* Venta rápida */
.pos-layout { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(320px, 1fr); gap: 16px; align-items: start; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prod-tile { background: var(--white); border: 2px solid var(--line); border-radius: 16px; padding: 10px; cursor: pointer; text-align: left; font: inherit; color: inherit; display: flex; flex-direction: column; gap: 6px; transition: border-color .1s, transform .05s; }
.prod-tile:hover { border-color: var(--orange); } .prod-tile:active { transform: scale(.98); }
.prod-tile .ph { aspect-ratio: 4/3; border-radius: 11px; background: var(--cream) center/cover no-repeat; display: grid; place-items: center; font-family: var(--f-display); color: var(--orange); font-size: 30px; }
.prod-tile .n { font-family: var(--f-head); font-weight: 700; font-size: 12px; text-transform: uppercase; color: var(--brown); line-height: 1.25; }
.prod-tile .p { font-weight: 700; color: var(--orange); }
.cart { position: sticky; top: 16px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line); }
.cart-line .n { font-weight: 700; color: var(--brown); }
.qty { display: inline-flex; align-items: center; border: 1.5px solid var(--line); border-radius: 10px; overflow: hidden; }
.qty button { border: 0; background: var(--cream); width: 30px; height: 30px; cursor: pointer; font-size: 17px; color: var(--brown); }
.qty input { width: 52px; border: 0; text-align: center; padding: 4px; border-radius: 0; }
.big-total { font-family: var(--f-display); font-size: 36px; color: var(--brown); }
.paybtns { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.paybtns button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; cursor: pointer; font-family: var(--f-head); font-weight: 700; font-size: 11px; text-transform: uppercase; color: var(--brown); }
.paybtns button.on { border-color: var(--orange); background: var(--orange); color: #fff; }

/* Recetas: planilla */
.sheet td input { padding: 6px 8px; }
.sheet td .input-money input { padding-left: 24px; }
.sheet td.ing { min-width: 200px; }
.cost-box { background: var(--brown); color: var(--cream); border-radius: var(--radius); padding: 18px 20px; }
.cost-box .row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px dashed rgba(252, 228, 195, .2); gap: 10px; }
.cost-box .row b { font-variant-numeric: tabular-nums; }
.cost-box .grand { font-family: var(--f-display); font-size: 28px; color: #fff; border: 0; padding-top: 12px; }
.photo-prev { width: 100%; aspect-ratio: 4/3; border-radius: 14px; background: var(--cream) center/cover no-repeat; border: 2px dashed var(--line); display: grid; place-items: center; color: var(--muted); font-size: 13px; cursor: pointer; }

.chart-box { position: relative; height: 260px; }
.chart-box.sm { height: 220px; }
.list-plain { list-style: none; margin: 0; padding: 0; }
.list-plain li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 0; border-bottom: 1px dashed var(--line); align-items: center; }
.list-plain li:last-child { border-bottom: 0; }
.bar-mini { height: 7px; border-radius: 99px; background: var(--cream); overflow: hidden; margin-top: 4px; }
.bar-mini > i { display: block; height: 100%; background: var(--orange); border-radius: 99px; }
.stepper { display: flex; gap: 8px; flex-wrap: wrap; }
.stepper span { padding: 6px 12px; border-radius: 99px; background: var(--cream); font-family: var(--f-head); font-weight: 700; font-size: 11px; text-transform: uppercase; color: var(--muted); }
.stepper span.on { background: var(--orange); color: #fff; }
.pre { white-space: pre-wrap; font-family: ui-monospace, Consolas, monospace; font-size: 12px; background: #fff; padding: 10px; border-radius: 10px; border: 1px solid var(--line); max-height: 300px; overflow: auto; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .pos-layout { grid-template-columns: 1fr; } .cart { position: static; } }
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 270px; transform: translateX(-100%); transition: transform .2s; }
  .app.menu-open .side { transform: none; box-shadow: 0 0 0 100vmax rgba(46, 26, 12, .45); }
  .mobile-bar { display: flex; align-items: center; gap: 12px; background: var(--brown); color: var(--cream); padding: 10px 16px; position: sticky; top: 0; z-index: 40; }
  .mobile-bar .b1 { font-family: var(--f-display); font-size: 24px; letter-spacing: .05em; flex: 1; }
  .mobile-bar button { background: none; border: 0; color: var(--cream); padding: 4px; cursor: pointer; }
  .main { padding: 16px 16px 60px; }
  .g2, .g3, .g4, .form { grid-template-columns: 1fr; } .span2 { grid-column: auto; }
  h1 { font-size: 24px; }
  .kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .kpi .k-value { font-size: 20px; }
  .modal-bg { padding: 0; } .modal { border-radius: 0; min-height: 100%; box-shadow: none; border: 0; }
}
@media print { .side, .mobile-bar, .topbar .actions, .filters, .btn { display: none !important; } .app { display: block; } body { background: #fff; } .card { box-shadow: none; } }

/* WhatsApp */
.wa-grid { display: grid; grid-template-columns: minmax(220px, 320px) 1fr; gap: 16px; align-items: start; }
@media (max-width: 800px) { .wa-grid { grid-template-columns: 1fr; } }
.wa-list { max-height: 75vh; overflow: auto; }
.wa-item { display: block; width: 100%; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--cream); padding: 10px 6px; cursor: pointer; color: var(--ink); font: inherit; }
.wa-item.on, .wa-item:hover { background: var(--cream); }
.wa-name { font-weight: 700; } .wa-last { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wa-msgs { max-height: 55vh; overflow: auto; display: flex; flex-direction: column; gap: 8px; padding: 10px; background: #f7efe3; border-radius: 12px; }
.wa-msg { max-width: 80%; padding: 8px 12px; border-radius: 12px; font-size: 14px; background: #fff; align-self: flex-start; }
.wa-msg.out { background: #dcf3d0; align-self: flex-end; }
.wa-meta { font-size: 10px; opacity: .6; margin-top: 4px; }
.wa-send { display: flex; gap: 8px; margin-top: 10px; align-items: flex-end; } .wa-send textarea { flex: 1; }
.wa-prods { display: grid; gap: 4px; max-height: 260px; overflow: auto; margin-top: 6px; }
.wa-status { list-style: none; padding: 0; line-height: 2; }
