/* Platform collection workspace. Shared rules stay in styles.css. */
:root {
  --page-max: 100%;
  --page-pad: clamp(16px, 1.7vw, 32px);
  --workspace-blue: #087cf0;
  --workspace-blue-dark: #0066d6;
  --workspace-height: clamp(350px, calc(100vh - 500px), 720px);
}

body {
  overflow-x: hidden;
  background: #f5f5f7;
}

main {
  width: 100%;
  max-width: none;
  margin: 12px 0 20px;
  padding-inline: var(--page-pad);
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  overflow: visible;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.metrics .metric-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  min-width: 0;
  min-height: 80px;
  align-items: center;
  column-gap: 14px;
  padding: 12px 18px;
  border: 1px solid rgba(15, 23, 42, .055);
  border-radius: 16px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .035), 0 8px 24px rgba(15, 23, 42, .045);
}

.metrics .metric-card + .metric-card {
  border-left: 1px solid rgba(15, 23, 42, .055);
}

.metrics .metric-icon {
  display: grid;
  width: 42px;
  height: 42px;
  margin-top: 0;
  flex: 0 0 42px;
  place-items: center;
  align-self: center;
  justify-self: start;
  border-radius: 12px;
}

.metrics .metric-icon svg {
  display: block;
  width: 23px;
  height: 23px;
  margin: auto;
  fill: currentColor;
  stroke: none;
}

