/* Shopify Admin–like shell around Polaris web components */
:root {
  --admin-sidebar: #1a1a1a;
  --admin-sidebar-hover: #2c2c2c;
  --admin-sidebar-active: #303030;
  --admin-sidebar-text: #e3e3e3;
  --admin-sidebar-muted: #b5b5b5;
  --admin-content-bg: #f1f1f1;
  --admin-border: #e3e3e3;
  --admin-radius: 8px;
  --admin-sidebar-width: 240px;
  --admin-sidebar-collapsed-width: 60px;
  --font-sans: "Inter", "ShopifySans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-sans);
  background: var(--admin-sidebar);
  color: #303030;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
}
body.command-palette-open,
body.admin-drawer-open {
  overflow: hidden;
}

a { color: #005bd3; text-decoration: none; }
a:hover { text-decoration: underline; }

/* —— Admin frame —— */
.admin-frame {
  display: flex;
  min-height: 100vh;
  background: var(--admin-sidebar);
}

.admin-sidebar {
  width: var(--admin-sidebar-width);
  flex-shrink: 0;
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  /* Polaris s-icon reads these inside shadow DOM (default is dark gray) */
  --s-icon-color-f4125: var(--admin-sidebar-text);
  --p-color-icon-f4125: var(--admin-sidebar-text);
  --p-color-icon-secondary-f4125: var(--admin-sidebar-muted);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 30;
  transition: width 0.18s ease;
  overflow: hidden;
}

html.sidebar-collapsed .admin-sidebar,
.admin-sidebar.is-collapsed {
  width: var(--admin-sidebar-collapsed-width);
}

.admin-sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.25rem;
  padding: 0.65rem 0.5rem 0.35rem 0.65rem;
  min-height: 48px;
}

.admin-sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  color: #fff;
  text-decoration: none;
  font-weight: 400;
  font-size: 0.9375rem;
}
.admin-sidebar-brand:hover { text-decoration: none; opacity: 0.92; }
.admin-sidebar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
  flex-shrink: 0;
}

.admin-sidebar-toggle {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--admin-sidebar-text);
  cursor: pointer;
  padding: 0;
}
.admin-sidebar-toggle:hover { background: var(--admin-sidebar-hover); }
.admin-sidebar-toggle .icon-expand { display: none; }
html.sidebar-collapsed .admin-sidebar-toggle .icon-collapse,
.admin-sidebar.is-collapsed .admin-sidebar-toggle .icon-collapse { display: none; }
html.sidebar-collapsed .admin-sidebar-toggle .icon-expand,
.admin-sidebar.is-collapsed .admin-sidebar-toggle .icon-expand { display: inline-flex; }

.admin-sidebar-search {
  padding: 0 0.65rem 0.75rem;
}
.admin-sidebar-search-trigger {
  width: 100%;
  margin: 0;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.45rem;
  appearance: none;
  border: none;
  border-radius: 10px;
  background: #303030;
  color: #8c8c8c;
  padding: 0.5rem 0.55rem 0.5rem 0.65rem;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
}
.admin-sidebar-search-trigger:hover {
  background: #3a3a3a;
  color: #b5b5b5;
}
.admin-sidebar-search-trigger .search-label {
  flex: 1;
  min-width: 0;
}
.admin-sidebar-search-trigger kbd {
  flex-shrink: 0;
  font: inherit;
  font-size: 0.6875rem;
  color: #8c8c8c;
  background: transparent;
  border: none;
  padding: 0;
}
.admin-sidebar-search {
  --s-icon-color-f4125: #8c8c8c;
  --p-color-icon-f4125: #8c8c8c;
}

.admin-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0.15rem 0.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-nav-section {
  margin-top: 0.85rem;
  padding: 0 0.55rem 0.35rem;
  font-size: 0.6875rem;
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: var(--admin-sidebar-muted);
}

.admin-nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.65rem;
  border-radius: 10px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.25;
  min-height: 36px;
}
.admin-nav a:hover {
  background: var(--admin-sidebar-hover);
  text-decoration: none;
}
.admin-nav a.active {
  background: var(--admin-sidebar-active);
  color: #fff;
}
.admin-nav a s-icon,
.admin-sidebar-toggle s-icon,
.logout-btn s-icon,
.admin-sidebar-search-trigger s-icon {
  flex-shrink: 0;
}
.admin-nav a.active {
  --s-icon-color-f4125: #fff;
  --p-color-icon-f4125: #fff;
}

