/* LetRecord v11.1 — final QA polish and responsive hardening */
html{-webkit-text-size-adjust:100%;text-size-adjust:100%;scroll-behavior:smooth}
body{overflow-wrap:anywhere}
img,svg,video,canvas{max-width:100%}
button,input,select,textarea{max-width:100%}
button,[role="button"],a,select,input[type="checkbox"],input[type="radio"]{touch-action:manipulation}
:where(.main,.route-view,.card,.route-card,.workspace-dialog,.dialog-body-grid,.real-case-view,.real-overview-grid,.real-side-column,.readiness-grid,.portal-admin-grid,.people-grid,.property-grid,.case-list-row,.workspace-case-row,.team-row,.audit-row,.notification-entry)>*{min-width:0}
:where(h1,h2,h3,h4,p,strong,small,span,dd,dt,code,a,button){overflow-wrap:anywhere}

/* keyboard accessibility */
:where(button,a,input,select,textarea,[tabindex]):focus-visible{outline:3px solid rgba(42,119,204,.28);outline-offset:2px}
.side-nav button:focus-visible,.tabs button:focus-visible{outline-color:rgba(255,255,255,.5)}

/* stable interaction sizing */
.primary-button,.secondary-button,.danger-button,.side-nav button,.icon-button,.profile,.mobile-menu{min-height:40px}
.icon-button,.mobile-menu{min-width:40px}

