:root{--content-max:1480px;--control-h:38px;--radius:12px}

main{padding:22px 26px 52px;overflow-x:hidden}
header,.page{width:100%;max-width:var(--content-max);margin-left:auto;margin-right:auto}
header{height:auto;min-height:52px;align-items:center;margin-bottom:18px;padding-bottom:14px}
header h1{font-size:21px}

.panel{padding:18px;margin:14px 0;border-radius:var(--radius)}
.panel h2,.panel h3{margin-top:0;color:#1d2939}
.panel>p{margin:5px 0 14px;color:#667085;font-size:12px;line-height:1.65}

.toolbar{display:flex;flex-wrap:wrap;align-items:flex-end;gap:10px;padding:14px;margin:0 0 14px}
.toolbar>label{display:grid;gap:5px;flex:0 1 210px;min-width:180px}
.toolbar>label:has(input[type="checkbox"]){display:flex;align-items:center;align-self:center;flex:0 0 auto;min-width:0;gap:7px}
.toolbar>label input[type="checkbox"]{width:auto}
.toolbar>input{flex:1 1 260px;min-width:220px;max-width:420px}
.toolbar>select{flex:0 1 190px;min-width:160px;max-width:240px}
.toolbar>button{flex:0 0 auto;min-height:var(--control-h);margin:0;justify-self:auto}
.toolbar input,.toolbar select{height:var(--control-h)}

.stats{grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px}
.stat{padding:15px 16px;min-height:82px}
.stat b{font-size:20px;line-height:1.2;overflow-wrap:anywhere}
.detail-stats{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}

table{font-size:13px}
th,td{padding:10px 9px;vertical-align:middle}
thead th{top:-18px;height:42px;white-space:nowrap}
tbody tr:last-child td{border-bottom:0}
td code{overflow-wrap:anywhere;word-break:break-all}
.panel:has(>table){overflow-x:auto;scrollbar-gutter:stable}
.panel table:has(#users-body){min-width:1120px}
.panel table:has(#codes-body){min-width:1080px}
.panel table:has(#ledger-body){min-width:1160px}
.panel table:has(#usage-body){min-width:1450px}
.panel table:has(#models-body){min-width:1380px}

.actions{display:flex;flex-wrap:wrap;gap:6px;min-width:180px;max-width:310px}
.actions button{min-width:auto;padding:6px 10px;line-height:1.25}
td:last-child .actions{justify-content:flex-start}
.pager{position:sticky;left:0;justify-content:space-between;min-width:320px;padding-top:16px}
.pager span{flex:1;text-align:center}

.editor-shell{background:#fff;border:1px solid #e5e7eb;border-radius:var(--radius);padding:12px;margin-bottom:14px}
.editor-toggle{margin:0;padding:8px 13px}
.editor-form{margin:10px 0 0;border:0;border-top:1px solid #eef0f3;border-radius:0;padding:18px 6px 6px;grid-template-columns:repeat(2,minmax(0,1fr));gap:12px 22px;box-shadow:none}
.field,.wide.field{grid-template-columns:150px minmax(0,1fr);gap:12px}
.field>span{font-size:12px;text-align:right;white-space:normal;line-height:1.35}
.field input,.field select{height:var(--control-h)}
.field select[multiple]{height:160px}
.check-row,.form-actions{padding-left:162px}
.form-help{margin-left:162px}
.form-actions{padding-top:5px}

.detail-head{align-items:center;flex-wrap:wrap}
.detail-actions,.range-controls{display:flex;align-items:flex-end;flex-wrap:wrap;gap:8px}
.detail-actions label,.range-controls label{display:grid;gap:5px;min-width:190px}
.detail-actions button,.range-controls button{height:var(--control-h)}
.user-detail{width:min(1040px,calc(100vw - 232px));padding:20px 22px}
.user-detail>.detail-head{top:-20px;margin:-4px -4px 14px;padding:16px 4px 14px}

.inventory-head{align-items:center;margin-top:18px}
.inventory-controls{flex-wrap:wrap;justify-content:flex-end}
.inventory-stats{grid-template-columns:repeat(auto-fit,minmax(150px,1fr))}
.model-stock{min-width:230px}

dialog{width:min(480px,calc(100vw - 32px));border:1px solid #e5e7eb;border-radius:14px;padding:22px;box-shadow:0 24px 80px #10182838}
dialog::backdrop{background:#10182873;backdrop-filter:blur(2px)}
dialog .stack{max-width:none}

@media(max-width:1180px){main{padding:20px}.editor-form{grid-template-columns:1fr}.field,.wide.field{grid-template-columns:145px minmax(0,1fr)}.check-row,.form-actions{padding-left:157px}.form-help{margin-left:157px}.user-detail{width:calc(100vw - 232px)}}
@media(max-width:900px){main{padding:16px}.page,header{max-width:none}.toolbar>*{max-width:none!important}.toolbar>label,.toolbar>input,.toolbar>select{flex:1 1 220px}.user-detail{width:100vw}.editor-shell{padding:10px}}
@media(max-width:640px){.toolbar{display:grid;grid-template-columns:1fr}.toolbar>*{width:100%;min-width:0!important}.field,.wide.field{grid-template-columns:1fr}.field>span{text-align:left}.check-row,.form-actions{padding-left:0}.form-help{margin-left:0}.detail-actions,.range-controls{width:100%}.detail-actions>* ,.range-controls>*{width:100%;min-width:0!important}.actions{max-width:none}.pager{min-width:0}.user-detail{padding:16px}}

/* Give the user detail the full workspace instead of the old 1040px drawer. */
#user-detail{left:232px;right:0;width:calc(100vw - 232px);max-width:none}
#user-detail .user-request-log{overflow-x:hidden}
#user-detail .user-request-log table{width:100%;min-width:1280px;table-layout:fixed;white-space:normal}
#user-detail .user-request-log th:nth-child(1){width:14%}
#user-detail .user-request-log th:nth-child(2){width:25%}
#user-detail .user-request-log th:nth-child(3){width:7%}
#user-detail .user-request-log th:nth-child(4){width:7%}
#user-detail .user-request-log th:nth-child(5){width:6%}
#user-detail .user-request-log th:nth-child(6){width:6%}
#user-detail .user-request-log th:nth-child(7){width:10%}
#user-detail .user-request-log th:nth-child(8){width:8%}
#user-detail .user-request-log th:nth-child(9){width:17%}
#user-detail .user-request-log .error-cell{max-width:none;overflow:visible;text-overflow:clip;white-space:pre-wrap;overflow-wrap:anywhere}
@media(max-width:900px){#user-detail{left:0;width:100vw}}
