:root {
  --bg: #08111f;
  --bg-soft: rgba(13, 24, 43, 0.78);
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --text: #f7fafc;
  --muted: #b6c2d2;
  --stroke: rgba(255, 255, 255, 0.12);
  --accent: #ffaf1a;
  --accent-deep: #f08900;
  --brand: #0b4f7c;
  --brand-soft: #1f7cae;
  --success: #2fd484;
  --danger: #ff7b7b;
  --shadow: 0 24px 60px rgba(3, 8, 20, 0.35);
  --radius-lg: 28px;
  --radius-md: 20px;
  --radius-sm: 14px;
  --font-sans: "Segoe UI Variable", "Aptos", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(27, 108, 155, 0.28), transparent 30%),
    radial-gradient(circle at bottom right, rgba(255, 175, 26, 0.16), transparent 34%),
    linear-gradient(160deg, #07111e 0%, #0f1b2e 55%, #08121f 100%);
  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 18rem;
  height: 18rem;
  border-radius: 50%;
  filter: blur(50px);
  opacity: 0.55;
  pointer-events: none;
}

.ambient-a {
  top: 5rem;
  left: -4rem;
  background: rgba(255, 175, 26, 0.18);
}

.ambient-b {
  right: -6rem;
  bottom: 2rem;
  background: rgba(31, 124, 174, 0.22);
}

.page-shell {
  width: min(1180px, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: 1rem 0 2.5rem;
}

body.auth-mode .page-shell {
  width: min(34rem, calc(100% - 1.5rem));
}

body.auth-mode .topbar {
  justify-content: center;
  padding: 1.4rem 0 0.8rem;
}

body.auth-mode .topbar-actions {
  display: none;
}

.topbar,
.section-heading,
.dashboard-header,
.toolbar,
.product-head,
.product-meta,
.product-actions,
.hero-points,
.dashboard-stats,
.topbar-actions {
  display: flex;
  gap: 0.9rem;
}

.topbar,
.section-heading,
.dashboard-header {
  justify-content: space-between;
  align-items: center;
}

.topbar {
  padding: 0.6rem 0 1rem;
}

.topbar-actions {
  align-items: flex-start;
}

body.app-mode .topbar-actions {
  flex-direction: column;
  align-items: flex-end;
}

.brand-lockup {
  display: flex;
  gap: 0.9rem;
  align-items: center;
}

body.auth-mode .brand-lockup {
  width: 100%;
  flex-direction: column;
  justify-content: center;
  gap: 0.7rem;
  text-align: center;
}

body.auth-mode .brand-lockup > div {
  display: grid;
  justify-items: center;
  gap: 0.2rem;
}

.brand-mark {
  width: 3.25rem;
  height: 3.25rem;
  object-fit: contain;
  border-radius: 1rem;
  box-shadow: 0 18px 40px rgba(255, 175, 26, 0.18);
}

body.auth-mode .brand-mark {
  width: 5.6rem;
  height: 5.6rem;
  border-radius: 1.45rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.5rem, 3vw, 2rem);
}

body.app-mode h1 {
  font-size: clamp(1.8rem, 3vw, 2.35rem);
}

body.auth-mode h1 {
  font-size: clamp(2.2rem, 7vw, 2.8rem);
  line-height: 1;
}

.account-summary {
  display: grid;
  gap: 0.42rem;
  justify-items: end;
}

.account-email {
  max-width: min(40vw, 18rem);
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.35;
  text-align: right;
  overflow-wrap: anywhere;
}

h2 {
  font-size: clamp(1.55rem, 3vw, 2.25rem);
  line-height: 1.1;
}

h3 {
  font-size: 1.1rem;
}

.eyebrow,
.metric-label {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.76rem;
  color: rgba(255, 255, 255, 0.58);
}

.muted,
.empty-state p,
.small-stat span,
.product-subcopy,
.inline-note {
  color: var(--muted);
  line-height: 1.55;
}

