.test-app {
  max-width: 1240px;
}

.prototype-pill,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 5px 10px;
  border: 1px solid rgba(14, 165, 233, .22);
  border-radius: 8px;
  background: rgba(224, 242, 254, .64);
  color: var(--primary-hover);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.test-stats {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.test-stats .stat {
  min-height: 108px;
  display: grid;
  grid-template-rows: 20px 34px minmax(30px, auto);
  gap: 8px;
  align-content: start;
  justify-content: stretch;
  padding: 14px 16px 12px 18px;
}

.test-stats .stat span,
.test-stats .stat strong,
.test-stats .stat small {
  margin: 0;
}

.test-stats .stat span {
  align-self: start;
  line-height: 1.2;
}

.test-stats .stat strong {
  align-self: center;
  line-height: 1.15;
}

.test-stats .stat small {
  align-self: start;
  line-height: 1.25;
}

.test-stats .yellow {
  background: #eef7ff;
  border: 1px solid rgba(14, 165, 233, .16);
  box-shadow: inset 4px 0 0 rgba(14, 165, 233, .58);
}

.test-stats .yellow strong {
  color: #0f2a44;
}

.overview-top-row {
  display: grid;
  grid-template-columns: minmax(340px, max-content) minmax(320px, 1fr);
  gap: 18px;
  align-items: start;
}

.order-heading {
  min-width: 0;
}

.overview-push {
  min-height: 44px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 8px;
  align-items: center;
  margin: 0;
  padding: 6px 8px 6px 12px;
  border-color: rgba(14, 165, 233, .22);
  background: rgba(248, 252, 255, .72);
}

.overview-push strong {
  font-size: 12px;
}

.overview-push small {
  font-size: 11px;
}

.overview-push button {
  height: 32px;
  padding: 0 16px;
}

.marja-video-shortcut {
  border-color: rgba(14, 165, 233, .38);
  background: rgba(224, 242, 254, .82);
  color: var(--primary-hover);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
}

.marja-video-modal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-items: center;
  padding: 22px;
}

.marja-video-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 24, 40, .58);
  backdrop-filter: blur(8px);
}

.marja-video-card {
  position: relative;
  z-index: 1;
  width: min(1040px, 100%);
  max-height: calc(100vh - 44px);
  overflow: auto;
  padding: 22px;
  border: 1px solid rgba(203, 222, 242, .9);
  border-radius: 12px;
  background: rgba(248, 252, 255, .97);
  box-shadow: 0 28px 80px rgba(16, 32, 51, .35);
}

.marja-video-head {
  margin-bottom: 14px;
  padding-right: 52px;
}

.marja-video-head h2 {
  margin: 6px 0 0;
  color: #0f2a44;
  font-size: clamp(22px, 3vw, 34px);
  line-height: 1.15;
}

.marja-video-card video {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 10px;
  background: #0f1f33;
  box-shadow: 0 18px 42px rgba(16, 32, 51, .2);
}

.marja-video-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  min-width: 38px;
  height: 38px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(203, 222, 242, .9);
  border-radius: 8px;
  background: rgba(255, 255, 255, .92);
  color: #0f2a44;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}

.marja-video-close:hover,
.marja-video-close:focus-visible {
  background: #fff;
  transform: translateY(-1px);
}

body.marja-video-open {
  overflow: hidden;
}

.test-grid {
  display: grid;
  grid-template-columns: minmax(0, .95fr) minmax(360px, 1.05fr);
  gap: 8px;
  align-items: start;
}

.test-app .upload-row {
  display: grid;
  grid-template-columns: auto minmax(260px, 1fr) minmax(420px, 520px);
  gap: 14px 20px;
  align-items: center;
  padding: 12px 14px;
}

.test-app .file-button {
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.test-app .upload-text {
  justify-content: center;
  min-width: 0;
}

.delivery-cost-control {
  min-width: 0;
  width: 100%;
  min-height: 58px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(128px, 158px);
  gap: 12px;
  align-items: center;
  padding: 6px 8px 6px 14px;
  border: 1px solid rgba(203, 222, 242, .82);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(248, 252, 255, .94) 0%, rgba(241, 248, 255, .82) 100%);
}

.delivery-cost-copy {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.delivery-cost-copy label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
}

.delivery-cost-copy small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.delivery-cost-copy small.active {
  color: #0f6b4f;
  font-weight: 800;
}

.delivery-cost-input {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  height: 44px;
  padding-right: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.delivery-cost-input:focus-within {
  border-color: rgba(14, 165, 233, .62);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, .12);
}

.delivery-cost-input input {
  height: 42px;
  border: 0;
  background: transparent;
  text-align: right;
  box-shadow: none;
}

.delivery-cost-input span {
  color: var(--muted);
  font-weight: 800;
}

.control-card {
  margin-bottom: 8px;
}

