/* ==========================================================================
   Census counting ("Ghi nhận & đếm") and the counting-mode chooser – phone first, one-hand use.
   Tokens and base classes come from app.css; team cards / zone chips from inventory-campaign.css.
   ========================================================================== */

/* ---------- Mode chooser (/inventory/:id/start) ---------- */
.im-body {
  max-width: 640px;
  gap: 12px;
}
.im-lead {
  margin: 0;
  font-size: 14px;
}
.im-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 20px;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 112px;
  padding: 18px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
  transition:
    border-color 0.12s,
    transform 0.08s ease-out;
}
.im-card:hover:not(:disabled) {
  border-color: var(--line-2);
}
.im-card.last {
  border-color: var(--brand);
  box-shadow: 0 0 0 1px var(--brand);
}
.im-card:disabled {
  cursor: not-allowed;
  background: var(--surface-2);
}
.im-card:disabled .im-ic,
.im-card:disabled .im-t,
.im-card:disabled .im-d {
  opacity: 0.55;
}
.im-card:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.im-ic {
  width: 52px;
  height: 52px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: var(--brand-soft);
  color: var(--brand);
}
.im-ic .icon {
  width: 26px;
  height: 26px;
}
.im-main {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.im-t {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.im-t b {
  font-size: 17px;
  line-height: 1.3;
}
.im-d {
  font-size: 13.5px;
  color: var(--text-2);
  line-height: 1.45;
}
.im-m {
  font-size: 12.5px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.im-m.off {
  color: var(--warn);
  font-weight: 600;
}
.im-m .icon {
  width: 14px;
  height: 14px;
}
.im-go {
  color: var(--muted);
}
.im-card:disabled .im-go {
  visibility: hidden;
}

/* ---------- Census screen ---------- */
.cs-body {
  max-width: 760px;
  gap: 12px;
}
.cs-head {
  position: sticky;
  top: calc(var(--topbar-h) + var(--safe-t));
  z-index: 20;
  margin: -12px -16px 0;
  padding: 10px 16px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(1.5) blur(8px);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
}
.cs-tools {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.cs-tools .search {
  flex: 1;
  min-width: 0;
  height: 44px;
}
.cs-tools .search input[type='search']::-webkit-search-cancel-button {
  display: none;
}
.cs-pick-title {
  flex: 1;
  font-size: 15px;
}
.cs-tools .cnt-team {
  height: 44px;
  flex-shrink: 0;
}
.cs-sync {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--info);
  white-space: nowrap;
  flex-shrink: 0;
}
.cs-sync .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
  animation: pulse 1s ease-in-out infinite;
}
.cs-zones .chip {
  min-height: 38px;
}
.cs-failed {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  border-radius: var(--r);
  background: var(--bad-soft);
  color: var(--bad);
  font-size: 13px;
}
.cs-failed .icon {
  width: 18px;
  height: 18px;
}
.cs-failed .btn {
  height: 36px;
  flex-shrink: 0;
}

/* Zone picker */
.cs-zone-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.cs-zone-card {
  display: grid;
  gap: 2px;
  align-content: start;
  min-height: 84px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  text-align: left;
  font: inherit;
  color: inherit;
  cursor: pointer;
}
.cs-zone-card:hover {
  border-color: var(--line-2);
}
.cs-zone-card b {
  font-size: 18px;
  color: var(--brand);
}
.cs-zone-card span {
  font-weight: 600;
  line-height: 1.3;
}
.cs-zone-card small {
  color: var(--muted);
  font-size: 12px;
}

/* Zone list */
.cs-zone-h {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 2px 10px;
  padding: 0 2px;
}
.cs-zone-h b {
  font-size: 16px;
}
.cs-sec {
  display: grid;
  gap: 8px;
}
.cs-sec + .cs-sec {
  margin-top: 6px;
}
.cs-sec-h {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--muted);
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.cs-sec-h .n {
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: 99px;
  padding: 0 7px;
  letter-spacing: 0;
}
.cs-hint {
  margin: 0;
  padding: 4px 2px;
}
.cs-list {
  display: grid;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.cs-row {
  position: relative;
  display: flex;
  align-items: stretch;
  border-bottom: 1px solid var(--line);
  scroll-margin-top: 170px;
}
.cs-row:last-child {
  border-bottom: 0;
}
.cs-main {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  min-height: 60px;
  padding: 9px 6px 9px 14px;
  border: 0;
  background: none;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
.cs-main:hover {
  background: var(--surface-2);
}
.cs-main:active {
  background: var(--surface-3);
}
.cs-main:focus-visible,
.cs-info:focus-visible,
.cs-del:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
}
.cs-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.cs-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.cs-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 2px 10px;
  font-size: 12.5px;
  color: var(--muted);
}
.cs-meta > span + span::before {
  content: '·';
  margin-right: 10px;
  color: var(--line-2);
}
.cs-meta > .cs-tag::before,
.cs-meta > .cs-other::before {
  display: none;
}
.cs-tag {
  font-size: 11px;
  font-weight: 700;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--info-soft);
  color: var(--info);
}
.cs-other {
  font-family: var(--f-mono);
  font-size: 11.5px;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--surface-3);
  color: var(--text-2);
}
.cs-qty {
  display: grid;
  justify-items: end;
  min-width: 56px;
  line-height: 1.15;
}
.cs-qty b {
  font-size: 21px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.cs-qty.none b {
  color: var(--line-2);
  font-weight: 500;
}
.cs-qty small {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--warn);
  white-space: nowrap;
}
/* Counted marker on the row (not the button) so it stays at the left edge when a photo leads the row */
.cs-row.counted::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--ok);
  z-index: 1;
  pointer-events: none;
}
/* Catalog photo of the item: small square before the name; tap = larger photo */
.cs-ph {
  flex: 0 0 auto;
  align-self: center;
  width: 44px;
  height: 44px;
  margin-left: 10px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}
