:root {
  --canvas: #eef3f8;
  --paper: #ffffff;
  --paper-soft: #f7fafc;
  --ink: #071a2f;
  --muted: #617287;
  --line: #d8e2ec;
  --menu: #ffffff;
  --menu-raised: #f5f7fa;
  --menu-hover: #eef3f8;
  --menu-text: #333942;
  --menu-muted: #687789;
  --accent: #c8102e;
  --accent-strong: #a90722;
  --accent-soft: #fff1f4;
  --teal: #0e7468;
  --blue: #0057b8;
  --blue-deep: #071f49;
  --red: #c8102e;
  --green: #4f8a10;
  --amber: #a66d08;
  --shadow-soft: 0 18px 42px rgba(7, 26, 47, 0.1);
  --shadow-menu: 0 22px 44px rgba(3, 13, 30, 0.42);
}

* {
  box-sizing: border-box;
}

html {
  height: 100%;
  font-size: 14px;
}

body {
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  background: var(--canvas);
  font-size: 13px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

.app-shell {
  width: 100vw;
  height: 100dvh;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 76px minmax(0, 1fr);
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(232, 239, 247, 0.9)),
    repeating-linear-gradient(135deg, rgba(0, 87, 184, 0.034) 0 1px, transparent 1px 16px);
}

.left-menu {
  position: relative;
  z-index: 30;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(168px, 200px) minmax(190px, 230px) minmax(0, 1fr) minmax(160px, 190px);
  align-items: center;
  gap: 12px;
  padding: 0 18px;
  overflow: visible;
  color: var(--menu-text);
  background: var(--menu);
  border-right: 0;
  border-bottom: 1px solid var(--line);
  box-shadow: 0 8px 22px rgba(7, 26, 47, 0.06);
}

