:root {
  --sans: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --bg: #f4f6f2;
  --ink: #243830;
  --muted: #64716b;
  --green: #173f34;
  --green-soft: #edf4ed;
  --line: #dce2da;
  --amber: #a97327;
  --amber-soft: #fcf3df;
  --red: #a04438;
}
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.5 var(--sans);
}
a {
  color: var(--green);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}
button,
input,
select,
textarea {
  font: inherit;
}
button,
a,
input,
select,
textarea,
summary {
  touch-action: manipulation;
}
button {
  cursor: pointer;
}
button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
:focus-visible {
  outline: 3px solid #a6b83a;
  outline-offset: 3px;
}
button,
a {
  -webkit-tap-highlight-color: transparent;
}
.skip-link {
  position: fixed;
  top: -60px;
  padding: 12px;
  background: white;
  z-index: 100;
}
.skip-link:focus {
  top: 10px;
}
.app-sidebar {
  width: 212px;
  position: fixed;
  inset: 0 auto 0 0;
  background: var(--green);
  color: #e7efe9;
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  z-index: 20;
}
.wordmark {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 750;
  color: white;
  white-space: nowrap;
}
.brand-icon {
  display: grid;
  place-items: center;
  background: #d9e58f;
  color: var(--green);
  height: 33px;
  width: 33px;
  border-radius: 8px;
  font-size: 26px;
}
.nav-label {
  font-size: 10px;
  letter-spacing: 1.4px;
  color: #a4bbb0;
  margin: 34px 12px 10px;
}
.mesa-nav {
  display: grid;
  gap: 5px;
}
.mesa-nav button {
  display: flex;
  align-items: center;
  gap: 8px;
  text-align: left;
  background: transparent;
  border: 0;
  color: #dce7df;
  padding: 12px 10px;
  border-radius: 7px;
  font-weight: 600;
  min-height: 45px;
}
.app-sidebar .nav-icon {
  width: 22px;
  height: 22px;
  flex: 0 0 22px;
}
.app-sidebar .nav-name {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  white-space: nowrap;
}
.mesa-nav button[aria-current="page"],
.sidebar-bottom #view-data[aria-current="page"],
#view-setup[aria-current="page"] {
  background: #f7faf4;
  color: var(--green);
}
.sidebar-recent a,
.sidebar-recent small {
  display: block;
  margin: 8px 12px;
  color: #dbe8df;
}
.sidebar-recent small {
  color: #a4bbb0;
  font-size: 11px;
}
.sidebar-bottom {
  margin-top: auto;
  border: 1px solid #537268;
  border-radius: 7px;
  padding: 10px;
  text-align: center;
  font-size: 12px;
}
.sidebar-bottom small {
  display: block;
  color: #b3c9bd;
}
.app-content {
  margin-left: 212px;
}
.topbar {
  height: 66px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 36px;
  gap: 20px;
}
.topbar nav {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
}
.demo-tag {
  font-size: 11px;
  color: var(--muted);
}
main {
  padding: 28px 36px;
  max-width: 1600px;
  margin: auto;
  min-height: calc(100vh - 66px);
}
h1,
h2,
h3,
h4,
p {
  margin: 0 0 12px;
}
h1 {
  font-size: 29px;
  letter-spacing: -1.1px;
  line-height: 1.2;
}
h2 {
  font-size: 19px;
  letter-spacing: -0.35px;
}
h3 {
  font-size: 16px;
}
h4 {
  font-size: 14px;
}
small {
  color: var(--muted);
}
.page-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
}
.page-heading p {
  color: var(--muted);
  margin: 8px 0 0;
}
.panel {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  padding: 24px;
  margin: 0 0 20px;
}
.primary,
.secondary,
.quiet-button,
.text-button {
  border-radius: 6px;
  min-height: 36px;
  padding: 8px 13px;
  font-weight: 600;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.primary {
  background: var(--green);
  color: white;
  border: 1px solid var(--green);
}
.secondary {
  background: white;
  border: 1px solid var(--line);
  color: var(--green);
}
.quiet-button,
.text-button {
  background: transparent;
  border: 1px solid transparent;
  color: var(--green);
}
.text-button {
  padding: 5px 0;
  min-height: 32px;
}
.primary:hover {
  background: #245745;
}
.secondary:hover,
.quiet-button:hover {
  background: var(--green-soft);
}
.section-head,
.history-head,
.editor-head,
.inspect-heading,
.compare-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}
.section-head h3 {
  margin: 0;
}
.eyebrow {
  font-size: 10px;
  letter-spacing: 0.9px;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 5px;
}
.source-note,
.mini-note,
.field-help,
.editor-copy {
  font-size: 12px;
  color: var(--muted);
}
.error {
  color: var(--red) !important;
}
.source-note:empty,
#notice:empty {
  display: none;
}
#notice {
  padding: 10px 14px;
  background: #eef2e9;
  border-radius: 6px;
  margin-bottom: 15px;
  overflow-wrap: anywhere;
}
#notice.error {
  background: #fceeea;
}
.table-wrap {
  overflow-x: auto;
}
table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 12px;
}
th {
  font-size: 11px;
  font-weight: 650;
  color: var(--muted);
  background: #f8faf6;
  padding: 13px 16px;
  border-bottom: 1px solid var(--line);
}
td {
  padding: 20px 16px;
  border-bottom: 1px solid #e9ede6;
  vertical-align: middle;
}
td small {
  display: block;
  margin-top: 5px;
  font-size: 11px;
}
td a {
  font-weight: 650;
}
tbody tr:last-child td {
  border-bottom: 0;
}
tbody tr:hover {
  background: #fbfcf9;
}
#forecast-list {
  padding: 0;
  overflow-x: auto;
  margin-top: 30px;
}
#forecast-list td:first-child {
  min-width: 210px;
}
#forecast-list td {
  padding-top: 27px;
  padding-bottom: 27px;
}
.collection-foot {
  border-top: 1px solid var(--line);
  padding: 15px 20px;
  color: var(--muted);
  font-size: 12px;
  margin: 0;
}
#cartera-slot {
  display: none;
}
.mesa-layout {
  display: block;
}
.analysis-space {
  min-width: 0;
}
.analysis-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  gap: 15px;
}
.analysis-heading h2 {
  font-size: 23px;
  line-height: 1.25;
  margin-bottom: 6px;
}
.analysis-heading p {
  margin-bottom: 5px;
  color: var(--muted);
}
#selection-chips:empty {
  display: none;
}
.scope-toolbar {
  border: 1px solid var(--line);
  background: white;
  border-radius: 9px;
  padding: 14px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 12px;
  margin-bottom: 24px;
  align-items: center;
}
.scope-toolbar > details {
  margin-left: auto;
}
.scope-toolbar details[open] {
  flex-basis: 100%;
}
.scope-toolbar strong {
  font-weight: 600;
}
.cycle-metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 15px;
  margin: 22px 0;
}
.metric-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.metric-card:hover {
  background: var(--green-soft);
  text-decoration: none;
  border-color: #a9bfb0;
}
.metric-card strong {
  font-size: 28px;
  letter-spacing: -1px;
}
#scope-products td > a {
  display: inline-block;
}
.metric-card small {
  font-size: 12px;
}
.prepared-totals {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0 24px;
}
#overview-products {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  margin: 0 0 28px;
}
.decision-card {
  border: 1px solid #e9d7b6;
  background: #fffdf7;
  border-radius: 7px;
  padding: 17px;
}
.decision-card p {
  font-size: 12px;
}
#scope-products {
  margin-top: 14px;
}
#readiness-detail {
  color: var(--muted);
  font-size: 13px;
}
#readiness-title {
  font-size: 21px;
}
.catalog-filters {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin: 15px 0;
}
.catalog-filters label {
  font-size: 12px;
}
.catalog-filters > label[for] {
  position: absolute;
  clip-path: inset(50%);
  width: 1px;
  height: 1px;
  overflow: hidden;
}
.catalog-filters input[type="search"] {
  flex: 1;
  min-width: 200px;
}
.catalog-filters select {
  max-width: 220px;
}
input,
select,
textarea {
  padding: 10px 12px;
  border: 1px solid #cdd6ca;
  border-radius: 6px;
  background: white;
  color: var(--ink);
  max-width: 100%;
}
input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--green);
}
.integral-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
}
.integral-heading h2 {
  margin: 0 auto 0 0;
}
.precision-bands {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin: 20px 0;
}
.precision-caption {
  font-size: 11px;
  color: var(--muted);
  flex-basis: 100%;
}
.band {
  border: 1px solid var(--line);
  border-radius: 20px;
  background: #fff;
  padding: 6px 12px;
  font-size: 12px;
}
.band[aria-pressed="true"] {
  border-color: var(--green);
  background: var(--green-soft);
  box-shadow: 0 0 0 1px var(--green);
}
.band-high {
  color: var(--green);
}
.band-medium {
  color: #8b6118;
}
.band-low {
  color: var(--red);
}
.precision-policy {
  font-size: 11px;
  margin-left: auto;
}
#integral-count {
  font-size: 12px;
  color: var(--muted);
}
#integral-rows td:nth-child(2) {
  min-width: 240px;
}
#integral-rows td:nth-child(5) {
  max-width: 260px;
}
#integral-rows td:first-child {
  font-size: 11px;
  color: var(--muted);
}
.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.85fr) minmax(290px, 1fr);
  gap: 20px;
  align-items: start;
}
.workspace > .panel {
  min-width: 0;
}
.portfolio .section-head {
  display: none;
}
.inspector {
  position: sticky;
  top: 20px;
}
.priority,
.draft-pill,
.count {
  font-size: 10px;
  color: var(--muted);
  white-space: nowrap;
}
.inspect-heading {
  align-items: flex-start;
}
.inspect-heading h2 {
  font-size: 17px;
}
.input-line {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0;
}
.input-line input {
  width: 155px;
  font-size: 22px;
  font-weight: 650;
}
.inspector label {
  font-weight: 600;
  font-size: 12px;
  display: block;
  margin-top: 18px;
}
.inspector label span {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}
.inspector textarea {
  width: 100%;
  margin-top: 8px;
}
.save-line {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.save-line > span {
  flex-basis: 100%;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}
.deltas {
  font-size: 12px;
  color: var(--muted);
  margin: 12px 0;
}
.source-strip,
.local-summary {
  font-size: 12px;
  margin: 18px 0;
}
.source-strip > div {
  display: flex;
  gap: 15px;
  margin: 8px 0;
}
.source-strip .label {
  min-width: 85px;
  color: var(--muted);
}
.unit-note {
  color: #8a6228;
}
details {
  font-size: 12px;
}
summary {
  cursor: pointer;
  color: var(--green);
  padding: 8px 0;
}
details p {
  margin: 10px 0;
}
.review-summary {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 12px;
  max-width: 100%;
}
.saved-flow {
  font-size: 11px;
  color: var(--muted);
  margin-top: 12px;
}
.history-table {
  max-height: 350px;
  overflow: auto;
}
.compare-head h3 {
  font-size: 13px;
}
.compare-head {
  gap: 6px;
}
.compare-head button {
  font-size: 11px;
}
.compare .bar {
  background: var(--green);
  height: 6px;
}
.compare article {
  margin: 12px 0;
}
.local-summary {
  color: var(--muted);
}
.chart-controls {
  display: flex;
  justify-content: flex-end;
}
.chart-controls label {
  font-size: 11px;
}
.chart-controls select {
  padding: 5px;
}
.chart-legend {
  display: flex;
  gap: 8px 14px;
  flex-wrap: wrap;
  font-size: 11px;
  margin: 14px 0 0;
}
.legend-sales {
  color: var(--green);
}
.legend-forecast {
  color: var(--amber);
}
.legend-proposal {
  color: #4667a0;
}
.history svg {
  width: 100%;
  height: auto;
  display: block;
  overflow: visible;
}
.chart-axis {
  font: 12px var(--sans);
  fill: var(--muted);
}
.chart-axis-title {
  font: 13px var(--sans);
  fill: var(--muted);
}
.chart-grid {
  stroke: var(--line);
  stroke-width: 1;
}
.forecast-zone {
  fill: var(--amber-soft);
  opacity: 0.65;
}
.sales-line,
.forecast-line,
.proposal-line {
  stroke-width: 2;
}
.sales-line {
  stroke: var(--green);
}
.forecast-line {
  stroke: var(--amber);
  stroke-dasharray: 5 4;
}
.proposal-line {
  stroke: #4667a0;
  stroke-dasharray: 2 6;
}
.sales-point {
  fill: var(--green);
}
.forecast-point {
  fill: var(--amber);
}
.proposal-point {
  fill: none;
  stroke: #4667a0;
  stroke-width: 2;
}
.chart-point {
  cursor: pointer;
  outline: none;
}
.chart-point:hover circle,
.chart-point:focus circle,
.chart-point.is-inspected circle {
  stroke: var(--ink);
  stroke-width: 3;
}
.chart-point .chart-hit,
.chart-point:hover .chart-hit,
.chart-point:focus .chart-hit,
.chart-point.is-inspected .chart-hit {
  stroke: transparent;
}
.chart-readout {
  min-height: 54px;
  padding: 12px;
  background: var(--green-soft);
  border-radius: 6px;
  font-size: 11px;
  margin: 14px 0 18px;
}
#product-rows button {
  padding: 7px;
  border: 0;
  background: transparent;
  color: var(--green);
  border-radius: 4px;
  cursor: pointer;
}
#product-rows tr[aria-selected="true"],
#product-rows tr.selected {
  background: var(--green-soft);
}
.month-pick.active {
  background: var(--green-soft) !important;
  box-shadow: inset 0 0 0 1px var(--green);
}
#close-drawer {
  position: static;
  width: 100%;
  max-width: none;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
  color: var(--ink);
  margin: 0 0 20px;
}
#close-drawer[open] {
  display: block;
}
#dismiss-close {
  margin-bottom: 20px;
}
.closure-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px;
  margin-bottom: 24px;
}
.closure-grid article {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 7px;
  overflow-wrap: anywhere;
}
.closure-grid small {
  font-size: 11px;
}
.closure-grid p {
  margin: 8px 0 0;
  font-size: 14px;
}
.partial-notice {
  padding: 14px;
  background: var(--amber-soft);
  border-radius: 6px;
  font-size: 13px;
}
#cycle-rows > article {
  padding: 16px;
  border: 1px solid var(--line);
  margin: 12px 0;
  border-radius: 6px;
}
#close-cycle {
  margin: 20px 0;
}
#closure-human {
  color: var(--muted);
}
#closure-history {
  display: grid;
  justify-items: start;
}
.data-row {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13px;
}
.data-row span {
  color: var(--muted);
}
.data-row strong {
  text-align: right;
  font-weight: 550;
  overflow-wrap: anywhere;
}
.origin-bar {
  font-size: 12px;
  color: var(--muted);
  margin-top: 20px;
  overflow-wrap: anywhere;
}
.origin-bar > span {
  display: none;
}
footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  color: #758076;
  font-size: 10px;
  margin-top: 35px;
  border-top: 1px solid var(--line);
  padding-top: 16px;
}
@media (min-width: 1450px) {
  main {
    padding: 36px 46px;
  }
  .topbar {
    padding: 0 46px;
  }
}
@media (max-width: 1150px) {
  .workspace {
    grid-template-columns: 1fr;
  }
  .inspector {
    position: static;
    max-width: none;
  }
  .inspector .save-line {
    align-items: center;
  }
  main {
    padding: 24px;
  }
  .topbar {
    padding: 0 24px;
  }
}
@media (max-width: 700px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    width: 100%;
    height: auto;
    padding: 10px 14px;
    display: block;
  }
  .wordmark {
    font-size: 14px;
  }
  .brand-icon {
    width: 26px;
    height: 26px;
    font-size: 22px;
  }
  .mesa-nav {
    display: flex;
    gap: 6px;
    margin-top: 8px;
  }
  .mesa-nav button {
    padding: 8px 10px;
    min-height: 36px;
    font-size: 12px;
    flex: 1;
    text-align: center;
  }
  .mesa-nav button .nav-icon {
    display: none;
  }
  .mesa-nav button .nav-name {
    font-size: 12px;
    white-space: normal;
  }
  .mesa-nav button {
    justify-content: center;
  }
  .nav-label,
  .sidebar-recent,
  .sidebar-bottom {
    display: none;
  }
  .app-content {
    margin-left: 0;
  }
  .topbar {
    height: auto;
    min-height: 45px;
    padding: 10px 18px;
  }
  .demo-tag {
    display: none;
  }
  main {
    padding: 22px 16px;
  }
  h1 {
    font-size: 25px;
  }
  .page-heading {
    gap: 12px;
  }
  .page-heading .primary {
    padding: 8px 10px;
  }
  .page-heading p {
    font-size: 12px;
  }
  .panel {
    padding: 18px;
  }
  .analysis-heading {
    flex-wrap: wrap;
  }
  .analysis-heading h2 {
    font-size: 20px;
  }
  .cycle-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 7px;
  }
  .metric-card {
    padding: 12px 9px;
  }
  .metric-card small {
    font-size: 10px;
  }
  .metric-card strong {
    font-size: 24px;
  }
  .closure-grid {
    grid-template-columns: 1fr;
  }
  .scope-toolbar > details {
    margin-left: 0;
  }
  .catalog-filters input[type="search"],
  .catalog-filters select {
    width: 100%;
    flex-basis: 100%;
    max-width: none;
  }
  .data-row {
    flex-direction: column;
    gap: 5px;
  }
  .data-row strong {
    text-align: left;
  }
  .history-head {
    align-items: flex-start;
  }
  .history-head h3 {
    font-size: 14px;
  }
  .history-head .mini-note {
    font-size: 10px;
  }
  .chart-readout {
    font-size: 10px;
  }
  .chart-axis {
    font-size: 13px;
  }
  #close-drawer {
    padding: 18px;
  }
  footer {
    flex-direction: column;
    gap: 5px;
  }
}