.admin-sidebar-footer {
  border-top: 1px solid #2c2c2c;
  padding: 0.65rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.admin-user {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.45rem 0.55rem;
  border-radius: 8px;
  color: var(--admin-sidebar-text);
  text-decoration: none;
  font-weight: 400;
}
.admin-user:hover {
  background: var(--admin-sidebar-hover);
  text-decoration: none;
}
.admin-user .avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #5c6ac4;
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 400;
  flex-shrink: 0;
}
.admin-user .meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.admin-user .meta .name {
  font-size: 0.8125rem;
  font-weight: 400;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: #fff;
}
.admin-user .meta .email {
  font-size: 0.7rem;
  font-weight: 400;
  color: var(--admin-sidebar-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-form { margin: 0; }
.logout-btn {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  width: 100%;
  padding: 0.45rem 0.65rem;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: var(--admin-sidebar-text);
  font: inherit;
  font-size: 13px;
  font-weight: 400;
  cursor: pointer;
  text-align: left;
  min-height: 36px;
}
.logout-btn:hover { background: var(--admin-sidebar-hover); }

/* Collapsed: icon rail */
html.sidebar-collapsed .nav-label,
.admin-sidebar.is-collapsed .nav-label {
  display: none;
}
html.sidebar-collapsed .admin-sidebar-search,
.admin-sidebar.is-collapsed .admin-sidebar-search {
  display: none;
}
html.sidebar-collapsed .admin-sidebar-top,
.admin-sidebar.is-collapsed .admin-sidebar-top {
  flex-direction: column;
  padding: 0.65rem 0.35rem;
  gap: 0.35rem;
}
html.sidebar-collapsed .admin-sidebar-brand,
.admin-sidebar.is-collapsed .admin-sidebar-brand {
  justify-content: center;
  width: 100%;
}
html.sidebar-collapsed .admin-nav a,
.admin-sidebar.is-collapsed .admin-nav a,
html.sidebar-collapsed .logout-btn,
.admin-sidebar.is-collapsed .logout-btn {
  justify-content: center;
  padding: 0.55rem;
}
html.sidebar-collapsed .admin-user,
.admin-sidebar.is-collapsed .admin-user {
  justify-content: center;
  padding: 0.45rem;
}
html.sidebar-collapsed .admin-nav-section,
.admin-sidebar.is-collapsed .admin-nav-section {
  display: none;
}

.admin-main {
  flex: 1;
  min-width: 0;
  background: var(--admin-content-bg);
  padding: 0.75rem 1.25rem 2.5rem;
  border-radius: 14px;
  margin: 8px 8px 8px 0;
  overflow-x: hidden;
  overflow-y: auto;
  min-height: calc(100vh - 16px);
}

/* Table links read as dark text; underline only appears on hover */
s-table s-link,
s-table a {
  --s-link-color-f4125: #1a1a1a;
  --s-link-color-hover-f4125: #1a1a1a;
  --s-link-color-active-f4125: #1a1a1a;
  --s-global-font-weight-f4125: 550;
  color: #1a1a1a;
  font-weight: 550;
  text-decoration: none;
}

s-table a:hover {
  text-decoration: underline;
}

/* Page header with the section icon, like the Shopify Admin title bar.
   Left inset matches Polaris page-content; right inset is tighter so the
   action button lines up with the section/card right edge below. */
.admin-page-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 36px;
  padding: 0.5rem 0 0.75rem;
  margin-inline: 1rem 0.25rem;
  --s-icon-color-f4125: #1a1a1a;
  --p-color-icon-f4125: #1a1a1a;
}

.admin-page-actions {
  margin-inline-start: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.admin-page-head--in-page {
  margin-inline: 0;
  padding: 0 0 0.75rem;
}

.admin-page-head h1 {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 650;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: #1a1a1a;
}

/* Detail page lead sits outside s-page so it stays full-width in base layout */
.admin-page-lead {
  width: auto;
  margin-inline: 1rem 0.25rem;
  margin-bottom: 0.35rem;
  max-width: 100%;
  min-width: 0;
}
.admin-page-lead .admin-page-head {
  margin-inline: 0;
  padding: 0 0 0.25rem;
}
.admin-page-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 28px;
}
.admin-page-lead--bare {
  padding-bottom: 0.5rem;
}
.admin-page-lead--bare .admin-page-bar {
  min-height: 36px;
}
.admin-page-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid #c9cccf;
  text-decoration: none;
  flex-shrink: 0;
  --s-icon-color-f4125: #4a4a4a;
  --p-color-icon-f4125: #4a4a4a;
}
.admin-page-back:hover {
  background: #f6f6f7;
}
.admin-page-crumbs {
  min-width: 0;
  font-size: 0.8125rem;
}
.admin-page-crumbs a {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  color: #8a8a8a;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  --s-icon-color-f4125: #8a8a8a;
  --p-color-icon-f4125: #8a8a8a;
}
.admin-page-crumbs a:hover {
  color: #616161;
  --s-icon-color-f4125: #616161;
  --p-color-icon-f4125: #616161;
}