.brand-lockup {
  min-width: 0;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.brand-logo-frame {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.brand-logo-frame img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.brand-copy {
  min-width: 0;
}

.brand-copy small,
.brand-copy strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.brand-copy small {
  color: var(--accent);
  font-size: 0.66rem;
  font-weight: 760;
  text-transform: uppercase;
}

.brand-copy strong {
  margin-top: 3px;
  font-size: 1rem;
  font-weight: 780;
}

.source-picker {
  position: relative;
  z-index: 20;
}

.source-trigger {
  width: 100%;
  min-height: 48px;
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 18px;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  color: var(--menu-text);
  background: var(--menu-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  text-align: left;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.source-trigger:hover,
.source-picker.open .source-trigger {
  border-color: rgba(200, 16, 46, 0.26);
  background: var(--menu-hover);
}

.source-trigger:active {
  transform: translateY(1px);
}

.source-mark,
.menu-icon,
.row-icon {
  display: grid;
  place-items: center;
  color: #ffffff;
  background: var(--accent);
  font-weight: 760;
  letter-spacing: 0;
}

.source-mark,
.menu-icon {
  background: var(--accent);
}

.source-mark {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  font-size: 0.68rem;
}

.source-trigger-copy {
  min-width: 0;
}

.source-trigger small,
.source-trigger strong,
.menu-footer strong,
.menu-footer small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-trigger small {
  color: var(--menu-muted);
  font-size: 0.66rem;
  font-weight: 680;
  text-transform: uppercase;
}

.source-trigger strong {
  margin-top: 2px;
  font-size: 0.88rem;
  font-weight: 700;
}

.chevron {
  width: 9px;
  height: 9px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  opacity: 0.72;
  transform: rotate(45deg);
  transition: transform 180ms ease;
}

.source-picker.open .chevron {
  transform: rotate(225deg) translate(-2px, -2px);
}

.source-menu {
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  right: 0;
  display: none;
  gap: 4px;
  padding: 7px;
  overflow: hidden;
  background: var(--menu-raised);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
}

.source-picker.open .source-menu {
  display: grid;
  animation: menu-in 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.source-option {
  min-height: 42px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 18px;
  align-items: center;
  gap: 8px;
  padding: 8px;
  border-radius: 6px;
  color: var(--menu-text);
  background: transparent;
  text-align: left;
  animation: row-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(80ms + var(--row-index, 0) * 60ms);
}

.source-option:hover,
.source-option.selected,
.menu-item:hover {
  background: var(--menu-hover);
}

.source-option.selected,
.menu-item.active {
  box-shadow: inset 0 -3px 0 var(--accent);
}

.menu-item.active {
  color: #ffffff;
  background: var(--accent);
  box-shadow: none;
}

.menu-item.active .menu-icon,
.menu-item.active .menu-badge {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
}

.source-option strong,
.source-option small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.source-option small {
  margin-top: 2px;
  color: var(--menu-muted);
  font-size: 0.7rem;
}

.check-mark {
  width: 13px;
  height: 8px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  transform: rotate(-45deg);
}

.menu-list {
  min-height: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
}

.menu-item {
  --menu-row-index: 0;
  min-height: 76px;
  display: grid;
  grid-template-columns: minmax(0, auto) auto;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
  padding: 0 11px;
  border-radius: 0;
  color: var(--menu-text);
  background: transparent;
  text-align: left;
  animation: row-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(80ms + var(--menu-row-index) * 55ms);
  transition: background 160ms ease, box-shadow 160ms ease, transform 160ms ease;
}

.menu-item:active {
  transform: translateY(1px);
}

.menu-icon {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  font-size: 0.68rem;
  display: none;
}

.menu-item span:not(.menu-icon):not(.menu-badge) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.78rem;
  font-weight: 660;
}

.menu-badge {
  min-width: 22px;
  height: 20px;
  display: inline-grid;
  place-items: center;
  padding: 0 6px;
  border-radius: 999px;
  color: #ffffff;
  background: var(--accent);
  font-size: 0.6rem;
  font-weight: 760;
  font-variant-numeric: tabular-nums;
}

.left-menu > .menu-list .menu-badge {
  display: none;
}

.menu-footer {
  min-height: 48px;
  display: grid;
  grid-template-columns: 12px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--menu-raised);
}

.menu-footer strong {
  font-size: 0.8rem;
  font-weight: 680;
}

.menu-footer small {
  margin-top: 2px;
  color: var(--menu-muted);
  font-size: 0.68rem;
}

.sync-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(200, 16, 46, 0.12);
}

.sync-dot.ready {
  background: var(--green);
  box-shadow: 0 0 0 5px rgba(79, 138, 16, 0.13);
}

.sync-dot.warning {
  background: var(--red);
  box-shadow: 0 0 0 5px rgba(200, 16, 46, 0.13);
}

.main-stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 12px;
  overflow: hidden;
  padding: 20px 24px 24px;
}

.stage-header {
  position: relative;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(300px, 0.82fr) minmax(390px, 1fr);
  align-items: start;
  gap: 0;
  overflow: hidden;
  padding: 0;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.stage-header::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: linear-gradient(180deg, var(--blue) 0 42%, #ffffff 42% 54%, var(--accent) 54% 100%);
}

.stage-title {
  position: relative;
  min-width: 0;
  min-height: 152px;
  display: grid;
  align-content: center;
  padding: 20px 24px;
  color: #ffffff;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.08) 0 22%, transparent 22% 44%, rgba(7, 26, 47, 0.1) 44% 66%, transparent 66%),
    var(--accent);
}

.stage-brand-strip {
  display: inline-grid;
  grid-template-columns: 38px minmax(0, auto);
  align-items: center;
  gap: 9px;
  max-width: 100%;
  margin-bottom: 11px;
  padding: 5px 9px 5px 5px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(0, 87, 184, 0.14);
  border-radius: 8px;
}

.stage-brand-strip img {
  width: 38px;
  height: 38px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 7px;
}

.stage-brand-strip span {
  min-width: 0;
}

.stage-brand-strip small,
.stage-brand-strip strong {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.stage-brand-strip small {
  color: var(--accent);
  font-size: 0.62rem;
  font-weight: 760;
  text-transform: uppercase;
}

.stage-brand-strip strong {
  margin-top: 1px;
  font-size: 0.84rem;
  font-weight: 760;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--blue);
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
  letter-spacing: 0;
}

h1 {
  margin-bottom: 6px;
  font-size: clamp(1.55rem, 1.2rem + 1.05vw, 2.35rem);
  font-weight: 760;
  line-height: 1.08;
}

h2 {
  margin-bottom: 0;
  font-size: 0.92rem;
  font-weight: 680;
  line-height: 1.28;
}

h3 {
  margin-bottom: 4px;
  font-size: 0.86rem;
  font-weight: 680;
}

.stage-title p:not(.eyebrow) {
  max-width: 720px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.84rem;
  line-height: 1.45;
}

.stage-title .eyebrow {
  color: rgba(255, 255, 255, 0.88);
}

.toolbar {
  position: relative;
  display: grid;
  grid-template-columns: minmax(140px, 180px) minmax(210px, 1fr) auto;
  align-items: end;
  justify-content: stretch;
  gap: 9px;
  max-width: none;
  min-height: 152px;
  align-content: center;
  padding: 20px 24px;
  background: #ffffff;
}

.toolbar label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 680;
  text-transform: uppercase;
}

.toolbar input,
.toolbar select {
  width: 100%;
  min-height: 38px;
  padding: 0 10px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.toolbar input:focus,
.toolbar select:focus {
  border-color: rgba(0, 87, 184, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 87, 184, 0.1);
}

.primary-action {
  min-height: 38px;
  display: inline-grid;
  grid-template-columns: 18px auto;
  align-items: center;
  gap: 8px;
  min-width: 132px;
  padding: 0 14px;
  color: #ffffff;
  background: linear-gradient(180deg, #df1637, var(--accent));
  border-radius: 8px;
  font-size: 0.84rem;
  font-weight: 720;
  box-shadow: 0 12px 24px rgba(200, 16, 46, 0.22);
  transition: transform 160ms ease, box-shadow 160ms ease, filter 160ms ease;
}

.primary-action span:last-child {
  white-space: nowrap;
}

.primary-action:hover {
  filter: brightness(0.98);
  transform: translateY(-1px);
  box-shadow: 0 16px 30px rgba(200, 16, 46, 0.28);
}

.primary-action:disabled {
  cursor: wait;
  filter: saturate(0.72);
  opacity: 0.82;
}

.primary-action:active {
  transform: translateY(0);
}

.button-icon {
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-top-color: transparent;
  border-radius: 999px;
}

.primary-action.loading .button-icon {
  animation: spin 760ms linear infinite;
}

.refresh-status {
  grid-column: 1 / -1;
  max-width: 520px;
  color: var(--muted);
  font-size: 0.68rem;
  line-height: 1.35;
  text-align: left;
}

.metric-grid {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  gap: 8px;
}

.metric {
  min-width: 0;
  min-height: 76px;
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 11px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  animation: row-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(70ms + var(--metric-index, 0) * 55ms);
}

.metric span,
.metric small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.metric span {
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 1.08rem;
  font-weight: 740;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.metric small {
  color: var(--muted);
  font-size: 0.72rem;
}

.metric.good strong {
  color: var(--green);
}

.metric.warn strong {
  color: var(--red);
}

.metric.watch strong {
  color: var(--amber);
}

.work-surface {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  align-content: start;
  gap: 12px;
  padding-right: 2px;
}

.panel {
  min-width: 0;
  padding: 14px;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
  animation: row-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
}

.panel-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, 0.65fr);
  gap: 12px;
}

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

.panel-header {
  min-width: 0;
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel-header p:not(.eyebrow) {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.4;
}

.status-pill {
  flex: 0 0 auto;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 9px;
  border-radius: 999px;
  color: #1f4708;
  background: #e8f4dc;
  font-size: 0.66rem;
  font-weight: 760;
  text-transform: uppercase;
}

.status-pill.pending,
.status-pill.low,
.status-pill.watch {
  color: #684205;
  background: #fff2d5;
}

.status-pill.out,
.status-pill.error {
  color: #780018;
  background: var(--accent-soft);
}

.status-pill.inactive {
  color: #4b5660;
  background: #e7ecef;
}

.list {
  display: grid;
  gap: 7px;
}

.data-row {
  min-width: 0;
  min-height: 54px;
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
  animation: row-in 360ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(60ms + var(--row-index, 0) * 42ms);
}

.data-row.selected {
  border-color: rgba(0, 87, 184, 0.28);
  background: #eef6ff;
}

.row-icon {
  width: 38px;
  height: 38px;
  border-radius: 7px;
  font-size: 0.68rem;
}

.row-copy {
  min-width: 0;
}

.row-copy strong,
.row-copy small,
.row-value {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-copy strong {
  font-size: 0.86rem;
  font-weight: 680;
}

.row-copy small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.row-value {
  max-width: 170px;
  font-size: 0.78rem;
  font-weight: 730;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.product-summary {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.product-summary span {
  min-width: 0;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper-soft);
}

.product-summary small,
.product-summary strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.product-summary small {
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 760;
  text-transform: uppercase;
}

.product-summary strong {
  font-size: 0.9rem;
  font-weight: 720;
  font-variant-numeric: tabular-nums;
}

.product-table-shell {
  width: 100%;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.stock-table {
  width: 100%;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
}

.product-table {
  min-width: 920px;
}

.stock-table th,
.stock-table td {
  padding: 11px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.stock-table th {
  color: var(--muted);
  background: #f0f5fb;
  font-size: 0.66rem;
  font-weight: 760;
  text-transform: uppercase;
}

.stock-table td {
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

.product-table tbody tr {
  animation: row-in 320ms cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: calc(35ms + var(--row-index, 0) * 16ms);
}

.stock-table tr:hover td {
  background: #f7fbff;
}

.product-column {
  width: 34%;
  min-width: 300px;
}

.product-identity {
  min-width: 0;
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: start;
  gap: 10px;
}

.product-thumb {
  position: relative;
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(0, 87, 184, 0.08), rgba(0, 156, 222, 0.08)),
    #ffffff;
  color: var(--blue);
  font-size: 0.68rem;
  font-weight: 780;
}

.data-row > .product-thumb {
  width: 38px;
  height: 38px;
  border-radius: 7px;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.product-thumb.fallback::after {
  content: attr(data-fallback);
}

.product-copy,
.sku-stack,
.price-stack,
.status-stack,
.stock-stack,
.type-cell {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.product-copy strong,
.sku-stack strong,
.price-stack strong {
  min-width: 0;
  overflow: hidden;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 720;
  line-height: 1.25;
  text-overflow: ellipsis;
}

.product-copy small,
.sku-stack small,
.price-stack small,
.status-stack small,
.stock-stack small {
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.7rem;
  line-height: 1.28;
  text-overflow: ellipsis;
}

.sku-stack strong,
.price-stack strong {
  color: var(--ink);
}

.tag-row,
.source-chips {
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.tag-chip,
.source-chips span {
  max-width: 170px;
  min-height: 22px;
  display: inline-grid;
  place-items: center;
  padding: 0 7px;
  overflow: hidden;
  border: 1px solid #d6e1e8;
  border-radius: 999px;
  color: #31506b;
  background: #f3f8fb;
  font-size: 0.64rem;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tag-chip:nth-child(1) {
  color: #216653;
  background: #e8f6f0;
  border-color: #cbe9dc;
}

.source-chips span:nth-child(1) {
  color: #5b4307;
  background: #fff3cf;
  border-color: #f2df9c;
}

.stock-pill {
  width: max-content;
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  border-radius: 999px;
  color: #164f3b;
  background: #def3ea;
  font-size: 0.66rem;
  font-weight: 780;
}

.stock-pill.low,
.stock-pill.watch,
.stock-pill.unstocked {
  color: #684707;
  background: #fff0cc;
}

.stock-pill.out {
  color: #6f241c;
  background: #fadfd9;
}

.muted-dash {
  color: var(--muted);
}

.align-right {
  text-align: right;
}

.qr-id {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 0 8px;
  border-radius: 6px;
  color: var(--blue-deep);
  background: #e8f1fb;
  font-size: 0.7rem;
  font-weight: 760;
}

.qr-card {
  width: 38px;
  height: 38px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(5, 1fr);
  gap: 2px;
  padding: 4px;
  border-radius: 6px;
  background: #ffffff;
  border: 1px solid var(--line);
}

.qr-card span {
  border-radius: 1px;
  background: #15191c;
  opacity: var(--dot-alpha, 0.12);
}

.empty-state {
  min-height: 220px;
  display: grid;
  place-items: center;
  padding: 22px;
  border: 1px dashed #c3ceda;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.68);
  text-align: center;
}

.empty-state h2 {
  margin-bottom: 6px;
  font-size: 1rem;
}

.empty-state p {
  max-width: 46ch;
  margin: 0 auto;
  color: var(--muted);
  line-height: 1.5;
}

.right-rail {
  position: fixed;
  inset: 16px 16px 16px auto;
  z-index: 80;
  width: min(380px, calc(100vw - 32px));
  min-width: 0;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 12px;
  overflow-y: auto;
  padding: 14px;
  background: rgba(238, 243, 248, 0.96);
  border: 1px solid rgba(216, 226, 236, 0.92);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(100% + 24px));
  transition: opacity 180ms ease, transform 220ms ease;
}

.app-shell[data-rail-open="true"] .right-rail {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.rail-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(7, 26, 47, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.app-shell[data-rail-open="true"] .rail-backdrop {
  opacity: 1;
  pointer-events: auto;
}

.rail-fab {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 60;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #ffffff;
  background: linear-gradient(180deg, var(--blue), var(--blue-deep));
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 999px;
  box-shadow: 0 18px 32px rgba(7, 31, 73, 0.26);
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.rail-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 38px rgba(7, 31, 73, 0.3);
}

.rail-fab span {
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  border: 2px solid currentColor;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  font-family: Georgia, serif;
  line-height: 1;
}

.app-shell[data-rail-open="true"] .rail-fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

.rail-panel {
  min-width: 0;
  display: grid;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-soft);
}

.rail-heading p {
  margin-bottom: 4px;
}

.sync-card {
  min-width: 0;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(135deg, #f8fbff, #ffffff);
}

.sync-card strong,
.sync-card small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sync-card strong {
  font-size: 0.84rem;
}

.sync-card small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 0.72rem;
}

.sync-ring {
  width: 42px;
  height: 42px;
  border: 4px solid rgba(0, 87, 184, 0.16);
  border-top-color: var(--teal);
  border-radius: 999px;
  animation: spin 1.4s linear infinite;
}

.timeline,
.check-list {
  display: grid;
  gap: 8px;
}

.timeline-item,
.check-item {
  display: grid;
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 9px;
  border-radius: 8px;
  background: #f8fbff;
  border: 1px solid var(--line);
}

.timeline-dot,
.check-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--amber);
}

.timeline-dot.ready,
.check-dot.ready {
  background: var(--green);
}

.timeline-dot.error,
.check-dot.error {
  background: var(--red);
}

.timeline-item strong,
.timeline-item small,
.check-item strong,
.check-item small {
  display: block;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.timeline-item strong,
.check-item strong {
  font-size: 0.78rem;
}

.timeline-item small,
.check-item small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.68rem;
}

.mobile-topbar,
.mobile-pane-heading {
  display: none;
}

.right-rail .mobile-pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--ink);
}

.mobile-icon-button {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
}

.mobile-screen-title img {
  width: 30px;
  height: 30px;
  display: none;
  margin: 0 auto 3px;
  object-fit: contain;
  background: #ffffff;
  border-radius: 7px;
}

.hamburger-icon,
.rail-icon,
.close-icon {
  width: 17px;
  height: 17px;
  position: relative;
}

.hamburger-icon,
.rail-icon {
  border-top: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

.hamburger-icon::before,
.rail-icon::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 6px;
  border-top: 2px solid currentColor;
}

.rail-icon {
  width: 18px;
}

.close-icon::before,
.close-icon::after {
  content: "";
  position: absolute;
  left: 1px;
  right: 1px;
  top: 7px;
  border-top: 2px solid currentColor;
}

.close-icon::before {
  transform: rotate(45deg);
}

.close-icon::after {
  transform: rotate(-45deg);
}

@keyframes row-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes menu-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .left-menu {
    grid-template-columns: minmax(190px, 1fr) minmax(220px, 270px);
    grid-template-rows: auto auto;
    gap: 10px 14px;
    min-height: 118px;
    padding: 10px 14px;
  }

  .menu-list {
    grid-column: 1 / -1;
    min-height: 46px;
  }

  .menu-item {
    min-height: 46px;
    border-radius: 6px;
    padding: 0 12px;
  }

  .menu-footer {
    display: none;
  }

  .stage-header {
    grid-template-columns: minmax(250px, 0.82fr) minmax(320px, 1fr);
    overflow: hidden;
  }

  .stage-title,
  .toolbar {
    min-height: 140px;
  }

  .metric-grid {
    grid-template-columns: repeat(auto-fit, minmax(116px, 1fr));
  }

  .panel-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  body {
    overflow: hidden;
  }

  .app-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr);
  }

  .left-menu {
    position: fixed;
    inset: 0 auto 0 0;
    z-index: 50;
    width: min(86vw, 320px);
    min-height: 0;
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    align-items: stretch;
    gap: 14px;
    padding: 18px 14px;
    overflow: hidden;
    transform: translateX(-105%);
    transition: transform 220ms ease;
  }

  .brand-lockup {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #ffffff;
    box-shadow: 0 10px 24px rgba(7, 26, 47, 0.07);
  }

  .brand-logo-frame {
    width: 58px;
    height: 58px;
  }

  .source-trigger {
    min-height: 58px;
  }

  .menu-list {
    grid-column: auto;
    height: auto;
    min-height: 0;
    display: grid;
    align-content: start;
    gap: 4px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .menu-item {
    min-height: 46px;
    grid-template-columns: 34px minmax(0, 1fr) auto;
    padding: 6px 8px;
    border-radius: 6px;
  }

  .menu-icon {
    display: grid;
  }

  .source-option.selected,
  .menu-item.active {
    box-shadow: inset 3px 0 0 var(--accent);
  }

  .menu-footer {
    display: grid;
    min-height: 62px;
    padding: 12px 10px;
  }

  .right-rail {
    inset: 10px 10px 10px auto;
    width: min(90vw, 340px);
    padding: 14px;
    background: var(--canvas);
  }

  .app-shell[data-mobile-pane="menu"] .left-menu {
    transform: translateX(0);
    box-shadow: var(--shadow-menu);
  }

  .rail-fab {
    top: auto;
    right: 16px;
    bottom: 16px;
  }

  .main-stage {
    grid-template-rows: auto auto auto minmax(0, 1fr);
    padding: 12px;
  }

  .mobile-topbar,
  .mobile-pane-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
  }

  .mobile-topbar {
    min-height: 46px;
    padding: 3px 0;
  }

  .mobile-pane-heading {
    color: var(--menu-text);
  }

  .right-rail .mobile-pane-heading {
    color: var(--ink);
  }

  .mobile-screen-title {
    min-width: 0;
    text-align: center;
  }

  .mobile-screen-title img {
    display: block;
  }

  .mobile-screen-title small,
  .mobile-screen-title strong {
    display: block;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .mobile-screen-title small {
    color: var(--muted);
    font-size: 0.68rem;
  }

  .mobile-screen-title strong {
    font-size: 0.9rem;
  }

  .stage-header {
    display: block;
    overflow: visible;
    background: transparent;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .stage-header::before {
    display: none;
  }

  .stage-title {
    min-height: auto;
    padding: 22px;
    border-radius: 8px;
    overflow: hidden;
  }

  .toolbar {
    min-height: auto;
    margin-top: 10px;
    padding: 14px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: var(--shadow-soft);
  }

  .stage-brand-strip {
    max-width: 100%;
  }

  .toolbar {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .toolbar label,
  .toolbar input,
  .toolbar select,
  .primary-action {
    width: 100%;
  }

  .primary-action {
    grid-column: 1 / -1;
    justify-content: center;
  }

  .refresh-status {
    text-align: left;
  }

  .metric-grid {
    grid-template-columns: 1fr;
  }

  .stock-table {
    min-width: 720px;
  }
}

/* Floating menu drawer */
.app-shell {
  grid-template-rows: minmax(0, 1fr);
}

.left-menu {
  position: fixed;
  inset: 14px auto 14px 14px;
  z-index: 80;
  width: min(326px, calc(100vw - 28px));
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 14px;
  padding: 18px 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow-menu);
  opacity: 0;
  pointer-events: none;
  transform: translateX(calc(-100% - 28px));
  transition: opacity 180ms ease, transform 220ms ease;
}

.app-shell[data-mobile-pane="menu"] .left-menu {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

.left-menu .mobile-pane-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--menu-text);
}

.brand-lockup {
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 10px 24px rgba(7, 26, 47, 0.07);
}

.brand-logo-frame {
  width: 58px;
  height: 58px;
}

.source-trigger {
  min-height: 58px;
}

.source-option.selected,
.menu-item.active {
  box-shadow: inset 3px 0 0 var(--accent);
}

.menu-list {
  height: auto;
  min-height: 0;
  display: grid;
  align-content: start;
  gap: 4px;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 0;
}

.menu-item {
  min-height: 46px;
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  gap: 8px;
  flex: 0 0 auto;
  padding: 6px 8px;
  border-radius: 6px;
}

.menu-icon {
  display: grid;
}

.left-menu > .menu-list .menu-badge {
  display: inline-grid;
}

.menu-footer {
  display: grid;
  min-height: 62px;
  padding: 12px 10px;
}

.main-stage {
  grid-column: 1;
  grid-row: 1;
  padding: 20px 24px 24px 78px;
}

.menu-fab {
  position: fixed;
  top: 18px;
  left: 18px;
  z-index: 60;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 18px 32px rgba(7, 26, 47, 0.16);
  transition: opacity 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}

.menu-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 22px 38px rgba(7, 26, 47, 0.2);
}

.app-shell[data-mobile-pane="menu"] .menu-fab {
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
}

.menu-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgba(7, 26, 47, 0.18);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.app-shell[data-mobile-pane="menu"] .menu-backdrop {
  opacity: 1;
  pointer-events: auto;
}

@media (max-width: 820px) {
  .left-menu {
    inset: 10px auto 10px 10px;
    width: min(86vw, 320px);
    height: auto;
  }

  .main-stage {
    padding: 12px;
  }

  .menu-fab {
    top: 16px;
    left: 16px;
    bottom: auto;
  }

  .mobile-topbar .mobile-icon-button {
    visibility: hidden;
  }
}
