:root {
  --bg: #f6f2eb;
  --panel: #ffffff;
  --panel-soft: #fffaf2;
  --ink: #181818;
  --muted: #756f66;
  --line: #e8dece;
  --accent: #181818;
  --ok: #166534;
  --danger: #9f1239;
  --warning: #92400e;
  --radius: 22px;
  --shadow: 0 18px 60px rgba(24, 24, 24, 0.09);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
}

button, input, select, textarea {
  font: inherit;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 13px 16px;
  background: var(--accent);
  color: white;
  font-weight: 750;
  cursor: pointer;
}

button.secondary {
  background: var(--panel-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

button.danger {
  background: var(--danger);
}

button.ghost {
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--line);
}

button:disabled {
  opacity: .45;
  cursor: not-allowed;
}

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  background: white;
  border-radius: 16px;
  padding: 13px 14px;
  color: var(--ink);
  outline: none;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.center-card {
  width: min(440px, 100%);
  margin: 9vh auto;
  background: var(--panel);
  border-radius: 28px;
  padding: 28px;
  box-shadow: var(--shadow);
  border: 1px solid var(--line);
}

.brand-mark {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: var(--panel-soft);
  font-size: 30px;
  margin-bottom: 16px;
}

h1, h2, h3, p { margin-top: 0; }

h1 { font-size: clamp(30px, 8vw, 46px); line-height: .95; letter-spacing: -.05em; margin-bottom: 10px; }
h2 { font-size: 24px; letter-spacing: -.035em; margin-bottom: 12px; }
h3 { font-size: 17px; margin-bottom: 10px; }
p { color: var(--muted); line-height: 1.45; }

.login-form { display: grid; gap: 14px; margin-top: 22px; }
.login-help { font-size: 13px; background: var(--panel-soft); border: 1px solid var(--line); border-radius: 18px; padding: 12px; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  padding: 12px 0 14px;
  background: linear-gradient(to bottom, var(--bg) 75%, rgba(246,242,235,0));
}

.topbar-title strong { display: block; font-size: 18px; }
.topbar-title span { display: block; color: var(--muted); font-size: 13px; margin-top: 2px; }

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 4px 0 16px;
}

.tabs button {
  flex: 0 0 auto;
  background: white;
  color: var(--ink);
  border: 1px solid var(--line);
  padding: 10px 14px;
}

.tabs button.active {
  background: var(--ink);
  color: white;
}

.grid {
  display: grid;
  gap: 16px;
}

.grid.two {
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, .9fr);
  align-items: start;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: 0 8px 30px rgba(24, 24, 24, 0.04);
}

.card.soft { background: var(--panel-soft); }

.row { display: flex; gap: 10px; align-items: center; }
.row.wrap { flex-wrap: wrap; }
.row > * { min-width: 0; }
.row input, .row select { flex: 1; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; }

.kpi {
  display: grid;
  gap: 4px;
  padding: 18px;
  border-radius: 24px;
  background: #181818;
  color: white;
  margin-bottom: 16px;
}

.kpi span { color: rgba(255,255,255,.72); font-size: 13px; font-weight: 700; }
.kpi strong { font-size: clamp(34px, 11vw, 54px); letter-spacing: -.055em; line-height: 1; }

.list {
  display: grid;
  gap: 10px;
}

.item {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 13px;
  background: white;
}

.item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.item-title { font-weight: 800; }
.item-sub { color: var(--muted); font-size: 13px; }
.item-money { font-weight: 900; white-space: nowrap; }
.item-money.ok { color: var(--ok); }
.item-money.danger { color: var(--danger); }

.cart-total {
  display: grid;
  gap: 8px;
  padding-top: 12px;
  margin-top: 12px;
  border-top: 1px dashed var(--line);
}

.total-line {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.total-line.grand {
  font-size: 24px;
  font-weight: 950;
  letter-spacing: -.04em;
}

.payment-grid, .form-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 680px;
}

th, td {
  padding: 12px 10px;
  text-align: left;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}

th { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }

.alert {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  margin: 10px 0;
}

.alert.error { border-color: #fecdd3; background: #fff1f2; color: var(--danger); }
.alert.ok { border-color: #bbf7d0; background: #f0fdf4; color: var(--ok); }
.alert.warn { border-color: #fed7aa; background: #fff7ed; color: var(--warning); }

.scanner-video {
  position: fixed;
  inset: auto 14px 14px 14px;
  width: calc(100% - 28px);
  max-height: 42vh;
  background: #000;
  border-radius: 22px;
  z-index: 10;
  object-fit: cover;
  box-shadow: var(--shadow);
}

.empty {
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 16px;
  text-align: center;
}

.small { font-size: 13px; color: var(--muted); }

@media (max-width: 820px) {
  .app-shell { padding: 12px; }
  .grid.two { grid-template-columns: 1fr; }
  .payment-grid, .form-grid { grid-template-columns: 1fr; }
  .topbar { align-items: flex-start; }
  .topbar .row { justify-content: flex-end; }
  button { padding: 12px 14px; }
  .card { padding: 15px; }
}


.scanner-fallback {
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgba(0, 0, 0, 0.92);
  padding: 18px;
  display: grid;
  place-items: center;
}

.scanner-fallback[hidden] {
  display: none;
}

.scanner-fallback video {
  max-width: min(96vw, 520px);
  max-height: 72vh;
  border-radius: 18px;
}

.scanner-fallback__stop {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  z-index: 31;
}


html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

button, input, select, textarea {
  font-size: 16px;
}

.payment-method-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.payment-method {
  background: var(--panel-soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.payment-method.active {
  background: var(--ink);
  color: white;
}

.payment-fields[hidden] {
  display: none;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-size: 14px;
}

.check-row input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: 0 0 auto;
  accent-color: var(--ink);
}

.scanner-fallback {
  padding: max(18px, env(safe-area-inset-top)) 18px max(96px, env(safe-area-inset-bottom)) 18px;
}

.scanner-fallback__close {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  z-index: 32;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  background: rgba(255,255,255,.94);
  color: #181818;
  border: 1px solid rgba(255,255,255,.25);
  font-size: 31px;
  line-height: 1;
  font-weight: 700;
}

.scanner-fallback__checkout {
  position: fixed;
  left: 50%;
  bottom: max(22px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 31;
  min-width: min(86vw, 360px);
  background: #181818;
  color: #fff;
  box-shadow: 0 16px 48px rgba(0,0,0,.28);
}

.scanner-fallback__stop {
  top: max(14px, env(safe-area-inset-top));
  right: 14px;
  left: auto;
  bottom: auto;
  transform: none;
}

@media (max-width: 820px) {
  .cashier-product-section {
    display: none;
  }

  .payment-method-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #cartPanel {
    scroll-margin-top: 92px;
  }
}
