/* R57: connected headers, compact section navigation and visible spreadsheet copying. */
body#crm-ui{--r57-teal:linear-gradient(110deg,#123c46,#1b6570)}
/* The same authorised view links sit on the bottom edge of their page header. */
body#crm-ui .module-layout.module-header-only{grid-template-columns:minmax(0,1fr)!important;gap:0!important}
body#crm-ui .module-layout.module-header-only>.module-navigation{display:none!important}
body#crm-ui #main-content .page-heading:has(>.executive-header){display:block;min-width:0;margin-bottom:14px}
body#crm-ui #main-content .page-heading:has(>.header-nav:not([hidden]))>.executive-header{padding-bottom:32px!important;margin-bottom:0!important}
body#crm-ui #main-content .page-heading>.header-nav:not([hidden]){position:relative;z-index:2;display:flex!important;align-items:center;flex-wrap:nowrap!important;gap:7px;margin:-19px 0 0!important;padding:0 16px 5px!important;max-width:100%;min-width:0;overflow-x:auto;overflow-y:hidden;scroll-padding-inline:16px}
body#crm-ui #main-content .page-heading>.header-nav>:is(a,button){flex:0 0 auto;display:inline-flex;align-items:center;gap:7px;white-space:nowrap!important;min-height:36px;margin:0!important;padding:7px 14px!important}
body#crm-ui #main-content .crm-header-tabs :is(.module-nav-label,.module-nav-count){display:inline!important;position:static!important;opacity:1!important;max-width:none!important;width:auto!important;height:auto!important;overflow:visible!important;clip-path:none!important;white-space:nowrap!important;font-size:13px}
body#crm-ui #main-content .crm-header-tabs .module-nav-icon{display:inline-flex;width:18px;height:18px;flex:0 0 18px;background:transparent!important;color:inherit;padding:0}
body#crm-ui #main-content .crm-header-tabs .module-nav-count{padding:1px 6px;border-radius:12px;background:#ffffff90;font-weight:700}
body#crm-ui #main-content .crm-header-tabs svg{width:18px;height:18px}
body#crm-ui #main-content .executive-header .crm-heading-icon{color:#ffe36b!important}
/* Default overview metrics are integrated; custom order, hidden widgets and edit mode remain intact. */
body#crm-ui #main-content .dashboard-header:has(>.pd-toolbar){display:grid!important;grid-template-columns:minmax(0,1fr) minmax(280px,440px);gap:12px 20px;align-items:center;padding:18px 22px!important}
body#crm-ui #main-content .dashboard-header .header-copy{min-width:0;max-width:none}
body#crm-ui #main-content .dashboard-header h1{font-size:clamp(23px,2.2vw,30px);margin:4px 0 6px}
body#crm-ui #main-content .dashboard-header-metrics{grid-column:2;grid-row:1 / span 2;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:8px;min-width:0}
body#crm-ui #main-content .dashboard-header-metrics>a{display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--ref-selected)!important;color:#293538!important;border:1px solid #d8b932;border-radius:24px;box-shadow:inset 0 1px #fff8b2,0 4px 9px #061e3530;padding:10px 15px;min-height:46px;text-decoration:none;line-height:1.2;font-size:13px}
body#crm-ui #main-content .dashboard-header-metrics :is(span,small){color:inherit;font-size:12px;letter-spacing:0}
body#crm-ui #main-content .dashboard-header-metrics strong{font-size:23px;line-height:1;white-space:nowrap}
body#crm-ui #main-content .dashboard-header>.pd-toolbar{grid-column:1;display:flex;align-items:center;gap:7px;flex-wrap:wrap;margin:0;padding:0;background:transparent;border:0}
body#crm-ui #main-content .dashboard-header>.pd-toolbar [data-save-status]{color:#e0f3f1;flex-basis:100%;font-size:12px}
body#crm-ui #main-content .dashboard-header>.pd-toolbar [data-save-status]:empty{display:none}
body#crm-ui #personal-dashboard .pd-docked{display:none!important}
/* Long record forms use one section picker, without replacing any field or submit action. */
body#crm-ui #main-content .premium-form .compact-section-nav{display:flex!important;align-items:center;justify-content:space-between;gap:12px;padding:0!important;margin:0 0 9px!important}
body#crm-ui #main-content .premium-form .compact-section-nav>button{display:none!important}
body#crm-ui #main-content .form-section-picker{display:flex;align-items:center;gap:8px;margin:0;min-width:0;font-size:12px;font-weight:600}
body#crm-ui #main-content .form-section-picker select{width:min(370px,50vw);min-width:0;min-height:34px;padding:6px 30px 6px 10px;border-radius:9px;border:1px solid #b9d0d1;background:#fff;color:#193d43;font:italic 14px Calibri,'Segoe UI',sans-serif}
body#crm-ui #main-content .form-section-counter{font-size:12px;white-space:nowrap;color:#4b676c}
body#crm-ui #main-content .module-form-candidates .editor-section{padding:12px!important;margin:0 0 10px!important}
body#crm-ui #main-content .module-form-candidates .section-head{background:var(--r57-teal)!important;border-radius:10px;padding:8px 11px!important;margin:0 0 10px!important;color:white}
body#crm-ui #main-content .module-form-candidates .section-head h2{color:white!important;font-size:16px;margin:0}
body#crm-ui #main-content .module-form-candidates .form-grid{gap:9px 12px!important}
body#crm-ui #main-content .module-form-candidates .form-field{gap:4px;margin:0}
body#crm-ui #main-content .module-form-candidates :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select){min-height:34px;padding:6px 9px}
body#crm-ui #main-content .module-form-candidates .premium-form-footer{padding:9px 0!important;gap:8px;margin-top:0}
body#crm-ui #main-content .recovery-status{font-size:11px;padding:5px 8px!important;margin:0 0 8px!important;line-height:1.35}
/* My workspace uses the same teal header and attached view pills. */
body#crm-ui #home .desk-welcome{padding:17px 20px 31px!important;margin-bottom:0!important;background:var(--r57-teal)!important;border-radius:18px;min-height:0}
body#crm-ui #home .desk-welcome h1{font-size:27px;line-height:1.15;margin:4px 0 6px}
body#crm-ui #home .desk-overview{position:relative;display:flex!important;flex-wrap:nowrap;gap:7px;margin:-19px 0 12px!important;padding:0 16px 5px!important;overflow-x:auto;min-width:0;grid-template-columns:none}
body#crm-ui #home .desk-overview>button{flex:0 0 auto;display:flex;align-items:center;gap:7px;min-height:36px!important;padding:7px 13px!important;border-radius:22px!important;white-space:nowrap!important;text-align:left}
body#crm-ui #home .desk-overview>button>span:last-child{display:flex;align-items:center;gap:8px}
body#crm-ui #home .desk-overview strong{display:inline;font-size:13px;margin:0;padding:1px 6px;background:#ffffff80;border-radius:12px;line-height:1.3}
body#crm-ui #home .desk-overview [data-desk-icon]{display:inline-flex;width:18px;height:18px;padding:0;background:transparent!important;box-shadow:none}
body#crm-ui #home .desk-overview svg{width:18px;height:18px}
body#crm-ui #home .desk-panel>.section-head,body#crm-ui #home .desk-panel>h2{background:var(--r57-teal)!important;color:white!important;border-radius:11px;padding:9px 11px;margin:0 0 12px!important;font-size:16px}
body#crm-ui #home .desk-panel>.section-head :is(h2,output,#sheet-count){color:white!important;font-size:14px}
body#crm-ui #home .desk-panel>:is(.section-head,h2) [data-desk-icon]{color:#ffe36b!important}
body#crm-ui #home .shortcuts{grid-template-columns:repeat(auto-fill,minmax(min(100%,180px),1fr))!important}
body#crm-ui #home .shortcut>a{min-width:0;grid-template-columns:30px minmax(0,1fr);gap:9px;padding-right:24px!important}
body#crm-ui #home .shortcut>a>span:last-child{overflow-wrap:normal;word-break:normal;hyphens:auto;line-height:1.3}
/* Workbook title and actions are part of its teal header; the ribbon stays compact. */
body#crm-ui #editor .sheet-head{background:var(--r57-teal)!important;color:white;padding:10px 12px!important;border-radius:14px 14px 0 0;margin:0!important;gap:7px;box-shadow:inset 0 1px #fff3}
body#crm-ui #editor #sheet-title{color:white!important;background:#ffffff12;border:1px solid #ffffff35;min-height:34px;font-size:17px;width:220px;max-width:100%;padding:5px 8px}
body#crm-ui #editor #sheet-title:focus{background:#fff;color:#193d43!important}
body#crm-ui #editor #save-status{color:#e0f3f1!important}
body#crm-ui #editor .sheet-actions{flex:1 1 570px;justify-content:flex-end;gap:5px}
body#crm-ui #editor .sheet-actions button{min-height:30px;padding:5px 9px;font-size:12px}
body#crm-ui #editor .ribbon{border-radius:0;padding:5px;gap:4px;background:#edf5f4}
body#crm-ui #editor .ribbon button{background:var(--ref-tab)!important;background-image:var(--ref-tab)!important;color:#244d54!important;border-color:#c9dce0!important;border-radius:7px!important;box-shadow:inset 0 1px #fff,0 2px 3px #1c49530f!important;text-shadow:none!important;min-height:28px;padding:4px 7px;font-size:12px}
body#crm-ui #editor .ribbon button[aria-pressed=true]{background:var(--ref-selected)!important;background-image:var(--ref-selected)!important;border-color:#d8b932!important;color:#293538!important}
body#crm-ui #editor .sheet-formula-bar{padding:5px 8px;gap:7px}
body#crm-ui #editor .sheet-formula-bar input{padding:5px 8px}
body#crm-ui #editor .sheet-foot{flex-wrap:wrap;align-items:center;gap:5px 12px}
body#crm-ui #editor #copy-status{color:#12655f;font-weight:600;flex:1 1 360px}
body#crm-ui #editor #copy-status:empty{display:none}
body#crm-ui #editor #grid td{position:relative}
body#crm-ui #editor #grid td.selected{background-color:var(--sheet-cell-fill,#ecf8f2)!important;box-shadow:inset 0 0 0 1px #7eb8ae}
body#crm-ui #editor #grid td:focus{outline:2px solid #167b67;outline-offset:-2px}
/* Separate copied-range edges remain visible when a new destination is selected. */
body#crm-ui #editor #grid td.copied-cell::after{content:'';position:absolute;inset:0;pointer-events:none;z-index:1;--copy-top:transparent;--copy-right:transparent;--copy-bottom:transparent;--copy-left:transparent;background-image:repeating-linear-gradient(90deg,var(--copy-top) 0 5px,transparent 5px 9px),repeating-linear-gradient(0deg,var(--copy-right) 0 5px,transparent 5px 9px),repeating-linear-gradient(90deg,var(--copy-bottom) 0 5px,transparent 5px 9px),repeating-linear-gradient(0deg,var(--copy-left) 0 5px,transparent 5px 9px);background-size:calc(100% + 9px) 2px,2px calc(100% + 9px),calc(100% + 9px) 2px,2px calc(100% + 9px);background-position:0 0,100% 0,0 100%,0 0;background-repeat:no-repeat}
body#crm-ui #editor #grid td.copy-top::after{--copy-top:#076e62}
body#crm-ui #editor #grid td.copy-right::after{--copy-right:#076e62}
body#crm-ui #editor #grid td.copy-bottom::after{--copy-bottom:#076e62}
body#crm-ui #editor #grid td.copy-left::after{--copy-left:#076e62}
@keyframes r57-copy-march{to{background-position:9px 0,100% 9px,-9px 100%,0 -9px}}
@keyframes r57-icon-motion{0%,100%{transform:translateY(0) rotate(-4deg)}50%{transform:translateY(-3px) rotate(5deg)}}
@media(prefers-reduced-motion:no-preference){
 body#crm-ui :is(#main-content,#crm-topbar,#home,#editor,#workspace-home,.desk-top,.module-navigation,.chat-dock) :is(svg.crm-line-icon,svg.crm-existing-icon,.module-nav-icon>svg,.workspace-action-icon>svg,[data-desk-icon]>svg,.shortcut .icon>svg,.workbook-card-icon>svg,.home-link>svg,.bell-button>svg,.personal-workspace-button>svg),body#crm-ui #desk-brand-icon>svg{animation:r57-icon-motion 2.8s ease-in-out infinite!important;transform-origin:50% 65%;transform-box:fill-box}
 body#crm-ui :is(#main-content,#home,#editor,#workspace-home) :is(a,button):nth-child(even) svg{animation-delay:-1.4s!important}
 body#crm-ui #editor #grid td.copied-cell::after{animation:r57-copy-march .6s linear infinite}
 body#crm-ui #workspace-home[data-paused=true] svg,body#crm-ui #workspace-home.motion-paused svg,body#crm-ui #workspace-home.dh-paused svg{animation-play-state:paused!important}
}
@media(max-width:760px){
 body#crm-ui #main-content .dashboard-header:has(>.pd-toolbar){grid-template-columns:minmax(0,1fr);padding:15px!important}
 body#crm-ui #main-content .dashboard-header-metrics{grid-column:1;grid-row:auto}
 body#crm-ui #main-content .dashboard-header>.pd-toolbar{grid-row:auto}
 body#crm-ui #main-content .page-heading>.header-nav:not([hidden]),body#crm-ui #home .desk-overview{padding-inline:9px!important}
 body#crm-ui #main-content .form-section-picker{flex:1;flex-wrap:wrap;gap:4px}
 body#crm-ui #main-content .form-section-picker select{width:100%;font-size:16px}
 body#crm-ui #home .desk-welcome h1{font-size:23px}
 body#crm-ui #editor .sheet-actions{justify-content:flex-start;flex-basis:100%}
}
@media(pointer:coarse){body#crm-ui #main-content .form-section-picker select,body#crm-ui #main-content .module-form-candidates :is(input:not([type=checkbox]):not([type=radio]):not([type=hidden]),select),body#crm-ui #editor .ribbon button,body#crm-ui #editor .sheet-actions button,body#crm-ui #home .desk-overview>button{min-height:44px!important}}
@media(prefers-reduced-motion:reduce){body#crm-ui #editor #grid td.copied-cell::after{animation:none!important}}

body#crm-ui #main-content .dashboard-header:has(>.pd-toolbar):not(:has(.dashboard-header-metrics)){grid-template-columns:minmax(0,1fr)}

/* R58: shared form contracts, contained text, keyboard-visible attached controls. */
body#crm-ui #main-content .record-editor .section-head{background:var(--r57-teal)!important;color:#fff!important;border-radius:10px;padding:8px 11px!important;margin-bottom:10px!important}
body#crm-ui #main-content .record-editor .section-head :is(h2,.section-number){color:#fff!important}
body#crm-ui #main-content .record-editor .form-grid{gap:9px 12px!important}
body#crm-ui #main-content .record-editor .form-field{min-width:0;margin:0}
body#crm-ui #main-content .record-editor .form-field :is(input,select,textarea){max-width:100%;min-width:0;box-sizing:border-box}
body#crm-ui #main-content .record-editor .form-field :is(label,small){overflow-wrap:anywhere}
body#crm-ui #main-content .executive-header :is(h1,p,.header-copy){min-width:0;overflow-wrap:anywhere}
body#crm-ui #main-content .header-nav :is(a,button):focus-visible{outline:3px solid #0a8078;outline-offset:2px}
body#crm-ui #main-content .page-heading>.access-tabs.header-nav a{background:var(--ref-tab)!important;color:#234d54!important;border:1px solid #bfd3d5;border-radius:22px;box-shadow:inset 0 1px #fff,0 3px 6px #123c4620}
body#crm-ui #main-content .page-heading>.access-tabs.header-nav a[aria-current=page]{background:var(--ref-selected)!important;color:#293538!important;border-color:#d8b932}
