:root{font:14px/1.55 Inter,Segoe UI,Arial,sans-serif;color:#172b36;background:#f3f6f7}*{box-sizing:border-box}body{margin:0}button,input,select{font:inherit}button{cursor:pointer;border:1px solid #dbe5e9;border-radius:9px;background:white;color:#24404a;padding:9px 13px;transition:.15s}button:hover{border-color:#60a49b;background:#f0fafa}button.primary,.primary{background:#087c72;border:1px solid #087c72;color:white}button.primary:hover{background:#04665e}button.danger{color:#bd3131}button.active,.tabs .active{background:#0a7d74;color:white}label{display:flex;flex-direction:column;gap:5px;font-weight:600;color:#344f5b;font-size:12px}input,select{background:#fff;border:1px solid #d8e1e5;border-radius:8px;padding:9px 10px;min-width:0;max-width:100%;color:#18323b}input:focus,select:focus{outline:2px solid #92d6ce;border-color:#087c72}h1,h2,h3,h4{line-height:1.2;margin:0 0 13px}h1{font-size:36px}h2{font-size:25px}h3{font-size:16px}.muted,.hint{color:#738894}.hint{font-size:12px}.tag{font-size:10px;color:#12897d;letter-spacing:2px;font-weight:800;margin-bottom:8px}.auth{min-height:100vh;display:flex;align-items:center;justify-content:center;background:radial-gradient(circle at 20% 0%,#d5efeb,transparent 37%),radial-gradient(circle at 85% 90%,#dde8f6,transparent 45%)}.login{background:white;border:1px solid #e4eaed;box-shadow:0 15px 60px #1a55551a;border-radius:22px;padding:45px;width:min(460px,calc(100% - 32px))}.login form{display:grid;gap:15px;margin-top:24px}.login button{margin-top:10px}.error{color:#bf3030;margin-top:14px}.sidebar{position:fixed;width:240px;height:100vh;background:#12313b;color:white;padding:24px 13px;display:flex;flex-direction:column;gap:25px}.brand{display:flex;align-items:center;gap:12px;padding:0 11px}.brand b{display:block;letter-spacing:2px;font-size:15px}.brand small{color:#a7c4ca;letter-spacing:1px;font-size:9px}.symbol{display:flex;align-items:center;justify-content:center;background:#19a69a;width:39px;height:39px;border-radius:12px;color:#fff;font-size:25px;font-weight:800}.sidebar nav{display:grid;gap:5px}.sidebar button{background:transparent;text-align:left;color:#c9dce0;border:0}.sidebar nav button.selected,.sidebar nav button:hover{color:white;background:#24616a;border-radius:10px}.aside-foot{margin-top:auto;border-top:1px solid #38606a;padding:17px 7px;display:grid;gap:12px}.aside-foot small{color:#8db2bb}.main{margin-left:240px;padding:25px 30px 80px;min-height:100vh;max-width:2000px}.main header{display:flex;justify-content:space-between;align-items:center;margin-bottom:25px}.main header #identity{font-size:12px;color:#54707a;background:white;padding:9px 13px;border:1px solid #e0e9eb;border-radius:18px}.page{display:grid;gap:20px}.page[hidden],section[hidden],div[hidden]{display:none!important}.toolbar{display:flex;justify-content:space-between}.tabs{display:flex;gap:8px;flex-wrap:wrap}.filters{display:grid;grid-template-columns:repeat(4,minmax(130px,1fr)) 120px;align-items:end;gap:12px;background:white;border:1px solid #e0e7eb;padding:18px;border-radius:13px}.note{background:#edf9f7;border:1px solid #cceae4;color:#386d67;padding:11px 15px;border-radius:10px;font-size:12px}.kpis{display:grid;grid-template-columns:repeat(3,1fr);gap:15px}.kpi,.panel{background:white;border:1px solid #e0e8eb;border-radius:14px;padding:20px;box-shadow:0 2px 14px #20454b08}.kpi small{display:block;color:#7e929b;font-size:12px;margin-bottom:13px}.kpi strong{display:block;font-size:24px;letter-spacing:-.6px;color:#073f43;overflow-wrap:anywhere}.two{display:grid;grid-template-columns:1fr 1fr;gap:17px}.bars{min-height:200px;display:flex;align-items:end;gap:10px;overflow-x:auto;padding:20px 4px 4px}.barcol{height:100%;min-width:50px;display:flex;flex-direction:column;justify-content:flex-end;text-align:center;align-items:center;gap:9px}.bar{width:32px;background:linear-gradient(180deg,#12ada0,#0b776e);border-radius:7px 7px 2px 2px;min-height:3px}.barcol small{font-size:10px;color:#7a8b92}.empty{padding:45px 10px;text-align:center;color:#8da1a7}table{border-collapse:collapse;width:100%;font-size:12px}th{background:#f5f9fa;font-size:11px;text-align:left;color:#607a85;white-space:nowrap}th,td{padding:10px 11px;border-bottom:1px solid #ebf0f2}td{white-space:nowrap}tr:hover{background:#f8fbfb}.table-scroll{overflow:auto;max-height:580px}.panel{min-width:0}.heading{display:flex;justify-content:space-between;align-items:center;gap:12px;margin-bottom:15px}.heading h3{margin:0}.heading button{margin-left:5px}.form-grid{display:grid;grid-template-columns:repeat(3,minmax(160px,1fr));gap:12px;align-items:end;margin:15px 0 20px}.form-grid button{height:39px}.check{flex-direction:row;align-items:center}.check input{width:15px;height:15px}.rule{display:grid;grid-template-columns:1fr 160px 1fr 80px;gap:9px;align-items:end;background:#f7fafb;border:1px solid #e4ecee;padding:12px;border-radius:11px;margin-bottom:9px}.actions{display:flex;gap:9px;margin:18px 0}.panel>.table-scroll{margin-top:12px}.pill{background:#e3f6f1;border-radius:15px;color:#06786d;padding:3px 8px;font-size:11px}#toast{position:fixed;right:22px;bottom:22px;z-index:9;background:#1b3942;color:#fff;padding:11px 18px;max-width:360px;border-radius:12px;box-shadow:0 7px 25px #1233;display:none}#toast.show{display:block}.admin.is-hidden{display:none!important}@media(max-width:1100px){.kpis{grid-template-columns:repeat(2,1fr)}.filters{grid-template-columns:repeat(3,1fr)}.two{grid-template-columns:1fr}}@media(max-width:720px){.sidebar{position:relative;width:auto;height:auto;gap:12px;padding:16px}.sidebar nav{display:flex;overflow:auto}.sidebar button{white-space:nowrap}.aside-foot{display:none}.main{margin-left:0;padding:18px}.kpis{grid-template-columns:1fr 1fr}.filters{grid-template-columns:1fr 1fr}.form-grid,.rule{grid-template-columns:1fr}.kpi strong{font-size:19px}.login{padding:27px}}

/* V1.1: Sales Dashboard V6.9.1 visual design language */
:root{--bg:#f6f8f5;--surface:#fff;--border:#d8e2db;--primary:#007247;--primary-dark:#005d3a;--muted:#5e7065;--soft:#eef8f2}
body{background:linear-gradient(180deg,#f7faf8 0%,#f3f7f4 100%);color:#10221a}
.sidebar{background:#07120d;box-shadow:0 8px 30px rgba(7,18,13,.25)}
.sidebar nav button.selected,.sidebar nav button:hover{background:rgba(0,114,71,.42)}
.symbol{background:linear-gradient(145deg,#007247,#10a468)}
.tag{color:#128855}button.primary,.primary,button.active,.tabs .active{background:#007247;border-color:#007247}
button.primary:hover{background:#005d3a}button:hover{border-color:#7ebca0;background:#eef8f2}
input:focus,select:focus{outline:2px solid #a9dac0;border-color:#007247}
.kpi,.panel,.filters{border:1px solid #d8e2db;border-radius:20px;box-shadow:0 12px 35px rgba(16,34,26,.07)}
.kpi strong{color:#005d3a}.bar{background:linear-gradient(180deg,#19aa6e,#007247)}
.note{background:#eef8f2;border-color:#c6e7d5;color:#145b3d}.pill{background:#def5e8;color:#007247}
.main header{background:linear-gradient(135deg,#062016,#007247 60%,#0d8e5a);padding:24px 28px;color:white;border-radius:24px;box-shadow:0 12px 35px rgba(16,34,26,.09)}
.main header .tag{color:#b6e9cd}.main header #identity{background:rgba(255,255,255,.12);color:white;border-color:rgba(255,255,255,.2)}
.filters{grid-template-columns:repeat(3,minmax(155px,1fr));gap:14px}.filters button{align-self:end}
.paging{display:flex;align-items:center;justify-content:flex-end;gap:10px;padding:15px;color:#52695c}
@media(max-width:760px){.filters{grid-template-columns:1fr 1fr}.main header{padding:18px}.paging{flex-wrap:wrap}}

/* V1.3 — expanded Purchase dashboard / Pursal UX */
.overview-kpis{display:grid;grid-template-columns:repeat(3,minmax(0,1fr));gap:16px}
.overview-card{border-top:4px solid #008653;position:relative;overflow:hidden}
.overview-card strong{font-size:clamp(19px,2.3vw,31px)}.overview-card>span{font-size:11px;color:#6b8275}
.overview-card:nth-child(2){border-top-color:#12a58b}.overview-card:nth-child(3){border-top-color:#486cbd}
.hbars{display:grid;gap:11px;margin:15px 0 20px}.hbar-row{display:grid;grid-template-columns:minmax(70px,130px) minmax(65px,1fr) minmax(85px,140px);gap:10px;align-items:center;font-size:12px}
.hbar-row>span{white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#30493c}.hbar-row>b{text-align:right;font-size:11px;overflow-wrap:anywhere}
.hbar-track{background:#eff4f0;border-radius:30px;height:10px;overflow:hidden}.hbar-fill{height:100%;border-radius:30px;background:linear-gradient(90deg,#027948,#27ba81)}
.pursal-search{display:grid;grid-template-columns:1fr 1.25fr;gap:14px;margin:16px 0}.pursal-search label{font-size:12px}
.pursal-search textarea{font:12px/1.5 Consolas,monospace;border:1px solid #d8e1e5;border-radius:10px;padding:11px;resize:vertical;min-height:100px}
.pursal-code-actions{display:flex;align-items:end;flex-wrap:wrap;gap:9px;grid-column:1/-1}.pursal-code-actions label{min-width:220px}
.columns-dialog{border:1px solid #d2e4da;border-radius:18px;padding:25px;width:min(750px,94vw);max-height:86vh;box-shadow:0 25px 80px #10291d40}
.columns-dialog::backdrop{background:#092b1d88}.columns-toolbar{display:flex;gap:9px;flex-wrap:wrap;margin-bottom:14px}.columns-toolbar input{flex:1;min-width:170px}
.columns-list{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;max-height:44vh;overflow:auto;padding:4px}
.column-option{display:flex;flex-direction:row;align-items:center;gap:9px;background:#f6faf7;padding:7px 9px;border-radius:8px;min-width:0;overflow-wrap:anywhere}.column-option input{width:16px;height:16px}
@media(max-width:1100px){.overview-kpis{grid-template-columns:1fr 1fr}}@media(max-width:720px){.overview-kpis,.pursal-search,.columns-list{grid-template-columns:1fr}.pursal-code-actions{grid-column:auto}.hbar-row{grid-template-columns:95px 1fr}.hbar-row>b{grid-column:2}}

/* V1.7 — purchase workflow, entity history, BOM hierarchy */
.purchase-period-toolbar{justify-content:flex-start}.period-choice{display:flex;gap:8px;flex-wrap:wrap}.period-choice button.active{background:#007247;color:#fff;border-color:#007247}
.purchase-smart-filters{grid-template-columns:repeat(4,minmax(145px,1fr)) 120px}
.detail-filter-grid,.stock-filter-grid,.pursal-filter-grid{display:grid;grid-template-columns:repeat(4,minmax(145px,1fr));gap:12px;align-items:end}.detail-filter-grid button,.stock-filter-grid button{height:39px}
.pursal-filter-grid{margin:15px 0;background:#f7faf8;border:1px solid #dce9e1;padding:14px;border-radius:14px}
.link-button{padding:0;border:0;background:transparent;color:#007247;font-weight:700;text-align:left}.link-button:hover{background:transparent;border:0;text-decoration:underline}.cell-sub{display:block;color:#82958a;font-weight:400;margin-top:2px}
.history-dialog{border:1px solid #d2e4da;border-radius:20px;padding:24px;width:min(1180px,96vw);max-height:90vh;box-shadow:0 25px 80px #10291d40}.history-dialog::backdrop{background:#092b1d88}.history-dialog .overview-kpis{grid-template-columns:repeat(3,minmax(0,1fr));margin-bottom:18px}.followup-compose{display:grid;grid-template-columns:1fr auto;gap:10px;align-items:end}.followup-compose textarea{border:1px solid #d8e1e5;border-radius:10px;padding:10px;font:inherit;resize:vertical}.followup-note{border:1px solid #e1ebe5;border-radius:11px;padding:10px 12px;margin-top:8px;background:#f8fbf9}.followup-note small{color:#7f9187;margin-left:8px}.followup-note p{margin:6px 0 0;white-space:pre-wrap}
.hierarchy-table .tree-indent{display:inline-block;width:22px}.tree-toggle{border:0;background:transparent;padding:1px 5px;color:#007247}.tree-leaf{display:inline-block;width:24px;color:#99aaa1}.hierarchy-table .bom-row td:first-child{font-weight:600}.hierarchy-table .no-bom-row td{background:#fbfcfb}.hierarchy-table .no-bom-row:first-of-type td{border-top:3px solid #dce9e1}.hierarchy-table td:first-child{position:sticky;left:0;background:#fff;z-index:1}.hierarchy-table .no-bom-row td:first-child{background:#fbfcfb}
@media(max-width:1100px){.purchase-smart-filters,.detail-filter-grid,.stock-filter-grid,.pursal-filter-grid{grid-template-columns:repeat(2,minmax(140px,1fr))}.history-dialog .overview-kpis{grid-template-columns:repeat(2,1fr)}}
@media(max-width:720px){.purchase-smart-filters,.detail-filter-grid,.stock-filter-grid,.pursal-filter-grid,.history-dialog .overview-kpis,.followup-compose{grid-template-columns:1fr}}

/* Purchase V1.8: wide tables & sticky item context */
.table-scroll,#pursalTable,#stockTable,#detailTable,#historyTable,#pursalReportsTable{max-width:100%;overflow:auto;max-height:72vh;position:relative;scrollbar-gutter:stable}
.table-scroll table,.hierarchy-table{border-collapse:separate;border-spacing:0;min-width:max-content}
.table-scroll thead th,.hierarchy-table thead th{position:sticky;top:0;z-index:5;background:var(--panel,#fff);box-shadow:0 1px 0 #cbd5e1}
#stockTable .hierarchy-table th:first-child,#stockTable .hierarchy-table td:first-child{position:sticky;left:0;z-index:4;background:var(--panel,#fff)}
#stockTable .hierarchy-table th:nth-child(2),#stockTable .hierarchy-table td:nth-child(2){position:sticky;left:42px;z-index:3;background:var(--panel,#fff);min-width:185px}
#pursalTable .hierarchy-table th:first-child,#pursalTable .hierarchy-table td:first-child{position:sticky;left:0;z-index:4;background:var(--panel,#fff);min-width:185px}
#stockTable .hierarchy-table thead th,#pursalTable .hierarchy-table thead th{z-index:7}
.tree-check{min-width:42px;width:42px;text-align:center}
.history-filter-bar{display:flex;flex-wrap:wrap;align-items:end;gap:10px;margin:14px 0}
.history-filter-bar label{min-width:130px;flex:1 1 150px}.history-filter-bar input,.history-filter-bar select{max-width:100%;width:100%}
.history-dialog{width:min(1320px,96vw);max-height:95vh;overflow:auto}
@media(max-width:800px){.history-filter-bar{display:grid;grid-template-columns:repeat(auto-fit,minmax(145px,1fr))}.sidebar{max-width:100%} .main{min-width:0}}

.dynamic-filter-rows{display:grid;gap:8px;margin-bottom:12px}.dynamic-filter-row{display:grid;grid-template-columns:minmax(150px,2fr) minmax(125px,1fr) minmax(150px,2fr) auto;gap:8px}.dynamic-filter-row>.dynamic-remove{font-size:20px}.dynamic-filter-panel>.heading{flex-wrap:wrap}@media(max-width:720px){.dynamic-filter-row{grid-template-columns:1fr 1fr}.dynamic-filter-row .dynamic-value{grid-column:1/-1}}

.inline-import{display:inline-flex;align-items:center;gap:8px;padding:9px 12px;border:1px solid #dbe5e9;border-radius:9px;background:white;cursor:pointer}.inline-import input{max-width:190px;font-size:11px}.hero-actions{display:flex;gap:8px;flex-wrap:wrap;align-items:center}

.permission-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(150px,1fr));gap:10px;margin:12px 0}.permission-grid label{font-weight:500}.permission-grid .check{margin:0}

#stockTable .hierarchy-table th:nth-child(3),#stockTable .hierarchy-table td:nth-child(3){position:sticky;left:227px;z-index:3;background:#fff;min-width:230px;max-width:300px;overflow:hidden;text-overflow:ellipsis}
#pursalTable .hierarchy-table th:nth-child(2),#pursalTable .hierarchy-table td:nth-child(2){position:sticky;left:185px;z-index:3;background:#fff;min-width:230px;max-width:300px;overflow:hidden;text-overflow:ellipsis}
#stockTable .hierarchy-table thead th:nth-child(-n+3),#pursalTable .hierarchy-table thead th:nth-child(-n+2){z-index:8;background:#f5f9fa}


/* V1.8.3 Alert tabs */
.alert-tabbar{display:flex;flex-wrap:wrap;gap:8px;margin:14px 0 18px;border-bottom:1px solid #d6e5dd;padding-bottom:9px}
.alert-tabbar button{border-radius:10px 10px 4px 4px;min-height:40px;padding:9px 16px;white-space:nowrap}
.alert-tabbar button.active{background:#067449;color:white;border-color:#067449}
.indent-toolbar{display:grid;grid-template-columns:minmax(145px,180px) minmax(145px,180px) minmax(200px,1fr) auto auto;align-items:end;gap:10px;margin:12px 0}
.indent-toolbar label{min-width:0}.indent-toolbar input{width:100%;max-width:100%}
#indentAlertContent .panel{min-width:0;max-width:100%}#indentTable{overflow:auto;max-height:70vh;max-width:100%}
#indentTable table{min-width:max-content}#indentTable th{position:sticky;top:0;z-index:5;background:#e8f2ec}
#indentPagination{display:flex;align-items:center;justify-content:flex-end;flex-wrap:wrap;gap:10px;margin-top:12px}
@media(max-width:950px){.indent-toolbar{grid-template-columns:repeat(2,minmax(0,1fr))}.indent-toolbar label:nth-child(3){grid-column:1/-1}}
@media(max-width:540px){.indent-toolbar{grid-template-columns:1fr}.indent-toolbar label:nth-child(3){grid-column:auto}}
