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

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  overflow-x: clip;
  max-width: 100%;
}

/* Authenticated shell: scroll only inside .app-main, not the document */
html:has(#app-frame) {
  overflow: hidden;
  height: 100%;
}

html:has(#app-frame) body {
  overflow: hidden;
  height: 100%;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  min-height: 100vh;
  max-width: 100%;
  overflow-x: clip;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.55;
  color: var(--color-text);
  background-color: var(--color-bg);
  background-image:
    radial-gradient(ellipse 90% 60% at 0% -10%, var(--mesh-1), transparent 55%),
    radial-gradient(ellipse 70% 50% at 100% 0%, var(--mesh-2), transparent 50%),
    radial-gradient(ellipse 50% 40% at 50% 100%, rgba(18, 48, 79, 0.03), transparent 55%),
    linear-gradient(180deg, var(--color-bg-accent) 0%, var(--color-bg) 28%, var(--color-bg) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "ss01" on, "kern" on;
}

img {
  max-width: 100%;
  display: block;
}

a {
  color: var(--color-accent-mid);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
  transition: color var(--transition);
}

a:hover {
  color: var(--color-accent);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
}

h1, h2, h3, h4 {
  margin: 0 0 var(--space-3);
  line-height: 1.22;
  font-weight: 600;
  color: var(--color-text);
}

h1 {
  font-family: var(--font-display);
  font-size: var(--text-2xl);
  font-weight: 650;
  letter-spacing: var(--tracking-tight);
  font-optical-sizing: auto;
}

h2 {
  font-family: var(--font-display);
  font-size: var(--text-xl);
  font-weight: 600;
  letter-spacing: -0.015em;
}

h3 {
  font-size: var(--text-lg);
  font-weight: 600;
}

p {
  margin: 0 0 var(--space-3);
  color: var(--color-text-secondary);
}

ul, ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 1000;
  padding: var(--space-2) var(--space-4);
  background: var(--color-accent);
  color: #fff;
  border-radius: var(--radius-sm);
  font-weight: 600;
}

.skip-link:focus {
  left: var(--space-4);
  top: var(--space-4);
}

:focus-visible {
  outline: 2px solid var(--color-focus);
  outline-offset: 2px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-loading {
  display: block;
  min-height: 40vh;
  padding: var(--space-6);
  color: var(--color-text-muted);
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  box-sizing: border-box;
  pointer-events: none;
  user-select: none;
}

/* Content skeleton — grey boxes in the same places as real content */
.content-skeleton,
.sk-page {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
  pointer-events: none;
  user-select: none;
}

/* Skeletons are pure CSS — never show broken <img> / onerror icons */
.app-loading img,
.sk-page img,
.content-skeleton img {
  display: none !important;
}

.sk-fill,
.sk-fill-box {
  background: linear-gradient(
    90deg,
    #e4eaf1 0%,
    #f1f5f9 42%,
    #e4eaf1 85%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.2s ease-in-out infinite;
  border-radius: 8px;
}

.sk-fill-box {
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

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

.sk-line {
  height: 14px;
  display: block;
}

.sk-line--title {
  width: min(70%, 280px);
  height: 18px;
}

.sk-line--sub,
.sk-line--welcome {
  width: min(40%, 180px);
  height: 14px;
}

.sk-line--price {
  width: 110px;
  height: 16px;
}

.sk-line--meta {
  width: 55%;
  height: 12px;
}

.sk-line--wide {
  width: 100%;
  height: 14px;
}

.sk-line--back {
  width: 88px;
  height: 14px;
  margin-bottom: 4px;
}

.sk-btn {
  width: 120px;
  height: 36px;
  border-radius: 10px;
  flex-shrink: 0;
}

.sk-btn--sm {
  width: 100px;
  height: 34px;
}

.sk-pill {
  width: 72px;
  height: 28px;
  border-radius: 999px;
}

.sk-toolbar {
  height: 58px;
  width: 100%;
}

.sk-deal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 1.1rem;
}

.sk-card {
  display: flex;
  flex-direction: column;
  min-height: 340px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  overflow: hidden;
}

.sk-card-media {
  aspect-ratio: 1 / 1;
  margin: 12px 12px 0;
  border-radius: 10px;
  border: none;
  background-image: none !important;
}

.sk-card-media::before,
.sk-card-media::after,
.sk-top-deal-media::before,
.sk-top-deal-media::after {
  content: none !important;
  display: none !important;
}

.sk-card-body {
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.sk-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: auto;
  padding-top: 6px;
}

.sk-top-deal-rail {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

@media (min-width: 1100px) {
  .sk-top-deal-rail {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (min-width: 1500px) {
  .sk-top-deal-rail {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}

.sk-top-deal {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
  overflow: hidden;
}

.sk-top-deal-media {
  aspect-ratio: 4 / 3;
  margin: 0;
  border-radius: 0;
  background-image: none !important;
}

.sk-top-deal-body {
  padding: 10px 14px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sk-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  flex-shrink: 0;
}

.sk-top-deal-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sk-top-deal-info {
  height: 36px;
  border-radius: 10px;
}

.sk-top-deal-ctas {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.sk-top-deal-ctas .sk-btn {
  height: 40px;
  border-radius: 999px;
  width: 100%;
}

.sk-stat-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.sk-stat-card {
  min-height: 150px;
}

.sk-panel {
  width: 100%;
}

.sk-panel--banner {
  min-height: 64px;
}

.sk-panel--mid-short {
  min-height: 88px;
}

.sk-panel--tall {
  min-height: 220px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.sk-panel--mid {
  min-height: 160px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-sizing: border-box;
}

.sk-detail-overview {
  display: grid;
  grid-template-columns: 168px minmax(0, 1fr);
  gap: 18px 22px;
  padding: 16px 18px;
  min-height: 200px;
  box-sizing: border-box;
}

.sk-detail-media {
  width: 168px;
  height: 168px;
  border-radius: 10px;
}

.sk-detail-copy {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 8px;
}

.sk-detail-table {
  padding: 16px;
  min-height: 280px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-sizing: border-box;
}

.sk-table-rows {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.sk-table-row {
  height: 44px;
  width: 100%;
  border-radius: 8px;
}

@keyframes skeleton-shimmer {
  0% {
    background-position: 100% 0;
  }
  100% {
    background-position: -100% 0;
  }
}

@media (max-width: 900px) {
  .sk-stat-grid {
    grid-template-columns: 1fr;
  }

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

  .sk-detail-media {
    width: 140px;
    height: 140px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .sk-fill,
  .sk-fill-box {
    animation: none;
    background: #e4eaf1;
  }
}

.dash-refresh.is-loading,
.header-refresh.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.dash-refresh.is-loading .icon,
.header-refresh.is-loading .icon {
  animation: spin 0.75s linear infinite;
}

.spinner {
  width: 28px;
  height: 28px;
  border: 2.5px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
}

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

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes soft-in {
  from { opacity: 0; }
  to { opacity: 1; }
}
