/* LFM Inventory — Loganville Family Medicine
   Brand: navy #253551 / deep #022A4D, sky #31A7F5, orange CTA #FF792C */

:root {
  --bg: #F2F2EF;
  --surface: #ffffff;
  --ink: #1c2b33;
  --muted: #5a6b75;
  --border: #d8ddd8;
  --primary: #253551;
  --primary-dark: #022A4D;
  --primary-soft: #e8eef5;
  --accent: #31A7F5;
  --accent-soft: #e5f5fe;
  --cta: #FF792C;
  --cta-dark: #e66a22;
  --danger: #b33a3a;
  --danger-soft: #fceaea;
  --warn: #b8860b;
  --warn-soft: #fff6e8;
  --low: #c45c26;
  --low-soft: #fff1e8;
  --shadow: 0 1px 3px rgba(2, 42, 77, 0.08), 0 4px 12px rgba(2, 42, 77, 0.04);
  --radius: 12px;
  --tap: 48px;
  --nav-h: 64px;
  --header-h: 64px;
  --max: 960px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { 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(--bg);
  min-height: 100dvh;
  padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; }
.muted { color: var(--muted); }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0,0,0,0); border: 0;
}

/* Header — white like clinic website, logo upper-left */
.app-header {
  position: sticky; top: 0; z-index: 40;
  background: #ffffff; color: var(--primary);
  height: var(--header-h);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(0,0,0,0.04);
}
.header-inner {
  max-width: var(--max); margin: 0 auto;
  height: 100%; padding: 0 12px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--primary); text-decoration: none; min-width: 0; }
