/* SAF Shop. The main app's colours and weights, so the two feel like one
   thing - with the shop's own blue running through the buttons. */
:root {
  --bg: #060d22;
  --bg-2: #0b1430;
  --ink: #eef5fd;
  --muted: #94aacb;
  --line: rgba(255, 255, 255, .10);
  --glass: rgba(255, 255, 255, .05);
  --glass-2: rgba(255, 255, 255, .08);
  --grad: linear-gradient(135deg, #3fb3e8, #2a55b0);
  --good: #46d18a;
  --bad: #ff7a7a;
  --tabbar-h: 66px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; background: var(--bg); }
body {
  color: var(--ink);
  font: 15px/1.5 -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(1100px 620px at 8% -8%, rgba(63, 179, 232, .16), transparent 60%),
    radial-gradient(900px 520px at 100% 0%, rgba(42, 85, 176, .20), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  min-height: 100vh;
  padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom, 0px) + 12px);
}

#app { max-width: 640px; margin: 0 auto; padding: 14px 14px 8px; }
.loading { text-align: center; color: var(--muted); padding: 22vh 0; }
.hidden { display: none !important; }

h1 { font-size: 25px; letter-spacing: -0.02em; margin: 0; }
.pagehead {
  display: flex; align-items: flex-start; justify-content: space-between;
  gap: 10px; margin: 6px 0 14px;
}
.pagehead .sub { color: var(--muted); font-size: 13px; margin-top: 3px; }
.cardtitle { margin: 0 0 10px; font-size: 13px; text-transform: uppercase;
  letter-spacing: .08em; color: var(--muted); }

.card {
  background: var(--glass); border: 1px solid var(--line); border-radius: 18px;
  padding: 16px; margin-bottom: 12px;
  -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
}
.card.center { text-align: center; }
.card.list { padding: 6px 8px; }
.hint { color: var(--muted); font-size: 13px; line-height: 1.5; }
.err { color: var(--bad); font-size: 13.5px; margin: 8px 0; }
.empty { text-align: center; color: var(--muted); padding: 40px 16px; }
.empty .big { font-size: 40px; margin-bottom: 8px; }
.neg { color: var(--bad); }
.pos { color: var(--good); }

button {
  font: inherit; font-weight: 700; color: #fff; cursor: pointer;
  background: var(--grad); border: 0; border-radius: 13px;
  padding: 11px 15px; min-height: 44px;
  box-shadow: 0 6px 18px rgba(63, 170, 255, .25);
}
button:disabled { opacity: .5; box-shadow: none; }
.btn-block { display: block; width: 100%; }
.btn-quiet { background: var(--glass-2); border: 1px solid var(--line); box-shadow: none; }
.btn-danger { background: rgba(255, 92, 92, .16); border: 1px solid rgba(255, 92, 92, .35);
  color: #ffb3b3; box-shadow: none; }
.btn-sm { padding: 7px 11px; min-height: 36px; font-size: 13.5px; border-radius: 10px; }
.btn-sub { display: block; font-size: 11.5px; font-weight: 600; opacity: .85; margin-top: 2px; }
.btn-block + .btn-block { margin-top: 8px; }

input, select {
  width: 100%; font: inherit; color: var(--ink);
  background: rgba(9, 18, 44, .55); border: 1px solid var(--line);
  border-radius: 12px; padding: 12px 13px; min-height: 46px;
}
input::placeholder { color: rgba(148, 170, 203, .7); }
input:focus, select:focus { outline: none; border-color: rgba(63, 179, 232, .6); }
/* Autofill must not repaint the box white. */
input:-webkit-autofill, input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--ink);
  transition: background-color 100000s ease-in-out 0s;
}
.lbl { display: block; font-size: 12px; color: var(--muted); margin: 12px 0 5px;
  text-transform: uppercase; letter-spacing: .06em; font-weight: 700; }
.card > .lbl:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; }
.row > input { flex: 1; }
.row-between { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 6px 0; }

