/* Rack digital twin — align with slate-950 + cyan border contract */
:root {
  --rm-bg: #020617;
  --rm-panel: #0f172a;
  --rm-line: rgba(6, 182, 212, 0.3);
  --rm-text: #e2e8f0;
  --rm-muted: #94a3b8;
  --rm-accent: #22d3ee;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--rm-bg);
  color: var(--rm-text);
  font-family: system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.rm-page {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 18px 32px;
}

.rm-page--workspace {
  max-width: 1720px;
  width: 100%;
  margin: 0 auto;
  padding: 12px 14px 28px;
  box-sizing: border-box;
}

.rm-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 34%);
  gap: 16px;
  align-items: start;
}

@media (max-width: 1100px) {
  .rm-split {
    grid-template-columns: 1fr;
  }
  .rm-intel-panel {
    position: relative !important;
    top: auto !important;
    max-height: none;
  }
}

.rm-split__main {
  min-width: 0;
}

.rm-intel-panel {
  border: 1px solid var(--rm-line);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.82);
  padding: 12px 14px 14px;
  position: sticky;
  top: 10px;
  align-self: start;
  max-height: min(90vh, 960px);
  overflow: auto;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.rm-intel-kicker {
  margin: 0 0 6px;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  text-transform: none;
  color: #bae6fd;
  font-weight: 700;
}

.rm-intel-headline {
  margin: 0 0 6px;
  font-size: 0.95rem;
  font-weight: 700;
  color: #e0f2fe;
  line-height: 1.25;
  word-break: break-word;
}

.rm-intel-aggregate {
  font-size: 0.78rem;
  color: #cbd5e1;
  line-height: 1.5;
  border-top: 1px solid rgba(51, 65, 85, 0.55);
  padding-top: 10px;
  margin-top: 6px;
}

.rm-intel-aggregate strong {
  color: #f1f5f9;
  font-weight: 650;
}

.rm-intel-aggregate p {
  margin: 0 0 6px;
}

.rm-intel-detail {
  font-size: 0.75rem;
  line-height: 1.45;
  color: #e2e8f0;
}

.rm-intel-detail.rm-intel-detail--stack {
  margin-top: 10px;
}

.rm-intel-detail.hidden,
.rm-intel-detail[hidden] {
  display: none !important;
}

.rm-intel-detail--stack {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid rgba(51, 65, 85, 0.55);
  border-radius: 10px;
  overflow: hidden;
  background: rgba(2, 6, 23, 0.35);
}

.rm-intel-section {
  padding: 10px 12px;
}

.rm-intel-section + .rm-intel-section {
  border-top: 1px solid rgba(51, 65, 85, 0.55);
}

.rm-intel-section__title {
  margin: 0 0 8px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: none;
  color: #e0f2fe;
}

.rm-intel-section--mid {
  flex: 1 1 auto;
  min-height: 100px;
}

.rm-intel-bottom-actions a {
  font-size: 0.72rem;
  color: #67e8f9;
  text-decoration: none;
}

.rm-intel-bottom-actions a:hover {
  text-decoration: underline;
}

.rm-intel-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: center;
  margin-bottom: 8px;
}

.rm-intel-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  border: 1px solid rgba(100, 116, 139, 0.45);
}

.rm-intel-badge--empty {
  color: #94a3b8;
  background: rgba(30, 41, 59, 0.5);
}

.rm-intel-badge--partial {
  color: #5eead4;
  background: rgba(20, 184, 166, 0.12);
  border-color: rgba(45, 212, 191, 0.35);
}

.rm-intel-badge--full {
  color: #fdba74;
  background: rgba(234, 88, 12, 0.12);
  border-color: rgba(251, 146, 60, 0.35);
}

.rm-intel-meta {
  font-size: 0.72rem;
  color: var(--rm-muted);
  margin: 0 0 6px;
}

.rm-intel-actions .rm-btn {
  font-size: 0.72rem;
  padding: 6px 10px;
}

.rm-cell--selected {
  outline: 3px solid rgba(34, 211, 238, 0.98) !important;
  outline-offset: 2px;
  box-shadow:
    0 0 0 1px rgba(6, 182, 212, 0.55),
    0 0 14px rgba(34, 211, 238, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.18);
  filter: brightness(1.28) saturate(1.08);
  z-index: 3;
  position: relative;
}

