/* ==========================================================
   BRIIVO Cloud Sales — Live demo (demo.html)
   Builds on style.css tokens
   ========================================================== */
.demo-page { --top-h: 64px; background: var(--bg); }

.demo-top {
  position: sticky; top: 0; z-index: 60;
  display: flex; align-items: center; gap: 14px;
  height: var(--top-h);
  padding: 0 18px;
  background: var(--header-bg);
  border-bottom: 1px solid var(--line);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  backdrop-filter: saturate(160%) blur(14px);
}
.demo-top .brand-mark { height: 34px; }
.demo-top .brand-word { height: 15px; }
.env-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--line-gold);
  background: var(--gold-soft); color: var(--gold-ink);
  font: 700 12.5px/1 var(--head); letter-spacing: 0.04em; white-space: nowrap;
}
.env-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.demo-top-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
@media (max-width: 720px) {
  .hide-sm { display: none; }
  .demo-top { gap: 10px; padding: 0 12px; }
  .demo-top .brand-word { display: none; }
  .demo-top .btn-sm { padding: 8px 11px; }
}

.demo-banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 10px 18px;
  background: var(--warn-bg);
  border-bottom: 1px solid var(--line);
  color: var(--text); font-size: 13.5px; line-height: 1.5;
}
.demo-banner .ico { color: var(--gold-ink); margin-top: 2px; }

.app { display: grid; grid-template-columns: 236px minmax(0, 1fr); min-height: calc(100vh - var(--top-h)); }
.app-nav {
  position: sticky; top: var(--top-h);
  align-self: start;
  height: calc(100vh - var(--top-h));
  display: flex; flex-direction: column; gap: 2px;
  padding: 16px 12px;
  border-right: 1px solid var(--line);
  background: var(--surface-2);
  overflow-y: auto;
}
.biz-card { display: flex; gap: 10px; align-items: center; padding: 6px 8px 16px; margin-bottom: 6px; border-bottom: 1px solid var(--line); }
.biz-ava { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 11px; background: var(--gold-grad); color: var(--on-gold); font: 800 13px/1 var(--head); }
.biz-card b { display: block; font: 700 14.5px/1.2 var(--head); }
.biz-card small { color: var(--muted); font-size: 12px; }
.app-nav > a {
  display: flex; align-items: center; gap: 11px;
  min-height: 42px; padding: 9px 12px;
  border-radius: 11px;
  color: var(--text-2); font: 600 14.5px/1.2 var(--head);
  transition: background-color 0.2s, color 0.2s;
}
.app-nav > a .ico { width: 19px; height: 19px; }
.app-nav > a:hover { background: var(--surface-3); color: var(--text); }
.app-nav > a.on { background: var(--gold-soft); color: var(--text); box-shadow: inset 3px 0 0 var(--gold); }
.app-nav > a.on .ico { color: var(--gold-ink); }
.nav-foot { margin-top: auto; padding: 14px 8px 4px; display: grid; gap: 8px; border-top: 1px solid var(--line); }
.nav-foot p { color: var(--muted); font-size: 13px; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .app-nav {
    position: sticky; top: var(--top-h); z-index: 50;
    height: auto; flex-direction: row; gap: 4px;
    padding: 8px 10px;
    border-right: 0; border-bottom: 1px solid var(--line);
    background: var(--header-bg);
    -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
    overflow-x: auto; overflow-y: hidden;
    scrollbar-width: none;
  }
  .app-nav::-webkit-scrollbar { display: none; }
  .app-nav > a { flex-shrink: 0; min-height: 40px; padding: 8px 12px; font-size: 14px; }
  .app-nav > a.on { box-shadow: inset 0 -2px 0 var(--gold); }
  .biz-card, .nav-foot { display: none; }
}

.view { padding: clamp(16px, 3vw, 32px); min-width: 0; outline: none; }
.view-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; margin-bottom: 22px; }
.view-head h1 { font-size: clamp(24px, 3vw, 30px); letter-spacing: -0.02em; line-height: 1.15; }
.view-head p { color: var(--muted); font-size: 14px; margin-top: 4px; }
.view-head .btn-row { gap: 8px; }