#analysis-view:not(.has-product) #selection-context {
  display: none;
}
.has-product #selection-context > div:first-child {
  display: none;
}
.has-product .analysis-heading {
  margin-top: -6px;
  margin-bottom: 18px;
}
#integral-view .scope-toolbar {
  margin-top: 18px;
  margin-bottom: 16px;
  background: var(--bg);
}

.input-line input {
  width: 100%;
  font-size: 20px;
}

/* Cola contextual del ciclo: conserva el gráfico y editor existentes. */
.pending-list {
  grid-column: 1 / -1;
}
.pending-row {
  display: grid;
  grid-template-columns: minmax(180px, 1fr) minmax(220px, 2fr) auto;
  gap: 5px 18px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
  align-items: center;
}
.pending-row h4 {
  margin: 0;
  font-size: 13px;
}
.pending-row p {
  margin: 0;
  font-size: 12px;
}
.pending-row .source-note {
  grid-column: 1;
}
.pending-row .error {
  grid-column: 2;
  grid-row: 1 / 4;
}
.pending-row button {
  grid-column: 3;
  grid-row: 1 / 4;
}
.review-context {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 24px;
  padding: 16px 20px;
}
.review-context span,
.cycle-context {
  font-size: 12px;
  color: var(--muted);
}
.queue-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 10px;
}
#blocked-decision {
  max-width: 760px;
  margin: 20px 0;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
