:root {
  --p-surface: #f1f2f4;
  --p-card: #ffffff;
  --p-card-subdued: #f8f9fa;
  --p-border: #e1e3e5;
  --p-border-strong: #c9cccf;
  --p-text: #1a1a1a;
  --p-text-subdued: #5c5f62;
  --p-topbar: #1a1a1a;
  --p-emerald: #008060;
  --p-emerald-hover: #006e52;
  --p-emerald-soft: #e3f1df;
  --p-emerald-ink: #004c3f;
  --p-amber-soft: #fff5ea;
  --p-amber-ink: #8a5100;
  --p-critical-soft: #fbeae5;
  --p-critical-ink: #8e1f0b;
  --p-radius: 12px;
  --p-shadow: 0 1px 2px rgba(26, 26, 26, 0.06), 0 0 0 1px rgba(26, 26, 26, 0.04);
}

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

html,
body {
  margin: 0;
  padding: 0;
  max-width: 100%;
  overflow-x: hidden;
  background: var(--p-surface);
  color: var(--p-text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.88em;
  background: #ebeef0;
  padding: 1px 5px;
  border-radius: 5px;
  word-break: break-word;
}

/* Top Shopify Bar */
.shopify-topbar {
  background: var(--p-topbar);
  color: #ffffff;
  border-bottom: 1px solid #2e2e2e;
}

.topbar-inner {
  max-width: 1320px;
  margin: 0 auto;
  padding: 11px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: linear-gradient(135deg, #00a47c, #008060);
  color: #ffffff;
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.brand-name {
  font-weight: 650;
  font-size: 15px;
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 12px;
  color: #b5b8bc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.store-pill,
.plan-pill {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.store-pill {
  background: #2c2d30;
  color: #e3e5e7;
  border: 1px solid #3c3e42;
}

.plan-pill {
  background: rgba(0, 164, 124, 0.22);
  color: #7ee8c8;
  border: 1px solid rgba(126, 232, 200, 0.35);
  font-weight: 600;
}

/* Main Admin Container */
.admin-shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.page-header > div,
.card-header-row > div,
.migrator-grid > *,
.workspace-two-col > * {
  min-width: 0;
  max-width: 100%;
}

.page-header h1 {
  margin: 0 0 4px 0;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.page-lead {
  margin: 0;
  color: var(--p-text-subdued);
  max-width: 780px;
}

.extension-pills {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.badge-emerald {
  background: var(--p-emerald-soft);
  color: var(--p-emerald-ink);
}

.badge-amber {
  background: var(--p-amber-soft);
  color: var(--p-amber-ink);
}

.badge-critical {
  background: var(--p-critical-soft);
  color: var(--p-critical-ink);
}

.badge-neutral {
  background: #e4e5e7;
  color: #303030;
}

/* Notice Banner */
.notice-banner {
  padding: 11px 14px;
  border-radius: 10px;
  font-weight: 500;
  border: 1px solid var(--p-border-strong);
  background: var(--p-card);
}

.notice-banner.success {
  background: var(--p-emerald-soft);
  border-color: #95c9b4;
  color: var(--p-emerald-ink);
}

.notice-banner.error {
  background: var(--p-critical-soft);
  border-color: #e69b8e;
  color: var(--p-critical-ink);
}

.hidden {
  display: none !important;
}

/* Polaris Cards & KPI Strip */
.polaris-card {
  background: var(--p-card);
  border-radius: var(--p-radius);
  box-shadow: var(--p-shadow);
  border: 1px solid var(--p-border);
}

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

.kpi-card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.kpi-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--p-text-subdued);
}

.kpi-value {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--p-text);
  overflow: hidden;
  text-overflow: ellipsis;
}

.kpi-channel {
  font-size: 20px;
}

.kpi-caption {
  font-size: 12px;
  color: var(--p-text-subdued);
}

.section-card {
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.card-header-row h2 {
  margin: 0 0 3px 0;
  font-size: 16px;
  font-weight: 650;
}

.card-subcopy {
  margin: 0;
  font-size: 13px;
  color: var(--p-text-subdued);
}

/* Migrator Grid */
.migrator-grid {
  display: grid;
  grid-template-columns: 1.15fr 0.85fr;
  gap: 16px;
  align-items: stretch;
}

.migration-output {
  background: var(--p-card-subdued);
  border: 1px solid var(--p-border);
  border-radius: 10px;
  padding: 14px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
}

.empty-migration-state {
  margin: auto 0;
  text-align: left;
  color: var(--p-text-subdued);
}

.empty-migration-state strong {
  display: block;
  color: var(--p-text);
  margin-bottom: 4px;
}

.migration-summary-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--p-border);
  margin-bottom: 10px;
}

.extracted-list {
  margin: 0 0 10px 0;
  display: grid;
  grid-template-columns: minmax(90px, auto) 1fr;
  gap: 6px 10px;
  font-size: 12.5px;
}

.extracted-list dt {
  font-weight: 600;
  color: var(--p-text-subdued);
}

.extracted-list dd {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  color: var(--p-text);
}

.warnings-block {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.warning-item {
  background: #ffffff;
  border: 1px solid #e6d7c3;
  border-left: 3px solid #d88b1c;
  border-radius: 6px;
  padding: 7px 9px;
  font-size: 12px;
}

.warning-item strong {
  display: block;
  color: #5c3b00;
}

/* Workspace Two Columns */
.workspace-two-col {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  align-items: start;
}

.stack-form,
.simulator-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.form-row-two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.form-row-three {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 0;
}

.field-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--p-text);
}

.text-input,
.select-input,
.text-area,
.code-textarea {
  width: 100%;
  max-width: 100%;
  font-family: inherit;
  border: 1px solid var(--p-border-strong);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  color: var(--p-text);
  background: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.code-textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.45;
  resize: vertical;
}

.text-input:focus,
.select-input:focus,
.text-area:focus,
.code-textarea:focus {
  outline: none;
  border-color: var(--p-emerald);
  box-shadow: 0 0 0 2px rgba(0, 128, 96, 0.18);
}

.section-divider {
  border: 0;
  border-top: 1px solid var(--p-border);
  margin: 2px 0;
}

/* Buttons */
.button-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 8px 13px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  border: 1px solid transparent;
  transition: background 0.14s ease, border-color 0.14s ease;
  max-width: 100%;
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--p-emerald);
  color: #ffffff;
  border-color: #006e52;
}