/* Panels */
.panel {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  min-width: 0;
}
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 0; }
.panel-head h2 { font-size: 16px; letter-spacing: -0.01em; }
.panel-head a, .panel-head button.linkish { color: var(--gold-ink); font: 700 13px/1 var(--head); background: none; border: 0; padding: 6px 0; }
.panel-body { padding: 14px 18px 18px; }
.cols { display: grid; gap: 16px; }
@media (min-width: 1100px) { .cols-2 { grid-template-columns: 1.4fr 1fr; } .cols-2e { grid-template-columns: 1fr 1fr; } }
@media (min-width: 760px) and (max-width: 1099px) { .cols-2e { grid-template-columns: 1fr 1fr; } }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 14px; margin-bottom: 16px; }
.stat { padding: 16px 18px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow-sm); }
.stat small { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 13px; font-weight: 500; }
.stat small .ico { color: var(--gold-ink); width: 16px; height: 16px; }
.stat b { display: block; margin-top: 6px; font: 800 clamp(19px, 2.2vw, 24px)/1.15 var(--head); letter-spacing: -0.01em; }
.stat span { display: block; margin-top: 4px; color: var(--muted); font-size: 12.5px; }

/* Chart */
.chart { width: 100%; height: 220px; }
.chart .bar { fill: url(#goldGrad); }
.chart .bar.dim { opacity: 0.55; }
.chart .axis { fill: var(--muted); font: 500 11px var(--body); }
.chart .val { fill: var(--text-2); font: 700 10.5px var(--head); }
.chart .gridline { stroke: var(--line); }
.hbars { display: grid; gap: 12px; }
.hbar { display: grid; gap: 5px; }
.hbar-top { display: flex; justify-content: space-between; gap: 10px; font-size: 13.5px; }
.hbar-top span { color: var(--muted); }
.hbar-track { height: 8px; border-radius: 6px; background: var(--surface-3); overflow: hidden; }
.hbar-fill { height: 100%; border-radius: 6px; background: var(--gold-grad); transition: width 0.6s var(--ease); }

/* Tables */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th {
  padding: 10px 12px; text-align: left; white-space: nowrap;
  color: var(--muted); font: 600 12px/1.2 var(--head); letter-spacing: 0.06em; text-transform: uppercase;
  border-bottom: 1px solid var(--line);
}
table.data td { padding: 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.data tr:last-child td { border-bottom: 0; }
table.data tbody tr { transition: background-color 0.15s; }
table.data tbody tr.clickable { cursor: pointer; }
table.data tbody tr.clickable:hover { background: var(--surface-2); }
table.data .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
table.data .strong { font-weight: 600; }
table.data .sub { display: block; color: var(--muted); font-size: 12.5px; }
.row-btn {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 34px; padding: 6px 12px;
  border: 1px solid var(--line-strong); border-radius: 9px;
  background: var(--surface); color: var(--text);
  font: 600 13px/1 var(--head); white-space: nowrap;
}
.row-btn:hover { border-color: var(--gold); color: var(--gold-ink); }

/* Mobile list rows instead of wide tables */
@media (max-width: 640px) {
  table.data.stack thead { display: none; }
  table.data.stack, table.data.stack tbody, table.data.stack tr, table.data.stack td { display: block; width: 100%; }
  table.data.stack tr { padding: 12px 4px; border-bottom: 1px solid var(--line); }
  table.data.stack tr:last-child { border-bottom: 0; }
  table.data.stack td { padding: 3px 4px; border: 0; text-align: left; }
  table.data.stack td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 12.5px; }
  table.data.stack td.num { text-align: left; }
}

/* Toolbar */
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 14px; }
.search {
  position: relative; flex: 1; min-width: 200px;
}
.search input {
  width: 100%; min-height: 44px; padding: 10px 14px 10px 40px;
  border: 1px solid var(--line-strong); border-radius: 12px;
  background: var(--surface); color: var(--text); font-size: 16px;
}
.search input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 4px var(--gold-soft); }
.search svg { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); color: var(--muted); }
.chips { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex-shrink: 0;
  min-height: 36px; padding: 7px 13px;
  border: 1px solid var(--line-strong); border-radius: 999px;
  background: var(--surface); color: var(--text-2);
  font: 600 13px/1 var(--head);
}
.chip[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); color: var(--text); }

