:root {
  --portal-topbar-height: 64px;
  --portal-sidebar-width: 248px;
}

html,
body {
  max-width: 100%;
  overflow-x: clip;
}

body.portal-page {
  background: #eef1f4;
}

body.portal-nav-open {
  overflow: hidden;
}

.portal-page section[id],
.portal-page div[id] {
  scroll-margin-top: 82px;
}

.portal-topbar {
  position: sticky;
  z-index: 80;
  top: 0;
  min-height: var(--portal-topbar-height);
  display: grid;
  grid-template-columns: var(--portal-sidebar-width) minmax(0, 1fr) auto;
  align-items: center;
  gap: 22px;
  padding: 0 22px 0 18px;
  color: #fff;
  background: #0b1728;
  border-bottom: 1px solid rgba(255, 255, 255, .09);
}

.portal-topbar .brand {
  min-height: 44px;
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.portal-topbar .brand strong {
  color: #fff;
  font-size: 15px;
  font-weight: 800;
}

.portal-topbar .brand-mark {
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #0b1728;
  background: #fff;
  font-size: 15px;
}

.portal-menu-button {
  display: none;
  width: 44px;
  min-height: 44px;
  padding: 10px;
  border: 0;
  border-radius: 7px;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.portal-menu-button span {
  display: block;
  height: 2px;
  margin: 4px 0;
  border-radius: 2px;
  background: currentColor;
}

.portal-context {
  min-width: 0;
  color: #aebbd0;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.portal-context strong {
  color: #fff;
}

.portal-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #aebbd0;
  font: 500 10px/1 "DM Mono", monospace;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .12);
}

.portal-app-frame {
  min-height: calc(100vh - var(--portal-topbar-height));
  display: grid;
  grid-template-columns: var(--portal-sidebar-width) minmax(0, 1fr);
}

.portal-sidebar {
  position: sticky;
  top: var(--portal-topbar-height);
  align-self: start;
  min-height: calc(100vh - var(--portal-topbar-height));
  height: calc(100vh - var(--portal-topbar-height));
  display: flex;
  flex-direction: column;
  padding: 20px 14px 18px;
  overflow-y: auto;
  color: #c9d2de;
  background: #0b1728;
  border-right: 1px solid rgba(255, 255, 255, .07);
  scrollbar-color: #354760 #0b1728;
}

.portal-journey-nav {
  padding: 30px 18px 24px;
}

.portal-journey-nav li.has-link {
  display: block;
  padding: 0;
}

.portal-journey-nav li.has-link > a {
  min-height: 52px;
  display: grid;
  grid-template-columns: 32px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 12px;
  border-radius: 8px;
  color: inherit;
  text-decoration: none;
}

.portal-journey-nav li.has-link > a:hover,
.portal-journey-nav li.has-link > a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .06);
}

.portal-journey-nav li.has-link > a > span {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 1px solid #435267;
  border-radius: 50%;
  font: 500 11px/1 "DM Mono", monospace;
}

.portal-journey-nav li.has-link > a strong,
.portal-journey-nav li.has-link > a small {
  display: block;
}

.portal-journey-nav li.has-link > a strong {
  color: #c8d2de;
  font-size: 12px;
}

.portal-journey-nav li.has-link > a small {
  margin-top: 3px;
  color: #8493a6;
  font-size: 10px;
  line-height: 1.35;
}

.portal-journey-nav li.complete.has-link > a {
  color: #8ee1c9;
}

.portal-journey-nav li.complete.has-link > a > span {
  color: #fff;
  border-color: var(--mint);
  background: var(--mint);
}

.portal-journey-nav .nav-boundary {
  margin-top: auto;
}

.frozen-output-subnav {
  margin: 18px 12px 8px 52px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, .09);
}

.frozen-output-subnav > p {
  margin: 0 0 8px;
  color: #758398;
  font: 500 10px/1 "DM Mono", monospace;
  letter-spacing: .09em;
  text-transform: uppercase;
}

