:root {
  --bg: #f3f5f8;
  --bg-deep: #e7ebf0;
  --bg-raised: #ffffff;
  --panel: #ffffff;
  --line: #dde3ea;
  --line-strong: #c5ced8;
  --text: #122033;
  --muted: #5b6b7c;
  --saffron: #1f6feb;
  --saffron-deep: #1558c0;
  --gold: #3d8bfd;
  --maroon: #122033;
  --maroon-deep: #0b1726;
  --mint: #17803d;
  --danger: #c9372c;
  --nav: #0b1726;
  --nav-text: #d7e0ea;
  --accent: #1f6feb;
  --shadow: 0 12px 32px rgba(11, 23, 38, 0.08);
  --shadow-card: 0 1px 2px rgba(11, 23, 38, 0.06), 0 8px 20px rgba(11, 23, 38, 0.04);
  --radius: 10px;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --display: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100vh; }
body {
  font-family: var(--font);
  color: var(--text);
  background: var(--bg);
  letter-spacing: -0.01em;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
select {
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 28px;
}

.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
}

.nav {
  background: var(--nav);
  border-right: 1px solid #152536;
  padding: 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--nav-text);
  min-height: 100vh;
  overflow-y: auto;
}
.brand {
  display: flex;
  flex-direction: column;
  padding: 4px 10px 18px;
  margin-bottom: 8px;
  border-bottom: 1px solid #1e3348;
}
.brand-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  margin-bottom: 12px;
  padding: 4px;
  border: 1px solid var(--line);
}
.brand-mark {
  width: 36px;
  height: 36px;
  margin-bottom: 12px;
  border-radius: 8px;
  background: var(--accent);
  position: relative;
}
.brand-mark::after {
  content: "";
  position: absolute;
  inset: 10px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 3px;
}
.logo-preview {
  max-width: 180px;
  max-height: 120px;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  padding: 8px;
  margin: 0 20px 8px;
  border: 1px solid var(--line);
}
.brand strong {
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.25;
  color: #fff;
  text-transform: uppercase;
}
.brand span { color: #8ea0b3; font-size: 12px; word-break: break-word; margin-top: 6px; line-height: 1.4; }

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  padding: 4px 24px 16px;
}
.report-toolbar label { color: var(--muted); font-size: 11px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; display: grid; gap: 6px; }
.report-toolbar input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
.report-block { margin: 0 24px 28px; }
.report-block-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.report-block-head h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}
.report-block .table-wrap { padding: 0; }
.report-empty { color: var(--muted); padding: 8px 0; }

