.grb-wizard,
.grb-wizard * {
  box-sizing: border-box;
}

.grb-wizard {
  --grb-primary: #780ab6;
  --grb-primary-2: #5e078f;
  --grb-success: #28a745;
  --grb-border: #d9d9df;
  --grb-bg-soft: #f8f8fb;
  --grb-text: #1f2430;
  --grb-muted: #737783;
  width: 100%;
  max-width: 100%;
  margin: 30px auto;
  padding: 20px;
  border-radius: 14px;
  background: #fff;
  color: var(--grb-text);
  box-shadow: 0 10px 30px rgba(20, 20, 40, 0.06);
  font-family: "Segoe UI", Arial, sans-serif;
}

.grb-progress {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 0 0 26px;
}

.grb-progress::before {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 2px;
  background: #ececf1;
  transform: translateY(-50%);
  z-index: 0;
}

.grb-progress-step {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 999px;
  background: #e7e7eb;
  color: #71717a;
  font-size: 14px;
  font-weight: 700;
  transition: .22s ease;
}

.grb-progress-step.is-active,
.grb-progress-step.is-done {
  background: var(--grb-primary);
  color: #fff;
}

.grb-progress-step.is-current {
  box-shadow: 0 0 0 5px rgba(120, 10, 182, .12);
}

.grb-step {
  display: none;
  animation: grbFade .18s ease;
}

.grb-step.is-active {
  display: block;
}

@keyframes grbFade {
  from { opacity: .25; transform: translateY(3px); }
  to { opacity: 1; transform: none; }
}

.grb-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 18px;
  color: #22252b;
  font-size: clamp(20px, 2.5vw, 27px);
  line-height: 1.25;
  font-weight: 500;
}

.grb-title img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

.grb-title strong {
  color: var(--grb-primary);
  font-weight: 750;
}

.grb-help {
  margin: -8px 0 16px;
  color: var(--grb-muted);
  font-size: 14px;
}

.grb-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.grb-option-card {
  appearance: none;
  content-visibility: auto;
  contain-intrinsic-size: 150px 120px;
  width: 100%;
  min-width: 0;
  min-height: 128px;
  padding: 12px 10px;
  border: 1.5px solid var(--grb-border);
  border-radius: 12px;
  background: #fff;
  color: #22252b;
  text-align: center;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}

.grb-option-card:hover {
  transform: translateY(-2px);
  border-color: var(--grb-primary) !important;
  background: var(--grb-primary) !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(120, 10, 182, .18);
}

.grb-option-card:hover span {
  color: #fff !important;
}

.grb-option-card:focus-visible {
  outline: 3px solid rgba(120, 10, 182, .18);
  outline-offset: 2px;
}

.grb-option-card.is-selected {
  border-color: var(--grb-success);
  background: #effbf2;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, .08);
}

.grb-option-card img {
  display: block;
  width: 80px;
  height: 80px;
  margin: 0 auto 8px;
  object-fit: contain;
}

.grb-option-card span {
  display: block;
  overflow-wrap: anywhere;
  font-size: 14px;
  line-height: 1.35;
  text-transform: capitalize;
}

.grb-model-search-wrap {
  margin: 0 0 16px;
}

.grb-model-search,
.grb-input-group input {
  width: 100%;
  min-height: 50px;
  padding: 12px 14px;
  border: 1.5px solid #d2d2d8;
  border-radius: 14px;
  background: #fff;
  color: #20232a;
  font: inherit;
  font-size: 16px;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.grb-model-search:focus,
.grb-input-group input:focus {
  border-color: var(--grb-primary);
  box-shadow: 0 0 0 4px rgba(120, 10, 182, .10);
  outline: none;
}

.grb-input-group {
  margin-bottom: 15px;
}

.grb-input-group label {
  display: block;
  margin-bottom: 7px;
  color: #32343a;
  font-size: 14px;
  font-weight: 600;
  text-transform: capitalize;
}

.grb-summary {
  padding: 18px;
  border: 1px solid #ececf0;
  border-radius: 12px;
  background: var(--grb-bg-soft);
  font-size: 14px;
}

.grb-summary p {
  margin: 0 0 10px;
  overflow-wrap: anywhere;
}

.grb-summary p:last-child {
  margin-bottom: 0;
}

.grb-summary hr {
  border: 0;
  border-top: 1px solid #dedee4;
  margin: 14px 0;
}

.grb-buttons {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 22px;
}

.grb-btn {
  min-width: 135px;
  min-height: 46px;
  padding: 11px 18px;
  border: 0;
  border-radius: 9px;
  background: var(--grb-primary);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .16s ease, transform .16s ease, opacity .16s ease;
  text-transform: capitalize;
}

.grb-btn:hover {
  background: var(--grb-primary-2);
  transform: translateY(-1px);
}

.grb-btn-secondary {
  background: #ececf1;
  color: #40434a;
}

.grb-btn-secondary:hover {
  background: #dedee5;
}

.grb-btn:disabled {
  cursor: not-allowed;
  opacity: .48;
  transform: none;
}

.grb-empty {
  padding: 22px;
  border-radius: 10px;
  background: var(--grb-bg-soft);
  color: var(--grb-muted);
  text-align: center;
}

.grb-success {
  padding: 42px 20px;
  text-align: center;
}

.grb-success img {
  width: 80px;
  height: 80px;
  margin-bottom: 12px;
}

.grb-success h2 {
  margin: 0 0 8px;
  color: var(--grb-success);
  font-size: 26px;
}

.grb-success p {
  margin: 0;
  color: var(--grb-muted);
}

.grb-live {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}

@media (min-width: 768px) {
  .grb-wizard {
    padding: 26px;
  }
  .grb-options-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 15px;
  }
}

