/* ROC OS presentation layer — shared alignment and theme parity only.
   Financial values, workflow state and Mobility business logic are untouched. */
:root{
  --roc-ui-control-h:40px;
  --roc-ui-radius:10px;
  --roc-ui-radius-lg:14px;
  --roc-ui-gap:12px;
  --roc-ui-page-x:28px;
}
html[data-roc-theme="dark"]{
  --roc-ui-bg:#080b0a;
  --roc-ui-surface:#0d1110;
  --roc-ui-surface-raised:#111614;
  --roc-ui-border:#242b28;
  --roc-ui-border-strong:#323a36;
  --roc-ui-text:#f4f2ea;
  --roc-ui-muted:#adb4af;
  --roc-ui-focus:#d7a92d;
}
html[data-roc-theme="light"]{
  --roc-ui-bg:#f5f3ed;
  --roc-ui-surface:#fff;
  --roc-ui-surface-raised:#eeece5;
  --roc-ui-border:#dedbd2;
  --roc-ui-border-strong:#c9c4b8;
  --roc-ui-text:#171a18;
  --roc-ui-muted:#59635d;
  --roc-ui-focus:#a9770d;
}

/* Shared application geometry. */
.os{grid-template-columns:232px minmax(0,1fr);background:var(--roc-ui-bg);color:var(--roc-ui-text)}
.os-main{min-width:0;background:var(--roc-ui-bg);overflow-x:clip}
.os{overflow-x:clip}
#osContent{min-width:0;overflow-x:clip}
.os-main main{padding:24px var(--roc-ui-page-x) 36px;min-width:0}
.os-header{min-height:76px;height:76px;padding:0 var(--roc-ui-page-x);gap:18px}
.os-header>div:first-child{min-width:0}
.os-header h2{line-height:1.2}
.os-header-actions{align-items:center;gap:8px}
.os-header-actions>*{min-height:var(--roc-ui-control-h);height:var(--roc-ui-control-h)}
.search{height:var(--roc-ui-control-h);border-radius:var(--roc-ui-radius);display:flex;align-items:center}
.icon-btn,.os-header-actions .filter-btn{width:var(--roc-ui-control-h);height:var(--roc-ui-control-h);min-height:var(--roc-ui-control-h);display:inline-flex;align-items:center;justify-content:center;border-radius:var(--roc-ui-radius)}
.os-header-actions .gold-btn{min-height:var(--roc-ui-control-h);height:var(--roc-ui-control-h);display:inline-flex;align-items:center;justify-content:center;gap:8px;border-radius:var(--roc-ui-radius);padding:0 18px}
.os-header-actions svg,.icon-btn svg{width:17px;height:17px;display:block}

/* Sidebar hit areas and icon centre line. */
.os-sidebar{width:232px;padding:18px 12px}
.os-sidebar #osNav button,.os-sidebar .sidebar-bottom button{min-height:44px;height:44px;padding:0 11px;border-radius:9px;display:flex;align-items:center;gap:10px}
.os-sidebar #osNav button i,.os-sidebar .sidebar-bottom button i{width:20px;height:20px;display:inline-flex;align-items:center;justify-content:center;flex:0 0 20px;margin:0}
.os-sidebar #osNav button i svg,.os-sidebar .sidebar-bottom button i svg{width:17px;height:17px;display:block}
.os-sidebar #osNav button em,.os-sidebar .sidebar-bottom button em{margin-left:auto;line-height:1}
.os-sidebar .profile{min-height:52px;align-items:center;border-radius:var(--roc-ui-radius)}

/* Cards, panels and KPI rhythm. */
.kpi-grid{align-items:stretch;gap:var(--roc-ui-gap)}
.kpi-card,.panel,.quick-card,.deal-card,.document-mobile-card{border-radius:var(--roc-ui-radius-lg);border-width:1px;min-width:0}
.kpi-card{min-height:126px;padding:16px;display:flex;flex-direction:column}
.kpi-top{min-height:32px;align-items:center;line-height:1.25}
.kpi-icon{width:32px;height:32px;display:inline-flex;align-items:center;justify-content:center;border-radius:9px;flex:0 0 32px}
.kpi-icon svg{width:18px;height:18px;display:block}
.kpi-value{min-height:29px;margin:15px 0 6px;line-height:1.1;font-variant-numeric:tabular-nums}
.kpi-card .delta{min-height:28px;line-height:1.35;overflow-wrap:anywhere}
.panel{padding:16px}
.panel-head{min-height:28px;margin-bottom:14px;align-items:center}
.panel-head h3{line-height:1.2}

