/* Casework phone workspace. Existing desktop layout and tools are unchanged. */

#cwCaseBar .cw-mob-accounting{display:none}
body.mob #cwCaseBar .cw-mob-case-shortcuts:has(.cw-mob-accounting){grid-template-columns:minmax(0,1.45fr) minmax(0,1.12fr) minmax(0,.72fr) 44px}
body.mob #cwCaseBar .cw-mob-case-shortcuts .cw-mob-accounting{display:inline-flex;align-items:center;justify-content:center;min-width:44px;font-weight:750;font-size:18px}
#cwOvDlg .ov-amt .cw-ov-expense,.cw-accounting-total{color:#a22121;font-size:12px;font-weight:700}
html[data-theme=dark] #cwOvDlg .ov-amt .cw-ov-expense,html[data-theme=dark] .cw-accounting-total{color:#ff9d9d}
body.mob #cwOvDlg .ov-amt{white-space:normal;overflow-wrap:anywhere}
#cwMobileAccounting{box-sizing:border-box;width:min(560px,calc(100% - 20px));max-height:calc(100dvh - 30px - env(safe-area-inset-top,0px) - env(safe-area-inset-bottom,0px));padding:0;border:1px solid var(--line);border-radius:14px;background:var(--panel,Canvas);color:var(--ink,CanvasText);overscroll-behavior:contain}
#cwMobileAccounting::backdrop{background:#0008}
#cwMobileAccounting .cw-md-head{position:sticky;top:0;padding:8px 12px;background:var(--panel,Canvas);border-bottom:1px solid var(--line)}
#cwMobileAccounting button{min-height:44px}
.cw-accounting-content{padding:12px;overflow-wrap:anywhere}
.cw-accounting-case{font-weight:650;margin:0 0 8px}
.cw-accounting-total{display:block;font-size:22px;margin:0 0 3px}
.cw-accounting-items{list-style:none;padding:0;margin:12px 0}
.cw-accounting-items li{display:flex;justify-content:space-between;gap:8px;padding:8px 0;border-top:1px solid var(--line)}
.cw-accounting-items li b{white-space:nowrap}
.cw-accounting-items small{display:block;color:var(--muted)}
.cw-accounting-folders h3{font-size:14px;margin:0 0 8px}
.cw-accounting-folders button{margin:0 6px 6px 0;text-align:left;white-space:normal}
body.mob #mobNav.cw-mob-v2 .cw-mob-legacy{display:none}
body.mob #mobNav.cw-mob-v2 button[data-cw-mob]{min-height:50px}
body.mob #mobNav.cw-mob-v2 button[data-cw-mob].on{color:var(--ink)}
body.mob.cw-mob-docs #cwMobileDocuments{display:flex}
#cwMobileDocuments{display:none;position:fixed;inset:var(--cwMobileTop,52px) 0 var(--cwMobileBottom,60px);z-index:570;flex-direction:column;background:var(--side,var(--panel));color:var(--ink);overflow:auto;overscroll-behavior:contain;padding:12px 12px 22px;gap:10px}
body.mob.mob-full #cwMobileDocuments{top:0;bottom:0}
body.mob.cw-mob-comms #cwSide{display:flex!important;position:fixed!important;z-index:580;top:var(--cwMobileTop,52px);bottom:var(--cwMobileBottom,60px);left:0;right:0;width:auto!important;max-width:none!important;margin:0;border-radius:0}
body.mob.cw-mob-comms #cwSide .tl-dock-grip{display:none}
body.mob.mob-full.cw-mob-comms #cwSide{top:0;bottom:0}
.cw-md-head,.cw-mf-head,.cw-pv-head{display:flex;align-items:center;justify-content:space-between;gap:7px}.cw-md-head h2,.cw-mf-head h2,.cw-pv-head h2{margin:0;font-size:17px;overflow-wrap:anywhere}
.cw-md-search,.cw-md-row{background:var(--panel);color:var(--ink);border:1px solid var(--line);border-radius:9px}
.cw-md-search{padding:9px;min-height:44px;width:100%;font-size:16px}
.cw-md-meta{margin:0;font-size:12px;color:var(--muted)}
.cw-md-list{display:grid;gap:7px}.cw-md-row{display:flex;align-items:center;gap:9px;text-align:left;padding:9px;width:100%;min-height:46px;cursor:pointer}
.cw-md-row strong,.cw-md-row small{display:block;overflow-wrap:anywhere}.cw-md-row small{margin-top:3px;font-size:11px;color:var(--muted)}
.cw-md-chip{display:grid;place-items:center;min-width:32px;height:30px;border-radius:6px;background:var(--side);color:var(--ink);font-size:10px;font-weight:750}
.cw-md-grow{flex:1;min-width:0}
.cw-md-empty{padding:10px;border:1px dashed var(--line);font-size:13px;border-radius:8px}
#cwMobilePdf,#cwMobileFiles{padding:0;border:0;color:var(--ink);background:var(--panel)}
#cwMobilePdf[open]{position:fixed;inset:0;max-width:none;max-height:none;width:100vw;height:100dvh;margin:0;display:grid;grid-template-rows:auto minmax(0,1fr) auto}
#cwMobilePdf .cw-pv-head{padding:calc(8px + env(safe-area-inset-top,0px)) 8px 8px;border-bottom:1px solid var(--line)}
#cwMobilePdf .cw-pv-head h2{font-size:14px;line-height:1.15}
.cw-pv-main{overflow:auto;min-height:0;overscroll-behavior:contain;background:var(--side);padding:8px}
.cw-pv-main canvas{display:block;width:100%;height:auto;max-width:740px;margin:auto;background:#fff;box-shadow:0 4px 13px #0002}
.cw-pv-nav{display:flex;align-items:center;justify-content:space-between;gap:5px;padding:8px 8px calc(8px + env(safe-area-inset-bottom,0px));border-top:1px solid var(--line)}
.cw-pv-nav output{font-size:12px;white-space:nowrap}
#cwMobileFiles[open]{width:min(96vw,475px);max-height:65dvh;margin:auto auto max(5px,env(safe-area-inset-bottom,0px));padding:12px;border-radius:13px;border:1px solid var(--line)}
#cwMobileFiles::backdrop{background:#0008}

/* Shared phone geometry; only the case-tab track scrolls sideways. */
body.mob{--cw-phone-gutter:8px;--cw-phone-gap:6px;--cw-phone-radius:9px;width:100%;max-width:100%}
body.mob:not(.mob-full) header.top{width:100%;max-width:100%;overflow:visible;flex-wrap:wrap!important;gap:4px;padding:4px max(var(--cw-phone-gutter),env(safe-area-inset-right,0px)) 4px max(var(--cw-phone-gutter),env(safe-area-inset-left,0px));zoom:1!important}
body.mob:not(.mob-full) header.top>nav.tabs{flex:0 1 auto;min-width:0;max-width:100%;overflow:visible;flex-wrap:wrap;margin-left:0}
body.mob:not(.mob-full):not(.mob-ai)>main{height:calc(100dvh - var(--cwMobileTop,52px) - var(--cwMobileCaseBar,0px) - var(--cwMobileBottom,60px))!important;padding-inline:var(--cw-phone-gutter)!important;overflow-x:hidden}
body.mob #view-map .map-layout{grid-template-columns:minmax(0,1fr)!important;padding-left:0}
body.mob #view-map .map-layout>.mapmain{grid-column:1;min-width:0}
body.mob #view-map .map-layout>#aiRight{grid-column:1;min-width:0;max-width:100%}
body.mob #cwCaseBar{width:100%;min-width:0;padding-inline:var(--cw-phone-gutter)}
body.mob #cwCaseBar .cw-case-info{flex:1 1 100%}
body.mob #cwCaseBar .cw-case-info strong{max-width:100%}
body.mob #cwCaseBar .cw-mob-case-shortcuts:has(.cw-mob-accounting){grid-template-columns:repeat(3,minmax(0,1fr)) 44px;gap:var(--cw-phone-gap)}
body.mob #cwCaseBar .cw-mob-case-shortcuts button{height:44px;align-items:center;border-radius:var(--cw-phone-radius);line-height:1.12}
body.mob #view-map .wsbar{min-width:0;overflow:hidden;gap:var(--cw-phone-gap)}
body.mob #view-map .wsbar .wstabs{flex:1 1 0;min-width:0;touch-action:pan-x;overscroll-behavior-x:contain;padding-inline:0;mask-image:none;-webkit-mask-image:none}
body.mob #view-map .wsbar .wstab,body.mob #view-map .wsbar>button{min-height:44px;border-radius:var(--cw-phone-radius)}
body.mob #mobNav.cw-mob-v2{gap:var(--cw-phone-gap);padding-inline:var(--cw-phone-gutter)}
body.mob #mobNav.cw-mob-v2 button[data-cw-mob]{flex:1 1 0;font-size:clamp(11px,3vw,12px);border-radius:var(--cw-phone-radius)}
body.mob #cwMobileDocuments{padding-inline:var(--cw-phone-gutter)}
body.mob #mobNav.cw-mob-v2 button[data-cw-mob] i{width:20px;height:20px;display:grid;place-items:center;line-height:1}
body.mob #cwMobileDocuments .cw-md-head button,body.mob #view-tl .tl-toolbar :is(button,select),body.mob.cw-mob-comms #cwSide .cw-sidetabs button{min-height:44px}
body.mob #view-tl .tl-toolbar{max-width:100%;min-width:0;padding:6px var(--cw-phone-gutter);gap:var(--cw-phone-gap)}
body.mob.cw-mob-comms #cwSide .cw-sidetabs{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:var(--cw-phone-gap)}
body.mob.cw-mob-comms #cwSide .cw-sidetabs button{padding-inline:4px;white-space:normal}
@media(max-width:360px){body.mob #mobNav.cw-mob-v2{gap:2px;padding-inline:4px}}

#cwPhoneCases{box-sizing:border-box;position:fixed;inset:0;margin:0;width:100%;max-width:none;height:100%;height:100dvh;max-height:none;padding:env(safe-area-inset-top,0px) max(8px,env(safe-area-inset-right,0px)) env(safe-area-inset-bottom,0px) max(8px,env(safe-area-inset-left,0px));border:0;background:var(--panel,Canvas);color:var(--ink,CanvasText);overflow:hidden}
#cwPhoneCases[open]{display:grid;grid-template-rows:auto auto auto minmax(0,1fr)}
#cwPhoneCases::backdrop{background:#0004}
.cw-phone-case-head{display:flex;align-items:center;justify-content:space-between;gap:8px;min-width:0;padding-block:4px}
.cw-phone-case-head h2{font-size:18px;margin:0}
.cw-phone-case-head button{min-height:44px;min-width:54px}
.cw-phone-case-filters{display:grid;grid-template-columns:minmax(0,1fr) minmax(92px,.66fr);gap:6px}
.cw-phone-case-filters input,.cw-phone-case-filters select{width:100%;min-width:0;min-height:44px;padding-inline:7px;font-size:16px;background:var(--panel,Canvas);color:var(--ink,CanvasText);border:1px solid var(--line);border-radius:9px}
.cw-phone-case-count{margin:5px 0;color:var(--muted);font-size:12px}
.cw-phone-case-results{min-height:0;min-width:0;overflow:hidden auto;overscroll-behavior:contain;touch-action:pan-y;padding:0 2px 8px}
.cw-phone-case-group{display:grid;gap:6px;margin:0 0 12px;min-width:0}
.cw-phone-case-group h3{font-size:13px;margin:3px 0;color:var(--muted);overflow-wrap:anywhere}
.cw-phone-case-item.btn{width:100%;min-height:44px;display:flex;align-items:center;justify-content:space-between;gap:8px;text-align:left;border-radius:9px;white-space:normal;overflow-wrap:anywhere;box-shadow:none}
.cw-phone-case-item[aria-current]{border-color:var(--accent);font-weight:700}
.cw-phone-case-current{flex:none;color:var(--muted)}

/* Keep the overview and case picker distinct without changing the desktop strip. */
#cwCaseBar [data-cw-mob-overview],#cwCaseBar .cw-case-picker-phone{display:none}
body.mob:has(#cwCaseBar:not([hidden]) .cw-mob-case-shortcuts) #mcBtn{display:none!important}
body.mob #cwCaseBar .cw-mob-case-shortcuts [data-cw-mob-overview],
body.mob #cwCaseBar .cw-mob-case-shortcuts .cw-case-picker-phone{display:inline-flex}
body.mob #cwCaseBar .cw-mob-case-shortcuts .cw-case-picker-desktop{display:none}
body.mob:has(#mobNav.cw-mob-v2) #cwCaseBar .cw-mob-case-shortcuts [data-route="map"],
body.mob:has(#mobNav.cw-mob-v2) #cwCaseBar .cw-mob-case-shortcuts [data-route="docs"],
body.mob:has(#mobNav.cw-mob-v2) #cwCaseBar .cw-mob-case-shortcuts [data-route="timeline"]{display:none}
body.mob #cwCaseBar .cw-mob-case-shortcuts{display:grid;width:100%;grid-template-columns:minmax(0,1.45fr) minmax(0,1.12fr) minmax(0,.72fr);gap:5px}
body.mob #cwCaseBar .cw-mob-case-shortcuts button{min-width:0;min-height:44px;justify-content:center;padding-inline:5px;white-space:normal;text-align:center}
body.mob #cwCaseBar .cw-mob-case-shortcuts [data-cw-mob-overview]{color:var(--accent);border-color:var(--accent);font-weight:750}

/* Desktop rails must not create implicit columns in the one-column phone map. */
body.mob header.top{min-width:0;max-width:100%;overflow:hidden;zoom:1!important}
body.mob header.top>nav.tabs{flex:0 1 auto;min-width:0;overflow-x:auto;overflow-y:hidden;scrollbar-width:none}
body.mob #view-map .map-layout{grid-template-columns:minmax(0,1fr)!important;padding-left:0}
body.mob #view-map .map-layout>.mapmain{grid-column:1;min-width:0}
body.mob #view-map .map-layout>#aiRight{grid-column:1;min-width:0;max-width:100%}

body.mob #cwAdminMenu>summary{min-height:44px;padding:0 7px;line-height:44px}
#cwPhoneTools{box-sizing:border-box;position:fixed;right:auto;bottom:auto;margin:0;padding:0;max-width:none;border:1px solid var(--line,#d5d7dd);border-radius:12px;background:var(--panel,Canvas);color:var(--ink,CanvasText);box-shadow:0 12px 36px #0003;overflow:hidden}
#cwPhoneTools[open]{display:grid;grid-template-rows:auto minmax(0,1fr)}
#cwPhoneTools::backdrop{background:#0004}
.cw-phone-tools-head{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:5px 10px;border-bottom:1px solid var(--line)}
.cw-phone-tools-head h2{font-size:16px;margin:0}
.cw-phone-tools-head button,.cw-phone-tools-list button{min-height:44px}
.cw-phone-tools-list{min-height:0;overflow:hidden auto;overscroll-behavior:contain;touch-action:pan-y;padding:5px 10px calc(6px + env(safe-area-inset-bottom,0px))}
.cw-phone-tools-list section{display:grid;gap:4px;margin-bottom:6px}
.cw-phone-tools-list h3{font-size:12px;color:var(--muted);margin:4px 0 0}
.cw-phone-tools-list button{width:100%;display:flex;align-items:center;justify-content:space-between;gap:6px;text-align:left;white-space:normal}
.cw-phone-tools-list button[aria-current]{border-color:var(--accent);font-weight:700}
.cw-phone-tools-list small{color:var(--muted);white-space:nowrap}
body.mob #acctAll .aa-top,body.mob #acctAll .trk-foot{flex-wrap:wrap;gap:6px}
body.mob #acctAll .aa-sec,body.mob #acctAll .aa-body{min-width:0;overflow:auto}
body.mob #acctAll .trk-foot button{min-height:44px}

/* Manual case expenses are entered here, not on the map. */
#cwMobileAccounting [hidden]{display:none!important}
#cwMobileAccounting .cw-add-expense{margin:8px 0 2px}
.cw-direct-expense{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:10px;margin:12px 0;padding:12px;border:1px solid var(--line);border-radius:10px}
.cw-direct-expense .wide{grid-column:1/-1}
.cw-direct-expense label{display:grid;min-width:0;gap:4px;font-weight:600}
.cw-direct-expense input{font-size:16px;box-sizing:border-box;width:100%;min-width:0;min-height:44px;color:inherit;background:var(--panel,Canvas);border:1px solid var(--line);border-radius:8px;padding:6px 8px}
.cw-direct-expense output{font-weight:700}
.cw-direct-expense [role=alert]{margin:0;color:var(--ink)}
.cw-direct-expense div.wide{display:flex;flex-wrap:wrap;justify-content:flex-end;gap:8px}
.cw-expense-quantity{display:grid;grid-template-columns:44px minmax(0,1fr) 44px;gap:4px}.cw-expense-quantity button{padding-inline:0}.cw-expense-quantity input[type=number]{appearance:textfield;padding-inline:3px;text-align:center}.cw-expense-quantity input::-webkit-inner-spin-button,.cw-expense-quantity input::-webkit-outer-spin-button{appearance:none;margin:0}@media(max-width:380px){.cw-direct-expense label:has(.cw-expense-quantity){grid-column:1/-1}}

#cwMobileAccounting .cw-accounting-actions{display:flex;align-items:center;flex:0 0 auto;gap:6px}
#cwMobileAccounting .cw-add-expense{margin:0;min-width:44px;padding:0 8px;font-size:24px;font-weight:650;line-height:1}
.cw-direct-expense select{font-size:16px;width:100%;min-width:0;max-width:100%;min-height:44px}
.cw-direct-expense .cw-expense-inclusive{display:flex;align-items:center;justify-content:space-between;gap:8px;min-height:44px}
.cw-direct-expense .cw-expense-inclusive input{width:22px;height:22px;min-height:0}
.cw-direct-expense output{display:grid;gap:3px}
.cw-direct-expense output small,.cw-direct-expense label small{font-weight:500;color:var(--muted)}

.cw-accounting-items li.cw-expense-product-row{display:grid;grid-template-columns:minmax(0,1fr) auto}
.cw-expense-row-controls{grid-column:1/-1;display:flex;align-items:center;gap:5px;flex-wrap:wrap}
.cw-expense-row-controls button{min-width:44px}
.cw-expense-row-controls button[data-expense-action]{font-size:18px}
.cw-expense-row-controls .cw-expense-row-qty{min-width:34px;line-height:44px;text-align:center;font-variant-numeric:tabular-nums;font-weight:650}
.cw-expense-row-controls .cw-expense-remove{color:var(--red,#a22121)}
.cw-expense-remove-label{flex:1 0 100%;font-weight:600}