.main-grid {
  display: grid;
  gap: 1rem;
}

body.auth-mode .main-grid {
  min-height: calc(100vh - 7.5rem);
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.05));
  border: 1px solid var(--stroke);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.auth-card,
.dashboard {
  padding: 1.2rem;
}

.hero-points,
.dashboard-stats,
.product-actions {
  flex-wrap: wrap;
}

.hero-points span,
.pill,
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.92rem;
}

.small-stat,
.product-card {
  background: rgba(8, 17, 31, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.small-stat {
  padding: 1rem;
  border-radius: var(--radius-md);
  flex: 1 1 180px;
}

.small-stat strong {
  display: block;
  margin: 0.35rem 0;
  font-size: 1.35rem;
}

.ghost-button,
.primary-button,
.secondary-button,
.danger-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 999px;
  padding: 0.85rem 1.15rem;
  cursor: pointer;
  transition:
    transform 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
}

.stack-form,
.inset-form,
.field,
.list-shell,
.product-body,
.price-grid,
.invite-banner {
  display: grid;
  gap: 0.9rem;
}

.field span {
  display: block;
  margin-bottom: 0.42rem;
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.92rem;
}

.field input {
  width: 100%;
  padding: 0.92rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(4, 10, 18, 0.45);
  color: var(--text);
}

.field input:focus {
  outline: 2px solid rgba(255, 175, 26, 0.35);
  border-color: rgba(255, 175, 26, 0.45);
}

.field input[readonly] {
  opacity: 0.88;
  cursor: default;
}

.primary-button {
  color: #0d1624;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #ffc75e);
}

.ghost-button,
.secondary-button,
.danger-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.danger-button {
  color: #ffd3d3;
}

.primary-button:hover,
.ghost-button:hover,
.secondary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  opacity: 0.65;
  cursor: wait;
}

.dashboard {
  display: grid;
  gap: 1rem;
}

.dashboard-header {
  flex-direction: column;
  align-items: stretch;
}

.dashboard-header > div:first-child {
  display: grid;
  gap: 0.28rem;
}

.auth-card {
  isolation: isolate;
  width: min(100%, 32rem);
  margin: clamp(3rem, 12vh, 6rem) auto 0;
}

.auth-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto;
  height: 10rem;
  background:
    radial-gradient(circle at top left, rgba(255, 175, 26, 0.2), transparent 55%),
    radial-gradient(circle at top right, rgba(31, 124, 174, 0.22), transparent 52%);
  pointer-events: none;
  z-index: 0;
}

.auth-stage {
  display: grid;
  gap: 1rem;
  position: relative;
  z-index: 1;
  text-align: center;
}

.auth-action-form {
  width: min(100%, 22rem);
  margin: 0.35rem auto 0;
}

.auth-action-form .primary-button {
  width: 100%;
}

.auth-stage .muted {
  width: min(100%, 28rem);
  margin: 0 auto;
}

.inset-form {
  padding: 1rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
}

.invite-banner {
  padding: 1rem;
  border-radius: var(--radius-md);
  background:
    linear-gradient(135deg, rgba(255, 175, 26, 0.14), transparent 55%),
    rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 175, 26, 0.16);
}

.invite-stage {
  margin-top: 1.2rem;
  padding-top: 1.2rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  text-align: left;
}

.compact {
  align-items: flex-start;
}

.toolbar {
  flex-direction: column;
}

.search-field {
  flex: 1;
}

.toggle-field {
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  color: rgba(255, 255, 255, 0.88);
}

.list-shell {
  min-height: 14rem;
}

.product-list {
  display: grid;
  gap: 0.9rem;
}

.product-card {
  padding: 1rem;
  border-radius: var(--radius-md);
  animation: card-in 260ms ease;
}

.product-head {
  align-items: flex-start;
  justify-content: space-between;
}

.product-meta {
  flex-direction: column;
}

.product-media {
  display: flex;
  gap: 0.9rem;
}

