/* "Đối chiếu định mức" (pages/inventory-norms.js): summary tiles, filters, table with one column per site, cards,
   per-site sheet. Tokens only. */

/* ---------- Filters ---------- */
.nc-filters {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}
.nc-filters .filter-row > .nc-search {
  flex: 2 1 260px;
  min-width: 0;
}
.nc-filters .filter-row > select.input {
  flex: 1 1 170px;
  max-width: 260px;
  width: auto;
  min-width: 0;
}
@media (max-width: 719px) {
  .nc-filters .filter-row > .nc-search {
    flex-basis: 100%;
  }
  .nc-filters .filter-row > select.input {
    flex: 1 1 140px;
    max-width: none;
  }
}

/* ---------- Summary tiles ---------- */
.nc-summary {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 14px 16px;
}
.nc-kpi {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
  color: inherit;
  font: inherit;
  text-align: left;
}
button.nc-kpi {
  cursor: pointer;
}
button.nc-kpi:hover {
  border-color: var(--line-2);
}
.nc-kpi.on {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.nc-kpi > span:last-child {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.nc-kpi b {
  font-size: 22px;
  line-height: 1.15;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
  color: var(--ink);
}
.nc-kpi small {
  font-size: 12.5px;
  line-height: 1.3;
  color: var(--muted);
}
.nc-kpi-ic {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: var(--off-soft);
  color: var(--off);
}
.nc-kpi-ic .icon {
  width: 19px;
  height: 19px;
}
.nc-kpi-ic.under {
  background: var(--warn-soft);
  color: var(--warn);
}
.nc-kpi-ic.over {
  background: var(--bad-soft);
  color: var(--bad);
}
@media (max-width: 719px) {
  .nc-summary {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
    padding: 12px;
  }
  .nc-kpi {
    padding: 9px 10px;
    gap: 8px;
  }
  .nc-kpi-ic {
    width: 30px;
    height: 30px;
    border-radius: 8px;
  }
  .nc-kpi b {
    font-size: 19px;
  }
  .nc-kpi small {
    font-size: 11.5px;
  }
}

/* ---------- "Còn lại": fewer than the norm (amber), more than the norm (red, minus sign), zero (muted) ---------- */
.nc-rem {
  display: inline-flex;
  justify-content: center;
  min-width: 34px;
  padding: 1px 7px;
  border-radius: 6px;
  font-family: var(--f-mono);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.nc-rem.under {
  background: var(--warn-soft);
  color: var(--warn);
}
.nc-rem.over {
  background: var(--bad-soft);
  color: var(--bad);
}
.nc-rem.zero {
  color: var(--muted);
  font-weight: 500;
}
/* No norm: not compared */
.nc-rem.none {
  color: var(--muted);
  font-weight: 400;
}

/* ---------- Selection bar (administrators) ---------- */
.nc-selbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 0 2px;
}
.nc-all {
  font-size: 13.5px;
}
.nc-all.off {
  opacity: 0.6;
}

/* ---------- Desktop table: item column stays in view while the site columns scroll ---------- */
.nc-tbl .t th.nc-item,
.nc-tbl .t td.nc-item {
  position: sticky;
  left: 0;
  z-index: 1;
  min-width: 280px;
  max-width: 420px;
  box-shadow: inset -1px 0 0 var(--line);
}
.nc-tbl .t th.nc-item {
  z-index: 2;
  background: var(--surface-2);
}
.nc-tbl .t td.nc-item {
  background: var(--surface);
}
.nc-tbl .t tbody tr:hover td.nc-item {
  background: var(--surface-2);
}
.nc-tbl .t tr.sel td {
  background: var(--primary-soft);
}
.nc-tbl .t th.nc-site,
.nc-tbl .t td.nc-site {
  padding-inline: 8px;
  min-width: 46px;
  font-family: var(--f-mono);
  font-size: 13px;
}
.nc-tbl .t th.nc-site {
  cursor: help;
}
.nc-prime {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.nc-prime-t {
  min-width: 0;
}
.nc-cb {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
}
.nc-thumb {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}
.nc-thumb.lg {
  width: 52px;
  height: 52px;
  border-radius: 10px;
}
.nc-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nc-thumb:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.nc-loading {
  opacity: 0.6;
  transition: opacity 0.15s;
}

/* ---------- Cards (phone / tablet) ---------- */
.nc-card.sel {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
}
.nc-card .band.nc-band-under {
  background: var(--warn);
}
.nc-card .band.nc-band-over {
  background: var(--bad);
}
.nc-card .band.nc-band-zero,
.nc-card .band.nc-band-none {
  background: var(--line);
}
.nc-ctop {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}
.nc-csel {
  display: grid;
  place-items: center;
  width: 36px;
  height: 30px;
  margin: -6px -6px -6px 0;
  cursor: pointer;
}
.nc-csel input {
  width: 18px;
  height: 18px;
}
.nc-cq {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}
.nc-cq b {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* ---------- Action bar labels ---------- */
.nc-narrow {
  display: none;
}
@media (max-width: 719px) {
  .nc-wide {
    display: none;
  }
  .nc-narrow {
    display: inline;
  }
}

/* ---------- Item sheet ---------- */
.nc-detail {
  display: grid;
  gap: 14px;
}
.nc-dhead {
  display: flex;
  align-items: center;
  gap: 12px;
}
.nc-dphoto {
  flex-shrink: 0;
  width: 84px;
  height: 84px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-3);
  overflow: hidden;
  cursor: zoom-in;
}
.nc-dphoto img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.nc-big {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  min-width: 0;
}
.nc-big > div {
  display: grid;
  gap: 2px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--surface-2);
}
.nc-big small {
  font-size: 12px;
  color: var(--muted);
}
.nc-big b {
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.nc-big b.nc-rem {
  justify-self: start;
  font-size: 18px;
  padding: 1px 8px;
}
.nc-dnote {
  margin: -6px 0 0;
}
.nc-h {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
}
.nc-sites {
  display: grid;
  border: 1px solid var(--line);
  border-radius: var(--r);
  overflow: hidden;
}
.nc-site-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 12px;
  border-bottom: 1px solid var(--line);
}
.nc-site-row:last-child {
  border-bottom: 0;
}
.nc-site-row.zero {
  color: var(--muted);
}
.nc-sc {
  min-width: 44px;
  font-weight: 700;
}
.nc-sn {
  display: grid;
  min-width: 0;
}
.nc-sn small {
  font-size: 12px;
  color: var(--muted);
}
.nc-sq {
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 479px) {
  .nc-dhead {
    flex-direction: column;
    align-items: stretch;
  }
  .nc-dphoto {
    align-self: center;
    width: 120px;
    height: 120px;
  }
  .nc-big > div {
    padding: 8px 10px;
  }
  .nc-big b {
    font-size: 18px;
  }
}

/* Item sheet: each count of the item at a site – zone, who entered it and when, quantity */
.nc-cells {
  display: flex;
  flex-direction: column;
  padding: 2px 12px 8px 66px;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.nc-cell {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  font-size: 13px;
}
.nc-cell > b {
  min-width: 36px;
}
.nc-cell-who {
  display: grid;
  min-width: 0;
}
.nc-cell-who small {
  color: var(--muted);
  font-size: 11.5px;
}
.nc-cell-q {
  font-weight: 600;
  white-space: nowrap;
}
.nc-cell-q small {
  color: var(--warn);
  font-weight: 500;
}
@media (max-width: 479px) {
  .nc-cells {
    padding-left: 12px;
  }
}
