body.m6-detail-open {
  overflow: hidden;
}

.m6-detail {
  position: fixed;
  inset: 0;
  z-index: 9700;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: #f5f5f5;
  -webkit-overflow-scrolling: touch;
}

.m6-detail.hidden {
  display: none;
}

.m6-detail-shell {
  width: min(100%, 760px);
  min-height: 100%;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 16px max(28px, calc(env(safe-area-inset-bottom) + 20px));
}

.m6-detail-top {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: start;
  margin-bottom: 14px;
}

.m6-detail-top h2 {
  margin: 3px 0 5px;
  font-size: clamp(23px, 6vw, 34px);
  line-height: 1.05;
}

.m6-detail-top p:not(.eyebrow) {
  margin: 0;
  color: #666;
  font-size: 12px;
  line-height: 1.4;
}

.m6-close {
  width: 48px;
  height: 48px;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: #fff;
  font-size: 31px;
  line-height: 1;
}

.m6-price-hero {
  display: grid;
  gap: 4px;
  padding: 18px;
  margin-bottom: 12px;
  border-radius: 22px;
  background: #111;
  color: #fff;
}

.m6-price-hero.confirmed {
  background: #166534;
}

.m6-price-hero span {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .08em;
}

.m6-price-hero strong {
  font-size: clamp(40px, 13vw, 68px);
  line-height: 1;
  letter-spacing: -.04em;
}

.m6-kpis,
.m6-info-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
  margin-bottom: 12px;
}

.m6-kpis > div,
.m6-info-grid > div {
  display: grid;
  align-content: start;
  gap: 4px;
  min-height: 92px;
  padding: 13px;
  border: 1px solid #e4e4e7;
  border-radius: 17px;
  background: #fff;
}

.m6-kpis span,
.m6-info-grid span {
  color: #71717a;
  font-size: 11px;
  line-height: 1.25;
}

.m6-kpis b,
.m6-info-grid b {
  overflow-wrap: anywhere;
  font-size: 20px;
  line-height: 1.08;
}

.m6-kpis small {
  color: #71717a;
  font-size: 10px;
}

.m6-actions {
  position: sticky;
  bottom: max(8px, env(safe-area-inset-bottom));
  z-index: 3;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
  padding: 9px;
  margin: 2px 0 14px;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  background: rgba(255,255,255,.94);
  box-shadow: 0 10px 35px rgba(0,0,0,.12);
  backdrop-filter: blur(12px);
}

.m6-actions button {
  min-height: 52px;
  border: 0;
  border-radius: 14px;
  padding: 0 14px;
  font-weight: 900;
}

.m6-confirm {
  background: #111;
  color: #fff;
}

.m6-confirm.saved {
  background: #dcfce7;
  color: #166534;
}

.m6-edit {
  background: #e5e7eb;
  color: #111;
}

.m6-history-section,
.m6-scan-history {
  padding: 14px;
  border: 1px solid #e4e4e7;
  border-radius: 20px;
  background: #fff;
}

.m6-scan-history {
  margin: 14px 0;
}

.m6-section-title {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 11px;
}

.m6-section-title h3 {
  margin: 2px 0 0;
  font-size: 19px;
}

.m6-history-list {
  display: grid;
  gap: 8px;
}

.m6-history-row {
  padding: 12px;
  border: 1px solid #ececec;
  border-radius: 15px;
  background: #fafafa;
}

.m6-history-row.compact {
  padding: 10px;
}

.m6-history-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.m6-history-head > div {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.m6-history-head b {
  font-size: 14px;
}

.m6-history-head span:not(.m6-status) {
  overflow-wrap: anywhere;
  color: #71717a;
  font-size: 10px;
}

.m6-status {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 999px;
  background: #fef3c7;
  color: #92400e;
  font-size: 9px;
  font-weight: 900;
}

.m6-status.confirmed {
  background: #dcfce7;
  color: #166534;
}

.m6-history-values {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
}

.m6-history-row.compact .m6-history-values {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.m6-history-values > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.m6-history-values small {
  color: #71717a;
  font-size: 9px;
}

.m6-history-values b {
  overflow-wrap: anywhere;
  font-size: 13px;
}

.m6-empty {
  padding: 16px;
  border-radius: 14px;
  background: #f4f4f5;
  color: #71717a;
  font-size: 12px;
  text-align: center;
}

.m6-open-full {
  width: 100%;
  min-height: 46px;
  margin-top: 10px;
  border: 0;
  border-radius: 13px;
  background: #e5e7eb;
  color: #111;
  font-weight: 900;
}

.document-item.m6-doc-product {
  cursor: pointer;
  border-radius: 9px;
  transition: background .12s ease, transform .12s ease;
}

.document-item.m6-doc-product:active {
  transform: scale(.99);
  background: #f4f4f5;
}

.document-item.m6-doc-product::after {
  content: '›';
  margin-left: 8px;
  color: #a1a1aa;
  font-weight: 900;
}

@media (max-width: 480px) {
  .m6-detail-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .m6-kpis,
  .m6-info-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .m6-actions {
    grid-template-columns: 1fr;
  }

  .m6-edit {
    width: 100%;
  }

  .m6-history-values {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