.cs-ph img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cs-ph:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.cs-row.has-ph .cs-main {
  padding-left: 10px;
}
.cs-dot {
  position: absolute;
  top: 8px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--info);
}
.cs-dot.wait {
  animation: pulse 1s ease-in-out infinite;
}
.cs-dot.failed {
  background: var(--bad);
}
.cs-info,
.cs-info-gap {
  flex: 0 0 44px;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--muted);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cs-info-gap {
  border-left-color: transparent;
  cursor: default;
}
.cs-info:hover {
  background: var(--surface-2);
  color: var(--ink);
}
.cs-del {
  flex: 0 0 44px;
  border: 0;
  border-left: 1px solid var(--line);
  background: none;
  color: var(--bad);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.cs-del:hover {
  background: var(--surface-2);
}
.cs-add {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 52px;
  padding: 10px 14px;
  border: 1.5px dashed var(--line-2);
  border-radius: var(--r-lg);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.cs-add:hover {
  border-color: var(--primary);
}
.cs-add small {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}
.cs-add.big {
  min-height: 64px;
  border-style: solid;
  border-color: var(--primary);
}
.cs-more {
  height: 48px;
}

/* Undo snackbar: above the bottom bars; at the top while the keypad covers the bottom of the screen */
.cs-snack {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(var(--tabbar-h) + var(--bar-pad-b) + var(--vv-bottom) + 12px);
  z-index: 150;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 52px;
  padding: 6px 6px 6px 14px;
  border-radius: var(--r);
  background: var(--ink);
  color: var(--surface);
  box-shadow: var(--shadow-lg);
  font-size: 14px;
  animation: fade 0.15s ease-out;
}
body.no-tabbar .cs-snack {
  bottom: calc(var(--vv-bottom) + var(--bar-pad-b) + 12px);
}
.cs-snack.top {
  top: calc(var(--safe-t) + 10px);
  bottom: auto;
}
.cs-snack .icon {
  width: 18px;
  height: 18px;
  color: #6fd394;
}
.cs-snack button {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--r-sm);
  background: color-mix(in srgb, var(--surface) 14%, transparent);
  color: var(--surface);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ---------- Keypad sheet ---------- */
.kp {
  display: grid;
  gap: 10px;
}
.kp-display {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 108px;
  gap: 8px;
}
.kp-field {
  display: grid;
  align-content: end;
  justify-items: end;
  gap: 0;
  min-height: 84px;
  padding: 8px 12px;
  border: 1.5px solid var(--line);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  cursor: pointer;
  text-align: right;
  min-width: 0;
}
.kp-field small {
  justify-self: start;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.kp-field.on {
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 1px var(--primary);
}
.kp-field.dmg.on {
  border-color: var(--warn);
  box-shadow: 0 0 0 1px var(--warn);
}
.kp-field.dmg.has .kp-val {
  color: var(--warn);
}
.kp-expr {
  font-family: var(--f-mono);
  font-size: 13px;
  color: var(--muted);
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  /* Long expressions keep their end (the latest keys) visible */
  direction: rtl;
}
.kp-expr bdi {
  direction: ltr;
  unicode-bidi: isolate;
}
.kp-val {
  font-family: var(--f-mono);
  font-size: 34px;
  line-height: 1.1;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kp-field.dmg .kp-val {
  font-size: 26px;
}
.kp-val.is-empty {
  color: var(--line-2);
}
/* A prefilled value is replaced by the first digit: show it as selected */
.kp-field.fresh.on .kp-val {
  background: var(--primary-soft);
  border-radius: 6px;
  padding: 0 4px;
}
.kp-info {
  display: flex;
  align-items: center;
  gap: 8px;
}
.kp-pos {
  margin-left: auto;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}
.kp-err {
  margin: 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--bad);
}
.kp-keys {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}
.kp-key {
  height: 56px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--f-mono);
  font-size: 24px;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  box-shadow: var(--shadow-sm);
  transition:
    background 0.08s,
    transform 0.06s;
}
.kp-key:hover {
  background: var(--surface-2);
}
.kp-key:active {
  background: var(--surface-3);
}
.kp-key.op {
  background: var(--surface-3);
  color: var(--text-2);
}
.kp-key.clear {
  color: var(--bad);
  font-family: var(--f-body);
  font-size: 18px;
}
.kp-key.zero {
  grid-column: span 2;
}
.kp-key:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.sheet-f .kp-done,
.sheet-f .kp-next {
  height: 52px;
  font-size: 15.5px;
}
.sheet-f .kp-done {
  flex: 1;
}
.sheet-f .kp-next {
  flex: 2;
}
.kp-next .icon {
  width: 18px;
  height: 18px;
}

/* Person picker options / add item / detail */
.cs-post-list {
  display: grid;
  gap: 6px;
}
.cs-post-opt {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
}
.cs-post-opt:hover {
  background: var(--surface-2);
}
.cs-post-opt.on {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary);
  font-weight: 700;
}
.cs-post-opt .icon {
  width: 18px;
  height: 18px;
}
.cs-units {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.cs-units .chip {
  min-height: 40px;
  padding-inline: 14px;
  font-size: 14px;
}
.cs-cells {
  display: grid;
  gap: 4px;
}
.cs-cell {
  display: grid;
  grid-template-columns: 52px 76px minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  padding: 7px 10px;
  border-radius: var(--r-sm);
  background: var(--surface-2);
  font-size: 13px;
}
.cs-cell.here {
  box-shadow: inset 3px 0 0 var(--brand);
}
.cs-cell-q {
  text-align: right;
  font-weight: 700;
}
.cs-cell-q small {
  font-weight: 600;
  color: var(--warn);
}
.cs-cell-by {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Responsive ---------- */
/* Phones: no page header (the title sits in the top bar) – the room goes to the list */
@media (max-width: 1023px) {
  .page-header:has(+ .cs-body) {
    display: none;
  }
}
@media (max-width: 380px) {
  .kp-display {
    grid-template-columns: minmax(0, 1fr) 92px;
  }
  .kp-key {
    height: 52px;
  }
  .cs-sync {
    font-size: 0;
    gap: 0;
  }
}
/* Short phones (keypad must fit with the header and the footer) */
@media (max-height: 700px) {
  .kp-field {
    min-height: 70px;
  }
  .kp-val {
    font-size: 30px;
  }
  .kp-key {
    height: 50px;
  }
  .kp {
    gap: 8px;
  }
}
@media (min-width: 640px) {
  .cs-head {
    margin-inline: -24px;
    padding-inline: 24px;
  }
  .cs-zone-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .cs-zones {
    flex-wrap: nowrap;
    overflow-x: auto;
  }
  .sheet-f .kp-done,
  .sheet-f .kp-next {
    height: 48px;
  }
  .sheet-f .kp-done {
    flex: 1 1 0;
  }
  .sheet-f .kp-next {
    flex: 2 1 0;
  }
  .cs-snack.top {
    top: auto;
    bottom: calc(var(--vv-bottom) + 20px);
  }
}
@media (min-width: 1024px) {
  .cs-head {
    margin: -16px -28px 0;
    padding: 12px 28px;
  }
  .cs-zone-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .cs-snack {
    bottom: 24px;
  }
}
@media (min-width: 1024px) and (max-width: 1279px) {
  .cs-head {
    margin-inline: -20px;
    padding-inline: 20px;
  }
}
@media (hover: none) {
  .im-card:active:not(:disabled),
  .cs-zone-card:active,
  .kp-key:active {
    transform: scale(0.97);
  }
}

/* Zone suggestions ("Gợi ý cho khu này") and who entered a number */
.cs-sub-h {
  margin: 2px 0 0;
  padding: 0 2px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-2);
}
.cs-sub-h .n {
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  background: var(--surface-3);
  color: var(--text-2);
  border-radius: 99px;
  padding: 0 7px;
}
.cs-meta > .cs-why::before,
.cs-meta > .cs-by::before {
  display: none;
}
.cs-why {
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 5px;
  background: var(--ok-soft);
  color: var(--ok);
}
.cs-why.type {
  background: var(--surface-3);
  color: var(--text-2);
}
.cs-by {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-2);
  white-space: nowrap;
}
.cs-by .icon {
  width: 12px;
  height: 12px;
}
.kp-by {
  margin: 0;
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--warn-soft);
  color: var(--text-2);
  font-size: 13px;
  line-height: 1.35;
}
.kp-by .icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  margin-top: 1px;
  color: var(--warn);
}

