/* UI craft guidance adapted from unslop by Damir Sokolovsky (@heydamir), CC BY 4.0.
   Scoped to the existing draw, wheel, business settings, audit and security views. */

/* The draw view keeps the existing form order and highlights the current round. */
body:has(#navigation [data-page="draw"].active) #content .panel:has(> #automationForm)>h2,
body:has(#navigation [data-page="draw"].active) #content .panel:has(> #drawForm)>h2,
body:has(#navigation [data-page="settings"].active) #content .panel:has(> #settingsForm)>h2,
body:has(#navigation [data-page="security"].active) #content .security-panel>h2{margin:0 0 8px;font-size:17px;line-height:24px;font-weight:600;letter-spacing:0}
body:has(#navigation [data-page="draw"].active) #content .panel:has(> :is(#automationForm,#drawForm))>p.muted,
body:has(#navigation [data-page="settings"].active) #content .panel:has(> #settingsForm)>p.muted{max-width:78ch;margin:0 0 16px;color:#56685a;font-size:13px;line-height:20px;overflow-wrap:anywhere}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm),
body:has(#navigation [data-page="settings"].active) #content #settingsForm{width:100%;max-width:none}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) .formgrid,
body:has(#navigation [data-page="settings"].active) #content #settingsForm .formgrid{gap:0 16px;align-items:start}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) label,
body:has(#navigation [data-page="settings"].active) #content #settingsForm label{min-width:0;margin:0 0 16px;color:#294b37;font-size:13px;line-height:20px;font-weight:500;overflow-wrap:anywhere}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) :is(input:not([type="hidden"]),select,textarea),
body:has(#navigation [data-page="settings"].active) #content #settingsForm :is(select,textarea){width:100%;min-width:0;min-height:40px;margin-top:8px;padding:8px 12px;border:1px solid #b9cbbd;border-radius:8px;background:#fff;color:#173b29;font-size:13px;line-height:20px}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) :is(input,select,textarea):disabled,
body:has(#navigation [data-page="settings"].active) #content #settingsForm :is(select,textarea):disabled{border-color:#d2dcd3;background:#edf1ed;color:#617264;cursor:not-allowed}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) textarea,
body:has(#navigation [data-page="settings"].active) #content #settingsForm textarea{height:auto;min-height:96px;resize:vertical}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) label small{margin-top:8px;color:#56685a;font-size:12px;line-height:20px;font-weight:400}
body:has(#navigation [data-page="draw"].active) #content :is(#automationStatus,#drawSelected){min-width:0;margin:0 0 16px;padding:12px 16px;border:1px solid #d7e6d7;border-left:3px solid #48835d;border-radius:8px;background:#f3f8f2;color:#25533b;font-size:13px;line-height:20px;font-weight:500;overflow-wrap:anywhere}
body:has(#navigation [data-page="draw"].active) #content #drawDraftFeedback:not([hidden]){min-width:0;margin:0 0 16px;line-height:20px;overflow-wrap:anywhere}
body:has(#navigation [data-page="draw"].active) #content #automationForm .formgrid>p.muted{margin:0 0 16px;color:#56685a;font-size:12px;line-height:20px}
body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) button:not([hidden]),
body:has(#navigation [data-page="settings"].active) #content #settingsForm button:not([hidden]){min-height:40px;max-width:100%;margin-right:8px;padding:8px 16px;border-radius:8px;font-size:13px;line-height:20px;font-weight:600;white-space:normal;overflow-wrap:anywhere;box-shadow:none}
body:has(#navigation [data-page="draw"].active) #content .draw-history-search{display:block;width:min(100%,480px);max-width:100%;margin:0 0 8px;color:#294b37;font-size:13px;line-height:20px;font-weight:500}
body:has(#navigation [data-page="draw"].active) #content .draw-history-search input{box-sizing:border-box;width:100%;min-height:40px;margin-top:8px;padding:8px 12px;border:1px solid #b9cbbd;border-radius:8px;background:#fff;font-size:13px;line-height:20px}
body:has(#navigation [data-page="draw"].active) #content #drawHistoryCount{margin:0 0 12px;color:#617365;font-size:12px;line-height:20px}
body:has(#navigation [data-page="draw"].active) #content #drawHistoryTable .tablewrap{max-width:100%;overflow-x:auto}
body:has(#navigation [data-page="draw"].active) #content #drawHistoryTable table{min-width:640px}
body:has(#navigation [data-page="draw"].active) #content #drawHistoryTable td:first-child{min-width:180px;white-space:normal;overflow-wrap:anywhere}
body:has(#navigation [data-page="draw"].active) #content #drawHistoryTable td:last-child{white-space:nowrap;font-variant-numeric:tabular-nums}
body:has(#navigation [data-page="draw"].active) #content .draw-history-pages:not([hidden]){display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:8px;margin-top:16px;color:#617365;font-size:12px;line-height:20px}

/* The prize editor already distinguishes types and unavailable inputs. */
body:has(#navigation [data-page="wheel"].active) #content #wheelConfigForm{width:100%;max-width:none}
body:has(#navigation [data-page="wheel"].active) #content #wheelConfigForm>.formgrid{gap:0 16px;align-items:end}
body:has(#navigation [data-page="wheel"].active) #content #wheelConfigForm>p.muted{max-width:78ch;margin:0 0 16px;color:#56685a;font-size:13px;line-height:20px}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize{min-width:0;margin:16px 0;padding:16px;border:1px solid #dfe7df;border-radius:12px;background:#fff;box-shadow:none}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize legend{padding:0 8px;color:#294b37;font-size:13px;line-height:20px;font-weight:600}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize legend button{min-height:40px;margin-left:8px;padding:8px 12px;border-radius:8px;font-size:12px;line-height:20px;font-weight:500;box-shadow:none}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize [hidden]{display:none!important}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize details{padding-top:8px;border-color:#e2e9e2}
body:has(#navigation [data-page="wheel"].active) #content .wheel-prize details summary{min-height:44px;color:#315c40;font-size:13px;line-height:20px;font-weight:500}
body:has(#navigation [data-page="wheel"].active) #content #wheelProbability{font-size:13px;line-height:20px;font-variant-numeric:tabular-nums;color:#56685a}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) .tablewrap{max-width:100%;overflow-x:auto}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) table{min-width:720px}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) td:first-child{white-space:nowrap;font-variant-numeric:tabular-nums}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) td:nth-child(3){min-width:160px;white-space:normal;overflow-wrap:anywhere}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) td:nth-child(4){min-width:160px;white-space:normal;overflow-wrap:anywhere}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) details summary{min-height:40px;padding:8px 0;color:#12663e;font-size:12px;line-height:20px;font-weight:500}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev) details ul{min-width:0;margin:4px 0 0;padding-left:20px;color:#56685a;font-size:12px;line-height:20px;overflow-wrap:anywhere}
body:has(#navigation [data-page="wheel"].active) #content .panel:has(#wheelPrev)>.actions{display:flex;align-items:center;flex-wrap:wrap;gap:8px;margin-top:16px;color:#617365;font-size:12px;line-height:20px}

/* Audit details remain selectable and horizontal scrolling stays in the table. */
body:has(#navigation [data-page="audit"].active) #content .tablewrap{max-width:100%;overflow-x:auto}
body:has(#navigation [data-page="audit"].active) #content .tablewrap table{min-width:720px}
body:has(#navigation [data-page="audit"].active) #content tbody td:nth-child(1),
body:has(#navigation [data-page="audit"].active) #content tbody td:nth-child(2){min-width:120px;white-space:normal;overflow-wrap:anywhere;word-break:normal}
body:has(#navigation [data-page="audit"].active) #content tbody td:nth-child(4){white-space:nowrap;font-variant-numeric:tabular-nums}
body:has(#navigation [data-page="audit"].active) #content details summary{min-height:40px;padding:8px 0;color:#12663e;font-size:13px;line-height:20px;font-weight:500}
body:has(#navigation [data-page="audit"].active) #content details pre{box-sizing:border-box;width:min(100%,640px);max-width:100%;margin:8px 0;padding:12px;border:1px solid #e2e9e2;border-radius:8px;background:#f8faf7;color:#344b3b;font-size:12px;line-height:20px;white-space:pre-wrap;overflow-wrap:anywhere;word-break:break-word}

/* Distinct sections and neutral checkboxes make security operations legible. */
body:has(#navigation [data-page="security"].active) #content .security-panel>p{max-width:78ch;margin:0 0 8px;color:#56685a;font-size:13px;line-height:20px;overflow-wrap:anywhere}
body:has(#navigation [data-page="security"].active) #content .security-panel>p[role="status"]:empty{display:none}
body:has(#navigation [data-page="security"].active) #content .security-section{min-width:0;margin:20px 0 0;padding:20px 0 0;border:0;border-top:1px solid #e1e8e1;border-radius:0;background:transparent}
body:has(#navigation [data-page="security"].active) #content .security-section h3{margin:0 0 8px;color:#254d37;font-size:14px;line-height:20px;font-weight:600}
body:has(#navigation [data-page="security"].active) #content .security-section>p{max-width:78ch;margin:0 0 12px;color:#56685a;font-size:13px;line-height:20px;overflow-wrap:anywhere}
body:has(#navigation [data-page="security"].active) #content .security-sessions{display:grid;gap:8px;min-width:0;margin:0 0 16px;padding:0;list-style:none;color:#405b49;font-size:13px;line-height:20px}
body:has(#navigation [data-page="security"].active) #content .security-sessions li{min-width:0;padding:8px 12px;border:1px solid #e2e9e2;border-radius:8px;background:#f8faf7;overflow-wrap:anywhere;font-variant-numeric:tabular-nums}
body:has(#navigation [data-page="security"].active) #content .security-section :is(form,.security-fields,.security-setup>label){width:100%;max-width:720px}
body:has(#navigation [data-page="security"].active) #content .security-section form label,
body:has(#navigation [data-page="security"].active) #content .security-setup>label{min-width:0;color:#294b37;font-size:13px;line-height:20px;font-weight:500;overflow-wrap:anywhere}
body:has(#navigation [data-page="security"].active) #content .security-section :is(input:not([type="checkbox"]),select){box-sizing:border-box;width:100%;min-width:0;min-height:40px;margin-top:8px;padding:8px 12px;border:1px solid #b9cbbd;border-radius:8px;background:#fff;color:#173b29;font-size:13px;line-height:20px}
body:has(#navigation [data-page="security"].active) #content .security-section form>button,
body:has(#navigation [data-page="security"].active) #content .security-section>button,
body:has(#navigation [data-page="security"].active) #content .security-setup>button{min-height:40px;max-width:100%;padding:8px 16px;border-radius:8px;font-size:13px;line-height:20px;font-weight:600;white-space:normal;overflow-wrap:anywhere;box-shadow:none}
body:has(#navigation [data-page="security"].active) #content .security-section fieldset{min-width:0;margin:0 0 16px;padding:12px;border:1px solid #dfe7df;border-radius:10px}
body:has(#navigation [data-page="security"].active) #content .security-section fieldset legend{padding:0 8px;font-size:13px;line-height:20px;font-weight:600}
body:has(#navigation [data-page="security"].active) #content fieldset label:has(.security-permission){display:inline-flex;align-items:center;gap:8px;min-height:40px;margin:4px 8px 4px 0;padding:8px;border-radius:8px;background:#f3f7f2;color:#344f3e;font-weight:500}
body:has(#navigation [data-page="security"].active) #content fieldset .security-permission{flex:none;width:18px;height:18px;min-height:18px;margin:0;accent-color:#087448}

/* Keep the previous focus, disabled, error and hidden semantics intact. */
body:has(#navigation [data-page="draw"].active) #content :is(button,input,select,textarea,summary):focus-visible,
body:has(#navigation [data-page="wheel"].active) #content :is(button,input,select,textarea,summary):focus-visible,
body:has(#navigation [data-page="settings"].active) #content :is(button,input,select,textarea,summary):focus-visible,
body:has(#navigation [data-page="audit"].active) #content :is(button,input,select,textarea,summary):focus-visible,
body:has(#navigation [data-page="security"].active) #content :is(button,input,select,textarea,summary):focus-visible{outline:2px solid #087448;outline-offset:2px}
@media(max-width:650px){
 body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) .formgrid,
 body:has(#navigation [data-page="settings"].active) #content #settingsForm .formgrid{grid-template-columns:minmax(0,1fr)}
 body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) :is(input:not([type="hidden"]),select,textarea),
 body:has(#navigation [data-page="draw"].active) #content .draw-history-search input,
 body:has(#navigation [data-page="settings"].active) #content #settingsForm :is(select,textarea),
 body:has(#navigation [data-page="security"].active) #content .security-section :is(input:not([type="checkbox"]),select){min-height:44px;font-size:16px}
 body:has(#navigation [data-page="draw"].active) #content :is(#automationForm,#drawForm) button:not([hidden]),
 body:has(#navigation [data-page="settings"].active) #content #settingsForm button:not([hidden]),
 body:has(#navigation [data-page="wheel"].active) #content .wheel-prize legend button,
 body:has(#navigation [data-page="security"].active) #content .security-section form>button,
 body:has(#navigation [data-page="security"].active) #content .security-section>button{min-height:44px}
 body:has(#navigation [data-page="wheel"].active) #content .wheel-prize{padding:16px 12px}
 body:has(#navigation [data-page="audit"].active) #content details pre{min-width:0;max-width:min(70vw,480px)}
}

/* Final cross-module alignment; semantic red remains reserved for failures. */
#content#content tbody td.money,#content#content tbody td.admin-money-cell{color:#26332c;text-align:right;font-weight:500}
#content#content th.admin-numeric-heading{text-align:right}
#content#content .stat strong{color:#26332c;font-weight:500}
#content#content :is(.toolbar button,.actions button),#editor#editor button{font-weight:500;box-shadow:none;transform:none}
#content#content .actions button{min-height:36px;padding:6px 12px}
#content#content .tablewrap tbody td{padding-top:12px;padding-bottom:12px}
#content#content .tablewrap tbody td small{font-size:12px;line-height:18px}
#content#content .badge{font-weight:500;border-radius:6px}
#content#content .wheel-prize-table :is(input,select){min-height:40px;font-size:13px;line-height:20px}
#content#content .wheel-table-footer button{min-height:40px}
#editor#editor .admin-form-actions{display:flex;justify-content:flex-end;gap:8px}
@media(max-width:650px){#content#content .actions button{min-height:40px}#content#content .wheel-prize-table :is(input,select){font-size:16px;min-height:44px}}
/* Ten-digit stock and reward values remain readable without shrinking text. */
#content#content .wheel-prize-table{min-width:1000px}
#content#content .wheel-col-name{width:22%}
#content#content .wheel-col-type{width:13%}
#content#content .wheel-col-probability{width:10%}
#content#content .wheel-col-stock{width:14%}
#content#content .wheel-col-reward{width:26%}
#content#content .wheel-col-actions{width:15%}
#content#content .wheel-prize-table th:nth-child(3),#content#content .wheel-prize-table th:nth-child(4){text-align:right}
#content#content .wheel-config-settings{background:#f6f7f6;border-color:#e2e6e3}
#content#content .wheel-admin-tabs{gap:8px;padding-bottom:16px;margin-bottom:16px;border-bottom:1px solid #e2e6e3}
#content#content .wheel-admin-tabs>button{min-height:40px;padding:8px 16px;font-size:13px;line-height:20px;font-weight:500;border-radius:8px}
#editor .admin-points-change{text-align:right;font-variant-numeric:tabular-nums;white-space:nowrap}
#editor .admin-points-pagination{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin-top:16px;font-size:13px}
#editor .admin-order-number-pages{display:flex;align-items:center;justify-content:flex-end;gap:12px;margin:16px 0 24px;font-size:13px}
#editor #adminOrderNumberResults{max-height:180px;overflow:auto;padding:12px;border:1px solid #e2e6e3;border-radius:8px;line-height:24px;background:#f7f8f7;overflow-wrap:anywhere}
#editor #adminOrderNumberResults[aria-busy=true]{color:#59675f}
/* Long point histories scroll within the table; paging stays in reach. */
#editor .admin-points-content .tablewrap{max-height:min(48dvh,420px);overflow:auto;border:1px solid #e2e6e3;border-radius:8px}
#editor .admin-points-content thead th{position:sticky;top:0;background:#f4f6f4;z-index:1}
#editor .admin-points-pagination{position:sticky;bottom:0;background:#fff;padding:12px 0 0;margin-top:8px}
#editor .admin-points-content[aria-busy=true]{opacity:.65}
