/* Version 2.5 */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap');

:root{
  --ats-font:'Manrope','Helvetica Neue',Arial,sans-serif;
  --ats-bg:#eef2f6;
  --ats-bg-grad:radial-gradient(1200px 320px at 8% -10%, rgba(37, 99, 235, 0.08), transparent 55%), radial-gradient(900px 240px at 92% -12%, rgba(22, 163, 74, 0.07), transparent 54%), linear-gradient(180deg, #f8fafc 0%, #eef2f6 100%);
  --ats-surface:#ffffff;
  --ats-surface-soft:#f8fafc;
  --ats-border:#d8e0ea;
  --ats-border-strong:#bfd0e2;
  --ats-ink:#0f172a;
  --ats-text:#1f2937;
  --ats-muted:#5f6e7f;
  --ats-accent:#2563eb;
  --ats-accent-strong:#1d4ed8;
  --ats-accent-soft:rgba(37,99,235,0.12);
  --ats-success:#15803d;
  --ats-danger:#b42318;
  --ats-radius-sm:10px;
  --ats-radius-md:14px;
  --ats-radius-lg:18px;
  --ats-shadow-sm:0 8px 22px -18px rgba(15, 23, 42, 0.35);
  --ats-shadow-md:0 20px 42px -28px rgba(15, 23, 42, 0.42);
  --ats-shadow-lg:0 30px 60px -42px rgba(15, 23, 42, 0.55);
}

.ats-gb,
.ats-gb *,
.ats-gb *::before,
.ats-gb *::after{
  box-sizing:border-box;
}

.ats-gb{
  display:grid;
  gap:16px;
  width:100%;
  max-width:1140px;
  margin:0 auto;
  padding:18px;
  border:1px solid var(--ats-border);
  border-radius:24px;
  background:var(--ats-bg-grad);
  color:var(--ats-text);
  font-family:var(--ats-font);
  font-weight:500;
  box-shadow:var(--ats-shadow-md);
}

.ats-gb__header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:14px;
  padding:4px 4px 0;
}

.ats-gb__title{
  margin:0;
  color:var(--ats-ink);
  font-size:clamp(1.35rem, 1.08rem + 1vw, 1.75rem);
  line-height:1.15;
  font-weight:800;
  letter-spacing:0.01em;
}

.ats-gb__subtitle{
  margin-top:4px;
  font-size:0.86rem;
  color:var(--ats-muted);
}

.ats-gb__build{
  flex:0 0 auto;
  padding:8px 11px;
  border:1px solid var(--ats-border);
  border-radius:999px;
  background:var(--ats-surface);
  font-size:0.76rem;
  color:var(--ats-muted);
  font-weight:700;
  box-shadow:var(--ats-shadow-sm);
}

.ats-gb__progress{
  display:flex;
  align-items:center;
  gap:12px;
  padding:12px 14px;
  border:1px solid var(--ats-border);
  border-radius:var(--ats-radius-md);
  background:var(--ats-surface);
  box-shadow:var(--ats-shadow-sm);
}

.ats-gb__progress-text{
  white-space:nowrap;
  font-size:0.76rem;
  line-height:1;
  font-weight:800;
  color:#37516a;
  letter-spacing:0.08em;
  text-transform:uppercase;
}

.ats-gb__progress-track{
  position:relative;
  flex:1;
  height:10px;
  border-radius:999px;
  background:#e6edf6;
  overflow:hidden;
}

