:root {
  --app-bg: #f7f4ff;
  --sidebar-bg: #ffffff;
  --text: #1d1730;
  --muted: #70657f;
  --line: #e4ddef;
  --primary: #7c3aed;
  --primary-dark: #5b21b6;
  --primary-soft: #f0e7ff;
  --danger: #dc2626;
}

* {
  box-sizing: border-box;
  scrollbar-color: rgba(124, 58, 237, 0.36) transparent;
  scrollbar-width: thin;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(124, 58, 237, 0.16), transparent 30rem),
    linear-gradient(180deg, #fbf9ff 0%, var(--app-bg) 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 0.92rem;
}

body.is-overlay-open {
  overflow: hidden;
}

::-webkit-scrollbar {
  width: 3px;
  height: 3px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.32);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(124, 58, 237, 0.5);
}

.btn {
  --bs-btn-padding-y: 0.45rem;
  --bs-btn-padding-x: 0.78rem;
  --bs-btn-font-size: 0.9rem;
  --bs-btn-border-radius: 0.65rem;
  cursor: pointer;
  font-weight: 700;
}

.btn:focus-visible,
.icon-button:focus-visible,
.jobs-button:focus-visible,
.job-delete-button:focus-visible,
.toolbar-icon-button:focus-visible,
.shop-select-button:focus-visible {
  outline: 3px solid rgba(124, 58, 237, 0.28);
  outline-offset: 2px;
}

.btn-lg {
  --bs-btn-padding-y: 0.48rem;
  --bs-btn-padding-x: 0.85rem;
  --bs-btn-font-size: 0.92rem;
  --bs-btn-border-radius: 0.7rem;
}

.form-control,
.form-select {
  min-height: 2.45rem;
  font-size: 0.9rem;
}

.form-label {
  margin-bottom: 0.35rem;
  font-size: 0.86rem;
}

.btn-primary {
  --bs-btn-bg: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary-dark);
  --bs-btn-hover-border-color: var(--primary-dark);
  --bs-btn-active-bg: var(--primary-dark);
  --bs-btn-active-border-color: var(--primary-dark);
}

.btn-outline-primary {
  --bs-btn-color: var(--primary);
  --bs-btn-border-color: var(--primary);
  --bs-btn-hover-bg: var(--primary);
  --bs-btn-hover-border-color: var(--primary);
  --bs-btn-active-bg: var(--primary-dark);
  --bs-btn-active-border-color: var(--primary-dark);
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.25rem rgba(124, 58, 237, 0.16);
}

.form-check-input:checked {
  border-color: var(--primary);
  background-color: var(--primary);
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(300px, 360px) minmax(0, 1fr);
  min-height: 100vh;
}

.sidebar {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(12px);
  padding: 1.15rem;
  transition:
    transform 220ms ease,
    box-shadow 220ms ease;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.brand-mark {
  display: grid;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  place-items: center;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: #fff;
  flex: 0 0 auto;
  font-weight: 900;
  box-shadow: 0 14px 28px rgba(124, 58, 237, 0.28);
}

.shop-list-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1rem;
  margin-bottom: 0.55rem;
}

.shop-list {
  display: grid;
  gap: 0.5rem;
  overflow-y: auto;
  min-height: 17rem;
  max-height: calc(100vh - 16rem);
  padding-right: 0.15rem;
}

.shop-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0.55rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.65rem;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    transform 160ms ease;
}

.shop-item:hover {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 14px 30px rgba(38, 22, 67, 0.1);
  transform: translateY(-1px);
}

.shop-item.is-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.shop-item.is-token-invalid {
  border-color: rgba(220, 38, 38, 0.55);
  background: #fff1f2;
}

.shop-item.is-token-invalid .shop-name {
  color: #b91c1c;
}

