/* Shared operational surfaces. The approved PnL remains the visual authority:
   its data table, fonts, frames and controls are deliberately excluded below. */
.portal-screen,
.portal-auth {
  --bg: #e7e9ee;
  --panel: #fff;
  --text: #242539;
  --muted: #646577;
  --line: #dcdfe7;
  --accent: #545fdc;
  --row-alt: #f7f8fb;
  --row-accent: #f0f6f2;
  --portal-control-radius: 9px;
  --portal-panel-radius: 12px;
  --portal-control-height: 36px;
  --portal-table-width: 1760px;
  --portal-form-width: 1040px;
  --portal-chart-width: 1000px;
  --portal-type-page: 18px;
  --portal-type-section: 15px;
  --portal-type-subgroup: 14px;
  --portal-type-data: 13px;
  --portal-type-caption: 12px;
  --portal-type-metric: 20px;
  --portal-type-answer: 26px;
}

.portal-screen:not(.portal-pnl) .sg-main {
  font-size: var(--portal-type-data);
  line-height: 1.5;
  font-weight: 500;
  overflow-wrap: anywhere;
}

.portal-screen:not(.portal-pnl) .sg-main :where(h1, h2, h3) {
  color: var(--text);
  overflow-wrap: anywhere;
}
.portal-screen:not(.portal-pnl) .sg-main h1 {
  font-size: var(--portal-type-page);
  font-weight: 800;
  letter-spacing: -.02em;
  line-height: 1.4;
}
.portal-screen:not(.portal-pnl) .sg-main h2 {
  margin: 24px 0 10px;
  font-size: var(--portal-type-section);
  font-weight: 750;
  line-height: 1.4;
}
.portal-screen:not(.portal-pnl) .sg-main h3 {
  font-size: var(--portal-type-subgroup);
  font-weight: 700;
  line-height: 1.45;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.panel, .card) {
  min-width: 0;
  border-radius: var(--portal-panel-radius);
  border-color: var(--line);
  background: var(--panel);
}
.portal-screen:not(.portal-pnl) .sg-main .panel {
  padding: 18px 20px;
  margin-bottom: 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .panel > :first-child {
  margin-top: 0;
}
.portal-screen:not(.portal-pnl) .sg-main .panel > :last-child {
  margin-bottom: 0;
}
.portal-screen:not(.portal-pnl) .sg-main .panel--inner {
  padding: 12px 14px;
  background: var(--row-alt);
}
.portal-screen:not(.portal-pnl) .sg-main .panel--accent {
  border-color: var(--accent);
}
.portal-screen:not(.portal-pnl) .sg-main .panel--warn {
  border-color: #e8d4a6;
  background: #fffdf7;
}

/* Existing classes stay intact: forms retain names, endpoints, submission
   behavior and compact input widths inside operational tables. */
.portal-screen:not(.portal-pnl) .sg-main .month-nav {
  gap: 10px 14px;
  align-items: center;
  margin-bottom: 14px;
}
.portal-screen:not(.portal-pnl) .sg-main .month-nav h1 {
  min-width: 0;
}
.portal-screen:not(.portal-pnl) .sg-main .month-nav .hint {
  font-size: 12px;
  line-height: 1.5;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.filters, .cs-bar, .cs-tools, .add-row, .ship-point) {
  gap: 8px 12px;
}
.portal-screen:not(.portal-pnl) .sg-main .filters {
  margin-bottom: 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr));
  gap: 14px 18px;
  margin-top: 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid :where(label, .ship-point__field) {
  gap: 7px;
  color: #555a6b;
  font-size: 12px;
  font-weight: 600;
  min-width: 0;
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid h2 {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid label > :where(input:not([type="checkbox"]):not([type="radio"]), select, textarea) {
  width: 100%;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input, select, textarea) {
  max-width: 100%;
  border: 1px solid #cfd4df;
  border-radius: var(--portal-control-radius);
  padding: 8px 10px;
  background: #fff;
  color: var(--text);
  font: 500 13px/1.45 Manrope, 'Segoe UI', sans-serif;
  caret-color: var(--accent);
  font-variant-numeric: tabular-nums;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input:not([type="checkbox"]):not([type="radio"]):not([type="hidden"]), select) {
  min-height: var(--portal-control-height);
}
.portal-screen:not(.portal-pnl) .sg-main textarea {
  min-height: 88px;
  resize: vertical;
}
.portal-screen:not(.portal-pnl) .sg-main input[type="file"] {
  padding: 5px 8px;
}
.portal-screen:not(.portal-pnl) .sg-main input[type="file"]::file-selector-button {
  margin-right: 10px;
  padding: 5px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--row-alt);
  color: var(--text);
  font: inherit;
  cursor: pointer;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input[type="checkbox"], input[type="radio"]) {
  width: 15px;
  height: 15px;
  min-height: 0;
  padding: 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input, textarea)::placeholder {
  color: #6c7080;
  opacity: 1;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input, select, textarea):disabled {
  color: #757988;
  background: #f1f3f7;
  cursor: not-allowed;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input, select, textarea)[readonly] {
  background: #f7f8fb;
}
.portal-screen:not(.portal-pnl) .sg-main :where(input, select, textarea)[aria-invalid="true"] {
  border-color: var(--out);
}
.portal-screen:not(.portal-pnl) .sg-main .check {
  gap: 7px;
  color: #555a6b;
  font-size: 12px;
  font-weight: 500;
}
.portal-screen:not(.portal-pnl) .sg-main .form-grid .check {
  color: var(--text);
}
.portal-screen:not(.portal-pnl) .sg-main .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--portal-control-height);
  border-radius: var(--portal-control-radius);
  padding: 7px 12px;
  font: 650 12px/1.4 Manrope, 'Segoe UI', sans-serif;
  text-align: center;
  text-decoration: none;
  vertical-align: middle;
  transition: transform 120ms cubic-bezier(.23, 1, .32, 1);
}
.portal-screen:not(.portal-pnl) .sg-main .btn:active:not(:focus-visible) {
  transform: scale(.98);
}
.portal-screen:not(.portal-pnl) .sg-main .btn:focus-visible {
  transition: none;
}
.portal-screen:not(.portal-pnl) .sg-main .btn--ghost {
  color: #4c5162;
  border-color: #d5d9e3;
  background: #fff;
}
.portal-screen:not(.portal-pnl) .sg-main .btn--danger {
  color: var(--out);
  border-color: #e8c8c1;
  background: #fff;
}
.portal-screen:not(.portal-pnl) .sg-main .btn:disabled {
  cursor: not-allowed;
  opacity: .55;
  transform: none;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.tag, .step, .cs-chip, .col-menu__btn) {
  font-family: inherit;
  min-height: 27px;
  padding: 4px 9px;
  font-size: 11px;
  font-weight: 600;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.step--active, .tag--on) {
  border-color: var(--accent);
}
.portal-screen:not(.portal-pnl) .sg-main .steps {
  flex-wrap: wrap;
  gap: 6px;
}
.portal-screen:not(.portal-pnl) .sg-main .step--active {
  background: var(--accent);
  color: #fff;
}
.portal-screen:not(.portal-pnl) .sg-main .tag--on {
  background: #eef0ff;
  color: #3d47ac;
}