.frozen-output-subnav a {
  min-height: 34px;
  display: flex;
  align-items: center;
  margin: 1px 0;
  padding: 7px 9px;
  border-radius: 6px;
  color: #aeb9c8;
  text-decoration: none;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

.frozen-output-subnav a:hover,
.frozen-output-subnav a:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, .06);
}

.frozen-output-subnav a[aria-current="page"] {
  color: #fff;
  background: #14243a;
  box-shadow: inset 2px 0 0 #6f9fff;
}

.portal-workspace {
  min-width: 0;
}

.portal-sidebar-backdrop {
  display: none;
}

.portal-page .run-shell,
.portal-page .result-shell {
  width: min(1440px, 100%);
  max-width: none;
  margin: 0;
  padding: 34px clamp(20px, 3vw, 46px) 64px;
}

.portal-page .run-shell {
  width: min(1320px, 100%);
}

.portal-page .back-link {
  min-height: 44px;
  align-items: center;
}

.operator-table {
  border-collapse: separate;
  border-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.operator-table thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  border-bottom: 1px solid var(--line-strong);
  color: #405069;
  background: #e6ebf1;
}

.result-calendar-table.operator-table thead th {
  color: #334155;
  background: #dde4ec;
}

.table-scroll-cue {
  margin: 0 18px 10px;
  color: #5d6b7d;
  font: 500 10px/1.4 "DM Mono", monospace;
  text-align: right;
}

.operator-table tbody tr:nth-child(even) {
  background: #f8fafc;
}

.operator-table tbody tr:hover {
  background: #edf3ff;
}

.operator-table td {
  line-height: 1.45;
}

.compact-schedule-table {
  min-width: 0;
}

.daily-schedule-table {
  min-width: 1080px;
}

.audit-table {
  min-width: 760px;
}

.operator-table .numeric-cell,
.operator-table td[data-label="Amount"],
.operator-table td[data-label="Balance"] {
  text-align: right;
  white-space: nowrap;
}

.movement-account-role,
.movement-account-reference {
  display: block;
}

.movement-account-role {
  color: #26364a;
  font-weight: 800;
}

.movement-account-reference {
  margin-top: 3px;
  color: var(--muted);
  font: 500 9px/1.35 "DM Mono", monospace;
}

.decision-badge {
  display: inline-flex;
  max-width: 100%;
  padding: 6px 8px;
  border: 1px solid #bfd0f1;
  border-radius: 6px;
  color: #194cac;
  background: #edf3ff;
  font: 700 9px/1.35 "DM Mono", monospace;
  overflow-wrap: anywhere;
}

.decision-badge.pending {
  color: #815200;
  border-color: #e8d49e;
  background: #fff5dc;
}

.decision-badge.template {
  color: #4b3a7a;
  border-color: #d7cef1;
  background: #f4f0ff;
}

.decision-badge.confirmed {
  color: #0f654c;
  border-color: #b9dccf;
  background: #e8f5f0;
}

.decision-source-card {
  padding: 0;
  overflow: hidden;
  border: 1px solid #cbd8ed;
  border-radius: 10px;
  background: #f4f7fc;
}

.decision-source-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border-bottom: 1px solid #d7e1ef;
}

.decision-source-card header strong {
  color: #26364a;
  font-size: 12px;
}

.decision-template-origin {
  padding: 4px 7px;
  border-radius: 5px;
  color: #4b3a7a;
  background: #eae3fb;
  font: 700 9px/1.2 "DM Mono", monospace;
}

.decision-source-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.decision-source-grid div {
  min-width: 0;
  padding: 11px 13px;
  border-right: 1px solid #d7e1ef;
}

.decision-source-grid div:nth-child(3) {
  border-right: 0;
}

.decision-source-grid .decision-source-description {
  grid-column: 1 / -1;
  border-top: 1px solid #d7e1ef;
  border-right: 0;
}

.decision-source-grid span,
.decision-source-grid strong {
  display: block;
}

.decision-source-grid span {
  color: var(--muted);
  font: 500 9px/1.3 "DM Mono", monospace;
  letter-spacing: .05em;
  text-transform: uppercase;
}