.shop-select-button {
  display: block;
  width: 100%;
  min-width: 0;
  border: 0;
  border-radius: 0.55rem;
  background: transparent;
  padding: 0;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.shop-select-button:focus:not(:focus-visible) {
  outline: 0;
}

.shop-name {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  overflow: hidden;
  color: var(--text);
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.shop-loading {
  display: none;
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0.75rem 0;
  text-align: center;
}

.shop-loading.is-visible {
  display: block;
}

.content {
  display: grid;
  align-content: start;
  gap: 0.9rem;
  padding: 1.15rem;
}

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.section-kicker {
  margin-bottom: 0.25rem;
  color: var(--primary);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.display-title {
  margin: 0;
  font-size: clamp(1.8rem, 3vw, 2.6rem);
  font-weight: 900;
  letter-spacing: 0;
}

.selected-shop {
  max-width: 24rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  overflow: hidden;
  padding: 0.7rem 1rem;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 14px 34px rgba(38, 22, 67, 0.08);
}

.hero-card {
  background: linear-gradient(135deg, #ffffff, #faf7ff);
}

.api-status {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  background: #f1f5f9;
  color: var(--muted);
  font-weight: 700;
  padding: 0.5rem 0.85rem;
}

.api-status.is-ready {
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.api-status.is-invalid {
  background: #fee2e2;
  color: #b91c1c;
}

.report-progress {
  border: 1px solid var(--line);
  position: relative;
  overflow: hidden;
  border-radius: 0.75rem;
  background: #fff;
  color: var(--muted);
  padding: 0.7rem;
}

.report-progress::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(124, 58, 237, 0.08) 45%, transparent 72%);
  content: "";
  transform: translateX(-100%);
  animation: progressSheen 2.2s ease-in-out infinite;
}

.report-progress strong {
  color: var(--primary-dark);
}

.progress,
.progress-bar {
  border-radius: 999px;
}

.progress {
  height: 0.55rem;
  background: #ebe5f5;
}

.progress-bar {
  position: relative;
  overflow: hidden;
  background: linear-gradient(90deg, var(--primary-dark), var(--primary), #a855f7);
  transition: width 260ms ease;
}

.progress-bar::after {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.32), transparent);
  content: "";
  transform: translateX(-100%);
  animation: progressSheen 1.6s ease-in-out infinite;
}

.metric {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  box-shadow: 0 12px 30px rgba(38, 22, 67, 0.07);
  padding: 0.85rem;
}

.metric span {
  color: var(--muted);
  font-weight: 700;
}

.metric strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.6rem;
  line-height: 1;
}

.orders-status {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  padding: 0.28rem 0.62rem;
}

.orders-status.is-loading {
  border-color: rgba(124, 58, 237, 0.35);
  background: var(--primary-soft);
  color: var(--primary-dark);
}

.orders-status.is-ready {
  border-color: rgba(22, 163, 74, 0.28);
  background: #f0fdf4;
  color: #15803d;
}

.orders-status.is-warning {
  border-color: rgba(234, 179, 8, 0.35);
  background: #fefce8;
  color: #854d0e;
}

.orders-status.is-error {
  border-color: rgba(220, 38, 38, 0.35);
  background: #fff1f2;
  color: var(--danger);
}

.table th {
  color: var(--muted);
  font-size: 0.85rem;
}

.mobile-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: rgba(255, 255, 255, 0.9);
  padding: 0.55rem;
}

.current-shop-heading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  gap: 0.55rem;
}

.current-shop-heading strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.current-shop-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.toolbar-icon-button {
  display: grid;
  width: 2.05rem;
  height: 2.05rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #fff;
  color: var(--primary);
  place-items: center;
  transition:
    border-color 160ms ease,
    background 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.toolbar-icon-button:hover:not(:disabled) {
  border-color: rgba(124, 58, 237, 0.5);
  background: var(--primary-soft);
  transform: translateY(-1px);
}

.toolbar-icon-button.is-danger {
  color: var(--danger);
}

.toolbar-icon-button.is-danger:hover:not(:disabled) {
  border-color: rgba(220, 38, 38, 0.45);
  background: #fff1f2;
}

.toolbar-icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.toolbar-icon-button svg {
  width: 1rem;
  height: 1rem;
}

.icon-button,
.jobs-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: #fff;
  color: var(--text);
  font-weight: 800;
  gap: 0.35rem;
  padding: 0.4rem 0.65rem;
  transition:
    border-color 160ms ease,
    color 160ms ease,
    transform 160ms ease;
}

.icon-button {
  display: none;
  flex-direction: column;
  width: 2.2rem;
  padding: 0;
}

.icon-button span {
  width: 1rem;
  height: 2px;
  border-radius: 999px;
  background: var(--primary-dark);
}

.jobs-button {
  position: relative;
  width: 2.35rem;
  min-height: 2.2rem;
  padding: 0;
}

.jobs-button.has-active-jobs {
  border-color: rgba(124, 58, 237, 0.55);
  color: var(--primary-dark);
}

