/* Morpheus Portal V150.6 — calm, consistent UI across all non-specialized workspaces. */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] {
  --v1506-gap-1: 8px;
  --v1506-gap-2: 12px;
  --v1506-gap-3: 16px;
  --v1506-gap-4: 22px;
  --v1506-radius: 14px;
  --v1506-radius-sm: 10px;
  --v1506-border: color-mix(in srgb, var(--line, #d8ded4) 82%, transparent);
  --v1506-surface: color-mix(in srgb, var(--card, #fff) 96%, var(--accent, #6a8f3a) 4%);
  --v1506-shadow: 0 8px 24px rgba(31, 42, 29, .07);
  --v1506-focus: 0 0 0 3px color-mix(in srgb, var(--accent, #6a8f3a) 28%, transparent);
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) #main,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) main {
  min-width: 0;
  padding-bottom: 40px;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .command-mast.compact.ultra {
  min-height: auto;
  margin-bottom: var(--v1506-gap-3);
  padding: 18px 20px;
  border-radius: var(--v1506-radius);
  box-shadow: none;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .command-mast.compact.ultra .mast-crumbs { display: none; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .command-mast.compact.ultra h1 {
  max-width: 24ch;
  margin: 0;
  font-size: clamp(1.3rem, 2vw, 1.8rem);
  line-height: 1.12;
  letter-spacing: -.025em;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .command-mast.compact.ultra p {
  max-width: 72ch;
  margin: 5px 0 0;
  line-height: 1.45;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.card,.panel,.command-panel,.smart-card,.soft-depth-panel) {
  border-color: var(--v1506-border);
  border-radius: var(--v1506-radius);
  box-shadow: var(--v1506-shadow);
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .mpd-v1506-toolbar {
  display: grid;
  grid-template-columns: minmax(220px, 1.5fr) repeat(auto-fit, minmax(150px, .55fr));
  align-items: center;
  gap: var(--v1506-gap-2);
  margin-bottom: var(--v1506-gap-3);
  padding: 12px;
  border: 1px solid var(--v1506-border);
  border-radius: var(--v1506-radius);
  background: var(--v1506-surface);
  box-shadow: 0 4px 14px rgba(31, 42, 29, .045);
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .mpd-v1506-toolbar > * { min-width: 0; margin: 0; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) input,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) select,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) textarea,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) button {
  font: inherit;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(input,select,textarea,button):focus-visible {
  outline: none;
  box-shadow: var(--v1506-focus);
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(input,select,.btn,button):not(.icon-btn) { min-height: 40px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .mpd-v1506-empty {
  display: grid;
  min-height: 108px;
  place-items: center;
  padding: 22px;
  border: 1px dashed var(--v1506-border);
  border-radius: var(--v1506-radius-sm);
  background: color-mix(in srgb, var(--v1506-surface) 82%, transparent);
  text-align: center;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.table-wrap,.table-scroll,.data-table-wrap) {
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scrollbar-gutter: stable;
}

html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) table { width: 100%; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) th {
  position: sticky;
  top: 0;
  z-index: 1;
  white-space: nowrap;
}

/* Role dashboards */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="heartbeat"] :is(.tower-status-grid,.role-heartbeat-grid,.staff-hero-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="heartbeat"] :is(.tower-main-grid,.tower-v99-grid,.tower-secondary-grid,.partner-exec-grid) {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="heartbeat"] :is(.tower-status-card,.role-home-panel,.tower-panel) { min-width: 0; padding: 16px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="heartbeat"] :is(.tower-quick-actions,.role-command-actions,.partner-library-actions) {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Companies */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="companies"] .company-command-shell {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="companies"] .company-rail {
  position: sticky;
  top: 82px;
  max-height: calc(100dvh - 104px);
  overflow: auto;
  padding: 10px;
  scrollbar-gutter: stable;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="companies"] .workbench-main { min-width: 0; }

/* Projects */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="projects"] .projects-latest-strip-v11033 {
  gap: 10px;
  padding: 10px;
  overflow-x: auto;
  scroll-snap-type: x proximity;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="projects"] .latest-project-row-v11033 { scroll-snap-align: start; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="projects"] .projects-cockpit-layout-v11033 {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 30%);
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="projects"] .projects-board-v11033 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(300px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}

/* Updates */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-command-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-command-metric { min-height: 78px; padding: 12px 14px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-intelligence-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(280px, .7fr);
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-feed-stack { display: grid; gap: var(--v1506-gap-2); }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-feed-card { padding: 14px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] :is(.updates-newest-side,.updates-feed-rail) {
  position: sticky;
  top: 82px;
  max-height: calc(100dvh - 104px);
  overflow: auto;
}

/* Orders and agents */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="orders"] .orders-active-grid,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="agents"] .agent-service-overview,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="agents"] .improved-agent-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(280px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="orders"] .order-command-lanes-v1051 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="orders"] :is(.order-control-map,.compact-order-map) { padding: 14px; }

/* Finance */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-command-dashboard {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-left-deck { min-width: 0; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-right-control {
  position: sticky;
  top: 82px;
  max-height: calc(100dvh - 104px);
  overflow-y: auto;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-company-ledger {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-gutter: stable;
}

/* Product, stock and packaging libraries: use a compact horizontal company rail. */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] :is(.product-library-workspace,.stock-library-workspace,.packaging-library-workspace) {
  display: block;
  min-width: 0;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] :is(.product-company-rail,.stock-company-rail,.packaging-company-rail) {
  position: sticky;
  top: 66px;
  z-index: 5;
  display: flex;
  gap: 8px;
  max-width: 100%;
  margin-bottom: 14px;
  padding: 9px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  background: color-mix(in srgb, var(--card, #fff) 92%, transparent);
  backdrop-filter: blur(12px);
  scrollbar-width: thin;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] .product-company-chip {
  flex: 0 0 auto;
  min-height: 38px;
  white-space: nowrap;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] :is(.product-library-main,.stock-library-main,.packaging-library-main) { min-width: 0; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] :is(.product-category-shelf,.stock-category-shelf,.packaging-category-shelf) { margin-bottom: var(--v1506-gap-3); padding: 14px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-mpd-page-family="library"] :is(.product-bubble-grid,.stock-mini-grid,.packaging-bubble-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(220px, 100%), 1fr));
  gap: var(--v1506-gap-2);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="assets"] .asset-library-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="assets"] .company-assets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(240px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}

/* Pipeline */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="pipeline"] .pipeline-workbench {
  min-width: 0;
  overflow: hidden;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="pipeline"] .pipeline-dnd-board {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(280px, 1fr);
  gap: var(--v1506-gap-3);
  max-width: 100%;
  padding-bottom: 10px;
  overflow-x: auto;
  overscroll-behavior-inline: contain;
  scroll-snap-type: x proximity;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="pipeline"] .pipeline-lane {
  min-width: 0;
  max-height: calc(100dvh - 210px);
  scroll-snap-align: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="pipeline"] .pipeline-lane-body {
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* SOPs and users */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="sops"] .sop-engine-grid {
  display: grid;
  grid-template-columns: minmax(250px, .7fr) minmax(0, 1.3fr);
  gap: var(--v1506-gap-3);
  align-items: start;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="sops"] .sop-project-grid,
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="users"] :is(.user-grid,.compact-users) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="sops"] :is(.sop-engine-panel,.sop-template-detail) { min-width: 0; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="users"] :is(.user-command-tools,.users-access-toolbar) {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="users"] .users-access-search { flex: 1 1 260px; min-width: 0; }

/* Gallery, calls, messages and profile */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="gallery"] :is(.gallery-grid,.gallery-latest-grid) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(190px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="gallery"] .file-tile img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="gallery"] .gallery-company-summary { min-height: 48px; padding: 10px 14px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="calls"] :is(.card-grid.small,.call-board) {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(280px, 100%), 1fr));
  gap: var(--v1506-gap-3);
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="messages"] .mpd-chat-shell {
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  height: min(760px, calc(100dvh - 170px));
  min-height: 520px;
  overflow: hidden;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="messages"] :is(.mpd-chat-list,.mpd-thread-list,.mpd-chat-room) {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="profile"] .profile-command-page { max-width: 1120px; margin-inline: auto; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="profile"] .profile-self-card { padding: 16px; }
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="profile"] .profile-window-v2 {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(280px, .65fr);
  gap: var(--v1506-gap-3);
  align-items: start;
}

