/* WINEHUB Stock — mobile-first */
:root {
  --wine: #722f37; --wine-dark: #4a1f24; --gold: #c9a227;
  --ink: #2b2420; --muted: #8a7f78; --bg: #f6f3f1; --card: #ffffff;
  --ok: #2e7d32; --err: #c62828; --line: #e8e2de;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  background: var(--bg); color: var(--ink); font-size: 15px;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }
.muted { color: var(--muted); font-size: 13px; }
.error { color: var(--err); font-size: 14px; margin-top: 10px; text-align: center; }

/* ---------- brand ---------- */
.brand { font-size: 26px; font-weight: 800; }
.brand.small { font-size: 17px; }
.brand .b1 { color: var(--wine-dark); }
.brand .b2 { color: var(--gold); }
.brand .b3 { color: var(--muted); font-size: .55em; font-weight: 600; }

/* ---------- login ---------- */
.login-view {
  min-height: 100dvh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(160deg, #fdfbfa 0%, #f1e8e6 100%);
}
.login-card {
  width: 100%; max-width: 360px; background: var(--card); border-radius: 16px;
  padding: 28px 22px; box-shadow: 0 8px 30px rgba(74, 31, 36, .12); text-align: center;
}
.login-sub { color: var(--muted); margin: 6px 0 18px; }
.login-card input {
  width: 100%; margin-bottom: 10px;
}

/* ---------- inputs & buttons ---------- */
input, select {
  width: 100%; padding: 12px 14px; border: 1px solid var(--line);
  border-radius: 10px; font-size: 15px; background: #fff; color: var(--ink);
}
input:focus, select:focus { outline: 2px solid var(--wine); border-color: var(--wine); }
.btn {
  border: 1px solid var(--line); background: #fff; color: var(--ink);
  padding: 11px 16px; border-radius: 10px; font-size: 15px; font-weight: 600;
  cursor: pointer; touch-action: manipulation;
}
.btn.primary { background: var(--wine); border-color: var(--wine); color: #fff; }
.btn.ghost { background: transparent; }
.btn.wide { width: 100%; }
.btn.big { padding: 16px; font-size: 17px; }
.btn:active { transform: scale(.98); }
.btn[disabled] { opacity: .5; }
.icon-btn {
  background: none; border: none; font-size: 20px; color: var(--wine);
  padding: 6px 10px; cursor: pointer;
}

/* ---------- shell ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center;
  gap: 10px; padding: 10px 12px; background: #fff; border-bottom: 1px solid var(--line);
  padding-top: calc(10px + env(safe-area-inset-top));
}
.topbar select { flex: 1; padding: 8px 10px; font-size: 14px; }
.role-banner {
  background: #fff6e5; color: #8a6d1a; font-size: 13px; padding: 8px 14px;
  border-bottom: 1px solid #f0e3bd;
}
main { padding: 14px 12px 90px; max-width: 640px; margin: 0 auto; }
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: #fff; border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom);
}
.tab {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  border: none; background: none; font-size: 19px; padding: 8px 0 6px;
  color: var(--muted); cursor: pointer;
}
.tab span { font-size: 11px; font-weight: 600; }
.tab.active { color: var(--wine); }

/* ---------- scan ---------- */
.scanner-box { margin-bottom: 12px; }
#scanner, #modal-scanner {
  width: 100%; min-height: 240px; background: #000; border-radius: 12px;
  overflow: hidden; margin-bottom: 8px;
}
#scanner video, #modal-scanner video { width: 100% !important; border-radius: 12px; }
.scan-controls {
  display: flex; align-items: center; gap: 10px; margin: 8px 0;
}
.scan-controls input[type=range] { flex: 1; accent-color: var(--wine); }
.scan-controls .btn.torch { padding: 8px 12px; }
.scan-hint { text-align: center; margin: 6px 0 2px; }
.or { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0 8px; }
.searchrow { display: flex; gap: 8px; margin-bottom: 10px; }
.searchrow .btn { flex-shrink: 0; }

/* ---------- cards & lists ---------- */
.card {
  background: var(--card); border-radius: 14px; padding: 16px;
  box-shadow: 0 2px 10px rgba(74, 31, 36, .07); margin-top: 14px;
}
.card.slim { padding: 12px 16px; margin-top: 0; margin-bottom: 12px; }
.card h2 { font-size: 18px; color: var(--wine-dark); margin-bottom: 2px; }
.list { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }
.list.slim { gap: 4px; }
.item {
  background: var(--card); border-radius: 12px; padding: 12px 14px;
  box-shadow: 0 1px 6px rgba(74, 31, 36, .06); cursor: pointer;
}
.item .t { font-weight: 600; }
.item .s { color: var(--muted); font-size: 13px; margin-top: 2px; }
.item .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.qty-badge {
  font-weight: 700; font-size: 16px; color: var(--wine); white-space: nowrap;
}
.pill {
  display: inline-block; font-size: 11px; font-weight: 700; padding: 2px 8px;
  border-radius: 99px; text-transform: uppercase;
}
.pill.active { background: #e8f2e9; color: var(--ok); }
.pill.fulfilled { background: #e7ecf5; color: #2f5391; }
.pill.cancelled { background: #f5e7e7; color: var(--err); }
.pill.in { background: #e8f2e9; color: var(--ok); }
.pill.out { background: #f5e7e7; color: var(--err); }
.pill.adjust { background: #f3edda; color: #8a6d1a; }
.item .actions-inline { display: flex; gap: 6px; margin-top: 8px; }
.item .actions-inline .btn { padding: 6px 10px; font-size: 13px; }

/* ---------- stock table ---------- */
.stock-table { width: 100%; border-collapse: collapse; margin-top: 10px; font-size: 14px; }
.stock-table th {
  text-align: right; color: var(--muted); font-size: 12px; font-weight: 600;
  padding: 4px 6px; border-bottom: 1px solid var(--line);
}
.stock-table th:first-child, .stock-table td:first-child { text-align: left; }
.stock-table td { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: right; }
.stock-table tr.sel td { background: #faf4ee; font-weight: 700; }

/* ---------- product actions ---------- */
.actions { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.btn.act { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 10px 4px; }
.btn.act small { font-weight: 400; color: var(--muted); font-size: 10px; }
.btn.act.in { border-color: #bcd9be; }
.btn.act.out { border-color: #e3bcbc; }
.rowline { display: flex; gap: 8px; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.rowline select { max-width: 45%; }
.export-row { display: flex; align-items: center; justify-content: space-between; }
.btn.small { padding: 6px 12px; font-size: 13px; }
#sm-export-row { margin-top: 6px; }
#sm-export-day { flex: 1; }

h3 { font-size: 15px; color: var(--wine-dark); margin: 18px 0 4px; }

/* ---------- assign barcode: prodotto selezionato ben visibile ---------- */
.mb-product {
  background: #faf4ee; border: 1px solid #eadfd2;
  border-left: 4px solid var(--wine); border-radius: 10px; padding: 10px 12px;
}
.mb-product .name { font-weight: 700; font-size: 17px; color: var(--wine-dark); }
.mb-product .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.mb-product .sub.warn { color: #8a6d1a; }
.mb-product.empty {
  color: var(--muted); font-size: 14px; font-style: italic;
  border-left-color: var(--line);
}

/* ---------- modals ---------- */
.backdrop {
  position: fixed; inset: 0; background: rgba(43, 36, 32, .45); z-index: 50;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal {
  background: #fff; border-radius: 18px 18px 0 0; width: 100%; max-width: 560px;
  padding: 20px 18px calc(20px + env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; max-height: 88dvh; overflow-y: auto;
}
.modal h3 { margin: 0; font-size: 17px; }
.modal-btns { display: flex; gap: 10px; margin-top: 6px; }
.modal-btns .btn { flex: 1; }

/* ---------- inventory review ---------- */
.tab { position: relative; }
.tab-badge {
  position: absolute; top: 4px; right: 50%; transform: translateX(18px);
  background: var(--err); color: #fff; font-size: 10px; font-weight: 700;
  min-width: 16px; height: 16px; border-radius: 8px; padding: 0 4px;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}
.pill.pending { background: #f3edda; color: #8a6d1a; }
.pill.approved { background: #e8f2e9; color: var(--ok); }
.pill.rejected { background: #f5e7e7; color: var(--err); }
.diff { font-weight: 800; font-size: 18px; }
.diff.pos { color: var(--ok); }
.diff.neg { color: var(--err); }
.diff.zero { color: var(--muted); }
.btn.danger { border-color: #e3bcbc; color: var(--err); }
.approval-note {
  background: #f3edda; color: #8a6d1a; border-radius: 8px;
  padding: 8px 10px; font-size: 12px;
}
.approval-note.warn { background: #fdecea; color: #b3261e; }
.discrepancy {
  display: flex; align-items: stretch; gap: 6px; margin: 4px 0 2px;
}
.disc-col {
  flex: 1; background: #faf4ee; border-radius: 10px; padding: 8px 4px;
  text-align: center; display: flex; flex-direction: column; gap: 2px;
}
.disc-col span { font-size: 11px; color: var(--muted); text-transform: uppercase; }
.disc-col b { font-size: 19px; }
.disc-col.arrow {
  flex: 0 0 auto; background: none; justify-content: center; color: var(--muted);
  font-size: 18px; padding: 8px 2px;
}
.disc-col.pos { background: #e8f2e9; } .disc-col.pos b { color: var(--ok); }
.disc-col.neg { background: #fdecea; } .disc-col.neg b { color: var(--err); }
.disc-col.zero b { color: var(--muted); }
.mc-h { margin: 14px 0 6px; font-size: 14px; }
.moves { display: flex; flex-direction: column; gap: 4px; max-height: 34dvh; overflow-y: auto; }
.move {
  border: 1px solid var(--line); border-radius: 8px; padding: 7px 10px; font-size: 13px;
}
.move-main { display: flex; justify-content: space-between; gap: 8px; font-weight: 600; }
.move-qty.pos { color: var(--ok); }
.move-qty.neg { color: var(--err); }
.move-qty.zero { color: var(--muted); }
.move-sub { color: var(--muted); font-size: 12px; margin-top: 2px; }
.reviewed { flex: 1; font-size: 13px; color: var(--muted); align-self: center; }

/* ---------- toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 84px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 99px;
  font-size: 14px; z-index: 99; max-width: 90vw; text-align: center;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .25);
}
.toast.ok { background: var(--ok); }
.toast.err { background: var(--err); }

@media (min-width: 700px) {
  .backdrop { align-items: center; }
  .modal { border-radius: 18px; }
}

/* selettore sotto-locazione (conto vendita) */
.topbar #location-select { flex: 1; max-width: 45%; }
.loc-badge {
  display: inline-block; background: #f3edda; color: #8a6d1a; font-size: 11px;
  font-weight: 700; padding: 2px 8px; border-radius: 99px; margin-left: 6px;
}