#blocked-decision textarea {
  width: 100%;
}
@media (max-width: 700px) {
  .pending-row {
    display: block;
  }
  .pending-row p {
    margin: 6px 0;
  }
  .pending-row button {
    margin-top: 8px;
  }
  .review-context {
    display: block;
  }
  .review-context span {
    display: block;
    margin-top: 8px;
  }
}

/* Procedencia y causas deben envolver identificadores sin desplazar la página. */
#blocked-product,
.source-strip,
.analysis-heading,
.analysis-space {
  min-width: 0;
  overflow-wrap: anywhere;
}
#product-origin-hash,
#source-note,
#blocked-cut,
#exclusion-state {
  overflow-wrap: anywhere;
  word-break: break-word;
}

/* Contextual resolution reuses the existing analysis and chart. */
#pending-modal {
  width: min(1100px, calc(100vw - 32px));
  max-height: 90vh;
  overflow: auto;
  border: 1px solid #dbe3df;
  border-radius: 18px;
  padding: 24px;
  color: inherit;
}
#pending-modal::backdrop {
  background: #172d2780;
}
#pending-modal .workspace {
  grid-template-columns: minmax(0, 1.5fr) minmax(260px, 1fr);
}
#pending-modal .source-strip {
  margin-top: 20px;
}
#pending-modal #back-summary {
  display: none;
}
#pending-modal .analysis-heading {
  margin-top: 16px;
}
#overview-products {
  padding-bottom: 28px;
  margin-bottom: 28px;
  border-bottom: 1px solid #dbe3df;
}
.pending-row[role="button"] {
  cursor: pointer;
}
.pending-row[role="button"]:hover,
.pending-row[role="button"]:focus-visible {
  background: #f4f8f6;
  outline: 2px solid #1e725b;
  outline-offset: 2px;
}
.correction-row {
  border-top: 1px solid #dbe3df;
  padding: 16px 0;
  margin-top: 12px;
}
.correction-row label,
.communication-panel label {
  display: block;
  margin: 12px 0;
}
.correction-row input,
.communication-panel textarea {
  display: block;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
}
.communication-panel {
  margin-top: 24px;
  padding-top: 20px;
  border-top: 1px solid #dbe3df;
}
.communication-panel pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.sidebar-bottom #view-data {
  display: block;
  margin-bottom: 20px;
}
@media (max-width: 700px) {
  #pending-modal {
    padding: 16px;
  }
  #pending-modal .workspace {
    grid-template-columns: minmax(0, 1fr);
  }
  #pending-modal .section-head {
    flex-wrap: wrap;
  }
}

