/* Venddra - clean retail look: navy ink, white cards, and the two blues from the Venddra logo */
:root {
  --ink: #0c1b3a;
  --ink-2: #0743bb;
  --muted: #5a6b8c;
  --line: #d9e1f0;
  --bg: #f3f6fc;
  --card: #ffffff;
  --brand: #0743bb;
  --brand-dark: #05328c;
  --brand-soft: #e3edff;
  --accent: #0070f8;
  --ok: #1b7f4f;
  --ok-soft: #dff1e7;
  --warn: #9a6200;
  --warn-soft: #fbedc9;
  --bad: #b42318;
  --bad-soft: #fbe0dc;
  --radius: 10px;
  --nav-h: 62px;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--ink);
  font-size: 16px;
  line-height: 1.45;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); }
body { min-height: 100vh; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.2; font-weight: 650; letter-spacing: -0.01em; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.05rem; }
p { margin: 0 0 .6rem; }
a { color: var(--brand); }
a:hover { color: var(--accent); }
.num, td.n, th.n { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.hidden { display: none !important; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* ---------- buttons & fields ---------- */
button { cursor: pointer; }
.btn, button.primary, button.ghost, button.danger {
  min-height: 44px; padding: 0 16px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); font-weight: 600;
}
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.ghost:hover { background: var(--brand-soft); }
button.danger { color: var(--bad); border-color: #e9b8b2; }
button.danger:hover { background: var(--bad-soft); }
button.big { width: 100%; min-height: 52px; font-size: 1.05rem; }
button.sm { min-height: 34px; padding: 0 10px; font-size: .88rem; }
button:disabled { opacity: .55; cursor: not-allowed; }
input, select, textarea {
  width: 100%; min-height: 44px; padding: 8px 12px; border: 1px solid #b8c6e0; border-radius: 8px; background: #fff;
}
input[type=checkbox] { width: 20px; min-height: 20px; height: 20px; }
label { display: block; font-weight: 600; font-size: .9rem; margin: 0 0 4px; }
.field { margin-bottom: 12px; }
.row { display: flex; gap: 10px; align-items: end; flex-wrap: wrap; }
.row > .field { flex: 1 1 140px; margin-bottom: 0; }

/* ---------- auth ---------- */
.auth { max-width: 420px; margin: 0 auto; padding: 8vh 20px 40px; }
.auth h1 { font-size: 2rem; margin-bottom: 4px; }
.auth .card { margin-top: 24px; }
.auth .logo { display: block; width: min(300px, 80%); height: auto; margin: 0 0 18px; }
.auth h1 { color: var(--brand); }

/* ---------- shell ---------- */
.shell { min-height: 100vh; }
.top {
  position: sticky; top: 0; z-index: 20; background: #fff; color: var(--ink); border-bottom: 1px solid var(--line);
  display: flex; gap: 8px; align-items: center; padding: 8px 12px; min-height: 56px;
}
.top .brand { margin-right: auto; display: flex; align-items: center; flex: 0 0 auto; }
.top .brand img { display: block; height: 38px; width: auto; }
.top .brand .logo-full { display: none; }
.top select { background: #fff; border-color: var(--line); color: var(--ink); min-height: 40px; min-width: 0; max-width: 40vw; }
.top button { white-space: nowrap; min-height: 40px; padding: 0 14px; border: 1px solid var(--line); border-radius: 8px; font-weight: 600; background: transparent; color: var(--brand); }
.top button:hover { background: var(--brand-soft); }
.nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 30; background: #fff; border-top: 1px solid var(--line);
  display: flex; overflow-x: auto; height: var(--nav-h);
}
.nav button {
  flex: 1 0 74px; border: 0; background: transparent; padding: 6px 4px; font-size: .74rem; font-weight: 600; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; border-top: 3px solid transparent;
}
.nav button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav button[aria-current=page] { color: var(--brand-dark); border-top-color: var(--accent); background: var(--brand-soft); }
main#view { padding: 14px 12px calc(var(--nav-h) + 24px); max-width: 1180px; margin: 0 auto; min-width: 0; }
.page-head { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; margin-bottom: 14px; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 210px minmax(0, 1fr); grid-template-rows: auto 1fr; }
  .top { grid-column: 1 / -1; }
  .top .brand .logo-full { display: block; }
  .top .brand .logo-icon { display: none; }
  .nav {
    position: sticky; top: 56px; align-self: start; height: calc(100vh - 56px); flex-direction: column; overflow: visible;
    border-top: 0; border-right: 1px solid var(--line); padding: 10px 8px;
  }
  .nav button { flex: 0 0 auto; flex-direction: row; justify-content: flex-start; gap: 10px; padding: 10px 12px; font-size: .95rem;
    border-top: 0; border-left: 3px solid transparent; border-radius: 6px; }
  .nav button[aria-current=page] { border-left-color: var(--accent); }
  main#view { padding: 22px 26px 60px; width: 100%; }
}

/* ---------- cards, tables ---------- */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card + .card { margin-top: 14px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 10px; margin-bottom: 14px; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.stat .v { font-size: 1.45rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat { min-width: 0; }
.stat .l { color: var(--muted); font-size: .85rem; }
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fff; }
table { width: 100%; border-collapse: collapse; font-size: .93rem; }
th, td { padding: 9px 12px; border-bottom: 1px solid #e6ecf7; text-align: left; vertical-align: middle; }
th { font-size: .82rem; color: var(--muted); font-weight: 650; background: #f7f9fe; position: sticky; top: 0; }
tr:last-child td { border-bottom: 0; }
tfoot td { font-weight: 700; background: #f7f9fe; }
.badge { display: inline-block; padding: 2px 9px; border-radius: 99px; font-size: .78rem; font-weight: 700; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.mute { background: #e6ecf7; color: var(--muted); }
.tabs { display: inline-flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.tabs button { border: 0; background: transparent; min-height: 40px; padding: 0 16px; font-weight: 600; color: var(--muted); }
.tabs button[aria-pressed=true] { background: var(--ink); color: #fff; }
.empty { text-align: center; padding: 34px 16px; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }
.notice { padding: 10px 14px; border-radius: 8px; background: var(--warn-soft); color: #5e3d00; margin-bottom: 14px; }

/* ---------- selling: tiles + till slip ---------- */
.sell { display: grid; gap: 14px; }
@media (min-width: 900px) { .sell { grid-template-columns: 1fr 380px; align-items: start; } .slip { position: sticky; top: 72px; } }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 10px; }
.tile {
  text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 10px; padding: 10px 12px; min-height: 74px;
  display: flex; flex-direction: column; gap: 2px;
}
.tile:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-soft); }
.tile b { font-size: .95rem; }
.tile .sub { font-size: .8rem; color: var(--muted); }
.tile .price { margin-top: auto; font-weight: 700; font-variant-numeric: tabular-nums; }
.slip {
  background: #fffef9; border: 1px solid #e4dfc9; padding: 16px 16px 26px; border-radius: 4px 4px 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .9rem;
  --zig: linear-gradient(135deg, #fffef9 50%, transparent 50%), linear-gradient(225deg, #fffef9 50%, transparent 50%);
  position: relative; margin-bottom: 12px;
}
.slip::after {
  content: ""; position: absolute; left: -1px; right: -1px; bottom: -9px; height: 10px;
  background: var(--zig); background-size: 14px 10px; background-repeat: repeat-x;
  border-left: 1px solid #e4dfc9; border-right: 1px solid #e4dfc9; filter: drop-shadow(0 1px 0 #e4dfc9);
}
.slip-head { display: flex; justify-content: space-between; gap: 8px; border-bottom: 1px dashed #b9b394; padding-bottom: 8px; margin-bottom: 8px; }
.slip-head span { color: var(--muted); }
.line { padding: 8px 0; border-bottom: 1px dashed #d8d3b8; }
.line .ln { display: flex; justify-content: space-between; gap: 8px; font-weight: 700; }
.line .ctrl { display: flex; gap: 6px; align-items: center; margin-top: 6px; }
.line input { min-height: 38px; padding: 4px 8px; font-family: inherit; }
.line .q { width: 72px; text-align: center; }
.line .p { flex: 1; min-width: 0; text-align: right; }
.line button { min-height: 38px; min-width: 38px; padding: 0; font-family: inherit; }
.line .warnq { color: var(--bad); font-size: .8rem; }
.slip-total { display: flex; justify-content: space-between; font-size: 1.25rem; font-weight: 700; padding: 12px 0; }
.slip .empty { padding: 18px 4px; font-family: system-ui, sans-serif; }

/* ---------- charts & insights ---------- */
.chart { width: 100%; height: auto; display: block; }
.chart .grid { stroke: #e5eaf5; stroke-width: 1; }
.chart .ax { fill: var(--muted); font-size: 11px; }
.chart .bar-rev { fill: var(--ink-2); }
.chart .bar-pro { fill: var(--accent); }
.legend { display: flex; gap: 16px; font-size: .85rem; color: var(--muted); margin-top: 6px; }
.legend i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.brandgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.brandcard h3 { display: flex; justify-content: space-between; gap: 8px; }
.winner { font-size: 1.15rem; font-weight: 700; margin: 8px 0 2px; }
.bars { margin-top: 10px; display: grid; gap: 6px; }
.bar { display: grid; grid-template-columns: 1fr auto; gap: 8px; font-size: .88rem; }
.bar .track { grid-column: 1 / -1; height: 8px; background: #e6ecf7; border-radius: 4px; overflow: hidden; }
.bar .track i { display: block; height: 100%; background: var(--brand); }
.bar.first .track i { background: var(--accent); }
.ordercard pre { white-space: pre-wrap; background: #f7f9fe; border: 1px solid var(--line); border-radius: 8px; padding: 10px; font-size: .85rem; margin: 8px 0; }

/* ---------- dialogs & toasts ---------- */
dialog.dlg { border: 0; border-radius: 12px; padding: 0; width: min(520px, calc(100vw - 24px)); max-height: 90vh; box-shadow: 0 20px 60px rgba(12, 27, 58, .35); }
dialog.dlg::backdrop { background: rgba(12, 27, 58, .5); }
dialog.dlg form { padding: 18px; }
dialog.dlg h3 { margin-bottom: 12px; }
dialog.dlg menu { display: flex; gap: 8px; justify-content: flex-end; padding: 0; margin: 14px 0 0; }
#toasts { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--nav-h) + 14px); z-index: 100; display: grid; gap: 8px; width: min(92vw, 460px); }
@media (min-width: 900px) { #toasts { bottom: 20px; } }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: 10px; box-shadow: 0 6px 24px rgba(0,0,0,.25); }
.toast.bad { background: var(--bad); }
.toast.ok { background: var(--ok); }
.spin { text-align: center; padding: 40px; color: var(--muted); }

/* ---------- receipts ---------- */
.rc { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .85rem; line-height: 1.35; color: #000; background: #fff; max-width: 80mm; margin: 0 auto; padding: 4px 2px; }
.rc-head { text-align: center; border-bottom: 1px dashed #000; padding-bottom: 8px; margin-bottom: 8px; }
.rc-shop { display: block; font-size: 1.15rem; }
.rc-meta { margin-top: 6px; }
.rc-lines { width: 100%; border-collapse: collapse; }
.rc-lines td { padding: 1px 0; vertical-align: top; border: 0; background: none; }
.rc-lines td.n { text-align: right; white-space: nowrap; padding-left: 8px; }
.rc-lines td.rc-name { font-weight: 700; padding-top: 6px; }
.rc-total { display: flex; justify-content: space-between; font-weight: 700; font-size: 1.05rem; border-top: 1px dashed #000; border-bottom: 1px dashed #000; padding: 6px 0; margin: 8px 0; }
.rc-foot { text-align: center; }
.rc-thanks { margin: 10px 0 2px; }
.rc-pow { margin: 0; font-size: .7rem; color: #555; }
dialog.rcdlg { padding: 18px; width: min(380px, calc(100vw - 24px)); }
dialog.rcdlg menu.rc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; justify-content: stretch; padding: 16px 0 0; margin: 0; list-style: none; }
.rc-actions button { width: 100%; }
#rcptPrint { display: none; }
.slip .field { margin: 10px 0 0; }
.slip .field label { font-family: system-ui, sans-serif; }
.slip #go { margin-top: 14px; }

@media print {
  body.print-receipt #app, body.print-receipt #toasts, body.print-receipt dialog { display: none !important; }
  body.print-receipt #rcptPrint { display: block !important; }
  .top, .nav, .noprint, #toasts { display: none !important; }
  .shell { display: block; }
  main#view { padding: 0; max-width: none; }
  body { background: #fff; }
}
@media (prefers-reduced-motion: no-preference) {
  .toast { animation: pop .18s ease-out; }
  @keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
}