.nav-btn {
  text-align: left;
  border: 0;
  background: transparent;
  color: #b7c4d2;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 500;
  font-size: 13.5px;
}
.nav-btn:hover { background: #152536; color: #fff; }
.nav-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.nav-foot { margin-top: auto; display: grid; gap: 8px; padding-top: 18px; }
.nav-foot .chip {
  background: #152536;
  border-color: #24384c;
  color: #8ea0b3;
}
.nav-foot .chip b { color: #fff; }

.btn-logout {
  width: 100%;
  border: 1px solid #2a425a;
  background: transparent;
  color: #d7e0ea;
  border-radius: 8px;
  padding: 9px 12px;
  font-weight: 600;
  font-size: 13px;
}
.btn-logout:hover { background: #152536; color: #fff; }
.session-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  z-index: 6;
  flex-wrap: wrap;
}
.session-support a { color: var(--accent); font-weight: 600; }
.session-bar span { color: var(--muted); font-size: 13px; font-weight: 500; }
.session-bar .btn-logout {
  width: auto;
  min-width: 96px;
  color: var(--text);
  background: #fff;
  border-color: var(--line-strong);
}

.stage { min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.view { display: block; padding: 0; min-height: 100vh; }
.view[hidden] { display: none; }
.view > h2 {
  margin: 24px 24px 6px;
  font-size: 22px;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: var(--text);
}
.lede { margin: 0 24px 18px; color: var(--muted); max-width: 68ch; line-height: 1.5; font-size: 14px; }
.view > .hint { margin: 0 24px 12px; }

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fff;
  position: sticky;
  top: 0;
  z-index: 5;
}
.search { flex: 1; display: flex; }
.search input, .select, .settings input, .settings select, .tender input, .report-toolbar input {
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
}
.search input:focus, .select:focus, .settings input:focus, .settings select:focus, .report-toolbar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.18);
}
.search input { width: 100%; }
.select { min-width: 168px; background-color: #fff; }
.pack-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 8px; }
.chip {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}
.chip b { color: var(--text); font-weight: 650; }
.btn {
  border: 1px solid var(--line-strong);
  background: #fff;
  color: var(--text);
  border-radius: 8px;
  padding: 9px 14px;
  font-weight: 600;
  font-size: 13.5px;
}
.btn:hover { background: #f7f9fb; }
.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn.primary:hover { background: var(--saffron-deep); }
.btn.ghost { background: transparent; }
.btn.danger {
  background: #fff;
  border-color: #e7b4af;
  color: var(--danger);
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
a.btn { text-decoration: none; display: inline-block; }

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(320px, 0.9fr);
  min-height: calc(100vh - 68px);
}

.catalog {
  padding: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(176px, 1fr));
  gap: 12px;
  align-content: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  text-align: left;
  color: inherit;
  box-shadow: var(--shadow-card);
  min-height: 132px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.card::before { display: none; }
.card:hover { border-color: #b9c7d6; }
.card .sku { color: var(--muted); font-size: 11px; letter-spacing: 0.08em; text-transform: uppercase; }
.card .name { font-weight: 650; font-size: 14.5px; line-height: 1.3; }
.card .meta { display: flex; justify-content: space-between; color: var(--muted); font-size: 13px; margin-top: auto; }
.stock.ok { color: var(--mint); font-weight: 650; }
.stock.low { color: #b45309; font-weight: 650; }
.stock.out { color: var(--danger); font-weight: 650; }

.ticket {
  border-left: 1px solid var(--line);
  background: #fff;
  display: grid;
  grid-template-rows: auto auto auto 1fr auto auto;
  min-height: 0;
}
.ticket h2 {
  margin: 0;
  padding: 16px 16px 4px;
  font-size: 16px;
  font-weight: 650;
  color: var(--text);
}
.lines { overflow: auto; padding: 0 10px 8px; max-height: 50vh; }
.line {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 10px 8px;
  border-bottom: 1px solid var(--line);
}
.line .who { font-weight: 600; }
.line .pack { color: var(--muted); font-size: 12px; }
.qty { display: flex; align-items: center; gap: 6px; }
.qty button {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  font-weight: 700;
}
.totals {
  padding: 14px 16px;
  border-top: 1px solid var(--line);
  display: grid;
  gap: 6px;
  font-size: 13.5px;
  background: #f8fafc;
}
.totals div { display: flex; justify-content: space-between; color: var(--muted); }
.totals .grand { font-size: 20px; font-weight: 700; color: var(--text); font-variant-numeric: tabular-nums; }
.totals .grand span:last-child { color: var(--accent); }
.pay { padding: 12px 16px 18px; display: grid; gap: 8px; }
.pay-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.pay-row .btn { width: 100%; }
.tender { display: flex; gap: 8px; }
.hint { color: var(--muted); font-size: 12px; min-height: 16px; }
.hint.error { color: var(--danger); }
.hint.ok { color: var(--mint); }

.table-wrap { padding: 0 24px 28px; overflow-x: auto; }
table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); font-size: 13.5px; }
th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  background: #f8fafc;
}
tr:last-child td { border-bottom: 0; }
tr:hover td { background: #f8fafc; }
.split {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(260px, 0.8fr);
  gap: 16px;
  padding: 0 24px 28px;
}
.pane {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  min-height: 200px;
}
.report-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(188px, 1fr));
  gap: 12px;
  padding: 0 24px 24px;
}
.report-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}
.report-card span {
  color: var(--muted);
  display: block;
  font-size: 11px;
  font-weight: 650;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.report-card strong {
  font-size: 22px;
  color: var(--text);
  font-weight: 650;
  font-variant-numeric: tabular-nums;
}
.settings {
  display: grid;
  gap: 12px;
  max-width: 460px;
  margin: 0 24px 16px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.settings label { display: grid; gap: 6px; color: var(--muted); font-size: 12px; font-weight: 650; letter-spacing: 0.03em; }
.settings.wide {
  max-width: 960px;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  align-items: end;
}
.settings.wide.biz-create {
  grid-template-columns: 1fr;
  align-items: stretch;
  max-width: 960px;
}
.settings.wide.biz-create h3 {
  margin: 0 0 4px;
  font-size: 16px;
}
.settings.wide.biz-create .signup-grid {
  margin: 0;
}
.settings textarea,
.signup-grid select,
.signup-grid textarea {
  font: inherit;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
}
.settings.wide button { margin-top: 8px; }
.pack-compose {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
}
.pack-compose label {
  display: flex;
  gap: 10px;
  align-items: center;
  color: var(--text);
  background: var(--bg);
  border-radius: 8px;
  padding: 8px 10px;
}
.pack-compose input[type="number"] { width: 110px; }
.ticket-pack {
  padding: 0 16px 10px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 650;
}
.print-actions { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }

@media print {
  body { background: #fff; color: #111; }
  .nav, .topbar, .hint, .pay, .qty button, .nav-btn, .session-bar { display: none !important; }
  .app { display: block; }
  .view[hidden] { display: none !important; }
  .receipt { background: #fff; color: #111; max-height: none; }
}

.lock, .modal {
  position: fixed;
  inset: 0;
  background: rgba(11, 23, 38, 0.48);
  display: grid;
  place-items: center;
  z-index: 20;
}
.lock[hidden], .modal[hidden] { display: none; }
.dialog {
  width: min(520px, calc(100% - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
}
.dialog h3 { margin: 0 0 8px; color: var(--text); }
.dialog p { color: var(--muted); }
.pin { display: flex; gap: 8px; margin: 16px 0; }
#btn-demo-pin { width: 100%; }
.pin input {
  flex: 1;
  padding: 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--text);
  letter-spacing: 0.4em;
  text-align: center;
}
.receipt {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  background: #f8fafc;
  color: #122033;
  padding: 16px;
  border-radius: 8px;
  max-height: 480px;
  overflow: auto;
  border: 1px solid var(--line);
}
.held-item, .order-item {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  width: 100%;
  margin-bottom: 8px;
}

@media (max-width: 980px) {
  .app { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid #152536; min-height: 0; }
  .nav-foot { flex-direction: row; margin-top: 0; display: flex; flex-wrap: wrap; width: 100%; }
  .nav-foot .btn-logout { width: auto; flex: 1; min-height: 44px; }
  .session-bar .btn-logout { min-height: 44px; }
  .workspace, .split { grid-template-columns: 1fr; }
  .ticket { border-left: 0; border-top: 1px solid var(--line); }
  .view { min-height: 0; }
  .brand { width: 100%; border-bottom: 0; }
}