@media (min-width: 1180px) {
  .grb-options-grid {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }
}

@media (max-width: 520px) {
  .grb-wizard {
    margin: 18px auto;
    padding: 15px;
    border-radius: 11px;
  }
  .grb-progress-step {
    width: 31px;
    height: 31px;
    flex-basis: 31px;
    font-size: 12px;
  }
  .grb-progress::before {
    left: 15px;
    right: 15px;
  }
  .grb-option-card {
    min-height: 118px;
    padding: 10px 8px;
  }
  .grb-option-card img {
    width: 70px;
    height: 70px;
  }
  .grb-buttons {
    position: sticky;
    bottom: 8px;
    z-index: 5;
    padding: 8px;
    border-radius: 12px;
    background: rgba(255,255,255,.98);
    box-shadow: 0 8px 30px rgba(20,20,30,.10);
  }
  .grb-btn {
    min-width: 0;
    flex: 1;
  }
}

/* Popup flow: step 1 stays on the page, steps 2-6 open in a modal. */
html.grb-modal-open,
body.grb-modal-open {
  overflow: hidden !important;
  overscroll-behavior: none;
}

/* A fixed body lock prevents the page underneath the popup from moving,
   including on mobile Safari. The original scroll position is restored in JS. */
body.grb-modal-open {
  position: fixed !important;
  top: var(--grb-scroll-lock-top, 0px) !important;
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
}

.grb-modal[hidden] {
  display: none !important;
}

.grb-modal {
  --grb-primary: #780ab6;
  --grb-primary-2: #5e078f;
  --grb-success: #28a745;
  --grb-border: #d9d9df;
  --grb-bg-soft: #f8f8fb;
  --grb-text: #1f2430;
  --grb-muted: #737783;
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 22px;
}

.grb-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 17, 24, .62);
  /* No backdrop blur: it forces an expensive full-page GPU repaint. */
}

.grb-modal-dialog {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100vw - 44px));
  max-height: min(92vh, 940px);
  overflow-x: hidden;
  overflow-y: auto;
  padding: 30px 30px 26px;
  border: 1px solid rgba(255, 255, 255, .7);
  border-radius: 22px;
  background: #fff;
  color: var(--grb-text);
  box-shadow: 0 26px 90px rgba(0, 0, 0, .24);
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  contain: layout paint;
  opacity: 0;
  transform: translateY(14px) scale(.985);
  transition: opacity .2s ease, transform .2s ease;
  scrollbar-gutter: stable;
}

.grb-modal.is-open .grb-modal-dialog {
  opacity: 1;
  transform: none;
}

.grb-modal-close {
  appearance: none;
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0 0 -40px auto;
  padding: 0;
  border: 1px solid #e5e5eb;
  border-radius: 999px;
  background: rgba(255, 255, 255, .96);
  color: #353841;
  box-shadow: 0 6px 18px rgba(20, 20, 35, .08);
  font: inherit;
  font-size: 29px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  transition: border-color .16s ease, color .16s ease, transform .16s ease, background .16s ease;
}

.grb-modal-close:hover,
.grb-modal-close:focus-visible {
  border-color: var(--grb-primary);
  background: #fff;
  color: var(--grb-primary);
  transform: rotate(4deg);
  outline: none;
}

.grb-progress-modal {
  padding-right: 56px;
}

.grb-device-grid {
  width: 100%;
  max-width: 520px;
  grid-template-columns: repeat(2, minmax(180px, 240px)) !important;
  justify-content: start;
  align-items: stretch;
}

.grb-device-grid .grb-option-card {
  min-height: 190px;
  padding: 16px 12px;
}

.grb-device-grid .grb-option-card img {
  width: 88px;
  height: 88px;
  margin-bottom: 12px;
}

.grb-device-grid .grb-option-card span {
  font-size: 16px;
}

@media (max-width: 767px) {
  .grb-modal {
    align-items: flex-end;
    padding: 10px;
  }

  .grb-modal-dialog {
    width: 100%;
    max-height: calc(100dvh - 20px);
    padding: 20px 14px 14px;
    border-radius: 20px 20px 14px 14px;
  }

  .grb-modal-close {
    width: 38px;
    height: 38px;
    margin-bottom: -38px;
  }

  .grb-progress-modal {
    padding-right: 47px;
  }
}

