:root {
  --bg: #0B0E11;
  --card: #1E2329;
  --field: #2B3139;
  --line: #2B3139;
  --line-strong: #474D57;
  --text: #EAECEF;
  --muted: #848E9C;
  --accent: #F0B90B;
  --accent-hi: #FCD535;
  --on-accent: #181A20;
  --green: #0ECB81;
  --green-bg: #0F2F24;
  --red: #F6465D;
  --red-bg: #3A161B;
  --blue: #6EA8FE;
  --blue-bg: #14213A;
  --cost: #F0B90B;
  --cost-bg: #2A2512;
  --b-bg: #0F2A22;
  --radius: 14px;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'IBM Plex Sans', 'Noto Sans Myanmar', system-ui, sans-serif;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--accent); }
.num { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { max-width: 640px; margin: 0 auto; min-height: 100%; display: flex; flex-direction: column; }

/* ---------- auth screens ---------- */
.auth { padding: 64px 24px 32px; display: flex; flex-direction: column; gap: 32px; min-height: 100vh; }
.brand { display: flex; flex-direction: column; gap: 16px; }
.brand-mark { width: 56px; height: 56px; border-radius: 16px; background: var(--accent); display: flex; align-items: center; justify-content: center; }
.brand h1 { margin: 0; font-size: 30px; line-height: 1.15; }
.brand p { margin: 4px 0 0; color: var(--muted); }
.form { display: flex; flex-direction: column; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 15px; font-weight: 600; }
.input {
  height: 52px; border-radius: 12px; border: 1.5px solid var(--line-strong);
  background: var(--card); padding: 0 14px; outline: none; font-size: 17px; width: 100%;
}
.input:focus { border-color: var(--accent); }
.check { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.check input { width: 22px; height: 22px; accent-color: var(--accent); }
.hint { font-size: 13px; color: var(--muted); margin: 0; line-height: 1.5; }
.error { color: var(--red); font-size: 14px; min-height: 20px; margin: 0; }
.btn {
  height: 52px; border-radius: 12px; border: 0; background: var(--accent); color: var(--on-accent);
  font-size: 16px; font-weight: 600; cursor: pointer; padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
}
.btn:active { background: var(--accent-hi); }
.btn[disabled] { opacity: .5; }
.btn.ghost { background: var(--card); color: var(--text); border: 1.5px solid var(--line-strong); }
.btn.small { height: 44px; font-size: 14px; border-radius: 10px; }
.btn.danger { background: var(--card); color: var(--red); border: 1.5px solid var(--line-strong); }
.btn.good { background: var(--green-bg); color: var(--green); border: 1.5px solid var(--green); }
.note-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }

/* ---------- top bar ---------- */
.top { position: sticky; top: 0; z-index: 5; background: var(--card); border-bottom: 1px solid var(--line); padding: 14px 16px 12px; display: flex; flex-direction: column; gap: 12px; }
.top-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.top h1 { margin: 0; font-size: 21px; }
.status { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--green); flex-shrink: 0; }
.dot.warn { background: var(--accent); }
.dot.bad { background: var(--red); }
.badge { font-size: 12px; font-weight: 600; padding: 6px 10px; border-radius: 999px; background: var(--field); color: var(--text); white-space: nowrap; }
.badge.super { background: var(--accent); color: var(--on-accent); }
.badge.admin { background: var(--blue-bg); color: var(--blue); }
.badge.sales { background: var(--green-bg); color: var(--green); }
.icon-btn { width: 44px; height: 44px; border-radius: 10px; border: 0; background: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; color: var(--muted); }
.search { display: flex; align-items: center; gap: 10px; background: var(--field); border: 1.5px solid var(--line-strong); border-radius: 12px; height: 48px; padding: 0 6px 0 12px; }
.search input { flex: 1; border: 0; outline: 0; background: transparent; font-size: 16px; min-width: 0; }
.search:focus-within { border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex-shrink: 0; min-height: 36px; padding: 0 14px; border-radius: 999px; font-size: 14px; background: var(--card); border: 1.5px solid var(--line-strong); cursor: pointer; }
.chip.on { background: var(--accent); color: var(--on-accent); border-color: var(--accent); font-weight: 600; }