.control-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.control-head strong {
  display: block;
  margin-top: 4px;
  font-size: 16px;
}

.order-warning {
  display: none;
  margin: 0 12px 10px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 8px;
  background: #fff7e8;
  color: #92400e;
  font-weight: 800;
}

.order-warning.visible {
  display: block;
}

.range-shell {
  display: grid;
  gap: 10px;
}

.range-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.range-value {
  color: var(--text);
  font-weight: 900;
}

input[type="range"] {
  width: 100%;
  height: 14px;
  margin: 2px 0;
  padding: 0;
  border: 0;
  border-radius: 999px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  background:
    linear-gradient(90deg, var(--range-color, var(--primary)) 0 var(--range-fill, 0%), #dce8f5 var(--range-fill, 0%) 100%);
  accent-color: var(--range-color, var(--primary));
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 14px;
  border-radius: 999px;
  background:
    linear-gradient(90deg, var(--range-color, var(--primary)) 0 var(--range-fill, 0%), #dce8f5 var(--range-fill, 0%) 100%);
}

input[type="range"]::-webkit-slider-thumb {
  width: 28px;
  height: 28px;
  margin-top: -7px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--range-color, var(--primary));
  box-shadow: 0 8px 18px rgba(16, 32, 51, .18);
  box-sizing: border-box;
  -webkit-appearance: none;
}

input[type="range"]::-moz-range-track {
  height: 14px;
  border-radius: 999px;
  background: #dce8f5;
}

input[type="range"]::-moz-range-progress {
  height: 14px;
  border-radius: 999px;
  background: var(--range-color, var(--primary));
}

input[type="range"]::-moz-range-thumb {
  width: 28px;
  height: 28px;
  border: 4px solid #fff;
  border-radius: 50%;
  background: var(--range-color, var(--primary));
  box-shadow: 0 8px 18px rgba(16, 32, 51, .18);
  box-sizing: border-box;
}

input[type="range"]:disabled {
  opacity: .55;
}

.money-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 420px) minmax(180px, 220px);
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}

.money-row label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.input-with-warning {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  height: 44px;
}

.money-row .input-with-warning > input,
.money-row .loyalty-option,
.money-row > button {
  height: 44px;
  min-height: 44px;
}

.money-row .input-with-warning > input {
  padding: 0 14px;
  font-size: 14px;
  font-weight: 800;
}

.money-row .loyalty-option {
  display: flex;
  align-items: center;
  gap: 10px;
  align-self: end;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #f8fbff;
  color: var(--text);
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
}

.money-row .loyalty-option input {
  width: 18px;
  height: 18px;
  margin: 0;
  flex: 0 0 auto;
}

.money-row .loyalty-option span {
  overflow-wrap: anywhere;
}

.money-row > button {
  align-self: end;
  padding: 0 18px;
  font-size: 14px;
  line-height: 1;
}

.warning-box {
  display: none;
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid rgba(245, 158, 11, .28);
  border-radius: 8px;
  background: #fff7e8;
  color: #92400e;
  font-weight: 800;
  line-height: 1.35;
}

.warning-box.visible {
  display: block;
}

.warning-box.danger {
  border-color: rgba(220, 38, 38, .28);
  background: #fef2f2;
  color: #991b1b;
}

.table-tools {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
}

.table-wrap th {
  z-index: 6;
}

.items-table-wrap {
  max-height: 420px;
}

.virtual-spacer td {
  padding: 0;
  border-bottom: 0;
}

.form-grid > select {
  min-width: 0;
}

.history-sort,
.item-sort {
  position: relative;
  width: 100%;
  height: auto;
  min-height: 20px;
  padding: 0 18px 0 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  text-align: center;
}

.history-sort::after,
.item-sort::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 50%;
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid rgba(93, 112, 134, .45);
  transform: translateY(-35%);
}

.history-sort.active,
.item-sort.active {
  color: var(--primary-hover);
}

.history-sort.active[data-direction="asc"]::after,
.item-sort.active[data-direction="asc"]::after {
  border-top: 0;
  border-bottom: 5px solid var(--primary-hover);
}

.history-sort.active[data-direction="desc"]::after,
.item-sort.active[data-direction="desc"]::after {
  border-top-color: var(--primary-hover);
}

.item-code {
  display: grid;
  gap: 4px;
  text-align: left;
}

.code-line {
  display: flex;
  align-items: center;
  gap: 8px;
}

.item-code strong {
  overflow-wrap: anywhere;
}

.item-code small {
  color: var(--muted);
  font-size: 11px;
}

.copy-code,
.reset-item {
  width: 23px;
  height: 23px;
  padding: 0;
  border: 1px solid rgba(14, 165, 233, .22);
  border-radius: 6px;
  background: rgba(224, 242, 254, .62);
  color: var(--primary-hover);
}

