/* PNFS UI refresh: shared components for EVERY screen (main window and all embedded pages).
   Buttons, inputs, tabs, cards, tables and badges get one consistent look. Layout is untouched.
   Scoped to html.ui-refresh, so ?ui=classic / Rollback-UI-Refresh.ps1 restore the old look. */
@media screen{
html.ui-refresh{--ui-primary:#e5373d;--ui-primary-line:#e5373d}
html.ui-refresh[data-theme="dark"]{--ui-primary:#c73a4a;--ui-primary-line:#e0606d}

/* ---------- Primary action: one red, everywhere ---------- */
html.ui-refresh :is(.btn.primary,button.primary,#recordSubmitBtn,.mp-add-photo,#loginSubmit):not(label.upload):not(:disabled){background:var(--ui-primary)!important;border:1px solid var(--ui-primary-line)!important;color:#fff!important;border-radius:8px!important;font-weight:700!important;box-shadow:none!important}
html.ui-refresh :is(.btn.primary,button.primary,#recordSubmitBtn,.mp-add-photo,#loginSubmit):not(label.upload):not(:disabled):hover{filter:brightness(.94)}
html.ui-refresh[data-theme] body.material-app #recordForm button[type=submit]{background:var(--ui-primary)!important;border-color:var(--ui-primary-line)!important;color:#fff!important}

/* ---------- Secondary buttons: white, thin line ---------- */
html.ui-refresh :is(.btn,button.light,.light.btn):not(.primary):not(.tab):not(.active):not(.product-row):not(.lot-open):not(.table-sort-button):not([data-record-edit]):not([data-record-delete]):not([data-record-print]):not([data-raw-edit]):not([data-raw-delete]):not([data-edit]):not([data-delete]):not([data-open]):not(.mobile-expand){border-radius:8px;border-color:var(--ui-line)!important}

/* ---------- Danger (non-icon) buttons: white with red text, not pink fills ---------- */
html.ui-refresh :is(.btn.danger,button.danger,.btn.delete,.import-delete,.delete-account,.danger-button):not([data-record-delete]):not([data-raw-delete]):not([data-delete]):not([data-del]):not(.delete-action){background:var(--ui-panel)!important;border:1px solid var(--ui-line)!important;color:var(--ui-brand)!important;border-radius:8px!important;box-shadow:none!important}
html.ui-refresh :is(.btn.danger,button.danger,.btn.delete,.import-delete,.delete-account,.danger-button):not([data-record-delete]):not([data-raw-delete]):not([data-delete]):not([data-del]):not(.delete-action):hover{border-color:var(--ui-brand)!important}

/* ---------- Segmented tabs (e.g. S/D · 믹서 · 보류/정지) ---------- */
html.ui-refresh button.tab{border-radius:8px!important;border:1px solid var(--ui-line)!important;background:var(--ui-panel)!important;color:var(--ui-muted)!important;font-weight:600;box-shadow:none!important}
html.ui-refresh button.tab:hover{color:var(--ui-ink)!important;background:var(--ui-hover)!important}
html.ui-refresh button.tab.active{background:var(--ui-brand-soft)!important;border-color:var(--ui-brand)!important;color:var(--ui-brand)!important;font-weight:700}

/* ---------- Product tabs (믹서 계획 등): same segmented look ---------- */
html.ui-refresh .product-plan-tabs button{border-radius:8px!important;border:1px solid var(--ui-line)!important;background:var(--ui-panel)!important;color:var(--ui-muted)!important;font-weight:600;box-shadow:none!important}
html.ui-refresh .product-plan-tabs button:hover{color:var(--ui-ink)!important;background:var(--ui-hover)!important}
html.ui-refresh .product-plan-tabs button.active{background:var(--ui-brand-soft)!important;border-color:var(--ui-brand)!important;color:var(--ui-brand)!important;font-weight:700}

/* ---------- Admin top actions: outlined, not three red fills ---------- */
html.ui-refresh .admin-actions .admin-action-button{background:var(--ui-panel)!important;border:1px solid var(--ui-line)!important;color:var(--ui-ink)!important;border-radius:8px!important;box-shadow:none!important;font-weight:600}
html.ui-refresh .admin-actions .admin-action-button:hover{background:var(--ui-hover)!important}
html.ui-refresh .admin-actions .admin-action-button:is(.active,[aria-pressed="true"],[aria-expanded="true"]){background:var(--ui-brand-soft)!important;border-color:var(--ui-brand)!important;color:var(--ui-brand)!important}

/* ---------- Underline tabs (top tabs of each screen) ---------- */
html.ui-refresh :is(.tabs,.production-tabs,.material-tabs,.line-tabs,.product-plan-tabs) button:not(.tab){border-radius:0}
html.ui-refresh :is(.tabs,.production-tabs,.line-tabs) button.active{color:var(--ui-ink)!important;font-weight:700}

/* ---------- Inputs ---------- */
html.ui-refresh :is(input:not([type=checkbox]):not([type=radio]):not([type=file]):not([type=hidden]):not([type=range]):not([type=color]),select,textarea){border-color:var(--ui-line);border-radius:8px}
html.ui-refresh :is(input,select,textarea):focus{border-color:#7aa2e8!important;box-shadow:0 0 0 3px #2f6fdb22!important;outline:0}
html.ui-refresh :is(input,textarea)::placeholder{color:var(--ui-faint)}
html.ui-refresh label{color:var(--ui-muted)}

/* ---------- Cards / panels ---------- */
html.ui-refresh :is(.panel,.card,.metric,.editor-panel,.filterbar,.summary,.dashboard-card,.module-card,.sheet,.controls,.record-form,.product-panel,.product-detail,.chart-half,.out-filters,.out-metrics,.out-charts,.plan-head,.heading,.metrics):not(td):not(th){border-color:var(--ui-line)!important;box-shadow:none!important}
html.ui-refresh :is(.panel,.card,.editor-panel,.filterbar,.dashboard-card,.module-card,.sheet,.product-panel,.chart-half,.out-filters,.out-charts){border-radius:12px}
html.ui-refresh :is(.metric,.summary-item) :is(strong,b){font-variant-numeric:tabular-nums;letter-spacing:-.2px}

/* ---------- Tables everywhere: light header, softer grid lines (calendars keep their look) ---------- */
html.ui-refresh table:not(.calendar-table):not(.cal-table)>thead th{background:var(--ui-head)!important;color:var(--ui-muted)!important;font-weight:600!important;font-size:12px}
html.ui-refresh table:not(.calendar-table):not(.cal-table) :is(th,td){border-color:var(--ui-line2)!important}
html.ui-refresh table:not(.calendar-table):not(.cal-table)>tbody>tr:hover>td{background-color:var(--ui-hover)!important}
html.ui-refresh table td{font-variant-numeric:tabular-nums}

/* ---------- Badges: one pill shape ---------- */
html.ui-refresh :is(.status,.status-badge,.type-badge,.shipping-badge,.cip-badge,.install-status,.holiday-badge,.adjustment-badge){border-radius:999px!important;font-weight:700;font-size:12px;padding:2px 9px}

/* ---------- Dialogs / modals ---------- */
html.ui-refresh :is(dialog,.modal,.modal-card,.dialog-card){border-radius:14px!important;border:1px solid var(--ui-line)!important;box-shadow:0 20px 50px #0f172a2e!important}
html.ui-refresh dialog::backdrop{background:#0f172a66}

/* ---------- 수입 (수입현황 · 출고현황 · 수입단가): its own ledger rules are id-scoped, so override them here ---------- */
html.ui-refresh:not(#ui-x) #nasImportScreen{--import-head:var(--ui-head);--import-body:var(--ui-panel);--ledger-edge:var(--ui-line2);--import-edit-row:var(--ui-brand-soft);--head:var(--ui-head);--line:var(--ui-line)}
html.ui-refresh #nasImportScreen :is(.import-grid-scroll,.shipment-scroll,.import-table-scroll){border:1px solid var(--ui-line)!important;border-radius:12px!important;background:var(--ui-panel);box-shadow:none!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) thead th{color:var(--ui-muted)!important;font-size:12px!important;font-weight:600!important;padding-block:7px!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tbody td{border-right-color:transparent!important;padding-block:5px!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tbody td.import-actions{box-shadow:-1px 0 var(--ui-line2)}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) th.import-product-heading{background:var(--ui-head)!important;color:var(--ui-ink)!important;font-weight:700!important;border-right-color:transparent!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tbody tr:hover>td{background-color:var(--ui-hover)!important}
html.ui-refresh #nasImportScreen #nasImportReceipts textarea:focus{border-color:#7aa2e8!important;box-shadow:0 0 0 2px #2f6fdb22!important}
/* 회사 선택: segmented like the other screens; 행 추가 = the one primary action */
html.ui-refresh #nasImportScreen .import-company-tools button:not(.import-add){background:var(--ui-panel)!important;border:1px solid var(--ui-line)!important;color:var(--ui-muted)!important;border-radius:8px!important;font-weight:600!important;box-shadow:none!important}
html.ui-refresh #nasImportScreen .import-company-tools button:not(.import-add):hover{background:var(--ui-hover)!important;color:var(--ui-ink)!important}
html.ui-refresh #nasImportScreen .import-company-tools button[aria-pressed=true]:not(.import-add){background:var(--ui-brand-soft)!important;border-color:var(--ui-brand)!important;color:var(--ui-brand)!important;font-weight:700!important}
html.ui-refresh #nasImportScreen .import-company-tools button.import-add{background:var(--ui-primary)!important;border:1px solid var(--ui-primary-line)!important;color:#fff!important;border-radius:8px!important;font-weight:700!important;box-shadow:none!important;display:inline-flex;align-items:center;gap:5px}
html.ui-refresh #nasImportScreen .import-company-tools button.import-add::before{content:"";width:14px;height:14px;background:currentColor;-webkit-mask:var(--ui-i-plus) center/contain no-repeat;mask:var(--ui-i-plus) center/contain no-repeat}
/* 수정 / 삭제: outlined, delete in red text */
html.ui-refresh:not(#ui-x) #nasImportScreen .import-actions{--action-bg:var(--ui-panel);--action-ink:var(--ui-ink);--action-line:var(--ui-line);--delete-bg:var(--ui-panel);--delete-ink:var(--ui-brand);--delete-line:var(--ui-line)}
html.ui-refresh #nasImportScreen td.import-actions button{height:28px!important;min-height:28px!important;font-size:13px!important;font-weight:600!important;padding:0 9px!important}
html.ui-refresh #nasImportScreen td.import-actions button:hover{background:var(--ui-hover)!important}
html.ui-refresh #nasImportScreen td.import-actions button.import-delete:hover{border-color:var(--ui-brand)!important}
/* 보기 상태의 수정·삭제는 다른 화면과 같은 28px 아이콘 버튼 (편집 중인 행의 "수정 저장/취소"는 글자 유지) */
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button{position:relative;width:28px!important;min-width:28px!important;height:28px!important;min-height:28px!important;padding:0!important;font-size:0!important;color:var(--ui-muted)!important;background:transparent!important;border:1px solid transparent!important;border-radius:7px!important;vertical-align:middle}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button::before{content:"";position:absolute;inset:6px;background:currentColor;-webkit-mask:var(--ui-i-edit) center/contain no-repeat;mask:var(--ui-i-edit) center/contain no-repeat}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button.import-delete::before{-webkit-mask-image:var(--ui-i-trash);mask-image:var(--ui-i-trash)}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button:hover{background:var(--ui-hover)!important;border-color:var(--ui-line)!important;color:var(--ui-ink)!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button.import-delete:hover,html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing):hover>td.import-actions>button.import-delete{color:var(--ui-brand)!important}
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:not(.import-editing)>td.import-actions>button+button{margin-left:2px!important}

/* 관리 열: 아이콘 두 개만큼만 (행을 편집 중일 때만 글자 버튼 폭으로 넓어짐) */
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments):not(:has(tr.import-editing)) .import-actions{width:72px!important;min-width:72px!important;max-width:72px!important;padding-inline:4px!important}
html.ui-refresh #nasImportScreen #nasImportReceipts:not(:has(tr.import-editing)) table>colgroup>col:last-child{width:72px!important}
/* 품목 묶음 줄의 관리 칸도 묶음 줄과 같은 색 */
html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:has(>th.import-product-heading)>td.import-actions,html.ui-refresh #nasImportScreen :is(#nasImportReceipts,#nasImportShipments) tr:has(>.import-product-heading)>.import-actions{background:var(--ui-head)!important}

/* ---------- Side menu: departments whose screens hang directly under them (수입, 품질) get the same lined tree ---------- */
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button{position:relative;width:calc(100% - 23px)!important;margin:1px 0 1px 23px!important;min-height:30px;padding:5px 8px!important;border-radius:7px!important;border:0!important;font-size:13px;font-weight:500;text-align:left;color:var(--ui-muted)!important;background:transparent!important;box-shadow:none!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button::after{content:none!important;display:none!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button::before{content:""!important;display:block!important;position:absolute!important;left:-6px!important;top:-2px!important;bottom:-2px!important;width:1.5px!important;height:auto!important;margin:0!important;border:0!important;border-radius:0!important;background:var(--ui-line)!important;opacity:1!important;transform:none!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>summary+button{margin-top:4px!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button:last-child{margin-bottom:6px!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button:hover{background:var(--ui-hover)!important;color:var(--ui-ink)!important}
html.ui-refresh #appShell:not(.nas-folded) #nasSide [data-department]>button[aria-current="page"]{background:var(--ui-brand-soft)!important;color:var(--ui-brand)!important;font-weight:700!important}

/* ---------- 제품 목록: the "제품 목록 · N개" title strip repeats the page title, so hide it ---------- */
html.ui-refresh #appShell .panel-head:has(>#productCount){display:none!important}

/* ---------- Toast ---------- */
html.ui-refresh :is(.toast,#toast){border-radius:10px!important}
}
