/* App shell, page chrome, and per-page composition. Built from components.css. */

/* ——— Shell ——— */
.shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  align-self: flex-start;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-width);
  height: 100vh;
  flex-shrink: 0;
  padding: var(--space-6) var(--space-3) var(--space-4);
  background: var(--color-surface);
  border-right: 1px solid var(--color-line);
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--space-3) var(--space-5);
}

.sidebar-toggle {
  display: none;
  min-height: 2.25rem;
  padding: 0 var(--space-3);
  background: var(--color-surface);
  border: 1px solid var(--color-line-strong);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 600;
}

.sidebar-body {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.nav-item,
.nav-store-link,
.nav-connect {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem var(--space-3);
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--color-muted);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.nav-item:hover,
.nav-store-link:hover,
.nav-connect:hover,
.nav-report:hover {
  color: var(--color-ink);
  background: var(--color-sunken);
}

.nav-item.active,
.nav-store.active,
.nav-report.active {
  background: var(--color-accent-soft);
  color: var(--color-accent);
  font-weight: 600;
}

.nav-group {
  margin: var(--space-4) 0 var(--space-2);
}

.nav-group .label {
  padding: 0 var(--space-3) var(--space-2);
}

.nav-store {
  display: flex;
  align-items: center;
  border-radius: var(--radius-sm);
}

.nav-store-link {
  flex: 1;
  min-width: 0;
  color: inherit;
}

.nav-store.active .nav-store-link:hover {
  background: transparent;
}

.chev {
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  background: none;
  border: 0;
  border-radius: var(--radius-sm);
  color: var(--color-muted);
}

.chev .icon {
  width: 0.875rem;
  height: 0.875rem;
  transition: transform var(--dur-fast) var(--ease);
}

.chev[aria-expanded='true'] .icon {
  transform: rotate(90deg);
}

.nav-nested {
  margin: var(--space-1) 0 var(--space-2) var(--space-4);
  padding-left: var(--space-3);
  border-left: 1px solid var(--color-line);
}

.nav-nested .label {
  display: block;
  padding: var(--space-1) var(--space-2);
  font-size: 0.625rem;
}

.nav-report {
  display: block;
  padding: 0.375rem var(--space-2);
  border-radius: 5px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.nav-report.is-static {
  font-family: var(--font-sans);
  cursor: default;
}

.nav-report.is-static:hover {
  background: transparent;
  color: var(--color-muted);
}

.nav-connect {
  margin-top: var(--space-1);
  font-size: var(--text-xs);
}

.sidebar-bottom {
  margin-top: auto;
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-line);
}

.nav-logout {
  width: 100%;
  border: 0;
  background: none;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
}

.main {
  flex: 1;
  min-width: 0;
  padding: var(--space-10) var(--space-10) var(--space-12);
}

.page {
  max-width: var(--content-max);
  margin: 0 auto;
}

.page-narrow {
  max-width: 46rem;
}

/* ——— Page header ——— */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
}

.page-header h1 {
  font-size: var(--text-2xl);
  font-weight: 800;
}

.page-header .sub {
  margin-top: var(--space-1);
  color: var(--color-muted);
}

.page-header-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: var(--space-2);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.breadcrumb a {
  font-weight: 500;
}

.breadcrumb a:hover {
  color: var(--color-ink);
}

.breadcrumb .sep {
  color: var(--color-line-strong);
}

.breadcrumb .current {
  font-weight: 600;
  color: var(--color-ink);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-3);
  margin: var(--space-8) 0 var(--space-3);
}

.section-head h2 {
  font-size: var(--text-md);
  font-weight: 700;
}

.section-head .muted {
  font-size: var(--text-sm);
}

/* ——— Pulse strip ——— */
.pulse {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 11rem), 1fr));
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.footnote {
  margin-top: var(--space-5);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

/* ——— Overview: store cards ——— */
.store-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 20rem), 1fr));
  gap: var(--space-4);
}

.store-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.store-card:hover {
  border-color: var(--color-line-strong);
  box-shadow: var(--shadow-2);
}

.store-card-top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.store-icon {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  flex-shrink: 0;
  border-radius: var(--radius);
  background: var(--color-accent);
  color: var(--color-on-accent);
  font-size: var(--text-md);
  font-weight: 700;
}