.decision-source-grid strong {
  margin-top: 4px;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.decision-fieldset {
  min-width: 0;
  display: grid;
  gap: 13px;
  margin: 0;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.decision-fieldset legend {
  padding: 0 7px;
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}

.decision-requirement-hint {
  margin: 0;
  padding: 10px 12px;
  border: 1px solid #ead6a4;
  border-radius: 7px;
  color: #73520f;
  background: #fff8e7;
  font-size: 11px;
  line-height: 1.55;
}

.decision-advanced {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.decision-advanced > summary {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 11px 15px;
  color: #334155;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

.decision-advanced[open] > summary {
  border-bottom: 1px solid var(--line);
}

.decision-advanced-body {
  display: grid;
  gap: 13px;
  padding: 15px;
}

@media (max-width: 900px) {
  .portal-topbar {
    grid-template-columns: 44px minmax(0, 1fr) auto;
    gap: 10px;
    padding: 0 14px 0 8px;
  }

  .portal-menu-button {
    display: block;
  }

  .portal-context {
    display: none;
  }

  .portal-app-frame {
    display: block;
  }

  .portal-sidebar {
    position: fixed;
    z-index: 75;
    top: var(--portal-topbar-height);
    left: 0;
    width: min(300px, calc(100vw - 42px));
    min-height: 0;
    height: calc(100vh - var(--portal-topbar-height));
    transform: translateX(-102%);
    transition: transform .22s cubic-bezier(.22, 1, .36, 1);
    box-shadow: 0 20px 55px rgba(6, 15, 28, .28);
  }

  .portal-sidebar.open {
    transform: translateX(0);
  }

  .portal-journey-nav {
    padding: 24px 18px 20px;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .portal-journey-nav > p {
    display: block;
  }

  .portal-journey-nav ol {
    min-width: 0;
    display: block;
  }

  .portal-journey-nav li {
    min-width: 0;
    display: grid;
    grid-template-columns: 32px minmax(0, 1fr);
    gap: 10px;
    padding: 12px;
  }

  .portal-journey-nav li > span {
    width: 28px;
    height: 28px;
  }

  .portal-journey-nav li strong {
    font-size: 12px;
  }

  .portal-journey-nav li small {
    display: block;
  }

  .portal-journey-nav li.has-link {
    display: block;
    padding: 0;
  }

  .frozen-output-subnav {
    margin-right: 10px;
  }

  .portal-sidebar-backdrop {
    position: fixed;
    z-index: 70;
    inset: var(--portal-topbar-height) 0 0;
    width: 100%;
    min-height: 0;
    display: block;
    border: 0;
    background: rgba(5, 13, 24, .5);
  }

  .portal-page .run-shell,
  .portal-page .result-shell {
    padding: 26px 16px 52px;
  }
}

@media (max-width: 620px) {
  .portal-status {
    font-size: 8px;
  }

  .compact-schedule-table,
  .compact-schedule-table tbody {
    display: block;
  }

  .compact-schedule-table thead {
    display: none;
  }

  .compact-schedule-table tbody {
    display: grid;
    gap: 10px;
    padding: 12px;
  }

  .compact-schedule-table tbody tr {
    display: grid;
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #fff;
  }

  .compact-schedule-table tbody td {
    display: grid;
    grid-template-columns: 92px minmax(0, 1fr);
    gap: 10px;
    padding: 10px 12px;
    border-top: 1px solid var(--line);
    text-align: left;
  }

  .compact-schedule-table tbody td:first-child {
    border-top: 0;
  }

  .compact-schedule-table tbody td::before {
    content: attr(data-label);
    color: var(--muted);
    font: 500 9px/1.4 "DM Mono", monospace;
    letter-spacing: .05em;
    text-transform: uppercase;
  }

  .compact-schedule-table .empty-row td {
    display: block;
    border: 0;
  }

  .compact-schedule-table .empty-row td::before {
    content: none;
  }

  .decision-source-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .decision-source-grid div:nth-child(2) {
    border-right: 0;
  }

  .decision-source-grid div:nth-child(3) {
    grid-column: 1 / -1;
    border-top: 1px solid #d7e1ef;
  }
}

@media (prefers-reduced-motion: reduce) {
  .portal-sidebar {
    transition: none;
  }
}