.ats-gb__progress-bar{
  position:absolute;
  inset:0 auto 0 0;
  width:20%;
  border-radius:999px;
  background:linear-gradient(90deg, var(--ats-accent) 0%, #4f8df6 100%);
  transition:width .25s ease;
}

.ats-builder-fallback{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:10px;
  margin:0 8px;
  padding:12px 14px;
  border:1px solid rgba(180,83,9,0.28);
  border-radius:var(--ats-radius-md);
  background:#fff8ea;
  color:#78350f;
  font-size:0.84rem;
}

.ats-builder-fallback a{
  color:#1e40af;
  font-weight:700;
  text-decoration:underline;
}

.ats-steps{
  display:flex;
  flex-direction:column;
  gap:16px;
}

.ats-steps .ats-step{
  display:none !important;
  padding:18px;
  border:1px solid var(--ats-border);
  border-radius:20px;
  background:var(--ats-surface);
  box-shadow:var(--ats-shadow-sm);
}

.ats-steps .ats-step.is-active{
  display:block !important;
}

.ats-step__header{
  display:flex;
  align-items:flex-start;
  gap:12px;
  margin-bottom:14px;
}

.ats-step__badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-height:30px;
  padding:4px 14px;
  border-radius:999px;
  background:linear-gradient(120deg, #1e3a8a 0%, var(--ats-accent) 100%);
  color:#fff;
  font-size:0.7rem;
  letter-spacing:0.08em;
  text-transform:uppercase;
  font-weight:800;
  white-space:nowrap;
}

.ats-step__title{
  margin:0;
  color:var(--ats-ink);
  font-size:clamp(1.05rem, 0.96rem + 0.48vw, 1.35rem);
  line-height:1.2;
  font-weight:800;
}

.ats-step__meta{
  margin-top:4px;
  color:var(--ats-muted);
  font-size:0.84rem;
}

.ats-step__body{
  display:flex;
  flex-direction:column;
  gap:14px;
}

.ats-step__body > *{
  width:100%;
}

.ats-step__grid{
  display:grid;
  gap:14px;
}

.ats-step__grid--builder{
  align-items:start;
  grid-template-columns:minmax(0,1fr);
}

@media (min-width: 980px){
  .ats-step__grid--builder{
    grid-template-columns:minmax(0,1.05fr) minmax(360px,0.95fr);
  }
}

.ats-step__stack{
  display:flex;
  flex-direction:column;
  gap:14px;
  min-width:0;
}

.ats-builder-aside{
  display:flex;
  flex-direction:column;
  gap:14px;
  min-width:0;
}

@media (min-width: 980px){
  .ats-builder-aside{
    position:sticky;
    top:14px;
    align-self:start;
  }
}

.ats-panel{
  border:1px solid var(--ats-border);
  border-radius:var(--ats-radius-lg);
  background:var(--ats-surface);
  box-shadow:var(--ats-shadow-sm);
  min-width:0;
}

.ats-panel__header{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:10px;
  padding:14px 16px 12px;
  border-bottom:1px solid var(--ats-border);
}

.ats-panel__title{
  color:var(--ats-ink);
  font-size:1rem;
  font-weight:800;
}

.ats-panel__meta{
  font-size:0.78rem;
  color:var(--ats-muted);
}

.ats-gb__series{
  display:grid;
  grid-template-columns:repeat(auto-fit, minmax(270px, 1fr));
  gap:14px;
}

.ats-series-card{
  position:relative;
  display:grid;
  gap:0;
  width:100%;
  aspect-ratio:16 / 10;
  overflow:hidden;
  border:2px solid var(--ats-border);
  border-radius:18px;
  background:linear-gradient(180deg, #f8fbff 0%, #f2f6fb 100%);
  box-shadow:var(--ats-shadow-sm);
  cursor:pointer;
  transition:border-color .2s ease, box-shadow .2s ease, transform .2s ease;
}

.ats-series-card:hover{
  transform:translateY(-2px);
  border-color:var(--ats-border-strong);
  box-shadow:var(--ats-shadow-md);
}

.ats-series-card input{
  position:absolute;
  inset:0;
  opacity:0;
}

.ats-series-card__img{
  width:100% !important;
  height:100% !important;
  min-height:0;
  padding:42px 0 0;
  object-fit:cover !important;
  object-position:center;
  display:block;
}

.ats-series-card__title{
  position:absolute !important;
  z-index:3;
  top:10px;
  left:50% !important;
  right:auto !important;
  width:calc(100% - 20px) !important;
  max-width:calc(100% - 20px) !important;
  min-height:34px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:7px 12px;
  border:1px solid var(--ats-border);
  border-radius:999px;
  background:rgba(255,255,255,0.95);
  color:#1f3348;
  font-weight:800;
  font-size:0.75rem;
  letter-spacing:0.05em;
  text-transform:uppercase;
  text-align:center;
  line-height:1;
  direction:ltr;
  unicode-bidi:isolate;
  transform:translateX(-50%) !important;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.ats-series-card.is-active .ats-series-card__title{
  width:calc(100% - 20px) !important;
  max-width:calc(100% - 20px) !important;
}

.ats-series-card.is-active{
  border-color:var(--ats-accent);
  box-shadow:0 0 0 4px var(--ats-accent-soft), var(--ats-shadow-md);
}

.ats-gb__sizes{
  display:grid;
  grid-template-columns:1fr;
  gap:8px;
  padding:10px 14px 8px;
}

.ats-leaf-builder{
  display:grid;
  gap:7px;
}

.ats-leaf-row{
  display:grid;
  grid-template-columns:minmax(188px, 236px) minmax(180px, 1fr) 38px;
  align-items:center;
  gap:8px;
  min-height:48px;
  padding:6px;
  border:1px solid #c8d7e3;
  border-radius:12px;
  background:#fff;
  box-shadow:0 10px 20px -20px rgba(15,23,42,0.5);
}

.ats-leaf-row.is-empty{
  border-style:dashed;
  background:#fbfdff;
}

.ats-leaf-row__visual{
  display:grid;
  grid-template-columns:28px minmax(0,1fr);
  align-items:center;
  gap:8px;
  min-width:0;
}

.ats-leaf-row__index{
  display:grid;
  place-items:center;
  width:26px;
  height:26px;
  border-radius:999px;
  background:#e8f2f7;
  color:#17465d;
  font-size:0.76rem;
  font-weight:800;
}

.ats-leaf-row.is-filled .ats-leaf-row__index{
  background:#137c8a;
  color:#fff;
}

.ats-leaf-row__plate{
  position:relative;
  display:flex;
  align-items:center;
  min-width:0;
  min-height:34px;
  padding:5px 10px 5px 36px;
  border:1px solid #c5d3df;
  border-radius:999px 6px 6px 999px;
  background:linear-gradient(90deg, #f7fbfd 0%, #ffffff 52%, #eef4f8 100%);
  color:#162632;
  overflow:hidden;
}

.ats-leaf-row.is-empty .ats-leaf-row__plate{
  color:#496679;
  background:linear-gradient(90deg, #f9fcfe 0%, #ffffff 58%, #f4f8fb 100%);
}

.ats-leaf-row__screw{
  position:absolute;
  left:8px;
  top:50%;
  width:20px;
  height:20px;
  border:2px solid #c5d3df;
  border-radius:999px;
  transform:translateY(-50%);
  background:#f8fbfd;
}

.ats-leaf-row__screw::after{
  content:'';
  position:absolute;
  inset:5px;
  border-radius:999px;
  background:#c5d3df;
}

.ats-leaf-row__plate-label{
  min-width:0;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  font-size:0.86rem;
  font-weight:800;
}

.ats-leaf-row__select{
  width:100%;
  min-width:0;
  min-height:38px;
  border:1px solid var(--ats-border-strong);
  border-radius:10px;
  background-color:#fff;
  color:var(--ats-ink);
  padding:0 34px 0 12px;
  font:inherit;
  font-size:0.9rem;
  font-weight:800;
  line-height:1.2;
  appearance:none;
  cursor:pointer;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23425870'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.115l3.71-3.884a.75.75 0 0 1 1.08 1.04l-4.25 4.45a.75.75 0 0 1-1.08 0l-4.25-4.45a.75.75 0 0 1 .02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 10px center;
  background-size:16px;
}

.ats-leaf-row__select:hover{
  border-color:#8fb0c8;
}

.ats-leaf-row__remove{
  display:grid;
  place-items:center;
  width:38px;
  height:38px;
  border:1px solid var(--ats-border);
  border-radius:10px;
  background:#fff;
  color:#4a6274;
  font-size:0.9rem;
  font-weight:800;
  cursor:pointer;
}

.ats-leaf-row__remove:hover{
  border-color:#f3c5bd;
  background:#fff6f4;
  color:var(--ats-danger);
}

.ats-leaf-row__remove:disabled{
  opacity:0.35;
  cursor:not-allowed;
}

.ats-leaf-builder__controls{
  display:flex;
  align-items:center;
  justify-content:space-between;
  flex-wrap:wrap;
  gap:10px;
  margin:0 14px 8px;
}

.ats-btn--leaf-add{
  display:inline-flex;
  align-items:center;
  gap:8px;
  min-height:36px;
  padding:7px 12px;
  color:#183244;
}

.ats-leaf-add__icon{
  position:relative;
  display:inline-grid;
  place-items:center;
  flex:0 0 auto;
  width:18px;
  height:18px;
  border-radius:999px;
  background:#e69a00;
}

.ats-leaf-add__icon::before,
.ats-leaf-add__icon::after{
  content:'';
  position:absolute;
  left:50%;
  top:50%;
  width:9px;
  height:2px;
  border-radius:2px;
  background:#111827;
  transform:translate(-50%, -50%);
}

.ats-leaf-add__icon::after{
  width:2px;
  height:9px;
}

.ats-leaf-builder__limit{
  color:#526b7d;
  font-size:0.78rem;
  font-weight:800;
}

.ats-leaf-builder__message{
  margin:0 14px 10px;
  padding:8px 10px;
  border:1px solid #f2d38a;
  border-radius:10px;
  background:#fff8e7;
  color:#8a5300;
  font-size:0.8rem;
  font-weight:800;
}

.ats-leaf-builder__message[hidden]{
  display:none !important;
}

.ats-gb__actions{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.ats-gb__actions--step{
  justify-content:space-between;
  align-items:center;
}

.ats-gb__actions--step .ats-btn{
  min-width:150px;
}

.ats-sizes-footer{
  margin:0 14px 12px;
  padding:12px 0 0;
  border-top:1px solid var(--ats-border);
  display:flex;
  flex-direction:column;
  gap:10px;
}

.ats-sizes-summary{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
}

.ats-sizes-summary__count{
  color:var(--ats-ink);
  font-size:0.95rem;
  font-weight:800;
}

.ats-inline-meta{
  display:flex;
  align-items:center;
}

.ats-saved-pill{
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:6px 10px;
  border:1px solid #dbe7ff;
  border-radius:999px;
  background:#eef4ff;
  color:#27476a;
  font-size:0.73rem;
  font-weight:700;
}

.ats-selection-summary{
  border:1px solid var(--ats-border);
  border-radius:var(--ats-radius-lg);
  background:var(--ats-surface);
  box-shadow:var(--ats-shadow-sm);
  padding:14px;
  display:flex;
  flex-direction:column;
  gap:12px;
}

.ats-multi-set-hint{
  display:flex;
  flex-direction:column;
  gap:4px;
  padding:11px 12px;
  border:1px solid #bfdbfe;
  border-radius:14px;
  background:linear-gradient(135deg, #eff6ff 0%, #f8fbff 100%);
  color:#1e3a5f;
  box-shadow:0 10px 22px -20px rgba(37,99,235,0.55);
}

.ats-multi-set-hint strong{
  font-size:0.82rem;
  font-weight:800;
  letter-spacing:0.03em;
  text-transform:uppercase;
}

.ats-multi-set-hint span{
  font-size:0.84rem;
  line-height:1.45;
}

.ats-selection-summary__header{
  display:flex;
  flex-direction:column;
  gap:4px;
}

.ats-selection-summary__title{
  margin:0;
  color:var(--ats-ink);
  font-size:0.95rem;
  font-weight:800;
}

.ats-selection-summary__text{
  margin:0;
  color:var(--ats-muted);
  font-size:0.79rem;
}

.ats-selection-summary__stats{
  display:grid;
  grid-template-columns:repeat(2, minmax(0,1fr));
  gap:8px;
}

.ats-selection-summary__stat{
  display:flex;
  flex-direction:column;
  gap:2px;
  padding:9px 10px;
  border:1px solid var(--ats-border);
  border-radius:11px;
  background:#f8fafc;
}

.ats-selection-summary__label{
  color:var(--ats-muted);
  font-size:0.68rem;
  letter-spacing:0.04em;
  text-transform:uppercase;
  font-weight:700;
}

.ats-selection-summary__value{
  color:var(--ats-ink);
  font-size:1.02rem;
  line-height:1;
  font-weight:800;
}

.ats-selection-summary__totals{
  padding:9px 10px;
  border:1px solid var(--ats-border);
  border-radius:11px;
  background:#f8fafc;
  color:#1f3348;
  font-size:0.76rem;
  line-height:1.35;
  font-weight:700;
  min-height:40px;
}

.ats-request-banner{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  gap:8px 10px;
  padding:13px 14px;
  border:1px solid rgba(21,128,61,0.22);
  border-radius:16px;
  background:linear-gradient(135deg, #ecfdf3 0%, #f7fff9 100%);
  color:#166534;
  box-shadow:0 14px 28px -24px rgba(21,128,61,0.5);
}

.ats-request-banner strong{
  font-size:0.86rem;
  font-weight:800;
}

.ats-request-banner span{
  font-size:0.84rem;
  line-height:1.45;
}

.ats-gb__stack-list{
  margin:0;
  padding:0;
  list-style:none;
  display:flex;
  flex-direction:column;
  gap:6px;
}

.ats-gb__stack-list li{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  margin:0;
  padding:8px 10px;
  border:1px solid var(--ats-border);
  border-radius:10px;
  background:#fff;
  font-size:0.82rem;
  color:var(--ats-text);
}

.ats-gb__stack-list li[draggable='true']{
  cursor:grab;
}

.ats-gb__stack-list--live{
  min-height:112px;
  max-height:240px;
  overflow:auto;
  padding-right:2px;
}

.ats-gb__stack-list--live:empty::before{
  content:'No leaves selected yet.';
  display:block;
  padding:12px;
  border:1px dashed var(--ats-border);
  border-radius:10px;
  color:var(--ats-muted);
  font-size:0.78rem;
  text-align:center;
  background:#f8fafc;
}

.ats-handle{
  flex:0 0 auto;
  color:#64748b;
  font-size:0.9rem;
  cursor:grab;
  line-height:1;
}

.ats-size-label{
  flex:1 1 auto;
  font-weight:700;
  overflow-wrap:anywhere;
}

.ats-row-controls{
  display:flex;
  gap:5px;
}

.ats-row-controls .ats-btn{
  padding:4px 7px;
  min-height:24px;
  min-width:24px;
}

.ats-gb__stack-list.is-drag-active li{
  transition:transform .12s ease, box-shadow .12s ease, border-color .12s ease;
}

.ats-gb__stack-list li.is-dragging{
  opacity:0.6;
}

.ats-gb__stack-list li.is-drop-target{
  border-color:var(--ats-border-strong);
}

.ats-gb__stack-list li.is-drop-before::before,
.ats-gb__stack-list li.is-drop-after::after{
  content:'';
  position:absolute;
  left:8px;
  right:8px;
  height:2px;
  border-radius:2px;
  background:var(--ats-accent);
}

.ats-gb__stack-list li.is-drop-before::before{top:-3px}
.ats-gb__stack-list li.is-drop-after::after{bottom:-3px}

.ats-stack-edge-risk{
  border-color:#f59e0b !important;
  background:#fffbeb !important;
}

.ats-stack-edge-risk .ats-size-label{
  color:#9a4b00;
}

.ats-btn{
  appearance:none;
  border:1px solid var(--ats-border);
  border-radius:10px;
  background:#fff;
  color:var(--ats-text);
  min-height:38px;
  padding:8px 13px;
  font-size:0.83rem;
  line-height:1;
  font-weight:800;
  letter-spacing:0.01em;
  cursor:pointer;
  transition:background .15s ease, border-color .15s ease, box-shadow .15s ease, transform .15s ease;
}

.ats-btn:hover{
  border-color:var(--ats-border-strong);
  background:#f8fafc;
  transform:translateY(-1px);
  box-shadow:0 12px 24px -22px rgba(15,23,42,0.52);
}

.ats-btn:disabled{
  opacity:0.48;
  cursor:not-allowed;
  transform:none;
  box-shadow:none;
}

.ats-btn.is-at-limit{
  border-color:#f2d38a;
  background:#fff8e7;
  color:#8a5300;
}

.ats-btn--primary{
  border-color:transparent;
  background:linear-gradient(135deg, var(--ats-accent) 0%, var(--ats-accent-strong) 100%);
  color:#fff;
}

.ats-btn--primary:hover{
  background:linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
  box-shadow:0 16px 28px -18px rgba(29,78,216,0.6);
}

.ats-btn--ghost{
  background:transparent;
}

.ats-btn--icon{
  min-width:30px;
  min-height:30px;
  padding:0;
  display:grid;
  place-items:center;
  font-size:1rem;
}

.ats-btn--tiny{
  min-height:30px;
  padding:6px 9px;
  font-size:0.75rem;
}

.ats-btn--danger{
  color:var(--ats-danger);
}

.ats-btn--danger:hover{
  border-color:#f3c5bd;
  background:#fff6f4;
}

.ats-btn--link{
  padding:2px 0;
  border:none;
  background:none;
  color:#1e3a8a;
  font-size:0.78rem;
  font-weight:700;
  text-decoration:underline;
  min-height:auto;
}

.ats-btn--link:hover{
  color:#1d4ed8;
  box-shadow:none;
  transform:none;
}

.ats-btn.is-loading{
  position:relative;
  pointer-events:none;
  opacity:.8;
}

.ats-btn.is-loading::after{
  content:'';
  position:absolute;
  right:10px;
  top:50%;
  width:14px;
  height:14px;
  margin-top:-7px;
  border:2px solid rgba(255,255,255,0.65);
  border-top-color:#fff;
  border-radius:50%;
  animation:atsSpin .7s linear infinite;
}

@keyframes atsSpin{to{transform:rotate(360deg)}}

.ats-label{
  font-size:0.75rem;
  color:var(--ats-muted);
}

.ats-warning-card,
.ats-stack-confirm__warning{
  border:1px solid rgba(180,35,24,0.25);
  border-radius:14px;
  background:#fff5f4;
}

.ats-warning-card{
  display:flex;
  flex-direction:column;
  gap:12px;
  padding:14px;
}

.ats-warning-card.is-safe,
.ats-stack-confirm__warning.is-safe{
  border-color:rgba(21,128,61,0.3);
  background:#f3fbf6;
}

.ats-warning-head{
  display:flex;
  align-items:flex-start;
  gap:12px;
}

.ats-warning-icon{
  width:42px;
  height:42px;
  border-radius:12px;
  background:#ffe7e3;
  color:#b42318;
  display:grid;
  place-items:center;
  font-size:1.2rem;
  font-weight:800;
}

.ats-warning-card.is-safe .ats-warning-icon{
  background:#e7f7ed;
  color:var(--ats-success);
}

.ats-warning-label,
.ats-stack-confirm__badge{
  display:inline-flex;
  align-items:center;
  min-height:22px;
  padding:3px 8px;
  border-radius:999px;
  background:rgba(180,35,24,0.12);
  color:#9f1239;
  font-size:0.65rem;
  letter-spacing:0.08em;
  text-transform:uppercase;
  font-weight:800;
}

.ats-warning-label.is-safe,
.ats-warning-card.is-safe .ats-warning-label,
.ats-stack-confirm__warning.is-safe .ats-stack-confirm__badge{
  background:rgba(21,128,61,0.14);
  color:var(--ats-success);
}

.ats-warning-title,
.ats-stack-confirm__title{
  margin:6px 0 0;
  color:#7f1d1d;
  font-size:1.05rem;
  font-weight:800;
}

.ats-warning-card.is-safe .ats-warning-title,
.ats-stack-confirm__warning.is-safe .ats-stack-confirm__title{
  color:#166534;
}

.ats-warning-copy p,
.ats-warning-helper,
.ats-stack-confirm__message,
.ats-stack-confirm__helper{
  margin:0;
  color:#6b2d2a;
  font-size:0.82rem;
  line-height:1.45;
}

.ats-warning-card.is-safe .ats-warning-copy p,
.ats-warning-card.is-safe .ats-warning-helper,
.ats-stack-confirm__warning.is-safe .ats-stack-confirm__message,
.ats-stack-confirm__warning.is-safe .ats-stack-confirm__helper{
  color:#14532d;
}

.ats-warning-stack{
  border:1px dashed var(--ats-border-strong);
  border-radius:12px;
  background:#f8fafc;
  padding:12px;
}

.ats-warning-stack__title{
  margin-bottom:6px;
  font-size:0.84rem;
  font-weight:800;
  color:var(--ats-ink);
}

.ats-3d-viewer{
  border:1px solid var(--ats-border);
  border-radius:var(--ats-radius-lg);
  background:var(--ats-surface);
  box-shadow:var(--ats-shadow-sm);
  padding:12px;
  display:flex;
  flex-direction:column;
  gap:10px;
  text-align:center;
}

.ats-3d-viewer__title{
  color:#4b637d;
  font-size:0.68rem;
  letter-spacing:0.1em;
  text-transform:uppercase;
  font-weight:800;
}

.ats-3d-viewer__frame{
  position:relative;
  width:100%;
  min-height:280px;
  aspect-ratio:16 / 9;
  overflow:hidden;
  border:1px solid var(--ats-border);
  border-radius:14px;
  background:radial-gradient(circle at 22% 15%, #f6faff 0%, #edf3f8 55%, #e6edf6 100%);
}

.ats-step[data-step="2"] .ats-3d-viewer__frame{
  min-height:340px;
}

.ats-3d-viewer__frame canvas{
  width:100%;
  height:100%;
  display:block;
}

.ats-3d-viewer__controls{
  position:absolute;
  top:8px;
  right:8px;
  z-index:4;
  display:flex;
  gap:6px;
}

.ats-3d-viewer__ctrl{
  appearance:none;
  border:1px solid var(--ats-border);
  border-radius:9px;
  min-width:30px;
  min-height:30px;
  background:#fff;
  color:#1f3348;
  font-size:0.82rem;
  font-weight:800;
  cursor:pointer;
  box-shadow:var(--ats-shadow-sm);
}

.ats-3d-viewer__status{
  position:absolute;
  inset:0;
  display:grid;
  place-items:center;
  padding:14px;
  font-size:0.8rem;
  color:#4b637d;
  background:linear-gradient(180deg, rgba(255,255,255,0.76), rgba(255,255,255,0.46));
}

.ats-3d-viewer__btn{
  position:absolute;
  left:50%;
  top:50%;
  transform:translate(-50%, -50%);
  min-height:40px;
  border:1px solid var(--ats-border);
  border-radius:999px;
  background:#fff;
  padding:0 16px;
  font-size:0.8rem;
  font-weight:800;
  cursor:pointer;
  box-shadow:var(--ats-shadow-sm);
}

.ats-3d-viewer__caption{
  color:var(--ats-ink);
  font-size:0.86rem;
  font-weight:800;
}

.ats-3d-viewer__hint{
  color:var(--ats-muted);
  font-size:0.76rem;
}

.ats-3d-viewer.is-hidden{
  display:none;
}

.ats-3d-viewer__placeholder{
  min-height:220px;
  border:1px dashed var(--ats-border);
  border-radius:12px;
  padding:14px;
  display:grid;
  place-items:center;
  font-size:0.8rem;
  color:var(--ats-muted);
  background:#f8fafc;
}

.ats-3d-viewer__frame:fullscreen{
  width:100vw;
  height:100vh;
  min-height:auto;
  border:none;
  border-radius:0;
  aspect-ratio:auto;
}

.ats-3d-viewer__frame.is-pseudo-fullscreen{
  position:fixed;
  inset:0;
  width:100vw;
  height:100vh;
  min-height:auto;
  z-index:100000;
  border:none;
  border-radius:0;
  aspect-ratio:auto;
  background:#eef2f6;
}

body.ats-3d-fullscreen-open{
  overflow:hidden;
}

.ats-qty{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.ats-qty--sidebar{
  border:1px solid var(--ats-border);
  border-radius:16px;
  background:#f8fafc;
  padding:14px;
}

.ats-qty__label{
  font-size:0.86rem;
  color:var(--ats-ink);
  font-weight:800;
}

.ats-qty__controls{
  display:flex;
  align-items:center;
  gap:8px;
}

.ats-qty__controls input{
  width:94px;
  height:34px;
  border:1px solid var(--ats-border);
  border-radius:9px;
  background:#fff;
  color:var(--ats-ink);
  text-align:center;
  font-size:0.92rem;
  font-weight:800;
}

.ats-qty__slider{
  margin-top:4px;
}

.ats-qty__range{
  width:100%;
  accent-color:var(--ats-accent);
}

.ats-cert{
  margin-top:4px;
  border:1px dashed var(--ats-border-strong);
  border-radius:12px;
  background:#fff;
  padding:11px;
}

.ats-cert__row{
  display:flex;
  gap:9px;
  align-items:center;
  color:var(--ats-ink);
  font-size:0.82rem;
  font-weight:800;
}

.ats-cert__row input{
  width:18px;
  height:18px;
}

.ats-cert__note{
  margin:6px 0 0;
  color:var(--ats-muted);
  font-size:0.75rem;
  line-height:1.4;
}

.ats-saved{
  border:1px solid var(--ats-border);
  border-radius:14px;
  background:#f8fafc;
  padding:12px;
}

.ats-saved summary{
  color:var(--ats-ink);
  font-size:0.86rem;
  font-weight:800;
  cursor:pointer;
}

.ats-saved__list{
  margin-top:10px;
  display:flex;
  flex-direction:column;
  gap:9px;
}

.ats-saved__item{
  border:1px solid var(--ats-border);
  border-radius:11px;
  background:#fff;
  padding:10px;
  box-shadow:var(--ats-shadow-sm);
}

.ats-saved__item-header{
  display:flex;
  justify-content:space-between;
  gap:8px;
  margin-bottom:5px;
  color:var(--ats-ink);
  font-size:0.82rem;
  font-weight:800;
}

.ats-saved__sizes{
  margin-bottom:5px;
  color:#425870;
  font-size:0.77rem;
  overflow-wrap:anywhere;
}

.ats-saved__cert{
  color:#3f5164;
  font-size:0.73rem;
}

.ats-saved__actions{
  margin-top:7px;
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.ats-empty{
  color:var(--ats-muted);
  font-size:0.82rem;
  padding:8px 0;
}

.ats-form-card{
  border:1px solid var(--ats-border);
  border-radius:18px;
  background:#f8fafc;
  padding:16px;
  display:grid;
  gap:12px;
  grid-template-columns:repeat(2, minmax(0, 1fr));
}

.ats-field{
  display:flex;
  flex-direction:column;
  gap:6px;
  min-height:0;
  padding:9px 10px;
  border:1px solid var(--ats-border);
  border-radius:12px;
  background:#fff;
  transition:border-color .15s ease, box-shadow .15s ease;
}

.ats-field--wide{
  grid-column:1 / -1;
}

.ats-field__label{
  color:#425870;
  font-size:0.66rem;
  letter-spacing:0.08em;
  text-transform:uppercase;
  font-weight:800;
}

.ats-gb .ats-field .ats-field__input{
  display:block !important;
  width:100% !important;
  border:none !important;
  outline:none;
  box-shadow:none !important;
  margin:0 !important;
  padding:0 !important;
  background:transparent !important;
  color:var(--ats-ink) !important;
  font-size:0.92rem !important;
  font-weight:600 !important;
  line-height:1.25 !important;
  height:2.35rem !important;
  min-height:2.35rem !important;
  max-height:2.35rem;
}

.ats-field__input::placeholder{
  color:#94a3b8;
}

.ats-gb .ats-field .ats-field__input--select{
  appearance:none;
  height:2.35rem !important;
  min-height:2.35rem !important;
  max-height:2.35rem;
  line-height:2.35rem !important;
  padding-right:22px !important;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%23425870'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 0 1 1.06.02L10 11.115l3.71-3.884a.75.75 0 0 1 1.08 1.04l-4.25 4.45a.75.75 0 0 1-1.08 0l-4.25-4.45a.75.75 0 0 1 .02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
  background-repeat:no-repeat;
  background-position:right 2px center;
  background-size:16px;
}

.ats-gb .ats-field .ats-field__input--textarea{
  height:auto !important;
  min-height:110px !important;
  max-height:none;
  line-height:1.42 !important;
  padding-top:2px !important;
  resize:vertical;
}

.ats-field:focus-within{
  border-color:#8cb4ff;
  box-shadow:0 0 0 3px rgba(37,99,235,0.16);
}

.ats-optin{
  display:flex;
  align-items:center;
  gap:8px;
  padding:10px 12px;
  border:1px solid var(--ats-border);
  border-radius:12px;
  background:#f8fafc;
  color:#304a64;
  font-size:0.82rem;
  font-weight:600;
}

.ats-optin input{
  width:18px;
  height:18px;
}

.ats-step__actions{
  margin-top:14px;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:10px;
  flex-wrap:wrap;
}

.ats-step__actions--split{
  justify-content:space-between;
}

.ats-step__cta{
  display:flex;
  align-items:center;
  flex-wrap:wrap;
  gap:8px;
}

dialog#atsModal,
dialog#atsStackModal{
  width:min(920px, 94vw);
  max-height:88vh;
  border:none;
  border-radius:16px;
  padding:0;
  background:#fff;
  box-shadow:var(--ats-shadow-lg);
}

dialog#atsModal:not([open]),
dialog#atsStackModal:not([open]){
  display:none;
}

dialog#atsModal::backdrop,
dialog#atsStackModal::backdrop{
  background:rgba(15,23,42,0.56);
}

body.ats-dialog-fallback-open{
  overflow:hidden;
}

body.ats-dialog-fallback-open::before{
  content:'';
  position:fixed;
  inset:0;
  background:rgba(15,23,42,0.56);
  z-index:99990;
}

body.ats-dialog-fallback-open dialog#atsModal[open],
body.ats-dialog-fallback-open dialog#atsStackModal[open]{
  position:fixed;
  inset:0;
  margin:auto;
  z-index:99991;
}

.ats-modal__header{
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:8px;
  padding:12px 14px;
  border-bottom:1px solid var(--ats-border);
}

.ats-modal__title{
  color:var(--ats-ink);
  font-size:0.97rem;
  font-weight:800;
}

.ats-modal__content{
  padding:14px;
  max-height:calc(88vh - 62px);
  overflow:auto;
}

.ats-results-group{
  margin-bottom:14px;
}

.ats-results-group h4{
  margin:0 0 6px;
  color:var(--ats-ink);
  font-size:0.86rem;
}

.ats-chip{
  display:inline-flex;
  align-items:center;
  gap:4px;
  margin:2px;
  padding:3px 8px;
  border:1px solid var(--ats-border);
  border-radius:999px;
  background:#f1f5f9;
  color:#1f3348;
  font-size:0.76rem;
  line-height:1.2;
  overflow-wrap:anywhere;
}

.ats-chip--copy,
.ats-chip--pn{
  cursor:pointer;
}

.ats-chip--copy:hover,
.ats-chip--pn:hover{
  border-color:#c7d7ed;
  background:#eaf2ff;
}

.ats-badge{
  display:inline-flex;
  align-items:center;
  min-height:16px;
  padding:0 6px;
  border:1px solid #f2d089;
  border-radius:999px;
  background:#fff3d5;
  color:#8a4b08;
  font-size:0.62rem;
  font-weight:800;
}

.ats-flag{
  display:inline-block;
  width:9px;
  height:9px;
  border-radius:50%;
  background:#dc2626;
  box-shadow:0 0 0 2px rgba(220,38,38,0.18);
}

.ats-exact{
  margin:12px 0;
  padding:12px;
  border:1px solid #bfd8ff;
  border-radius:12px;
  background:#f3f7ff;
}

.ats-exact__title{
  margin-bottom:6px;
  color:#173e7a;
  font-size:0.9rem;
  font-weight:800;
}

.ats-exact__pns{
  display:flex;
  flex-wrap:wrap;
  gap:6px;
}

.ats-chip--xl{
  font-size:0.88rem;
  padding:5px 10px;
}

.ats-exact__pns .ats-pn-detail{
  flex:1 1 100%;
  width:100%;
}

.ats-pn-detail{
  margin:8px 0;
  padding:9px;
  border:1px solid var(--ats-border);
  border-radius:12px;
  background:#fff;
}

.ats-pn-detail__head{
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:8px;
  margin-bottom:7px;
}

.ats-pn-detail__left{
  display:flex;
  align-items:center;
  gap:8px;
}

.ats-series-thumb{
  width:34px;
  height:34px;
  border:1px solid var(--ats-border);
  border-radius:8px;
  background:#f8fafc;
  object-fit:contain;
}

.ats-pn-title{
  color:var(--ats-ink);
  font-size:0.82rem;
  font-weight:800;
  overflow-wrap:anywhere;
}

.ats-pn-sizes{
  display:flex;
  flex-wrap:wrap;
  gap:5px;
}

.ats-size-badge{
  display:inline-flex;
  align-items:center;
  min-height:24px;
  padding:0 8px;
  border:1px solid #d2e0f4;
  border-radius:999px;
  background:#f1f6fc;
  color:#2d4d70;
  font-size:0.74rem;
  font-weight:700;
}

.ats-sep{
  opacity:0.45;
}

.ats-note{
  margin-top:8px;
  padding:8px;
  border:1px solid #f2c7c0;
  border-left:3px solid #dc2626;
  border-radius:9px;
  background:#fff5f5;
}

.ats-note__title{
  color:#991b1b;
  font-size:0.72rem;
  font-weight:800;
  text-transform:uppercase;
  letter-spacing:0.06em;
}

.ats-note__text{
  margin-top:4px;
  color:#7f1d1d;
  font-size:0.78rem;
  white-space:pre-wrap;
}

#atsStackModal .ats-stack-confirm__columns{
  display:grid;
  grid-template-columns:minmax(0,1fr) minmax(0,1.05fr);
  gap:14px;
  align-items:start;
}

#atsStackModal .ats-stack-confirm__left,
#atsStackModal .ats-stack-confirm__right{
  display:flex;
  flex-direction:column;
  gap:10px;
}

.ats-stack-confirm__copy{
  margin:0;
  color:#455a70;
  font-size:0.81rem;
}

.ats-stack-confirm__viewer{
  display:flex;
  flex-direction:column;
  gap:8px;
}

.ats-stack-confirm__viewer-slot .ats-3d-viewer__frame{
  min-height:220px;
  aspect-ratio:4 / 3;
}

.ats-stack-confirm__top,
.ats-stack-confirm__bottom,
.ats-stack-confirm__hint{
  color:var(--ats-muted);
  font-size:0.65rem;
  letter-spacing:0.08em;
  text-transform:uppercase;
  font-weight:700;
}

.ats-stack-confirm__list{
  margin:0;
  padding:0;
  list-style:none;
  display:flex;
  flex-direction:column;
  gap:6px;
  max-height:42vh;
  overflow:auto;
}

.ats-stack-confirm__list li{
  position:relative;
  display:flex;
  align-items:center;
  gap:8px;
  padding:7px 8px;
  border:1px solid var(--ats-border);
  border-radius:10px;
  background:#fff;
}

.ats-stack-confirm__list li[draggable='true']{
  cursor:grab;
}

.ats-stack-confirm__list li.is-dragging{
  opacity:0.58;
}

.ats-stack-confirm__list li.is-drop-target{
  border-color:var(--ats-border-strong);
}

.ats-stack-confirm__list li.is-drop-before::before,
.ats-stack-confirm__list li.is-drop-after::after{
  content:'';
  position:absolute;
  left:8px;
  right:8px;
  height:2px;
  border-radius:2px;
  background:var(--ats-accent);
}

.ats-stack-confirm__list li.is-drop-before::before{top:-3px}
.ats-stack-confirm__list li.is-drop-after::after{bottom:-3px}

.ats-stack-confirm__index{
  flex:0 0 auto;
  min-width:24px;
  min-height:24px;
  padding:0 6px;
  border-radius:8px;
  border:1px solid var(--ats-border);
  background:#f8fafc;
  color:#1f3348;
  display:grid;
  place-items:center;
  font-size:0.74rem;
  font-weight:800;
}

.ats-stack-confirm__label{
  color:var(--ats-ink);
  font-size:0.82rem;
  font-weight:700;
  overflow-wrap:anywhere;
}

.ats-stack-confirm__actions,
.ats-stack-confirm__buttons{
  display:flex;
  flex-wrap:wrap;
  gap:8px;
}

.ats-drag-ghost{
  position:absolute;
  top:-9999px;
  left:-9999px;
  max-width:180px;
  padding:6px 8px;
  border-radius:8px;
  background:rgba(15,23,42,0.9);
  color:#fff;
  font-size:0.72rem;
  font-weight:700;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}

.ats-update-modal{
  position:fixed;
  inset:0;
  z-index:99999;
  display:grid;
  place-items:center;
  padding:16px;
  background:rgba(15,23,42,0.56);
}

.ats-update-modal[hidden]{
  display:none;
}

.ats-update-modal__card{
  width:min(460px, 94vw);
  border:1px solid var(--ats-border);
  border-radius:16px;
  background:#fff;
  padding:16px;
  box-shadow:var(--ats-shadow-lg);
}

.ats-update-modal__title{
  color:var(--ats-ink);
  font-size:1.05rem;
  font-weight:800;
}

.ats-update-modal__message{
  margin:8px 0 0;
  color:#475569;
  font-size:0.85rem;
}

.ats-update-modal__actions{
  margin-top:14px;
  display:flex;
  justify-content:flex-end;
  flex-wrap:wrap;
  gap:8px;
}

.ats-step,
.ats-step__body,
.ats-panel,
.ats-form-card,
.ats-field,
.ats-pn-detail,
.ats-saved__item{
  min-width:0;
}

/* Strong focus treatment for keyboard users */
.ats-gb button:focus-visible,
.ats-gb a:focus-visible,
.ats-gb input:focus-visible,
.ats-gb select:focus-visible,
.ats-gb textarea:focus-visible,
.ats-gb summary:focus-visible,
.ats-gb dialog:focus-visible,
.ats-leaf-row__select:focus-visible,
.ats-leaf-row__remove:focus-visible,
.ats-btn--leaf-add:focus-visible,
.ats-3d-viewer__ctrl:focus-visible,
.ats-3d-viewer__btn:focus-visible{
  outline:2px solid #1d4ed8;
  outline-offset:2px;
  box-shadow:0 0 0 4px rgba(29,78,216,0.2);
}

@media (max-width: 980px){
  .ats-gb{
    padding:12px;
    border-radius:18px;
  }

  .ats-step{
    padding:14px;
  }

  .ats-panel__header{
    flex-direction:column;
  }

  .ats-3d-viewer__frame{
    min-height:240px;
  }

  .ats-step[data-step="2"] .ats-3d-viewer__frame{
    min-height:260px;
  }

  #atsStackModal .ats-stack-confirm__columns{
    grid-template-columns:1fr;
  }

  .ats-stack-confirm__list{
    max-height:34vh;
  }
}

@media (max-width: 820px){
  .ats-form-card{
    grid-template-columns:1fr;
  }

  .ats-field--wide{
    grid-column:1;
  }

  .ats-step__actions,
  .ats-step__cta{
    width:100%;
  }

  .ats-step__actions{
    align-items:stretch;
  }

  .ats-step__cta .ats-btn,
  .ats-step__actions > .ats-btn{
    width:100%;
  }

  .ats-gb__actions--step .ats-btn{
    min-width:0;
  }

  .ats-leaf-row{
    grid-template-columns:minmax(172px, 224px) minmax(160px, 1fr) 38px;
  }
}

@media (max-width: 640px){
  .ats-gb{
    padding:10px;
    border-radius:14px;
    gap:12px;
  }

  .ats-gb__header{
    flex-direction:column;
    align-items:flex-start;
    gap:8px;
  }

  .ats-gb__progress{
    flex-direction:column;
    align-items:flex-start;
  }

  .ats-gb__progress-track{
    width:100%;
  }

  .ats-step__header{
    flex-direction:column;
    gap:8px;
  }

  .ats-step__badge{
    min-height:26px;
  }

  .ats-gb__series{
    grid-template-columns:1fr;
  }

  .ats-series-card{
    aspect-ratio:4 / 3;
  }

  .ats-series-card__img{
    height:100% !important;
    padding-top:40px;
  }

  .ats-gb__sizes{
    grid-template-columns:1fr;
    gap:8px;
    padding:10px;
  }

  .ats-leaf-row{
    grid-template-columns:minmax(0, 1fr) 38px;
    gap:7px;
  }

  .ats-leaf-row__select{
    grid-column:1 / -1;
  }

  .ats-leaf-builder__controls{
    align-items:flex-start;
    flex-direction:column;
  }

  .ats-selection-summary__stats{
    grid-template-columns:1fr 1fr;
  }

  .ats-step[data-step="2"] .ats-3d-viewer__frame,
  .ats-3d-viewer__frame{
    min-height:200px;
  }

  dialog#atsModal,
  dialog#atsStackModal{
    width:96vw;
  }
}

@media (max-width: 480px){
  .ats-step{
    padding:11px;
  }

  .ats-step__title{
    font-size:1rem;
  }

  .ats-gb__actions,
  .ats-gb__actions--step{
    display:grid;
    grid-template-columns:1fr;
    gap:6px;
  }

  .ats-sizes-summary{
    flex-direction:column;
    align-items:flex-start;
  }

  .ats-selection-summary__stats{
    grid-template-columns:1fr;
  }

  .ats-step[data-step="2"] .ats-3d-viewer__frame,
  .ats-3d-viewer__frame{
    min-height:180px;
  }

  .ats-3d-viewer__btn{
    padding:0 12px;
    min-height:34px;
    font-size:0.74rem;
  }
}

@media (prefers-reduced-motion: reduce){
  .ats-gb *,
  .ats-gb *::before,
  .ats-gb *::after{
    animation:none !important;
    transition:none !important;
    scroll-behavior:auto !important;
  }
}