.store-icon.waiting {
  background: var(--color-sunken);
  color: var(--color-muted);
  border: 1px solid var(--color-line-strong);
}

.store-meta {
  flex: 1 1 8rem;
  min-width: 0;
}

.store-name {
  font-size: var(--text-md);
  font-weight: 700;
  overflow-wrap: break-word;
}

.store-trend {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
}

.store-trend .num.value {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.15;
}

.store-facts {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1) var(--space-5);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.store-facts b {
  color: var(--color-ink);
  font-weight: 600;
}

.store-summary {
  font-size: var(--text-sm);
  color: var(--color-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.store-card .btn-link {
  margin-top: auto;
}

/* ——— Store page ——— */
.store-layout {
  display: grid;
  gap: var(--space-4);
}

.status-panel {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-2);
  padding: var(--space-6);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.status-panel .label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.status-panel .dot {
  width: 0.4375rem;
  height: 0.4375rem;
  border-radius: 50%;
  background: var(--color-warn);
}

.status-panel h3 {
  font-size: var(--text-md);
  font-weight: 700;
}

.status-panel .desc {
  color: var(--color-muted);
}

.status-panel .inset {
  align-self: stretch;
  margin-top: var(--space-2);
}

.status-panel .line {
  font-weight: 700;
}

.status-panel .when {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.status-panel .pill {
  margin-top: var(--space-2);
}

/* ——— Report ——— */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-3);
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-accent);
}

.report-lead {
  display: grid;
  grid-template-columns: 1.1fr 1fr;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.summary {
  padding: var(--space-4) var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.action + .summary {
  margin-top: var(--space-3);
}

.summary p {
  margin-top: var(--space-2);
  line-height: 1.55;
}

.report-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-5);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-1);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-md);
  font-weight: 700;
}

.panel-title .icon {
  color: var(--color-accent);
}

.kpis {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-2);
}

.kpi {
  min-width: 0;
  padding: var(--space-3);
  background: var(--color-sunken);
  border-radius: var(--radius-sm);
}

.kpi.wide {
  grid-column: 1 / -1;
}

.kpi .value {
  font-size: var(--text-lg);
  font-weight: 600;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.kpi .label {
  display: block;
  margin-top: var(--space-1);
  font-size: 0.625rem;
}

.kpi .vs {
  margin-top: var(--space-1);
}

.panel .label.with-dot {
  display: flex;
  align-items: center;
  gap: 0.375rem;
}

.alert-dot {
  width: 0.375rem;
  height: 0.375rem;
  border-radius: 50%;
  background: var(--color-warn);
}

/* ——— Settings / Support ——— */
.settings-panels {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-4);
}

.settings-panels .full {
  grid-column: 1 / -1;
}

.row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-3);
}

.billing-status,
.store-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.billing-status .plan {
  font-weight: 700;
}

