:root {
  --bg: #f6f3ec;
  --panel: #ffffff;
  --panel-2: #faf8f3;
  --ink: #1f2a2a;
  --ink-2: #566463;
  --ink-3: #8a9493;
  --line: #e4dfd3;
  --line-2: #efebe1;
  --brand: #1b2d62;
  --brand-2: #2a4590;
  --brand-soft: #e7ecf7;
  --gold: #c9a24a;
  --accent: #c8862a;
  --accent-soft: #f8ecd9;
  --ok: #2f7d4a;
  --ok-soft: #e2f1e6;
  --warn: #b26b00;
  --warn-soft: #fbefd9;
  --bad: #b23a3a;
  --bad-soft: #f8e1e1;
  --tienda: #2c5c94;
  --tienda-soft: #e2ebf6;
  --publico: #8a4f9e;
  --publico-soft: #f1e5f5;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(31, 42, 42, .06), 0 4px 16px rgba(31, 42, 42, .05);
  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "Cascadia Mono", Consolas, ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 15px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--brand); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 24px; font-weight: 650; letter-spacing: -.01em; }
h2 { font-size: 18px; font-weight: 600; }
h3 { font-size: 15px; font-weight: 600; }
.num, td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: 13px; }
.hidden { display: none !important; }
.nowrap { white-space: nowrap; }