/* dialogs: always fit inside short and narrow screens */
dialog{max-height:min(92dvh,920px);overflow:auto;overscroll-behavior:contain}
dialog.workspace-dialog{width:min(720px,calc(100vw - 28px))}
dialog.workspace-dialog>form,dialog.workspace-dialog>.dialog-head,dialog.workspace-dialog>.created-share-url,dialog.workspace-dialog>.case-summary-grid,dialog.workspace-dialog>.case-summary-next{min-width:0}
.workspace-dialog .dialog-head{position:sticky;top:0;z-index:2;background:#fff;padding-top:18px}
.workspace-dialog menu{position:sticky;bottom:0;z-index:2;background:#fff;border-top:1px solid #e7edf3;margin-top:12px;padding-bottom:max(14px,env(safe-area-inset-bottom))}
.workspace-dialog input,.workspace-dialog select,.workspace-dialog textarea{min-width:0;width:100%}

/* tables and wide record rows must never clip the viewport */
.evidence-table,.compliance-table,.document-library,.audit-list,.team-list,.portal-submission-list,.portal-link-list{max-width:100%}
.evidence-table>div,.compliance-table>div,.document-library>div{min-width:0}
.evidence-table code{white-space:normal;word-break:break-all}

/* prevent long user content from pushing action controls off-screen */
.workspace-case-row,.case-list-row,.inbox-row,.deadline-list article,.portal-submission,.portal-link-row,.team-row,.audit-row,.share-row{max-width:100%}
.workspace-case-row :where(strong,small,p),.case-list-row :where(strong,small),.portal-submission :where(strong,small,p,dd),.portal-link-row :where(strong,small,code){min-width:0;overflow-wrap:anywhere}

/* fixed chrome: safe areas and reliable stacking */
.topbar{padding-top:env(safe-area-inset-top);height:calc(72px + env(safe-area-inset-top));z-index:45}
.sidebar{padding-top:max(18px,env(safe-area-inset-top));padding-bottom:max(18px,env(safe-area-inset-bottom));z-index:55}
.notification-panel,.profile-menu,.search-results{max-width:calc(100vw - 20px)}

/* mobile navigation backdrop */
body.nav-open{overflow:hidden}
body.nav-open::after{content:"";position:fixed;inset:0;background:rgba(8,24,41,.42);backdrop-filter:blur(1.5px);z-index:50}
body.nav-open .sidebar{z-index:60}

/* top bar resilience */
.search-wrap{min-width:0}
.search-wrap input{min-width:0}
.profile{min-width:0}
.profile>span:not(.avatar){min-width:0}
.profile strong,.profile small{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}

/* case/workspace polish for content-heavy records */
#realCaseView .card,#realCaseView .real-detail-panel,#realCaseView .real-summary-card{overflow:visible}
#realCaseView :where(.real-person-summary,.real-repair-summary,.real-compliance-summary,.real-record-summary) :where(dt,dd,strong,small,p){line-height:1.45}
#realCaseView .real-side-column{align-items:start}
#realCaseView .real-detail-head{gap:14px}
#realCaseView .real-detail-head>div{min-width:0}

/* ensure notifications/search/profile cannot run off-screen */
.notification-panel{right:0;width:min(390px,calc(100vw - 24px));max-height:min(70dvh,620px);overflow:auto}
.profile-menu{right:12px;width:min(280px,calc(100vw - 24px));max-height:70dvh;overflow:auto}
.search-results{max-height:min(60dvh,520px);overflow:auto}

/* responsive production-readiness rows */
@media(max-width:760px){
  .readiness-head,.portal-submission header,.portal-link-row header,.share-row,.invite-row{align-items:flex-start;flex-direction:column}
  .team-role{width:100%;flex-wrap:wrap}.team-role select{max-width:100%}
  .audit-row{grid-template-columns:35px minmax(0,1fr)}.audit-row time{grid-column:2;white-space:normal}
  .readiness-head>.primary-button,.readiness-head>.secondary-button{width:100%;justify-content:center}
}

@media(max-width:900px){
  .topbar{height:calc(64px + env(safe-area-inset-top))}
  .main{padding-top:calc(86px + env(safe-area-inset-top))}
  .sidebar{width:min(286px,86vw);box-shadow:18px 0 45px rgba(10,31,51,.2)}
  .mobile-menu{display:grid;place-items:center;border-radius:10px}
  .search-wrap{flex:1}
}

@media(max-width:640px){
  .main{padding-left:12px;padding-right:12px;padding-bottom:max(28px,env(safe-area-inset-bottom))}
  .topbar{padding-left:10px;padding-right:10px}
  .topbar .search-wrap{height:42px}
  .topbar .search-wrap input{font-size:16px} /* avoids iOS input zoom */
  .notification-panel{position:fixed;top:calc(68px + env(safe-area-inset-top));left:10px;right:10px;width:auto;max-width:none}
  .profile-menu{position:fixed;top:calc(68px + env(safe-area-inset-top));left:10px;right:10px;width:auto;max-width:none}
  .search-results{position:fixed;top:calc(68px + env(safe-area-inset-top));left:10px;right:10px;width:auto;max-width:none}
  .route-heading{margin-bottom:20px}.route-heading h1{line-height:1.15}
  .action-heading{gap:14px}
  .action-heading>.primary-button{min-height:44px}
  .card,.route-card{border-radius:12px}
  dialog.workspace-dialog{width:calc(100vw - 16px);max-height:94dvh;border-radius:14px}
  .workspace-dialog .dialog-head{padding-left:16px!important;padding-right:16px!important}
  .dialog-body-grid,.workspace-dialog menu,.created-share-url,.case-summary-grid{padding-left:16px!important;padding-right:16px!important}
  .workspace-dialog menu{display:grid;grid-template-columns:1fr;gap:8px}
  .workspace-dialog menu button{width:100%;justify-content:center;min-height:44px}
  .toast{left:10px;right:10px;bottom:max(10px,env(safe-area-inset-bottom));width:auto;max-width:none}
  .property-grid{grid-template-columns:1fr!important}
  .deadline-summary{display:grid;grid-template-columns:1fr;gap:8px}
  .portal-admin-summary{grid-template-columns:1fr!important}
}

@media(max-width:420px){
  .topbar{gap:5px}.mobile-menu,.icon-button{width:38px;min-width:38px}.avatar{width:34px;height:34px}
  .search-wrap svg{display:none}.search-wrap{padding-left:9px;padding-right:9px}.search-wrap input{font-size:15px}
  .stat-grid{grid-template-columns:1fr!important}
  .case-actions{display:grid!important;grid-template-columns:1fr!important;width:100%}.case-actions>*{width:100%;justify-content:center}
  .tabs{gap:8px;overflow-x:auto;scrollbar-width:none;padding-bottom:3px}.tabs::-webkit-scrollbar{display:none}.tabs button{white-space:nowrap;min-height:40px}
  .real-case-tabs{overflow-x:auto;scrollbar-width:none}.real-case-tabs::-webkit-scrollbar{display:none}.real-case-tabs button{white-space:nowrap}
  .inbox-row,.deadline-list article{grid-template-columns:1fr!important}.inbox-row>*{grid-column:1!important}.deadline-list article>div{padding-left:0!important}.deadline-list time{border-right:0!important;border-bottom:1px solid #e3eaf0;padding-bottom:9px;justify-items:start!important}
  .team-row{grid-template-columns:34px minmax(0,1fr)}
}

/* landscape phones / short viewports */
@media(max-height:560px) and (orientation:landscape){
  .sidebar{overflow-y:auto}.record-card{display:none}
  dialog{max-height:96dvh}
  .notification-panel,.profile-menu,.search-results{max-height:72dvh}
}

/* accessibility preferences */
@media(prefers-reduced-motion:reduce){*,*::before,*::after{scroll-behavior:auto!important;animation-duration:.01ms!important;animation-iteration-count:1!important;transition-duration:.01ms!important}}
@media(prefers-contrast:more){.card,.route-card,input,select,textarea,button{border-color:#8da2b7!important}.muted,small{color:#51677e!important}}
body.dialog-open{overflow:hidden}
.demo-workspace-banner{display:flex;align-items:center;gap:14px;margin:0 0 18px;padding:12px 16px;border:1px solid #f3c969;border-radius:12px;background:#fff8df;color:#664b08}.demo-workspace-banner[hidden]{display:none}.demo-workspace-banner strong{font-size:.78rem;letter-spacing:.08em}.demo-workspace-banner span{font-size:.88rem}

/* Help centre */
.help-contact{display:flex;align-items:center;justify-content:space-between;gap:24px;padding:24px;margin-bottom:18px;background:linear-gradient(135deg,var(--navy),#164a67);color:#fff;overflow:hidden;position:relative}
.help-contact::after{content:"?";position:absolute;right:18px;top:-38px;font-size:10rem;font-weight:900;line-height:1;color:rgba(255,255,255,.055);pointer-events:none}
.help-contact-copy{max-width:760px;position:relative;z-index:1}.help-contact-copy>span,.help-card-title small{display:block;font-size:.67rem;letter-spacing:.14em;font-weight:800;color:#72dec5}.help-contact h2{margin:6px 0 5px;font-size:1.25rem}.help-contact p{margin:0;color:#c8d9e5;font-size:.86rem}
.help-contact-actions{display:flex;flex-wrap:wrap;gap:10px;position:relative;z-index:1;flex:none}.help-contact .primary-button{background:#fff;color:var(--navy);box-shadow:none;text-decoration:none}.help-contact .secondary-button{background:rgba(255,255,255,.08);border-color:rgba(255,255,255,.28);color:#fff}
.help-guide-grid{grid-template-columns:repeat(2,minmax(0,1fr))}.help-card{padding:22px;position:relative;overflow:hidden}.help-card-title{display:flex;align-items:center;gap:12px;margin-bottom:14px}.help-card-title>span{width:42px;height:42px;display:grid;place-items:center;flex:none;border-radius:11px;background:var(--mint);color:var(--teal)}.help-card-title>span svg{width:1.2rem}.help-card-title h2{margin:2px 0 0;font-size:1rem}.help-card-title small{color:var(--teal)}
.help-card p{margin:9px 0;color:var(--muted);font-size:.82rem;line-height:1.55}.help-card ul,.help-card ol{margin:0;padding-left:1.2rem;color:var(--muted);font-size:.82rem;line-height:1.55}.help-card li+li{margin-top:5px}.help-card strong{color:var(--ink)}.help-card-emphasis{border-color:color-mix(in srgb,var(--teal) 35%,var(--line));background:linear-gradient(145deg,var(--white),var(--mint))!important}
.help-boundaries{display:grid;grid-template-columns:44px 1fr;align-items:start;gap:14px;margin-top:18px;padding:20px 22px}.help-boundaries>div{width:42px;height:42px;border-radius:11px;display:grid;place-items:center;background:#fff3d8;color:#8d6300}.help-boundaries p{margin:0;color:var(--muted);font-size:.82rem;line-height:1.55}.help-boundaries strong{color:var(--ink)}
@media(max-width:900px){.help-contact{align-items:flex-start;flex-direction:column}.help-contact-actions{width:100%}.help-guide-grid{grid-template-columns:1fr}}
@media(max-width:640px){.help-contact,.help-card,.help-boundaries{padding:17px}.help-contact-actions{display:grid}.help-contact-actions>*{width:100%}.help-boundaries{grid-template-columns:1fr}.help-contact::after{display:none}}
