/* Benchmark report builder — admin */

.bm-report-builder {
  display: grid;
  grid-template-columns: minmax(280px, 340px) 1fr;
  gap: 20px;
  margin-top: 24px;
  align-items: start;
}

@media (max-width: 1100px) {
  .bm-report-builder {
    grid-template-columns: 1fr;
  }
}

.bm-report-panel {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
  overflow: hidden;
}

.bm-report-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-tertiary, #f8fafc);
}

.bm-report-panel-header h4 {
  margin: 0;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.bm-save-status {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  margin-left: auto;
  margin-right: 8px;
  min-width: 6em;
  text-align: right;
}

.bm-report-panel-body {
  padding: 14px 16px;
}

.bm-report-section-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 120px;
}

.bm-report-section-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: var(--card-bg, #fff);
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.bm-report-section-row:hover {
  border-color: var(--tech-cyan, #4fc3ca);
}

.bm-report-section-row.selected {
  border-color: var(--tech-cyan, #4fc3ca);
  box-shadow: 0 0 0 2px rgba(79, 195, 202, 0.2);
}

.bm-report-section-row.dragging {
  opacity: 0.45;
}

.bm-report-section-row.drag-over {
  border-style: dashed;
  border-color: var(--tech-cyan, #4fc3ca);
}

.bm-report-drag-handle {
  color: var(--text-muted, #64748b);
  font-size: 16px;
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
  padding: 4px;
}

.bm-report-section-meta {
  flex: 1;
  min-width: 0;
}

.bm-report-section-title {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bm-report-section-sub {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-top: 2px;
}

.bm-report-badge {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(79, 195, 202, 0.12);
  color: #0d9488;
  flex-shrink: 0;
}

.bm-report-badge.builtin {
  background: rgba(139, 92, 246, 0.12);
  color: #7c3aed;
}

.bm-report-badge.off {
  background: rgba(100, 116, 139, 0.12);
  color: #64748b;
}

.bm-report-editor-empty {
  padding: 48px 24px;
  text-align: center;
  color: var(--text-muted, #64748b);
  font-size: 14px;
}

.bm-report-form-grid {
  display: grid;
  gap: 14px;
}

.bm-editor-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

@media (max-width: 700px) {
  .bm-editor-row-2 {
    grid-template-columns: 1fr;
  }
}

.bm-copy-field {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.bm-copy-field:last-of-type {
  border-bottom: none;
}

.bm-report-rules {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bm-report-rule {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) minmax(120px, 160px) minmax(0, 2fr) auto;
  gap: 10px;
  align-items: start;
  padding: 12px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: var(--bg-tertiary, #f8fafc);
}

@media (max-width: 1000px) {
  .bm-report-rule {
    grid-template-columns: 1fr;
  }
}

.bm-report-rule-col label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.bm-report-rule-col-values {
  min-width: 0;
}

.bm-report-rule-actions {
  padding-top: 18px;
}

.bm-report-rule-values-wrap {
  min-width: 0;
}

.bm-value-search {
  margin-bottom: 6px;
  width: 100%;
}

.bm-value-count {
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-bottom: 4px;
}

.bm-report-multi {
  max-height: min(320px, 50vh);
  min-height: 80px;
  overflow-y: auto;
  overflow-x: hidden;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 6px;
  padding: 8px 10px;
  background: var(--card-bg, #fff);
}

.bm-report-multi label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12px;
  font-weight: 400;
  text-transform: none;
  color: inherit;
  margin: 0;
  padding: 6px 0;
  cursor: pointer;
  line-height: 1.35;
}

.bm-report-multi input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}

.bm-rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.bm-match-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-width: 280px;
}

.bm-report-preview {
  margin-top: 8px;
  padding: 14px;
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  background: #fff;
  font-size: 14px;
  line-height: 1.55;
  max-height: min(420px, 55vh);
  overflow-x: auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bm-report-preview h2,
.bm-report-preview h3 {
  font-size: 15px;
  margin: 0 0 8px;
}

.bm-report-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
  justify-content: flex-end;
}

.bm-report-hint {
  font-size: 12px;
  color: var(--text-muted, #64748b);
  line-height: 1.5;
  margin: 0;
}

.bm-report-rule-col .input,
.bm-report-rule-col select {
  width: 100%;
}

/* PDF page mockups */
.bm-preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.bm-preview-toolbar .detail-label {
  margin: 0;
}

.bm-report-preview--page {
  padding: 16px;
  background: #e8ecf0;
  max-height: min(480px, 60vh);
  overflow: auto;
}

.bm-mock--landscape {
  width: 100%;
  min-width: 280px;
  max-width: 720px;
  margin: 0 auto;
  background: #fff;
  font-size: 11px;
  color: #1a2332;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.12);
}

.bm-mock--cover-sheet {
  aspect-ratio: 842 / 595;
  min-height: 320px;
}

.bm-mock--page-sheet {
  min-height: 0;
}

.bm-mock--landscape.bm-mock--tall {
  aspect-ratio: auto;
  min-height: 280px;
}

/* Full-screen preview dialog */
.bm-preview-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(920px, 94vw);
  max-width: 94vw;
  max-height: 92vh;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}

.bm-preview-dialog::backdrop {
  background: rgba(15, 30, 55, 0.55);
}

.bm-preview-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-tertiary, #f8fafc);
}

.bm-preview-dialog-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.bm-preview-dialog-body {
  overflow: auto;
  max-height: calc(92vh - 56px);
  padding: 20px;
  background: #e8ecf0;
  -webkit-overflow-scrolling: touch;
}

.bm-preview-dialog-body .bm-mock--landscape {
  max-width: 860px;
}

.bm-mock-cover {
  display: grid;
  grid-template-columns: 58% 42%;
  min-height: 280px;
}

.bm-mock-cover-left {
  background-size: cover;
  background-position: center;
  min-height: 100%;
}

.bm-mock-cover-fallback {
  background: linear-gradient(135deg, #0f1e37 0%, #1a3050 100%);
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 24px;
}

.bm-mock-fallback-line1 {
  font-size: 28px;
  font-weight: 800;
  color: #fff;
  letter-spacing: 0.06em;
}

.bm-mock-fallback-line2 {
  font-size: 18px;
  font-weight: 700;
  color: #4fc3ca;
  margin-top: 8px;
}

.bm-mock-cover-right {
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  position: relative;
}

.bm-mock-teal {
  color: #0d9488;
  font-weight: 700;
}

.bm-mock-cover-kicker {
  font-size: 11px;
  letter-spacing: 0.12em;
}

.bm-mock-cover-title {
  margin: 6px 0 12px;
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 0.04em;
  line-height: 1.05;
}

.bm-mock-cover-company {
  font-size: 14px;
  font-weight: 700;
  margin: 0 0 16px;
}

.bm-mock-cover-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
  font-size: 10px;
}

.bm-mock-muted {
  color: #64748b;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bm-mock-cover-tagline {
  position: absolute;
  bottom: 14px;
  left: 18px;
  font-size: 9px;
  font-weight: 700;
  color: #0d9488;
  letter-spacing: 0.1em;
}

.bm-mock-section-head {
  margin: 0;
  padding: 14px 40px 8px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #0d9488;
  border-bottom: 2px solid #4fc3ca;
}

.bm-mock-general {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 16px;
  padding: 12px 40px 24px;
}

.bm-mock-lead {
  font-size: 12px;
  margin: 0 0 8px;
}

.bm-mock-body {
  line-height: 1.5;
  margin: 0 0 12px;
  color: #334155;
}

.bm-mock-subhead {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.06em;
  margin: 12px 0 6px;
}

.bm-mock-dl {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 4px 8px;
  margin: 0;
  font-size: 10px;
}

.bm-mock-dl dt {
  color: #64748b;
}

.bm-mock-dl dd {
  margin: 0;
  font-weight: 600;
}

.bm-mock-client-name {
  font-size: 13px;
  font-weight: 700;
  margin: 4px 0 0;
}

.bm-mock-contact-card {
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 12px;
  background: #f8fafc;
  border-top: 3px solid #4fc3ca;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bm-mock-batch {
  padding: 12px 16px;
}

.bm-mock-batch-machine {
  background: #0f1e37;
  color: #fff;
  padding: 8px 12px;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  margin-bottom: 12px;
}

.bm-mock-batch-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bm-mock-batch-cols h4 {
  font-size: 9px;
  color: #64748b;
  margin: 0 0 6px;
  letter-spacing: 0.06em;
}

.bm-mock-photos {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  padding: 12px 16px 16px;
}

.bm-mock-photo-label {
  font-size: 9px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.08em;
}

.bm-mock-photo-placeholder {
  margin-top: 6px;
  aspect-ratio: 4/3;
  background: #e2e8f0;
  border-radius: 4px;
}

.bm-mock-extra {
  margin: 12px 16px 16px;
  padding-top: 12px;
  border-top: 1px dashed #cbd5e1;
  font-size: 11px;
}

.bm-cover-variants-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin: 16px 0 8px;
}

.bm-cover-variants-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bm-cover-variant {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  padding: 12px;
  background: var(--bg-tertiary, #f8fafc);
}

.bm-cover-variant-top {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 12px;
}

.bm-cover-variant-thumb {
  width: 120px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #64748b;
}

.bm-cover-variant-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bm-cover-variant-rules {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color, #e2e8f0);
}

.bm-preview-machine-row {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  max-width: 400px;
}

.bm-mock-cover-logo {
  position: absolute;
  top: 14px;
  right: 14px;
  max-width: 100px;
  max-height: 32px;
  object-fit: contain;
}

.bm-content-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 12px 0;
  padding: 10px 12px;
  background: var(--bg-tertiary, #f8fafc);
  border-radius: 8px;
  border: 1px solid var(--border-color, #e2e8f0);
}

.bm-content-toolbar-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted, #64748b);
  margin-right: 4px;
}

.bm-content-blocks {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.bm-content-block-card {
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 8px;
  overflow: hidden;
  background: var(--card-bg, #fff);
}

.bm-content-block-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-tertiary, #f8fafc);
  border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.bm-content-block-head strong {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.bm-content-block-actions {
  display: flex;
  gap: 6px;
}

.bm-content-block-body {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bm-block-img-preview {
  border-radius: 6px;
  overflow: hidden;
  background: #e2e8f0;
  min-height: 80px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bm-block-img-preview.small {
  min-height: 60px;
  max-width: 200px;
}

.bm-block-img-preview img,
.bm-block-img {
  max-width: 100%;
  height: auto;
  display: block;
}

.bm-block-img.half {
  max-width: 48%;
}

.bm-block-caption {
  display: block;
  font-size: 11px;
  color: var(--text-muted, #64748b);
  margin-top: 4px;
}

.bm-section-blocks-preview {
  padding: 16px;
  max-height: min(480px, 60vh);
  overflow: auto;
}

.bm-block-preview-item {
  margin-bottom: 12px;
}

.bm-block-preview-item h3,
.bm-block-preview-item h4 {
  color: #0d9488;
  margin: 0 0 8px;
}

.bm-block-preview-divider {
  height: 1px;
  background: #cbd5e1;
  margin: 12px 0;
}

.bm-block-cols-preview {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.bm-block-col-preview {
  min-width: 0;
}

/* Benchmark live preview */
.bm-benchmark-preview-bar {
  display: grid;
  grid-template-columns: 1fr minmax(200px, 2fr) auto;
  gap: 10px;
  align-items: end;
  padding: 16px;
  margin-bottom: 16px;
  background: var(--bg-tertiary, #f8fafc);
  border: 1px solid var(--border-color, #e2e8f0);
  border-radius: 10px;
}

@media (max-width: 900px) {
  .bm-benchmark-preview-bar {
    grid-template-columns: 1fr;
  }
}

.bm-live-report-dialog {
  border: none;
  border-radius: 12px;
  padding: 0;
  width: min(960px, 96vw);
  max-width: 96vw;
  max-height: 94vh;
  box-shadow: 0 24px 64px rgba(15, 23, 42, 0.35);
}

.bm-live-report-dialog::backdrop {
  background: rgba(15, 30, 55, 0.6);
}

.bm-live-report-dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color, #e2e8f0);
  background: var(--bg-tertiary, #f8fafc);
}

.bm-live-report-dialog-header h3 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
}

.bm-live-report-dialog-body {
  overflow: auto;
  max-height: calc(94vh - 56px);
  padding: 20px;
  background: #dde3ea;
  display: flex;
  flex-direction: column;
  gap: 24px;
  align-items: center;
}

/* Prevent flex parent from crushing page cards (causes overlapping content). */
.bm-live-report-dialog-body > .bm-live-report-page,
.bm-preview-dialog-body > .bm-mock {
  flex-shrink: 0;
  flex-grow: 0;
}

.bm-live-report-page {
  width: 100%;
  max-width: 820px;
  position: relative;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  overflow: hidden;
}

.bm-mock-page-logo {
  position: absolute;
  top: 12px;
  right: 14px;
  max-width: 90px;
  max-height: 28px;
  object-fit: contain;
  z-index: 2;
}

.bm-mock-page-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  font-size: 9px;
  color: #64748b;
  border-top: 1px solid #e2e8f0;
  background: #fff;
}

.bm-live-photo-thumb {
  width: 100%;
  max-height: 140px;
  object-fit: cover;
  border-radius: 4px;
  margin-top: 6px;
  display: block;
}

.bm-live-report-notice {
  margin: 0;
  padding: 10px 18px;
  font-size: 12px;
  line-height: 1.45;
  color: #475569;
  background: #fffbeb;
  border-bottom: 1px solid #fde68a;
}

.bm-mock-batch-layout {
  display: grid;
  grid-template-columns: 42% 1fr;
  gap: 24px;
  padding: 8px 40px 24px;
}

.bm-mock-machine-panel {
  background: #f7f9fb;
  border: 1px solid #e2e8f0;
  min-height: 170px;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

.bm-mock-machine-img {
  display: block;
  width: calc(100% - 20px);
  height: 130px;
  margin: 10px auto 0;
  object-fit: contain;
}

.bm-mock-machine-placeholder {
  height: 130px;
  margin: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #94a3b8;
  background: #eef2f6;
  border-radius: 4px;
}

.bm-mock-machine-panel-foot {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 12px;
  background: rgba(255, 255, 255, 0.95);
  border-top: 1px solid #e2e8f0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bm-mock-machine-label {
  font-size: 8px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.06em;
}

.bm-mock-batch-meta {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.bm-mock-meta-row {
  margin: 0;
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 8px;
  font-size: 10px;
}

.bm-mock-meta-label {
  color: #64748b;
  font-weight: 700;
  text-transform: uppercase;
  font-size: 9px;
  letter-spacing: 0.04em;
}

.bm-mock-meta-value {
  color: #1a2332;
}

.bm-mock-results-title {
  margin: 0 0 10px;
  font-size: 12px;
  font-weight: 700;
  color: #1a2332;
  padding-bottom: 6px;
  border-bottom: 2px solid #4fc3ca;
  display: inline-block;
}

.bm-mock-notes-title {
  margin: 12px 0 4px;
  font-size: 10px;
  font-weight: 700;
  color: #64748b;
}

.bm-mock-photos--full {
  padding: 8px 40px 24px;
}

.bm-mock-photo-img {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  border-radius: 4px;
  margin-top: 8px;
  display: block;
  background: #f1f5f9;
}

.bm-live-custom-inner {
  padding: 12px 40px 24px;
}
