:root {
  --ink: #142033;
  --paper: #f4f1ea;
  --card: #fffdf8;
  --line: #d9d1c3;
  --accent: #b45309;
  --accent-ink: #fff;
  --ok: #166534;
  --bad: #9f1239;
  --muted: #5c6b7a;
}
* { box-sizing: border-box; }
body { margin: 0; font: 16px/1.5 "Segoe UI", sans-serif; color: var(--ink); background: var(--paper); }
a { color: var(--accent); }
.topbar, .sidebar a, button, .btn { font: inherit; }
.guest { max-width: 1080px; margin: 0 auto; padding: 24px; }
.hero { display: grid; grid-template-columns: 1.3fr .7fr; gap: 24px; align-items: center; }
.card, .panel { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.nav { display: flex; justify-content: space-between; align-items: center; margin-bottom: 28px; }
.brand { font-weight: 750; letter-spacing: .04em; }
.btn, button {
  background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 999px; padding: 10px 16px; cursor: pointer; text-decoration: none; display: inline-block;
}
.btn.secondary, button.secondary { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.shell { display: grid; grid-template-columns: 230px 1fr; min-height: 100vh; }
.sidebar { background: var(--ink); color: #fff; padding: 18px 12px; }
.sidebar a { display: block; color: #fff; text-decoration: none; padding: 8px 10px; border-radius: 8px; }
.sidebar a:hover { background: #24344d; }
.sidebar button.secondary { color: #fff; border-color: rgba(255,255,255,.55); }
.main { padding: 20px; overflow-x: auto; }
label { display: block; font-size: 13px; margin: 10px 0 4px; color: var(--muted); }
input, select, textarea { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
input[type="checkbox"] { width: auto; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.stat strong { display: block; font-size: 22px; }
table { width: 100%; border-collapse: collapse; background: var(--card); }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.flash { padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
.flash.ok { background: #dcfce7; color: var(--ok); }
.flash.error { background: #ffe4e6; color: var(--bad); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.split { display: grid; grid-template-columns: 1.2fr .8fr; gap: 16px; }
.search-hit { border-bottom: 1px solid var(--line); padding: 12px 4px; cursor: pointer; min-height: 44px; }
.pos-cart { overflow-x: auto; }
.quick-add { margin-top: 16px; }
.quick-add summary { font-weight: 700; font-size: 18px; cursor: pointer; }
.quick-tabs { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.quick-tabs button { min-height: 44px; }
.quick-tabs button.is-on { background: var(--ink); color: #fff; border-color: var(--ink); }
.quick-panel { display: none; }
.quick-panel.active { display: block; }
.quick-status { min-height: 1.4em; margin: 0 0 8px; }
.quick-status.ok { color: var(--ok); }
.quick-status.error { color: var(--bad); }
.bill-status { min-height: 1.4em; }
.pos-tabs { margin: 0 0 12px; }
.pos-section[hidden] { display: none !important; }
.manage-table { margin-top: 12px; }
.row-actions { white-space: nowrap; }
.row-actions button { padding: 6px 10px; min-height: 36px; margin: 0 4px 4px 0; }
.menu-toggle { display: none; }
@media (max-width: 860px) {
  .hero, .shell, .split { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .sidebar.open { display: block; }
  .menu-toggle { display: inline-block; }
}
@media print {
  .sidebar, .topbar, .menu-toggle, .flash, .no-print { display: none !important; }
  .shell { display: block; }
  body { background: #fff; }
  .main { padding: 0; }
}
td.row-actions { white-space: normal; }
.product-qr-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.product-qr-actions a { padding: 6px 10px; min-height: 36px; }
.qr-sheet { display: flex; flex-wrap: wrap; align-content: flex-start; column-gap: 0; row-gap: 1mm; width: 200mm; }
.qr-sheet .qr-label-sheet { flex: 0 0 25mm; min-width: 25mm; max-width: 25mm; }
.qr-label-sheet { width: 25mm; height: 25mm; box-sizing: border-box; overflow: hidden; display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 0.8mm 0.6mm 0; text-align: center; page-break-inside: avoid; break-inside: avoid; }
.qr-label-sheet svg { width: 15mm; height: 15mm; flex: 0 0 15mm; display: block; }
.qr-label-sheet p { margin: 0; max-width: 23mm; overflow: hidden; font-size: 5pt; line-height: 1.05; white-space: nowrap; text-overflow: ellipsis; }
.qr-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.qr-toolbar button { width: auto; }
input.qr-copies { width: 5.5rem; max-width: 5.5rem; padding: 6px 8px; }
@media print {
  .qr-sheet { column-gap: 0; row-gap: 1mm; width: 200mm; }
  .qr-label-sheet { width: 25mm !important; height: 25mm !important; border: 0; }
  .qr-label-sheet svg { width: 15mm !important; height: 15mm !important; }
}
.qr-sheet .qr-label-row { display: contents; }
.qr-sheet-4in { display: block; width: 100mm; margin: 0 auto; }
.qr-sheet-4in .qr-label-row { display: flex; flex-direction: row; flex-wrap: nowrap; align-items: flex-start; width: 100mm; height: 25mm; margin: 0 0 1mm; overflow: hidden; }
.qr-sheet-4in .qr-label-sheet { width: 25mm; height: 25mm; flex: 0 0 25mm; min-width: 25mm; max-width: 25mm; max-height: 25mm; min-height: 0; margin: 0; overflow: hidden; }
.qr-sheet-4in .qr-label-sheet svg { width: 15mm; height: 15mm; max-width: 15mm; max-height: 15mm; min-width: 0; }
@media print {
  .qr-sheet-4in { display: block !important; width: 100mm !important; margin: 0 !important; }
  .qr-sheet-4in .qr-label-row { display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important; width: 100mm !important; height: 25mm !important; margin: 0 0 1mm !important; overflow: hidden !important; }
  .qr-sheet-4in .qr-label-sheet { width: 25mm !important; height: 25mm !important; flex: 0 0 25mm !important; min-width: 25mm !important; max-width: 25mm !important; max-height: 25mm !important; overflow: hidden !important; }
  .qr-sheet-4in .qr-label-sheet svg { width: 15mm !important; height: 15mm !important; max-width: 15mm !important; max-height: 15mm !important; }
}
.qr-scan-dialog[hidden] { display: none !important; }
.qr-scan-dialog { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; padding: 12px; background: rgba(20, 32, 51, .72); }
.qr-scan-panel { width: min(520px, 100%); max-height: calc(100vh - 24px); overflow: auto; background: var(--card); border-radius: 16px; padding: 16px; }
.qr-scan-stage { position: relative; background: #111; border-radius: 12px; overflow: hidden; aspect-ratio: 3 / 4; max-height: 52vh; }
.qr-scan-stage video { width: 100%; height: 100%; object-fit: cover; background: #111; }
.qr-scan-frame { position: absolute; inset: 14% 12%; border: 3px solid #fff; border-radius: 12px; box-shadow: 0 0 0 999px rgba(0, 0, 0, .35); pointer-events: none; }
@media (min-width: 800px) {
  .qr-scan-dialog { align-items: center; }
}
.sidebar a.sub { padding-left: 22px; }
.legal-toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.legal-toolbar button { width: auto; }
.legal-editor { min-height: 480px; max-height: 70vh; overflow: auto; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.legal-editor h2, .legal-editor h3 { margin: 1em 0 .4em; }
.legal-status { display: flex; flex-wrap: wrap; gap: 8px 18px; }
.legal-status p { margin: 0 0 12px; }
.legal-banner { background: #fff4d6; border: 1px solid #e2c56a; padding: 10px 12px; border-radius: 8px; margin-bottom: 12px; }
