:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --border: #2d3a4f;
  --text: #e7ecf3;
  --muted: #8b9cb3;
  --pending: #f0b429;
  --running: #4dabf7;
  --completed: #51cf66;
  --failed: #ff6b6b;
  --retrying: #cc5de8;
  --reconciling: #ffa94d;
  --page-padding: clamp(1rem, 3vw, 2rem);
  --touch-min: 44px;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  min-height: 100dvh;
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
  -webkit-text-size-adjust: 100%;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem var(--page-padding);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

h1 { margin: 0; font-size: 1.5rem; }
.subtitle { margin: 0.25rem 0 0; color: var(--muted); font-size: 0.9rem; }

.connection {
  padding: 0.4rem 0.8rem;
  border-radius: 999px;
  font-size: 0.85rem;
  background: #243044;
}
.connection.connected { background: #1b4332; color: #95d5b2; }
.connection.disconnected { background: #4a1515; color: #ffb3b3; }

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.75rem;
  padding: 1.25rem var(--page-padding);
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.25rem;
  border-left: 4px solid var(--muted);
}
.stat-card.pending { border-left-color: var(--pending); }
.stat-card.running { border-left-color: var(--running); }
.stat-card.completed { border-left-color: var(--completed); }
.stat-card.failed { border-left-color: var(--failed); }
.stat-card.retrying { border-left-color: var(--retrying); }
.stat-card.reconciling { border-left-color: var(--reconciling); }

.stat-card .label { display: block; color: var(--muted); font-size: 0.8rem; }
.stat-card .value { font-size: 2rem; font-weight: 700; }

.stat-card.stat-clickable {
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.stat-card.stat-clickable:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}
.stat-card.stat-clickable:focus-visible {
  outline: 2px solid var(--completed);
  outline-offset: 2px;
}

.actions, .jobs {
  padding: 0 var(--page-padding) 1.75rem;
}

.history-section {
  margin: 0 var(--page-padding) 1.5rem;
  padding: 1.25rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

h2 {
  margin: 0 0 1rem;
  font-size: clamp(1.05rem, 2.5vw, 1.2rem);
}
.actions { overflow: visible; position: relative; z-index: 20; }

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 1rem;
  align-items: end;
  overflow: visible;
}

.form-row > label, .field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.field-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.required-mark {
  color: #ff6b6b;
}

.multiselect {
  position: relative;
  min-width: 0;
  width: 100%;
  z-index: 1;
}

.multiselect:has(.multiselect-menu:not(.hidden)) {
  z-index: 100;
}

.multiselect-toggle {
  width: 100%;
  text-align: left;
  background: #121a26;
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.multiselect-toggle:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.multiselect-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  z-index: 50;
  min-width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.5rem;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
}

.multiselect-search {
  width: 100%;
  padding: 0.45rem 0.6rem;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.multiselect-options {
  max-height: 220px;
  overflow: auto;
}

.multiselect-toolbar {
  display: flex;
  gap: 0.35rem;
  flex-shrink: 0;
}

.multiselect-toolbar.hidden {
  display: none;
}

.multiselect-toolbar button {
  flex: 1;
  padding: 0.35rem 0.5rem;
  font-size: 0.78rem;
  background: #243044;
  border-color: var(--border);
  font-weight: 500;
}

.multiselect-toolbar button:hover {
  background: #334155;
}

.multiselect-empty {
  padding: 0.75rem 0.5rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.85rem;
}

.multiselect-empty.hidden {
  display: none;
}

.multiselect-menu label.hidden {
  display: none;
}

.multiselect-menu.hidden {
  display: none;
}

.multiselect-menu label {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.35rem;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}

.multiselect-menu label:hover {
  background: #243044;
}

.multiselect-menu input {
  width: auto;
  margin: 0;
}

input, select, button {
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #121a26;
  color: var(--text);
  font-size: 0.9rem;
}

button {
  cursor: pointer;
  background: #2563eb;
  border-color: #2563eb;
  font-weight: 600;
}
button:hover { background: #1d4ed8; }
button.secondary { background: #334155; border-color: #475569; }
button.danger { background: #7f1d1d; border-color: #991b1b; }
button.danger:hover { background: #991b1b; }

.sync-batch-summary {
  margin: 0 var(--page-padding) 1rem;
  padding: 1rem 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-left: 4px solid var(--running);
  border-radius: 12px;
}

.sync-batch-summary.hidden {
  display: none;
}

.sync-batch-summary.batch-running-pulse {
  border-left-color: var(--running);
  animation: batch-pulse 2s ease-in-out infinite;
}

.sync-batch-summary.batch-complete {
  border-left-color: var(--completed);
}

@keyframes batch-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, 0); }
  50% { box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.15); }
}

.sync-batch-summary .batch-progress-wrap {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.sync-batch-summary .batch-progress-track {
  flex: 1;
  height: 8px;
  background: #121a26;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.sync-batch-summary .batch-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #2563eb, #22c55e);
  border-radius: 999px;
  transition: width 0.4s ease;
}

.sync-batch-summary .batch-progress-label {
  font-size: 0.78rem;
  color: var(--muted);
  min-width: 2.5rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sync-batch-summary .batch-count-card.hidden {
  display: none;
}

#sync-form button.loading {
  opacity: 0.85;
  cursor: wait;
}

.sync-batch-summary .batch-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.sync-batch-summary h3 {
  margin: 0;
  font-size: 0.95rem;
}

.sync-batch-summary .batch-mode {
  font-size: 0.75rem;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  background: #243044;
  color: var(--muted);
}

.sync-batch-summary .batch-hero {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 0.85rem;
  margin-bottom: 0.85rem;
}

.sync-batch-summary .batch-hero-card {
  background: linear-gradient(145deg, #141f2e 0%, #0f1620 100%);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 1rem 1.1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.sync-batch-summary .batch-hero-card.orders {
  border-color: #2f6f44;
}

.sync-batch-summary .batch-hero-card.time {
  border-color: #2563eb;
}

.sync-batch-summary .batch-hero-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.sync-batch-summary .batch-hero-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

.sync-batch-summary .batch-hero-sub {
  font-size: 0.8rem;
  color: var(--muted);
}

.sync-batch-summary .batch-count-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.75rem;
}

.sync-batch-summary .batch-count-card {
  background: #121a26;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.75rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.sync-batch-summary .batch-count-card.ok {
  border-color: #2f6f44;
}

.sync-batch-summary .batch-count-card.mismatch {
  border-color: #8b3a3a;
}

.sync-batch-summary .batch-count-card.highlight {
  border-color: #2563eb;
}

.sync-batch-summary .batch-count-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.sync-batch-summary .batch-count-value {
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.2;
}

.sync-batch-summary .batch-count-sub {
  font-size: 0.78rem;
  color: var(--muted);
}

.sync-batch-summary .batch-count-sub.mismatch {
  color: var(--failed);
}

.sync-batch-summary .batch-warn {
  color: var(--reconciling);
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.sync-batch-summary .batch-ok {
  color: var(--completed);
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.sync-batch-summary .batch-running {
  color: var(--muted);
  margin-top: 0.75rem;
  font-size: 0.85rem;
}

.sync-batch-summary .batch-mismatch-stores {
  margin: 0.5rem 0 0 1.1rem;
  padding: 0;
  font-size: 0.82rem;
}

.sync-batch-summary .batch-mismatch-stores li {
  margin: 0.2rem 0;
}

.count-pair {
  font-size: 0.82rem;
  white-space: nowrap;
}

.count-pair .count-label {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.count-pair .count-sep {
  color: var(--muted);
  margin: 0 0.15rem;
}

.count-pair.ok {
  color: var(--completed);
}

.count-pair.mismatch {
  color: var(--reconciling);
}

.count-pair.detail .count-label {
  margin-right: 0.25rem;
}

.duration-live {
  color: var(--running);
}

#sync-form button[type="submit"] {
  width: 100%;
  min-height: var(--touch-min);
}

.filter-divider {
  display: none;
}

.jobs-filters {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.jobs-filter-group {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  min-width: 0;
  flex: 1 1 auto;
}

.jobs-filter-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.filters-scope,
.filters-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
  width: 100%;
}

.filters button {
  background: transparent;
  border-color: var(--border);
  margin-left: 0;
  padding: 0.4rem 0.75rem;
  flex: 0 0 auto;
  white-space: nowrap;
  min-height: 2.25rem;
}

.jobs-filter-group-search {
  flex: 1 1 100%;
}

.jobs-filter-group-search .jobs-search-wrap {
  width: 100%;
  margin: 0;
}

.jobs-filter-group-search .jobs-search-status {
  min-height: 1.1rem;
  line-height: 1.35;
}

.jobs-filter-hint {
  flex: 1 1 100%;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.jobs-filter-hint strong {
  color: #cbd5e1;
  font-weight: 600;
}

.filters button.active { background: #2563eb; border-color: #2563eb; }

.jobs-search-wrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.35rem;
  box-sizing: border-box;
  width: 100%;
  min-height: 2.5rem;
  position: relative;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.2rem 0.5rem 0.2rem 0.65rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.jobs-search-wrap:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}

.jobs-search-wrap.has-query {
  border-color: #2563eb;
}

.jobs-search-wrap.is-loading {
  opacity: 0.92;
}

.jobs-search-icon {
  display: flex;
  align-items: center;
  color: var(--muted);
  flex-shrink: 0;
}

.jobs-search-wrap input[type="search"] {
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  height: auto;
  min-height: 0;
  margin: 0;
  padding: 0.45rem 0.25rem;
  border: none;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.3;
  box-shadow: none;
}

.jobs-search-wrap input[type="search"]:focus {
  outline: none;
}

.jobs-search-wrap input[type="search"]::-webkit-search-cancel-button {
  display: none;
}

.jobs-search-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid rgba(148, 163, 184, 0.35);
  border-top-color: #2563eb;
  border-radius: 50%;
  flex-shrink: 0;
  opacity: 0;
  animation: none;
}

.jobs-search-wrap.is-loading .jobs-search-spinner {
  opacity: 1;
  animation: search-spin 0.7s linear infinite;
}

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

.jobs-search-wrap #jobs-search-clear {
  flex: 0 0 auto;
  min-height: 1.75rem;
  min-width: 1.75rem;
  padding: 0;
  border-radius: 999px;
  line-height: 1;
  font-size: 1rem;
}

.jobs-search-wrap #jobs-search-clear.hidden {
  display: none;
}

.jobs-search-status {
  font-size: 0.82rem;
  color: var(--muted);
  min-height: 1.1rem;
}

.jobs-search-status.has-results {
  color: #93c5fd;
}

.jobs-search-status.is-loading {
  color: #94a3b8;
}

.jobs-search-hint {
  font-size: 0.78rem;
}

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

.jobs-search-hint {
  font-size: 0.78rem;
  flex: 0 1 auto;
}

.hide-mobile {
  display: inline;
}

button.compact {
  padding: 0.2rem 0.45rem;
  font-size: 0.72rem;
}

.actions-cell {
  white-space: nowrap;
  display: flex;
  gap: 0.35rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.job-detail-row td {
  font-size: 0.88rem;
}

.scope-filter {
  background: #243044;
  border-color: #3d4f6a;
}

.scope-filter.active {
  background: #1e3a5f;
  border-color: #2563eb;
}

.jobs-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.jobs-header h2 {
  margin-bottom: 0;
  flex: 1 1 auto;
}

#clear-all {
  flex: 0 0 auto;
  min-height: var(--touch-min);
}

.empty-row {
  text-align: center;
  color: var(--muted);
  padding: 2rem !important;
}

.table-scroll-hint {
  position: relative;
}

.table-scroll-hint::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 1.5rem;
  pointer-events: none;
  background: linear-gradient(to left, var(--surface), transparent);
  opacity: 0;
  transition: opacity 0.2s ease;
  border-radius: 0 12px 12px 0;
}

.table-scroll-hint.can-scroll::after {
  opacity: 1;
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  -webkit-overflow-scrolling: touch;
}

.jobs-pagination {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-top: 0.85rem;
  padding: 0 0.25rem;
}

.pagination-info,
.page-size-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.pagination-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.pagination-nav {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem;
  background: #121a26;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.pagination-pages {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.pagination-page,
.pagination-arrow {
  min-width: 2rem;
  height: 2rem;
  padding: 0 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 7px;
  font-size: 0.82rem;
  font-weight: 500;
  line-height: 1;
}

.pagination-page {
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted);
}

.pagination-page:hover {
  background: #243044;
  color: var(--text);
}

.pagination-page.active {
  background: #2563eb;
  border-color: #2563eb;
  color: #fff;
}

.pagination-arrow {
  padding: 0 0.55rem;
  font-size: 1rem;
}

.pagination-controls .secondary {
  padding: 0.4rem 0.75rem;
  font-size: 0.85rem;
}

.pagination-controls .secondary:disabled,
.pagination-page:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-size-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.page-size-label select {
  padding: 0.35rem 0.5rem;
  font-size: 0.85rem;
}

.multiselect-toggle.has-selection {
  border-color: #2563eb;
  color: #e2e8f0;
}

table { width: 100%; border-collapse: collapse; font-size: 0.88rem; min-width: 640px; }

.responsive-table {
  min-width: 640px;
}

th, td { padding: 0.75rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
th {
  color: var(--muted);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--surface);
  box-shadow: 0 1px 0 var(--border);
}
tr:last-child td { border-bottom: none; }

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.pending { background: #3d2e00; color: var(--pending); }
.badge.running { background: #0c2d48; color: var(--running); }
.badge.completed { background: #0f2e1a; color: var(--completed); }
.badge.failed { background: #3b1010; color: var(--failed); }
.badge.retrying { background: #2d1040; color: var(--retrying); }
.badge.reconciling { background: #3d2800; color: var(--reconciling); }

.reconcile-hint {
  font-size: 0.75rem;
  color: var(--reconciling);
  margin-left: 0.25rem;
}

.error-cell {
  max-width: 260px;
  color: #ffb3b3;
  font-size: 0.8rem;
}

.error-link {
  display: block;
  width: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: #ffb3b3;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font: inherit;
}

.error-link:hover {
  color: #ffd4d4;
  text-decoration: underline;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
}

.modal-panel {
  position: relative;
  width: min(760px, calc(100vw - 2rem));
  max-height: calc(100vh - 4rem);
  max-height: calc(100dvh - 4rem);
  margin: 2rem auto;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
}

.modal-panel-wide {
  width: min(920px, calc(100vw - 2rem));
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  margin: 0;
  font-size: 1rem;
}

.modal-close {
  border: none;
  background: transparent;
  color: var(--text);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.modal-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow: auto;
  flex: 1 1 auto;
  background: #121a26;
}

.job-modal-body {
  padding: 1rem 1.25rem 1.25rem;
  max-height: calc(100vh - 8rem);
  max-height: calc(100dvh - 8rem);
  overflow: auto;
  background: #121a26;
  flex: 1 1 auto;
}

.job-modal-meta {
  margin-bottom: 1rem;
}

.job-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 0.35rem 1rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.job-meta-grid strong {
  color: var(--text);
  font-weight: 600;
}

.job-modal-section {
  margin-bottom: 1rem;
}

.job-modal-section h4 {
  margin: 0 0 0.4rem;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.job-modal-pre {
  margin: 0;
  padding: 0.85rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: #0f1419;
  white-space: pre-wrap;
  word-break: break-word;
  font-size: 0.8rem;
  line-height: 1.45;
  color: var(--text);
  max-height: 280px;
  overflow: auto;
}

#job-modal-error {
  color: #ffd4d4;
}

#job-modal-platform {
  color: #c8e6ff;
}

.retry-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  background: #475569;
}

.swal2-popup {
  border: 1px solid var(--border) !important;
}

.breakdown-popup {
  text-align: left;
  font-size: 0.9rem;
}

.breakdown-summary {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.breakdown-summary .muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.breakdown-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.breakdown-table th,
.breakdown-table td {
  padding: 0.45rem 0.5rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.breakdown-table .num {
  text-align: right;
  font-weight: 600;
  color: var(--completed);
}

@media (min-width: 768px) {
  #clear-all {
    width: auto;
    min-height: auto;
  }

  .jobs-filters {
    flex-direction: row;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 1rem 2rem;
  }

  .jobs-filter-group {
    flex: 1 1 280px;
    max-width: 100%;
  }

  .jobs-filter-group-search {
    flex: 1 1 100%;
    order: 3;
  }

  .jobs-filter-group-search .jobs-search-wrap {
    max-width: none;
  }

  #sync-form button[type="submit"] {
    width: auto;
    min-height: auto;
  }
}

@media (max-width: 900px) {
  header {
    flex-direction: column;
    align-items: flex-start;
  }

  .stat-card .value {
    font-size: 1.5rem;
  }

  .sync-batch-summary .batch-hero-value {
    font-size: 1.5rem;
  }

  .sync-batch-summary .batch-header {
    flex-direction: column;
    align-items: flex-start;
  }

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

  th, td {
    padding: 0.55rem 0.65rem;
    font-size: 0.8rem;
  }

  .error-cell {
    max-width: none;
  }
}

@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }

  .table-scroll-hint::after {
    display: none;
  }

  .responsive-table {
    min-width: 0;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody tr {
    display: block;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--border);
  }

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

  .responsive-table tbody td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.35rem 0;
    border-bottom: none;
    min-width: 0;
    text-align: right;
  }

  .responsive-table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--muted);
    flex: 0 0 38%;
    text-align: left;
    padding-top: 0.1rem;
  }

  .responsive-table tbody td.empty-row {
    display: block;
    text-align: center;
  }

  .responsive-table tbody td.empty-row::before {
    display: none;
  }

  .responsive-table tbody td.actions-cell {
    justify-content: flex-end;
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
    margin-top: 0.35rem;
  }

  .responsive-table tbody td.actions-cell::before {
    align-self: center;
  }

  .responsive-table tbody td.error-cell {
    flex-direction: column;
    align-items: stretch;
    text-align: left;
  }

  .responsive-table tbody td.error-cell::before {
    flex: none;
  }

  .error-link {
    white-space: normal;
    text-align: left;
  }

  .modal-panel,
  .modal-panel-wide {
    width: 100%;
    max-width: none;
    height: 100%;
    max-height: none;
    margin: 0;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .modal {
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }

  .job-modal-body {
    max-height: none;
  }

  .pagination-controls {
    width: 100%;
    justify-content: space-between;
  }

  .pagination-nav {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .pagination-controls .secondary,
  .pagination-page,
  .pagination-arrow {
    min-height: var(--touch-min);
  }

  .pagination-controls .secondary {
    flex: 0 0 auto;
  }

  button,
  .multiselect-toggle {
    min-height: var(--touch-min);
  }

  button.compact {
    min-height: 2rem;
  }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  h1 {
    font-size: 1.2rem;
  }

  .subtitle {
    font-size: 0.82rem;
  }

  .connection {
    width: 100%;
    text-align: center;
  }

  .stat-card {
    padding: 0.75rem 0.9rem;
  }

  .stat-card .value {
    font-size: 1.35rem;
  }

  .sync-batch-summary {
    padding: 0.85rem 1rem;
  }

  .history-section {
    padding: 1rem;
  }
}

.history-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  flex-wrap: wrap;
}

.history-header h2 {
  margin: 0;
  font-size: clamp(1.05rem, 2.5vw, 1.15rem);
}

.history-table .platform-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  justify-content: flex-end;
}

.history-table .platform-badge {
  display: inline-block;
  padding: 0.12rem 0.45rem;
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 600;
  background: #243044;
  color: var(--text);
  text-transform: uppercase;
}

.history-status {
  display: inline-block;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
}

.history-status.complete { background: #1b4332; color: #95d5b2; }
.history-status.running { background: #1c3d5a; color: #74c0fc; }
.history-status.failed { background: #4a1515; color: #ffb3b3; }
.history-status.mismatch { background: #3d2a14; color: #ffc078; }

.history-pagination {
  margin-top: 0.75rem;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.batch-stores-wrap {
  margin-top: 1rem;
  max-height: 50vh;
  overflow: auto;
}