/* ── Stocktaking: desktop table / mobile card list ─────────────── */

.st-desktop-table { display: block; }
.st-mobile-list { display: none; }

/* Shared mobile label–value rows */
.st-mobile-kv {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
}
.st-mobile-kv__row {
  display: grid;
  grid-template-columns: minmax(96px, 38%) 1fr;
  gap: 8px;
  align-items: baseline;
  font-size: 13px;
}
.st-mobile-kv__row dt {
  margin: 0;
  color: var(--text-muted);
  font-weight: 500;
}
.st-mobile-kv__row dd {
  margin: 0;
  word-break: break-word;
  min-width: 0;
}
.st-mobile-kv__badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.st-mobile-kv__progress {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.st-mobile-kv__progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}
.st-mobile-kv__progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
}
.st-mobile-kv__progress-text {
  font-size: 12px;
  color: var(--text-muted);
}

/* Full-width action buttons */
.st-mobile-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}
.st-mobile-actions > .btn,
.st-mobile-actions > form,
.st-mobile-actions > form.inline-form,
.st-mobile-actions > form .btn {
  width: 100%;
  display: block;
  text-align: center;
  box-sizing: border-box;
}

/* List cards */
.st-mobile-card {
  padding: 14px;
  border-bottom: 1px solid var(--border);
}
.st-mobile-card:last-child { border-bottom: none; }

.st-mobile-card__title {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.35;
  color: var(--accent);
  text-decoration: none;
  word-break: break-word;
  margin-bottom: 10px;
}
.st-mobile-card__title:hover { text-decoration: underline; }

/* List card: Open + Delete on one row (2/3 + 1/3) */
.st-mobile-card .st-mobile-actions {
  flex-direction: row;
  align-items: stretch;
  gap: 8px;
}
.st-mobile-card .st-mobile-actions > .btn {
  flex: 2;
  width: auto;
  min-width: 0;
}
.st-mobile-card .st-mobile-actions > form {
  flex: 1;
  min-width: 0;
}
.st-mobile-card .st-mobile-actions > .btn:only-child {
  flex: 1;
  width: 100%;
}

/* ── Detail page layout ──────────────────────────────────────── */

.st-detail-layout {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 24px;
  align-items: start;
}

.st-detail-main { min-width: 0; }
.st-detail-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

.st-audit-items-desktop { display: block; }
.st-audit-items-mobile { display: none; }

.st-audit-item-mobile {
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
}
.st-audit-item-mobile:last-child { border-bottom: none; }
.st-audit-item-mobile.is-found { background: rgba(63, 185, 80, 0.04); }
.st-audit-item-mobile.is-discrepancy { background: rgba(210, 153, 34, 0.06); }
.st-audit-item-mobile.is-not_found { background: rgba(248, 81, 73, 0.06); }

.st-audit-item-mobile__inv {
  display: inline-block;
  width: fit-content;
  max-width: 100%;
  font-size: 12px;
  margin-bottom: 8px;
  color: var(--accent);
}

.st-audit-item-mobile__photos {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}
.st-audit-item-mobile__photos img {
  width: 32px;
  height: 32px;
  object-fit: cover;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid var(--border);
}