.closure-grid article > small {
  display: block;
  margin-bottom: 8px;
}
.closure-grid article > .text-button {
  display: block;
  text-align: left;
  padding: 0;
  font-size: 15px;
  line-height: 1.5;
}
.sidebar-bottom #view-data {
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}
#pending-modal > .section-head {
  position: sticky;
  top: -24px;
  z-index: 5;
  background: white;
  padding: 12px 0;
}
@media (max-width: 700px) {
  #pending-modal > .section-head {
    top: -16px;
  }
}

/* M21 delta: first screen prioritizes the datum and its action. */
#pending-modal > .section-head {
  margin-bottom: 8px;
  padding: 4px 0 8px;
}
#pending-modal > .section-head h2 {
  font-size: 15px;
  margin: 0;
}
#pending-message:empty {
  display: none;
}
#pending-message {
  margin: 4px 0 8px;
}
#pending-modal .analysis-heading {
  margin: 0 0 8px;
  padding: 0;
}
#pending-modal .analysis-heading .eyebrow {
  display: none;
}
#pending-modal .analysis-heading h2 {
  font-size: 20px;
  margin: 0;
}
#pending-modal #selection-hint {
  margin: 2px 0 0;
  font-size: 12px;
}
#pending-modal .review-context {
  border: 0;
  border-radius: 0;
  padding: 0;
  margin: 0 0 12px;
  gap: 4px 16px;
}
#pending-modal .review-context .queue-actions {
  margin: 0 0 0 auto;
}
#pending-modal .review-context #queue-period {
  display: none;
}
#pending-modal #correction-panel {
  padding: 16px;
  margin: 0 0 12px;
}
#pending-modal #correction-panel h3 {
  font-size: 16px;
  margin: 0 0 8px;
}
#pending-modal .correction-row {
  padding: 12px 0;
  margin: 0;
}
#pending-modal .correction-row:first-of-type {
  border-top: 0;
  padding-top: 0;
}
#pending-modal .correction-row h4 {
  margin: 0;
  font-size: 14px;
}
#pending-modal .correction-row > p {
  margin: 2px 0 8px;
  font-size: 12px;
}
#pending-modal .correction-fields {
  display: grid;
  grid-template-columns: minmax(140px, 0.7fr) minmax(160px, 1fr) minmax(180px, 1.2fr);
  gap: 12px;
}
#pending-modal .correction-fields label {
  margin: 0 0 10px;
  font-size: 12px;
}
#pending-modal #blocked-decision {
  margin: 0 0 12px;
  padding-top: 0;
  border: 0;
}
#pending-modal #blocked-decision > p {
  margin: 0 0 8px;
}
#pending-modal .source-strip #blocked-product {
  border: 0;
  box-shadow: none;
  padding: 12px 0;
  margin: 0;
}
#pending-modal .source-strip #blocked-product h2 {
  font-size: 15px;
  margin: 0 0 8px;
}
@media (max-width: 700px) {
  #pending-modal .review-context {
    display: flex;
  }
  #pending-modal .review-context .queue-actions {
    margin-left: 0;
  }
  #pending-modal .correction-fields {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
  }
  #pending-modal .analysis-heading h2 {
    font-size: 17px;
  }
  #pending-modal #correction-panel {
    padding: 12px;
  }
  #pending-modal > .section-head {
    flex-wrap: nowrap;
    gap: 8px;
  }
}
#pending-modal #queue-progress {
  font-size: 19px;
  font-weight: 750;
  color: var(--green);
}
#pending-modal #queue-remaining {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
#pending-modal .review-context {
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
}
#pending-modal .correction-row > .primary {
  min-height: 40px;
  font-weight: 650;
}
#pending-complete {
  margin: 12px 0 0;
  padding: 20px;
  background: var(--green-soft);
}
#pending-complete h2 {
  font-size: 23px;
  margin: 0 0 12px;
}
.handoff-stage {
  margin: 0 0 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 20px;
  background: var(--green-soft);
}
.handoff-stage h3 {
  font-size: 23px;
  margin: 4px 0 8px;
}
.handoff-stage > p {
  margin: 6px 0;
}
.handoff-stage .queue-actions {
  margin: 16px 0 12px;
}
.handoff-stage > details {
  margin-top: 12px;
}
.handoff-stage .prepared-content {
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.handoff-stage .prepared-content p {
  overflow-wrap: anywhere;
}
@media (max-width: 700px) {
  #pending-modal #queue-progress {
    font-size: 19px;
  }
  #pending-modal .review-context {
    gap: 4px 12px;
  }
  #pending-modal #queue-remaining {
    margin: 0;
  }
  .handoff-stage {
    padding: 16px;
  }
  .handoff-stage h3 {
    font-size: 21px;
  }
  .handoff-stage .queue-actions > button {
    width: 100%;
  }
}
#cycle-rows > #close-cycle {
  margin: 4px 0 20px;
  min-height: 40px;
}
#close-drawer > #closure-human {
  margin-bottom: 8px;
}
#close-drawer > #dismiss-close {
  margin-bottom: 12px;
}