/* ---------- list ---------- */
.main { flex: 1; padding: 12px 12px 96px; display: flex; flex-direction: column; gap: 10px; }
.count { font-size: 12px; color: var(--muted); padding: 0 4px; }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; cursor: pointer; text-align: left; width: 100%; }
.card-head { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.card-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.stock { flex-shrink: 0; font-size: 12px; font-weight: 600; padding: 4px 8px; border-radius: 8px; }
.stock.in { background: var(--green-bg); color: var(--green); }
.stock.out { background: var(--red-bg); color: var(--red); }
.prices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.price { border-radius: 10px; padding: 8px 10px; background: var(--field); display: flex; flex-direction: column; gap: 2px; }
.price .lbl { font-size: 12px; font-weight: 600; color: var(--muted); }
.price .val { font-size: 16px; font-weight: 700; }
.price.cost { background: var(--cost-bg); }
.price.cost .lbl { color: var(--cost); }
.price.b { background: var(--b-bg); }
.price.b .lbl { color: var(--green); }
.price.c { background: var(--blue-bg); }
.price.c .lbl { color: var(--blue); }
.margin { font-size: 12px; color: var(--muted); }

.tbl-head, .row { display: grid; gap: 6px; align-items: center; }
.tbl-head { font-size: 12px; font-weight: 600; color: var(--muted); padding: 4px 8px 0 12px; }
.row { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 8px 12px 12px; min-height: 52px; cursor: pointer; text-align: left; width: 100%; }
.row .nm { font-size: 14px; font-weight: 600; line-height: 1.3; }
.row .v { text-align: right; font-size: 14px; }
.cols-3 { grid-template-columns: minmax(0, 1fr) 84px 84px 84px; }
.cols-2 { grid-template-columns: minmax(0, 1fr) 100px 100px; }
.col-a { font-weight: 700; }
.col-b { color: var(--green); }
.col-c { color: var(--blue); }
.r { text-align: right; }
.empty { text-align: center; color: var(--muted); padding: 48px 16px; }

/* ---------- bottom nav ---------- */
.nav { position: fixed; bottom: 0; left: 0; right: 0; z-index: 6; background: var(--card); border-top: 1px solid var(--line); display: flex; justify-content: center; padding: 6px 4px calc(10px + env(safe-area-inset-bottom)); }
.nav-in { width: 100%; max-width: 640px; display: grid; grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); }
.nav button { background: transparent; border: 0; min-height: 52px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 12px; color: var(--muted); cursor: pointer; }
.nav button.on { color: var(--accent); font-weight: 600; }

/* ---------- sheet (detail / share) ---------- */
.sheet-bg { position: fixed; inset: 0; background: rgba(0,0,0,.6); z-index: 10; display: flex; align-items: flex-end; justify-content: center; }
.sheet { width: 100%; max-width: 640px; max-height: 92vh; overflow-y: auto; background: var(--bg); border-radius: 18px 18px 0 0; border-top: 1px solid var(--line); padding: 8px 14px calc(16px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line-strong); margin: 4px auto 0; }
.sheet h2 { margin: 0; font-size: 20px; line-height: 1.25; }
.plist { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.pline { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-top: 1px solid var(--line); gap: 12px; }
.pline:first-child { border-top: 0; }
.pline .l { display: flex; flex-direction: column; gap: 2px; font-weight: 600; }
.pline .l small { font-weight: 400; font-size: 12px; color: var(--muted); }
.pline .v { font-size: 20px; font-weight: 700; }
.pline.cost { background: var(--cost-bg); }
.pline.cost .l { color: var(--cost); }
.pline.b .l { color: var(--green); }
.pline.c .l { color: var(--blue); }
.actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tiers { display: flex; gap: 8px; flex-wrap: wrap; }
.preview { white-space: pre-wrap; font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px; max-height: 240px; overflow: auto; }

/* ---------- users ---------- */
.ucard { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; display: flex; flex-direction: column; gap: 10px; }
.ucard .btns { display: flex; gap: 8px; flex-wrap: wrap; }
.ucard .btns .btn { flex: 1 1 120px; }
select.input { appearance: none; }
.section-title { font-size: 15px; font-weight: 600; margin: 8px 4px 0; }
.toast { position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%); background: var(--field); color: var(--text); padding: 10px 16px; border-radius: 10px; font-size: 14px; z-index: 20; border: 1px solid var(--line-strong); max-width: 90vw; }
.prewrap { white-space: pre-line; }