/* Staff actions must stay readable on narrow screens; the existing wrapper
   handles horizontal scrolling without changing table or form semantics. */
.portal-screen:not(.portal-pnl) .sg-main .portal-users-table {
  min-width: 1120px;
  overflow-wrap: normal;
}

/* All data grids scroll within their own surface. Do not change table display
   or semantic column alignment: sticky headers, sorting and drag tools rely on it. */
.portal-screen:not(.portal-pnl) .sg-main :where(.portal-table-wrap, .table-wrap, .matrix-wrap, .fn-scroll, .cs-scroll) {
  min-width: 0;
  max-width: 100%;
  overflow-x: auto;
  overscroll-behavior-x: contain;
}
.portal-screen:not(.portal-pnl) .sg-main .portal-table-wrap {
  margin: 10px 0;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table) {
  font-size: 13px;
  font-weight: 400;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table) th {
  padding: 8px 9px;
  color: #555a6b;
  background: #f6f7fa;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.45;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table) td {
  padding: 7px 9px;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list .btn, .row-actions .btn) {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 11px;
  border-radius: 7px;
}
.portal-screen:not(.portal-pnl) .sg-main .list :where(input:not([type="checkbox"]):not([type="radio"]), select) {
  min-height: 29px;
  padding: 4px 7px;
  font-size: var(--portal-type-data);
  border-radius: 6px;
}
.portal-screen:not(.portal-pnl) .sg-main .cs-table td {
  padding: 5px 7px;
  font-size: var(--portal-type-data);
}
.portal-screen:not(.portal-pnl) .sg-main .cs-table th {
  padding: 7px;
}
.portal-screen:not(.portal-pnl) .sg-main .cs-table :where(.cs-sel, .cs-tick) {
  min-height: 24px;
  font-size: var(--portal-type-caption);
}
.portal-screen:not(.portal-pnl) .sg-main .list th.num,
.portal-screen:not(.portal-pnl) .sg-main .list td.num {
  text-align: right;
}
.portal-screen:not(.portal-pnl) .sg-main .matrix .sticky {
  background: #fff;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.eco-menu, .cv-menu, .legend, .calc-how) {
  border-color: var(--line);
  border-radius: var(--portal-control-radius);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.eco-menu, .cv-menu, .legend, .calc-how) > summary {
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 650;
}
.portal-screen:not(.portal-pnl) .sg-main .col-menu__list {
  border-radius: 12px;
  box-shadow: 0 8px 20px #24253914;
}