/* One persistent header keeps position and identity together while the body scrolls. */
#pending-modal {
  scroll-padding-top: calc(var(--pending-header-height, 180px) + 8px);
}
#pending-header {
  position: sticky;
  top: -24px;
  z-index: 10;
  background: white;
  padding-top: 4px;
  margin-bottom: 8px;
}
#pending-header > .section-head {
  position: static;
  padding: 4px 0 8px;
  margin-bottom: 8px;
}
#pending-header > .section-head h2 {
  font-size: 15px;
  margin: 0;
}
#pending-header .analysis-heading {
  padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 700px) {
  #pending-header {
    top: -16px;
  }
  #pending-header > .section-head {
    flex-wrap: nowrap;
    gap: 8px;
  }
}

.journey {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 0 0 24px;
}
.journey a {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted, #61716d);
  text-decoration: none;
  padding: 5px 8px;
}
.journey span {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  border: 1px solid currentColor;
  border-radius: 50%;
}
.journey [aria-current] {
  color: #176b55;
  font-weight: 700;
}
.journey [aria-current] span {
  background: #176b55;
  color: white;
}
.demo-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin: 20px 0;
}
.demo-form label,
#commercial-view label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
}
.demo-form input,
#commercial-view textarea {
  width: 100%;
  box-sizing: border-box;
}
#commercial-view pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.commercial-history details {
  border: 1px solid #dce5e0;
  border-radius: 10px;
  padding: 14px;
  margin: 12px 0;
}
.button-link {
  display: inline-block;
  padding: 10px 14px;
  margin: 12px 0;
  text-decoration: none;
}
@media (max-width: 600px) {
  .demo-form {
    grid-template-columns: 1fr;
  }
  .journey {
    gap: 2px;
  }
  .journey a {
    font-size: 12px;
    padding: 4px;
    gap: 4px;
  }
  .journey span {
    width: 22px;
    height: 22px;
  }
}
#view-setup {
  color: #e7efe9;
  justify-content: flex-start;
  margin-top: 6px;
}
.topbar .demo-tag {
  display: flex;
  align-items: center;
  gap: 6px;
}
.demo-tag select {
  width: auto;
  padding: 5px;
  font-size: 12px;
}
@media (max-width: 700px) {
  #view-setup {
    position: absolute;
    right: 14px;
    top: 8px;
    margin: 0;
    font-size: 11px;
  }
  .topbar {
    flex-wrap: wrap;
    gap: 8px;
  }
  .topbar .demo-tag {
    font-size: 10px;
  }
}
.commercial-metrics {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.commercial-metrics article {
  padding: 12px;
}
#commercial-view details {
  margin: 14px 0;
}
#commercial-view .queue-actions {
  margin: 12px 0 20px;
}
@media (max-width: 600px) {
  .commercial-metrics h3 {
    font-size: 19px;
  }
  .commercial-metrics small {
    font-size: 11px;
  }
}
#commercial-view .panel > a {
  display: inline-block;
  margin: 8px 14px 8px 0;
}
.commercial-history details a {
  display: block;
  margin: 10px 0 4px;
}
.commercial-history small {
  display: block;
  overflow-wrap: anywhere;
}

