:root {
  --bg: #0a0a0c;
  --bg-elev: #111114;
  --card: #161619;
  --card-2: #1d1d21;
  --border: #2a2a30;
  --text: #f3f3f6;
  --muted: #8d8d97;
  --accent: #5b5cf6;
  --accent-2: #7172ff;
  --accent-soft: rgba(91, 92, 246, .16);
  --accent-glow: 0 6px 22px rgba(91, 92, 246, .45);
  --danger: #ff5b61;
  --danger-soft: rgba(255, 91, 97, .14);
  --ok: #33c27a;
  --warn: #f5a524;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 30px rgba(0, 0, 0, .35);
  --tabbar-h: 64px;
  color-scheme: dark;
}
:root[data-theme="light"] {
  --bg: #f3f3f7;
  --bg-elev: #ffffff;
  --card: #ffffff;
  --card-2: #f5f5f9;
  --border: #e2e2ea;
  --text: #121216;
  --muted: #6b6b76;
  --accent: #4f50ee;
  --accent-2: #6566ff;
  --accent-soft: rgba(79, 80, 238, .12);
  --accent-glow: 0 6px 18px rgba(79, 80, 238, .3);
  --danger: #e5383f;
  --danger-soft: rgba(229, 56, 63, .1);
  --shadow: 0 10px 30px rgba(20, 20, 40, .12);
  color-scheme: light;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 16px/1.4 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  overflow-x: hidden;
}
body.noscroll { overflow: hidden; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
img { display: block; }
h1, h2, h3 { margin: 0; letter-spacing: -.01em; }
h1 { font-size: 30px; font-weight: 750; }
h2 { font-size: 18px; font-weight: 700; }
h3 { font-size: 17px; font-weight: 700; }
.muted { color: var(--muted); }
.hidden { display: none !important; }

/* ---------- boot / spinner ---------- */
.boot { min-height: 100vh; display: grid; place-items: center; }
.spinner {
  width: 30px; height: 30px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
.spinner.sm { width: 18px; height: 18px; border-width: 2px; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading-row { display: flex; justify-content: center; padding: 28px; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(160%) blur(16px);
  -webkit-backdrop-filter: saturate(160%) blur(16px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-logo { width: 46px; height: 46px; border-radius: 13px; box-shadow: 0 4px 14px rgba(0,0,0,.3); flex: none; }
.brand-name { font-weight: 750; font-size: 19px; }
.brand-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-actions { display: flex; gap: 8px; flex: none; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 2px;
  width: 46px; height: 46px; border-radius: 14px;
  background: var(--card); border: 1px solid var(--border); color: var(--text);
}
.icon-btn.labeled { flex-direction: column; width: auto; min-width: 54px; padding: 0 10px; font-size: 12px; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.labeled svg { width: 18px; height: 18px; }
.icon-btn.sm { width: 34px; height: 34px; border-radius: 10px; }
.icon-btn.sm svg { width: 18px; height: 18px; }
.icon-btn.accent { color: var(--accent-2); }

/* ---------- layout ---------- */
.view {
  max-width: 720px; margin: 0 auto;
  padding: 18px 16px calc(var(--tabbar-h) + 34px + env(safe-area-inset-bottom));
}
.page-head { margin: 4px 0 16px; }
.page-head p { margin: 4px 0 0; font-size: 17px; }
.page-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }

.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 16px;
}
.card.pad { padding: 16px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 16px 8px; }
.card.pad .card-head { padding: 0 0 10px; }

/* ---------- tab bar ---------- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--bg-elev) 92%, transparent);
  backdrop-filter: saturate(160%) blur(18px);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--border);
}
.tab {
  position: relative;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 0 4px; text-decoration: none; color: var(--muted); font-size: 13px; font-weight: 500;
}
.tab svg { width: 26px; height: 26px; color: var(--accent-2); opacity: .75; }
.tab.active { color: var(--text); font-weight: 700; }
.tab.active svg { opacity: 1; }
.tab .dot {
  position: absolute; top: 4px; left: calc(50% + 12px);
  width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2);
}

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 18px; border-radius: 14px;
  background: var(--card-2); border: 1px solid var(--border); color: var(--text);
  font-weight: 600; font-size: 16px; text-decoration: none; white-space: nowrap;
}
.btn svg { width: 20px; height: 20px; }
.btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent));
  border-color: color-mix(in srgb, var(--accent-2) 70%, white 10%);
  color: #fff; box-shadow: var(--accent-glow);
}
.btn.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.btn.sm { min-height: 40px; padding: 0 16px; font-size: 15px; border-radius: 12px; }
.btn.block { width: 100%; }
.btn:disabled { opacity: .5; box-shadow: none; cursor: default; }
.btn:active:not(:disabled) { transform: scale(.98); }
.link {
  background: none; border: 0; padding: 6px 0; color: var(--accent-2); font-weight: 600; font-size: 15px;
}
.link.danger { color: var(--danger); }
.link.muted { color: var(--muted); font-weight: 500; }
.link.center { display: block; margin: 14px auto 0; }

/* ---------- inputs ---------- */
.input, select.input {
  width: 100%; min-height: 54px; padding: 0 16px;
  background: var(--bg); border: 1px solid var(--border); border-radius: 14px;
  color: var(--text); font-size: 17px; outline: none;
  -webkit-appearance: none; appearance: none;
}
:root[data-theme="light"] .input { background: var(--card-2); }
.input::placeholder { color: color-mix(in srgb, var(--muted) 75%, transparent); }
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
select.input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%238d8d97' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}
.field { display: flex; flex-direction: column; justify-content: flex-end; gap: 8px; margin-bottom: 14px; }
.field > span { color: var(--muted); font-size: 16px; line-height: 1.3; }
:root[data-theme="dark"] .field > span { color: #c5c5cc; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 14px; align-items: end; }
.hint { color: var(--muted); font-size: 15px; margin: -4px 0 16px; line-height: 1.45; }

.search-wrap { position: relative; margin-bottom: 14px; }
.search-wrap svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 20px; height: 20px; color: var(--muted); }
.search-wrap .input { padding-left: 46px; }

/* stepper */
.stepper {
  display: grid; grid-template-columns: 58px 1fr 58px; min-height: 54px;
  border: 1px solid var(--border); border-radius: 14px; overflow: hidden; background: var(--bg);
}
:root[data-theme="light"] .stepper { background: var(--card-2); }
.stepper button { background: none; border: 0; font-size: 24px; color: var(--text); }
.stepper button:active { background: var(--accent-soft); }
.stepper input {
  width: 100%; min-width: 0; border: 0; border-left: 1px solid var(--border); border-right: 1px solid var(--border);
  background: none; text-align: center; font-size: 18px; outline: none;
}
.stepper.sm { grid-template-columns: 38px 46px 38px; min-height: 40px; border-radius: 11px; }
.stepper.sm button { font-size: 20px; }
.stepper.sm input { font-size: 16px; }

/* chips / segmented */
.chips { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; }
.chip {
  min-height: 44px; padding: 0 20px; border-radius: 999px;
  background: var(--card); border: 1px solid var(--border); color: var(--text); font-size: 16px;
}
.chip.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent-2); font-weight: 600; }

.seg { display: inline-flex; background: var(--card-2); border: 1px solid var(--border); border-radius: 11px; padding: 3px; gap: 2px; }
.seg button {
  border: 0; background: none; padding: 6px 12px; border-radius: 8px; font-size: 14px; color: var(--muted); font-weight: 600;
}
.seg button.on { background: var(--accent); color: #fff; }
.seg button:disabled { opacity: .35; }

/* ---------- product list ---------- */
.list { overflow: hidden; }
.prow {
  display: grid; grid-template-columns: 66px 1fr auto; gap: 14px; align-items: center;
  padding: 16px; border-bottom: 1px solid var(--border); width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: inherit;
}
.list > :last-child { border-bottom: 0; }
.prow:active { background: var(--card-2); }
.thumb {
  width: 66px; height: 66px; border-radius: 12px; object-fit: cover;
  background: var(--card-2); border: 1px solid var(--border);
}
.thumb.ph { display: grid; place-items: center; color: var(--muted); }
.thumb.ph svg { width: 26px; height: 26px; }
.thumb.sm { width: 52px; height: 52px; border-radius: 10px; }
.pname { font-size: 17px; font-weight: 600; text-transform: uppercase; line-height: 1.3; word-break: break-word; }
.pmeta { color: var(--muted); font-size: 15px; margin-top: 3px; }
.pmeta .combo { color: var(--accent-2); }
.pstock { text-align: right; }
.pstock b { display: block; font-size: 32px; font-weight: 750; line-height: 1.05; font-variant-numeric: tabular-nums; }
.pstock span { color: var(--muted); font-size: 14px; }
.pstock.low b { color: var(--danger); }
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }

/* search results in Vender */
.ritem { display: grid; grid-template-columns: 58px 1fr auto; gap: 14px; align-items: center; padding: 14px 0; border-bottom: 1px solid var(--border); }
.ritem:last-child { border-bottom: 0; }
.ritem .thumb { width: 58px; height: 58px; }

/* ---------- cart ---------- */
.cart-empty { padding: 4px 16px 18px; color: var(--muted); font-size: 16px; }
.cart-item { padding: 12px 16px; border-bottom: 1px solid var(--border); }
.ci-top { display: grid; grid-template-columns: 52px 1fr auto; gap: 12px; align-items: center; }
.ci-bottom { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 10px; flex-wrap: wrap; }
.ci-sub { font-weight: 700; font-variant-numeric: tabular-nums; margin-left: auto; }
.ci-unit { color: var(--muted); font-size: 13px; }
.cart-form { padding: 14px 16px 4px; }
.cart-total { display: flex; justify-content: space-between; align-items: baseline; padding: 4px 16px 14px; }
.cart-total span { color: var(--muted); }
.cart-total b { font-size: 28px; font-variant-numeric: tabular-nums; }
.cart-actions { padding: 0 16px 16px; }

/* ---------- sales list ---------- */
.sales-head { display: flex; align-items: center; gap: 18px; margin: 22px 2px 12px; flex-wrap: wrap; }
.tabs-text button { background: none; border: 0; padding: 4px 0; margin-right: 18px; font-size: 17px; color: var(--muted); }
.tabs-text button.on { color: var(--text); font-weight: 600; }
.sales-head .day-total { margin-left: auto; color: var(--muted); font-size: 16px; }
.srow {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 14px 16px; border-bottom: 1px solid var(--border); width: 100%;
  background: none; border-left: 0; border-right: 0; border-top: 0; text-align: left; color: inherit;
}
.srow:active { background: var(--card-2); }
.srow .who { font-size: 17px; font-weight: 500; }
.srow .meta { color: var(--muted); font-size: 15px; margin-top: 2px; }
.srow .amt { font-weight: 700; font-size: 18px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.srow.void .amt { text-decoration: line-through; color: var(--muted); }
.badge { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; vertical-align: middle; }
.badge.void { background: var(--danger-soft); color: var(--danger); }
.badge.combo { background: var(--accent-soft); color: var(--accent-2); }

/* ---------- dashboard ---------- */
.hero { padding: 20px 18px; background:
  radial-gradient(120% 140% at 100% 0%, var(--accent-soft), transparent 60%), var(--card); }
.hero .label { color: var(--muted); font-size: 15px; font-weight: 600; }
.hero .big { font-size: 40px; font-weight: 800; letter-spacing: -.02em; margin: 4px 0 14px; font-variant-numeric: tabular-nums; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.kpis > div { background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; }
.kpis b { display: block; font-size: 20px; font-variant-numeric: tabular-nums; }
.kpis span { color: var(--muted); font-size: 13px; }
.chart { padding: 6px 12px 14px; position: relative; min-height: 200px; }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .bar { fill: var(--accent); opacity: .55; }
.chart .bar.hl { opacity: 1; }
.chart .axis { stroke: var(--border); stroke-width: 1; }
.chart .grid { stroke: var(--border); stroke-width: 1; stroke-dasharray: 3 4; opacity: .7; }
.chart text { fill: var(--muted); font-size: 12px; font-family: inherit; }
.chart text.val { fill: var(--text); font-weight: 700; font-size: 12px; }
.chart text.lbl.hl { fill: var(--text); font-weight: 700; }
.chart-empty { position: absolute; inset: 0 0 30px; display: grid; place-items: center; color: var(--muted); font-size: 15px; pointer-events: none; }
.chart-foot { padding: 0 16px 14px; color: var(--muted); font-size: 14px; }
.toprow { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; padding: 10px 16px; }
.toprow .bar-bg { grid-column: 1 / -1; height: 6px; border-radius: 6px; background: var(--card-2); overflow: hidden; }
.toprow .bar-fg { height: 100%; background: var(--accent); border-radius: 6px; }
.toprow .n { font-weight: 700; font-variant-numeric: tabular-nums; }
.toprow .nm { font-size: 15px; text-transform: uppercase; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- más ---------- */
.menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 16px; background: none; border: 0; border-bottom: 1px solid var(--border);
  text-align: left; color: var(--text); font-size: 17px;
}
.menu-item:last-child { border-bottom: 0; }
.menu-item svg { width: 22px; height: 22px; color: var(--accent-2); flex: none; }
.menu-item small { display: block; color: var(--muted); font-size: 14px; }
.menu-item.danger, .menu-item.danger svg { color: var(--danger); }
.stats { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 0 16px 16px; }
.stats > div { background: var(--card-2); border: 1px solid var(--border); border-radius: 14px; padding: 12px; }
.stats b { display: block; font-size: 19px; font-variant-numeric: tabular-nums; }
.stats span { color: var(--muted); font-size: 13px; }

/* ---------- sheet (modal) ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(0, 0, 0, .55);
  backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fade .18s ease;
}
.sheet {
  width: 100%; max-width: 720px; max-height: 92vh; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--bg-elev); border: 1px solid var(--border); border-bottom: 0;
  border-radius: 26px 26px 0 0;
  padding: 22px 18px calc(22px + env(safe-area-inset-bottom));
  animation: up .24s cubic-bezier(.2, .9, .3, 1);
}
:root[data-theme="dark"] .sheet { background: #0f0f12; }
@media (min-width: 760px) {
  .sheet-backdrop { align-items: center; }
  .sheet { border-radius: 26px; border-bottom: 1px solid var(--border); }
}
.sheet-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.sheet-head h2 { font-size: 28px; font-weight: 750; }
.sheet-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 8px; }
@keyframes up { from { transform: translateY(40px); opacity: .4; } to { transform: none; opacity: 1; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.photo-row { display: grid; grid-template-columns: 150px 1fr; gap: 16px; align-items: start; }
.photo-box {
  width: 150px; height: 150px; border-radius: 18px; overflow: hidden;
  background: var(--card-2); border: 1px solid var(--border); display: grid; place-items: center; color: var(--muted);
}
.photo-box img { width: 100%; height: 100%; object-fit: cover; }
.photo-box svg { width: 40px; height: 40px; }
.photo-actions { display: flex; flex-direction: column; gap: 10px; }
.photo-actions .btn { width: 100%; white-space: normal; text-align: center; }
.photo-rm { width: 150px; text-align: center; margin: 4px 0 10px; }

.detail-line { display: flex; justify-content: space-between; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); }
.detail-line:last-child { border-bottom: 0; }
.detail-line .q { color: var(--muted); font-size: 14px; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; margin-bottom: 14px; color: var(--muted); }
.kv b { color: var(--text); font-weight: 600; text-align: right; }

/* ---------- auth / setup ---------- */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 400px; }
.auth-logo { width: 84px; height: 84px; border-radius: 22px; margin: 0 auto 16px; box-shadow: var(--shadow); }
.auth h1 { text-align: center; }
.auth .sub { text-align: center; color: var(--muted); margin: 6px 0 24px; }
.auth .err { color: var(--danger); font-size: 15px; min-height: 20px; margin: 0 0 10px; }
.auth code { background: var(--card-2); padding: 2px 6px; border-radius: 6px; font-size: 14px; }

/* ---------- toast ---------- */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 26px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(20px); opacity: 0; pointer-events: none; z-index: 80;
  max-width: calc(100% - 32px); padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg); font-weight: 600; font-size: 15px; box-shadow: var(--shadow);
  transition: all .22s ease; text-align: center;
}
#toast.show { opacity: 1; transform: translateX(-50%); }
#toast.error { background: var(--danger); color: #fff; }
#toast.ok { background: var(--ok); color: #fff; }

@media (max-width: 380px) {
  .photo-row { grid-template-columns: 120px 1fr; }
  .photo-box, .photo-rm { width: 120px; }
  .photo-box { height: 120px; }
  .prow { grid-template-columns: 56px 1fr auto; gap: 12px; }
  .thumb { width: 56px; height: 56px; }
  .pstock b { font-size: 26px; }
  .kpis b { font-size: 17px; }
}