/* Store detail facts: label above a stronger value, Shopify-style */
.store-facts {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.15rem 1.5rem;
  margin: 0;
}
.store-fact {
  margin: 0;
  min-width: 0;
}
.store-fact dt {
  margin: 0 0 0.2rem;
  font-size: 0.8125rem;
  font-weight: 450;
  line-height: 1.3;
  color: #8a8a8a;
}
.store-fact dd {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 550;
  line-height: 1.35;
  color: #1a1a1a;
  word-break: break-word;
}
.store-fact-inline {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
}
.store-fact dd .store-fact-meta {
  margin-inline-start: 0.4rem;
  font-size: 0.8125rem;
  font-weight: 450;
  color: #8a8a8a;
}
@media (max-width: 640px) {
  .store-facts { grid-template-columns: 1fr; }
}

.partner-profile-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 640px) {
  .partner-profile-grid {
    grid-template-columns: 1fr;
  }
}

/* Shopify Admin–style toast (bottom center) */
.admin-toast {
  position: fixed;
  left: 50%;
  bottom: 1.25rem;
  z-index: 1000;
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  max-width: min(480px, calc(100vw - 2rem));
  padding: 0.75rem 0.75rem 0.75rem 1rem;
  border-radius: 8px;
  background: #1a1a1a;
  color: #fff;
  --s-icon-color-f4125: #b5b5b5;
  --p-color-icon-f4125: #b5b5b5;
  font-size: 13px;
  font-weight: 400;
  line-height: 1.4;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28);
  transform: translate(-50%, 12px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  pointer-events: auto;
}
.admin-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}
.admin-toast.is-hiding {
  opacity: 0;
  transform: translate(-50%, 8px);
}
.admin-toast-msg {
  flex: 1;
  min-width: 0;
  padding-top: 0.1rem;
}
.admin-toast-close {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin: -0.15rem -0.15rem -0.15rem 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #b5b5b5;
  cursor: pointer;
  padding: 0;
}
.admin-toast-close:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
}
.admin-toast--success {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), inset 3px 0 0 #29845a;
}
.admin-toast--critical {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), inset 3px 0 0 #e51c00;
}
.admin-toast--warning {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), inset 3px 0 0 #b98900;
}
.admin-toast--info {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.28), inset 3px 0 0 #005bd3;
}

.status-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.token-warn-icon {
  display: inline-flex;
  align-items: center;
  --s-icon-color-f4125: #b98900;
}
.token-warn-form {
  margin: 0 0 1rem;
}
.plan-cell {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}
.plan-refresh-form {
  margin: 0;
  display: inline-flex;
}
.plan-refresh-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: #616161;
  cursor: pointer;
}
.plan-refresh-btn:hover {
  background: #f1f1f1;
  color: #303030;
}

.invoice-send-form {
  margin: 0;
  display: inline-flex;
}

/* Table action column always sits flush right */
.row-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
}