/* ---------- layout ---------- */
.app { display: grid; grid-template-columns: 232px 1fr; min-height: 100vh; }
.side {
  background: var(--brand); color: #e6ebf6; display: flex; flex-direction: column; border-right: 3px solid var(--gold);
  position: sticky; top: 0; height: 100vh; padding: 18px 12px;
}
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 10px 18px; }
.brand-logo {
  display: grid; justify-items: center; gap: 6px; padding: 10px 10px 12px; margin: 0 2px 14px;
  background: #fff; border-radius: 14px; box-shadow: 0 2px 10px rgba(0,0,0,.18);
}
.brand-logo img { width: 100%; max-width: 180px; height: auto; display: block; }
.brand-logo span { font-size: 11px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--brand); }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; background: #f6f3ec; color: var(--brand);
  display: grid; place-items: center; font-weight: 800; font-size: 18px;
}
.brand-name { font-weight: 650; font-size: 16px; line-height: 1.15; }
.brand-sub { font-size: 12px; opacity: .7; }
.nav { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.nav a {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 9px;
  color: #d3dcf0; text-decoration: none; font-weight: 500;
}
.nav a:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.nav a.active { background: #f6f3ec; color: var(--brand); }
.nav .ico { width: 20px; text-align: center; font-size: 16px; }
.nav .sep { height: 1px; background: rgba(255, 255, 255, .12); margin: 8px 6px; }
.nav .badge { margin-left: auto; background: var(--accent); color: #fff; border-radius: 99px; font-size: 11px; padding: 1px 7px; font-weight: 700; }
.side-foot { margin-top: auto; padding: 12px 10px 0; font-size: 12px; color: #c3cde6; display: grid; gap: 6px; }
.side-foot b { color: #fff; font-weight: 600; }
.side-foot button { background: none; border: 1px solid rgba(255,255,255,.25); color: #e6ebf6; border-radius: 8px; padding: 5px 8px; cursor: pointer; }
.side-foot button:hover { background: rgba(255,255,255,.08); }
.sync-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: #8fd3a8; margin-right: 6px; }
.sync-dot.warn { background: #f2c26b; }
.sync-dot.bad { background: #f08a8a; }

.main { padding: 24px 28px 48px; min-width: 0; }
.page-head { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.page-head .grow { flex: 1; }
.btn.menu-btn { display: none; }

/* ---------- cards ---------- */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.card-pad { padding: 18px; }
.card-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--line-2); }
.card-head .grow { flex: 1; }
.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)); }
.stack { display: grid; gap: 16px; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }

.kpi { padding: 16px 18px; }
.kpi .label { color: var(--ink-2); font-size: 13px; font-weight: 500; }
.kpi .value { font-size: 26px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.kpi .sub { color: var(--ink-2); font-size: 13px; margin-top: 2px; }
.kpi.ok .value { color: var(--ok); }

/* ---------- buttons & inputs ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink);
  border-radius: 9px; padding: 8px 14px; font-weight: 550; cursor: pointer; white-space: nowrap;
  text-decoration: none;
}
.btn:hover { background: var(--panel-2); border-color: #d6d0c1; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn.primary:hover { background: var(--brand-2); }
.btn.accent { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--bad); border-color: #e9c3c3; }
.btn.danger:hover { background: var(--bad-soft); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--line-2); }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 7px; }
.btn.lg { padding: 13px 22px; font-size: 17px; border-radius: 11px; }
.btn.block { width: 100%; }

.field { display: grid; gap: 5px; }
.field > span { font-size: 13px; color: var(--ink-2); font-weight: 500; }
.input, select.input, textarea.input {
  width: 100%; border: 1px solid #d9d3c5; background: #fff; border-radius: 9px; padding: 8px 11px; outline: none;
  min-height: 38px;
}
textarea.input { min-height: 70px; resize: vertical; }
.input:focus { border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(42, 69, 144, .15); }
.input.num { text-align: right; }
.input.sm { min-height: 32px; padding: 5px 8px; }
.form-grid { display: grid; gap: 12px 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.form-grid .full { grid-column: 1 / -1; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--brand); }

.seg { display: inline-flex; background: var(--line-2); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 7px 14px; border-radius: 8px; cursor: pointer; font-weight: 550; color: var(--ink-2); }
.seg button.on { background: #fff; color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
table.t { width: 100%; border-collapse: collapse; }
.t th, .t td { padding: 9px 12px; border-bottom: 1px solid var(--line-2); text-align: left; vertical-align: middle; }
.t th { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--ink-3); font-weight: 600; background: var(--panel-2); position: sticky; top: 0; }
.t tbody tr:hover { background: #fcfbf8; }
.t tr.click { cursor: pointer; }
.t tfoot td { font-weight: 650; background: var(--panel-2); }
.t tr.cancel td { color: var(--ink-3); text-decoration: line-through; }
.t .group td { background: var(--panel-2); font-weight: 600; color: var(--ink-2); font-size: 13px; }

.pill { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: 12px; font-weight: 600; white-space: nowrap; }
.pill.tienda { background: var(--tienda-soft); color: var(--tienda); }
.pill.publico { background: var(--publico-soft); color: var(--publico); }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.gray { background: var(--line-2); color: var(--ink-2); }

.empty { padding: 36px 18px; text-align: center; color: var(--ink-3); }
.alert { border-radius: 10px; padding: 10px 14px; font-size: 14px; }
.alert.warn { background: var(--warn-soft); color: #7a4a00; }
.alert.bad { background: var(--bad-soft); color: #7d2525; }
.alert.ok { background: var(--ok-soft); color: #1d5532; }
.alert.info { background: var(--brand-soft); color: #1b2d62; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs button { border: 0; background: none; padding: 10px 14px; cursor: pointer; font-weight: 550; color: var(--ink-2); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs button.on { color: var(--brand); border-color: var(--brand); }

/* ---------- POS ---------- */
.pos { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 16px; align-items: start; }
.pos-top { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
.tipo-switch { display: inline-flex; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); background: #fff; }
.tipo-switch button { border: 0; background: transparent; padding: 10px 18px; cursor: pointer; font-weight: 650; color: var(--ink-2); }
.tipo-switch button.on.tienda { background: var(--tienda); color: #fff; }
.tipo-switch button.on.publico { background: var(--publico); color: #fff; }
.cats { display: flex; gap: 6px; flex-wrap: wrap; margin: 10px 0 12px; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 99px; padding: 5px 12px; cursor: pointer; font-size: 13px; font-weight: 550; color: var(--ink-2); }
.chip.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(178px, 1fr)); gap: 10px; }
.prod {
  text-align: left; background: #fff; border: 1px solid var(--line); border-radius: 11px; padding: 11px 12px;
  cursor: pointer; display: grid; gap: 4px; min-height: 104px; transition: border-color .1s, transform .05s;
}
.prod:hover { border-color: var(--brand-2); }
.prod:active { transform: scale(.985); }
.prod .pn { font-weight: 600; line-height: 1.25; }
.prod .pp { font-variant-numeric: tabular-nums; font-weight: 650; color: var(--brand); }
.prod .ps { font-size: 12px; color: var(--ink-3); }
.prod.sin { opacity: .55; }
.prod .stock-0 { color: var(--bad); font-weight: 600; }
.cart { position: sticky; top: 16px; display: flex; flex-direction: column; max-height: calc(100vh - 32px); }
.cart-lines { overflow-y: auto; flex: 1; min-height: 120px; }
.cline { padding: 10px 14px; border-bottom: 1px solid var(--line-2); display: grid; gap: 6px; }
.cline-top { display: flex; gap: 8px; align-items: flex-start; }
.cline-top .n { flex: 1; font-weight: 600; line-height: 1.25; }
.cline-ctrl { display: grid; grid-template-columns: auto minmax(64px, 84px) 1fr auto; gap: 6px; align-items: center; }
.cline-ctrl .precio { display: flex; align-items: center; gap: 4px; justify-content: flex-end; white-space: nowrap; }
.cline-ctrl .precio input { width: 76px; }
.cline-ctrl .sub { text-align: right; font-weight: 650; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; border: 1px solid #d9d3c5; border-radius: 9px; overflow: hidden; background: #fff; }
.qty button { border: 0; background: var(--panel-2); width: 28px; flex: none; height: 32px; cursor: pointer; font-size: 17px; }
.qty input { width: 48px; border: 0; text-align: center; height: 32px; outline: none; }
.pres { font-size: 12px; }
.cart-foot { padding: 14px; border-top: 1px solid var(--line); display: grid; gap: 10px; background: var(--panel-2); border-radius: 0 0 var(--radius) var(--radius); }
.total-line { display: flex; justify-content: space-between; align-items: baseline; }
.total-line .big { font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }

.cart-bar {
  display: none; position: fixed; left: 0; right: 0; bottom: 0; z-index: 40; padding: 10px 16px;
  background: var(--brand); color: #fff; align-items: center; gap: 12px; box-shadow: 0 -4px 20px rgba(0,0,0,.15);
}
.cart-bar .grow { flex: 1; }
.cart-bar b { font-size: 20px; font-variant-numeric: tabular-nums; }
.cart-bar .btn { background: #fff; color: var(--brand); border-color: #fff; }

/* ---------- modal & toast ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(20, 30, 30, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 14px; width: min(640px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; box-shadow: 0 20px 60px rgba(0,0,0,.25); }
.modal.wide { width: min(980px, 100%); }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 16px 20px; border-bottom: 1px solid var(--line-2); }
.modal-head h2 { flex: 1; }
.modal-body { padding: 18px 20px; overflow-y: auto; }
.modal-foot { display: flex; gap: 10px; justify-content: flex-end; padding: 14px 20px; border-top: 1px solid var(--line-2); background: var(--panel-2); border-radius: 0 0 14px 14px; }
.toasts { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 80; width: min(380px, calc(100vw - 36px)); }
.toast { background: var(--ink); color: #fff; border-radius: 11px; padding: 11px 14px; box-shadow: 0 8px 28px rgba(0,0,0,.2); font-size: 14px; display: flex; gap: 10px; animation: tin .2s ease-out; }
.toast.ok { background: var(--ok); }
.toast.bad { background: var(--bad); }
.toast.info { background: #26404a; }
.toast .t-body { flex: 1; }
.toast .t-title { font-weight: 650; font-size: 13px; opacity: .85; }
.toast button { background: none; border: 0; color: #fff; opacity: .7; cursor: pointer; font-size: 16px; }
@keyframes tin { from { transform: translateY(8px); opacity: 0; } }

/* ---------- charts ---------- */
.chart { width: 100%; height: 240px; display: block; }
.chart .bar-t { fill: var(--brand); }
.chart .bar-g { fill: var(--gold); }
.chart text { fill: var(--ink-3); font-size: 11px; font-family: var(--font); }
.chart .grid-l { stroke: var(--line-2); }
.legend { display: flex; gap: 14px; font-size: 13px; color: var(--ink-2); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.split-bar { display: flex; height: 10px; border-radius: 99px; overflow: hidden; background: var(--line-2); }
.split-bar .a { background: var(--tienda); }
.split-bar .b { background: var(--publico); }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login { width: min(380px, 100%); padding: 28px; display: grid; gap: 14px; }
.login-logo { display: block; width: min(260px, 80%); height: auto; margin: 0 auto 4px; }
.login-title { text-align: center; color: var(--ink-2); font-weight: 600; margin-bottom: 4px; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .pos { grid-template-columns: minmax(0, 1fr) 360px; }
  .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .side { position: fixed; z-index: 60; left: 0; top: 0; width: 250px; transform: translateX(-100%); transition: transform .2s; }
  .side.open { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .btn.menu-btn { display: inline-flex; }
  .cart-bar { display: flex; }
  .main.con-barra { padding-bottom: 96px; }
  .main { padding: 16px; }
  .pos { grid-template-columns: 1fr; }
  .cart { position: static; max-height: none; }
  .g2, .g3 { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
}
@media (max-width: 560px) {
  .g4 { grid-template-columns: 1fr; }
  .cline-ctrl { grid-template-columns: auto 1fr; }
  .toasts { bottom: 80px; }
}
@media print {
  .side, .page-head .btn, .toasts { display: none !important; }
  .app { display: block; }
  .card { box-shadow: none; }
}