/* Tables: stable columns, vertical centring and compact rows. */
.table-panel{min-width:0}
.data-table th,.data-table td{height:52px;padding:11px 13px;vertical-align:middle;line-height:1.3}
.data-table th{white-space:nowrap}
.data-table td{font-variant-numeric:tabular-nums}
.data-table td small{line-height:1.3}
.data-table .status,.data-table .loan-basis-badge,.status{display:inline-flex;align-items:center;justify-content:center;min-height:24px;padding:4px 8px;border-radius:999px;white-space:nowrap;line-height:1.15}
.data-table .more-btn,.data-table button{display:inline-flex;align-items:center;justify-content:center;min-height:32px}
.data-table .more-btn svg{width:16px;height:16px}

/* Form controls and focus treatment. */
:is(input,select,textarea,.filter-btn){min-height:var(--roc-ui-control-h);border-radius:var(--roc-ui-radius);line-height:1.25}
:is(input,select,textarea):focus-visible,.filter-btn:focus-visible,.gold-btn:focus-visible,.icon-btn:focus-visible{outline:2px solid color-mix(in srgb,var(--roc-ui-focus) 55%,transparent);outline-offset:2px}
.filter-btn{display:inline-flex;align-items:center;justify-content:center;gap:7px;padding:0 13px}
.filter-btn svg,.gold-btn svg{width:16px;height:16px;display:block}

/* Drawers and modals share one predictable shell. */
.modal{padding:16px;overscroll-behavior:contain}
.modal-card{width:min(680px,calc(100vw - 32px));max-height:min(90svh,860px);padding:24px;border-radius:var(--roc-ui-radius-lg);overflow:auto}
.modal-card--compact{width:min(480px,calc(100vw - 32px))}
.modal-card--form{width:min(720px,calc(100vw - 32px))}
.modal-card--wide{width:min(1100px,calc(100vw - 32px))}
.modal-card--loan-detail:has(.loan-detail-header){width:min(1100px,calc(100vw - 32px));max-height:min(92svh,920px)}
.modal-close{width:36px;height:36px;display:inline-flex;align-items:center;justify-content:center;border-radius:50%}
.modal-close svg{width:17px;height:17px;display:block}
.modal-card--loan-detail:has(.roc-score-drawer){width:min(760px,calc(100vw - 32px));max-height:min(90svh,860px);margin:auto;align-self:center;border-radius:var(--roc-ui-radius-lg)}
.modal-card--loan-metric-drilldown{width:min(920px,calc(100vw - 32px));height:auto;max-height:min(88svh,840px);margin:auto;padding:24px;align-self:center;border-radius:var(--roc-ui-radius-lg)}