.copy-code {
  position: relative;
  flex: 0 0 23px;
}

.copy-code::before,
.copy-code span {
  content: "";
  position: absolute;
  width: 8px;
  height: 10px;
  border-radius: 3px;
}

.copy-code::before {
  left: 9px;
  top: 8px;
  border: 1.5px solid rgba(2, 132, 199, .7);
}

.copy-code span {
  left: 5px;
  top: 4px;
  border: 1.5px solid rgba(14, 165, 233, .45);
  background: rgba(14, 165, 233, .14);
}

.copy-order {
  width: 21px;
  height: 21px;
  border-radius: 5px;
}

.copy-order::before,
.copy-order span {
  width: 10px;
  height: 11px;
  border-radius: 3px;
}

.copy-order::before {
  left: 8px;
  top: 7px;
  border-width: 1.5px;
}

.copy-order span {
  left: 4px;
  top: 3px;
  border-width: 1.5px;
}

#choiceModal .modal-card {
  width: min(680px, calc(100vw - 32px));
  padding: 14px 16px;
}

#choiceModal .modal-card h2 {
  font-size: 18px;
}

#choiceModal .modal-card p {
  margin-bottom: 12px;
  font-size: 13px;
}

#choiceButtons {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

#choiceButtons[data-count="2"] {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

#choiceButtons button {
  width: 100%;
  min-width: 0;
  height: 42px;
  padding: 0 10px;
  font-size: 13px;
  white-space: normal;
}

.range-tooltip {
  position: fixed;
  z-index: 70;
  min-width: 104px;
  padding: 7px 10px;
  border: 1px solid rgba(14, 165, 233, .28);
  border-radius: 8px;
  background: rgba(16, 32, 51, .94);
  color: #fff;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.25;
  text-align: center;
  box-shadow: 0 12px 28px rgba(16, 32, 51, .22);
  pointer-events: none;
  transform: translate(-50%, -100%);
}

.range-tooltip::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -6px;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(16, 32, 51, .94);
  transform: translateX(-50%);
}

.item-controls {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) 96px 34px;
  gap: 8px;
  align-items: center;
}

.item-controls input[type="text"] {
  padding: 7px 9px;
  text-align: center;
}

.inline-warning {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 900;
}

.inline-warning.red {
  border: 1px solid rgba(220, 38, 38, .3);
  background: #fef2f2;
  color: #b91c1c;
}

.inline-warning.amber {
  border: 1px solid rgba(245, 158, 11, .34);
  background: #fff7e8;
  color: #92400e;
}

.inline-warning[data-tooltip]::before,
.inline-warning[data-tooltip]::after {
  position: absolute;
  z-index: 25;
  opacity: 0;
  pointer-events: none;
  transition: opacity .12s ease, transform .12s ease;
}

.inline-warning[data-tooltip]::before {
  content: attr(data-tooltip);
  right: 50%;
  bottom: calc(100% + 9px);
  width: max-content;
  max-width: 280px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #102033;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
  transform: translate(50%, 4px);
}

.inline-warning[data-tooltip]::after {
  content: "";
  right: 50%;
  bottom: calc(100% + 3px);
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid #102033;
  transform: translate(50%, 4px);
}

.inline-warning[data-tooltip]:hover::before,
.inline-warning[data-tooltip]:hover::after,
.inline-warning[data-tooltip]:focus-visible::before,
.inline-warning[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(50%, 0);
}

.status-risk-low {
  background: var(--green);
  border: 1px solid rgba(16, 185, 129, .18);
  box-shadow: inset 4px 0 0 rgba(16, 185, 129, .68);
}

.status-risk-high {
  background: #fff7e8;
  border: 1px solid rgba(245, 158, 11, .24);
  box-shadow: inset 4px 0 0 rgba(245, 158, 11, .76);
}

.status-risk-limit {
  background: #fef2f2;
  border: 1px solid rgba(220, 38, 38, .22);
  box-shadow: inset 4px 0 0 rgba(220, 38, 38, .68);
}

@media (max-width: 980px) {
  .test-stats,
  .test-grid,
  .overview-top-row,
  .upload-row,
  .money-row,
  .table-tools {
    grid-template-columns: 1fr;
  }

  .delivery-cost-control {
    width: 100%;
    margin-left: 0;
    grid-template-columns: minmax(0, 1fr) minmax(128px, 158px);
  }

  .test-app .file-button {
    width: 100%;
  }

  .test-app .upload-text {
    text-align: center;
  }

  .overview-push {
    grid-template-columns: 1fr;
  }

  .marja-video-shortcut {
    width: 100%;
  }

  .item-controls {
    grid-template-columns: 1fr;
  }

  #choiceButtons {
    gap: 8px;
  }

  #choiceButtons button {
    height: 48px;
    padding: 0 8px;
    font-size: 12px;
  }
}