/* ---------- Way of managing (keypad) ---------- */
.kp-track {
  flex: 1;
  min-width: 0;
}
.kp-track button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 36px;
  white-space: nowrap;
}
.kp-track button .icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}
.kp-track button small {
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
}
.kp-lot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
}
.kp-lot .icon {
  width: 14px;
  height: 14px;
}

/* Person picker */
.cs-emps {
  display: grid;
  gap: 8px;
}
.sheet-b .search.cs-emp-search {
  position: sticky;
  top: -14px;
  z-index: 1;
  margin: -14px calc(-1 * var(--sheet-px)) 0;
  padding: 0 12px;
  border-width: 0 0 1px;
  border-radius: 0;
  height: 48px;
}
.cs-emp-search:focus-within {
  box-shadow: none;
}
.cs-emp-opt .grow {
  display: grid;
  line-height: 1.3;
  padding: 6px 0;
}
.cs-emp-opt small {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

/* Row marker: item that gets one code per piece */
.cs-meta > .cs-code::before {
  display: none;
}
.cs-code {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  padding: 0 6px;
  border-radius: 5px;
  border: 1px solid var(--line);
  color: var(--text-2);
  white-space: nowrap;
}
.cs-code .icon {
  width: 11px;
  height: 11px;
}

/* Zone marked done: read-only */
.cs-done {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--r);
  background: var(--ok-soft);
  color: var(--ok);
}
.cs-done .icon {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  margin-top: 1px;
}
.cs-done .grow {
  display: grid;
  gap: 1px;
  font-size: 14px;
}
.cs-done small {
  font-size: 12.5px;
  color: var(--text-2);
}
.cs-zone-card.done {
  border-color: color-mix(in srgb, var(--ok) 45%, var(--line));
  background: color-mix(in srgb, var(--ok-soft) 55%, var(--surface));
}
.cs-zone-card.done small {
  color: var(--ok);
  font-weight: 600;
}