.rm-map-zones-host {
  align-items: flex-start;
}

.rm-zone-grid {
  justify-content: start;
}

.rm-intel-stock-mount {
  max-height: min(42vh, 420px);
  overflow: auto;
}

.rm-intel-stock-mount .rm-table {
  font-size: 0.68rem;
}

.rm-intel-stock-mount .rm-table th,
.rm-intel-stock-mount .rm-table td {
  padding: 4px 6px;
}

.rm-intel-trace:empty {
  display: none;
}

.rm-intel-note {
  color: #94a3b8;
  font-size: 0.72rem;
}

.rm-zone-switcher {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.rm-zone-pill {
  appearance: none;
  border: 1px solid rgba(51, 65, 85, 0.8);
  background: rgba(15, 23, 42, 0.65);
  color: #cbd5e1;
  font-size: 0.68rem;
  font-weight: 600;
  padding: 3px 10px;
  border-radius: 999px;
  cursor: pointer;
  line-height: 1.2;
}

.rm-zone-pill:hover {
  border-color: rgba(34, 211, 238, 0.45);
  color: #e2e8f0;
}

.rm-zone-pill--ghost {
  opacity: 0.85;
}

.rm-zone-pill--active {
  border-color: rgba(34, 211, 238, 0.75);
  background: rgba(6, 182, 212, 0.12);
  color: #a5f3fc;
  box-shadow: 0 0 0 1px rgba(34, 211, 238, 0.2);
}

.rm-page h1 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.rm-sub {
  margin: 0 0 14px;
  color: var(--rm-muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rm-nav a {
  color: #7dd3fc;
  text-decoration: none;
  margin-right: 12px;
  font-size: 0.85rem;
}

.rm-panel {
  border: 1px solid var(--rm-line);
  border-radius: 12px;
  background: var(--rm-panel);
  padding: 14px 16px;
  margin-bottom: 14px;
}

.rm-panel h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: #bae6fd;
}

.rm-gen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: flex-end;
}

.rm-gen-row label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.75rem;
  color: var(--rm-muted);
  flex: 1 1 220px;
}

.rm-gen-row textarea,
.rm-gen-row input[type='text'] {
  border: 1px solid var(--rm-line);
  border-radius: 8px;
  background: #020617;
  color: var(--rm-text);
  padding: 8px 10px;
  font-size: 0.85rem;
  min-height: 40px;
}

.rm-gen-row textarea {
  min-height: 72px;
  resize: vertical;
  font-family: ui-monospace, monospace;
}

.rm-btn {
  border: 1px solid var(--rm-line);
  border-radius: 8px;
  background: #082f49;
  color: #e0f2fe;
  padding: 9px 16px;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.85rem;
}

.rm-btn:hover {
  background: #0c4a6e;
}

.rm-btn-muted {
  background: #1e293b;
  color: #cbd5e1;
}

/* Compact planner / register ops strip — low visual weight vs map */
.rm-ops-strip {
  margin-top: 6px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid rgba(6, 182, 212, 0.16);
  background: rgba(15, 23, 42, 0.42);
  box-shadow: none;
}

.rm-ops-strip.hidden,
.rm-ops-strip[hidden] {
  display: none !important;
}

.rm-ops-strip__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  row-gap: 2px;
  font-size: 0.68rem;
  line-height: 1.35;
  color: #94a3b8;
}

.rm-ops-strip__txt {
  margin: 0;
  font-weight: 500;
}

.rm-ops-strip__txt--plan {
  color: #7dd3fc;
}

.rm-ops-strip__txt--ok {
  color: #6ee7b7;
}

.rm-ops-strip__sep {
  color: rgba(148, 163, 184, 0.5);
  user-select: none;
  font-weight: 400;
}

.rm-ops-strip__sep--bar {
  color: rgba(100, 116, 139, 0.45);
}

.rm-ops-strip__sep.hidden,
.rm-ops-strip__txt.hidden {
  display: none !important;
}