/* Chart cards sitting directly on the page background */
.chart-card {
  background: #fff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(26, 26, 26, 0.07);
  padding: 1rem 1rem 0.75rem;
  height: 100%;
}
.chart-card-title {
  margin: 0 0 0.25rem;
  font-size: 0.8125rem;
  font-weight: 450;
  color: #616161;
}
.chart-card-value {
  margin: 0 0 0.75rem;
  font-size: 1.375rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  color: #1a1a1a;
}
.chart-card-value + .chart-card-note {
  margin-top: -0.5rem;
}
.chart-card-note {
  margin: 0 0 0.75rem;
  font-size: 0.75rem;
  color: #8c8c8c;
}
.chart-wrap {
  position: relative;
  width: 100%;
  height: 220px;
}
.chart-wrap--sm {
  height: 180px;
}
.chart-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Shopify Analytics–style overview figures (separate cards on page bg) */
.stats-overview {
  margin: 0 0 1.25rem;
}
.stats-overview-heading {
  margin: 0 0 0.75rem;
  padding: 0 0.15rem;
  font-size: 0.8125rem;
  font-weight: 650;
  letter-spacing: 0.01em;
  color: #303030;
}
.metric-grid,
.overview-grid {
  display: grid;
  grid-template-columns: repeat(1, minmax(0, 1fr));
  gap: 0.75rem;
}
@media (min-width: 640px) {
  .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .overview-grid--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .metric-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
.metric-figure {
  display: flex;
  flex-direction: column;
  gap: 0;
  margin: 0;
  background: #fff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  padding: 1rem 1rem 0.65rem;
  min-height: 0;
  box-shadow: 0 1px 2px rgba(26, 26, 26, 0.07);
}
.metric-figure-title {
  margin: 0 0 0.35rem;
  font-size: 0.8125rem;
  font-weight: 450;
  line-height: 1.3;
  color: #616161;
}
.metric-figure-value {
  margin: 0 0 0.85rem;
  font-size: 1.5rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.15;
  color: #1a1a1a;
}
.metric-figure-chart {
  position: relative;
  width: 100%;
  height: 72px;
  margin-top: auto;
}
.metric-figure-chart canvas {
  width: 100% !important;
  height: 100% !important;
}

/* Command palette (Ctrl/Cmd+K) */
.command-palette[hidden] { display: none !important; }
.command-palette {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 1rem 1rem;
}
.command-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.command-palette-dialog {
  position: relative;
  width: min(560px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: min(420px, 70vh);
}
.command-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--admin-border);
  --s-icon-color-f4125: #8c8c8c;
  --p-color-icon-f4125: #8c8c8c;
}
.command-palette-input-wrap input {
  flex: 1;
  border: none;
  outline: none;
  font: inherit;
  font-size: 0.9375rem;
  color: #1a1a1a;
  background: transparent;
}
.command-palette-input-wrap input::placeholder { color: #8c8c8c; }
.command-palette-list {
  list-style: none;
  margin: 0;
  padding: 0.35rem;
  overflow-y: auto;
}
.command-palette-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.75rem;
  border-radius: 10px;
  cursor: pointer;
}
.command-palette-item.is-active,
.command-palette-item:hover {
  background: #f1f1f1;
}
.command-palette-item-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.command-palette-item-title {
  font-size: 0.875rem;
  color: #1a1a1a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.command-palette-item-sub {
  font-size: 0.75rem;
  color: #8a8a8a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.command-palette-item-type {
  flex-shrink: 0;
  font-size: 0.6875rem;
  color: #8a8a8a;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.command-palette-empty {
  padding: 1.25rem 0.75rem;
  text-align: center;
  color: #8a8a8a;
  font-size: 0.875rem;
}
.command-palette-hint {
  border-top: 1px solid var(--admin-border);
  padding: 0.5rem 1rem;
  font-size: 0.6875rem;
  color: #8a8a8a;
  display: flex;
  gap: 0.75rem;
}
.command-palette-hint kbd {
  font: inherit;
  background: #f1f1f1;
  border-radius: 4px;
  padding: 0.1rem 0.35rem;
}

.snippet-box {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.8rem;
  background: #1a1a1a;
  color: #e3e3e3;
  padding: 1rem;
  border-radius: 8px;
  max-width: 100%;
  min-width: 0;
  overflow-x: hidden;
  overflow-wrap: anywhere;
  word-break: break-all;
  white-space: pre-wrap;
  margin: 0;
}