/* POS */
.pos { display: grid; gap: 16px; align-items: start; }
.pos > *, .cols > *, .view > * { min-width: 0; }
.demo-page { overflow-x: hidden; }
@media (min-width: 1100px) { .pos { grid-template-columns: minmax(0, 1fr) 380px; } }
.prod-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.prod {
  position: relative;
  display: grid; gap: 4px; align-content: start;
  min-height: 112px; padding: 13px;
  border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface);
  text-align: left; color: var(--text);
  transition: border-color 0.2s, transform 0.2s var(--ease), box-shadow 0.2s;
}
.prod:hover:not(:disabled) { border-color: var(--gold); transform: translateY(-2px); box-shadow: var(--shadow-sm); }
.prod:active:not(:disabled) { transform: scale(0.98); }
.prod:disabled { opacity: 0.55; cursor: not-allowed; }
.prod .p-cat { color: var(--muted); font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; }
.prod .p-name { font: 700 14px/1.3 var(--head); }
.prod .p-price { margin-top: auto; font: 800 15px/1.2 var(--head); color: var(--gold-ink); }
.prod .p-stock { font-size: 12px; color: var(--muted); }
.prod .p-stock.low { color: var(--warn); font-weight: 600; }
.prod .p-stock.out { color: var(--bad); font-weight: 600; }
.prod .in-cart {
  position: absolute; top: 9px; right: 9px;
  display: grid; place-items: center; min-width: 24px; height: 24px; padding: 0 7px; border-radius: 999px;
  background: var(--gold-grad); color: var(--on-gold); font: 800 12px/1 var(--head);
}
.cart { position: sticky; top: calc(var(--top-h) + 16px); }
@media (max-width: 1099px) { .cart { position: static; } }
.cart-lines { display: grid; gap: 2px; max-height: 340px; overflow-y: auto; margin: 0 -6px; padding: 0 6px; }
.cart-line { display: grid; grid-template-columns: 1fr auto; gap: 6px 10px; padding: 10px 0; border-bottom: 1px dashed var(--line-strong); }
.cart-line .cl-name { font: 600 14px/1.3 var(--head); }
.cart-line .cl-unit { color: var(--muted); font-size: 12.5px; }
.cart-line .cl-total { font: 700 14px/1.3 var(--head); text-align: right; font-variant-numeric: tabular-nums; }
.qty { display: inline-flex; align-items: center; border: 1px solid var(--line-strong); border-radius: 10px; overflow: hidden; }
.qty button { width: 34px; height: 34px; border: 0; background: var(--surface-2); color: var(--text); font: 700 16px/1 var(--head); }
.qty button:hover { background: var(--gold-soft); }
.qty input { width: 46px; height: 34px; border: 0; border-left: 1px solid var(--line); border-right: 1px solid var(--line); background: var(--surface); color: var(--text); text-align: center; font: 600 15px/1 var(--head); -moz-appearance: textfield; appearance: textfield; }
.qty input::-webkit-outer-spin-button, .qty input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.cl-remove { justify-self: end; border: 0; background: none; color: var(--muted); font-size: 12.5px; text-decoration: underline; padding: 6px 0; }
.cl-remove:hover { color: var(--bad); }
.cart-empty { padding: 26px 8px; text-align: center; color: var(--muted); font-size: 14px; }
.cart-empty .ico { width: 34px; height: 34px; margin: 0 auto 10px; color: var(--gold-ink); opacity: 0.7; }
.totals { display: grid; gap: 7px; margin-top: 14px; font-size: 14px; }
.totals div { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.totals span { color: var(--muted); }
.totals .grand { padding-top: 10px; margin-top: 4px; border-top: 1px solid var(--line-strong); font: 800 20px/1.2 var(--head); }
.totals .grand span { color: var(--text); }
.mini-field { display: grid; gap: 6px; margin-top: 12px; }
.mini-field label, .mini-field .label { font: 600 13px/1.2 var(--head); color: var(--text-2); }
.mini-field select, .mini-field input {
  width: 100%; min-height: 42px; padding: 8px 12px;
  border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font-size: 16px;
}
.mini-field select:focus, .mini-field input:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px var(--gold-soft); }
.pay-seg { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.pay-seg button {
  min-height: 40px; border: 1px solid var(--line-strong); border-radius: 10px;
  background: var(--surface-2); color: var(--text); font: 600 13.5px/1 var(--head);
}
.pay-seg button[aria-pressed="true"] { border-color: var(--gold); background: var(--gold-soft); box-shadow: inset 0 0 0 1px var(--gold); }
.cart-msg { margin-top: 10px; color: var(--bad); font-size: 13px; font-weight: 600; }
.cart-actions { display: grid; grid-template-columns: auto 1fr; gap: 8px; margin-top: 16px; }
.mobile-cart-bar {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom)); z-index: 40;
  display: none; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 10px 10px 16px;
  border: 1px solid var(--line-gold); border-radius: 16px;
  background: var(--surface); box-shadow: var(--shadow-lg);
  font: 700 14.5px/1.2 var(--head);
}
@media (max-width: 1099px) { .mobile-cart-bar.show { display: flex; } }