.billing-status .detail {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.store-row {
  justify-content: flex-start;
}

.store-row .connected {
  margin-left: auto;
}

.handoff-note {
  margin-top: var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.panel-actions {
  margin-top: var(--space-4);
}

.support-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
}

.support-row .muted {
  margin-top: var(--space-1);
  font-size: var(--text-sm);
}

.support-layout {
  display: grid;
  grid-template-columns: 1fr 20rem;
  gap: var(--space-4);
  align-items: start;
}

.faq-item {
  padding: var(--space-4) 0;
  border-top: 1px solid var(--color-line);
}

.faq-item:first-of-type {
  border-top: 0;
  padding-top: 0;
}

.faq-item .q {
  margin-bottom: var(--space-1);
  font-weight: 600;
}

.faq-item .a {
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.contact-box {
  margin-bottom: var(--space-4);
}

.contact-box .email {
  margin: var(--space-1) 0;
  font-size: var(--text-md);
  font-weight: 700;
  overflow-wrap: anywhere;
}

.contact-box .hint {
  font-size: var(--text-xs);
  color: var(--color-muted);
}

.stack {
  display: grid;
  gap: var(--space-3);
}

/* ——— Auth ——— */
.auth-shell {
  display: flex;
  min-height: 100vh;
}

.auth-brand {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: var(--space-8);
  width: 44%;
  padding: var(--space-12) 3.5rem;
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.auth-brand-home {
  align-self: flex-start;
  color: inherit;
}

.auth-brand .logo-mark rect {
  fill: var(--color-on-accent);
}

.auth-brand .logo-mark path {
  stroke: var(--color-accent);
}

.auth-brand h1 {
  max-width: 16ch;
  margin-bottom: var(--space-4);
  font-size: var(--text-2xl);
  font-weight: 800;
}

.auth-brand p {
  max-width: 24rem;
  font-size: var(--text-md);
  line-height: 1.6;
  opacity: 0.9;
}

.auth-brand-footer {
  font-size: var(--text-sm);
  opacity: 0.8;
}

.auth-panel {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: center;
  padding: var(--space-8) var(--space-4);
}

.auth-card {
  width: 100%;
  max-width: 25rem;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
}

.auth-card h2 {
  margin-bottom: var(--space-1);
  font-size: var(--text-lg);
  font-weight: 800;
}

.auth-card .sub {
  margin-bottom: var(--space-6);
  color: var(--color-muted);
}

.auth-footer {
  margin-top: var(--space-5);
  text-align: center;
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.auth-footer a {
  font-weight: 600;
  color: var(--color-accent);
}

/* ——— Billing return ——— */
.return-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.return-topbar {
  display: flex;
  align-items: center;
  height: 3.5rem;
  padding: 0 var(--space-8);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-line);
}

.return-card {
  width: calc(100% - 2rem);
  max-width: 26rem;
  margin: var(--space-12) auto;
  padding: var(--space-8);
  background: var(--color-surface);
  border: 1px solid var(--color-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-2);
  text-align: center;
}

.check-circle {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  margin: 0 auto var(--space-5);
  border-radius: 50%;
  background: var(--color-accent);
  color: var(--color-on-accent);
}

.check-circle .icon {
  width: 1.5rem;
  height: 1.5rem;
  stroke-width: 2.5;
}

.return-card h1 {
  margin-bottom: var(--space-2);
  font-size: var(--text-lg);
  font-weight: 800;
}

.return-card .lead {
  margin-bottom: var(--space-6);
  color: var(--color-muted);
}

.return-status {
  margin-bottom: var(--space-6);
  text-align: left;
}

.return-status .plan {
  font-weight: 700;
}

.return-status .detail {
  margin: var(--space-1) 0 var(--space-2);
  font-size: var(--text-sm);
  color: var(--color-muted);
}

.return-card .btn + .btn {
  margin-top: var(--space-3);
}

/* ——— Small screens ——— */
@media (max-width: 960px) {
  .shell {
    flex-direction: column;
  }

  .sidebar {
    position: sticky;
    z-index: 30;
    width: 100%;
    height: auto;
    padding: var(--space-3) var(--space-4);
    border-right: 0;
    border-bottom: 1px solid var(--color-line);
  }

  .sidebar-head {
    padding: 0;
  }

  .sidebar-toggle {
    display: inline-flex;
    align-items: center;
  }

  .sidebar-body {
    display: none;
    max-height: calc(100vh - 4.5rem);
    padding-top: var(--space-4);
  }

  .sidebar.is-open .sidebar-body {
    display: flex;
  }

  .main {
    padding: var(--space-6) var(--space-4) var(--space-10);
  }

  .report-lead,
  .report-grid,
  .settings-panels,
  .support-layout {
    grid-template-columns: 1fr;
  }

  .auth-shell {
    flex-direction: column;
  }

  .auth-brand {
    width: 100%;
    padding: var(--space-8) var(--space-6);
  }
}

@media (max-width: 520px) {
  .page-header {
    flex-direction: column;
  }

  .page-header-end {
    justify-content: flex-start;
  }

  .row-2 {
    grid-template-columns: 1fr;
  }

  .modal {
    padding: var(--space-6);
  }

  .support-row,
  .billing-status {
    flex-direction: column;
    align-items: flex-start;
  }
}

.handoff-backdrop {
  height: 12.5rem;
  opacity: 0.5;
}