/* —— Auth (Shopify login style) —— */
.auth-page {
  min-height: 100vh;
  background: #1a1a1a;
  display: flex;
  flex-direction: column;
  position: relative;
}
.auth-page-logo {
  position: absolute;
  top: 1.25rem;
  left: 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 400;
  font-size: 1.05rem;
}
.auth-page-logo:hover { text-decoration: none; opacity: 0.9; }
.auth-page-logo img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
}
.auth-page-center {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4rem 1rem 2rem;
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: #fff;
  border-radius: 16px;
  padding: 1.75rem 1.5rem 1.5rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}
.auth-card h1 {
  margin: 0 0 0.25rem;
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 20px;
  color: #1a1a1a;
}
.auth-card .auth-sub {
  margin: 0 0 1.25rem;
  color: #616161;
  font-size: 13px;
  line-height: 20px;
}
.auth-messages {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}
.auth-alt-link {
  display: block;
  text-align: center;
  color: #1a1a1a;
  text-decoration: none;
  font-size: 0.875rem;
}
.auth-alt-link:hover {
  color: #1a1a1a;
  text-decoration: underline;
}

.table-link-row { cursor: pointer; }
.table-link-row:hover { background: #f7f7f7; }

/* —— Admin mobile bar + drawer (hidden on desktop) —— */
.admin-mobile-bar,
.admin-drawer {
  display: none;
}

.invoice-table-mobile {
  display: none;
}

.admin-mobile-bar {
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.5rem 0.65rem;
  min-height: 52px;
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  --s-icon-color-f4125: var(--admin-sidebar-text);
  --p-color-icon-f4125: var(--admin-sidebar-text);
}

.admin-mobile-bar-menu,
.admin-mobile-bar-logout-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--admin-sidebar-text);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.admin-mobile-bar-menu:hover,
.admin-mobile-bar-logout-btn:hover {
  background: var(--admin-sidebar-hover);
}

.admin-mobile-bar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 0;
  color: #fff;
  text-decoration: none;
  font-size: 0.9375rem;
  font-weight: 400;
}

.admin-mobile-bar-brand:hover {
  text-decoration: none;
  opacity: 0.92;
}

.admin-mobile-bar-brand img {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  display: block;
}

.admin-mobile-bar-logout {
  margin: 0;
  flex-shrink: 0;
}

.admin-drawer {
  position: fixed;
  inset: 0;
  z-index: 1200;
  pointer-events: none;
}

.admin-drawer.is-open {
  pointer-events: auto;
}

.admin-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  opacity: 0;
  transition: opacity 0.22s ease;
}

.admin-drawer.is-open .admin-drawer-backdrop {
  opacity: 1;
}

.admin-drawer-panel {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: min(280px, 88vw);
  max-width: 100%;
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  --s-icon-color-f4125: var(--admin-sidebar-text);
  --p-color-icon-f4125: var(--admin-sidebar-text);
  --p-color-icon-secondary-f4125: var(--admin-sidebar-muted);
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.22s ease;
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}

.admin-drawer.is-open .admin-drawer-panel {
  transform: translateX(0);
}

.admin-drawer-header {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.65rem 0.65rem 0.35rem;
  flex-shrink: 0;
}

.admin-drawer-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--admin-sidebar-text);
  cursor: pointer;
  padding: 0;
}

.admin-drawer-close:hover {
  background: var(--admin-sidebar-hover);
}

.admin-drawer-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
}

.admin-drawer-scroll .admin-nav {
  flex: 1;
}