.rm-ops-strip__btn {
  margin-left: auto;
  padding: 2px 8px !important;
  font-size: 0.65rem !important;
  font-weight: 600 !important;
  border-radius: 5px !important;
  min-height: 0;
}

.rm-err {
  color: #fecaca;
  font-size: 0.85rem;
  margin-top: 8px;
}

.rm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  align-items: center;
  font-size: 0.75rem;
  color: var(--rm-muted);
  margin-top: 8px;
}

.rm-legend span {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.rm-swatch {
  width: 20px;
  height: 18px;
  border-radius: 3px;
  border: 1px solid #cbd5e1;
  border-left-width: 4px;
  border-left-style: solid;
  background: #ffffff;
}

.rm-viewport {
  position: relative;
  height: min(72vh, 640px);
  border: 1px solid rgba(148, 163, 184, 0.45);
  border-radius: 12px;
  background: #e2e8f0;
  overflow: hidden;
  touch-action: none;
}

.rm-stage {
  position: absolute;
  left: 0;
  top: 0;
  transform-origin: 0 0;
  will-change: transform;
  padding: 16px;
}

.rm-grid {
  display: grid;
  gap: 4px;
  align-content: start;
  justify-content: start;
}

.rm-cell {
  min-width: 48px;
  min-height: 48px;
  border-radius: 4px;
  border: 1px solid #cbd5e1;
  border-left-width: 4px;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  text-align: left;
  padding: 5px 6px 5px 5px;
  cursor: pointer;
  word-break: break-all;
  line-height: 1.2;
  color: #0f172a;
  background: #ffffff;
  user-select: none;
  -webkit-user-select: none;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.08);
  transition: outline-color 0.12s ease, box-shadow 0.12s ease;
}

.rm-cell:hover {
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.14);
  outline: 2px solid rgba(14, 116, 144, 0.75);
  outline-offset: 1px;
  z-index: 2;
  position: relative;
}

.rm-cell--empty {
  border-style: dashed;
  border-color: #94a3b8;
  background: #f1f5f9 !important;
  opacity: 0.92;
}

.rm-cell:not(.rm-cell--empty) .rm-cell__u {
  color: #334155;
  font-weight: 800;
}

@keyframes rm-cell-t0-flash {
  0% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.12),
      0 0 0 2px rgba(34, 211, 238, 0.95),
      0 0 22px rgba(34, 211, 238, 0.55);
    filter: brightness(1.22);
  }
  100% {
    box-shadow:
      inset 0 1px 0 rgba(255, 255, 255, 0.06),
      0 0 0 1px rgba(6, 182, 212, 0.12);
    filter: brightness(1);
  }
}

.rm-cell--t0-flash {
  animation: rm-cell-t0-flash 1.15s ease-out 1;
  position: relative;
  z-index: 2;
}

.rm-cell__code {
  font-weight: 800;
  font-size: 0.74rem;
  color: #0f172a;
  letter-spacing: 0.01em;
}

.rm-cell__u {
  font-size: 0.66rem;
  font-weight: 800;
  color: #475569;
  margin-top: 3px;
}

.rm-drawer-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

.rm-drawer-root.rm-drawer--open {
  pointer-events: auto;
}

.rm-drawer-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.55);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.rm-drawer-root.rm-drawer--open .rm-drawer-backdrop {
  opacity: 1;
}

.rm-drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: min(420px, 100vw - 24px);
  height: 100%;
  background: #020617;
  border-left: 1px solid var(--rm-line);
  box-shadow: -12px 0 40px rgba(0, 0, 0, 0.45);
  transform: translateX(100%);
  transition: transform 0.22s ease;
  display: flex;
  flex-direction: column;
}

.rm-drawer-root.rm-drawer--open .rm-drawer {
  transform: translateX(0);
}

.rm-drawer__head {
  padding: 14px 16px;
  border-bottom: 1px solid var(--rm-line);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
}

.rm-drawer__head h3 {
  margin: 0;
  font-size: 1rem;
}

.rm-drawer__x {
  border: 1px solid var(--rm-line);
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
}

.rm-drawer__body {
  flex: 1;
  overflow: auto;
  padding: 12px 16px 20px;
}

.rm-drawer__print {
  margin-top: 12px;
}