/* M27: M26 preparation layout, scoped to preserve the M22 review/editor. */
.preparation {
  color: #243830;
  font-size: 14px;
  line-height: 1.5;
}
.preparation h2 {
  font-size: 18px;
  margin: 0 0 10px;
}
.preparation h3 {
  font-size: 15px;
  margin: 22px 0 8px;
}
.preparation p {
  margin: 4px 0 14px;
}
.preparation .muted,
.preparation small,
.preparation .note {
  color: #64716b;
}
.preparation .note,
.preparation label {
  font-size: 12px;
}
.preparation .panel {
  border: 1px solid #dce2da;
  border-radius: 11px;
  padding: 23px;
  margin-bottom: 20px;
  background: white;
}
.preparation button {
  min-height: 42px;
  padding: 10px 14px;
  border: 1px solid #dce2da;
  border-radius: 7px;
  background: white;
  color: #243830;
  font-weight: 600;
  cursor: pointer;
}
.preparation button:hover {
  border-color: #7f9b8d;
  background: #f4f8f2;
}
.preparation button:disabled {
  opacity: 0.48;
  cursor: not-allowed;
}
.preparation button.primary {
  background: #173f34;
  color: white;
  border-color: #173f34;
}
.preparation .eyebrow {
  font-size: 10px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: #64716b;
  margin: 0 0 6px;
}
.preparation .prep-steps {
  display: flex;
  gap: 24px;
  margin: 0 0 24px;
  color: #64716b;
  font-size: 12px;
}
.prep-steps div {
  display: flex;
  gap: 5px;
  align-items: center;
}
.prep-steps div span:first-child {
  display: inline-grid;
  place-items: center;
  border: 1px solid #dce2da;
  border-radius: 50%;
  width: 23px;
  height: 23px;
}
.prep-steps .current {
  color: #173f34;
  font-weight: 700;
}
.prep-steps .current span:first-child {
  background: #173f34;
  color: white;
}
.prep-source,
.prep-row,
.prep-run {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
}
.prep-source .source-actions {
  flex-shrink: 0;
}
.prep-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(290px, 0.9fr);
  gap: 22px;
  align-items: start;
}
.prep-preview {
  position: sticky;
  top: 20px;
}
.prep-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid #dce2da;
  margin: 16px 0 10px;
}
.preparation .prep-tabs button {
  border: 0;
  border-radius: 0;
  background: transparent;
  font-size: 12px;
}
.preparation .prep-tabs button.active {
  border-bottom: 2px solid #173f34;
  color: #173f34;
}
.prep-cards {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}
.preparation .prep-template {
  display: flex;
  text-align: left;
  width: 100%;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
}
.preparation .prep-template[aria-pressed="true"] {
  border: 2px solid #173f34;
  padding: 15px;
  background: #f5f9f3;
}
.prep-radio {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  border: 1px solid #a8b8ae;
  border-radius: 50%;
  margin-top: 3px;
}
.prep-template[aria-pressed="true"] .prep-radio {
  border: 5px solid #173f34;
}
.prep-template strong,
.prep-template small,
.preparation .check small {
  display: block;
}
.prep-template small {
  font-weight: 400;
  margin-top: 3px;
}
.prep-star {
  margin-left: auto;
  color: #a97327;
}
.prep-badge {
  display: inline-block;
  background: #edf4ed;
  color: #173f34;
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 11px;
}
.prep-scope {
  padding: 14px 0;
  border-bottom: 1px solid #dce2da;
  margin-bottom: 16px;
}
.prep-count {
  font-size: 34px;
  line-height: 1.2;
  letter-spacing: -1px;
}
.prep-chips {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0;
}
.prep-chips span {
  background: #f4f6f2;
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 12px;
}
.preparation label {
  display: block;
  font-weight: 600;
  margin-top: 14px;
}
.preparation select,
.preparation input:not([type="checkbox"]) {
  display: block;
  width: 100%;
  padding: 10px;
  border: 1px solid #cbd5cd;
  border-radius: 6px;
  background: white;
  color: #243830;
  margin-top: 6px;
  min-height: 42px;
  font: inherit;
}
.preparation .prep-full {
  width: 100%;
  margin-top: 16px;
}
.prep-product-list {
  padding: 0;
  list-style: none;
  margin: 10px 0;
  max-height: 240px;
  overflow: auto;
}
.prep-product-list li {
  padding: 9px 0;
  border-bottom: 1px solid #edf0eb;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}
.preparation .dialoghead {
  padding: 22px 24px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid #dce2da;
}
.preparation .dialogbody {
  padding: 22px 24px;
  overflow: auto;
}
.preparation .dialogfoot {
  padding: 16px 24px;
  border-top: 1px solid #dce2da;
  background: #f8faf6;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}
.preparation .checks {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 20px;
}
.preparation .check {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border: 1px solid #dce2da;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 400;
  margin: 0;
}
.preparation .check input {
  accent-color: #173f34;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}
.preparation .checks.products {
  max-height: 210px;
  overflow: auto;
}
.preparation .editpreview {
  background: #edf4ed;
  padding: 12px;
  border-radius: 7px;
  margin-top: 16px;
}
#segmentation-editor {
  width: min(760px, calc(100% - 32px));
  max-height: 90vh;
  padding: 0;
}
.prep-run {
  padding: 18px;
  border: 1px solid #dce2da;
  border-radius: 8px;
  margin-top: 12px;
}
.prep-run h3 {
  margin: 0 0 8px;
}
@media (max-width: 760px) {
  .prep-layout {
    display: block;
  }
  .prep-preview {
    position: static;
  }
  .prep-source,
  .prep-run {
    display: block;
  }
  .prep-source .source-actions {
    margin-top: 14px;
  }
  .preparation .panel {
    padding: 18px;
    margin-bottom: 16px;
  }
  .preparation .checks {
    grid-template-columns: 1fr;
  }
  .preparation .dialoghead,
  .preparation .dialogbody,
  .preparation .dialogfoot {
    padding: 16px;
  }
  .prep-run a {
    margin-top: 12px;
  }
}

/* M28 reuses the existing palette and panel hierarchy. */
#preparation-progress {
  margin-bottom: 1.5rem;
}
#preparation-progress progress {
  width: 100%;
  height: 0.65rem;
  accent-color: var(--accent, #196c66);
}
.cause-card {
  border-bottom: 1px solid #dce3e1;
  padding: 1rem 0;
  overflow-wrap: anywhere;
}
.cause-card > button {
  text-align: left;
  font-size: 1.05rem;
}
/* Native dialog surface: viewport-centered; only the body scrolls. */
#cause-modal {
  position: fixed;
  inset: 0;
  margin: auto;
  width: min(720px, calc(100vw - 48px));
  max-width: none;
  max-height: min(820px, calc(100dvh - 48px));
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fff;
  color: var(--ink);
  box-shadow:
    0 24px 80px rgb(10 30 22 / 28%),
    0 4px 16px rgb(10 30 22 / 12%);
}
#cause-modal[open] {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}
#cause-modal::backdrop {
  background: rgb(12 29 23 / 58%);
  backdrop-filter: blur(3px);
}
#cause-modal .dialoghead {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 40px;
  align-items: start;
  gap: 20px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid var(--line);
  background: #fff;
}
#cause-modal h2 {
  margin: 4px 0 0;
  font-size: 22px;
  line-height: 1.25;
  letter-spacing: -0.02em;
  overflow-wrap: anywhere;
}
#cause-modal .cause-close {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
}
#cause-modal .cause-close:hover:not(:disabled) {
  background: var(--green-soft);
  color: var(--green);
}
#cause-modal .cause-close svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}
#cause-modal .dialogbody {
  min-height: 0;
  min-width: 0;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding: 20px 24px 24px;
}
#cause-modal .cause-summary {
  margin-bottom: 22px;
}
#cause-effect {
  margin: 0 0 8px;
  color: var(--green);
  font-size: 16px;
  font-weight: 650;
}
#cause-action {
  margin: 0;
  color: var(--muted);
}
#cause-modal label {
  display: block;
  margin: 16px 0 6px;
  font-weight: 600;
}
#cause-form > label:first-child {
  margin-top: 0;
}
#cause-modal textarea,
#cause-modal select,
#cause-search {
  display: block;
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
  margin-top: 6px;
  border: 1px solid #cbd5cd;
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 400;
}
#cause-modal textarea {
  resize: vertical;
  min-height: 82px;
  max-height: 240px;
}
#cause-consequence {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
}
#cause-modal .cause-confirmation {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0 20px;
  font-size: 13px;
  font-weight: 400;
}
#cause-confirm {
  flex: 0 0 auto;
  margin: 3px 0 0;
  accent-color: var(--green);
}
#cause-evidence,
#cause-population {
  border-top: 1px solid var(--line);
  padding: 12px 0;
}
#cause-modal summary {
  color: var(--green);
  font-weight: 550;
}
#cause-origin {
  margin: 12px 0 8px;
}
#cause-samples .cause-sample {
  padding: 10px 0;
}
#cause-samples h3 {
  margin: 0 0 6px;
  font: 600 12px/1.4 var(--sans);
  color: var(--muted);
}
#cause-samples ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
#cause-samples li {
  display: grid;
  grid-template-columns: 70px 100px minmax(0, 1fr);
  gap: 8px;
  margin: 6px 0;
  color: var(--muted);
  font-size: 12px;
}
#cause-samples code {
  font-size: 11px;
  overflow-wrap: anywhere;
}
#cause-members {
  max-height: 16rem;
  overflow-y: auto;
  margin-top: 10px;
}
#cause-members button {
  display: block;
  width: 100%;
  text-align: left;
  overflow-wrap: anywhere;
  padding: 9px 0;
  border-bottom: 1px solid #edf0eb;
}
#cause-validation:empty {
  display: none;
}
#cause-validation {
  margin-top: 14px;
  color: var(--muted);
  font-size: 12px;
}
#cause-validation h3 {
  font-size: 14px;
  color: var(--green);
}
#cause-modal .dialogfoot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 16px 24px;
  border-top: 1px solid var(--line);
  background: #f8faf7;
}
#cause-save {
  flex: 0 0 auto;
}
#cause-error {
  flex: 1;
  min-width: 0;
  max-height: 4.5em;
  overflow: auto;
  margin: 0;
  color: var(--red);
  font-size: 13px;
}
#cause-error:empty {
  display: none;
}
#cause-effect,
#cause-action,
#cause-consequence,
#cause-origin,
#cause-samples,
#cause-validation,
#cause-error {
  overflow-wrap: anywhere;
}
@media (max-width: 600px) {
  #cause-modal {
    width: calc(100vw - 24px);
    max-height: calc(100dvh - 24px);
    border-radius: 12px;
  }
  #cause-modal .dialoghead {
    padding: 16px;
    gap: 12px;
  }
  #cause-modal h2 {
    font-size: 20px;
  }
  #cause-modal .dialogbody {
    padding: 16px;
  }
  #cause-modal .dialogfoot {
    padding: 12px 16px;
    gap: 10px;
    flex-direction: column;
    align-items: stretch;
  }
  #cause-samples li {
    grid-template-columns: 70px minmax(0, 1fr);
  }
  #cause-samples li > span:last-child {
    grid-column: 1 / -1;
  }
}

.sidebar-bottom #view-data {
  display: flex;
  align-items: center;
  gap: 8px;
}

.demo-status { font-size: 11px; line-height: 1.5; margin: 8px 0; }
#demo-reset { color: inherit; font-size: 11px; padding: 4px 8px; margin-bottom: 8px; }
#demo-preview { max-width: min(850px, 94vw); }
#demo-preview pre { white-space: pre-wrap; overflow-wrap: anywhere; }