.jobs-button svg {
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.jobs-badge {
  position: absolute;
  top: -0.35rem;
  right: -0.35rem;
  display: grid;
  min-width: 1.05rem;
  height: 1.05rem;
  padding: 0 0.25rem;
  border-radius: 999px;
  place-items: center;
  background: var(--primary);
  color: #fff;
  font-size: 0.68rem;
  font-weight: 900;
  line-height: 1;
  animation: pulseDot 1.5s ease-in-out infinite;
}

.mobile-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1030;
  display: none;
  background: rgba(29, 23, 48, 0.32);
  opacity: 0;
  transition: opacity 200ms ease;
}

.mobile-backdrop.is-visible {
  display: block;
  opacity: 1;
}

.jobs-drawer {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1040;
  display: flex;
  width: min(26rem, 92vw);
  height: 100vh;
  flex-direction: column;
  border-left: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: -22px 0 48px rgba(38, 22, 67, 0.16);
  padding: 1rem;
  transform: translateX(105%);
  transition: transform 240ms ease;
}

.jobs-drawer.is-open {
  transform: translateX(0);
}

.jobs-drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding-bottom: 0.85rem;
}

.jobs-list {
  display: grid;
  gap: 0.55rem;
  overflow-y: auto;
}

.job-item,
.job-empty {
  border: 1px solid var(--line);
  border-radius: 0.75rem;
  background: #fff;
  padding: 0.75rem;
}

.job-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  font-weight: 900;
}

.job-status {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  color: var(--primary-dark);
  font-size: 0.8rem;
}

.job-title-actions {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.job-delete-button {
  display: grid;
  width: 1.75rem;
  height: 1.75rem;
  border: 1px solid rgba(220, 38, 38, 0.34);
  border-radius: 0.5rem;
  background: #fff;
  color: var(--danger);
  place-items: center;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease;
}

.job-delete-button:hover {
  border-color: rgba(220, 38, 38, 0.58);
  background: #fff1f2;
  transform: translateY(-1px);
}

.job-delete-button svg {
  width: 0.92rem;
  height: 0.92rem;
}

.job-meta,
.job-step {
  color: var(--muted);
  font-size: 0.82rem;
}

.job-step {
  margin-top: 0.35rem;
}

.job-progress {
  margin-top: 0.55rem;
}

.job-spinner,
.shop-job-spinner {
  display: inline-block;
  width: 0.85rem;
  height: 0.85rem;
  border: 2px solid rgba(124, 58, 237, 0.18);
  border-top-color: var(--primary);
  border-radius: 999px;
  animation: spin 850ms linear infinite;
  flex: 0 0 auto;
}

.shop-job-spinner {
  width: 0.72rem;
  height: 0.72rem;
  border-width: 1.5px;
}

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

@keyframes pulseDot {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(124, 58, 237, 0.25);
  }
  50% {
    box-shadow: 0 0 0 0.35rem rgba(124, 58, 237, 0);
  }
}

@keyframes progressSheen {
  to {
    transform: translateX(100%);
  }
}

.empty-row {
  color: var(--muted);
  text-align: center;
}

.toast-message {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 1080;
  max-width: min(28rem, calc(100vw - 2rem));
  border-radius: 0.85rem;
  background: #21172f;
  color: #fff;
  opacity: 0;
  pointer-events: none;
  padding: 0.85rem 1rem;
  transform: translateY(12px);
  transition:
    opacity 160ms ease,
    transform 160ms ease;
}

.toast-message.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.min-w-0 {
  min-width: 0;
}

@media (max-width: 991.98px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1040;
    width: min(16rem, 66vw);
    height: 100vh;
    border-right: 1px solid var(--line);
    border-left: 0;
    box-shadow: 22px 0 48px rgba(38, 22, 67, 0.16);
    transform: translateX(-105%);
  }

  .sidebar.is-open {
    transform: translateX(0);
  }

  .shop-list {
    max-height: calc(100vh - 11rem);
  }

  .mobile-toolbar {
    display: flex;
  }

  .icon-button {
    display: inline-flex;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .selected-shop {
    max-width: 100%;
    width: 100%;
  }
}

@media (max-width: 575.98px) {
  .sidebar,
  .content {
    padding: 0.75rem;
  }

  .current-shop-heading {
    justify-content: flex-start;
    gap: 0.4rem;
  }
}