@media (max-width: 520px) {
  .grb-device-grid {
    max-width: 100%;
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    gap: 12px;
  }

  .grb-device-grid .grb-option-card {
    min-height: 150px;
    padding: 12px 8px;
  }

  .grb-device-grid .grb-option-card img {
    width: 72px;
    height: 72px;
  }

  .grb-device-grid .grb-option-card span {
    font-size: 14px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .grb-modal-dialog {
    transition: none;
  }
}

/* v1.1.2: harden card hover styles against theme button hover rules. */
html body .grb-wizard .grb-option-card:hover,
html body .grb-modal .grb-option-card:hover,
html body .grb-wizard button.grb-option-card:hover,
html body .grb-modal button.grb-option-card:hover {
  background-color: #780ab6 !important;
  background-image: none !important;
  border-color: #780ab6 !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(120, 10, 182, .18) !important;
}

html body .grb-wizard .grb-option-card:hover span,
html body .grb-modal .grb-option-card:hover span,
html body .grb-wizard button.grb-option-card:hover span,
html body .grb-modal button.grb-option-card:hover span {
  color: #fff !important;
}

/* Some themes paint buttons with pseudo-elements on hover. Remove those overlays. */
html body .grb-wizard .grb-option-card::before,
html body .grb-wizard .grb-option-card::after,
html body .grb-modal .grb-option-card::before,
html body .grb-modal .grb-option-card::after {
  content: none !important;
  display: none !important;
  background: transparent !important;
  background-image: none !important;
}

/* Keep the selected state green while the pointer is resting on it. */
html body .grb-wizard .grb-option-card.is-selected:hover,
html body .grb-modal .grb-option-card.is-selected:hover {
  background-color: #effbf2 !important;
  background-image: none !important;
  border-color: #28a745 !important;
  color: #22252b !important;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, .08) !important;
}

html body .grb-wizard .grb-option-card.is-selected:hover span,
html body .grb-modal .grb-option-card.is-selected:hover span {
  color: #22252b !important;
}

/* Wheel/touch gestures over cards should remain available to the popup scroller. */
.grb-modal-dialog,
.grb-modal-dialog .grb-options-grid,
.grb-modal-dialog .grb-option-card {
  overscroll-behavior: contain;
  touch-action: pan-y;
}


/* v1.1.3: a popup step must not paint its first card with the theme button focus color. */
html body .grb-wizard button.grb-option-card:not(.is-selected):focus:not(:hover),
html body .grb-modal button.grb-option-card:not(.is-selected):focus:not(:hover),
html body .grb-wizard button.grb-option-card:not(.is-selected):active:not(:hover),
html body .grb-modal button.grb-option-card:not(.is-selected):active:not(:hover) {
  background-color: #fff !important;
  background-image: none !important;
  border-color: var(--grb-border) !important;
  color: #22252b !important;
  box-shadow: none !important;
}

html body .grb-wizard button.grb-option-card:not(.is-selected):focus:not(:hover) span,
html body .grb-modal button.grb-option-card:not(.is-selected):focus:not(:hover) span,
html body .grb-wizard button.grb-option-card:not(.is-selected):active:not(:hover) span,
html body .grb-modal button.grb-option-card:not(.is-selected):active:not(:hover) span {
  color: #22252b !important;
}

/* Preserve an accessible keyboard focus ring without changing the card fill. */
html body .grb-wizard button.grb-option-card:not(.is-selected):focus-visible:not(:hover),
html body .grb-modal button.grb-option-card:not(.is-selected):focus-visible:not(:hover) {
  outline: 3px solid rgba(120, 10, 182, .22) !important;
  outline-offset: 2px !important;
}

/* A selected card stays green even while focused/active. */
html body .grb-wizard button.grb-option-card.is-selected:focus,
html body .grb-modal button.grb-option-card.is-selected:focus,
html body .grb-wizard button.grb-option-card.is-selected:active,
html body .grb-modal button.grb-option-card.is-selected:active {
  background-color: #effbf2 !important;
  background-image: none !important;
  border-color: #28a745 !important;
  color: #22252b !important;
  box-shadow: 0 0 0 2px rgba(40, 167, 69, .08) !important;
}

html body .grb-wizard button.grb-option-card.is-selected:focus span,
html body .grb-modal button.grb-option-card.is-selected:focus span,
html body .grb-wizard button.grb-option-card.is-selected:active span,
html body .grb-modal button.grb-option-card.is-selected:active span {
  color: #22252b !important;
}

/* The dialog itself is the initial focus target for card-only popup steps. */
.grb-modal-dialog:focus {
  outline: none !important;
}

/* v1.4.0: cleaner professional repair icon presentation. */
[data-role="repair-options"] .grb-option-card img {
  width: 58px;
  height: 58px;
  margin: 2px auto 14px;
  object-fit: contain;
  filter: none;
}

html body .grb-modal [data-role="repair-options"] .grb-option-card:hover img {
  filter: brightness(0) invert(1);
}

html body .grb-modal [data-role="repair-options"] .grb-option-card.is-selected:hover img,
html body .grb-modal [data-role="repair-options"] .grb-option-card.is-selected img {
  filter: none;
}
