.seowb-wayback {
  --seowb-border: rgba(0, 0, 0, 0.16);
  --seowb-text: #222;
  --seowb-muted: #55555e;
  --seowb-accent: #55555e;
  --seowb-accent-dark: #38383f;
  --seowb-surface: rgba(0, 0, 0, 0.035);
  color: var(--seowb-text);
  max-width: 920px;
}

.seowb-wayback *,
.seowb-wayback *::before,
.seowb-wayback *::after {
  box-sizing: border-box;
}

.seowb-wayback [hidden] {
  display: none !important;
}

.seowb-wayback__form,
.seowb-wayback__status,
.seowb-wayback__history {
  border: 1px solid var(--seowb-border);
  border-radius: 0;
  padding: 20px;
  background: #fff;
}

.seowb-wayback__status,
.seowb-wayback__history {
  margin-top: 18px;
}

.seowb-wayback__grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.seowb-field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

.seowb-field--wide {
  grid-column: span 2;
}

.seowb-field-label,
.seowb-checks legend,
.seowb-checks legend > .seowb-field-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--seowb-muted);
  font-size: 14px;
  font-weight: 700;
}

.seowb-field input,
.seowb-field select {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--seowb-border);
  border-radius: 0;
  padding: 10px 15px;
  color: var(--seowb-text);
  background: #fff;
}

.seowb-field input:focus,
.seowb-field select:focus {
  border-color: var(--seowb-accent);
  outline: 1px solid var(--seowb-accent);
}

.seowb-help {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid var(--seowb-border);
  border-radius: 50%;
  color: var(--seowb-accent-dark);
  background: #fff;
  font-size: 12px;
  line-height: 1;
  cursor: help;
}

.seowb-help__tip {
  --seowb-tip-shift: 0px;
  position: absolute;
  z-index: 5;
  bottom: calc(100% + 9px);
  left: 50%;
  width: min(320px, calc(100vw - 40px));
  max-height: calc(100vh - 24px);
  overflow: auto;
  transform: translateX(calc(-50% + var(--seowb-tip-shift)));
  border: 1px solid var(--seowb-border);
  padding: 10px 12px;
  color: var(--seowb-text);
  background: #fff;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.12);
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  white-space: normal;
}

.seowb-help.is-below .seowb-help__tip {
  top: calc(100% + 9px);
  bottom: auto;
}

.seowb-help:hover .seowb-help__tip,
.seowb-help:focus .seowb-help__tip {
  opacity: 1;
  visibility: visible;
}

.seowb-checks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px 14px;
  margin: 18px 0 0;
  padding: 16px;
  border: 1px solid var(--seowb-border);
  border-radius: 0;
  background: var(--seowb-surface);
}

.seowb-checks--status {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.seowb-checks__head {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 2px;
}

.seowb-checks__head legend {
  margin: 0;
  padding: 0;
}

.seowb-checks__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.seowb-checks__actions button {
  min-height: 32px;
  border: 1px solid var(--seowb-border);
  padding: 5px 10px;
  color: var(--seowb-muted);
  background: #fff;
  font-size: 13px;
  line-height: 1.2;
  cursor: pointer;
}

.seowb-checks__actions button:hover,
.seowb-checks__actions button:focus {
  color: #fff;
  background: var(--seowb-accent);
}

.seowb-checks label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 28px;
  color: var(--seowb-text);
  font-size: 14px;
}

.seowb-wayback__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.seowb-inline-control {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
}

.seowb-inline-control .seowb-button {
  white-space: nowrap;
}

.seowb-date-range__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-top: 8px;
}

.seowb-date-picker__label {
  display: grid;
  gap: 4px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--seowb-muted);
}

.seowb-inline-status {
  min-height: 20px;
  color: var(--seowb-muted);
  font-size: 13px;
  line-height: 1.4;
}

.seowb-inline-status.is-loading::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  margin-right: 7px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: seowb-spin 0.75s linear infinite;
  vertical-align: -2px;
}

.seowb-inline-status[data-type="success"] {
  color: #047857;
}

.seowb-inline-status[data-type="error"] {
  color: #b91c1c;
}

.seowb-inline-status[data-type="warning"] {
  color: #b45309;
}

.seowb-spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: seowb-spin 0.75s linear infinite;
  vertical-align: -3px;
}

.seowb-spinner[hidden] {
  display: none;
}

@keyframes seowb-spin {
  to {
    transform: rotate(360deg);
  }
}

.seowb-calendar {
  border: 1px solid var(--seowb-border);
  padding: 12px;
  background: #fff;
}

.seowb-calendar__head {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  text-align: center;
}

.seowb-calendar__head button {
  min-height: 34px;
  border: 1px solid var(--seowb-border);
  color: var(--seowb-accent-dark);
  background: #fff;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
}

.seowb-calendar__head .seowb-calendar__title {
  overflow: hidden;
  padding: 6px 10px;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.seowb-calendar__head button:hover,
.seowb-calendar__head button:focus {
  color: #fff;
  background: var(--seowb-accent);
}

.seowb-calendar__jump {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(90px, 0.45fr);
  gap: 8px;
  margin-bottom: 10px;
}

.seowb-calendar__jump[hidden] {
  display: none;
}

.seowb-calendar__jump select {
  width: 100%;
  min-height: 36px;
  border: 1px solid var(--seowb-border);
  border-radius: 0;
  padding: 6px 8px;
  background: #fff;
  color: var(--seowb-text);
}

.seowb-calendar__weekdays,
.seowb-calendar__grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
}

