.store-management {
  --sm-ink: #122a2f;
  --sm-muted: #65787c;
  --sm-line: #dce6e5;
  --sm-soft: #f3f7f6;
  --sm-panel: #ffffff;
  --sm-accent: #0f766e;
  --sm-accent-dark: #0b5d57;
  --sm-warn: #a16207;
  --sm-danger: #b42318;
  color: var(--sm-ink);
  display: grid;
  gap: 20px;
  min-width: 0;
}

[data-theme="dark"] .store-management {
  --sm-ink: #e8f2f1;
  --sm-muted: #9eb2b0;
  --sm-line: #314846;
  --sm-soft: #172725;
  --sm-panel: #10201f;
  --sm-accent: #36b9ad;
  --sm-accent-dark: #5acdc2;
  --sm-warn: #e5ad46;
  --sm-danger: #ff8a80;
}

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

.sm-page-header,
.sm-toolbar,
.sm-intakes > header,
.sm-dialog-header,
.sm-detail-section > header,
.sm-pagination {
  align-items: center;
  display: flex;
  gap: 16px;
  justify-content: space-between;
}

.sm-page-header {
  border-bottom: 1px solid var(--sm-line);
  padding: 2px 0 18px;
}

.sm-page-header h2,
.sm-toolbar h3,
.sm-intakes h3,
.sm-dialog-header h2,
.sm-detail-section h3,
.sm-confirm h2 {
  color: var(--sm-ink);
  margin: 0;
}

.sm-page-header h2 {
  font-size: clamp(1.25rem, 2vw, 1.7rem);
  letter-spacing: -0.025em;
}

.sm-page-header span,
.sm-toolbar span,
.sm-intakes header span,
.sm-dialog-header span,
.sm-detail-section header span,
.sm-help,
.sm-empty span,
.sm-intake-main > span,
.sm-intake-status > span:last-child,
.sm-store-card header span,
.sm-waiting p,
.sm-complete p,
.sm-confirm p {
  color: var(--sm-muted);
  font-size: 0.86rem;
}

.sm-eyebrow {
  color: var(--sm-accent);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  margin: 0 0 5px;
  text-transform: uppercase;
}

.sm-button,
.sm-icon,
.sm-provider-choice button,
.sm-auth-choice button,
.sm-notice button {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
}

.sm-button {
  align-items: center;
  border-radius: 9px;
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 750;
  justify-content: center;
  min-height: 40px;
  padding: 9px 14px;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease, transform 140ms ease;
}

.sm-button:hover:not(:disabled) { transform: translateY(-1px); }
.sm-button:disabled { cursor: not-allowed; opacity: 0.52; }
.sm-button.is-primary { background: var(--sm-accent); color: #fff; }
.sm-button.is-primary:hover:not(:disabled) { background: var(--sm-accent-dark); }
.sm-button.is-secondary { background: var(--sm-panel); border: 1px solid var(--sm-line); color: var(--sm-ink); }
.sm-button.is-danger { background: color-mix(in srgb, var(--sm-danger) 10%, var(--sm-panel)); border: 1px solid color-mix(in srgb, var(--sm-danger) 36%, var(--sm-line)); color: var(--sm-danger); }

.sm-button:focus-visible,
.sm-icon:focus-visible,
.sm-provider-choice button:focus-visible,
.sm-auth-choice button:focus-visible,
.sm-app-option:focus-within,
.store-management input:focus-visible,
.store-management select:focus-visible,
.store-management textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--sm-accent) 35%, transparent);
  outline-offset: 2px;
}

.sm-list-panel,
.sm-intakes {
  background: var(--sm-panel);
  border: 1px solid var(--sm-line);
  border-radius: 14px;
  min-width: 0;
  overflow: hidden;
}

.sm-toolbar,
.sm-intakes > header {
  border-bottom: 1px solid var(--sm-line);
  padding: 17px 18px;
}

.sm-toolbar h3,
.sm-intakes h3 { font-size: 1rem; }
.sm-toolbar > div:first-child,
.sm-intakes header > div { display: grid; gap: 2px; }

