/* Inventory expense lists own their layout; editors and business handlers stay separate. */
@layer erp-reconstruction {
  #inventory-expense-panel { --iew-line:#d7e1ef; --iew-muted:#53647c; --iew-blue:#0868e8; box-sizing:border-box; min-width:0; color:#11274d!important; font:15px/1.6 "Microsoft YaHei UI","PingFang SC",sans-serif; font-size:15px!important; }
  #inventory-expense-panel[hidden],#inventory-expense-panel [hidden],
  #inventory-expense-panel .inventory-expense-view[hidden],
  #inventory-expense-panel .inventory-expense-empty[hidden] { display:none!important; }
  #inventory-expense-panel * { box-sizing:border-box; }
  #inventory-expense-panel:not([hidden]) { display:flex!important; flex-direction:column; height:auto!important; min-height:0!important; max-height:none; padding:20px 24px!important; overflow-y:auto!important; overflow-x:hidden!important; background:#fff!important; }
  #inventory-expense-panel :is(button,input,select) { min-width:0; min-height:44px!important; height:auto!important; font:inherit; line-height:1.5; color:inherit; border:1px solid #b8c9df; border-radius:6px; background:#fff; }
  #inventory-expense-panel button { padding:8px 14px; cursor:pointer; }
  #inventory-expense-panel button:disabled { color:#66758b; background:#f0f3f7; cursor:not-allowed; }
  #inventory-expense-panel button:hover:not(:disabled) { border-color:var(--iew-blue); background:#edf4fc; }
  #inventory-expense-panel :is(button,input,select):focus-visible { outline:2px solid var(--iew-blue); outline-offset:3px; }
  #inventory-expense-panel input { caret-color:var(--iew-blue); }
  #inventory-expense-panel input::placeholder { color:#586b85; opacity:1; }
  #inventory-expense-panel ::selection { color:#11274d; background:#d8e9ff; }

  #inventory-expense-panel .inventory-expense-tabs { display:flex; flex:0 0 auto; flex-wrap:wrap; align-items:stretch; gap:8px; height:auto; margin:0 0 16px; padding:0 0 12px; border:0; border-bottom:1px solid var(--iew-line); border-radius:0; background:transparent; }
  #inventory-expense-panel .inventory-expense-tabs button { flex:0 1 auto; min-width:0; border:1px solid transparent; border-radius:6px; color:var(--iew-muted); background:transparent; font-size:15px; font-weight:600; white-space:normal; box-shadow:none; }
  #inventory-expense-panel .inventory-expense-tabs button.active { color:#075abd; border-color:#b8d2f6; background:#edf4fc; box-shadow:none; }

  #inventory-expense-panel .inventory-expense-view { display:grid; flex:1 1 auto; grid-template-rows:auto auto minmax(160px,1fr) auto minmax(140px,.55fr)!important; min-width:0; min-height:0; height:auto!important; padding:0!important; overflow:hidden; }
  #inventory-expense-panel #inventory-expense-allocations { grid-template-rows:auto auto minmax(160px,1fr) auto!important; }
  #inventory-expense-panel .inventory-expense-filters { display:flex!important; flex-wrap:wrap; align-items:flex-end; gap:12px!important; min-width:0; min-height:0!important; height:auto!important; margin:0!important; padding:0 0 16px!important; border:0; border-bottom:1px solid var(--iew-line); border-radius:0; background:transparent; box-shadow:none; }
  #inventory-expense-panel .inventory-expense-filters > * { grid-column:auto!important; grid-row:auto!important; justify-self:auto!important; width:auto!important; max-width:100%; min-width:0; }
  #inventory-expense-panel .inventory-expense-filters > label { display:flex!important; flex:1 1 190px; flex-direction:column; align-items:stretch!important; gap:6px; width:auto!important; min-width:0; color:var(--iew-muted); font-size:14px; white-space:normal!important; }
  #inventory-expense-panel .inventory-expense-filters label :is(input,select) { flex:0 0 auto; width:100%; max-width:100%; padding:9px 10px; color:#11274d; font-size:15px; }
  #inventory-expense-panel .inventory-expense-filters > .inventory-expense-date { display:grid!important; flex:1 1 330px; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); align-items:center!important; gap:8px; }
  #inventory-expense-panel .inventory-expense-date input { flex:0 1 auto!important; width:100%; min-width:0; padding-inline:8px; }
  #inventory-expense-panel .inventory-expense-ranges { display:flex; flex:0 1 auto; flex-wrap:wrap; align-items:center; gap:6px; white-space:normal; }
  #inventory-expense-panel .inventory-expense-ranges button { width:auto!important; min-width:44px; padding:8px 10px!important; border:1px solid var(--iew-line); font-size:14px; white-space:nowrap; }
  #inventory-expense-panel .inventory-expense-ranges button.active { color:#075abd; border-color:#b8d2f6; background:#edf4fc; font-weight:600; }
  #inventory-expense-panel :is(#inventory-expense-reset,#inventory-allocation-reset) { flex:0 0 44px; width:44px!important; padding:8px; }
  #inventory-expense-panel .inventory-expense-primary { color:#fff!important; border-color:var(--iew-blue)!important; background:var(--iew-blue)!important; }
  #inventory-expense-panel .inventory-expense-primary:hover:not(:disabled) { background:#075abd!important; }

  #inventory-expense-panel .inventory-expense-actions { display:flex!important; flex:0 0 auto; flex-wrap:wrap; align-items:center; gap:8px!important; min-height:0!important; height:auto!important; margin:0!important; padding:12px 0!important; border:0!important; background:transparent!important; box-shadow:none; }
  #inventory-expense-panel .inventory-expense-actions > span { flex:1 1 auto; }
  #inventory-expense-panel :is(#inventory-expense-create,#inventory-allocation-create) { color:#fff; border-color:var(--iew-blue); background:var(--iew-blue); }

  #inventory-expense-panel .inventory-expense-table-wrap { position:relative; min-width:0; min-height:160px!important; max-height:none; overflow:auto!important; overscroll-behavior:contain; scrollbar-gutter:stable; border:1px solid var(--iew-line); border-radius:6px!important; background:#fff; }
  #inventory-expense-panel .inventory-expense-table { width:100%!important; min-width:1000px; height:auto!important; border-collapse:collapse; table-layout:fixed; font-size:15px; font-variant-numeric:tabular-nums; }
  #inventory-expense-panel .inventory-allocation-table { min-width:1280px; }
  #inventory-expense-panel .inventory-expense-table :is(th,td) { height:auto!important; min-height:44px; padding:10px 12px!important; vertical-align:middle; border-right:1px solid #e5ebf3; border-bottom:1px solid #e5ebf3; line-height:1.6; white-space:nowrap; }
  #inventory-expense-panel .inventory-expense-table th { position:sticky; top:0; z-index:1; color:#294467; background:#edf4fc; font-size:14px; font-weight:600; text-align:left; }
  #inventory-expense-panel .inventory-expense-table :is(th,td):first-child { width:44px; text-align:center; padding-inline:6px; }
  #inventory-expense-panel .inventory-expense-record-table :is(th,td):nth-child(2) { width:220px; }
  #inventory-expense-panel .inventory-expense-record-table :is(th,td):nth-child(3) { width:190px; }
  #inventory-expense-panel .inventory-expense-record-table :is(th,td):nth-child(4) { width:176px; }
  #inventory-expense-panel .inventory-expense-record-table :is(th,td):nth-child(5) { width:120px; }
  #inventory-expense-panel .inventory-expense-record-table :is(th,td):nth-child(n+6) { width:132px; text-align:right; }
  #inventory-expense-panel .inventory-expense-table tbody tr:hover { background:#f5f9ff; }
  #inventory-expense-panel .inventory-expense-table tbody tr.active { background:#eaf2ff; }
  #inventory-expense-panel .inventory-expense-table tfoot td { position:sticky; bottom:0; background:#f5f8fc; font-weight:600; border-top:1px solid var(--iew-line); }
  #inventory-expense-panel .inventory-expense-link { min-width:44px; padding:8px 0; border:0; color:#075abd; background:transparent; text-align:left; font-size:15px; }
  #inventory-expense-panel .inventory-expense-empty { position:sticky!important; inset:auto!important; left:0!important; display:flex!important; flex-direction:column; align-items:center; justify-content:center; gap:10px; width:100%; min-height:160px!important; padding:24px; color:var(--iew-muted); background:#fff; font-size:15px; text-align:center; white-space:normal; overflow-wrap:anywhere; }
  #inventory-expense-panel .inventory-expense-empty strong { color:#11274d; font-size:15px; }
  #inventory-expense-panel .inventory-expense-empty span { max-width:65ch; }
  #inventory-expense-panel .inventory-expense-empty button { margin:8px; }
  #inventory-expense-panel .inventory-expense-footer { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:8px; min-height:36px; margin:0; padding:8px 0; color:var(--iew-muted); font-size:14px; }

  #inventory-expense-panel .inventory-expense-detail { display:grid; grid-template-rows:auto minmax(0,1fr)!important; min-width:0; min-height:0; margin:8px 0 0; overflow:hidden; border:1px solid var(--iew-line); border-radius:6px!important; background:#fff; }
  #inventory-expense-panel .inventory-expense-detail > nav { display:flex; flex-wrap:wrap; align-items:center; gap:6px; min-width:0; padding:8px; border-bottom:1px solid var(--iew-line); }
  #inventory-expense-panel .inventory-expense-detail > nav button { border-color:transparent; color:var(--iew-muted); background:transparent; white-space:normal; }
  #inventory-expense-panel .inventory-expense-detail > nav button.active { color:#075abd; border-color:#b8d2f6; background:#edf4fc; }
  #inventory-expense-panel .inventory-expense-detail > div { min-width:0; min-height:0; overflow:auto; overscroll-behavior:contain; scrollbar-gutter:stable; }
  #inventory-expense-panel .inventory-expense-detail table { width:100%!important; min-width:480px; border-collapse:collapse; table-layout:auto; font-size:15px; font-variant-numeric:tabular-nums; }
  #inventory-expense-panel #inventory-expense-payments-pane table { width:100%!important; min-width:680px; }
  #inventory-expense-panel .inventory-expense-detail :is(th,td) { height:auto; padding:10px 12px; border:0; border-bottom:1px solid #e5ebf3; line-height:1.6; text-align:left; white-space:nowrap; }
  #inventory-expense-panel .inventory-expense-detail th { position:sticky; top:0; background:#edf4fc; color:#294467; font-size:14px; font-weight:600; }
  #inventory-expense-panel .inventory-expense-detail :is(th,td):first-child { width:44px; text-align:center; }
  #inventory-expense-panel .inventory-expense-detail :is(th,td):last-child { text-align:right; }
  #inventory-expense-panel :is(.inventory-expense-table-wrap,.inventory-expense-detail > div) { scrollbar-color:#a4b8d2 #f5f8fc; }

  @media(max-width:900px) {
    #inventory-expense-panel:not([hidden]) { flex:1 1 auto; padding:16px 12px!important; overflow-y:auto!important; overflow-x:hidden!important; }
    #inventory-expense-panel .inventory-expense-tabs { display:grid!important; grid-template-columns:repeat(2,minmax(0,1fr))!important; overflow:visible!important; gap:6px; margin-bottom:16px; padding:0 0 12px; }
    #inventory-expense-panel .inventory-expense-tabs button { width:100%; padding:8px; }
    #inventory-expense-panel .inventory-expense-view { display:flex!important; flex:0 0 auto; flex-direction:column; min-height:0; height:auto; overflow:visible; }
    #inventory-expense-panel .inventory-expense-filters { display:grid!important; grid-template-columns:minmax(0,1fr) 44px auto!important; gap:12px 8px!important; padding:0 0 16px!important; }
    #inventory-expense-panel .inventory-expense-filters > :is(label,.inventory-expense-ranges) { grid-column:1/-1!important; width:100%!important; }
    #inventory-expense-panel .inventory-expense-filters > button { width:auto!important; }
    #inventory-expense-panel .inventory-expense-filters > label { flex:none; gap:6px; }
    #inventory-expense-panel .inventory-expense-filters > .inventory-expense-date { display:grid; grid-template-columns:minmax(0,1fr) auto minmax(0,1fr); gap:6px; }
    #inventory-expense-panel .inventory-expense-filters > :is(#inventory-expense-more,#inventory-allocation-more) { justify-self:start!important; }
    #inventory-expense-panel .inventory-expense-ranges { display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:6px; }
    #inventory-expense-panel .inventory-expense-ranges button { width:100%!important; padding:8px 3px!important; }
    #inventory-expense-panel .inventory-expense-actions > span { display:none; }
    #inventory-expense-panel .inventory-expense-actions > button:first-child { flex:1 0 100%; width:100%; }
    #inventory-expense-panel .inventory-expense-actions > button { flex:1 1 auto; }
    #inventory-expense-panel .inventory-expense-table { display:table!important; width:100%!important; min-width:1100px!important; }
    #inventory-expense-panel .inventory-expense-table thead { display:table-header-group!important; position:static!important; width:auto!important; height:auto!important; clip-path:none!important; }
    #inventory-expense-panel .inventory-expense-table tbody { display:table-row-group!important; }
    #inventory-expense-panel .inventory-expense-table tfoot { display:table-footer-group!important; }
    #inventory-expense-panel .inventory-expense-table tr { display:table-row!important; padding:0!important; }
    #inventory-expense-panel .inventory-expense-table :is(th,td) { display:table-cell!important; width:auto!important; min-width:0!important; overflow:visible!important; white-space:nowrap!important; }
    #inventory-expense-panel .inventory-expense-table :is(th,td)::before { display:none!important; content:none!important; }
    #inventory-expense-panel .inventory-expense-table tfoot td { position:static!important; }
    #inventory-expense-panel .inventory-expense-table-wrap { flex:0 0 auto; min-height:180px!important; max-height:440px; overflow:auto; }
    #inventory-expense-panel .inventory-expense-footer { min-height:44px; }
    #inventory-expense-panel .inventory-expense-detail { flex:0 0 auto; min-height:0; margin-top:12px; overflow:hidden; }
    #inventory-expense-panel .inventory-expense-detail > div { min-height:120px; max-height:320px; }
  }
  @media(min-width:901px) and (max-height:740px) {
    #inventory-expense-panel:not([hidden]) { overflow-y:auto!important; }
    #inventory-expense-panel .inventory-expense-view { flex:0 0 auto; grid-template-rows:auto auto 200px auto 180px!important; overflow:visible; }
    #inventory-expense-panel #inventory-expense-allocations { grid-template-rows:auto auto 260px auto!important; }
  }
}

