/* Shared overflow policy for dashboard dialogs, drawers, and their tables. */
[data-ui-surface] {
  min-width: 0;
}

[data-ui-surface] *,
[data-ui-surface] *::before,
[data-ui-surface] *::after {
  min-width: 0;
}

[data-ui-surface].ui-modal-shell,
[data-ui-surface] .ui-modal-shell {
  width: min(var(--ui-modal-width, 1180px), calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  overflow: hidden;
}

[data-ui-surface] .ui-modal-head,
[data-ui-surface] .ui-modal-foot {
  flex: 0 0 auto;
}

[data-ui-surface] .ui-modal-head > :not(button),
[data-ui-surface] .ui-modal-foot > :not(button) {
  min-width: 0;
}

[data-ui-surface].ui-modal-body,
[data-ui-surface] .ui-modal-body {
  min-height: 0;
  max-width: 100%;
  overflow: auto;
}

[data-ui-surface] .ui-table-scroll {
  display: block;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  padding-inline-end: var(--ui-table-scroll-end-gap, 12px);
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
}

[data-ui-surface] table:not(.gtbl) {
  line-height: 1.4;
}

[data-ui-surface] table:not(.gtbl) th {
  padding: 7px 9px !important;
  font-size: 11px !important;
  vertical-align: middle;
}

[data-ui-surface] table:not(.gtbl) td {
  padding: 6px 9px !important;
  font-size: 12px !important;
  vertical-align: middle;
}

[data-ui-surface] .ui-table-scroll > table:not(.gtbl):not(.ui-table-fixed) {
  width: max-content !important;
  min-width: 100%;
  max-width: none;
  table-layout: auto !important;
}

[data-ui-surface] table.ui-table-fixed {
  width: 100% !important;
  table-layout: fixed;
}

[data-ui-surface] table.ui-table-wide {
  min-width: 940px;
}

[data-ui-surface] table.ui-table-very-wide {
  min-width: 1120px;
}

[data-ui-surface] table.ui-sticky-total {
  border-collapse: separate !important;
  border-spacing: 0;
}

[data-ui-surface] table.ui-sticky-total tfoot td {
  position: sticky;
  bottom: 0;
  z-index: 3;
  background: var(--bg-2);
  background-clip: padding-box;
  box-shadow:
    0 -1px 0 var(--border-hi, var(--border)),
    0 2px 0 var(--bg-2);
}

[data-ui-surface] table.rcp-ar-table {
  min-width: 1552px;
}

[data-ui-surface] .rcp-ar-project-col {
  width: 220px;
}

[data-ui-surface] .rcp-ar-division-col {
  width: 72px;
}

[data-ui-surface] .rcp-ar-amount-col {
  width: 128px;
}

[data-ui-surface].rcp-ar-detail-modal {
  padding: 12px 8px;
}

[data-ui-surface] .ui-modal-shell.rcp-ar-detail-panel {
  --ui-modal-width: 1600px;
  max-width: 1600px;
}

[data-ui-surface] .ui-modal-shell.rcp-forecast-panel {
  --ui-modal-width: 1680px;
  max-width: 1680px;
}

[data-ui-surface] .ui-modal-shell.rcp-detail-panel:not(.rcp-ar-detail-panel) {
  --ui-modal-width: 1600px;
  max-width: 1600px;
}

[data-ui-surface] .ui-modal-shell.outlook-input-panel {
  --ui-modal-width: 1480px;
  max-width: 1480px;
}

[data-ui-surface] .ui-modal-shell.simple-forecast-panel {
  --ui-modal-width: 520px;
  max-width: 520px;
}

[data-ui-surface] .rcp-forecast-panel table.ui-table-wide {
  min-width: 1320px;
}

[data-ui-surface] .rcp-forecast-panel table.ui-table-very-wide {
  min-width: 1560px;
}

[data-ui-surface] .rcp-ar-detail-panel .rcp-table-wrap {
  max-height: calc(100vh - 300px);
  margin: 10px 12px 12px;
}

[data-ui-surface] .rcp-ar-table .rcp-ar-project-sticky {
  position: sticky;
  left: 0;
  background: var(--bg-1);
  background-clip: padding-box;
  box-shadow: 1px 0 0 var(--border-hi, var(--border));
}

[data-ui-surface] .rcp-ar-table thead .rcp-ar-project-sticky,
[data-ui-surface] .rcp-ar-table tbody .rcp-ar-project-sticky {
  width: 220px;
  min-width: 220px;
  max-width: 220px;
}

[data-ui-surface] .rcp-ar-table thead .rcp-ar-project-sticky {
  z-index: 5;
  background: var(--bg-2);
}

[data-ui-surface] .rcp-ar-table tbody .rcp-ar-project-sticky {
  z-index: 2;
  white-space: normal;
}

[data-ui-surface] .rcp-ar-table tfoot .rcp-ar-project-sticky {
  z-index: 5;
  background: var(--bg-2);
}

[data-ui-surface] .rcp-ar-project-text {
  line-height: 1.35;
}

[data-ui-surface] .ui-cell-text {
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-word;
  line-height: 1.4;
}

[data-ui-surface] .ui-cell-code {
  white-space: normal !important;
  overflow-wrap: anywhere;
  word-break: break-all;
  font-family: var(--font-mono, "JetBrains Mono", monospace);
}

[data-ui-surface] .ui-cell-num,
[data-ui-surface] .ui-cell-date,
[data-ui-surface] .ui-cell-status,
[data-ui-surface] .ui-cell-action,
[data-ui-surface] table .num,
[data-ui-surface] table .tnm {
  white-space: nowrap !important;
  overflow-wrap: normal;
  word-break: normal;
}

[data-ui-surface] .ui-ellipsis {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

[data-ui-surface] .ui-clamp-2,
[data-ui-surface] .ui-clamp-3 {
  display: -webkit-box;
  overflow: hidden;
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
  -webkit-box-orient: vertical;
}

[data-ui-surface] .ui-clamp-2 {
  -webkit-line-clamp: 2;
}

[data-ui-surface] .ui-clamp-3 {
  -webkit-line-clamp: 3;
}

[data-ui-surface] .ui-kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(145px, 1fr)) !important;
}

[data-ui-surface] .ui-form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
}

[data-ui-surface] .apprv-extTbl td,
[data-ui-surface] .sup-extTbl td {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

[data-ui-surface] .apprv-extTbl code,
[data-ui-surface] .sup-extTbl code {
  overflow-wrap: anywhere;
  word-break: break-all;
}

@media (max-width: 720px) {
  [data-ui-surface] .ui-modal-shell {
    width: calc(100vw - 12px);
    max-height: calc(100vh - 12px);
    border-radius: 8px !important;
  }

  [data-ui-surface] .ui-modal-head,
  [data-ui-surface] .ui-modal-foot {
    gap: 6px !important;
  }

  [data-ui-surface] .ui-form-grid {
    grid-template-columns: 1fr !important;
  }
}