.seowb-calendar__grid > span {
  min-height: 34px;
}

.seowb-calendar__weekdays {
  margin-bottom: 6px;
  color: var(--seowb-muted);
  font-size: 12px;
  text-align: center;
}

.seowb-calendar__day {
  display: grid;
  align-content: center;
  justify-items: center;
  min-height: 46px;
  border: 1px solid transparent;
  padding: 4px 2px;
  color: var(--seowb-muted);
  background: var(--seowb-surface);
  font-size: 13px;
  line-height: 1.1;
}

.seowb-calendar__day[disabled] {
  opacity: 0.45;
}

/* Outside the linked calendar's max_date_range_years window from the other calendar's selected
   date - visually distinct from "just no snapshot that day" (plain disabled). */
.seowb-calendar__day.is-out-of-range {
  opacity: 0.25;
}

.seowb-calendar__day.is-available {
  border-color: var(--seowb-accent);
  color: var(--seowb-accent-dark);
  background: #fff;
  cursor: pointer;
  font-weight: 700;
}

.seowb-calendar__date {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

.seowb-calendar__day.is-selected,
.seowb-calendar__day.is-available:hover,
.seowb-calendar__day.is-available:focus {
  color: #fff;
  background: var(--seowb-accent);
}

.seowb-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid var(--seowb-accent);
  border-radius: 0;
  padding: 10px 20px;
  color: #fff;
  background: var(--seowb-accent);
  font-weight: 700;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
}

.seowb-button:hover,
.seowb-button:focus {
  color: #fff;
  background: var(--seowb-accent-dark);
}

.seowb-button:disabled,
.seowb-checks__actions button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.seowb-button--secondary {
  color: var(--seowb-accent-dark);
  background: #fff;
}

.seowb-button--secondary:hover,
.seowb-button--secondary:focus {
  color: #fff;
  background: var(--seowb-accent);
}

.seowb-button--download {
  margin-top: 12px;
  margin-right: 8px;
}

.seowb-button--sheets {
  color: var(--seowb-accent-dark);
  background: #fff;
}

.seowb-button--sheets:hover,
.seowb-button--sheets:focus {
  color: #fff;
  background: var(--seowb-accent);
}

.seowb-wayback__message {
  margin-top: 14px;
  border: 1px solid transparent;
  border-radius: 0;
  padding: 10px 12px;
  background: #eef5ff;
  color: #1d4f87;
}

.seowb-wayback__message[data-type="success"] {
  background: #ecfdf5;
  color: #047857;
  border-color: #bbf7d0;
}

.seowb-wayback__message[data-type="error"] {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.seowb-wayback__status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.seowb-wayback__status-row strong {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.seowb-progress {
  height: 9px;
  overflow: hidden;
  margin-top: 12px;
  border-radius: 0;
  background: #e8edf2;
}

.seowb-progress span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--seowb-accent);
  transition: width 0.25s ease;
}

.seowb-wayback__history-title {
  margin: 0 0 4px;
  font-size: 1rem;
}

.seowb-wayback__history-hint {
  margin: 0 0 14px;
  color: var(--seowb-muted);
  font-size: 0.85rem;
}

.seowb-wayback__history-empty {
  margin: 0;
  color: var(--seowb-muted);
}

.seowb-wayback__history-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.seowb-wayback__history-item {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
  border: 1px solid var(--seowb-border);
  padding: 10px 14px;
  background: var(--seowb-surface);
}

.seowb-wayback__history-target {
  font-weight: 700;
  word-break: break-word;
}

.seowb-wayback__history-meta {
  margin-top: 2px;
  color: var(--seowb-muted);
  font-size: 0.85rem;
}

.seowb-wayback__history-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.seowb-button--small {
  min-height: 32px;
  padding: 6px 12px;
  font-size: 0.85rem;
}

.seowb-button--danger {
  border-color: #b91c1c;
  background: #b91c1c;
}

.seowb-button--danger:hover,
.seowb-button--danger:focus {
  background: #991b1b;
  border-color: #991b1b;
}

.seowb-wayback__confirm {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
}

.seowb-wayback__confirm-box {
  max-width: 360px;
  width: 100%;
  border: 1px solid var(--seowb-border);
  padding: 20px;
  background: #fff;
}

.seowb-wayback__confirm-title {
  margin: 0 0 16px;
  font-weight: 700;
}

.seowb-wayback__confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 820px) {
  .seowb-wayback__grid {
    grid-template-columns: 1fr;
  }

  .seowb-field--wide {
    grid-column: span 1;
  }

  .seowb-checks {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .seowb-checks--status {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .seowb-wayback__form,
  .seowb-wayback__status,
  .seowb-wayback__history {
    padding: 14px;
  }

  .seowb-wayback__history-item {
    flex-direction: column;
    align-items: flex-start;
  }

  .seowb-checks {
    grid-template-columns: 1fr;
  }

  .seowb-checks--status {
    grid-template-columns: 1fr;
  }

  .seowb-checks__head,
  .seowb-inline-control {
    grid-template-columns: 1fr;
  }

  .seowb-date-range__grid {
    grid-template-columns: 1fr;
  }

  .seowb-checks__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .seowb-wayback__actions .seowb-button,
  .seowb-inline-control .seowb-button {
    width: 100%;
  }
}