/* All legacy dialogs receive a predictable viewport, without changing their actions. */
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.modal,.dialog,[role="dialog"]) {
  max-width: min(1040px, calc(100vw - 32px));
  max-height: min(90dvh, 900px);
  border-radius: 16px;
  overflow: hidden;
  overscroll-behavior: contain;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.modal-body,.dialog-body,[role="dialog"] > .body) {
  max-height: calc(90dvh - 126px);
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.modal-header,.dialog-header) {
  position: sticky;
  top: 0;
  z-index: 3;
}
html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(.modal-footer,.dialog-footer) {
  position: sticky;
  bottom: 0;
  z-index: 3;
}

@media (max-width: 1050px) {
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="companies"] .company-command-shell,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="projects"] .projects-cockpit-layout-v11033,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] .updates-intelligence-grid,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-command-dashboard,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="sops"] .sop-engine-grid,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="profile"] .profile-window-v2 {
    grid-template-columns: minmax(0, 1fr);
  }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="companies"] .company-rail {
    position: static;
    display: flex;
    gap: 8px;
    max-height: none;
    overflow-x: auto;
  }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="updates"] :is(.updates-newest-side,.updates-feed-rail) {
    position: static;
    max-height: none;
  }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="finance"] .finance-right-control { position: static; max-height: none; }
}

@media (max-width: 760px) {
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .command-mast.compact.ultra { padding: 14px; }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) .mpd-v1506-toolbar { grid-template-columns: minmax(0, 1fr); }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="orders"] .order-command-lanes-v1051,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="heartbeat"] :is(.tower-main-grid,.tower-v99-grid,.tower-secondary-grid,.partner-exec-grid),
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="messages"] .mpd-chat-shell { grid-template-columns: minmax(0, 1fr); }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="messages"] .mpd-chat-shell { height: auto; min-height: 0; }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body[data-section="messages"] .mpd-chat-list { max-height: 42dvh; }
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] body:not([data-section="tasks"]):not([data-section="shipments"]) :is(input,select,.btn,button):not(.icon-btn) { min-height: 42px; }
}

@media (prefers-reduced-motion: reduce) {
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] *,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] *::before,
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] *::after {
    scroll-behavior: auto !important;
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

@media (prefers-color-scheme: dark) {
  html[data-mpd-ui-v1506="central-v150-6-portal-consistency"] {
    --v1506-border: rgba(255, 255, 255, .11);
    --v1506-shadow: 0 10px 26px rgba(0, 0, 0, .16);
  }
}