/* ---- login ---- */
.loginwrap { max-width: 420px; margin: 8vh auto 0; text-align: center; }
.logo {
  width: 78px; height: 78px; margin: 0 auto 14px; border-radius: 22px;
  background: var(--grad) center/cover;
  box-shadow: 0 14px 34px rgba(42, 85, 176, .45);
  position: relative;
}
.logo::before, .logo::after {
  content: ''; position: absolute; background: #fff; border-radius: 4px;
}
.logo::before { left: 16%; right: 16%; top: 30%; height: 11%; }
.logo::after {
  left: 22%; right: 22%; top: 43%; height: 30%; border-radius: 4px;
  box-shadow: inset 0 -13px 0 -4px rgba(0, 0, 0, 0);
}
.brand { font-size: 27px; margin: 0; }
.brandsub { color: var(--muted); margin: 4px 0 18px; font-size: 13.5px; }
.loginwrap .card { text-align: left; }

/* ---- the menu ---- */
.menu { display: grid; gap: 10px; margin-bottom: 14px; }
.menu-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  width: 100%; text-align: left; padding: 14px 16px; border-radius: 16px;
  background: var(--glass); border: 1px solid var(--line); box-shadow: none;
  color: var(--ink); min-height: 66px;
}
.menu-item:active { background: var(--glass-2); }
.menu-item.out { opacity: .55; }
.mi-name { font-size: 16.5px; font-weight: 700; }
.mi-note { font-size: 12.5px; color: var(--muted); margin-top: 2px; }
.mi-stock { font-size: 12px; color: var(--muted); margin-top: 3px; }
.mi-stock.low { color: #ffc46b; }
.mi-price { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; flex: none; }

/* ---- rows ---- */
.list { display: block; }
.row-link {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: none; border: 0; box-shadow: none; color: var(--ink);
  padding: 13px 10px; border-bottom: 1px solid var(--line); border-radius: 0;
  font-weight: 600;
}
.row-link:last-child { border-bottom: 0; }
.row-link:active { background: var(--glass-2); }
.row-link.dim { opacity: .55; }
.rl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rl-val { font-weight: 800; letter-spacing: -0.01em; }
.chev { color: var(--muted); font-size: 20px; line-height: 1; flex: none; }
.tag {
  display: inline-block; margin-left: 7px; padding: 1px 7px; border-radius: 8px;
  background: var(--glass-2); border: 1px solid var(--line);
  font-size: 11px; font-weight: 700; color: var(--muted);
}
.tag.low { color: #ffc46b; border-color: rgba(255, 196, 107, .35); }
.linkrow { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; text-decoration: none; color: var(--ink); }

/* ---- stats ---- */
.statrow { display: flex; gap: 10px; margin-bottom: 12px; }
.statgrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 12px; }
.stat {
  flex: 1; background: var(--glass); border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 12px; text-align: center;
}
.stat-n { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.stat-l { font-size: 11.5px; color: var(--muted); margin-top: 2px; }
.bigbal { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }

.tbl { width: 100%; border-collapse: collapse; font-size: 14px; }
.tbl th {
  text-align: left; font-size: 11px; text-transform: uppercase; letter-spacing: .06em;
  color: var(--muted); padding: 4px 6px; border-bottom: 1px solid var(--line);
}
.tbl td { padding: 8px 6px; border-bottom: 1px solid var(--line); }
.tbl tr:last-child td { border-bottom: 0; }
.tbl .num { text-align: right; white-space: nowrap; }

.bars { display: grid; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 44px 1fr 62px; align-items: center; gap: 8px; }
.bar-day { font-size: 11.5px; color: var(--muted); }
.bar-track { height: 9px; background: var(--glass-2); border-radius: 6px; overflow: hidden; }
.bar { height: 100%; background: var(--grad); border-radius: 6px; }
.bar-val { font-size: 12px; text-align: right; color: var(--muted); }

/* ---- the quick buttons on a person's credit ---- */
.quickrow { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.quick { padding: 12px 4px; font-size: 15px; }
.log { display: grid; gap: 2px; }
.logrow { display: flex; align-items: center; justify-content: space-between;
  gap: 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.logrow:last-child { border-bottom: 0; }
.lg-what { font-size: 14px; font-weight: 600; }
.lg-when { font-size: 11.5px; color: var(--muted); margin-top: 1px; }
.lg-amt { font-weight: 800; white-space: nowrap; }

/* ---- segmented control ---- */
.seg { display: flex; gap: 6px; background: var(--glass); border: 1px solid var(--line);
  border-radius: 14px; padding: 5px; margin-bottom: 12px; }
.seg-btn { flex: 1; background: none; box-shadow: none; color: var(--muted);
  border-radius: 10px; min-height: 38px; padding: 8px; font-size: 13.5px; }
.seg-btn.on { background: var(--grad); color: #fff; }

/* ---- the sell sheet ---- */
.sheet { position: fixed; inset: 0; z-index: 60; }
.sheet-scrim { position: absolute; inset: 0; background: rgba(3, 8, 22, .6);
  opacity: 0; transition: opacity .18s ease; }
.sheet-panel {
  position: absolute; left: 0; right: 0; bottom: 0;
  max-width: 640px; margin: 0 auto;
  background: #0d1734; border-top: 1px solid var(--line);
  border-radius: 22px 22px 0 0; padding: 10px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  transform: translateY(100%); transition: transform .2s ease;
  max-height: 92vh; overflow-y: auto;
}
.sheet.open .sheet-scrim { opacity: 1; }
.sheet.open .sheet-panel { transform: translateY(0); }
.sheet-grab { width: 40px; height: 4px; border-radius: 3px; background: var(--line);
  margin: 4px auto 12px; }
.sell-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sell-name { font-size: 19px; font-weight: 800; letter-spacing: -0.02em; }
.sell-total { font-size: 26px; font-weight: 800; letter-spacing: -0.03em; }
.qty-row { display: flex; align-items: center; justify-content: center; gap: 18px; margin: 16px 0; }
.qty-btn { width: 58px; height: 52px; font-size: 24px; background: var(--glass-2);
  border: 1px solid var(--line); box-shadow: none; }
.qty-n { font-size: 30px; font-weight: 800; min-width: 46px; text-align: center; }
.picklist { max-height: 34vh; overflow-y: auto; margin-top: 8px;
  border: 1px solid var(--line); border-radius: 13px; }
.pick {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  width: 100%; background: none; box-shadow: none; color: var(--ink);
  border-radius: 0; border-bottom: 1px solid var(--line); text-align: left; font-weight: 600;
}
.pick:last-child { border-bottom: 0; }
.pick.on { background: rgba(63, 179, 232, .18); }
.pick-bal { font-weight: 800; color: var(--muted); }
.pick-bal.neg { color: var(--bad); }
#who-wrap .lbl { margin-top: 4px; }

/* ---- scanning ---- */
.scanbtn { font-size: 16px; padding: 15px; }
.scanbox { position: relative; border-radius: 14px; overflow: hidden; background: #000;
  aspect-ratio: 4 / 3; }
.scanbox video { width: 100%; height: 100%; object-fit: cover; }
.scan-line { position: absolute; left: 8%; right: 8%; top: 50%; height: 2px;
  background: rgba(255, 90, 90, .9); box-shadow: 0 0 12px rgba(255, 90, 90, .8); }

/* ---- the tab bar ---- */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  display: flex; max-width: 640px; margin: 0 auto;
  background: rgba(8, 15, 38, .92);
  -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px);
  border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tab {
  flex: 1; background: none; box-shadow: none; border-radius: 0;
  color: var(--muted); font-size: 11px; font-weight: 700;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px; min-height: var(--tabbar-h);
}
.tab.on { color: #fff; }
.tab-icon { font-size: 21px; line-height: 1; }

/* ---- toast ---- */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + 18px);
  transform: translateX(-50%); z-index: 80;
  background: rgba(13, 23, 52, .97); border: 1px solid var(--line);
  border-radius: 13px; padding: 11px 16px; font-size: 14px; font-weight: 600;
  max-width: 90vw; text-align: center; box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
}
.toast.bad { border-color: rgba(255, 122, 122, .5); color: #ffc9c9; }
