/* ============================================================================
   BS POS — design system (mobile first, no framework, no build step)
   ==========================================================================*/

:root {
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --brand-soft: #e6f4f2;
  --accent: #f59e0b;
  --accent-soft: #fff5e5;
  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --line: #e3e8ef;
  --bg: #f5f7fa;
  --card: #ffffff;
  --good: #16a34a;
  --good-soft: #eafaf0;
  --bad: #dc2626;
  --bad-soft: #fdecec;
  --warn: #b45309;
  --warn-soft: #fff7e6;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(15, 23, 42, .06), 0 8px 24px -12px rgba(15, 23, 42, .18);
  --shadow-sm: 0 1px 3px rgba(15, 23, 42, .08);
  --topbar-h: 58px;
  --sidebar-w: 236px;
  --gap: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

h1, h2, h3, h4 { margin: 0 0 .4em; line-height: 1.25; letter-spacing: -.01em; }
h1 { font-size: clamp(1.25rem, 4.6vw, 1.6rem); }
h2 { font-size: clamp(1.05rem, 3.6vw, 1.25rem); }
h3 { font-size: 1rem; }
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
p { margin: 0 0 .8em; }

.muted { color: var(--muted); }
.small { font-size: .82rem; }
.right { text-align: right; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }
.mt0 { margin-top: 0; } .mb0 { margin-bottom: 0; }
.mt1 { margin-top: 8px; } .mt2 { margin-top: 16px; } .mt3 { margin-top: 24px; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grow { flex: 1 1 auto; }

/* ---------------------------------------------------------------- topbar --- */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: var(--topbar-h);
  display: flex; align-items: center; gap: 10px;
  padding: 0 14px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
}
.burger {
  display: inline-flex; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; padding: 9px;
  background: none; border: 1px solid var(--line); border-radius: 10px;
  cursor: pointer; touch-action: manipulation;
}
.burger span { display: block; height: 2px; background: var(--ink-2); border-radius: 2px; }
.topbar-brand { display: flex; align-items: center; gap: 9px; color: var(--ink); font-weight: 650; }
.topbar-brand:hover { text-decoration: none; }
.topbar-logo {
  display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: 9px;
  background: var(--brand); color: #fff; font-size: .78rem; font-weight: 700; letter-spacing: .02em;
}
.topbar-name { font-size: 1rem; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.who { display: none; align-items: center; gap: 7px; color: var(--muted); font-size: .85rem; }
.logoutform { margin: 0; }

/* --------------------------------------------------------------- sidebar --- */
.sidebar {
  position: fixed; z-index: 45;
  top: 0; left: 0; bottom: 0; width: var(--sidebar-w);
  padding: calc(var(--topbar-h) + 14px) 12px 16px;
  background: #0d2b29;
  background-image: linear-gradient(180deg, #0f3b37 0%, #0b2a28 100%);
  color: #cfe6e3;
  transform: translateX(-100%);
  transition: transform .22s ease;
  overflow-y: auto;
  overscroll-behavior: contain;
}
body.drawer-open .sidebar { transform: translateX(0); }
.drawer-backdrop {
  position: fixed; inset: 0; z-index: 44;
  background: rgba(8, 20, 20, .45);
  backdrop-filter: blur(1px);
}
.nav { display: flex; flex-direction: column; gap: 4px; }
.nav-link {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; padding: 10px 12px;
  border-radius: 10px; color: #cfe6e3; font-size: .94rem; font-weight: 500;
}
.nav-link:hover { background: rgba(255, 255, 255, .07); text-decoration: none; color: #fff; }
.nav-link.is-active { background: var(--brand); color: #fff; box-shadow: var(--shadow-sm); }
.nav-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: rgba(255, 255, 255, .35); flex: 0 0 auto;
}
.nav-link.is-active .nav-dot { background: var(--accent); }
.sidebar-foot {
  margin-top: 26px; padding: 12px; border-top: 1px solid rgba(255, 255, 255, .12);
  font-size: .78rem; line-height: 1.5; color: #9fc4c0;
}
.sidebar-foot .store-name { color: #fff; font-weight: 600; }

/* ------------------------------------------------------------------ main --- */
.main { padding: 16px 14px calc(28px + var(--safe-b)); max-width: 1180px; }
.pagehead {
  display: flex; align-items: flex-end; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.pagehead h1 { margin: 0; }
.pagehead-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ------------------------------------------------------------ breakpoints -- */
@media (min-width: 576px) {
  .who { display: inline-flex; }
  .main { padding: 20px 20px calc(34px + var(--safe-b)); }
}

@media (min-width: 1024px) {
  .burger { display: none; }
  .drawer-backdrop { display: none !important; }
  .sidebar { transform: none; padding-top: 18px; }
  .sidebar::before {
    content: "BS POS"; display: block;
    margin: 0 4px 18px; padding-bottom: 14px;
    color: #fff; font-weight: 700; letter-spacing: .04em; font-size: .95rem;
    border-bottom: 1px solid rgba(255, 255, 255, .12);
  }
  .main { margin-left: var(--sidebar-w); padding: 26px 28px calc(40px + var(--safe-b)); }
  .topbar { padding-left: 20px; }
}

/* ------------------------------------------------------------------ card --- */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  padding: 16px;
  margin-bottom: var(--gap);
}
.card-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin: -4px 0 12px;
}
.card-head h2, .card-head h3 { margin: 0; }
.card.pad0 { padding: 0; overflow: hidden; }
.card > :last-child { margin-bottom: 0; }

.grid { display: grid; gap: var(--gap); }
.grid-2 { grid-template-columns: 1fr; }
.grid-3 { grid-template-columns: 1fr; }
.grid-4 { grid-template-columns: 1fr 1fr; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-4 { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 980px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

/* stats */
.stat {
  background: var(--card); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px 16px; box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .06em; }
.stat-value { font-size: clamp(1.3rem, 5.4vw, 1.85rem); font-weight: 680; letter-spacing: -.02em; }
.stat-value small { font-size: .55em; font-weight: 500; color: var(--muted); }
.stat-accent { color: var(--brand); }

/* --------------------------------------------------------------- buttons --- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 42px; padding: 9px 15px;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); color: var(--ink);
  font: inherit; font-weight: 550; font-size: .93rem;
  cursor: pointer; touch-action: manipulation; text-decoration: none;
  transition: background .15s ease, border-color .15s ease, transform .05s ease;
}
.btn:hover { text-decoration: none; background: #f8fafc; }
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); }
.btn-accent { background: var(--accent); border-color: var(--accent); color: #3b2400; }
.btn-accent:hover { background: #e0900a; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; }
.btn-sm { min-height: 34px; padding: 5px 11px; font-size: .85rem; border-radius: 9px; }
.btn-lg { min-height: 50px; font-size: 1.02rem; padding: 12px 20px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.btn-icon { padding: 6px 9px; min-height: 34px; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* ----------------------------------------------------------------- forms --- */
.field { margin-bottom: 13px; }
.label { display: block; margin-bottom: 5px; font-size: .82rem; font-weight: 600; color: var(--ink-2); }
.hint { color: var(--muted); font-size: .78rem; margin-top: 4px; }
.input, .select, textarea {
  width: 100%; min-height: 44px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink);
  font-family: inherit; font-size: 1rem; /* 16px stops iOS auto-zoom */
}
.input:focus, .select:focus, textarea:focus {
  outline: 2px solid var(--brand-soft); border-color: var(--brand);
}
.input-num { text-align: right; font-variant-numeric: tabular-nums; }
.input-error { border-color: var(--bad); }
.row2 { display: grid; gap: 0 12px; grid-template-columns: 1fr; }
@media (min-width: 620px) { .row2 { grid-template-columns: 1fr 1fr; } }
.inline-form { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.inline-form .field { margin-bottom: 0; }

/* ---------------------------------------------------------------- tables --- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th, .table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--line); }
.table th { background: #f8fafc; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.table tbody tr:hover { background: #fbfdfe; }
.table td.num, .table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.table tfoot td { font-weight: 650; background: #fbfdfe; }
.table .actions { white-space: nowrap; }
.table .actions form { display: inline; }

@media (max-width: 640px) {
  .table-cards thead { display: none; }
  .table-cards tr { display: block; border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 10px; padding: 6px 10px; }
  .table-cards td { display: flex; justify-content: space-between; gap: 12px; border: 0; padding: 5px 0; }
  .table-cards td::before { content: attr(data-label); color: var(--muted); font-size: .78rem; }
  .table-cards tfoot tr { border: 0; }
}

/* ---------------------------------------------------------------- badges --- */
.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 650; letter-spacing: .02em;
}
.badge-teal { background: var(--brand-soft); color: var(--brand-dark); }
.badge-amber { background: var(--accent-soft); color: var(--warn); }
.badge-red { background: var(--bad-soft); color: var(--bad); }
.badge-grey { background: #eef2f6; color: var(--muted); }

/* ---------------------------------------------------------------- alerts --- */
.alert {
  padding: 11px 14px; border-radius: var(--radius-sm); margin-bottom: 14px;
  border: 1px solid transparent; font-size: .92rem;
}
.alert-success { background: var(--good-soft); border-color: #b7e6c7; color: #14532d; }
.alert-error { background: var(--bad-soft); border-color: #f5c2c2; color: #7f1d1d; }
.alert-warn { background: var(--warn-soft); border-color: #f2ddb0; color: var(--warn); }

/* ------------------------------------------------------- empty / pager ----- */
.empty { padding: 28px 16px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink-2); margin-bottom: 4px; }
.pager { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; justify-content: center; padding: 12px 0 2px; }
.pager a, .pager span {
  min-width: 38px; min-height: 38px; display: inline-flex; align-items: center; justify-content: center;
  padding: 4px 10px; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink-2); font-size: .88rem;
}
.pager .is-current { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.pager .is-disabled { opacity: .45; }

/* --------------------------------------------------------- simple chart ---- */
.chart {
  display: flex; align-items: flex-end; gap: 4px;
  height: 180px; padding: 10px 2px 0; overflow-x: auto;
  border-bottom: 1px solid var(--line);
}
.chart-col {
  flex: 1 0 26px; min-width: 26px; height: 100%;
  display: flex; flex-direction: column; justify-content: flex-end; align-items: center;
}
.chart-bar {
  width: 100%; max-width: 34px; border-radius: 6px 6px 0 0;
  background: linear-gradient(180deg, #14b8a6 0%, #0f766e 100%);
  transition: opacity .15s ease;
}
.chart-col:hover .chart-bar { opacity: .8; }
.chart-x { font-size: .68rem; color: var(--muted); padding-top: 4px; white-space: nowrap; }

/* ------------------------------------------------------------ auth pages --- */
.auth-body {
  min-height: 100dvh; display: grid; place-items: center; padding: 22px;
  background:
    radial-gradient(1100px 460px at 12% -10%, #d9f2ee 0%, rgba(217, 242, 238, 0) 60%),
    radial-gradient(900px 420px at 100% 0%, #ffeecf 0%, rgba(255, 238, 207, 0) 55%),
    var(--bg);
}
.auth-card {
  width: 100%; max-width: 384px; background: var(--card);
  border: 1px solid var(--line); border-radius: 18px;
  padding: 26px 22px; box-shadow: var(--shadow);
}
.auth-logo { display: grid; place-items: center; margin-bottom: 8px; }
.auth-logo img { max-width: 168px; max-height: 168px; }
.auth-logo .mark {
  width: 108px; height: 108px; border-radius: 26px; background: var(--brand); color: #fff;
  display: grid; place-items: center; font-weight: 700; font-size: 2.1rem; letter-spacing: .04em;
}
.auth-title { text-align: center; font-size: 1.22rem; margin: 12px 0 2px; }
.auth-sub { text-align: center; color: var(--muted); font-size: .86rem; margin-bottom: 20px; }
.auth-foot { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 18px; }

/* ----------------------------------------------------------------- sheet --- */
.sheet { position: fixed; inset: 0; z-index: 60; display: flex; align-items: flex-end; justify-content: center; }
.sheet[hidden] { display: none; }
.sheet-backdrop { position: absolute; inset: 0; background: rgba(8, 20, 20, .5); }
.sheet-panel {
  position: relative; z-index: 1; width: 100%; max-height: 92dvh; overflow-y: auto;
  background: var(--card); border-radius: 18px 18px 0 0; padding: 18px 16px calc(18px + var(--safe-b));
  box-shadow: var(--shadow);
  animation: sheetup .2s ease;
}
@keyframes sheetup { from { transform: translateY(14px); opacity: .6; } to { transform: none; opacity: 1; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.sheet-head h2 { margin: 0; }
@media (min-width: 700px) {
  .sheet { align-items: center; padding: 20px; }
  .sheet-panel { max-width: 540px; border-radius: 18px; }
}

/* -------------------------------------------------------------------- POS -- */
.pos { display: grid; gap: var(--gap); }
@media (min-width: 1024px) { .pos { grid-template-columns: minmax(0, 1.12fr) minmax(330px, .88fr); align-items: start; } }
.searchbox { position: relative; }
.results { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; max-height: 46dvh; overflow-y: auto; }
.result {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; min-height: 52px; padding: 9px 12px; text-align: left;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius-sm);
  font: inherit; cursor: pointer; touch-action: manipulation;
}
.result:hover { border-color: var(--brand); background: var(--brand-soft); }
.result-name { font-weight: 550; }
.result-code { color: var(--muted); font-size: .78rem; font-family: ui-monospace, Menlo, monospace; }
.result-price { font-variant-numeric: tabular-nums; font-weight: 600; }
.cart-line { padding: 11px 0; border-bottom: 1px dashed var(--line); }
.cart-line:last-of-type { border-bottom: 0; }
.cart-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.cart-name { font-weight: 550; }
.cart-sub { color: var(--muted); font-size: .8rem; }
.cart-controls { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.cart-controls .input { min-height: 40px; padding: 6px 9px; }
.cart-controls .qty { max-width: 96px; }
.cart-controls .price { max-width: 132px; }
.cart-total { font-variant-numeric: tabular-nums; font-weight: 650; min-width: 88px; text-align: right; }
.totals { border-top: 1px solid var(--line); margin-top: 10px; padding-top: 10px; }
.totals-row { display: flex; justify-content: space-between; gap: 10px; padding: 4px 0; font-variant-numeric: tabular-nums; }
.totals-row.grand { font-size: 1.2rem; font-weight: 700; border-top: 1px solid var(--line); margin-top: 6px; padding-top: 10px; }
.totals-row .lbl { color: var(--muted); font-weight: 500; }
.cartbar {
  position: sticky; bottom: 0; z-index: 20;
  margin: 14px -14px calc(-1 * var(--safe-b)); padding: 12px 14px calc(12px + var(--safe-b));
  background: rgba(255, 255, 255, .96); border-top: 1px solid var(--line);
  backdrop-filter: blur(6px);
}
@media (min-width: 1024px) { .cartbar { position: static; margin: 14px 0 0; padding: 0; border-top: 0; background: none; backdrop-filter: none; } }