.brand:hover { text-decoration: none; opacity: 0.92; }
.brand-app-label {
  font-size: 13px; font-weight: 700; color: var(--primary);
  white-space: nowrap; letter-spacing: -0.01em;
}
.logo-mark {
  position: relative;
  background: linear-gradient(145deg, #ffffff 0%, #e8eef5 100%);
  color: var(--primary);
  font-weight: 850; font-size: 14px; letter-spacing: 0.06em;
  width: 40px; height: 40px; border-radius: 12px;
  display: grid; place-items: center;
  box-shadow: 0 2px 8px rgba(2, 42, 77, 0.22);
  border: 1px solid rgba(255,255,255,0.72);
  overflow: hidden;
}
.logo-mark::after {
  content: "+";
  position: absolute; top: 2px; right: 5px;
  color: var(--accent); font-size: 12px; line-height: 1; font-weight: 900;
}
.logo-mark span { position: relative; z-index: 1; }
.logo-mark.sm { width: 36px; height: 36px; font-size: 12px; border-radius: 10px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.15; }
.brand-text strong { font-size: 15px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; opacity: 0.85; }

.app-main {
  max-width: var(--max); margin: 0 auto;
  padding: 16px 12px 24px;
}
.loading-state { padding: 40px; text-align: center; color: var(--muted); }

/* Bottom nav (mobile) / top-ish for desktop via media */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-around; align-items: stretch;
  box-shadow: 0 -2px 10px rgba(2,42,77,0.06);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600;
  text-decoration: none; min-height: var(--nav-h); -webkit-tap-highlight-color: transparent;
}
.nav-item:hover { text-decoration: none; color: var(--primary); background: var(--primary-soft); }
.nav-item.active { color: var(--primary); }
.nav-icon { font-size: 18px; line-height: 1; }
.nav-scan .nav-icon {
  background: var(--primary); color: #fff;
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center; font-size: 14px;
}
.nav-scan.active .nav-icon { background: var(--primary-dark); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: var(--tap); padding: 0 16px;
  border: 1px solid transparent; border-radius: 10px;
  font-weight: 600; cursor: pointer; text-decoration: none;
  transition: background 0.12s, border-color 0.12s, transform 0.05s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: #fff; }
.btn-accent { background: var(--cta); color: #fff; }
.btn-accent:hover { background: var(--cta-dark); color: #fff; text-decoration: none; }
.btn-sky { background: var(--accent); color: #fff; }
.btn-sky:hover { background: #2496e0; color: #fff; text-decoration: none; }
.btn-danger { background: var(--danger-soft); color: var(--danger); border-color: #f0c4c4; }
.btn-danger:hover { background: #f8d9d9; text-decoration: none; }
.btn-ghost { background: transparent; color: var(--ink); border-color: var(--border); }
.btn-ghost:hover { background: var(--bg); text-decoration: none; color: var(--ink); }
.btn-sm { min-height: 36px; padding: 0 12px; font-size: 14px; border-radius: 8px; }
.btn-lg { min-height: 52px; font-size: 17px; }
.btn-block { width: 100%; }
.btn-icon {
  width: var(--tap); min-width: var(--tap); padding: 0;
}
.app-header .btn-ghost { color: var(--primary); border-color: var(--border); }
.app-header .btn-ghost:hover { background: var(--primary-soft); color: var(--primary); }

/* Forms */
.input, .select, .textarea {
  width: 100%; min-height: var(--tap);
  padding: 10px 14px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--surface); color: var(--ink);
}
.input:focus, .select:focus, .textarea:focus {
  outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent);
}
.textarea { min-height: 88px; resize: vertical; }
label { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.field { margin-bottom: 14px; }
.field-row { display: grid; gap: 12px; }
.hint { font-size: 13px; color: var(--muted); margin-top: 4px; }
.form-error { color: var(--danger); font-weight: 600; margin: 8px 0; }
.form-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }

/* Cards / lists */
.page-title {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 10px; margin: 0 0 14px;
}
.page-title h1 { margin: 0; font-size: 1.35rem; }
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.toolbar .search-wrap { flex: 1 1 180px; min-width: 0; position: relative; }
.toolbar .filters { display: flex; flex-wrap: wrap; gap: 8px; flex: 1 1 200px; }

.stat-pills { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.pill {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 999px; padding: 8px 14px; font-size: 14px; font-weight: 600;
  box-shadow: var(--shadow);
}
.pill.low { background: var(--low-soft); border-color: #f0c9b0; color: var(--low); }
.pill.ok { background: var(--accent-soft); border-color: #b3dffb; color: #1a7ab8; }

.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.card + .card { margin-top: 10px; }

.item-list { list-style: none; margin: 0; padding: 0; }

/* Swipe-right to reveal Delete (iOS Mail style, mirrored) */
.swipe-row {
  position: relative;
  overflow: hidden;
  border-bottom: 1px solid var(--border);
  background: var(--danger);
  touch-action: pan-y;
}
.swipe-row:last-child { border-bottom: none; }
.swipe-row.low { /* low marker on content */ }
.swipe-delete {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 88px;
  border: none;
  background: var(--danger);
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  z-index: 0;
}
.swipe-delete:active { background: #9a2f2f; }
.swipe-content.item-row,
.item-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px 10px;
  padding: 14px 14px;
  align-items: center;
  cursor: pointer;
  text-decoration: none; color: inherit;
  min-height: var(--tap);
  background: var(--surface);
  position: relative;
  z-index: 1;
  transition: transform 0.22s ease;
  will-change: transform;
  touch-action: pan-y;
}
.swipe-row.low .swipe-content {
  box-shadow: inset 4px 0 0 var(--low);
}
.item-row:hover, .item-row:focus-visible {
  background: var(--primary-soft); outline: none; text-decoration: none;
}
.item-main { min-width: 0; }
.item-name { font-weight: 650; font-size: 15px; }
.item-meta { font-size: 13px; color: var(--muted); margin-top: 2px; }
.item-qty {
  text-align: right; font-weight: 700; font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.item-qty.low { color: var(--low); }
.drag-handle {
  width: 28px; height: 40px; display: grid; place-items: center;
  color: var(--muted); cursor: grab; touch-action: none;
  font-size: 14px; letter-spacing: -2px; user-select: none;
}
.drag-handle:active { cursor: grabbing; }
.item-list.reordering .swipe-content { transition: none; }
.item-list .ghost { opacity: 0.4; }

.empty-state {
  text-align: center; padding: 36px 16px; color: var(--muted);
}
.empty-state strong { display: block; color: var(--ink); margin-bottom: 6px; }

/* Desktop table */
.desktop-only { display: none; }
.mobile-only { display: block; }
table.items-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
  background: var(--surface);
}
table.items-table th, table.items-table td {
  padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.items-table th {
  font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em;
  color: var(--muted); background: #f7f7f4; position: sticky; top: 0;
}
table.items-table tr:hover td { background: var(--primary-soft); }
table.items-table tr.low td:first-child { box-shadow: inset 4px 0 0 var(--low); }
.qty-cell.low { color: var(--low); font-weight: 700; }

/* Detail */
.detail-card { padding: 18px; }
.detail-name { margin: 0 0 4px; font-size: 1.4rem; }
.detail-meta { color: var(--muted); margin-bottom: 16px; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 18px;
}
.detail-stat {
  background: var(--bg); border-radius: 10px; padding: 12px;
}
.detail-stat .label { font-size: 12px; color: var(--muted); font-weight: 600; }
.detail-stat .value { font-size: 1.4rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.detail-stat .value.low { color: var(--low); }
.action-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 8px; }
.action-btns .btn { flex: 1 1 120px; }

/* Activity */
.activity-list { list-style: none; margin: 0; padding: 0; }
.activity-item {
  display: grid; grid-template-columns: auto 1fr auto; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border); align-items: start;
}
.activity-item:last-child { border-bottom: none; }
.activity-action {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 4px 8px; border-radius: 6px; background: var(--primary-soft); color: var(--primary);
  white-space: nowrap;
}
.activity-action.use { background: var(--accent-soft); color: #1a7ab8; }
.activity-action.receive { background: #e8f8ee; color: #1f7a45; }
.activity-action.edit { background: #eef0f2; color: var(--muted); }
.activity-action.deactivate { background: #eee; color: #666; }
.activity-body { min-width: 0; }
.activity-title { font-weight: 600; font-size: 14px; }
.activity-sub { font-size: 12px; color: var(--muted); margin-top: 2px; }
.activity-when { font-size: 12px; color: var(--muted); white-space: nowrap; text-align: right; }

/* Scanner */
.scanner-wrap {
  overflow: hidden; border-radius: 10px; background: #000;
  min-height: 240px; position: relative;
}
.scanner-wrap video { width: 100%; display: block; }
.scanner-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom, 0px));
  transform: translateX(-50%);
  background: var(--ink); color: #fff;
  padding: 12px 18px; border-radius: 10px; font-weight: 600;
  z-index: 100; max-width: calc(100% - 24px); box-shadow: var(--shadow);
}
.toast[hidden] { display: none !important; }
.toast.ok { background: var(--primary); }
.toast.err { background: var(--danger); }

/* Modal */
.modal {
  position: fixed; inset: 0; z-index: 80;
  display: flex; align-items: flex-end; justify-content: center;
}
.modal[hidden] { display: none !important; }
.modal-backdrop {
  position: absolute; inset: 0; background: rgba(2, 42, 77, 0.45);
}
.modal-sheet {
  position: relative; width: 100%; max-width: 480px;
  background: var(--surface); border-radius: 16px 16px 0 0;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -8px 30px rgba(0,0,0,0.15);
}
.modal-sheet h2 { margin: 0 0 6px; font-size: 1.15rem; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 14px; }

/* Login — navy brand gradient */
.login-body {
  display: grid; place-items: center; min-height: 100dvh;
  padding: 24px; background: linear-gradient(160deg, #022A4D 0%, #253551 55%, #1a4060 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: var(--surface);
  border-radius: 16px; padding: 28px 22px; box-shadow: 0 12px 40px rgba(0,0,0,0.22);
}
.login-brand { text-align: left; margin-bottom: 22px; }
.login-brand .logo-mark { margin: 0 auto 12px; width: 56px; height: 56px; font-size: 18px; }
.login-brand h1 { margin: 0; font-size: 1.3rem; letter-spacing: -0.01em; }
.login-form label { margin-top: 4px; }
.pin-input { font-size: 1.25rem; letter-spacing: 0.15em; text-align: center; }
.login-hint { text-align: center; font-size: 13px; margin: 18px 0 0; }

.back-link {
  display: inline-flex; align-items: center; gap: 4px;
  font-weight: 600; margin-bottom: 10px; min-height: 36px;
}

.checkbox-row {
  display: flex; align-items: center; gap: 10px;
  min-height: var(--tap); cursor: pointer; font-weight: 600;
}
.checkbox-row input { width: 22px; height: 22px; accent-color: var(--primary); }


/* Badges & qty helpers */
.badge-low {
  display: inline-block;
  margin-top: 4px;
  font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  text-transform: uppercase;
  background: var(--low-soft); color: var(--low);
  border: 1px solid #f0c9b0;
  border-radius: 999px; padding: 2px 8px;
}
.item-qty .unit { font-size: 12px; font-weight: 500; color: var(--muted); margin-top: 2px; }
.qty-big {
  font-size: 2rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.1;
}
.qty-big.low { color: var(--low); }

/* USB wedge scan fields */
.wedge-box { margin-bottom: 8px; }
.wedge-box label { margin-bottom: 6px; }
.wedge-hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; }

/* Detail page (matches app.js markup) */
.detail-header {
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px;
  margin: 0 0 14px;
}
.detail-header h1 { margin: 0; font-size: 1.45rem; flex: 1 1 auto; }
.detail-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; box-shadow: var(--shadow);
  margin-bottom: 16px;
}
.detail-field { min-width: 0; }
.detail-field.span-2 { grid-column: 1 / -1; }
.detail-label { font-size: 12px; font-weight: 600; color: var(--muted); margin-bottom: 2px; }
.detail-value { font-weight: 650; word-break: break-word; }

.action-panel {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.action-panel h2 { margin: 0 0 12px; font-size: 1.05rem; }
.qty-stepper {
  display: grid; grid-template-columns: var(--tap) 1fr var(--tap);
  gap: 8px; align-items: center; margin-bottom: 12px;
}
.qty-stepper .input { text-align: center; font-size: 1.25rem; font-weight: 700; }

/* Scan page */
.scan-panel { max-width: 560px; }
.scan-status { font-weight: 600; color: var(--primary); min-height: 1.4em; }

/* Table extras */
.table-wrap { overflow-x: auto; }
.drag-col { width: 36px; }
.table-delete { white-space: nowrap; }

/* Drag / swipe states */
.swipe-row.open .swipe-content { transform: translateX(88px); }
.dragging { opacity: 0.55; }
.drag-over { outline: 2px dashed var(--accent); outline-offset: -2px; }
.item-list .dragging, table.items-table tr.dragging { background: var(--primary-soft); }

/* Desktop / Windows Chrome & Edge */
@media (min-width: 768px) {
  :root { --max: 1040px; }
  body { padding-bottom: 0; }
  .bottom-nav {
    position: sticky; top: var(--header-h); bottom: auto;
    height: 52px; border-top: none; border-bottom: 1px solid var(--border);
    box-shadow: none; max-width: none;
  }
  .nav-item { flex-direction: row; gap: 8px; font-size: 14px; min-height: 52px; }
  .nav-scan .nav-icon { width: 28px; height: 28px; font-size: 12px; }
  .app-main { padding: 20px 20px 40px; }
  .page-title h1 { font-size: 1.6rem; }
  .field-row { grid-template-columns: 1fr 1fr; }
  .field-row.three { grid-template-columns: 1fr 1fr 1fr; }
  .desktop-only { display: block; }
  .mobile-only { display: none; }
  .item-list.mobile-only { display: none; }
  .modal { align-items: center; }
  .modal-sheet {
    border-radius: 16px; padding: 24px;
    margin: 16px;
  }
  .toast { bottom: 24px; }
  .detail-grid { grid-template-columns: repeat(3, 1fr); }
  .action-btns { max-width: 420px; }
  table.items-table { font-size: 15px; }
  .toolbar { align-items: center; }
}

@media (min-width: 1024px) {
  .brand-sub { display: inline; }
}


/* PWA install / Add to Home Screen hint */
.install-hint {
  position: sticky;
  top: 0;
  z-index: 60;
  background: linear-gradient(135deg, #022A4D 0%, #253551 70%, #31A7F5 160%);
  color: #fff;
  padding: 12px 14px;
  box-shadow: 0 2px 10px rgba(2, 42, 77, 0.4);
}
.install-hint[hidden] { display: none !important; }
.install-hint-inner {
  max-width: var(--max, 960px);
  margin: 0 auto;
  position: relative;
  padding-right: 36px;
}
.install-hint strong { display: block; font-size: 16px; margin-bottom: 4px; }
.install-hint p { margin: 2px 0 0; font-size: 13px; opacity: 0.95; line-height: 1.4; }

.install-hint .install-hint-title-ios { display: none; }
.install-hint .install-hint-title-desk { display: none; }
.install-hint.is-ios .install-hint-title-ios { display: block; }
.install-hint.is-desk .install-hint-title-desk { display: block; }
.install-hint .install-hint-ios { display: none; }
.install-hint .install-hint-desk { display: none; }
.install-hint.is-ios .install-hint-ios { display: block; }
.install-hint.is-desk .install-hint-desk { display: block; }
.install-hint.is-ios #install-hint-btn { display: none !important; }
.install-hint-steps {
  margin: 8px 0 0;
  padding-left: 1.2em;
  font-size: 13px;
  line-height: 1.45;
  opacity: 0.98;
}
.install-hint-steps li { margin: 4px 0; }
.install-hint .share-glyph {
  display: inline-block;
  padding: 0 4px;
  font-weight: 700;
}
.install-hint-dismiss {
  position: absolute;
  right: 0; top: 0;
  width: 36px; height: 36px;
  border: none; background: transparent;
  color: #fff; font-size: 22px; line-height: 1;
  cursor: pointer; border-radius: 8px;
}
.install-hint-dismiss:hover { background: rgba(255,255,255,0.15); }
.install-hint #install-hint-btn {
  margin-top: 8px;
  background: #fff;
  color: #253551;
  border: none;
}
html.standalone .install-hint { display: none !important; }

/* When launched from home screen, keep status-bar-friendly navy header flush */
@media all and (display-mode: standalone) {
  .install-hint { display: none !important; }
  body { background: #F2F2EF; }
  .app-header {
    padding-top: env(safe-area-inset-top, 0px);
  }
}


/* Clinic logo — never stretch; constrain ONE side only */
.brand-logo {
  display: block;
  object-fit: contain;
  object-position: left center;
  flex-shrink: 0;
  height: auto;
  width: auto;
}
.brand-logo-header {
  /* height only — width follows native ~3:1 ratio */
  height: 52px;
  width: auto;
  max-width: none;
}
.brand-logo-login {
  height: 80px;
  width: auto;
  max-width: none;
  margin: 0 0 16px 0;
}
.login-brand {
  text-align: left;
  margin-bottom: 22px;
}
.login-brand h1 {
  margin: 0;
  font-size: 1.25rem;
  color: var(--primary);
}
.app-header .brand-logo-header {
  flex-shrink: 0;
}


/* Desktop install instructions */
.install-hint-desk-block { display: none; }
.install-hint.is-desk .install-hint-desk-block { display: block; }
.install-hint.is-desk .install-hint-ios { display: none; }
.install-hint.is-ios .install-hint-desk-block { display: none; }
.install-hint-desk-steps { margin: 8px 0 10px; padding-left: 1.2rem; }
.install-hint-desk-steps li { margin: 4px 0; }

/* ── Accounts / users ─────────────────────────────────────────────────── */
.header-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.header-logout { margin: 0; }
.header-account { padding: 0 6px; }
.avatar {
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--primary); color: #fff; font-weight: 700; font-size: 14px;
  flex-shrink: 0;
}
.avatar-lg { width: 48px; height: 48px; font-size: 20px; }
@media (max-width: 400px) {
  .header-users { padding: 0 10px; }
  .brand-app-label { display: none; }
}
.login-form-title { margin: 0 0 4px; font-size: 1.1rem; color: var(--primary); }
.login-form-sub { margin: 0 0 14px; font-size: 14px; }
.login-form .field { margin-bottom: 12px; }
.section-h { margin: 0 0 12px; font-size: 1.05rem; }
.account-card { padding: 16px; }
.account-row { display: flex; align-items: center; gap: 12px; }
.account-actions { margin-top: 14px; }
.role-badge {
  display: inline-block; font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.02em; padding: 1px 7px; border-radius: 999px;
  background: var(--accent-soft); color: #1a7ab8; border: 1px solid #b3dffb;
}
.role-badge.role-admin { background: var(--primary-soft); color: var(--primary); border-color: #c5d2e3; }
.role-badge.role-inactive { background: var(--danger-soft); color: var(--danger); border-color: #f0c4c4; }
.user-list { list-style: none; margin: 0; padding: 0; }
.user-item {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 10px;
}
.user-item:last-child { border-bottom: 0; }
.user-item.inactive .user-main { opacity: 0.6; }
.user-main { display: flex; gap: 12px; align-items: flex-start; }
.user-text { min-width: 0; }
.user-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.activity-user { font-weight: 600; color: var(--primary); }
@media (min-width: 720px) {
  .user-item { flex-direction: row; align-items: center; justify-content: space-between; }
}
/* No drag handle (staff / reorder off): two-column rows */
.item-list[data-reorder="0"] .item-row { grid-template-columns: 1fr auto; }
.label-like { display: block; font-weight: 600; font-size: 14px; margin-bottom: 6px; }
.role-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.role-opt {
  display: flex; gap: 8px; align-items: flex-start; font-weight: 500; margin: 0;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; cursor: pointer;
  min-height: var(--tap); background: var(--surface);
}
.role-opt:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); }
.role-opt input { margin-top: 3px; accent-color: var(--primary); }
.role-opt small { font-size: 12px; }
/* Admin header has an extra "Users" button — shrink logo on narrow phones so nothing overlaps */
@media (max-width: 440px) {
  .app-header:has(.header-users) .brand-logo-header { height: 40px; }
  .app-header:has(.header-users) .brand-app-label { display: none; }
  .header-actions { gap: 4px; }
  .header-actions .btn-sm { padding: 0 9px; }
}
/* Activity rows: stack title line over meta line (time · who · reason) */
.activity-item { grid-template-columns: 1fr; gap: 4px; }

/* ── Reports ───────────────────────────────────────────────────────────── */
.report-controls label { margin-bottom: 8px; }
.preset-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip {
  min-height: 40px; padding: 0 14px; border-radius: 999px; font-weight: 600; font-size: 14px;
  border: 1px solid var(--border); background: var(--surface); color: var(--ink); cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }
.custom-range { margin-bottom: 4px; }
.report-actions .btn { flex: 1 1 150px; }
.report-period { margin: 4px 0 10px; font-size: 14px; }
.report-cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.report-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 12px 14px;
}
.report-card .v { font-size: 1.6rem; font-weight: 750; color: var(--primary); font-variant-numeric: tabular-nums; }
.report-card .l { font-size: 12px; font-weight: 600; color: var(--muted); }
.report-card.warn .v { color: var(--low); }
.report-h { margin: 22px 0 8px; display: flex; flex-wrap: wrap; align-items: baseline; gap: 8px; }
.report-table { width: 100%; border-collapse: collapse; font-size: 13.5px; min-width: 720px; }
.report-table th {
  position: sticky; top: 0; background: var(--primary); color: #fff; font-weight: 600;
  text-align: left; padding: 9px 10px; white-space: nowrap; cursor: pointer; user-select: none;
}
.report-table th.sorted { background: var(--primary-dark); }
.report-table td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.report-table .n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.report-table tr.low td { background: var(--low-soft); }
.report-table .sub, .reorder-qty .sub { font-size: 12px; color: var(--muted); }
.report-table-wrap { -webkit-overflow-scrolling: touch; }
.reorder-qty { text-align: right; white-space: nowrap; flex-shrink: 0; }
.flag { color: var(--danger); }
@media (min-width: 720px) { .report-cards { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 400px) { .bottom-nav .nav-item { font-size: 10px; } }

/* ── Expiry badges (amber ≤ 60 days, red ≤ 30 days / expired) ─────────── */
.badge-row { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.badge-row .badge-low { margin-top: 0; }
.badge-exp {
  display: inline-block; font-size: 11px; font-weight: 700; letter-spacing: 0.02em;
  border-radius: 999px; padding: 2px 8px; white-space: nowrap; text-transform: uppercase;
}
.badge-exp.amber { background: #fff4d6; color: #8a5a00; border: 1px solid #f1d58a; }
.badge-exp.red { background: var(--danger-soft); color: var(--danger); border: 1px solid #f0c4c4; }
.swipe-row.exp-amber .swipe-content { box-shadow: inset -4px 0 0 #e0a800; }
.swipe-row.exp-red .swipe-content, .swipe-row.exp-expired .swipe-content { box-shadow: inset -4px 0 0 var(--danger); }
.exp-row.amber { box-shadow: inset 4px 0 0 #e0a800; }
.exp-row.red { box-shadow: inset 4px 0 0 var(--danger); }
.detail-header .badge-exp { font-size: 12px; }

/* ── Scan-to-use banner ─────────────────────────────────────────────────── */
.scan-mode-note {
  background: var(--primary-soft); border: 1px solid #c5d2e3; color: var(--primary);
  border-radius: 10px; padding: 10px 12px; font-size: 14px;
}
.scan-banner {
  position: fixed; left: 8px; right: 8px; z-index: 120;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
  max-width: 560px; margin: 0 auto;
  background: var(--primary); color: #fff; border-radius: 16px;
  box-shadow: 0 10px 30px rgba(2, 42, 77, 0.35); overflow: hidden;
  animation: sb-in 0.18s ease-out;
}
.scan-banner[hidden] { display: none !important; }
@keyframes sb-in { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.scan-banner.low { background: #8a4a14; }
.scan-banner.out { background: var(--danger); }
.scan-banner.notfound { background: #3b4756; }
.scan-banner-inner { padding: 14px 14px 12px; display: flex; flex-direction: column; gap: 12px; }
.scan-banner-title { font-size: 1.15rem; font-weight: 750; line-height: 1.25; }
.scan-banner-left { font-size: 1rem; margin-top: 2px; opacity: 0.95; }
.scan-banner-left strong { font-size: 1.3rem; }
.scan-banner-note { margin-top: 6px; font-weight: 700; background: rgba(255,255,255,0.16); border-radius: 8px; padding: 4px 8px; display: inline-block; }
.scan-banner .badge-exp { margin-top: 6px; }
.scan-banner-actions { display: grid; grid-template-columns: 1.4fr 1fr auto; gap: 8px; }
.scan-banner .btn { min-height: 52px; font-size: 1.05rem; font-weight: 800; border-radius: 12px; }
.scan-undo { background: #fff; color: var(--primary); }
.scan-banner.low .scan-undo { color: #8a4a14; }
.scan-banner.out .scan-undo { color: var(--danger); }
.scan-more { background: var(--accent); color: #fff; }
.scan-more:disabled { opacity: 0.45; }
.scan-open { background: transparent; color: #fff; border: 1px solid rgba(255,255,255,0.5); padding: 0 14px; }
.scan-open:hover { color: #fff; text-decoration: none; }
.scan-banner-timer { height: 4px; background: rgba(255,255,255,0.7); transform-origin: left center; }
@media (min-width: 720px) { .scan-banner { bottom: 16px; } }
.activity-action.undo { background: #fff4d6; color: #8a5a00; }
.custom-range[hidden], .field-row[hidden] { display: none !important; }

/* ── Clickable status pills ─────────────────────────────────────────────── */
.stat-pills .pill-btn {
  font: inherit; font-size: 14px; font-weight: 650; cursor: pointer;
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--border); background: var(--surface);
  box-shadow: var(--shadow); -webkit-tap-highlight-color: transparent;
  transition: background .15s, box-shadow .15s, transform .05s, border-color .15s;
}
.stat-pills .pill-btn .pill-n { font-variant-numeric: tabular-nums; font-weight: 800; }
.pill-btn.low { background: var(--low-soft); border-color: #f0c9b0; color: var(--low); }
.pill-btn.ok { background: var(--accent-soft); border-color: #b3dffb; color: #1a7ab8; }
.pill-btn.exp { background: #fff4d6; border-color: #f1d58a; color: #8a5a00; }
.pill-btn:hover { filter: brightness(0.97); box-shadow: 0 2px 8px rgba(2,42,77,.14); }
.pill-btn:active { transform: scale(0.97); }
.pill-btn:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.pill-btn[aria-pressed="true"].low { background: var(--low); border-color: var(--low); color: #fff; box-shadow: 0 0 0 3px rgba(196,92,38,.25); }
.pill-btn[aria-pressed="true"].ok { background: #1a7ab8; border-color: #1a7ab8; color: #fff; box-shadow: 0 0 0 3px rgba(49,167,245,.3); }
.pill-btn[aria-pressed="true"].exp { background: #b37700; border-color: #b37700; color: #fff; box-shadow: 0 0 0 3px rgba(224,168,0,.3); }
.pill-btn .pill-x { display: none; font-size: 16px; line-height: 1; margin-left: 2px; opacity: .9; }
.pill-btn[aria-pressed="true"] .pill-x { display: inline; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin: 4px 0 10px; }
.view-head h2 { margin: 0; font-size: 1.1rem; }
.btn-clear { min-height: 36px; padding: 0 12px; font-size: 14px; }

/* ── Desktop sidebar (≥ 900px) ──────────────────────────────────────────── */
.sidebar { display: none; }
@media (min-width: 900px) {
  :root { --sb-w: 252px; }
  body { padding-left: var(--sb-w); padding-bottom: 0; }
  .app-header, .bottom-nav { display: none !important; }
  .app-main { padding: 28px 32px 48px; max-width: 1180px; }
  .install-hint { margin-left: 0; }
  .scan-banner { left: calc(var(--sb-w) + 16px); bottom: 20px; }
  .toast { left: calc(50% + var(--sb-w) / 2); }
  .sidebar {
    display: flex; flex-direction: column;
    position: fixed; inset: 0 auto 0 0; width: var(--sb-w); z-index: 70;
    background: linear-gradient(180deg, #253551 0%, #1f2d46 100%);
    color: #dbe7f5; padding: 16px 14px 12px; overflow-y: auto; overscroll-behavior: contain;
    border-right: 1px solid rgba(255,255,255,.06);
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
  }
  .sb-brand { display: block; text-decoration: none; margin-bottom: 18px; }
  .sb-brand:hover { text-decoration: none; }
  .sb-logo-card {
    display: flex; align-items: center; justify-content: center;
    background: #fff; border-radius: 14px; padding: 12px 14px;
    box-shadow: 0 6px 18px rgba(0,0,0,.18);
  }
  .sb-logo-card img { display: block; width: 100%; max-width: 196px; height: auto; object-fit: contain; }
  .sb-app { display: block; text-align: center; font-size: 11.5px; letter-spacing: .08em; text-transform: uppercase; color: #9fb6d3; margin-top: 10px; font-weight: 650; }
  .sb-nav { display: flex; flex-direction: column; gap: 2px; }
  .sb-link {
    display: flex; align-items: center; gap: 12px; min-height: 42px; padding: 0 12px;
    border-radius: 10px; color: #dbe7f5; text-decoration: none; font-weight: 600; font-size: 14.5px;
    position: relative; transition: background .15s, color .15s;
  }
  .sb-link:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
  .sb-link:focus-visible, .sb-person:focus-visible, .sb-me-btn:focus-visible, .sb-add:focus-visible, .sb-me-main:focus-visible { outline: 2px solid #31A7F5; outline-offset: 1px; }
  .sb-link.active { background: rgba(49,167,245,.18); color: #fff; }
  .sb-link.active::before { content: ""; position: absolute; left: -14px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: #31A7F5; }
  .sb-link.active .sb-icon { color: #31A7F5; }
  .sb-icon { flex-shrink: 0; color: #9fb6d3; }
  .sb-link:hover .sb-icon { color: #fff; }
  .sb-badge {
    margin-left: auto; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px;
    background: #e5484d; color: #fff; font-size: 12px; font-weight: 800;
    display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums;
  }
  .sb-badge[hidden] { display: none; }
  .sb-people { margin-top: 20px; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); }
  .sb-section-head { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 8px 6px; }
  .sb-section-title { font-size: 11.5px; letter-spacing: .1em; text-transform: uppercase; color: #9fb6d3; font-weight: 750; text-decoration: none; }
  .sb-section-title:hover, .sb-section-title.active { color: #fff; text-decoration: none; }
  .sb-add {
    display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 700;
    color: #31A7F5; text-decoration: none; padding: 4px 8px; border-radius: 8px;
  }
  .sb-add .sb-icon { width: 14px; height: 14px; color: #31A7F5; }
  .sb-add:hover { background: rgba(49,167,245,.14); text-decoration: none; color: #7cc8fa; }
  .sb-group { margin-bottom: 10px; }
  .sb-group-label { font-size: 12px; color: #9fb6d3; font-weight: 650; margin: 6px 6px 4px; display: flex; justify-content: space-between; }
  .sb-group-label span { opacity: .7; }
  .sb-person {
    display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 10px;
    color: #e6eef8; text-decoration: none; font-size: 14px; font-weight: 550;
  }
  .sb-person:hover { background: rgba(255,255,255,.08); color: #fff; text-decoration: none; }
  .sb-person.selected { background: rgba(49,167,245,.18); color: #fff; }
  .sb-person.inactive .sb-person-name { opacity: .55; text-decoration: line-through; text-decoration-color: rgba(255,255,255,.35); }
  .sb-person-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .sb-avatar {
    width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    background: #3a5075; color: #fff; font-size: 11.5px; font-weight: 800; letter-spacing: .02em;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,.12);
  }
  .sb-avatar-lg { width: 38px; height: 38px; font-size: 14px; background: #31A7F5; }
  .sb-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
  .sb-dot.online { background: #3ecf8e; box-shadow: 0 0 0 3px rgba(62,207,142,.22); }
  .sb-dot.offline { background: #ef5350; box-shadow: 0 0 0 3px rgba(239,83,80,.18); }
  .sb-dot.inactive { background: #7d8ea6; box-shadow: none; }
  .sb-empty { font-size: 13px; color: #8ea5c2; padding: 4px 8px; font-style: italic; }
  .sb-me { margin-top: auto; padding-top: 14px; border-top: 1px solid rgba(255,255,255,.1); }
  .sb-me-main { display: flex; align-items: center; gap: 10px; padding: 6px; border-radius: 12px; text-decoration: none; color: #fff; }
  .sb-me-main:hover, .sb-me-main.active { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
  .sb-me-text { display: flex; flex-direction: column; min-width: 0; gap: 3px; }
  .sb-me-text strong { font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sb-role { align-self: flex-start; font-size: 10.5px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; padding: 2px 8px; border-radius: 999px; background: rgba(255,255,255,.14); color: #dbe7f5; }
  .sb-role.admin { background: rgba(49,167,245,.22); color: #bfe4fd; }
  .sb-me-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
  .sb-me-actions form { margin: 0; }
  .sb-me-btn {
    width: 100%; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 36px; border-radius: 9px; border: 1px solid rgba(255,255,255,.16);
    background: transparent; color: #dbe7f5; font: inherit; font-size: 12.5px; font-weight: 650;
    cursor: pointer; text-decoration: none;
  }
  .sb-me-btn .sb-icon { width: 16px; height: 16px; }
  .sb-me-btn:hover { background: rgba(255,255,255,.1); color: #fff; text-decoration: none; }
  .user-item.selected { background: var(--primary-soft); box-shadow: inset 4px 0 0 var(--accent); }
}
.user-item.selected { background: var(--primary-soft); box-shadow: inset 4px 0 0 var(--accent); }

/* ── Role hierarchy chips ───────────────────────────────────────────────── */
.role-badge.role-owner { background: #253551; color: #fff; border-color: #253551; }
.role-badge.role-manager { background: var(--primary-soft); color: var(--primary); border-color: #c5d2e3; }
.role-badge.role-staff { background: var(--accent-soft); color: #1a7ab8; border-color: #b3dffb; }
.role-choice { grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); }
.select-sm { min-height: 36px; padding: 4px 10px; font-size: 14px; width: auto; border-radius: 8px; }
.view-only { font-size: 13px; font-style: italic; align-self: center; }
@media (min-width: 900px) {
  .sb-role.owner { background: #31A7F5; color: #fff; }
  .sb-role.manager { background: rgba(49,167,245,.22); color: #bfe4fd; }
}

/* ── Password show/hide (eye) ───────────────────────────────────────────── */
.pw-wrap { position: relative; display: block; width: 100%; }
.pw-wrap .pw-input { width: 100%; padding-right: 52px; }
.pw-eye {
  position: absolute; top: 50%; right: 4px; transform: translateY(-50%);
  width: 44px; height: 44px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; background: transparent; color: var(--muted); border-radius: 10px; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation; padding: 0;
}
.pw-eye:hover { color: var(--primary); background: var(--primary-soft); }
.pw-eye:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.pw-eye[aria-pressed="true"] { color: var(--accent); }
.pw-dialog .modal-sheet { max-width: 420px; }
.pw-dialog .form-error { margin: 6px 0 0; }

/* ── Vendor & cost (Chief admins + Admins only) ─────────────────────────── */
.item-vendor { font-size: 12.5px; color: var(--primary); font-weight: 600; margin-top: 3px; font-variant-numeric: tabular-nums; }
.items-table .item-vendor { font-weight: 500; }
.admin-only-tag {
  display: inline-block; margin-left: 6px; padding: 1px 7px; border-radius: 999px;
  background: var(--primary-soft); color: var(--primary); font-size: 10.5px; font-weight: 700;
  letter-spacing: .02em; text-transform: none; vertical-align: middle;
}
.vendor-panel { border-top: 1px solid var(--border); padding-top: 12px; }
.vendor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 16px; margin-top: 6px; }
.vendor-grid .span-all { grid-column: 1 / -1; }
.vendor-grid .vk { font-size: 12px; color: var(--muted); font-weight: 600; }
.vendor-grid .vv { font-weight: 650; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.vendor-grid a { color: var(--primary); }
@media (min-width: 900px) { .vendor-grid { grid-template-columns: repeat(4, 1fr); } }
.vendor-fieldset {
  border: 1px solid var(--border); border-radius: var(--radius); padding: 10px 14px 4px; margin: 4px 0 14px;
  background: #fafbfc;
}
.vendor-fieldset legend { font-weight: 700; color: var(--primary); padding: 0 6px; font-size: 14px; }
.money-input { position: relative; }
.money-input > span { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--muted); font-weight: 600; pointer-events: none; }
.money-input .input { padding-left: 26px; }
.money-cards { margin-top: 10px; }
@media (min-width: 640px) { .money-cards { grid-template-columns: repeat(3, 1fr); } }
.report-table tfoot td { font-weight: 700; border-top: 2px solid var(--primary); background: var(--primary-soft); }
.vendor-group { margin-bottom: 10px; overflow: hidden; }
.vendor-group-h {
  display: flex; flex-wrap: wrap; gap: 4px 10px; align-items: baseline; justify-content: space-between;
  background: var(--primary-soft); color: var(--primary); padding: 10px 14px; border-bottom: 1px solid var(--border);
}
.vendor-group-h .sub, .vendor-group-h a { font-size: 13px; color: var(--primary); }
.vendor-subtotal, .vendor-grand {
  display: flex; justify-content: space-between; gap: 10px; align-items: baseline;
  padding: 10px 14px; font-variant-numeric: tabular-nums;
}
.vendor-subtotal { border-top: 1px solid var(--border); font-weight: 600; }
.vendor-grand { font-size: 1.05rem; font-weight: 700; color: var(--primary); border: 2px solid var(--primary); }

/* Required fields */
.req { color: #c62828; font-weight: 800; margin-left: 2px; }
.req-note { font-size: 12.5px; color: var(--muted); margin: 0 0 10px; }
.req-note .req { margin: 0 2px 0 0; }
.field-error { color: #c62828; font-size: 13px; font-weight: 600; margin: 5px 0 0; }
.input[aria-invalid="true"], .select[aria-invalid="true"] { border-color: #c62828; box-shadow: 0 0 0 3px rgba(198, 40, 40, 0.14); }
/* Only our own eye button: hide browser-native reveal/clear icons (Edge/IE) to avoid duplicates */
input::-ms-reveal, input::-ms-clear { display: none; }
.pw-wrap > .input:not([data-password-eye]) + .pw-eye { display: none !important; }

/* Presence on the Users screen (green online / red offline / grey deactivated) */
.avatar-wrap { position: relative; display: inline-flex; flex-shrink: 0; }
.presence-dot {
  position: absolute; right: -2px; bottom: -2px; width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid var(--surface); background: #9aa7b4;
}
.presence-dot.online { background: #2fb67c; }
.presence-dot.offline { background: #e53935; }
.presence-dot.inactive { background: #9aa7b4; }
.presence-text { font-weight: 600; }
.presence-text.online { color: #1f8f5f; }
.presence-text.offline { color: #c62828; }
.presence-text.inactive { color: var(--muted); }
.btn-danger-solid { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger-solid:hover { background: #962f2f; border-color: #962f2f; color: #fff; text-decoration: none; }
.confirm-dialog #cd-msg { line-height: 1.45; }
.form-info {
  background: var(--accent-soft); color: var(--primary-dark); border: 1px solid #bfe3fb;
  border-radius: 10px; padding: 10px 12px; font-weight: 600; margin: 0 0 12px; font-size: 14px;
}
.idle-dialog .modal-sheet { max-width: 420px; }
#idle-count { font-variant-numeric: tabular-nums; }

/* ── Phone sizing (<768px): larger, rem-based text that follows iOS Dynamic Type ──────
   On iOS, -apple-system-body sets the root size from the user's Text Size setting (17px default).
   Everywhere else the root is 17px. Desktop (≥768px) sizes are unchanged. */
@media (max-width: 767.98px) {
  html { font-size: 17px; }
  @supports (font: -apple-system-body) {
    html { font: -apple-system-body; }
  }
  body { font-size: 1rem; line-height: 1.45; }
  :root { --tap: 48px; --nav-h: 68px; }

  /* Lists */
  .item-row, .swipe-content.item-row { padding-top: 14px; padding-bottom: 14px; gap: 12px; }
  .item-name { font-size: 1.06rem; font-weight: 600; line-height: 1.3; }   /* ≈18px */
  .item-meta, .item-vendor { font-size: 0.9rem; line-height: 1.35; }     /* ≈15px */
  .item-qty { font-size: 1.35rem; font-weight: 800; }                    /* ≈23px */
  .item-qty .unit { font-size: 0.9rem; font-weight: 500; }
  .badge-low, .badge-exp, .role-badge { font-size: 0.8rem; padding: 3px 9px; }
  .badge-row { margin-top: 6px; gap: 6px; }

  /* Text */
  .hint, .muted, .wedge-hint, .sub, .detail-label, .activity-sub, .activity-when,
  .report-card .l, .report-table .sub, .reorder-qty .sub, .role-opt small, .login-hint,
  .install-hint p, .req-note, .field-error, .presence-text { font-size: 0.9rem; }
  .activity-title { font-size: 1rem; }
  .page-title h1 { font-size: 1.5rem; }
  .section-h { font-size: 1.15rem; }
  .detail-header h1 { font-size: 1.5rem; }
  .detail-value { font-size: 1.05rem; }
  label, .label-like { font-size: 0.95rem; }

  /* Controls: ≥17px text (no iOS zoom) and ≥48px tall */
  .btn { min-height: 48px; font-size: 1rem; padding: 0 18px; }
  .btn-sm { min-height: 44px; font-size: 0.95rem; padding: 0 14px; }
  .btn-lg { min-height: 54px; font-size: 1.06rem; }
  .input, .select, .textarea { min-height: 48px; font-size: max(16px, 1rem); }
  .pill, .chip { font-size: 0.9rem; min-height: 44px; padding: 10px 16px; }   /* ≈15px */
  .pill-row, .chips { gap: 10px; }
  .field { margin-bottom: 16px; }
  .user-actions { gap: 8px; }

  /* Bottom tab bar: bigger icons + 12–13px labels */
  .nav-item { font-size: 0.75rem; gap: 4px; }                           /* ≈13px */
  .nav-icon { font-size: 1.45rem; }
  .nav-scan .nav-icon { width: 42px; height: 42px; font-size: 1.1rem; }
}
@media (max-width: 400px) { .bottom-nav .nav-item { font-size: 0.72rem; } }


.tel-link { display: inline-flex; align-items: center; gap: 6px; }
.vendor-contacts { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; font-size: 13px; }

/* "Clinic Inventory" text with the unchanged official logo (logo size/placement untouched) */
.sb-app.sb-clinic { color: #8fd0ff; font-size: 15px; font-weight: 700; letter-spacing: 0.02em; text-transform: none; }
.login-brand h1.brand-clinic-login { margin: 0; font-size: 1.3rem; font-weight: 750; color: var(--primary); }
.brand-app-label.brand-clinic { font-size: 15px; font-weight: 750; }
@media (max-width: 767.98px) {
  /* Phone header: logo (unchanged) + "Clinic Inventory" stacked, with breathing room.
     Height = 11px pad + logo + 8px gap + 16px text line + 11px pad */
  :root { --header-h: 98px; }                       /* staff: 52px logo */
  :root:has(.header-users) { --header-h: 86px; }    /* admins: original 40px logo rule */
  .app-header {
    border-bottom: 1px solid #e3e7ee;
    box-shadow: 0 2px 6px rgba(20, 40, 70, 0.06);
  }
  .header-inner { padding: 11px 16px; box-sizing: border-box; align-items: center; }
  .app-header .brand { flex-direction: column; align-items: flex-start; gap: 8px; }
  .app-header .brand-app-label.brand-clinic {
    display: block !important;
    font-size: 14.5px; font-weight: 600; line-height: 16px;
    letter-spacing: 0.04em; color: #4a5a70; white-space: nowrap;
    padding-left: 2px;
  }
}

/* ── iPhone Home Screen header fix (v1790313000) ─────────────────────────
   Header keeps its normal (#fff) background; safe-area inset is ADDED to the header height
   (it used to be carved out of it, pushing the buttons below the border). */
.app-header {
  background: #ffffff;
  -webkit-backdrop-filter: none; backdrop-filter: none;
  opacity: 1;
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
  overflow: visible;
}
.header-inner { height: var(--header-h); }
@media all and (display-mode: standalone) {
  .app-header { padding-top: env(safe-area-inset-top, 0px); }
}
@media (min-width: 768px) {
  .bottom-nav { top: calc(var(--header-h) + env(safe-area-inset-top, 0px)); }
}
/* Header buttons: identical 40px boxes, vertically centred, never clipped */
.header-actions { align-items: center; overflow: visible; }
.header-actions > *, .header-logout { display: flex; align-items: center; margin: 0; }
.header-actions .btn,
.header-actions .btn-sm {
  box-sizing: border-box;
  height: 40px; min-height: 40px;
  line-height: 1; border-radius: 10px; border-width: 1px;
  display: inline-flex; align-items: center; justify-content: center;
  padding: 0 12px; font-size: 15px; vertical-align: middle;
}
.header-actions .header-account { width: 40px; padding: 0; }
.header-actions .header-account .avatar { width: 28px; height: 28px; font-size: 14px; }
@media (max-width: 440px) {
  .header-actions .btn, .header-actions .btn-sm { padding: 0 10px; }
  .header-actions .header-account { padding: 0; }
}

/* ── Phone bottom tab bar: one icon line, one label baseline (v1790314000) ──
   Height = base + safe-area inset (added as padding, never carved out). */
@media (max-width: 767.98px) {
  :root { --nav-h: 64px; }
  .bottom-nav {
    box-sizing: border-box;
    height: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px));
    padding: 0 2px env(safe-area-inset-bottom, 0px);
    background: #ffffff;
    border-top: 1px solid var(--border);
    box-shadow: 0 -1px 6px rgba(2, 42, 77, 0.05);
    display: flex; align-items: stretch; justify-content: stretch;
  }
  .bottom-nav .nav-item {
    flex: 1 1 0; min-width: 0; min-height: 0; height: var(--nav-h);
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
    gap: 4px; padding: 8px 0 0;
    color: var(--muted); background: transparent;
  }
  .bottom-nav .nav-item:hover { background: transparent; }
  /* Every icon — Scan included — sits in the same 34×34 box */
  .bottom-nav .nav-icon,
  .bottom-nav .nav-scan .nav-icon {
    box-sizing: border-box;
    width: 34px; height: 34px; flex: 0 0 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 10px; font-size: 22px; line-height: 1;
    background: transparent; color: inherit; margin: 0;
  }
  .bottom-nav .nav-glyph { display: block; line-height: 1; font-family: -apple-system, "Segoe UI Symbol", "Noto Sans Symbols 2", "Noto Sans Symbols", system-ui, sans-serif; }
  .bottom-nav .nav-scan .nav-icon { background: var(--primary); color: #fff; font-size: 18px; }
  .bottom-nav .nav-label {
    display: block; font-size: 12px; line-height: 14px; font-weight: 600;
    white-space: nowrap; letter-spacing: -0.01em;
  }
  /* Active tab: sky-blue highlight */
  .bottom-nav .nav-item.active { color: var(--accent); }
  .bottom-nav .nav-item.active .nav-icon { background: var(--accent-soft); color: var(--accent); }
  .bottom-nav .nav-scan.active .nav-icon { background: var(--accent); color: #fff; }
  .bottom-nav .nav-item.active .nav-label { font-weight: 700; }
}
@media (max-width: 380px) { .bottom-nav .nav-label { font-size: 11.5px; letter-spacing: -0.02em; } }
/* SVG tab icons (same size everywhere; no emoji fallback) */
.nav-svg { display: block; width: 24px; height: 24px; flex-shrink: 0; }
.nav-scan .nav-svg { width: 22px; height: 22px; }
@media (min-width: 768px) { .nav-svg { width: 18px; height: 18px; } .nav-scan .nav-svg { width: 16px; height: 16px; } }

/* ── Fill from receipt (v1790315000) ───────────────────────────────────── */
.rc-entry {
  display: flex; align-items: center; gap: 14px; margin: 0 0 14px; padding: 14px 16px;
  background: linear-gradient(135deg, #eaf6fe 0%, #ffffff 100%); border: 1.5px solid #9fd5fa; border-radius: 14px;
  color: var(--primary); text-decoration: none; box-shadow: 0 2px 8px rgba(49,167,245,.12);
}
.rc-entry:hover { text-decoration: none; border-color: var(--accent); }
.rc-entry-ico { font-size: 30px; line-height: 1; flex-shrink: 0; }
.rc-entry strong { display: block; font-size: 17px; }
.rc-entry small { display: block; color: var(--muted); font-size: 13.5px; line-height: 1.35; margin-top: 2px; }
.rc-entry-go { margin-left: auto; font-size: 28px; color: var(--accent); }
.rc-pick { padding: 16px; }
.rc-lead { margin: 0 0 14px; }
.rc-pick-btns { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.rc-pick-btns .btn { flex: 1 1 180px; }
.rc-thumbs { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 14px; }
.rc-thumb { position: relative; width: 92px; text-align: center; font-size: 12px; color: var(--muted); }
.rc-thumb img, .rc-pdf { width: 92px; height: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--border); display: grid; place-items: center; background: #f4f4f1; font-weight: 700; }
.rc-x { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--danger); color: #fff; font-size: 16px; line-height: 1; cursor: pointer; }
.rc-warn { background: #fff4e0; border: 1px solid #f3c77a; color: #7a4b00; border-radius: 10px; padding: 10px 12px; margin-bottom: 12px; font-weight: 600; }
.rc-pages { display: flex; gap: 10px; align-items: flex-start; margin-bottom: 12px; overflow-x: auto; }
.rc-page img { width: 84px; height: 110px; object-fit: cover; object-position: top; border-radius: 8px; border: 1px solid var(--border); display: block; }
.rc-pages-note { font-size: 13.5px; color: var(--muted); align-self: center; min-width: 160px; }
.rc-card { padding: 14px 16px; margin-bottom: 14px; }
.rc-h { font-size: 16px; margin: 0 0 8px; }
.rc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.rc-grid .field { min-width: 0; }
.rc-line { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px 2px; margin-bottom: 10px; }
.rc-line.rc-off { opacity: .55; }
.rc-line-head { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.rc-inc { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; margin: 0; }
.rc-inc input { width: 20px; height: 20px; accent-color: var(--primary); }
.rc-del { margin-left: auto; background: none; border: none; color: var(--danger); font-weight: 600; font-size: 14px; padding: 6px; cursor: pointer; }
.rc-tag { font-size: 11.5px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: #0b6fb0; }
.rc-tag-mem { background: #e7f6ec; color: #1d7a3e; }
.input.rc-low, .select.rc-low { background: #fff6e0; border-color: #f0b44c; box-shadow: 0 0 0 2px rgba(240,180,76,.18); }
.rc-savebar {
  position: sticky; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom, 0px) + 8px); z-index: 5;
  display: flex; align-items: center; gap: 12px; justify-content: space-between;
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 10px 12px; margin: 14px 0; box-shadow: 0 6px 18px rgba(2,42,77,.12);
}
.rc-raw { margin: 8px 0 20px; font-size: 13px; }
.rc-raw pre { white-space: pre-wrap; background: #f6f6f3; padding: 10px; border-radius: 8px; max-height: 300px; overflow: auto; }
.rc-done { padding: 16px; }
.rc-done-list { padding-left: 1.1rem; }
.rc-done-list li { margin: 4px 0; }
.rc-view { max-width: 900px; margin: 0 auto; }
.rc-view-img { display: block; width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; margin: 0 0 14px; background: #fff; }
@media (min-width: 768px) { .rc-savebar { bottom: 12px; } .rc-grid { grid-template-columns: repeat(3, 1fr); } }
.rc-contact { margin: 2px 0 6px; }
.rc-contact summary { cursor: pointer; font-weight: 650; padding: 6px 0; font-size: 15px; }
.rc-contact summary .muted { font-weight: 500; font-size: 13.5px; margin-left: 6px; }
@media (min-width: 768px) { .rc-grid.rc-grid-2 { grid-template-columns: 1fr 1fr; } }
@media (max-width: 767.98px) {
  .rc-card { padding: 12px 14px 4px; }
  .rc-card .field, .rc-line .field { margin-bottom: 10px; }
  .rc-page img { width: 64px; height: 84px; }
  .page-title h1 { font-size: 1.5rem; }
}

/* Tablet (768–899px): tab row sits right under the header (nav comes after <main> in the DOM,
   so sticky left it at the page bottom). Fixed under the header + matching top padding. */
@media (min-width: 768px) and (max-width: 899.98px) {
  .bottom-nav {
    position: fixed; left: 0; right: 0; bottom: auto; z-index: 39;
    top: calc(var(--header-h) + env(safe-area-inset-top, 0px));
    background: #fff;
  }
  .app-main { padding-top: calc(52px + 20px); }
}
/* Add item: two receipt entry points (v1790318000) */
.rc-entry-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 0 6px; }
.rc-entry-row .rc-entry { margin: 0; flex-direction: column; align-items: flex-start; gap: 6px; padding: 12px 12px 14px; }
.rc-entry-row .rc-entry strong { font-size: 15.5px; line-height: 1.2; }
.rc-entry-row .rc-entry small { font-size: 12.5px; }
.rc-entry-row .rc-entry-ico { font-size: 26px; }
.rc-entry-upload { background: linear-gradient(135deg, #eef3fb 0%, #ffffff 100%); border-color: #b8c7e2; }
.rc-entry-note { margin: 0 0 14px; font-size: 13px; color: var(--muted); }
.rc-fname { display: block; max-width: 92px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-weight: 600; }
.rc-src { background: #fff4e0; border: 1px solid #f3c77a; color: #7a4b00; border-radius: 10px; padding: 9px 12px; margin-bottom: 12px; font-size: 14px; }
.rc-src-ok { background: #e9f7ee; border-color: #9fd6b1; color: #1d6b39; }
@media (max-width: 360px) { .rc-entry-row { grid-template-columns: 1fr; } }