.st-audit-item-mobile__checked {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

.st-detail-progress { margin-bottom: 24px; }

.st-stat-label-short { display: none; }

/* Compact five-metric strip on every stocktaking detail page. */
.stocktaking-detail-page .st-detail-stats {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.stocktaking-detail-page .st-detail-stats .stat-card {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 8px 10px;
  text-align: left;
  border-top-width: 1px;
  border-left: 3px solid var(--border);
}

.stocktaking-detail-page .st-detail-stats .stat-active {
  border-left-color: var(--success);
}

.stocktaking-detail-page .st-detail-stats .stat-warning {
  border-left-color: var(--warning);
}

.stocktaking-detail-page .st-detail-stats .stat-danger {
  border-left-color: var(--danger);
}

.stocktaking-detail-page .st-detail-stats .stat-value {
  flex: 0 0 auto;
  font-size: 21px;
  line-height: 1;
}

.stocktaking-detail-page .st-detail-stats .stat-label {
  margin-top: 0;
  font-size: 11px;
  line-height: 1.2;
}

/* ── Check item page ─────────────────────────────────────────── */

.st-check-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  max-width: 900px;
}

/* ── Mobile ──────────────────────────────────────────────────── */

@media (max-width: 768px) {
  .stocktaking-page .st-desktop-table { display: none; }
  .stocktaking-page .st-mobile-list { display: block; }

  .stocktaking-page .page-header {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .stocktaking-page .page-header .btn { width: 100%; text-align: center; }

  .stocktaking-detail-page .page-header > div {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
  }
  .stocktaking-detail-page .page-header > div .btn,
  .stocktaking-detail-page .page-header > div form {
    display: block !important;
    width: 100%;
  }
  .stocktaking-detail-page .page-header > div .btn,
  .stocktaking-detail-page .page-header > div button {
    width: 100%;
    text-align: center;
  }

  /* Compact stats */
  .stocktaking-detail-page .stats-grid {
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    margin-bottom: 12px;
  }
  .stocktaking-detail-page .st-stat-label-full { display: none; }
  .stocktaking-detail-page .st-stat-label-short { display: inline; }
  .stocktaking-detail-page .stat-card {
    display: block;
    padding: 8px 4px;
    border-radius: 6px;
    border-top-width: 2px;
    border-left-width: 1px;
    text-align: center;
  }
  .stocktaking-detail-page .stat-value {
    font-size: 17px;
    line-height: 1.1;
  }
  .stocktaking-detail-page .stat-label {
    font-size: 9px;
    line-height: 1.2;
    margin-top: 2px;
  }

  .stocktaking-detail-page .st-detail-progress {
    margin-bottom: 14px;
  }
  .stocktaking-detail-page .st-detail-progress > div:first-child {
    font-size: 12px !important;
    margin-bottom: 3px !important;
  }
  .stocktaking-detail-page .st-detail-progress > div:last-child {
    height: 6px !important;
  }

  /* Full-width items section */
  .st-detail-layout {
    grid-template-columns: 1fr;
    gap: 14px;
  }
  .st-detail-main {
    order: 1;
    margin-left: -16px;
    margin-right: -16px;
    width: calc(100% + 32px);
  }
  .st-detail-main > .card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
  .st-detail-main .card-header {
    padding-left: 16px;
    padding-right: 16px;
  }
  .st-detail-main .card-title {
    font-size: 15px;
  }

  .st-detail-sidebar {
    order: 2;
    padding: 0 4px;
  }
  .st-detail-sidebar .card-body {
    padding: 12px 14px;
  }
  .st-detail-sidebar .card-header {
    padding: 10px 14px;
  }
  .st-detail-sidebar .card-title {
    font-size: 14px;
  }

  .st-audit-items-desktop { display: none; }
  .st-audit-items-mobile { display: block; }

  /* Override global table min-width inside stocktaking pages */
  .stocktaking-page .table,
  .stocktaking-detail-page .table {
    min-width: 0;
  }
  .stocktaking-page .card-body.p-0,
  .stocktaking-detail-page .card-body.p-0 {
    overflow-x: visible;
  }

  .st-check-layout {
    grid-template-columns: 1fr;
    max-width: none;
    gap: 16px;
  }
}

@media (max-width: 380px) {
  .st-mobile-kv__row {
    grid-template-columns: minmax(84px, 36%) 1fr;
    gap: 6px;
    font-size: 12px;
  }
  .stocktaking-detail-page .stats-grid {
    gap: 4px;
  }
  .stocktaking-detail-page .stat-value { font-size: 15px; }
  .stocktaking-detail-page .stat-label { font-size: 8px; }
}

/* ── Live found notification modal ─────────────────────────────── */

.st-found-modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 210;
  opacity: 0;
  transition: opacity 0.25s ease;
  pointer-events: none;
}

.st-found-modal-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.st-found-modal {
  position: fixed;
  top: 50%;
  left: 50%;
  z-index: 211;
  width: min(360px, calc(100vw - 32px));
  padding: 18px 18px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid #3fb950;
  border-radius: 12px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28);
  opacity: 0;
  transform: translate(-50%, calc(-50% - 12px)) scale(0.97);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}

.st-found-modal.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.st-found-modal__close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  transition: color 0.15s, background 0.15s;
}

.st-found-modal__close:hover {
  color: var(--text);
  background: var(--surface-2);
}

.st-found-modal__icon {
  width: 40px;
  height: 40px;
  margin-bottom: 10px;
  border-radius: 50%;
  background: rgba(63, 185, 80, 0.15);
  color: #3fb950;
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.st-found-modal__title {
  margin: 0 0 10px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}

.st-found-modal__body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 14px;
}

.st-found-item {
  padding: 10px 12px;
  background: var(--surface-2);
  border-radius: 8px;
  font-size: 13px;
}

.st-found-item__inv {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: var(--text-muted);
}

.st-found-item__name {
  display: block;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

.st-found-item__meta {
  margin-top: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.st-found-modal__ok {
  width: 100%;
}