.product-image {
  width: 4.5rem;
  height: 4.5rem;
  flex-shrink: 0;
  border-radius: 1rem;
  object-fit: cover;
  background: rgba(255, 255, 255, 0.06);
}

.product-title {
  margin-bottom: 0.3rem;
  font-size: 1rem;
}

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

.price-box {
  padding: 0.85rem;
  border-radius: 1rem;
  background: rgba(255, 255, 255, 0.05);
}

.price-box strong {
  display: block;
  margin-top: 0.25rem;
  font-size: 1.08rem;
}

.product-actions {
  margin-top: 0.4rem;
  display: grid;
  grid-template-columns: 1fr;
}

.product-actions a {
  text-decoration: none;
}

.dashboard-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.75rem;
}

.dashboard-actions > .ghost-button,
.dashboard-actions > .primary-button,
.dashboard-actions > .secondary-button,
.dashboard-actions > .danger-button,
.product-actions > .ghost-button,
.product-actions > .primary-button,
.product-actions > .secondary-button,
.product-actions > .danger-button,
.product-actions > a.ghost-button {
  width: 100%;
  justify-content: center;
  text-align: center;
}

.empty-state,
.toast {
  text-align: center;
  padding: 1.2rem;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.14);
}

.toast {
  position: fixed;
  inset: auto 0 1rem;
  margin: 0 auto;
  width: min(92vw, 30rem);
  z-index: 50;
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow);
}

.status-badge.success {
  color: #defbe9;
  background: rgba(47, 212, 132, 0.14);
}

.status-badge.warning {
  color: #fff0cd;
  background: rgba(255, 175, 26, 0.14);
}

.hidden {
  display: none !important;
}

@keyframes card-in {
  from {
    transform: translateY(8px);
    opacity: 0;
  }

  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@media (min-width: 760px) {
  .page-shell {
    width: min(1240px, calc(100% - 2.2rem));
    padding-top: 1.35rem;
  }

  body.app-mode .brand-lockup {
    gap: 1.15rem;
  }

  body.app-mode .brand-mark {
    width: 4.6rem;
    height: 4.6rem;
    border-radius: 1.35rem;
  }

  body.auth-mode .page-shell {
    width: min(36rem, calc(100% - 2.2rem));
  }

  .dashboard,
  .auth-card {
    padding: 1.5rem;
  }

  .dashboard-header {
    flex-direction: row;
    align-items: center;
  }

  .toolbar {
    flex-direction: row;
    align-items: end;
  }

  .dashboard-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
  }

  .dashboard-actions > .ghost-button,
  .dashboard-actions > .primary-button,
  .dashboard-actions > .secondary-button,
  .dashboard-actions > .danger-button {
    width: auto;
  }

  .dashboard-stats {
    flex-wrap: nowrap;
  }

  .product-card {
    padding: 1.15rem;
  }

  .price-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .product-meta {
    flex-direction: row;
    align-items: flex-end;
  }

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

/* ---- Pull-to-Refresh -------------------------------------------- */
.pull-indicator {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.5rem 1.1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.09);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(14px);
  color: var(--muted);
  font-size: 0.88rem;
  opacity: 0;
  pointer-events: none;
  white-space: nowrap;
  z-index: 30;
  transition: opacity 120ms ease;
}

.pull-spinner {
  width: 1.1rem;
  height: 1.1rem;
  color: var(--accent);
  animation: ptr-spin 0.9s linear infinite;
}

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

/* ---- Settings panel --------------------------------------------- */
.settings-panel {
  border-radius: var(--radius-md);
  display: grid;
  gap: 0.9rem;
}

.settings-email {
  font-size: 0.95rem;
  word-break: break-all;
  overflow-wrap: anywhere;
}

.settings-actions {
  display: grid;
  gap: 0.65rem;
}

.settings-actions > button {
  width: 100%;
  justify-content: center;
}

@media (min-width: 760px) {
  .settings-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .settings-actions > button {
    width: auto;
  }
}