/* ---------- category filter + picker ---------- */
.filterbar { display: flex; gap: 8px; align-items: center; }
.filter-btn { line-height: 1.3; flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; height: 44px; padding: 0 12px; border-radius: 12px; background: var(--bg); border: 1.5px solid var(--line-strong); color: var(--muted); cursor: pointer; font-size: 14px; text-align: left; }
.filter-btn .fl { flex-shrink: 0; }
.filter-btn .fv { flex: 1; min-width: 0; color: var(--text); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.filter-btn:hover { border-color: var(--muted); }
.filter-btn.active { border-color: var(--accent); }
.filter-btn.active svg:first-child, .filter-btn.active .fv { color: var(--accent); }
.filterbar .clear { width: 44px; border: 1.5px solid var(--line-strong); border-radius: 12px; }

.cat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.cat-tile { line-height: 1.3; display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 46px; padding: 8px 12px; border-radius: 12px; background: var(--card); border: 1.5px solid var(--line); cursor: pointer; text-align: left; font-size: 14px; }
.cat-tile .cn { min-width: 0; overflow-wrap: anywhere; }
.cat-tile .cc { flex-shrink: 0; font-size: 12px; color: var(--muted); background: var(--field); border-radius: 999px; padding: 2px 8px; }
.cat-tile:hover { border-color: var(--line-strong); }
.cat-tile.on { background: var(--accent); border-color: var(--accent); color: var(--on-accent); font-weight: 600; }
.cat-tile.on .cc { background: rgba(0,0,0,.15); color: var(--on-accent); }
.cat-tile.all { min-height: 50px; font-weight: 600; }
.cat-group { display: flex; flex-direction: column; gap: 8px; padding-top: 4px; }
.cat-ghead { line-height: 1.35; display: flex; justify-content: space-between; align-items: center; gap: 8px; background: none; border: 0; padding: 6px 2px; cursor: pointer; text-align: left; color: var(--text); }
.cat-ghead > span:first-child { display: flex; flex-direction: column; gap: 2px; }
.cat-ghead b { font-size: 15px; }
.cat-ghead small { font-size: 12px; color: var(--muted); }
.cat-gall { flex-shrink: 0; font-size: 12px; color: var(--accent); border: 1px solid var(--line-strong); border-radius: 999px; padding: 4px 10px; }
.cat-ghead.on .cat-gall, .cat-ghead:hover .cat-gall { background: var(--accent); color: var(--on-accent); border-color: var(--accent); }
[hidden] { display: none !important; }

/* PC / tablet: dialogs float in the middle instead of sliding up from the bottom */
@media (min-width: 720px) {
  .sheet-bg { align-items: center; padding: 24px; }
  .sheet { border-radius: 18px; border: 1px solid var(--line); max-height: 86vh; padding-bottom: 18px; }
  .sheet .grab { display: none; }
  .sheet.wide { max-width: 860px; }
}
@media (max-width: 719px) { .sheet.wide { min-height: 75vh; } }