/* Loan portfolio detail behaves as a drawer without collapsing the table columns. */
@media(min-width:901px){
  .loan-table-panel.has-side-panel .loan-portfolio-split{grid-template-columns:minmax(0,1fr)}
  .loan-table-panel.has-side-panel .loan-portfolio-side-panel{position:fixed;z-index:30;inset:76px 0 0 auto;width:min(440px,calc(100vw - 40px));height:calc(100svh - 76px);max-height:none;padding:20px;overscroll-behavior:contain;scrollbar-gutter:stable;border-left:1px solid var(--command-gold,var(--gold));box-shadow:-18px 0 42px rgba(0,0,0,.2)}
  .loan-portfolio-side-panel .loan-side-header{position:sticky;z-index:3;top:-20px;margin-top:-20px;padding-top:20px;background:var(--command-surface,var(--panel,#fff))}
}

/* Loan controls use readable type and stable wrapping in both themes. */
.loan-side-communications button,.loan-side-actions button{min-height:38px}
.loan-side-communications .ui-icon,.loan-side-actions .ui-icon{flex:0 0 16px}
.loan-side-ageing span{overflow:hidden;color:transparent;font-size:0;line-height:0}
.loan-side-muted{display:inline-flex;align-items:center;justify-self:start;min-height:22px;padding:4px 8px;border-radius:999px;background:color-mix(in srgb,var(--command-gold,#c99b28) 11%,transparent);color:var(--command-gold,#c99b28);font-weight:700;letter-spacing:.45px}
.loan-side-section-heading .text-link{min-height:30px;padding:5px 0;color:var(--command-gold,#c99b28);opacity:1}
.loan-side-actions{z-index:3;padding-bottom:2px}
.modal-card--loan-detail .loan-command-tabs{overflow-x:auto;scrollbar-width:thin}
.modal-card--loan-detail .loan-command-tabs button{min-height:42px;white-space:nowrap}
.modal-card--loan-detail .loan-command-summary-strip{overflow-x:auto}
.modal-card--loan-detail .loan-command-context{min-width:0}
html[data-roc-theme="light"] .loan-portfolio-side-panel{box-shadow:-18px 0 42px rgba(39,34,22,.12)}
html[data-roc-theme="dark"] .loan-portfolio-side-panel{box-shadow:-18px 0 42px rgba(0,0,0,.38)}

/* Keep the portfolio register compact, readable and anchored while the page scrolls. */
.loan-table-panel{border-radius:12px;overflow:clip}
.loan-table-panel .panel-head{min-height:64px;padding:16px 18px;align-items:center}
.loan-table-panel .panel-head h3{font-size:14px;line-height:1.2}
.loan-table-panel .panel-head span{font-size:9px;line-height:1.35}
.loan-table{min-width:1320px}
.loan-table thead th{height:42px;padding:10px 12px;letter-spacing:.55px}
.loan-table tbody tr,.loan-table tbody td{height:74px}
.loan-table tbody td{padding:11px 12px;line-height:1.25}
.loan-table th:nth-child(1){width:230px}
.loan-table th:nth-child(2){width:105px}
.loan-table th:nth-child(3){width:125px}
.loan-table th:nth-child(4){width:235px}
.loan-table th:nth-child(5){width:125px}
.loan-table th:nth-child(6){width:94px}
.loan-table th:nth-child(7){width:195px}
.loan-table th:nth-child(8){width:140px}
.loan-table th:nth-child(9){width:170px}
.loan-table th:nth-child(10){width:44px}
.loan-table .loan-state-stack{gap:5px}
.loan-table .loan-state-secondary{white-space:normal;line-height:1.25}
.loan-table .loan-client b{font-size:10px}
.loan-table .loan-client small,.loan-table td>small{font-size:8px;line-height:1.35}
html[data-roc-theme="dark"] .loan-table tbody tr:nth-child(even){background:rgba(255,255,255,.012)}
html[data-roc-theme="light"] .loan-table tbody tr:nth-child(even){background:rgba(34,30,20,.012)}
@media(min-width:1400px){
  .loan-table-scroll{overflow:visible}
  .loan-table thead th{top:76px}
}

/* Prevent long labels from changing component geometry. */
.status,.loan-basis-badge,.loan-state-secondary{max-width:100%;overflow:hidden;text-overflow:ellipsis}
.eyebrow{line-height:1.2}
.money,.kpi-value,[data-money]{font-variant-numeric:tabular-nums}

@media(max-width:1100px){
  :root{--roc-ui-page-x:20px}
  .os{display:block}
  .os-sidebar{width:232px}
  .os-main main{padding-inline:var(--roc-ui-page-x)}
  .os-header{padding-inline:var(--roc-ui-page-x)}
  .kpi-grid{grid-template-columns:repeat(2,minmax(0,1fr))}
}
@media(max-width:700px){
  :root{--roc-ui-page-x:14px}
  .os-header{height:auto;min-height:68px;padding-block:12px}
  .os-header-actions{gap:6px}
  .os-header-actions>*{min-height:38px;height:38px}
  .os-header-actions .gold-btn{height:38px;min-height:38px;padding-inline:12px}
  .os-main main{padding-block:16px 24px}
  .kpi-grid{grid-template-columns:1fr;gap:10px}
  .kpi-card{min-height:112px}
  .panel{padding:14px}
  .data-table{min-width:720px}
  .modal{padding:10px 10px 0}
  .modal-card,.modal-card--compact,.modal-card--form,.modal-card--wide,.modal-card--loan-detail:has(.roc-score-drawer),.modal-card--loan-metric-drilldown{width:100%;max-height:calc(100svh - 10px);padding:20px 16px calc(18px + env(safe-area-inset-bottom));border-radius:18px 18px 0 0;align-self:end}
  .modal-close{width:34px;height:34px}
}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;scroll-behavior:auto!important;transition-duration:.001ms!important}}

/* Portfolio row cleanup: keep the canonical client account only and remove redundant gray helper copy. */
.loan-table td>small,.loan-table [class*="repay"] small,.loan-table .loan-servicing-meta{display:none}
.loan-mobile-card .loan-mobile-money small,.loan-mobile-card [class*="repay"] small{display:none}

/* Keep every desktop column inside the register, including the action menu and due-date control. */
.loan-table{min-width:1280px}
.loan-table th:nth-child(1){width:220px}
.loan-table th:nth-child(2){width:96px}
.loan-table th:nth-child(3){width:108px}
.loan-table th:nth-child(4){width:210px}
.loan-table th:nth-child(5){width:112px}
.loan-table th:nth-child(6){width:168px}
.loan-table th:nth-child(7){width:130px}
.loan-table th:nth-child(8){width:150px}
.loan-table th:nth-child(9){width:150px}
.loan-table th:nth-child(10){width:42px}
.loan-table .loan-legacy-date{max-width:100%;white-space:normal;overflow-wrap:anywhere;line-height:1.25}
.loan-table .more-btn{width:32px;min-width:32px;padding:0}

/* Loan register alignment: the live register has ten canonical columns after ROC Score. */
.loan-table-scroll{overflow-x:auto;overflow-y:visible}
.loan-table{width:100%;min-width:1320px;table-layout:fixed}
.loan-table .loan-col-client{width:15.5%}
.loan-table .loan-col-product{width:7%}
.loan-table .loan-col-principal{width:7.5%}
.loan-table .loan-col-repayment{width:15%}
.loan-table .loan-col-fee{width:8%}
.loan-table .loan-col-score{width:8.5%}
.loan-table .loan-col-status{width:12%}
.loan-table .loan-col-days{width:9.5%}
.loan-table .loan-col-due{width:13%}
.loan-table .loan-col-actions{width:4%}
.loan-table th,.loan-table td{vertical-align:middle}
.loan-table thead th{top:0}
.loan-table th{white-space:nowrap}
.loan-table td:nth-child(6){text-align:left}
.loan-table td:nth-child(7) .loan-state-stack{align-items:flex-start;justify-content:center}
.loan-table td:nth-child(8),.loan-table td:nth-child(9),.loan-table td:nth-child(10){text-align:center}
.loan-table .loan-client{display:grid;grid-template-columns:32px minmax(0,1fr);width:100%;min-width:0;align-items:center;gap:10px}
.loan-table .loan-client>span:last-child{display:grid;min-width:0;gap:3px}
.loan-table .loan-client b,.loan-table .loan-client small{display:block;width:100%;max-width:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.loan-table .loan-legacy-date{display:inline-flex;align-items:center;gap:5px;max-width:none;white-space:nowrap;overflow:visible;line-height:1.25}
.loan-table .due-date-link{justify-content:center;min-width:0}
.loan-table .more-btn{margin-inline:auto}
.client-bank-account{border-color:color-mix(in srgb,var(--command-gold,#c99b28) 38%,var(--command-line,var(--line,#ddd)));background:color-mix(in srgb,var(--command-gold,#c99b28) 5%,var(--command-surface,var(--panel,#fff)))}
.client-bank-account h3{font-variant-numeric:tabular-nums;overflow-wrap:anywhere}
.document-card-actions{display:flex;gap:7px;margin-top:12px}
.document-card-actions .filter-btn{flex:1;justify-content:center}
@media(max-width:900px){.loan-table{min-width:1280px}}
@media(max-width:760px){.document-card-actions{display:grid;grid-template-columns:1fr 1fr}.document-card-actions .filter-btn{width:100%}}
@media(max-width:520px){.document-card-actions{grid-template-columns:1fr}}