.rm-drawer__print a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--rm-line);
  background: #082f49;
  color: #e0f2fe;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.85rem;
}

.rm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78rem;
}

.rm-table th,
.rm-table td {
  border-bottom: 1px solid rgba(51, 65, 85, 0.6);
  padding: 6px 4px;
  text-align: left;
  vertical-align: top;
}

.rm-table th {
  color: #7dd3fc;
  font-weight: 600;
}

.rm-muted {
  color: var(--rm-muted);
  font-size: 0.8rem;
}

/* Multi-zone map: scroll inside viewport, sticky zone headers */
.rm-viewport--zone-stack {
  overflow-y: auto;
  overflow-x: hidden;
  touch-action: pan-y;
  height: min(85vh, 920px);
}

.rm-stage--zone-stack {
  position: relative;
  padding: 12px 14px 28px;
}

.rm-map-zones-host {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
}

.rm-zone-block {
  border: 1px solid rgba(100, 116, 139, 0.35);
  border-radius: 2px;
  background: rgba(15, 23, 42, 0.45);
  overflow: hidden;
  box-shadow: none;
  margin-bottom: 0;
}

.rm-zone-header {
  position: sticky;
  top: 0;
  z-index: 9;
  width: 100%;
  box-sizing: border-box;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-weight: 750;
  letter-spacing: 0.03em;
  color: #e0f2fe;
  background: rgba(15, 23, 42, 0.98);
  border-bottom: 1px solid rgba(100, 116, 139, 0.35);
  box-shadow: none;
}

.rm-zone-header__title {
  flex: 1 1 auto;
  min-width: 0;
}

.rm-zone-print-btn {
  flex: 0 0 auto;
  font-size: 0.65rem !important;
  padding: 6px 10px !important;
  font-weight: 600 !important;
}

.rm-zone-block .rm-zone-grid {
  padding: 10px;
}

/* Location label preview (Hero Putaway — scan wms_locations.code) */
.rm-label-modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
}

.rm-label-modal[hidden] {
  display: none !important;
}

.rm-label-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
}

.rm-label-modal__card {
  position: relative;
  z-index: 1;
  width: min(420px, 100%);
  max-height: min(90vh, 640px);
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(34, 211, 238, 0.35);
  background: #0f172a;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.55);
  padding: 16px 18px 18px;
}

.rm-label-modal__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 8px;
}

.rm-label-modal__title {
  margin: 0;
  font-size: 1.05rem;
  color: #e0f2fe;
}

.rm-label-modal__x {
  border: 1px solid var(--rm-line);
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  width: 36px;
  height: 36px;
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  flex-shrink: 0;
}

.rm-label-modal__code {
  margin-top: 10px;
  font-size: 1.25rem;
  font-weight: 800;
  color: #f8fafc;
  word-break: break-all;
}

.rm-label-modal__svgwrap {
  margin-top: 12px;
  padding: 12px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(148, 163, 184, 0.35);
}

.rm-label-modal__svgwrap svg {
  max-width: 100%;
  height: auto;
}

.rm-label-modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

.rm-print-mount {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  overflow: hidden;
  pointer-events: none;
}

.rm-label-print-card {
  page-break-inside: avoid;
  break-inside: avoid;
  padding: 14px 16px 18px;
  margin-bottom: 16px;
  border: 1px solid #ccc;
  border-radius: 8px;
  max-width: 360px;
  background: #fff;
  color: #0f172a;
}

.rm-label-print-card__zone {
  font-size: 10px;
  color: #64748b;
  margin: 0 0 4px;
}

.rm-label-print-card__code {
  font-size: 18px;
  font-weight: 800;
  margin: 0 0 10px;
  font-family: ui-monospace, monospace;
}

.rm-label-print-card svg {
  display: block;
  max-width: 100%;
}

@media print {
  .rm-no-print,
  .rm-label-modal,
  .rm-drawer-root {
    display: none !important;
  }

  body {
    background: #fff !important;
    color: #000 !important;
  }

  .rm-print-mount {
    position: static !important;
    left: auto !important;
    width: auto !important;
    height: auto !important;
    overflow: visible !important;
    pointer-events: auto !important;
  }

  .rm-label-print-card {
    border-color: #999;
  }
}