.btn-primary:hover:not(:disabled) {
  background: var(--p-emerald-hover);
}

.btn-secondary {
  background: #ffffff;
  color: var(--p-text);
  border-color: var(--p-border-strong);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.04);
}

.btn-secondary:hover:not(:disabled) {
  background: #f6f6f7;
}

.btn-compact {
  padding: 6px 11px;
  font-size: 12.5px;
}

.saved-hint,
.subtle-caption {
  font-size: 12px;
  color: var(--p-text-subdued);
}

/* Tables */
.log-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 4px;
}

.log-header-bar h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.table-scroll {
  width: 100%;
  overflow-x: auto;
  border: 1px solid var(--p-border);
  border-radius: 9px;
}

.polaris-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.polaris-table th,
.polaris-table td {
  padding: 9px 10px;
  text-align: left;
  border-bottom: 1px solid var(--p-border);
  vertical-align: middle;
}

.polaris-table th {
  background: var(--p-card-subdued);
  color: var(--p-text-subdued);
  font-weight: 600;
  white-space: nowrap;
}

.polaris-table tbody tr:last-child td {
  border-bottom: none;
}

.num-col {
  text-align: right !important;
}

/* Checkout Preview Frame */
.checkout-preview-frame {
  border: 1px solid var(--p-border);
  background: var(--p-card-subdued);
  border-radius: 10px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.callout-preview-box {
  background: #eef6ff;
  border: 1px solid #b8d6f8;
  border-radius: 8px;
  padding: 11px 12px;
}

.callout-preview-box strong {
  display: block;
  font-size: 13px;
  color: #0b3d75;
  margin-bottom: 3px;
}

.callout-preview-box p {
  margin: 0;
  font-size: 12.5px;
  color: #1f446e;
}

.survey-preview-box {
  background: #ffffff;
  border: 1px solid var(--p-border);
  border-radius: 8px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.survey-preview-header {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.survey-options-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.survey-option-btn {
  text-align: left;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--p-border-strong);
  background: #ffffff;
  color: var(--p-text);
  font-size: 12.5px;
  font-weight: 550;
  cursor: pointer;
  transition: border-color 0.14s ease, background 0.14s ease;
}

.survey-option-btn:hover {
  border-color: var(--p-emerald);
  background: #f2faf7;
}

/* Mobile & Tablet Breakpoints (375x812 zero horizontal overflow) */
@media (max-width: 1040px) {
  .kpi-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .migrator-grid,
  .workspace-two-col {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (max-width: 640px) {
  .topbar-inner {
    padding: 10px 14px;
  }
  .store-pill,
  .plan-pill {
    font-size: 11px;
    padding: 3px 8px;
  }
  .admin-shell {
    padding: 14px 12px;
    gap: 14px;
  }
  .page-header h1 {
    font-size: 18px;
  }
  .section-card {
    padding: 14px;
  }
  .kpi-grid,
  .form-row-two,
  .form-row-three,
  .survey-options-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .polaris-table th,
  .polaris-table td {
    padding: 7px 6px;
    font-size: 11.5px;
  }
  .header-actions,
  .button-row {
    width: 100%;
  }
  .btn {
    width: 100%;
  }
}

.admin-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 12px 4px 20px;
  font-size: 12px;
  color: var(--p-text-subdued);
}

.admin-footer a {
  color: var(--p-emerald);
  text-decoration: none;
}

.admin-footer a:hover {
  text-decoration: underline;
}

/* === Apple HIG & Emil Kowalski Micro-Interaction Craft === */
:root {
  --ease-out-expo: cubic-bezier(0.16, 1, 0.3, 1);
}
button, .btn, .p-btn, a.btn, [role="button"] {
  transition: transform 140ms var(--ease-out-expo), background-color 160ms var(--ease-out-expo), border-color 160ms var(--ease-out-expo), box-shadow 160ms var(--ease-out-expo);
}
button:active:not(:disabled), .btn:active:not(:disabled), .p-btn:active:not(:disabled), [role="button"]:active {
  transform: scale(0.97);
}
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 2px solid #008060;
  outline-offset: 2px;
}
.kpi-val, .metric-val, td, th, .stat-num {
  font-variant-numeric: tabular-nums;
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* === UI/UX Pro Max + Emil Kowalski Surface Elevation & Alignment Pass === */
body {
  background: radial-gradient(circle at 50% 0%, #eef2f7 0%, #f4f6fa 52%, #f1f3f7 100%);
}
.shopify-topbar {
  background: linear-gradient(180deg, #181a1f 0%, #111318 100%);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.12);
}
.card, .kpi-card, .panel, .section-card {
  border: 1px solid rgba(15, 23, 42, 0.08);
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.9), 0 1px 2px rgba(15, 23, 42, 0.04), 0 6px 18px rgba(15, 23, 42, 0.03);
  transition: transform 180ms var(--ease-out-expo), box-shadow 180ms var(--ease-out-expo), border-color 180ms var(--ease-out-expo);
}
.kpi-card:hover {
  transform: translateY(-1px);
  border-color: rgba(0, 128, 96, 0.25);
  box-shadow: 0 2px 6px rgba(15, 23, 42, 0.05), 0 10px 24px rgba(15, 23, 42, 0.05);
}
.kpi-value, .kpi-val, .metric-val, h1, h2 {
  letter-spacing: -0.025em;
}
.form-grid, .field-grid, .two-col-fields, .dest-grid {
  align-items: end;
}
.btn-primary, button.btn-primary {
  background: linear-gradient(180deg, #00946f 0%, #007a5b 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 6px rgba(0, 128, 96, 0.22);
}
input:focus, select:focus, textarea:focus {
  border-color: #008060 !important;
  box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.14) !important;
  outline: none;
}