@media (max-width: 860px) {
  .admin-frame {
    flex-direction: column;
  }

  .admin-mobile-bar {
    display: flex;
  }

  .admin-drawer {
    display: block;
  }

  .admin-sidebar {
    display: none !important;
  }

  .admin-main {
    margin: 0 8px 8px;
  }

  .invoice-table-desktop {
    display: none;
  }

  .invoice-table-mobile {
    display: block;
  }

  .invoice-mobile-card {
    padding: 0.85rem 0;
    border-bottom: 1px solid var(--admin-border);
  }

  .invoice-mobile-card:last-child {
    border-bottom: none;
  }

  .invoice-mobile-card-partner {
    font-size: 0.9375rem;
    font-weight: 600;
    margin-bottom: 0.65rem;
  }

  .invoice-mobile-card-partner a {
    color: #303030;
    text-decoration: none;
  }

  .invoice-mobile-card-partner a:hover {
    text-decoration: underline;
  }

  .invoice-mobile-fields {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(5.5rem, 34%) 1fr;
    gap: 0.45rem 0.75rem;
  }

  .invoice-mobile-field {
    display: contents;
  }

  .invoice-mobile-field dt {
    margin: 0;
    font-size: 0.8125rem;
    color: #616161;
    font-weight: 400;
  }

  .invoice-mobile-field dd {
    margin: 0;
    font-size: 0.875rem;
    color: #303030;
    min-width: 0;
  }

  .invoice-mobile-field--stacked {
    display: block;
    grid-column: 1 / -1;
    margin-top: 0.15rem;
  }

  .invoice-mobile-field--stacked dt {
    display: block;
    margin-bottom: 0.35rem;
  }

  .invoice-mobile-field--stacked dd {
    display: block;
    width: 100%;
  }

  .invoice-mobile-badge {
    display: inline-block;
    max-width: 100%;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-size: 0.75rem;
    line-height: 1.35;
    white-space: normal;
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  .invoice-mobile-badge--success {
    background: #cdfee1;
    color: #0c5132;
  }

  .invoice-mobile-badge--info {
    background: #d5ebff;
    color: #003a5a;
  }

  .invoice-mobile-badge--warning {
    background: #ffef9d;
    color: #4f4700;
  }

  .admin-row-actions--invoice {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    max-width: 100%;
  }

  .admin-row-actions--invoice form {
    margin: 0;
  }
}

/* Modal shell (Shopify Admin-style), shared by the invoice and details modals */
.invoice-modal[hidden],
.app-modal[hidden] { display: none !important; }
.invoice-modal,
.app-modal {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.invoice-modal-backdrop,
.app-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.invoice-modal-dialog,
.app-modal-dialog {
  position: relative;
  width: min(480px, 100%);
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.app-modal-dialog--wide {
  width: min(680px, 100%);
  max-height: min(80vh, 720px);
}
.invoice-modal-header,
.app-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--admin-border);
}
.invoice-modal-title,
.app-modal-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: #1a1a1a;
}
.invoice-modal-close,
.app-modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 8px;
  background: transparent;
  color: #616161;
  cursor: pointer;
  padding: 0;
}
.invoice-modal-close:hover,
.app-modal-close:hover {
  background: #f1f1f1;
  color: #303030;
}
.invoice-modal-body,
.app-modal-body {
  padding: 1.25rem;
}
.app-modal-body {
  overflow-y: auto;
}
body.app-modal-open {
  overflow: hidden;
}
.invoice-modal-dropzone {
  border: 2px dashed #c9cccf;
  border-radius: 10px;
  padding: 2rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.invoice-modal-dropzone:hover,
.invoice-modal-dropzone.is-dragover {
  border-color: #005bd3;
  background: #f0f5ff;
}
.invoice-modal-dropzone.has-file {
  border-color: #29845a;
  background: #f0fff4;
}
.invoice-modal-dropzone-icon {
  display: flex;
  justify-content: center;
  margin-bottom: 0.75rem;
  --s-icon-color-f4125: #8c8c8c;
  --p-color-icon-f4125: #8c8c8c;
}
.invoice-modal-dropzone.has-file .invoice-modal-dropzone-icon {
  --s-icon-color-f4125: #29845a;
  --p-color-icon-f4125: #29845a;
}
.invoice-modal-dropzone-text {
  font-size: 0.875rem;
  color: #616161;
  margin-bottom: 0.5rem;
}
.invoice-modal-dropzone-hint {
  font-size: 0.75rem;
  color: #8c8c8c;
}
.invoice-modal-dropzone-filename {
  font-size: 0.875rem;
  font-weight: 500;
  color: #1a1a1a;
  margin-top: 0.5rem;
  word-break: break-word;
}
.invoice-modal-input {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.invoice-modal-footer,
.app-modal-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--admin-border);
  background: #fafafa;
}

