/* "Bắt đầu kiểm kê" (pages/inventory-start.js): site cards (reuse .im-card of inventory-census.css), zone grid.
   .ks-body keeps the .body column layout (content stacked from the top); only the lists inside are grids. */
.ks-body {
  gap: 12px;
}
.ks-h {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 600;
}
.ks-code {
  display: inline-grid;
  place-items: center;
  flex-shrink: 0;
  min-width: 44px;
  height: 40px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--brand-soft);
  color: var(--brand);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 14px;
}
.ks-code.lg {
  min-width: 52px;
  height: 52px;
  border-radius: 14px;
  font-size: 15px;
}

/* Progress of a session: zones counted / zones of the site */
.ks-prog {
  display: block;
  height: 4px;
  border-radius: 2px;
  background: var(--surface-3);
  overflow: hidden;
}
.ks-prog > span {
  display: block;
  height: 100%;
  min-width: 0;
  border-radius: inherit;
  background: var(--ok);
  transition: width 0.3s ease-out;
}

/* ---------- Step 1: site cards ---------- */
.ks-sites {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
  gap: 12px;
}
.im-card.ks-site {
  min-height: 0;
  padding: 14px 14px 14px 16px;
  gap: 12px;
  align-items: center;
}
.ks-site .im-main {
  gap: 5px;
}
.ks-site .im-t {
  gap: 6px 8px;
}
.ks-site .im-t b {
  min-width: 0;
  overflow-wrap: anywhere;
}
.ks-site .im-d {
  font-size: 13px;
}
.ks-site .ks-prog {
  margin-top: 2px;
  max-width: 240px;
}
.pill.ks-today {
  background: var(--ok-soft);
  color: var(--ok);
  font-weight: 600;
}
.ks-site.busy {
  border-color: var(--line-2);
  cursor: progress;
}
.ks-site.busy .im-go {
  opacity: 0.35;
}

/* ---------- Step 2: chosen site + zone grid ---------- */
.ks-site-bar {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px 12px;
  padding: 12px 12px 12px 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
}
.ks-site-bar-t {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.ks-site-bar-t b {
  font-size: 15px;
  line-height: 1.3;
}
.ks-site-bar-t small {
  font-size: 12.5px;
}
.ks-site-bar .ks-prog {
  grid-column: 1 / -1;
}
.ks-change {
  white-space: nowrap;
}
@media (max-width: 379px) {
  /* Very narrow phones: the button keeps its icon, the label goes */
  .ks-change {
    width: 40px;
    padding: 0;
    justify-content: center;
    font-size: 0;
  }
}
.ks-zones {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 180px), 1fr));
  gap: 10px;
}
@media (max-width: 519px) {
  .ks-zones {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
.ks-zone {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-width: 0;
  min-height: 104px;
  padding: 12px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition:
    border-color 0.12s,
    transform 0.08s ease-out;
}
.ks-zone:hover {
  border-color: var(--line-2);
}
.ks-zone:active {
  transform: scale(0.98);
}
.ks-zone:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.ks-zone.done {
  border-color: color-mix(in srgb, var(--ok) 35%, var(--line));
}
.ks-zone-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
}
.ks-zone-code {
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  font-family: var(--f-mono);
  font-weight: 700;
  font-size: 13px;
  line-height: 1.5;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ks-zone.done .ks-zone-code {
  background: var(--ok-soft);
  color: var(--ok);
}
.ks-zone-ok {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  color: var(--ok);
}
.ks-zone-name {
  font-weight: 600;
  font-size: 14.5px;
  line-height: 1.3;
}
.ks-zone-note {
  margin-top: auto;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}
.ks-zone.done .ks-zone-note {
  color: var(--ok);
}

/* ---------- "Mở kiểm kê" sheet ---------- */
.ks-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 32px;
}
.ks-field-head label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-2);
}
.ks-choices {
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 150px), 1fr));
}
.ks-choice {
  min-height: 52px;
}
.ks-choice-t {
  display: grid;
  min-width: 0;
  line-height: 1.3;
}
.ks-choice-t b {
  font-family: var(--f-mono);
  font-size: 13px;
}
.ks-choice-t .ellipsis {
  font-size: 13px;
  color: var(--text-2);
}
.ks-choice-n {
  font-size: 11.5px;
  color: var(--warn);
  font-weight: 600;
}
.ks-choice-n.ok {
  color: var(--ok);
}

@media (pointer: coarse) {
  /* Tap targets: at least 44 px on touch screens */
  .ks-site-bar .ks-change,
  .ks-field-head .btn {
    height: 44px;
  }
  @media (max-width: 379px) {
    .ks-change {
      width: 44px;
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .ks-zone,
  .ks-prog > span {
    transition: none;
  }
  .ks-zone:active {
    transform: none;
  }
}

/* Zone being counted (items entered, "Xong khu" not tapped yet) */
.ks-zone.counting {
  border-color: color-mix(in srgb, var(--info) 35%, var(--line));
}
.ks-zone.counting .ks-zone-code {
  background: var(--info-soft);
  color: var(--info);
}
.ks-zone-live {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: 99px;
  background: var(--info-soft);
  color: var(--info);
  font-size: 11px;
  font-weight: 600;
}