/* Status pills reuse .pill from style.css */
.pill { font-size: 11.5px; }

/* Empty state */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty h1 { font-size: 22px; color: var(--text); margin-bottom: 8px; }
.empty a { color: var(--gold-ink); text-decoration: underline; }

/* Modal */
.modal {
  width: min(560px, calc(100% - 24px));
  max-height: calc(100% - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow-lg);
  overflow: auto;
}
.modal.wide { width: min(720px, calc(100% - 24px)); }
.modal::backdrop { background: rgba(10, 8, 4, 0.55); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-inner { padding: clamp(18px, 3vw, 28px); }
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-head h2 { font-size: 20px; letter-spacing: -0.01em; }
.modal-head p { color: var(--muted); font-size: 13.5px; margin-top: 4px; }
.modal-close {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font-size: 20px; line-height: 1;
}
.modal-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 20px; }
.modal .fields { margin-top: 4px; }

/* Invoice document */
.invoice-doc { border: 1px solid var(--line); border-radius: 14px; padding: 20px; background: var(--surface-2); font-size: 13.5px; }
.inv-top { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; padding-bottom: 14px; border-bottom: 1px solid var(--line-strong); }
.inv-top b { font: 800 16px/1.2 var(--head); }
.inv-top .sample { color: var(--gold-ink); font: 700 11px/1 var(--head); letter-spacing: 0.1em; text-transform: uppercase; }
.inv-meta { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px 16px; padding: 14px 0; border-bottom: 1px solid var(--line); }
.inv-meta small { display: block; color: var(--muted); font-size: 11.5px; text-transform: uppercase; letter-spacing: 0.06em; }
.invoice-doc table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.invoice-doc th { text-align: left; color: var(--muted); font: 600 11.5px/1.2 var(--head); text-transform: uppercase; letter-spacing: 0.05em; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.invoice-doc td { padding: 8px 4px; border-bottom: 1px dashed var(--line); }
.invoice-doc .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.inv-totals { display: grid; gap: 5px; margin-top: 12px; margin-left: auto; max-width: 260px; }
.inv-totals div { display: flex; justify-content: space-between; gap: 10px; font-variant-numeric: tabular-nums; }
.inv-totals span { color: var(--muted); }
.inv-totals .grand { padding-top: 8px; border-top: 1px solid var(--line-strong); font: 800 16px/1.2 var(--head); }
.inv-foot { margin-top: 16px; color: var(--muted); font-size: 12px; text-align: center; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); z-index: 300;
  max-width: calc(100% - 32px);
  padding: 12px 18px; border-radius: 14px;
  background: var(--text); color: var(--bg);
  font: 600 14px/1.35 var(--head);
  box-shadow: var(--shadow-lg);
  transform: translate(-50%, 160%); opacity: 0;
  transition: transform 0.35s var(--ease), opacity 0.25s;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

.demo-page .wa-float { display: none; }

@media print {
  .demo-page .demo-top, .demo-page .demo-banner, .demo-page .app, .demo-page .toast, .modal-actions, .modal-head .modal-close { display: none !important; }
  .modal { position: static; box-shadow: none; border: 0; width: 100%; max-height: none; }
  .modal::backdrop { display: none; }
  .invoice-doc { border: 0; background: #fff; color: #000; }
}