/* Billing period breakdown */
s-table-row[data-period-row] { cursor: pointer; }
s-table-row[data-period-row]:hover {
  --p-color-bg-surface-f4125: #f7f7f7;
}
/* Let the breakdown table run edge to edge inside the dialog. */
.app-modal-body--flush { padding: 0; }
.period-details s-table-cell:last-child {
  text-align: right;
}
.period-details-amount {
  display: block;
  width: 100%;
  margin-left: auto;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.period-details-total,
.period-details-total .period-details-amount {
  font-weight: 600;
}

/* Info cards (Shopify Admin-style) */
.billing-info-grid {
  margin-bottom: 1.25rem;
  align-items: stretch;
}
.billing-info-card {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 1.15rem 1.15rem 1rem;
}

.verify-page-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  --s-icon-color-f4125: #1a1a1a;
  --p-color-icon-f4125: #1a1a1a;
}
.verify-page-title .section-card-title {
  margin: 0;
}
.verify-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.verify-card-actions form {
  margin: 0;
}
.verify-card {
  max-width: 100%;
  min-width: 0;
}
.verify-card .billing-info-card-body {
  min-width: 0;
}
.verify-card .billing-info-card-body p {
  margin: 0;
}
.verify-card .billing-info-card-body .verify-steps {
  margin: 0;
  padding-left: 1.25rem;
  font-size: 0.875rem;
  line-height: 1.55;
  color: #303030;
}
.verify-card .billing-info-card-body .verify-steps li + li {
  margin-top: 0.45rem;
}
.verify-card .billing-info-card-body .snippet-box {
  margin: 0.75rem 0 0;
}
.billing-info-card-title,
.section-card-title {
  margin: 0 0 0.5rem;
  /* Match dashboard CTA / Polaris section heading scale */
  font-size: 16px;
  font-weight: 650;
  letter-spacing: -0.02em;
  line-height: 20px;
  color: #1a1a1a;
}

.affiliate-cta-media {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  width: 100%;
  min-width: 0;
}
.affiliate-cta-img {
  display: block;
  max-height: 250px;
  width: auto;
  max-width: 100%;
  height: auto;
  object-fit: contain;
  margin-left: auto;
}
@media (max-width: 700px) {
  .affiliate-cta-media {
    justify-content: center;
  }
  .affiliate-cta-img {
    margin-left: 0;
  }
}

.billing-info-card-body {
  flex: 1;
  /* Match Polaris s-paragraph color="subdued" used on the dashboard CTA */
  font-size: 13px;
  line-height: 20px;
  font-weight: 400;
  color: #4a4a4a;
}
.billing-info-card-body a {
  color: #005bd3;
  text-decoration: none;
}
.billing-info-card-body a:hover {
  text-decoration: underline;
}
.billing-info-card-footer {
  margin-top: 1rem;
}
.info-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
  margin-bottom: 1.25rem;
}
@media (max-width: 700px) {
  .info-cards {
    grid-template-columns: 1fr;
  }
}
.info-card {
  background: #fff;
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(26, 26, 26, 0.07);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  min-height: 180px;
}
.info-card-title {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  font-weight: 600;
  color: #1a1a1a;
}
.info-card-body {
  flex: 1;
  font-size: 0.875rem;
  line-height: 1.6;
  color: #303030;
}
.info-card-body a {
  color: #005bd3;
  text-decoration: none;
}
.info-card-body a:hover {
  text-decoration: underline;
}
.info-card-footer {
  margin-top: 1rem;
}
.info-card-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.85rem;
  border-radius: 20px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  background: #fff;
  color: #303030;
  border: 1px solid #c9cccf;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.info-card-btn:hover {
  background: #f6f6f7;
  border-color: #8c9196;
  text-decoration: none;
}

body.admin-backoffice {
  background: #f1f1f1;
  min-height: 100vh;
}
.admin-backoffice-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1.25rem;
  background: #1a1a1a;
  color: #fff;
}
.admin-backoffice-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  color: #fff;
  text-decoration: none;
  font-weight: 650;
}
.admin-backoffice-brand img {
  width: 28px;
  height: 28px;
}
.admin-backoffice-brand:hover {
  text-decoration: none;
  color: #fff;
}
.admin-backoffice-meta {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.8125rem;
  color: #b5b5b5;
}
.admin-backoffice-meta form {
  margin: 0;
}
.admin-backoffice-main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 2.5rem;
}
.admin-row-actions,
.admin-commission-form {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}
.admin-commission-form {
  margin: 0;
}
.admin-commission-input {
  width: 5.5rem;
  height: 32px;
  padding: 0 0.5rem;
  border: 1px solid #c9cccf;
  border-radius: 8px;
  font: inherit;
  font-size: 13px;
}
