:root {
  --bg: #f6f7f9;
  --card: #ffffff;
  --text: #1c2128;
  --muted: #667085;
  --line: #e4e7ec;
  --accent: #1f6feb;
  --danger: #d92d20;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
h1 { font-size: 22px; margin: 8px 0 4px; }
h2 { font-size: 17px; margin: 28px 0 8px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.muted { color: var(--muted); }
.wrap { max-width: 1100px; margin: 0 auto; padding: 16px 16px 96px; }

.topbar {
  position: sticky; top: 0; z-index: 10;
  display: flex; align-items: center; gap: 10px;
  padding: calc(10px + env(safe-area-inset-top)) 16px 10px;
  background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar .spacer { flex: 1; }

.btn {
  display: inline-block; border: 0; border-radius: 8px; cursor: pointer;
  padding: 10px 16px; font: inherit; font-weight: 600; text-decoration: none;
  background: var(--accent); color: #fff;
}
.btn-light { background: #eef2f7; color: var(--text); }
.btn[aria-disabled="true"] { opacity: .45; pointer-events: none; }
.link-danger { background: none; border: 0; color: var(--danger); cursor: pointer; font: inherit; padding: 0; }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 24px; }
.login { max-width: 360px; margin: 12vh auto 0; display: grid; gap: 14px; }
.login h1 { margin: 0 0 4px; }
label { display: grid; gap: 4px; font-weight: 600; font-size: 14px; }
input {
  font: inherit; padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff; color: var(--text); width: 100%;
}
input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

.flash, .error { padding: 10px 14px; border-radius: 8px; margin-bottom: 12px; }
.flash { background: #e7f5ec; color: #0f5132; }
.error { background: #fdecea; color: #8a1c13; }

.search { margin: 12px 0; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0 6px; }

.table-wrap { overflow-x: auto; background: var(--card); border: 1px solid var(--line); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 8px 12px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: middle; }
th { background: #fafbfc; font-size: 13px; color: var(--muted); position: sticky; top: 0; }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; }
.nowrap { white-space: nowrap; }
.sku { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; white-space: nowrap; }
input.qty { width: 90px; text-align: right; padding: 6px 8px; }

.submitbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10;
  display: flex; justify-content: flex-end; align-items: center; gap: 14px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line);
}

.tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: #eef2f7; }
.tag-pending { background: #fff4e5; color: #8a5300; }
.tag-exported { background: #e7f5ec; color: #0f5132; }

.tabs { display: inline-flex; gap: 4px; font-size: 13px; font-weight: 500; }
.tabs a { padding: 4px 10px; border-radius: 99px; text-decoration: none; color: var(--muted); }
.tabs a.on { background: var(--accent); color: #fff; }

@media (max-width: 640px) {
  th, td { padding: 8px; }
  .sku { font-size: 12px; }
}

/* Brand pages (staff) */
.brandbar { display: flex; flex-wrap: wrap; gap: 6px; margin: 14px 0 4px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 99px; border: 1px solid var(--line);
  background: var(--card); color: var(--text); text-decoration: none; font-size: 14px;
}
.chip .cnt { color: var(--muted); font-size: 12px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.chip.on .cnt { color: rgba(255,255,255,.8); }
.chip .filled {
  min-width: 18px; padding: 0 5px; border-radius: 99px; text-align: center;
  background: #12b76a; color: #fff; font-size: 11px; font-weight: 700; line-height: 18px;
}
.view-title { margin-top: 4px; }
table.one-brand .col-brand { display: none; }
.empty { padding: 16px; margin: 0; }
@media (max-width: 640px) {
  .brandbar { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; padding-bottom: 4px; }
  .chip { white-space: nowrap; flex: 0 0 auto; }
}

/* Top navigation (admin) */
.topnav { display: flex; gap: 4px; }
.topnav a { padding: 6px 10px; border-radius: 8px; color: var(--text); text-decoration: none; font-weight: 500; }
.topnav a.on { background: #eef2f7; }

/* Stock movement */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0; }
.stat { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }
.stat .v { font-size: 24px; font-weight: 700; }
.stat .l { color: var(--muted); font-size: 13px; }
.monthpick { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.monthpick input { width: auto; }
.bar { height: 8px; background: var(--accent); border-radius: 4px; min-width: 2px; }
tr.current td { background: #f0f6ff; }
tfoot td { font-weight: 700; background: #fafbfc; }
@media (max-width: 640px) {
  .topbar { flex-wrap: wrap; }
  .topbar > .muted { display: none; }
}

/* Staff table on phones: SKU / stock move under the product name so the qty box stays visible */
.sub { display: none; color: var(--muted); font-size: 12px; margin-top: 2px; }
@media (max-width: 640px) {
  #products .col-wide, #products .col-brand { display: none; }
  #products .sub { display: block; }
  #products.one-brand .sub-brand { display: none; }
  #products input.qty { width: 72px; }
}
#products td:first-child { overflow-wrap: anywhere; }
