#clients .scale-pager{display:none}
#clients .section-head p{font-size:14px}
#clients [hidden]{display:none!important}
#clients[data-client-mode=pending] .customer-toolbar{display:none}
#clients #client-grid{display:block;width:100%;min-width:0}
.customer-toolbar{display:flex;align-items:end;flex-wrap:wrap;gap:12px;padding:16px;margin-bottom:16px;border:1px solid var(--line);border-radius:14px;background:var(--paper)}
.customer-toolbar label{display:grid;gap:7px;min-width:0;font-size:14px;color:var(--muted)}
.customer-toolbar .customer-search{flex:1 1 260px}.customer-toolbar .customer-check{display:flex;align-items:center;gap:8px;min-height:44px}
.customer-toolbar input[type=search],.customer-toolbar select,.customer-dialog input{height:44px;border:1px solid var(--line);border-radius:9px;padding:10px 12px;font:inherit;color:var(--ink);background:var(--paper);min-width:0}
.customer-toolbar input[type=checkbox]{width:18px;height:18px;accent-color:var(--green)}
.customer-layout{display:grid;grid-template-columns:minmax(260px,330px) minmax(0,1fr);gap:18px;align-items:start}
.customer-list{display:grid;gap:8px;min-width:0;max-height:min(900px,calc(100dvh - 120px));overflow:auto;padding:3px;position:sticky;top:16px}.customer-list-heading{display:flex;justify-content:space-between;padding:4px 2px 10px;font-size:15px;font-weight:600}
#clients .customer-row{display:flex;flex-direction:column;align-items:stretch;gap:12px;padding:14px;border-radius:12px;box-shadow:none;background:var(--paper);text-align:left}
#clients .customer-row.active{border-color:var(--green);box-shadow:inset 3px 0 var(--green);background:var(--paper-soft)}
#clients .customer-row b{font-size:15px;color:var(--ink);white-space:normal;overflow-wrap:anywhere}#clients .customer-row small{font-size:13px;white-space:normal;line-height:1.45}
.customer-row-metrics{display:flex;flex-wrap:wrap;gap:6px 12px;align-items:center;font-size:13px}.customer-row-metrics em{width:100%;font-style:normal;color:var(--red,#bf303a)}
#clients .customer-row-metrics b{font-size:14px;font-weight:600}
#clients .customer-detail{padding:24px;border-radius:16px;box-shadow:none;background:var(--paper)}
#clients .customer-detail header,.customer-dialog header{min-height:0;height:auto;padding:0;border:0;margin:0 0 12px;flex-direction:row;text-align:left}
.customer-head{display:flex;align-items:start;justify-content:space-between;gap:16px}.customer-head h3{font-size:26px;margin:6px 0;line-height:1.25;overflow-wrap:anywhere}.customer-head p{font-size:14px;color:var(--muted);margin:6px 0}.customer-head small{font-size:13px;color:var(--muted)}
.customer-head>button{flex:none}.customer-contact{display:flex;gap:8px 16px;flex-wrap:wrap;align-items:center;font-size:15px;line-height:1.5;margin:12px 0;overflow-wrap:anywhere}.customer-contact a{color:var(--green-dark);text-decoration:underline;text-underline-offset:3px;min-height:36px;display:inline-flex;align-items:center;max-width:100%;overflow-wrap:anywhere}
#clients .customer-detail button,.customer-toolbar button,.customer-dialog button,#clients .customer-detail summary{font:inherit;font-size:14px;min-height:44px;padding:10px 13px;line-height:1.35;color:var(--ink);background:var(--paper);border:1px solid var(--line);border-radius:9px;cursor:pointer}
#clients :is(.customer-detail,.customer-toolbar) :is(button,input,select,summary):focus-visible,.customer-dialog :is(input,button):focus-visible{outline:3px solid var(--green);outline-offset:2px}
#clients .customer-detail button.primary-btn,.customer-dialog button.primary-btn{background:var(--green-dark);border-color:var(--green-dark);color:white}
#clients .customer-detail button.danger-btn{color:var(--red,#bf303a);border-top:1px solid var(--line);margin-top:8px}
.customer-actions{display:flex;gap:10px;flex-wrap:wrap;margin:16px 0}.customer-actions details{position:relative}.customer-actions summary{list-style:none;font-weight:600}.customer-actions summary:after{content:' ▾'}.customer-actions summary::-webkit-details-marker{display:none}
.customer-menu{position:absolute;z-index:30;top:calc(100% + 6px);left:0;width:250px;display:grid;padding:8px;border:1px solid var(--line);background:var(--paper);border-radius:12px;box-shadow:0 12px 35px #0003}.customer-actions details:last-child .customer-menu{left:auto;right:0}
#clients .customer-menu button{border:0;text-align:left;white-space:normal}.customer-menu button:hover{background:var(--paper-soft)!important}
.customer-stats{display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:10px;margin:20px 0}
#clients .customer-stats button{white-space:pre-line;text-align:left;min-height:80px;font-size:14px;line-height:1.7;background:var(--paper-soft)}#clients .customer-stats button::first-line{font-size:20px;font-weight:700}#clients .customer-stats button.attention{border-color:var(--red);color:var(--red)}
.customer-tabs{display:flex;gap:4px;border-bottom:1px solid var(--line);margin:0 0 18px;overflow:auto;padding-bottom:4px}
#clients .customer-tabs button{border:0;border-radius:0;flex:none;font-weight:600;background:transparent}#clients .customer-tabs [aria-selected=true]{color:var(--green-dark);box-shadow:inset 0 -3px var(--green)}
.customer-section{margin:18px 0}.customer-section header,.customer-section-header{display:flex;flex-wrap:wrap;justify-content:space-between;align-items:center;gap:10px;margin-bottom:8px}.customer-detail h4{font-size:17px;margin:0}.customer-section h4 span{font-weight:400;color:var(--muted)}
.customer-item{display:flex;align-items:start;justify-content:space-between;gap:12px;padding:14px 0;border-bottom:1px solid var(--line);min-width:0}.customer-item>div:first-child{min-width:0}.customer-item b{font-size:15px;line-height:1.4;overflow-wrap:anywhere}.customer-item small{display:block;font-size:13px;line-height:1.6;color:var(--muted);margin-top:4px;overflow-wrap:anywhere}.customer-item p{font-size:14px;line-height:1.5;white-space:pre-wrap;overflow-wrap:anywhere;margin:8px 0}.customer-item .customer-contact{margin:0}.customer-item-actions{display:flex;gap:6px;flex-wrap:wrap;justify-content:end;flex:none;max-width:45%}
.customer-list-pager{display:flex;align-items:center;justify-content:space-between;gap:8px;padding:14px 0;font-size:13px;color:var(--muted)}#clients .customer-list-pager button{font-size:14px;min-height:40px;padding:8px 10px;border:1px solid var(--line);border-radius:8px;background:var(--paper);color:var(--ink)}.customer-list-pager button:disabled{opacity:.45;cursor:default}
.customer-subnav{display:flex;gap:6px;flex-wrap:wrap;margin:0 0 16px}#clients .customer-subnav [aria-pressed=true]{background:var(--paper-soft);border-color:var(--green);color:var(--green-dark)}
.customer-state,.customer-empty,.customer-hint{font-size:14px;line-height:1.6;color:var(--muted);padding:10px 0}.customer-state[role=alert]{color:var(--red)}.customer-balance{display:flex;gap:8px 20px;flex-wrap:wrap;font-size:15px;padding:14px;background:var(--paper-soft);border-radius:10px}
.customer-rule-grid{display:grid;grid-template-columns:1fr 1fr;gap:20px}.customer-rule-grid dt{font-size:14px;color:var(--muted);margin-bottom:5px}.customer-rule-grid dd{font-size:16px;margin:0;overflow-wrap:anywhere}
.customer-expanded .customer-layout{grid-template-columns:1fr}.customer-expanded .customer-list{display:none}
.customer-dialog{width:min(760px,calc(100vw - 32px));max-height:calc(100dvh - 32px);padding:24px;border:1px solid var(--line);border-radius:16px;background:var(--paper);color:var(--ink);box-shadow:0 24px 80px #0005;overflow:auto}.customer-dialog::backdrop{background:#0008}.customer-dialog header{display:flex;justify-content:space-between;align-items:start;gap:12px;margin-bottom:20px}.customer-dialog h2{font-size:22px;margin:0}.customer-dialog p{font-size:15px;line-height:1.6}.customer-dialog form{display:grid;gap:14px}.customer-dialog label{display:grid;gap:6px;font-size:14px}.customer-dialog footer{display:flex;gap:10px;flex-wrap:wrap}.customer-dialog [role=alert]{color:var(--red)}
html[data-theme=dark] #clients .customer-detail button.primary-btn,html[data-theme=dark] .customer-dialog button.primary-btn{color:#10200a}
@media(max-width:1250px){.customer-layout{grid-template-columns:260px minmax(0,1fr)}.customer-stats{grid-template-columns:1fr 1fr}.customer-head{flex-wrap:wrap}}
@media(max-width:900px){.customer-layout{grid-template-columns:1fr}.customer-list{max-height:330px;overflow:auto;padding:2px;position:static}.customer-head h3{font-size:23px}.customer-item{flex-wrap:wrap}.customer-item-actions{max-width:100%}}
@media(max-width:520px){#clients .customer-detail{padding:14px}.customer-toolbar{padding:12px}.customer-toolbar>label{width:100%}.customer-stats{gap:6px}#clients .customer-stats button{padding:10px;font-size:13px}#clients .customer-stats button::first-line{font-size:18px}.customer-rule-grid{grid-template-columns:1fr}.customer-actions{gap:6px}.customer-dialog{padding:18px}.customer-menu{width:235px}.customer-head>button{min-height:40px!important}.customer-contact{display:grid}}

/* Orders lead the card; service and financial totals remain distinct. */
#client-form.customer-form{width:min(600px,calc(100vw - 24px));max-height:calc(100dvh - 32px);padding:0;border-radius:8px;overflow:auto}
#client-form [hidden]{display:none!important}
#client-form .modal-head{padding:18px 20px;margin:0;border-bottom:1px solid var(--line);min-height:0;display:flex;flex-direction:row;align-items:center}
#client-form .modal-head h2{font-size:20px;line-height:1.3;margin:0;flex:1}
#client-form .customer-form-body label{display:grid;gap:6px;margin:0;font-size:13px;font-weight:500;color:var(--ink)}
#client-form .customer-form-body :is(input,select){min-height:40px;width:100%;padding:8px 10px;font:inherit;font-size:14px;border:1px solid var(--line);border-radius:6px;background:var(--paper);color:var(--ink)}
#client-form .modal-actions{padding:14px 20px;margin:0;border-top:1px solid var(--line);gap:8px;position:sticky;bottom:0;background:var(--paper)}
#client-form .modal-actions button{font-size:14px;line-height:1.3;min-height:38px;padding:8px 14px;border-radius:6px}
#client-form :is(input,select,button,summary):focus-visible{outline:2px solid var(--green);outline-offset:2px}
#client-form .customer-contact-fields{padding:16px 0 0;margin:0;border:0;border-top:1px solid var(--line);display:grid;gap:14px;min-width:0}
#client-form .customer-contact-fields legend{font-size:14px;font-weight:600;padding:0 8px 0 0}
#client-form .customer-extra-fields>summary{font-size:13px;cursor:pointer;background:none;border:0;padding:8px 0;min-height:32px}
.customer-extra-body{display:grid;gap:14px;padding:12px 0 0}.customer-required{font-size:11px;color:var(--muted);font-weight:400}
@media(max-width:520px){#client-form .modal-head{padding:16px}#client-form .modal-actions{padding:12px 16px}#client-form .form-row{grid-template-columns:1fr}}
#clients #client-grid .customer-layout{grid-template-columns:248px minmax(0,1fr);gap:16px;align-items:start}
#clients #client-grid .customer-detail{border:0;border-left:1px solid var(--line);border-radius:0;padding:0 0 0 16px;background:transparent;min-width:0}
#clients #client-grid .customer-head{margin:0 0 6px;align-items:center}
#clients #client-grid .customer-head h3{margin:0 0 3px;font-size:20px;line-height:1.3}
#clients #client-grid .customer-row{border-radius:6px;padding:10px;gap:6px;border:1px solid var(--line)}
#clients #client-grid .customer-row.active{box-shadow:none;border-color:var(--green)}
#clients #client-grid .customer-row small{font-size:12px}
.customer-primary-contact{display:flex;align-items:center;gap:6px 12px;flex-wrap:wrap;margin:6px 0 10px}
#clients .customer-primary-contact .customer-contact{margin:0;font-size:13px;gap:6px 12px}
.customer-contact-origin{color:var(--muted);font-size:12px}
#clients .customer-primary-contact>button{margin-left:auto;min-height:30px;padding:4px 8px;font-size:12px}
#clients #client-grid .customer-stats{display:flex;gap:0;border-block:1px solid var(--line);margin:10px 0;background:var(--paper)}
#clients #client-grid .customer-stats button{flex:1;min-width:0;min-height:58px;border:0;border-right:1px solid var(--line);border-radius:0;background:transparent;line-height:1.55;font-size:12px;padding:7px 12px}
#clients #client-grid .customer-stats button:last-child{border-right:0}
#clients #client-grid .customer-stats button::first-line{font-size:17px}
#clients #client-grid .customer-tabs{margin:0 0 10px;gap:0}
#clients #client-grid .customer-tabs button{min-height:36px;padding:7px 10px;font-size:13px}
#clients #client-grid .customer-detail :is(.customer-section,.customer-section-header) h4{font-size:15px}
#clients #client-grid .customer-section{margin:14px 0}
#clients #client-grid .customer-section header{margin-bottom:6px}
#clients #client-grid .customer-balance{padding:6px 0;border-radius:0;background:none;font-size:12px;gap:5px 16px}
#clients #client-grid .customer-operational-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,330px),1fr));gap:16px}
#clients .customer-order-table{overflow:auto;max-width:100%}
.customer-order-labels,.customer-order{display:grid;grid-template-columns:minmax(210px,1.4fr) minmax(150px,1fr) minmax(180px,1.1fr) 120px 80px;gap:12px;min-width:780px}
.customer-order-labels{font-size:12px;color:var(--muted);padding:8px 0;border-bottom:1px solid var(--line)}
.customer-order{padding:12px 0;border-bottom:1px solid var(--line);font-size:13px;align-items:start}
.customer-order>div{min-width:0}.customer-order a{color:var(--ink);text-decoration:none}.customer-order a:hover{text-decoration:underline;text-underline-offset:3px}
.customer-order b{font-size:14px;line-height:1.45;overflow-wrap:anywhere}
.customer-order small{display:block;font-size:12px;line-height:1.5;color:var(--muted);margin-top:4px;overflow-wrap:anywhere}
.customer-order summary{cursor:pointer;padding:6px 0;font-size:12px;color:var(--green-dark)}
#clients #client-grid .customer-order details>summary{min-height:0;border:0;border-radius:0;background:none;padding:4px 0;font-size:12px;line-height:18px}
.customer-order details p{font-size:13px;line-height:1.6;white-space:pre-wrap;overflow-wrap:anywhere;margin:6px 0;max-width:65ch}
.customer-order ul{list-style:none;padding:0;margin:4px 0}.customer-order li{display:grid;grid-template-columns:1fr auto;gap:2px 8px;padding:5px 0;border-bottom:1px solid var(--line);font-size:12px}.customer-order li b{font-size:12px;font-weight:500;white-space:nowrap}.customer-order li small{grid-column:1/-1;margin:0}
.customer-order-status{display:inline-block;padding:2px 5px;border:1px solid var(--line);border-radius:4px;font-size:12px}
.customer-order-status[data-state=waiting],.customer-order-status[data-state=blocked]{color:var(--amber-dark,#8b5011);background:var(--paper-soft)}
.customer-order-status[data-state=active]{color:var(--green-dark)}
.customer-order-money{font-variant-numeric:tabular-nums;text-align:right}.customer-order-money>b>small{display:inline;font-weight:400}
.customer-order .customer-item-actions{max-width:none}.customer-order .customer-item-actions button{min-height:32px;padding:5px 8px;font-size:12px}
#clients #client-grid .customer-item{padding:10px 0}.customer-contact-sources{display:flex;flex-wrap:wrap;gap:6px 12px;margin-top:6px}.customer-contact-sources a{font-size:12px;color:var(--green-dark);text-decoration:underline;text-underline-offset:3px}
.customer-mobile-back{display:none}
.customer-filter-toggle{display:none}
.customer-order-labels>span:nth-child(4){text-align:right}
@media(max-width:1100px){#clients #client-grid .customer-layout{grid-template-columns:210px minmax(0,1fr)}#clients #client-grid .customer-stats{flex-wrap:wrap}#clients #client-grid .customer-stats button{flex-basis:40%}}
@media(max-width:700px){#clients #client-grid .customer-layout{grid-template-columns:1fr}#clients #client-grid .customer-detail{border:0;padding:0}#clients #client-grid .customer-list{max-height:none;position:static}#clients [data-customer-detail=true]>.customer-list,#clients [data-customer-detail=false]>.customer-detail{display:none}.customer-mobile-back{display:block;margin-bottom:10px}.customer-order-labels{display:none}.customer-order{min-width:0;grid-template-columns:minmax(0,1fr) auto;gap:8px}.customer-order>div:nth-child(1),.customer-order>div:nth-child(2),.customer-order>div:nth-child(3){grid-column:1/-1}.customer-order>div:nth-child(4){text-align:left}.customer-order>div:nth-child(5){grid-column:2;grid-row:4}.customer-order small{margin-top:2px}.customer-order details p{max-width:100%}#clients #client-grid .customer-stats button{min-height:64px}.customer-primary-contact{align-items:start}.customer-primary-contact .customer-contact{display:flex!important}.customer-toolbar .customer-check{min-height:36px}.customer-toolbar>label:not(.customer-search){flex:1 1 130px}.customer-head>button{display:none}}
@media(max-width:700px){#clients .customer-toolbar{gap:6px;align-items:end}#clients .customer-toolbar .customer-search{flex:1 1 120px;width:auto}#clients .customer-filter-toggle{display:inline-flex}#clients .customer-toolbar:not(.customer-filters-open)>label:not(.customer-search),#clients .customer-toolbar:not(.customer-filters-open)>[data-customer-action=reset]{display:none}#clients .customer-toolbar.customer-filters-open>label:not(.customer-search){flex-basis:45%;width:auto}#clients .customer-toolbar.customer-filters-open>.customer-check{flex-basis:100%}}
@media(max-width:700px){#clients:not([data-client-mode=pending]):has(.customer-layout[data-customer-detail=true])>.customer-toolbar,#clients:not([data-client-mode=pending]):has(.customer-layout[data-customer-detail=true])>.section-head,#clients:not([data-client-mode=pending]):has(.customer-layout[data-customer-detail=true]) #client-deletion-tabs{display:none}#clients #client-grid .customer-stats button{min-height:52px}}

#clients #client-grid .customer-detail{min-height:calc(100dvh - 180px)}
#clients #client-grid .customer-head{min-height:48px}
#clients #client-grid .customer-list{scrollbar-gutter:stable}
#clients.customer-expanded #client-grid .customer-layout{grid-template-columns:minmax(0,1fr)}
.customer-loading{min-height:360px;padding:18px 0;font-size:14px;color:var(--muted)}
.customer-contract details{margin-top:8px}.customer-contract details>button{display:block;margin:6px 0}
.customer-contract-details{display:grid;grid-template-columns:150px 1fr;gap:12px;font-size:14px}
.customer-contract-details dt{color:var(--muted)}.customer-contract-details dd{margin:0;overflow-wrap:anywhere}

#contact-form.customer-form,#portal-user-form.customer-form{width:min(600px,calc(100vw - 24px));max-height:calc(100dvh - 32px);padding:0;border-radius:8px;overflow:auto}
#contact-form [hidden],#portal-user-form [hidden]{display:none!important}
#contact-form .modal-head,#portal-user-form .modal-head{padding:18px 20px;margin:0;border-bottom:1px solid var(--line);min-height:0}
#contact-form .modal-head h2,#portal-user-form .modal-head h2{font-size:20px;line-height:1.3;margin:0}
.customer-form-body{display:grid;gap:16px;padding:18px 20px}
.customer-form-company{margin:0;padding:0 0 12px;border-bottom:1px solid var(--line);font-size:14px;font-weight:600;overflow-wrap:anywhere}
#contact-form .customer-form-body label,#portal-user-form .customer-form-body label{display:grid;gap:6px;margin:0;font-size:13px;font-weight:500;color:var(--ink)}
#contact-form .customer-form-body :is(input:not([type=checkbox]),select),#portal-user-form .customer-form-body :is(input:not([type=checkbox]),select){min-height:40px;width:100%;padding:8px 10px;font:inherit;font-size:14px;border:1px solid var(--line);border-radius:6px;background:var(--paper);color:var(--ink)}
#contact-form .customer-form-switch,#portal-user-form .customer-form-switch{display:flex;justify-content:space-between;align-items:center;border-top:1px solid var(--line);padding-top:14px;min-height:40px}
.customer-form-switch input{width:18px;height:18px;accent-color:var(--green)}
#contact-form .customer-form-body label.customer-form-switch,#portal-user-form .customer-form-body label.customer-form-switch{display:flex;flex-direction:row;justify-content:space-between;align-items:center}
#contact-form .modal-head h2,#portal-user-form .modal-head h2{flex:1;min-width:0}
#portal-user-form [data-access-fields]{display:grid;gap:16px}
.customer-access-identity{display:grid;grid-template-columns:80px minmax(0,1fr);gap:12px;padding:12px 0;border-block:1px solid var(--line);font-size:14px}
.customer-access-identity>span{color:var(--muted)}.customer-access-identity strong{overflow-wrap:anywhere;font-weight:600}
.customer-form-note{font-size:13px!important;line-height:1.5;color:var(--muted);margin:0}
.customer-form-error{font-size:13px;line-height:1.5;color:var(--red,#b72336);margin:0}
#contact-form .modal-actions,#portal-user-form .modal-actions{padding:14px 20px;margin:0;border-top:1px solid var(--line);gap:8px;position:sticky;bottom:0;background:var(--paper)}
#contact-form .modal-actions button,#portal-user-form .modal-actions button{font-size:14px;line-height:1.3;min-height:38px;padding:8px 14px;border-radius:6px}
.customer-credential-row{display:grid;grid-template-columns:minmax(0,1fr) 40px;gap:6px}
#portal-user-form .customer-icon-button{display:grid;place-items:center;width:40px;height:40px;padding:8px;border:1px solid var(--line);border-radius:6px;background:var(--paper);color:var(--ink)}
.customer-icon-button svg{width:18px;height:18px}
#portal-user-form [data-access-result]{display:grid;gap:14px;margin:0;padding:0}
#portal-user-form [data-access-result] h3{font-size:17px;margin:0}
#portal-user-form [data-access-result]>p{margin:0;font-size:14px;overflow-wrap:anywhere}
#portal-user-form .customer-access-copy{display:inline-flex;align-items:center;justify-content:center;gap:8px;min-height:40px;padding:8px 12px;border:1px solid var(--green-dark);border-radius:6px;background:var(--green-dark);color:var(--paper);font:inherit;font-size:14px;cursor:pointer}
.customer-access-copy svg{width:18px;height:18px;flex:none}
#portal-user-form [data-access-result]>a{font-size:14px;overflow-wrap:anywhere;color:var(--green-dark);text-underline-offset:3px}
#contact-form :is(input,select,button):focus-visible,#portal-user-form :is(input,select,button):focus-visible{outline:2px solid var(--green);outline-offset:2px}
@media(max-width:700px){#clients .customer-toolbar>.customer-relationship{display:grid!important;flex:1 1 140px}#clients #client-grid .customer-detail{min-height:calc(100dvh - 220px)}}
@media(max-width:520px){.customer-contract-details{grid-template-columns:1fr;gap:6px}.customer-form-body{padding:16px}.customer-form .form-row{grid-template-columns:1fr}.customer-access-identity{grid-template-columns:1fr;gap:4px}#contact-form .modal-head,#portal-user-form .modal-head{padding:16px}#contact-form .modal-actions,#portal-user-form .modal-actions{padding:12px 16px}}