/* Inventory expense entry owns a full page while retaining the original form. */
@layer erp-reconstruction {
body.pixel-replica.inventory-expense-entry-open :is(#module-page,#dashboard-page){display:none!important}
body.inventory-expense-entry-open .main{display:flex!important;flex-direction:column!important;overflow:hidden!important;min-height:0!important}
body.inventory-expense-entry-open{overflow:hidden!important}
#inventory-expense-entry-host{flex:1;min-height:0;margin:18px 24px 0;background:#fff;color:#213047;font:15px/1.6 "Microsoft YaHei",sans-serif}
#inventory-expense-entry-host[hidden],#inventory-expense-entry-host [hidden]{display:none!important}
#inventory-expense-entry-host *{box-sizing:border-box}
#inventory-expense-entry-host #inventory-expense-modal{position:static!important;display:block!important;inset:auto!important;padding:0!important;height:100%!important;max-height:none!important;overflow:hidden!important;background:none!important}
#inventory-expense-entry-host #inventory-expense-form{display:flex!important;flex-direction:column!important;width:100%!important;height:100%!important;max-height:none!important;margin:0!important;padding:0!important;border:0!important;border-radius:0!important;box-shadow:none!important;background:#fff!important;color:inherit;font:inherit;overflow:hidden!important}
#inventory-expense-entry-host :is(header,footer){display:flex!important;flex:0 0 auto;align-items:center!important;gap:12px!important;height:auto!important;padding:20px 24px!important;background:#fff!important}
#inventory-expense-entry-host header{border-bottom:1px solid #dce3ec!important}
#inventory-expense-entry-host header strong{font-size:24px!important;line-height:1.4;color:#172d47}
#inventory-expense-entry-host header button{margin-left:auto;min-width:44px}
#inventory-expense-entry-host .inventory-expense-entry-body{display:block!important;flex:1;min-height:0;overflow:auto!important;padding:24px!important;scrollbar-color:#9badc4 #f1f4f8;overscroll-behavior:contain}
#inventory-expense-entry-host .inventory-expense-entry-fields{display:grid!important;grid-template-columns:repeat(2,minmax(0,1fr))!important;gap:20px 24px!important;padding:0!important}
#inventory-expense-entry-host label{display:grid!important;gap:8px!important;min-width:0;font-size:14px!important;color:#53647a}
#inventory-expense-entry-host label.wide{grid-column:1/-1}
#inventory-expense-entry-host :is(button,input,select){font:15px/1.6 "Microsoft YaHei",sans-serif!important;min-height:44px!important;height:auto!important;max-width:100%;min-width:0;padding:8px 12px!important;border:1px solid #bfcbdc!important;border-radius:4px!important;background:#fff!important;color:#213047!important}
#inventory-expense-entry-host :is(input,select){width:100%}
#inventory-expense-entry-host footer{justify-content:flex-end!important;border-top:1px solid #dce3ec!important;border-bottom:0!important}
#inventory-expense-entry-host button[type=submit]{background:#245ca7!important;color:#fff!important;border-color:#245ca7!important}
#inventory-expense-entry-host button:hover:not(:disabled){filter:brightness(.96)}
#inventory-expense-entry-host :disabled{opacity:.65;cursor:default}
#inventory-expense-entry-host :focus-visible{outline:3px solid #6394df!important;outline-offset:2px}
#inventory-expense-entry-host ::selection{background:#d7e6fc;color:#172d47}
#inventory-expense-entry-host #inventory-expense-recovery{font-size:15px;line-height:1.7;padding:16px 0;color:#81521a}
#inventory-expense-entry-host #inventory-expense-entry-error{font-size:15px;color:#a32626;line-height:1.7;margin:20px 0 0;overflow-wrap:anywhere}
@media(max-width:767px){
 #inventory-expense-entry-host{margin:0}
 #inventory-expense-entry-host :is(header,footer){padding:16px!important}
 #inventory-expense-entry-host header strong{font-size:22px!important}
 #inventory-expense-entry-host .inventory-expense-entry-body{padding:20px 16px!important}
 #inventory-expense-entry-host .inventory-expense-entry-fields{grid-template-columns:minmax(0,1fr)!important;gap:18px!important}
 #inventory-expense-entry-host footer button{flex:1;min-width:0!important;padding-inline:8px!important}
}
}