.sm-filters {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.store-management input,
.store-management select,
.store-management textarea {
  background: var(--sm-panel);
  border: 1px solid var(--sm-line);
  border-radius: 8px;
  color: var(--sm-ink);
  font: inherit;
  min-height: 42px;
  padding: 9px 11px;
  width: 100%;
}

.sm-search { min-width: min(330px, 46vw); }
.sm-filters select { min-width: 144px; }

.sm-table-wrap { min-width: 0; overflow-x: auto; }
.sm-table { border-collapse: collapse; min-width: 820px; width: 100%; }
.sm-table th {
  background: var(--sm-soft);
  color: var(--sm-muted);
  font-size: 0.72rem;
  letter-spacing: 0.045em;
  padding: 10px 16px;
  text-align: left;
  text-transform: uppercase;
}
.sm-table td { border-top: 1px solid var(--sm-line); padding: 14px 16px; vertical-align: middle; }
.sm-table tbody tr:first-child td { border-top: 0; }
.sm-table td strong,
.sm-table td > span:not(.sm-status):not(.sm-provider) { display: block; }
.sm-table td > span:not(.sm-status):not(.sm-provider) { color: var(--sm-muted); font-size: 0.78rem; margin-top: 3px; }

.sm-provider,
.sm-status,
.sm-count {
  align-items: center;
  border-radius: 999px;
  display: inline-flex;
  font-size: 0.74rem;
  font-weight: 800;
  line-height: 1;
  min-height: 25px;
  padding: 6px 9px;
  white-space: nowrap;
}

.sm-provider { background: var(--sm-soft); border: 1px solid var(--sm-line); color: var(--sm-ink); }
.sm-provider.is-shopify { background: #edf8e8; border-color: #cbe8bd; color: #356b24; }
.sm-provider.is-shopline { background: #eef3ff; border-color: #cedaff; color: #3453a1; }
[data-theme="dark"] .sm-provider.is-shopify { background: #20331d; color: #9bd488; }
[data-theme="dark"] .sm-provider.is-shopline { background: #1e2942; color: #9bb3ff; }
.sm-status { background: var(--sm-soft); color: var(--sm-muted); }
.sm-status.is-good { background: color-mix(in srgb, var(--sm-accent) 12%, var(--sm-panel)); color: var(--sm-accent-dark); }
.sm-status.is-warn { background: color-mix(in srgb, var(--sm-warn) 12%, var(--sm-panel)); color: var(--sm-warn); }
.sm-status.is-muted { background: var(--sm-soft); color: var(--sm-muted); }
.sm-count { background: var(--sm-soft); color: var(--sm-accent); font-size: 0.86rem; }

.sm-pagination { border-top: 1px solid var(--sm-line); color: var(--sm-muted); font-size: 0.82rem; padding: 12px 16px; }
.sm-pagination > div { display: flex; gap: 8px; }
.sm-pagination .sm-button { min-height: 34px; padding: 6px 11px; }

.sm-card-list { display: none; }
.sm-store-card { background: var(--sm-panel); border-bottom: 1px solid var(--sm-line); padding: 16px; }
.sm-store-card header { align-items: flex-start; display: flex; gap: 12px; justify-content: space-between; }
.sm-store-card header > div { display: grid; gap: 3px; }
.sm-store-card dl { display: grid; gap: 9px; margin: 14px 0; }
.sm-store-card dl div { align-items: center; display: flex; gap: 12px; justify-content: space-between; }
.sm-store-card dt { color: var(--sm-muted); font-size: 0.76rem; }
.sm-store-card dd { margin: 0; text-align: right; }
.sm-store-card > .sm-button { width: 100%; }

.sm-intake-card {
  align-items: center;
  border-bottom: 1px solid var(--sm-line);
  display: grid;
  gap: 16px;
  grid-template-columns: minmax(180px, 1.2fr) minmax(145px, 0.7fr) minmax(280px, 1fr);
  padding: 14px 18px;
}
.sm-intake-main { display: grid; gap: 4px; }
.sm-intake-main .sm-provider { justify-self: start; margin-bottom: 2px; }
.sm-intake-status { align-items: flex-start; display: grid; gap: 5px; justify-items: start; }
.sm-bind-control { align-items: end; display: grid; gap: 8px; grid-template-columns: 1fr auto; }
.sm-bind-control label { color: var(--sm-muted); display: grid; font-size: 0.74rem; gap: 4px; }

.sm-notice {
  align-items: flex-start;
  background: var(--sm-soft);
  border: 1px solid var(--sm-line);
  border-left: 4px solid var(--sm-accent);
  border-radius: 10px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding: 11px 13px;
}
.sm-notice.is-error { border-left-color: var(--sm-danger); }
.sm-notice.is-success { border-left-color: var(--sm-accent); }
.sm-notice button { background: transparent; color: var(--sm-muted); font-size: 1.2rem; line-height: 1; }
.sm-live { height: 0; overflow: hidden; }

.sm-empty { align-items: center; display: grid; gap: 5px; justify-items: center; padding: 52px 20px; text-align: center; }
.sm-empty.is-compact { padding: 28px 20px; }

.sm-overlay {
  align-items: center;
  background: rgba(7, 24, 25, 0.58);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 1400;
}

.sm-dialog,
.sm-confirm {
  background: var(--sm-panel);
  border: 1px solid var(--sm-line);
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(9, 34, 36, 0.24);
  max-height: calc(100vh - 48px);
  overflow: auto;
  width: min(760px, 100%);
}
.sm-dialog-header { border-bottom: 1px solid var(--sm-line); padding: 17px 20px; }
.sm-dialog-header > div { min-width: 0; }
.sm-dialog-header h2 { font-size: 1.25rem; }
.sm-icon { align-items: center; background: var(--sm-soft); border-radius: 999px; color: var(--sm-muted); display: inline-flex; flex: 0 0 40px; font-size: 1.4rem; height: 40px; justify-content: center; }
.sm-dialog-body { padding: 22px; }

.sm-steps {
  border-bottom: 1px solid var(--sm-line);
  display: grid;
  gap: 5px;
  grid-template-columns: repeat(7, 1fr);
  list-style: none;
  margin: 0;
  padding: 12px 20px;
}
.sm-steps li { align-items: center; color: var(--sm-muted); display: flex; font-size: 0.7rem; gap: 5px; min-width: 0; }
.sm-steps li span { align-items: center; background: var(--sm-soft); border-radius: 999px; display: inline-flex; flex: 0 0 22px; height: 22px; justify-content: center; }
.sm-steps li.is-current { color: var(--sm-accent); font-weight: 800; }
.sm-steps li.is-current span,
.sm-steps li.is-done span { background: var(--sm-accent); color: #fff; }

.sm-provider-choice { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.sm-auth-choice { display: grid; gap: 14px; grid-template-columns: repeat(2, 1fr); }
.sm-provider-choice button { align-items: flex-start; background: var(--sm-panel); border: 1px solid var(--sm-line); border-radius: 13px; color: var(--sm-ink); display: grid; gap: 9px; min-height: 170px; padding: 20px; text-align: left; }
.sm-auth-choice button { align-items: flex-start; background: var(--sm-panel); border: 1px solid var(--sm-line); border-radius: 13px; color: var(--sm-ink); display: grid; gap: 8px; min-height: 132px; padding: 18px; text-align: left; }
.sm-provider-choice button:hover { border-color: var(--sm-accent); box-shadow: 0 9px 24px color-mix(in srgb, var(--sm-accent) 12%, transparent); }
.sm-auth-choice button:hover { border-color: var(--sm-accent); box-shadow: 0 9px 24px color-mix(in srgb, var(--sm-accent) 12%, transparent); }
.sm-provider-choice strong { font-size: 1.05rem; }
.sm-provider-choice small,
.sm-auth-choice small,
.sm-app-option small { color: var(--sm-muted); }
.sm-recommended { background: color-mix(in srgb, var(--sm-accent) 13%, var(--sm-panel)); border-radius: 999px; color: var(--sm-accent); font-size: 0.68rem; margin-left: 5px; padding: 3px 7px; }

.sm-app-picker { border: 1px solid var(--sm-line); border-radius: 11px; display: grid; gap: 8px; margin: 0; padding: 13px; }
.sm-app-picker legend { color: var(--sm-muted); font-size: 0.78rem; font-weight: 800; padding: 0 5px; }
.sm-app-option-row { display: grid; gap: 7px; grid-template-columns: minmax(0, 1fr) auto; }
.sm-app-option { align-items: center; border: 1px solid var(--sm-line); border-radius: 9px; color: var(--sm-ink) !important; cursor: pointer; display: grid !important; gap: 10px !important; grid-template-columns: 22px 1fr; min-height: 58px; padding: 9px 11px; }
.sm-app-option:has(input:checked) { background: color-mix(in srgb, var(--sm-accent) 8%, var(--sm-panel)); border-color: var(--sm-accent); }
.sm-app-option input { min-height: 20px; width: 20px; }
.sm-app-option span { display: grid; gap: 2px; }
.sm-app-rename-button { align-self: center; background: transparent; border: 0; color: var(--sm-accent); cursor: pointer; font: inherit; font-size: 0.78rem; font-weight: 800; padding: 10px; }
.sm-app-name-editor { align-items: end; background: var(--sm-soft); border: 1px solid var(--sm-line); border-radius: 9px; display: grid; gap: 8px; grid-column: 1 / -1; grid-template-columns: minmax(0, 1fr) auto auto; padding: 10px; }
.sm-app-name-editor label { display: grid; gap: 5px; }

.sm-form { display: grid; gap: 16px; }
.sm-form-grid { display: grid; gap: 14px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.sm-form label,
.sm-confirm label { color: var(--sm-muted); display: grid; font-size: 0.8rem; font-weight: 700; gap: 6px; }
.sm-form label.is-wide { grid-column: 1 / -1; }
.sm-form textarea,
.sm-confirm textarea { min-height: 88px; resize: vertical; }
.sm-modal-actions { align-items: center; display: flex; gap: 9px; justify-content: flex-end; margin-top: 4px; }
.sm-help { line-height: 1.5; margin: 0; }
.sm-readonly-contract { background: var(--sm-soft); border-left: 3px solid var(--sm-accent); border-radius: 8px; display: grid; gap: 4px; padding: 11px 13px; }
.sm-readonly-contract span { color: var(--sm-muted); font-size: 0.82rem; }

.sm-waiting,
.sm-complete { align-items: center; display: grid; gap: 12px; justify-items: center; min-height: 230px; padding: 28px; text-align: center; }
.sm-spinner { animation: sm-spin 900ms linear infinite; border: 3px solid var(--sm-line); border-radius: 999px; border-top-color: var(--sm-accent); height: 34px; width: 34px; }
@keyframes sm-spin { to { transform: rotate(360deg); } }
.sm-complete > span { align-items: center; background: color-mix(in srgb, var(--sm-accent) 14%, var(--sm-panel)); border-radius: 999px; color: var(--sm-accent); display: inline-flex; font-size: 1.5rem; height: 54px; justify-content: center; width: 54px; }

.sm-bind-review { align-items: center; display: grid; gap: 14px; grid-template-columns: 1fr auto 1fr; }
.sm-bind-review > div:not(.sm-bind-arrow) { background: var(--sm-soft); border: 1px solid var(--sm-line); border-radius: 11px; display: grid; gap: 5px; min-height: 120px; padding: 17px; }
.sm-bind-review span,
.sm-bind-review small { color: var(--sm-muted); }
.sm-bind-arrow { color: var(--sm-accent); font-size: 1.5rem; pointer-events: none; }

.sm-drawer-overlay { align-items: stretch; justify-content: flex-end; padding: 0; }
.sm-drawer { background: var(--sm-panel); box-shadow: -20px 0 60px rgba(7, 24, 25, 0.22); display: flex; flex-direction: column; height: 100%; max-width: 720px; width: min(720px, 94vw); }
.sm-drawer-body { display: grid; gap: 14px; overflow: auto; padding: 18px; }
.sm-detail-section { background: var(--sm-panel); border: 1px solid var(--sm-line); border-radius: 12px; padding: 16px; }
.sm-detail-section.is-muted { background: var(--sm-soft); }
.sm-detail-section > header { margin-bottom: 14px; }
.sm-detail-section > header > div { display: grid; gap: 3px; }
.sm-detail-section h3 { font-size: 0.98rem; }
.sm-detail-grid { display: grid; gap: 1px; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0; }
.sm-detail-grid div { background: var(--sm-soft); min-width: 0; padding: 11px 12px; }
.sm-detail-grid dt { color: var(--sm-muted); font-size: 0.72rem; margin-bottom: 4px; }
.sm-detail-grid dd { overflow-wrap: anywhere; margin: 0; }
.sm-danger-actions { display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 13px; }
.sm-detail-section > p:not(.sm-help) { color: var(--sm-muted); font-size: 0.85rem; line-height: 1.55; margin: 0; }

.sm-confirm-overlay { z-index: 1500; }
.sm-confirm { display: grid; gap: 12px; max-width: 480px; padding: 23px; }
.sm-confirm p { line-height: 1.55; margin: 0; }
.sm-confirm form { display: grid; gap: 14px; }

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

@media (max-width: 1024px) {
  .sm-toolbar { align-items: stretch; flex-direction: column; }
  .sm-filters { justify-content: flex-start; }
  .sm-search { flex: 1 1 100%; max-width: none; min-width: 0; width: 100%; }
  .sm-intake-card { grid-template-columns: 1fr 1fr; }
  .sm-bind-control { grid-column: 1 / -1; }
}

@media (max-width: 768px) {
  .store-management { gap: 14px; }
  .sm-page-header { align-items: flex-start; flex-direction: column; }
  .sm-page-header .sm-button { width: 100%; }
  .sm-toolbar { padding: 14px; }
  .sm-filters { align-items: stretch; display: grid; grid-template-columns: 1fr 1fr; width: 100%; }
  .sm-search { grid-column: 1 / -1; }
  .sm-filters label,
  .sm-filters select { min-width: 0; width: 100%; }
  .sm-table-wrap { display: none; }
  .sm-card-list { display: block; }
  .sm-pagination { align-items: stretch; flex-direction: column; }
  .sm-pagination > div .sm-button { flex: 1; }
  .sm-intakes > header { align-items: flex-start; }
  .sm-intake-card { grid-template-columns: 1fr; padding: 15px; }
  .sm-bind-control { grid-column: auto; grid-template-columns: 1fr; }
  .sm-bind-control .sm-button { width: 100%; }
  .sm-overlay { align-items: flex-end; padding: 0; }
  .sm-dialog,
  .sm-confirm { border-bottom-left-radius: 0; border-bottom-right-radius: 0; max-height: 94vh; width: 100%; }
  .sm-dialog-header { padding: 15px 16px; }
  .sm-dialog-body { padding: 17px 16px; }
  .sm-steps { grid-template-columns: repeat(7, minmax(40px, 1fr)); overflow-x: auto; padding: 10px 13px; }
  .sm-steps li { display: grid; gap: 4px; justify-items: center; text-align: center; }
  .sm-provider-choice,
  .sm-auth-choice,
  .sm-form-grid { grid-template-columns: 1fr; }
  .sm-app-option-row,
  .sm-app-name-editor { grid-template-columns: 1fr; }
  .sm-app-rename-button { justify-self: start; }
  .sm-form label.is-wide { grid-column: auto; }
  .sm-provider-choice button { min-height: 140px; }
  .sm-bind-review { grid-template-columns: 1fr; }
  .sm-bind-arrow { transform: rotate(90deg); }
  .sm-modal-actions { align-items: stretch; flex-direction: column-reverse; }
  .sm-modal-actions .sm-button { width: 100%; }
  .sm-drawer { max-width: none; width: 100%; }
  .sm-drawer .sm-dialog-header { flex: 0 0 auto; }
  .sm-drawer-body { padding: 13px; }
  .sm-detail-grid { grid-template-columns: 1fr; }
  .sm-detail-section > header { align-items: flex-start; flex-direction: column; }
  .sm-detail-section > header .sm-button { width: 100%; }
  .sm-danger-actions { align-items: stretch; flex-direction: column; }
  .sm-button,
  .sm-icon,
  .store-management input,
  .store-management select,
  .store-management textarea { min-height: 44px; }
  .sm-icon { height: 44px; width: 44px; }
}

@media (max-width: 430px) {
  .sm-filters { grid-template-columns: 1fr; }
  .sm-search { grid-column: auto; }
  .sm-store-card dl div { align-items: flex-start; flex-direction: column; gap: 3px; }
  .sm-store-card dd { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  .sm-button { transition: none; }
  .sm-spinner { animation-duration: 1800ms; }
}