/* "Chọn từ danh mục" */
.cs-cat-groups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.cs-cat-groups .chip {
  min-height: 38px;
  padding-inline: 13px;
  font-size: 13.5px;
}
.cs-cat-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.cs-cat-bar .search {
  flex: 1 1 220px;
  min-width: 0;
  height: 44px;
}
.cs-cat-bar .search input[type='search']::-webkit-search-cancel-button {
  display: none;
}
.cs-cat-n {
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
  padding: 0 2px;
}
.cs-cat-n b {
  color: var(--ink);
}
@media (max-width: 380px) {
  .kp-track button small {
    display: none;
  }
}

/* Zone actions in the zone header: Xong khu / In tem QR / Mở lại khu */
.cs-zone-acts {
  display: inline-flex;
  gap: 6px;
  margin-left: auto;
}
.cs-zone-acts .btn {
  min-height: 34px;
}
@media (pointer: coarse) {
  .cs-zone-acts .btn {
    min-height: 40px;
  }
}

/* Person responsible + custody post of the whole zone (zone header) */
.cs-zone-who {
  flex-basis: 100%;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 14px;
  min-width: 0;
  font-size: 13px;
  color: var(--text-2);
}
.cs-zone-emp,
.cs-zone-post {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 100%;
}
.cs-zone-who .icon {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--muted);
}
.cs-zone-h .cs-zone-who b {
  font-size: inherit;
  font-weight: 600;
  color: var(--ink);
}
.cs-zone-emp.unset,
.cs-zone-emp.unset .icon {
  color: var(--warn);
  font-weight: 600;
}
.cs-zone-pick {
  flex-shrink: 0;
  min-height: 30px;
  padding-inline: 8px;
}
@media (pointer: coarse) {
  .cs-zone-pick {
    min-height: 36px;
  }
}