.metric-icon.metric-blue { color: #347fd7; background: #edf5ff; }
.metric-icon.metric-green { color: #3e9068; background: #eef8f2; }
.metric-icon.metric-purple { color: #786ab3; background: #f3effb; }
.metric-icon.metric-orange { color: #b8782b; background: #fff5e8; }

.metric-copy {
  display: grid;
  min-width: 0;
  min-height: 48px;
  align-content: center;
}

.metrics .metric-copy b {
  color: #111827;
  font-size: clamp(25px, 1.7vw, 32px);
  font-weight: 710;
  letter-spacing: -.04em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metrics .metric-copy small {
  display: block;
  margin-top: 5px;
  color: #667085;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.step-nav {
  position: relative;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  min-height: 56px;
  margin-top: 10px;
  padding: 5px 18px;
  border: 1px solid rgba(15, 23, 42, .05);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 7px 24px rgba(15, 23, 42, .035);
}

.step-nav button {
  position: relative;
  z-index: 1;
  display: flex;
  min-width: 0;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  gap: clamp(8px, 1vw, 18px);
  padding: 4px 8px;
  border-radius: 12px;
  background: transparent;
  color: #111827;
  font-size: clamp(12px, .85vw, 15px);
  font-weight: 650;
}

.step-nav button span {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  border-radius: 50%;
  background: #f0f3f7;
  color: #111827;
  font-size: 14px;
  font-weight: 700;
}

.step-nav button::after {
  position: absolute;
  right: -16%;
  width: 32%;
  height: 1px;
  background: #c2cad6;
  content: "";
}

.step-nav button:last-child::after { display: none; }
.step-nav button:hover { margin-inline: 8px; background: rgba(8, 124, 240, .035); box-shadow: none; }
.step-nav button.active { background: transparent; color: #111827; box-shadow: none; }
.step-nav button.active::after { background: #86bdfb; }

.step-nav button.active span {
  background: linear-gradient(180deg, #1687ff, #0875ee);
  color: #fff;
  box-shadow: 0 3px 10px rgba(10, 122, 255, .18);
}

.issue-table thead th,
.result-table thead th {
  background: var(--track);
  color: var(--text);
  border-bottom-color: var(--hairline);
  box-shadow: none;
}

.result-actions .result-filters {
  justify-content: flex-start;
}

.result-actions .result-filters input,
.result-actions .result-filters select,
.result-actions .result-filters button {
  font-size: 13px;
}

html.table-view,
body.table-view {
  height: 100%;
  overscroll-behavior: none;
  overflow-y: hidden;
}

body.table-view main {
  display: flex;
  height: calc(100vh - 24px);
  min-height: 0;
  flex-direction: column;
  margin-block: 12px;
}

body.table-view .metrics,
body.table-view .step-nav,
body.table-view .result-actions,
body.table-view .pagination {
  flex: 0 0 auto;
}

body.table-view [data-step-panel="3"].active,
body.table-view [data-step-panel="4"].active {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  overflow: hidden;
}

body.table-view #issues,
body.table-view #results {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
}

body.table-view #issues .table-wrap,
body.table-view #results .table-wrap {
  width: 100%;
  height: 100%;
  max-height: none;
}

body.table-view .pagination {
  justify-content: flex-end;
  gap: 10px;
  margin-top: 10px;
  padding-right: 8px;
  flex-wrap: wrap;
}

body.table-view .pagination button {
  min-height: 34px;
  padding-inline: 13px;
  font-size: 13px;
}

body.table-view .pagination span {
  font-size: 13px;
}

body.table-view #pagination #resultPageSize {
  width: 132px;
  min-height: 34px;
  margin: 0;
  font-size: 13px;
}

.platform-panel {
  margin-top: 10px;
  padding: 0;
  background: transparent;
  border-radius: 0;
  box-shadow: none;
}

.platform-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.08fr) minmax(420px, .92fr);
  gap: 12px;
  min-height: var(--workspace-height);
}

.collector-card,
.runtime-card,
.footer-tool {
  min-width: 0;
  border: 1px solid rgba(15, 23, 42, .06);
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .04), 0 10px 32px rgba(15, 23, 42, .045);
}

.collector-card {
  display: flex;
  min-height: var(--workspace-height);
  flex-direction: column;
  padding: 18px;
}

.card-heading,
.footer-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.card-heading h3,
.footer-title h3 {
  margin: 0;
  color: #111827;
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.018em;
}

.heading-icon {
  display: grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-radius: 50%;
  background: #edf6ff;
  color: var(--workspace-blue);
}

.heading-icon svg,
.collection-actions svg,
.template-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.collector-card > .card-heading .status-chip { margin-left: auto; }

.status-chip {
  padding: 5px 10px;
  border-radius: var(--r-pill);
  background: #f1f3f6;
  color: #7b8494;
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}

.status-chip.ok { background: #eaf8ef; color: #178645; }

.platform-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.platform-choice {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 112px;
  align-items: center;
  padding: 14px;
  border: 1px solid #e2e7ee;
  border-radius: 16px;
  background: #fbfcfe;
  box-shadow: none;
  transition: border-color .2s, background .2s, box-shadow .2s;
}

.platform-choice.is-selected {
  border-color: #8bc2ff;
  background: #f4f9ff;
  box-shadow: 0 0 0 2px rgba(10, 122, 255, .055);
}

.platform-selector {
  position: relative;
  display: grid;
  grid-template-columns: minmax(102px, 118px) minmax(0, 1fr);
  min-width: 0;
  min-height: 72px;
  align-items: center;
  gap: 14px;
  padding: 0 0 0 28px;
  border-radius: 0;
  background: transparent;
  color: #111827;
  text-align: left;
}

.platform-selector:hover { filter: none; }
.platform-selector:active { transform: none; }

.platform-check {
  position: absolute;
  top: -4px;
  left: -4px;
  z-index: 2;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  border: 1px solid #cbd3df;
  border-radius: 7px;
  background: #fff;
  color: transparent;
}

.platform-check svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.platform-choice.is-selected .platform-check {
  border-color: var(--workspace-blue);
  background: var(--workspace-blue);
  color: #fff;
}

.platform-logo {
  width: 100%;
  max-width: 118px;
  height: 54px;
  padding: 6px 8px;
  object-fit: contain;
  object-position: left center;
  border: 1px solid rgba(15, 23, 42, .055);
  border-radius: 12px;
  background: rgba(255, 255, 255, .76);
  filter: saturate(.88) contrast(.98);
  image-rendering: auto;
}

.platform-choice-copy {
  display: grid;
  min-width: 0;
  gap: 5px;
}

.platform-choice-copy b {
  overflow: hidden;
  color: #121826;
  font-size: 16px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-choice .platform-state {
  display: flex;
  align-items: center;
  gap: 6px;
  overflow: hidden;
  color: #7b8494;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-choice .platform-state::before {
  width: 7px;
  height: 7px;
  flex: 0 0 7px;
  border-radius: 50%;
  background: #b5bdc9;
  content: "";
}

.platform-choice.is-ready .platform-state { color: #158347; }
.platform-choice.is-ready .platform-state::before { background: #16bf68; }

.platform-open {
  width: 56px;
  height: 56px;
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
  color: #667085;
  font-size: 0;
}

.platform-open::after {
  font-size: 40px;
  font-weight: 350;
  line-height: 1;
  content: "›";
}

.platform-open:hover { background: rgba(8, 124, 240, .07); color: var(--workspace-blue); filter: none; }

.collection-control {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: auto;
  padding-top: 14px;
  border-top: 1px solid #e7ebf0;
}

.collection-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.collection-actions button {
  min-height: 42px;
  border-radius: 11px;
  font-size: 13px;
}

.collection-actions button svg {
  width: 18px;
  height: 18px;
  margin-right: 7px;
}

.collection-actions #startAllPlatforms {
  margin: 0;
  background: linear-gradient(180deg, #1687ff, #0875ee);
  box-shadow: 0 8px 18px rgba(10, 122, 255, .16);
}

.collection-actions #testOneProduct {
  background: #eaf4ff;
  color: #0875ee;
}

.stop-button {
  margin: 0;
  border: 1px solid #ffb2b9;
  background: #fff;
  color: #d92b3a;
}

.stop-button:hover { background: #fff5f6; filter: none; }

.runtime-card {
  min-height: var(--workspace-height);
  overflow: hidden;
}

.runtime-head {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid #edf0f4;
}

.runtime-state {
  display: flex;
  align-items: center;
  gap: 7px;
  color: #778195;
  font-size: 12px;
  font-weight: 650;
  white-space: nowrap;
}

.runtime-state i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #a9b1bd;
}

.runtime-state.running { color: #087a42; }
.runtime-state.running i { background: #18bd68; animation: runtimePulse 1.7s infinite; }
.runtime-state.complete { color: #087a42; }
.runtime-state.complete i { background: #18bd68; }
.runtime-state.warning { color: #b76605; }
.runtime-state.warning i { background: #f59d23; }
.runtime-state.error { color: #c52233; }
.runtime-state.error i { background: #e53b4b; }
.runtime-state.stopped i { background: #8992a2; }

.runtime-log {
  height: calc(var(--workspace-height) - 58px);
  overflow-y: auto;
  padding: 6px 16px 12px;
  scrollbar-gutter: stable;
  background: #fcfdff;
}

.runtime-empty {
  display: grid;
  min-height: 100%;
  place-items: center;
  margin: 0;
  color: #99a2b0;
  font-size: 13px;
}

.runtime-row {
  display: grid;
  grid-template-columns: 68px 10px minmax(0, 1fr);
  min-height: 34px;
  align-items: start;
  gap: 9px;
  padding: 8px 0;
  border-bottom: 1px solid #eef1f5;
  color: #4d596d;
  font-size: 12.5px;
  line-height: 1.4;
}

.runtime-row:last-child { border-bottom: 0; }
.runtime-row time { color: #8b95a5; font-variant-numeric: tabular-nums; }
.runtime-row i { width: 8px; height: 8px; margin-top: 4px; border-radius: 50%; background: #2588f4; }
.runtime-row.success i { background: #18b868; }
.runtime-row.warning i { background: #ef9b23; }
.runtime-row.error i { background: #df3b4a; }
.runtime-row.error span { color: #b52231; }
.runtime-row.warning span { color: #9a5b0c; }

.platform-footer-grid {
  display: grid;
  grid-template-columns: minmax(200px, 1fr) minmax(340px, 1.2fr) minmax(220px, .86fr);
  gap: 12px;
  margin-top: 12px;
}

.footer-tool {
  display: flex;
  min-height: 112px;
  align-items: stretch;
  justify-content: space-between;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
}

.footer-title { min-width: 0; }
.footer-title p { margin: 3px 0 0; color: #858e9d; font-size: 11.5px; line-height: 1.35; }

.footer-tool select {
  min-height: 48px;
  margin: 0;
  padding-inline: 14px;
  border-radius: 12px;
  font-size: 13px;
}

.footer-tool .upload-dropzone.compact {
  width: 100%;
  min-height: 48px;
  padding: 6px 12px;
  border-radius: 12px;
  background: #fbfcfe;
}

.footer-tool .upload-dropzone.compact .upload-plus {
  width: 34px;
  height: 34px;
  flex-basis: 34px;
  font-size: 21px;
}

.footer-tool .upload-copy strong { font-size: 12.5px; }
.footer-tool .file-name { max-width: none; margin-top: 2px; font-size: 11.5px; }

.template-button {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 16px;
  border: 1px solid #82baff;
  border-radius: 12px;
  background: #f5faff;
  color: #0872e3;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}

.template-button:hover { background: #eaf5ff; }

@keyframes runtimePulse { 50% { opacity: .42; transform: scale(.82); } }

@media (min-width: 2200px) {
  .metrics,
  .platform-layout,
  .platform-footer-grid { gap: 14px; }
  .platform-panel { margin-top: 12px; }
  .platform-footer-grid { margin-top: 14px; }
}

@media (max-width: 1180px) {
  .platform-layout { grid-template-columns: minmax(0, 1.04fr) minmax(390px, .96fr); }
  .platform-selector { grid-template-columns: minmax(92px, 106px) minmax(0, 1fr); gap: 10px; padding-left: 26px; }
  .platform-logo { max-width: 106px; height: 50px; }
  .platform-footer-grid { grid-template-columns: .8fr 1.25fr .8fr; }
}

@media (max-width: 980px) {
  .platform-layout { grid-template-columns: 1fr; min-height: auto; }
  .collector-card { min-height: 350px; }
  .runtime-card { min-height: 310px; }
  .runtime-log { height: 252px; }
  .platform-footer-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .platform-footer-grid .footer-tool:last-child { grid-column: 1 / -1; }
}

@media (max-width: 760px) {
  :root { --page-pad: 12px; }
  main { margin-top: 10px; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .metrics .metric-card { min-height: 70px; gap: 10px; padding: 10px 12px; }
  .metrics .metric-card { grid-template-columns: 38px minmax(0, 1fr); }
  .metrics .metric-icon { width: 38px; height: 38px; flex-basis: 38px; border-radius: 11px; }
  .metrics .metric-icon svg { width: 21px; height: 21px; }
  .metrics .metric-copy b { font-size: 24px; }
  .step-nav { min-height: 50px; padding: 3px 4px; }
  .step-nav button { min-height: 42px; gap: 4px; padding-inline: 3px; font-size: 11px; }
  .step-nav button span { width: 24px; height: 24px; font-size: 12px; }
  .step-nav button::after { display: none; }
  .collector-card { min-height: auto; padding: 14px; }
  .platform-choice-grid { grid-template-columns: 1fr; }
  .platform-choice { min-height: 104px; padding: 12px; }
  .platform-selector { grid-template-columns: minmax(84px, 96px) minmax(0, 1fr); padding-left: 26px; }
  .platform-logo { max-width: 96px; height: 48px; }
  .collection-control { margin-top: 16px; }
  .collection-actions { grid-template-columns: 1fr 1fr; }
  .collection-actions button { min-height: 48px; font-size: 14px; }
  .platform-footer-grid { grid-template-columns: 1fr; }
  .platform-footer-grid .footer-tool:last-child { grid-column: auto; }
  .footer-tool { min-height: 106px; padding: 12px 14px; }
  .runtime-log { height: 240px; }
}

@media (max-width: 520px) {
  .metrics .metric-icon { display: none; }
  .metrics .metric-card { grid-template-columns: 1fr; justify-content: center; text-align: center; }
  .platform-selector { grid-template-columns: minmax(80px, 90px) minmax(0, 1fr); padding-left: 24px; }
  .platform-logo { max-width: 90px; height: 46px; padding: 5px 6px; }
  .collection-actions { grid-template-columns: 1fr; }
}

@media (max-width: 760px) {
  html.table-view,
  body.table-view { height: auto; overflow-y: auto; }
  body.table-view main { display: block; height: auto; margin-block: 10px 20px; }
  body.table-view [data-step-panel="3"].active,
  body.table-view [data-step-panel="4"].active { display: block; overflow: visible; }
  body.table-view #issues,
  body.table-view #results { display: block; }
  body.table-view #issues .table-wrap,
  body.table-view #results .table-wrap { height: auto; max-height: 60vh; }
  body.table-view .pagination { justify-content: center; padding-right: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .runtime-state.running i { animation: none; }
}
