/* AQ Mobile — one stylesheet, mobile first */
:root {
  --ink: #161A23;
  --ink-2: #3A404C;
  --muted: #5A6170;
  --line: #E2E5EA;
  --line-2: #EEF0F3;
  --field: #CDD2DA;
  --ground: #F4F5F7;
  --surface: #FFFFFF;
  --nav: #161A23;
  --nav-2: #2A3140;
  --nav-txt: #C9CED8;
  --nav-sub: #A9B0BD;
  --accent: #1E4FD8;
  --accent-ink: #163BA6;
  --accent-soft: #E8EDFB;
  --ok: #0B6643;  --ok-bg: #E7F4EE;
  --warn: #8A3F06; --warn-bg: #FDF1E3;
  --bad: #9B1C23; --bad-bg: #FBE9EA; --bad-line: #F0C9CC;
  --radius: 12px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; font-family: var(--font); font-size: 16px; line-height: 1.45; color: var(--ink); background: var(--ground); }
h1, h2, h3 { margin: 0; line-height: 1.2; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -0.01em; }
h2 { font-size: 18px; font-weight: 700; }
p { margin: 0; }
a { color: var(--accent); }
a:hover { color: var(--accent-ink); }
img { max-width: 100%; }
.ico { flex: none; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: absolute; left: -999px; top: 8px; background: var(--surface); padding: 10px 14px; border-radius: 8px; z-index: 100; }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.tiny { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }
.num { font-variant-numeric: tabular-nums; }
.mt-12 { margin-top: 12px; }
.row { display: flex; flex-wrap: wrap; }
.gap-8 { gap: 8px; } .gap-12 { gap: 12px; }
.align-center { align-items: center; }
.stack-6 { display: flex; flex-direction: column; gap: 6px; }
.stack { display: flex; flex-direction: column; gap: 16px; }
.grid-2 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr; gap: 14px; }
.hidden, [hidden] { display: none !important; }
.eyebrow { font-size: 13px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 44px; padding: 0 16px; border-radius: 10px; border: 1px solid var(--field);
  background: var(--surface); color: var(--ink); font: inherit; font-size: 15px; font-weight: 600;
  text-decoration: none; cursor: pointer; white-space: nowrap; touch-action: manipulation;
}
.btn:hover { background: #F8F9FA; color: var(--ink); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #FFFFFF; font-weight: 700; }
.btn-primary:hover { background: var(--accent-ink); border-color: var(--accent-ink); color: #FFFFFF; }
.btn-dark { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }
.btn-dark:hover { background: #000; color: #FFFFFF; }
.btn-danger { color: var(--bad); border-color: var(--bad-line); }
.btn-danger:hover { background: var(--bad-bg); color: var(--bad); }
.btn-lg { min-height: 50px; font-size: 16px; width: 100%; }
.btn-sm { min-height: 40px; padding: 0 12px; font-size: 14px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }
.icon-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 1px solid transparent; background: transparent; color: var(--ink-2); cursor: pointer; }
.icon-btn:hover { background: var(--line-2); }
.linkbtn { background: none; border: 0; padding: 8px; color: var(--accent); font: inherit; font-weight: 600; cursor: pointer; text-decoration: underline; }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > label, .label { font-size: 14px; font-weight: 600; }
.req { color: #B4232A; }
input[type=text], input[type=search], input[type=password], input[type=number], input[type=tel], input:not([type]), select, textarea {
  width: 100%; min-height: 46px; padding: 0 14px; border: 1px solid var(--field); border-radius: 10px;
  font: inherit; font-size: 16px; color: var(--ink); background: var(--surface);
}
textarea { padding: 12px 14px; resize: vertical; min-height: 90px; }
textarea.code { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
select { padding-right: 32px; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); }
input[readonly] { background: var(--ground); }
.hint { font-size: 13px; color: var(--muted); }
.hint.warn { color: var(--warn); font-weight: 600; }
.hint.ok { color: var(--ok); font-weight: 600; }
.check { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); flex: none; }
.input-icon { position: relative; display: flex; align-items: center; flex: 1 1 260px; min-width: 0; }
.input-icon .ico { position: absolute; left: 14px; color: var(--muted); pointer-events: none; }
.input-icon input { padding-left: 42px; }
.with-btn { display: flex; gap: 8px; }
.with-btn input { flex: 1 1 auto; min-width: 0; }
.money-field { position: relative; }
details summary { cursor: pointer; color: var(--muted); min-height: 32px; }

/* ---------- Cards, flash, badges ---------- */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 18px; }
.card-flush { padding: 0; overflow: hidden; }
.flash { padding: 12px 14px; border-radius: 10px; font-size: 15px; font-weight: 600; }
.flash-ok { background: var(--ok-bg); color: var(--ok); }
.flash-err { background: var(--bad-bg); color: var(--bad); }
.flash-warn { background: var(--warn-bg); color: var(--warn); }
.badge { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 13px; font-weight: 700; white-space: nowrap; }
.b-ok { background: var(--ok-bg); color: var(--ok); }
.b-low { background: var(--warn-bg); color: var(--warn); }
.b-out { background: var(--bad-bg); color: var(--bad); }
.b-none { background: var(--line-2); color: #4A505C; }
.b-me { background: var(--line-2); color: #4A505C; font-size: 12px; margin-left: 6px; }
.profit { color: var(--ok); font-weight: 700; }
.loss { color: var(--bad); font-weight: 700; }

.mark { display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 10px; background: var(--accent); color: #FFFFFF; font-weight: 800; font-size: 14px; flex: none; }
.mark-lg { width: 44px; height: 44px; border-radius: 12px; font-size: 16px; }

/* ---------- App shell ---------- */
.shell { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; justify-content: space-between;
  gap: 12px; padding: 10px 12px 10px 16px; padding-top: max(10px, env(safe-area-inset-top));
  background: var(--nav); color: #FFFFFF;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #FFFFFF; min-width: 0; }
.brand:hover { color: #FFFFFF; }
.brand-txt { display: flex; flex-direction: column; min-width: 0; }
.brand-txt strong { font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-txt small { font-size: 12px; color: var(--nav-sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; border-radius: 10px; border: 0; background: var(--nav-2); color: #FFFFFF; cursor: pointer; }

.sidenav {
  display: none; flex-direction: column; gap: 20px; padding: 12px 12px 20px;
  background: var(--nav); color: var(--nav-txt); position: sticky; top: 64px; z-index: 19;
  max-height: calc(100vh - 64px); overflow-y: auto; box-shadow: 0 10px 20px rgba(0,0,0,.25);
}
.sidenav.open { display: flex; }
.brand-side { display: none; padding: 0 8px; }
.navlist { display: flex; flex-direction: column; gap: 4px; }
.navlist a, .navbtn {
  display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 12px; border-radius: 10px;
  color: var(--nav-txt); text-decoration: none; font-size: 15px; font-weight: 500; background: none; border: 0; width: 100%; font-family: inherit; cursor: pointer; text-align: left;
}
.navlist a:hover, .navbtn:hover { background: var(--nav-2); color: #FFFFFF; }
.navlist a.on { background: var(--nav-2); color: #FFFFFF; font-weight: 600; }
.nav-foot { display: flex; flex-direction: column; gap: 6px; border-top: 1px solid #2A3140; padding-top: 12px; }
.who { font-size: 13px; color: var(--nav-sub); padding: 0 12px; }
.who strong { color: #FFFFFF; }

.main { padding: 18px 14px 40px; display: flex; flex-direction: column; gap: 18px; min-width: 0; max-width: 1240px; padding-bottom: max(40px, env(safe-area-inset-bottom)); }
.page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 14px; }
.page-head .stack-6 { min-width: 0; }
.back { display: inline-flex; align-items: center; gap: 4px; font-size: 14px; font-weight: 600; text-decoration: none; min-height: 36px; }

/* Stats */
.stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; display: flex; flex-direction: column; gap: 2px; min-width: 0; text-decoration: none; color: inherit; }
a.stat:hover { border-color: var(--field); color: inherit; }
.stat span { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat strong { font-size: 22px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stat .warnv { color: #B45309; } .stat .badv { color: #B4232A; }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.toolbar select { width: auto; flex: 1 1 150px; }
.pills { display: flex; flex-wrap: wrap; gap: 6px; }
.pill { min-height: 42px; padding: 0 16px; border: 1px solid var(--field); border-radius: 999px; background: var(--surface); color: var(--ink); font-size: 14px; font-weight: 600; text-decoration: none; display: inline-flex; align-items: center; }
.pill:hover { color: var(--ink); background: #F8F9FA; }
.pill.on { background: var(--ink); border-color: var(--ink); color: #FFFFFF; }

/* ---------- Tables (become cards on phones) ---------- */
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
table.list { width: 100%; border-collapse: collapse; font-size: 15px; }
table.list th { text-align: left; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; font-weight: 700; padding: 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
table.list tr:last-child td { border-bottom: 0; }
table.list .r { text-align: right; }
table.list td.num, table.list td.r { white-space: nowrap; }
table.list .c { text-align: center; }
.item-name { font-weight: 700; }
.item-sub { font-size: 13px; color: var(--muted); }
.empty { padding: 32px 16px; text-align: center; color: var(--muted); }

@media (max-width: 759px) {
  table.cards thead { display: none; }
  table.cards, table.cards tbody, table.cards tr, table.cards td { display: block; width: 100%; }
  table.cards tr { position: relative; padding: 12px 14px; border-bottom: 1px solid var(--line); display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 6px 12px; }
  table.cards tr:last-child { border-bottom: 0; }
  table.cards td { padding: 0; border: 0; text-align: left !important; min-width: 0; }
  table.cards td[data-label]::before { content: attr(data-label) ": "; color: var(--muted); font-size: 13px; font-weight: 600; }
  table.cards td.cell-main { grid-column: 1 / -1; padding-right: 96px; }
  table.cards td.cell-act { position: absolute; top: 8px; right: 10px; width: auto; }
  table.cards td.cell-wide { grid-column: 1 / -1; }
  table.bill-lines td:first-child { display: none; }
  table.bill-lines td.c { justify-self: start; }
  table.bill-lines td.r .price-in { width: 100%; max-width: 140px; }
  table.bill-lines td[data-label="Amount"] { grid-column: 1 / -1; font-size: 16px; }
}

.pager { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }

/* ---------- Product form ---------- */
.form-card { display: flex; flex-direction: column; gap: 24px; }
.form-card section { display: flex; flex-direction: column; gap: 14px; }
.profit-box { border-radius: 12px; padding: 12px 16px; background: var(--ground); display: flex; flex-direction: column; gap: 2px; justify-content: center; min-height: 72px; }
.profit-box strong { font-size: 22px; font-weight: 800; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-end; border-top: 1px solid var(--line); padding-top: 18px; }
.form-actions .spacer { flex: 1 1 auto; }

/* ---------- Billing ---------- */
.bill-layout { display: flex; flex-direction: column; gap: 18px; }
.bill-lines .qty { display: inline-flex; align-items: center; gap: 4px; }
.bill-lines .qty button { width: 40px; height: 40px; border: 1px solid var(--field); border-radius: 10px; background: var(--surface); font-size: 18px; font-weight: 700; cursor: pointer; color: var(--ink); }
.bill-lines .qty input { width: 56px; min-height: 40px; padding: 0 4px; text-align: center; font-weight: 700; }
.bill-lines .price-in { width: 110px; min-height: 40px; text-align: right; }
.suggest { position: absolute; z-index: 15; top: calc(100% + 4px); left: 0; right: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 12px 28px rgba(22,26,35,.14); max-height: 340px; overflow-y: auto; padding: 4px; }
.suggest button { width: 100%; display: flex; justify-content: space-between; gap: 12px; align-items: center; min-height: 52px; padding: 8px 12px; border: 0; border-radius: 8px; background: none; font: inherit; text-align: left; cursor: pointer; color: var(--ink); }
.suggest button:hover, .suggest button.active { background: var(--accent-soft); }
.suggest .s-price { font-weight: 700; white-space: nowrap; }
.totals { display: flex; flex-direction: column; gap: 12px; border-top: 1px solid var(--line); padding-top: 14px; }
.totals .line { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.totals .grand { border-top: 1px dashed var(--field); padding-top: 12px; align-items: baseline; }
.totals .grand strong { font-size: 28px; font-weight: 800; }
.totals input { width: 120px; min-height: 40px; text-align: right; }

/* ---------- Receipt ---------- */
.receipt { background: #FFFFFF; border: 1px solid var(--line); border-radius: 14px; padding: 22px 18px; max-width: 640px; width: 100%; display: flex; flex-direction: column; gap: 20px; }
.r-head { display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.r-head > .right { margin-left: auto; align-items: flex-end; }
.r-meta { display: flex; justify-content: space-between; gap: 12px; padding: 12px 14px; border-radius: 10px; background: var(--ground); font-size: 14px; flex-wrap: wrap; }
.r-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.r-table th { text-align: left; color: var(--muted); font-weight: 700; padding: 8px 4px; border-bottom: 1.5px solid var(--ink); }
.r-table td { padding: 9px 4px; border-bottom: 1px solid var(--line); }
.r-totals { align-self: flex-end; width: 100%; max-width: 260px; display: flex; flex-direction: column; gap: 6px; font-variant-numeric: tabular-nums; }
.r-totals div { display: flex; justify-content: space-between; }
.r-totals .g { border-top: 1.5px solid var(--ink); padding-top: 8px; font-weight: 800; font-size: 18px; }
.r-foot { border-top: 1px dashed var(--field); padding-top: 14px; text-align: center; font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }

/* ---------- Lists (categories, staff) ---------- */
.plain-list { list-style: none; margin: 0; padding: 0; }
.plain-list > li { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line-2); }
.plain-list > li:last-child { border-bottom: 0; }
.plain-list .grow { flex: 1 1 180px; min-width: 0; }
.avatar { width: 42px; height: 42px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-weight: 800; flex: none; }
.inline-form { display: inline; }
.temp-pass { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 18px; background: #FFFFFF; padding: 2px 8px; border-radius: 6px; user-select: all; }

/* ---------- Scanner modal ---------- */
.scan-modal { position: fixed; inset: 0; z-index: 60; background: rgba(10,12,18,.7); display: flex; align-items: flex-end; justify-content: center; }
.scan-box { background: var(--surface); width: 100%; max-width: 520px; border-radius: 18px 18px 0 0; padding: 16px; display: flex; flex-direction: column; gap: 10px; padding-bottom: max(16px, env(safe-area-inset-bottom)); }
.scan-head { display: flex; align-items: center; justify-content: space-between; }
#scanReader { width: 100%; min-height: 240px; border-radius: 12px; overflow: hidden; background: #000; }
#scanReader video { width: 100% !important; height: auto !important; }

/* ---------- Setup / login ---------- */
.center-wrap { min-height: 100vh; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 24px 14px; }
.setup-card { width: 100%; max-width: 500px; display: flex; flex-direction: column; gap: 18px; padding: 24px 18px; }
.login { min-height: 100vh; display: flex; flex-direction: column; }
.login-side { background: var(--nav); color: #FFFFFF; padding: 24px 20px; display: flex; flex-direction: column; gap: 18px; }
.login-shop { font-size: 20px; }
.login-pitch h1 { font-size: 26px; line-height: 1.15; }
.login-pitch p { color: var(--nav-txt); margin-top: 8px; display: none; }
.login-contact { font-size: 14px; color: var(--nav-sub); display: none; }
.login-main { flex: 1 1 auto; display: flex; justify-content: center; padding: 28px 16px 40px; }
.login-form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 18px; }
.login-form h2 { font-size: 26px; }

/* ---------- Bigger screens ---------- */
@media (min-width: 600px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .stats { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .main { padding: 24px 22px 48px; gap: 22px; }
  .card { padding: 22px; }
  .setup-card { padding: 32px; }
  .receipt { padding: 32px 30px; }
  h1 { font-size: 30px; }
  .scan-modal { align-items: center; }
  .scan-box { border-radius: 18px; }
}
@media (min-width: 900px) {
  .grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .bill-layout { flex-direction: row; align-items: flex-start; }
  .bill-layout > .bill-main { flex: 1 1 auto; min-width: 0; }
  .bill-layout > .bill-side { flex: 0 0 340px; position: sticky; top: 24px; }
  .login { flex-direction: row; }
  .login-side { flex: 1 1 50%; padding: 56px 48px; justify-content: space-between; }
  .login-pitch h1 { font-size: 44px; }
  .login-pitch p, .login-contact { display: block; }
  .login-main { flex: 1 1 50%; align-items: center; }
}
@media (min-width: 1024px) {
  .shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
  .topbar { display: none; }
  .sidenav { display: flex !important; position: sticky; top: 0; height: 100vh; max-height: none; padding: 24px 16px; box-shadow: none; gap: 28px; }
  .brand-side { display: flex; }
  .nav-foot { margin-top: auto; }
  .main { padding: 32px 32px 56px; }
}

/* ---------- Print (receipt) ---------- */
@media print {
  body { background: #FFFFFF; }
  .topbar, .sidenav, .no-print, .flash { display: none !important; }
  .shell { display: block; }
  .main { padding: 0; }
  .receipt { border: 0; padding: 0; max-width: none; }
}