/* Note of the count on the keypad and on the row (inventory_counts.note) */
.kp-note {
  margin-top: 8px;
  min-height: 40px;
}
.cs-meta > .cs-cnote::before {
  display: none;
}

/* Photos of the damaged pieces: one compact line under the note (keypad) and a camera mark after "hỏng N" (row) */
.kp-ph {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}
.kp-ph-h {
  flex-shrink: 0;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--warn);
  white-space: nowrap;
}
.kp-ph-list {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
}
.kp-ph-list::-webkit-scrollbar {
  display: none;
}
.kp-ph-it {
  position: relative;
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
}
.kp-ph-img {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}
.kp-ph-img img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.kp-ph-del {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--ink) 78%, transparent);
  color: var(--surface);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.kp-ph-del .icon {
  width: 12px;
  height: 12px;
}
.kp-ph-del:disabled {
  opacity: 0.5;
  cursor: default;
}
.kp-ph-img:focus-visible,
.kp-ph-del:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 1px;
}
.kp-ph-wait {
  display: grid;
  place-items: center;
  border: 1px dashed var(--line-2);
  border-radius: var(--r-sm);
  color: var(--muted);
  animation: pulse 1s ease-in-out infinite;
}
.kp-ph-wait .icon {
  width: 18px;
  height: 18px;
}
.kp-ph .btn {
  flex-shrink: 0;
  height: 40px;
  gap: 6px;
}
.kp-ph .btn.icon-only {
  width: 40px;
}
.kp-ph-add .icon {
  color: var(--warn);
}
.kp-ph-opt {
  min-width: 0;
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cs-qph {
  width: 12px;
  height: 12px;
  margin-left: 3px;
  vertical-align: -2px;
}
@media (max-height: 700px) {
  .kp-ph {
    min-height: 40px;
  }
  .kp-ph-it {
    width: 40px;
    height: 40px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .kp-ph-wait {
    animation: none;
  }
}
.cs-cnote {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 11.5px;
  color: var(--text-2);
  font-style: italic;
}
.cs-cnote .icon {
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}

/* "Tạo nhanh": a new item without searching first (next to the search box) */
.cs-quick {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0 12px;
  gap: 6px;
}
@media (max-width: 339px) {
  .cs-quick-t {
    display: none;
  }
}

/* "Tạo nhanh món mới" under the zone's list: always at hand when the item is in no list */
.cs-add-new {
  min-height: 60px;
}
.cs-add-new > .icon {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 7px;
  box-sizing: content-box;
  border-radius: 50%;
  background: var(--primary);
  color: var(--on-primary);
}
.cs-add-t {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.cs-add .cs-add-t small {
  white-space: normal;
  line-height: 1.35;
}

/* Quick add: name preview and existing items with the same name */
.cs-cat-preview {
  display: grid;
  gap: 6px;
  margin-top: -4px;
}
.cs-cat-dup {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: var(--text-2);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.cs-cat-dup:hover {
  border-color: var(--line-2);
}
.cs-cat-dup .icon {
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  color: var(--info);
}
.cs-cat-dup.on {
  border-color: var(--ok);
  background: var(--ok-soft);
  color: var(--ink);
}
.cs-cat-dup.on .icon {
  color: var(--ok);
}
.cs-cat-dup small {
  color: var(--muted);
}
.cs-cat-use {
  flex-shrink: 0;
  font-weight: 600;
  white-space: nowrap;
}

/* Photos of a counting line (line sheet): catalog photo first (tagged), then every photo of the line */
.cs-line-ph .kp-ph-it {
  width: 64px;
  height: 64px;
}
.cs-ph-cat .cs-ph-tag {
  position: absolute;
  left: 2px;
  bottom: 2px;
  padding: 0 4px;
  border-radius: 4px;
  font-size: 10px;
  background: color-mix(in srgb, var(--ink) 72%, transparent);
  color: var(--surface);
}
.cs-line-ph-btns {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.cs-line-ph-btns .btn.disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* Looked-up row: total over every zone of the session */
.cs-meta > .cs-sum {
  color: var(--primary);
  font-weight: 600;
}
.cs-sum .icon {
  width: 12px;
  height: 12px;
  vertical-align: -1px;
  margin-right: 2px;
}

/* Photos kept on the phone until the server has them (upload-queue.js) */
.kp-ph-it.pending .kp-ph-img {
  border-style: dashed;
  border-color: var(--warn);
}
.kp-ph-it.pending .kp-ph-img img {
  opacity: 0.7;
}
.kp-ph-it.failed .kp-ph-img {
  border-color: var(--bad);
}
.kp-ph-q {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 0 2px;
  font-size: 9px;
  line-height: 14px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  border-radius: 0 0 var(--r-sm) var(--r-sm);
  background: var(--warn);
  color: var(--surface);
  pointer-events: none;
}
.kp-ph-it.failed .kp-ph-q {
  background: var(--bad);
}
.up-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--warn);
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font: inherit;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
}
.up-chip.bad {
  border-color: var(--bad);
  color: var(--bad);
  background: var(--bad-soft, var(--warn-soft));
}
.up-chip .icon {
  width: 15px;
  height: 15px;
}
.up-chip:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.up-row {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 10px 0;
  border-top: 1px solid var(--line);
}
.up-row img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  flex-shrink: 0;
}
.up-t {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}
.up-t b {
  font-size: 13px;
  overflow-wrap: anywhere;
}
.up-t small {
  font-size: 12px;
  color: var(--muted);
}
.up-t small .bad {
  color: var(--bad);
}
.up-acts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}