/* Report summaries are compact groups, not a second layer of hero cards. */
.portal-screen:not(.portal-pnl) .sg-main .summary {
  gap: 18px 28px;
  margin-top: 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .stat__label {
  font-size: 12px;
  font-weight: 550;
}
.portal-screen:not(.portal-pnl) .sg-main .stat__value {
  font-size: 20px;
  font-weight: 750;
  line-height: 1.4;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-facts, .cs-facts) {
  gap: 12px;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-fact, .cs-fact) {
  border-radius: 10px;
  padding: 12px 14px;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-fact .v, .cs-fact .v) {
  font-size: 20px;
  font-weight: 750;
}
.portal-screen:not(.portal-pnl) .sg-main .cards {
  gap: 14px;
}
.portal-screen:not(.portal-pnl) .sg-main .card {
  padding: 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .card--red {
  border-left-color: #d03b3b;
}
.portal-screen:not(.portal-pnl) .sg-main .card--amber {
  border-left-color: #e8a317;
}
.portal-screen:not(.portal-pnl) .sg-main .card--planned {
  border-left-color: var(--in);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.card__name, .card__main) {
  font-weight: 700;
}
.portal-screen:not(.portal-pnl) .sg-main .fn-tabs {
  gap: 4px 8px;
  margin: 14px 0 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .fn-tab {
  padding: 9px 11px;
  font-size: 12px;
  font-weight: 600;
}
.portal-screen:not(.portal-pnl) .sg-main .fn-tab--on {
  color: #3d47ac;
  border-bottom-color: var(--accent);
  font-weight: 750;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-panel, .cv-panel, .fn-form) {
  border-radius: 10px;
  padding: 12px 14px;
}
.portal-screen:not(.portal-pnl) .sg-main .fn-table tr.fn-section td {
  color: #303969;
  background: #eef0ff;
}
.portal-screen:not(.portal-pnl) .sg-main .fn-table tr.fn-total td {
  border-color: #aeb6dd;
  background: #f2f4fd;
}
.portal-screen:not(.portal-pnl) .sg-main .hint {
  line-height: 1.55;
}
.portal-screen:not(.portal-pnl) .sg-main :where(p.hint, .fn-explain, .formula, .note) {
  max-width: 78ch;
}
.portal-screen:not(.portal-pnl) .sg-main .hint.wide {
  max-width: none;
}
.portal-screen:not(.portal-pnl) .sg-main .empty {
  padding: 10px 0;
  color: #646577;
  font-size: 13px;
  line-height: 1.65;
}
.portal-screen:not(.portal-pnl) .sg-main .toast {
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 550;
}

/* Calculator: preserve the fields and live answer composition while sharing
   the portal's surface/selection language. */
.portal-screen:not(.portal-pnl) .sg-main :where(.answer__box, .td-answer, .calc-how) {
  border-color: #d4d9eb;
  border-radius: var(--portal-panel-radius);
  box-shadow: none;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.answer__main, .td-answer__main) {
  background: #f2f4ff;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.answer__value, .td-answer__value) {
  font-size: var(--portal-type-answer);
  font-weight: 800;
  letter-spacing: -.02em;
}
.portal-screen:not(.portal-pnl) .sg-main .card--main {
  border-color: #ccd2ee;
  box-shadow: none;
}
.portal-screen:not(.portal-pnl) .sg-main .fld__name {
  color: #555a6b;
  font-weight: 600;
  gap: 7px;
}
.portal-screen:not(.portal-pnl) .sg-main .fold > summary {
  padding: 12px 16px;
}
.portal-screen:not(.portal-pnl) .sg-main .calcbar {
  padding: 12px 16px;
  border-radius: var(--portal-panel-radius);
  border-color: var(--line);
  box-shadow: none;
}
.portal-screen:not(.portal-pnl) .sg-main .calcbar--stale {
  border-color: #e8d4a6;
  background: #fffaf0;
}
.portal-screen:not(.portal-pnl) .sg-main .cs-bulk {
  border-color: var(--accent);
  background: #eef0ff;
}

/* Section-specific instructions and nearby explanations use the same note
   vocabulary as PnL. The original explanatory nodes remain in the DOM. */
.portal-help-trigger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 20px;
  width: 20px;
  height: 20px;
  min-height: 20px;
  padding: 0;
  margin: 0 0 0 5px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #747a8b;
  vertical-align: middle;
  cursor: help;
}
.portal-field-caption { display:inline; }
.portal-password { width:100%; max-width:none; margin:0; }
.portal-password .login__brand { font-size:18px; font-weight:800; text-align:left; }
.portal-password form.panel { display:flex; flex-direction:column; gap:10px; }
.portal-screen:not(.portal-pnl) .sg-main .portal-password form.panel > :where(input, label, button, .toast) { max-width:420px; }
.portal-password .login__label { font-size:12px; font-weight:650; color:#555a6b; }
.portal-password .login__back { text-align:left; }
.portal-help-trigger svg {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
  stroke-width: 1.8;
}
.portal-help-trigger[aria-expanded="true"] {
  color: var(--accent);
  background: #eef0ff;
}
.portal-help-popover {
  position: fixed;
  z-index: 1180;
  width: 360px;
  max-width: calc(100vw - 24px);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  overscroll-behavior: contain;
  padding: 14px 16px;
  border: 1px solid #d7dbe5;
  border-radius: 12px;
  background: #fbfcff;
  color: #555a6b;
  font: 500 13px/1.6 Manrope, 'Segoe UI', sans-serif;
  overflow-wrap: anywhere;
  transform-origin: var(--popover-origin, top left);
}
.portal-help-popover h3 {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 750;
  color: #242539;
}
.portal-help-popover :where(p, ul, ol, dl) {
  margin: 0 0 8px;
}
.portal-help-popover :last-child {
  margin-bottom: 0;
}
.portal-help-popover :where(.hint, .note, .formula, .portal-help-content) {
  color: inherit;
  font: inherit;
}
.portal-help-popover a,
.portal-instruction-content a {
  color: #414dac;
  text-underline-offset: 3px;
}
.portal-instruction-content {
  font-size: 13px;
  line-height: 1.7;
  font-weight: 500;
}
.portal-instruction-content :where(p, li, dd) {
  max-width: 74ch;
  overflow-wrap: anywhere;
}
.portal-instruction-content h3 {
  margin: 22px 0 8px;
  color: var(--sg-ink);
  font-size: 14px;
  font-weight: 750;
}
.portal-instruction-content :where(.hint, .note, .formula, .fn-explain) {
  color: #555a6b;
  font: inherit;
  max-width: 74ch;
}
.portal-instruction-content :where(.panel, .legend, .calc-how) {
  margin: 12px 0;
  padding: 0;
  background: transparent;
  border: 0;
  border-radius: 0;
}
.portal-instruction-content :where(.legend__body, .legend__list, .calc-how__body) {
  padding: 0;
  font: inherit;
}
.portal-instruction-content :where(code, .fn-code) {
  padding: 2px 5px;
  border-radius: 4px;
  background: #f0f2f7;
  color: #3d4354;
  font-size: 12px;
}
.portal-instruction-content :where(ul, ol) {
  padding-left: 20px;
}
.portal-instruction-content dt {
  margin-top: 14px;
  color: #34394b;
  font-weight: 700;
}
.portal-instruction-content dd {
  margin: 4px 0 12px;
}

/* Authentication is part of the same system, without a misleading business
   navigation before the user is authenticated. */
body.portal-auth {
  margin: 0;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--text);
  font: 500 14px/1.5 Manrope, 'Segoe UI', sans-serif;
}
.portal-auth main {
  max-width: none;
  margin: 0;
  padding: 24px 16px;
}
.portal-auth .login {
  width: 380px;
  max-width: 100%;
}
.portal-auth .login .panel {
  padding: 24px;
  border-color: var(--line);
  border-radius: 16px;
}
.portal-auth .login__brand {
  margin-bottom: 18px;
  font-size: 18px;
  line-height: 1.45;
  font-weight: 800;
  letter-spacing: -.02em;
}
.portal-auth .login form {
  gap: 12px;
}
.portal-auth :where(input, button, select) {
  font-family: inherit;
}
.portal-auth .login__label {
  color: #555a6b;
  font-size: 12px;
  font-weight: 650;
}
.portal-auth input:not([type="checkbox"]):not([type="hidden"]) {
  min-height: 40px;
  border: 1px solid #cfd4df;
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 14px;
  color: var(--text);
}
.portal-auth input::placeholder {
  color: #6c7080;
  opacity: 1;
}
.portal-auth .btn {
  min-height: 40px;
  border-radius: 9px;
  font-size: 13px;
  font-weight: 700;
}
.portal-auth input[type="checkbox"] {
  accent-color: var(--accent);
}
.portal-auth :focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}
.portal-auth ::selection {
  background: #dce0fc;
  color: #242539;
}

@media (hover: hover) and (pointer: fine) {
  .portal-screen:not(.portal-pnl) .sg-main .btn:hover {
    filter: none;
    background: #4955cb;
    border-color: #4955cb;
  }
  .portal-screen:not(.portal-pnl) .sg-main .btn--ghost:hover {
    color: #414861;
    border-color: #bdc5d9;
    background: #f6f7fa;
  }
  .portal-screen:not(.portal-pnl) .sg-main .btn--danger:hover {
    color: var(--out);
    border-color: #dba89e;
    background: #fff5f2;
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(input, select, textarea):not(:disabled):hover {
    border-color: #aeb7ca;
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table) tbody tr:hover {
    background: #f7f8fc;
  }
  .portal-help-trigger:hover {
    color: var(--accent);
    background: #eef0ff;
  }
}

@media (max-width: 1500px) {
  .portal-screen:not(.portal-pnl) .sg-main .panel {
    padding: 16px;
  }
  .portal-screen:not(.portal-pnl) .sg-main .form-grid {
    gap: 12px 16px;
  }
}
@media (max-width: 850px) {
  .portal-screen:not(.portal-pnl) .sg-main .form-grid {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
  }
  .portal-screen:not(.portal-pnl) .sg-main .calcbar {
    position: static;
  }
  .portal-screen:not(.portal-pnl) .sg-main .ship-point select {
    min-width: 0;
    width: 100%;
  }
}
@media (max-width: 600px) {
  .portal-screen:not(.portal-pnl) .sg-main .panel {
    padding: 14px;
    margin-bottom: 12px;
  }
  .portal-screen:not(.portal-pnl) .sg-main h1 {
    font-size: var(--portal-type-page);
  }
  .portal-screen:not(.portal-pnl) .sg-main .summary {
    gap: 14px 20px;
  }
  .portal-screen:not(.portal-pnl) .sg-main .stat__value {
    font-size: var(--portal-type-metric);
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(.filters, .cs-bar) input[type="search"] {
    min-width: 0;
    width: 100%;
  }
  .portal-screen:not(.portal-pnl) .sg-main .add-row input[type="search"] {
    min-width: 0;
    width: 100%;
  }
  .portal-screen:not(.portal-pnl) .sg-main .prod-cell {
    min-width: 230px;
  }
  .portal-screen:not(.portal-pnl) .sg-main .form-grid {
    grid-template-columns: minmax(0, 1fr);
  }
  .portal-screen:not(.portal-pnl) .sg-main .fn-facts,
  .portal-screen:not(.portal-pnl) .sg-main .cs-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .portal-screen:not(.portal-pnl) .sg-main .fn-fact,
  .portal-screen:not(.portal-pnl) .sg-main .cs-fact {
    padding: 10px;
  }
  .portal-auth .login .panel {
    padding: 20px;
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(.answer__value, .td-answer__value) {
    font-size: var(--portal-type-answer);
  }
}
@media (pointer: coarse) {
  .portal-screen:not(.portal-pnl) .sg-main .btn {
    min-height: 40px;
  }
  .portal-help-trigger {
    width: 26px;
    height: 26px;
    flex-basis: 26px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .portal-screen:not(.portal-pnl) .sg-main .btn {
    transition: none;
  }
  .portal-screen:not(.portal-pnl) .sg-main .btn:active {
    transform: none;
  }
}
@media print {
  body.portal-screen:not(.portal-pnl) {
    display: block;
    background: #fff;
  }
  .portal-screen:not(.portal-pnl) .sg-main {
    padding: 0;
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(.portal-table-wrap, .table-wrap, .matrix-wrap, .fn-scroll, .cs-scroll) {
    overflow: visible;
    max-width: none;
  }
  .portal-screen:not(.portal-pnl) .sg-main .panel {
    break-inside: auto;
    border-color: #aaa;
    padding: 12px;
  }
  .portal-help-trigger,
  .portal-help-popover,
  .portal-instruction-content {
    display: none !important;
  }
}

/* Full-width working surfaces follow the browser's available grid column.
   Inner task controls, plots and the PnL table retain readable dimensions. */
.portal-screen .sg-main {
  width: 100%;
  max-width: none;
  justify-self: stretch;
}
/* The panel spans the workspace; editable settings do not become giant fields. */
.portal-screen[data-portal-path$="/settings"] .sg-main .form-grid,
.portal-screen[data-portal-path="/businesses"] .sg-main .form-grid {
  max-width: var(--portal-form-width);
}
.portal-screen:not(.portal-pnl) .sg-main .calc-page {
  width: 100%;
  max-width: none;
}
/* Keep the input/answer relationship inside the full-width calculator surface. */
.portal-screen:not(.portal-pnl) .sg-main .calc-grid {
  width: 100%;
  max-width: 1400px;
}
/* The full-width picker surface contains compact fields, not growing thirds. */
.portal-screen:not(.portal-pnl) .sg-main .calc-pick > label {
  flex: 0 1 420px;
  min-width: 0;
  max-width: 100%;
}
.portal-pnl .pnl-report {
  width: 100%;
  max-width: none;
}
.portal-pnl .pnl-result-card {
  min-height: 0;
}
/* Existing user-selected wide mode affects the table, never the outer page. */
.portal-screen:not(.wide) .sg-main .cs-scroll {
  max-width: min(100%, var(--portal-table-width));
}

/* Preserve the SVG viewBox and hit-testing geometry. Small screens scroll
   the natural-sized plot instead of shrinking axis text or distorting data. */
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-panel, .ch-panel, .cv-panel) {
  width: 100%;
  max-width: calc(var(--portal-chart-width) + 30px);
  overflow-x: auto;
  margin-inline-start: 0;
}
.portal-screen:not(.portal-pnl) .sg-main :where(#finance-chart, #channel-chart, #coinvest-charts) {
  max-width: calc(var(--portal-chart-width) + 30px);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-svg, .ch-svg, .cv-svg) {
  width: var(--portal-chart-width);
  max-width: none;
  height: auto;
  display: block;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-axis, .ch-axis, .cv-axis, .cv-axis--unit, .ch-ratio-label) {
  font-size: var(--portal-type-caption);
}

/* One semantic type hierarchy across the old component vocabularies.
   Financial cells in the approved PnL are deliberately not reset. */
.portal-screen:not(.portal-pnl) .sg-main .portal-section-heading {
  font-size: var(--portal-type-section);
  font-weight: 750;
  letter-spacing: normal;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-facts, .ch-facts, .cs-facts, .ml-facts) {
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 240px));
  justify-content: start;
  gap: 12px;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-fact .v, .ch-fact .v, .cs-fact .v, .ml-fact .v, .stat__value, .td-tile__value) {
  font-size: var(--portal-type-metric);
  font-weight: 750;
  line-height: 1.4;
  font-variant-numeric: tabular-nums;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fn-fact .k, .ch-fact .k, .cs-fact .k, .ml-fact .k, .cs-fact .of, .stat__label, .td-tile__head) {
  font-size: var(--portal-type-caption);
  font-weight: 550;
  line-height: 1.5;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table, .ch-table, .cs-table, .ml-table, table.grid) {
  font-size: var(--portal-type-data);
  font-weight: 400;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list, .fn-table, .ch-table, .cs-table, .ml-table, table.grid) th {
  font-size: var(--portal-type-caption);
  font-weight: 700;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.ch-table td.main, .fn-table tr.fn-total td) {
  font-size: var(--portal-type-data);
  font-weight: 700;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.hint, .fn-table .src, .fn-detail, .cs-table .sub, .cs-table td.group, .cs-table .cs-money-edit small, .eco th small, .fld__src, .fld__few, .compare__head, .compare__src, .td-tile__note, .fn-legend, .ch-legend, .cv-legend, .fn-tip, .ch-tip, .cv-tip, .cv-panel__hint, .tag, .step, .cs-chip) {
  font-size: var(--portal-type-caption);
  line-height: 1.5;
}
.portal-screen:not(.portal-pnl) .sg-main .cs-table td.group {
  font-size: var(--portal-type-caption);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.stat__sub, .day__balance, .payment__who, .out-note, .delta--up, .delta--down, .card__planned, .prod__art-sub, .chip, .cs-count, .cs-link, .cs-ff, .cs-ffok, .cs-ovr th, .eco tr.eco-sec td, .matrix th.rot, .matrix td.note-cell, .shortages .note-cell) {
  font-size: var(--portal-type-caption);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.fld__name, .calc-pick label, .horizon, .check, .fn-tab) {
  font-size: var(--portal-type-caption);
  font-weight: 600;
}
.portal-screen:not(.portal-pnl) .sg-main :where(.list .btn, .row-actions .btn) {
  font-size: var(--portal-type-caption);
}
.portal-screen:not(.portal-pnl) .sg-main :where(.compare__val, .answer__row--main .v, .calc-table tr.grand td) {
  font-size: var(--portal-type-section);
  font-weight: 700;
}
@media (max-width: 600px) {
  .portal-screen:not(.portal-pnl) .sg-main :where(.fn-facts, .ch-facts, .cs-facts, .ml-facts) {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  /* Shrink form tracks and native selects instead of clipping their controls. */
  .portal-screen:not(.portal-pnl) .sg-main .cs-forms {
    grid-template-columns: minmax(0, 1fr);
  }
  .portal-screen:not(.portal-pnl) .sg-main .cs-form,
  .portal-screen:not(.portal-pnl) .sg-main .cs-form > :where(label, select, input) {
    min-width: 0;
    max-width: 100%;
  }
  .portal-screen:not(.portal-pnl) .sg-main .card__head,
  .portal-screen:not(.portal-pnl) .sg-main .dispatch-pair {
    flex-wrap: wrap;
    min-width: 0;
    max-width: 100%;
  }
  .portal-screen:not(.portal-pnl) .sg-main .card__name {
    min-width: 0;
    overflow-wrap: anywhere;
  }
}
@media print {
  .portal-screen .sg-main,
  .portal-screen .pnl-report {
    width: 100%;
    max-width: none;
  }
  .portal-screen:not(.portal-pnl) .sg-main :where(.fn-panel, .ch-panel, .cv-panel) {
    overflow: visible;
  }
}
