:root{
  --brand:#E32119;
  --brand-dark:#B51811;
  --brand-gray:#4A4A4A;
  --brand-light:#fdf4f4;
  --muted:#6c757d;
  --panel:#f8f9fa;
  --card-shadow: 0 1px 6px rgba(32,33,36,0.08);
}
html,body{height:100%;}
body{
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  background:#fbfcfd;
  color:#222;
}

/* Slightly increase checkbox/radio contrast against light surfaces. */
.form-check-input{
  background-color:#f4f6fb;
  border-color:#9aa7ba;
  box-shadow:inset 0 0 0 1px rgba(18, 32, 56, 0.06);
}

.form-check-input:checked,
.form-check-input[type="radio"]:checked{
  border-color:#0d6efd;
}

.form-check-input:focus{
  border-color:#4b8dff;
  box-shadow:0 0 0 0.14rem rgba(13, 110, 253, 0.22), inset 0 0 0 1px rgba(18, 32, 56, 0.08);
}
.navbar-brand{font-weight:700;letter-spacing:0.2px;}
.nav-split-dropdown > .dropdown-menu{flex-basis:100%;}
@media (min-width: 992px){
  /* Hover-open skips Bootstrap's positioning, and a flex parent's static position would overlap the label. */
  .nav-split-dropdown > .dropdown-menu{top:100%;left:0;}
}
.aron-navbar{background:#E32119!important;border-bottom:3px solid #B51811;}
.aron-navbar .navbar-brand,.aron-navbar .nav-link,.aron-navbar .navbar-toggler{color:#fff!important;}
.aron-navbar .nav-link:hover,.aron-navbar .nav-link:focus{color:rgba(255,255,255,0.8)!important;}
.aron-navbar .dropdown-menu{border-top:3px solid #E32119;}
.aron-navbar .navbar-toggler-icon{filter:invert(1) brightness(2);}
.aron-navbar .dropdown-menu > li:not(:first-child) > .dropdown-header{border-top:1px solid var(--bs-border-color-translucent);margin-top:.25rem;padding-top:.5rem;}
.aron-navbar .dropdown-header{font-size:.7rem;text-transform:uppercase;letter-spacing:.05em;font-weight:600;}
.aron-navbar .nav-user-name{display:inline-block;max-width:10rem;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;vertical-align:bottom;}
.main-container{max-width:1200px;margin:0 auto;padding:0 16px}

@media (min-width: 992px){
  .navbar .dropdown:hover > .dropdown-menu{
    display:block;
    margin-top:0;
  }
  /* Hover-open skips Popper, so right-side menus must anchor to the right edge themselves. */
  .aron-navbar .dropdown > .dropdown-menu-end{right:0;left:auto;}
  /* Nested "Planning" submenu: stays collapsed until hovered directly, then
     flies out horizontally to the right of the parent item. */
  .dropdown-submenu{position:relative;}
  .dropdown-submenu > .dropdown-menu{
    top:0;
    left:100%;
    margin-top:0;
    margin-left:2px;
  }
  .dropdown-submenu:hover > .dropdown-menu{
    display:flex;
    flex-direction:row;
  }
  .dropdown-submenu > .dropdown-menu > li > .dropdown-item{
    white-space:nowrap;
  }
}

/* Orders page: allow a much wider layout so the orders table
  can take up most of the screen when the window is maximized. */
.orders-page .main-container{max-width:95vw;padding:0 20px}

/* Vendor RFQs page: widen so the Parts/Vendors/RFQs tab tables use most of the screen. */
.vendor-rfqs-page .main-container{max-width:95vw;padding:0 20px}
.parts-vendors-page .main-container{max-width:95vw;padding:0 20px}

/* Customer RFQs page: widen so the RFQ grid isn't cramped by the default 1200px cap. */
.customer-rfqs-page .main-container{max-width:95vw;padding:0 20px}

/* Replacements page: widen so the RMA table isn't cramped by the default 1200px cap. */
.replacements-page .main-container{max-width:95vw;padding:0 20px}
.sample-requests-page .main-container{max-width:95vw;padding:0 20px}
.sample-requests-page thead th{overflow-wrap:normal !important;word-break:normal !important}
.sample-requests-page #samples-table .btn{white-space:nowrap !important;overflow-wrap:normal !important;word-break:normal !important}
.sample-requests-page #sampleFixtureBody input{min-width:95px}
.sample-requests-page #sampleFixtureBody input.sf-qty{min-width:65px}
.sample-requests-page #sampleFixtureBody input.sf-fixture-code,.sample-requests-page #sampleFixtureBody input.sf-tracking{min-width:150px}
.orders-page .orders-card{padding:1.25rem}
.flash-wrapper .alert{border-radius:8px;box-shadow:var(--card-shadow);}
.orders-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:1rem}
.orders-card{background:white;border-radius:10px;padding:1rem;border:1px solid rgba(15,15,20,0.03);box-shadow:var(--card-shadow)}
.orders-table-wrapper{margin:0 -0.5rem}

/* Global table readability: wrap cell content instead of bleeding into adjacent columns. */
table th,
table td{
  white-space:normal !important;
  overflow-wrap:anywhere;
  word-break:break-word;
}

/* Keep action/control columns compact and single-line where wrapping harms usability. */
table .toggle-col,
table .po-row-actions-cell,
table th.master-po-action-col,
table td.master-po-action-col{
  white-space:nowrap !important;
}

/* Batch Invoicer */
#batch-invoicer-page{
  --binv-age-1_30:#f0b429;--binv-age-1_30-bg:#fff6dc;--binv-age-1_30-fg:#7a5200;
  --binv-age-31_60:#f08c2b;--binv-age-31_60-bg:#ffeedd;--binv-age-31_60-fg:#8f4300;
  --binv-age-61_90:#e8590c;--binv-age-61_90-bg:#ffe3d6;--binv-age-61_90-fg:#9c3606;
  --binv-age-90_plus:#c92a2a;--binv-age-90_plus-bg:#fde2e2;--binv-age-90_plus-fg:#951b1b;
  --binv-line:#e9edf3;--binv-soft:#f6f8fb;--binv-muted:#6c757d;--binv-recent-bg:#fff4d6;--binv-recent-fg:#7a5600;
}
#batch-invoicer-page .min-w-0{min-width:0}
#batch-invoicer-page .binv-pill{display:inline-flex;align-items:center;gap:.35rem;padding:.2rem .65rem;border:1px solid var(--binv-line);border-radius:999px;background:var(--binv-soft);font-size:.8rem;color:var(--binv-muted)}
#batch-invoicer-page .binv-pill strong{color:var(--bs-body-color);font-weight:600}
#batch-invoicer-page .binv-kpi{display:flex;flex-direction:column;align-items:flex-start;gap:.1rem;width:100%;height:100%;text-align:left;padding:.7rem .9rem;border:1px solid var(--binv-line);border-left:4px solid #6c757d;border-radius:.6rem;background:var(--bs-body-bg);transition:box-shadow .15s ease,transform .15s ease}
#batch-invoicer-page .binv-kpi-total{border-left-color:#0d6efd}
#batch-invoicer-page .binv-kpi-days{border-left-color:#6f42c1}
#batch-invoicer-page button.binv-kpi:not(:disabled):hover{box-shadow:0 2px 10px rgba(0,0,0,.08);transform:translateY(-1px)}
#batch-invoicer-page button.binv-kpi:disabled{opacity:.55;cursor:default}
#batch-invoicer-page button.binv-kpi.is-active{box-shadow:0 0 0 2px rgba(13,110,253,.35)}
#batch-invoicer-page .binv-kpi-label{font-size:.72rem;text-transform:uppercase;letter-spacing:.04em;color:var(--binv-muted);font-weight:600}
#batch-invoicer-page .binv-kpi-value{font-size:1.4rem;font-weight:700;line-height:1.2;color:var(--bs-body-color)}
#batch-invoicer-page .binv-kpi-sub{font-size:.78rem;color:var(--binv-muted)}
#batch-invoicer-page .binv-kpi-bucket.binv-age-1_30{border-left-color:var(--binv-age-1_30)}
#batch-invoicer-page .binv-kpi-bucket.binv-age-31_60{border-left-color:var(--binv-age-31_60)}
#batch-invoicer-page .binv-kpi-bucket.binv-age-61_90{border-left-color:var(--binv-age-61_90)}
#batch-invoicer-page .binv-kpi-bucket.binv-age-90_plus{border-left-color:var(--binv-age-90_plus)}
#batch-invoicer-page .binv-main-card{padding:0}
#batch-invoicer-page .binv-toolbar{display:flex;flex-wrap:wrap;align-items:center;gap:.6rem 1rem;padding:.75rem 1rem;border-bottom:1px solid var(--binv-line)}
#batch-invoicer-page .binv-search{max-width:22rem;min-width:14rem;flex:1 1 16rem}
#batch-invoicer-page .binv-active-filter{display:inline-flex;align-items:center;gap:.4rem;padding:.15rem .3rem .15rem .6rem;border-radius:999px;background:rgba(13,110,253,.1);color:#0a58ca;font-size:.8rem;font-weight:600}
#batch-invoicer-page .binv-active-filter .btn-close{font-size:.55rem}
#batch-invoicer-page .binv-table-wrap{overflow-x:auto}
#batch-invoicer-page #batchInvoicerTable > thead th{font-size:.74rem;text-transform:uppercase;letter-spacing:.03em;color:var(--binv-muted);background:var(--binv-soft);border-bottom:1px solid var(--binv-line);white-space:nowrap !important;padding:.55rem .5rem}
#batch-invoicer-page #batchInvoicerTable > tbody > tr > td{padding:.55rem .5rem}
#batch-invoicer-page .binv-check-col{width:42px;text-align:center}
#batch-invoicer-page th.binv-sortable{cursor:pointer;user-select:none}
#batch-invoicer-page th.binv-sortable::after{content:'';display:inline-block;margin-left:.3rem;opacity:.35;border:4px solid transparent;border-top-color:currentColor;vertical-align:-1px}
#batch-invoicer-page th.binv-sortable.is-sorted{color:var(--bs-body-color)}
#batch-invoicer-page th.binv-sortable.is-sorted::after{opacity:1}
#batch-invoicer-page th.binv-sortable.is-sorted[data-sort-dir-active="asc"]::after{border-top-color:transparent;border-bottom-color:currentColor;vertical-align:3px}
#batch-invoicer-page .binv-customer-row{cursor:pointer}
#batch-invoicer-page .binv-customer-row:hover > td{background:rgba(13,110,253,.035)}
#batch-invoicer-page .binv-customer-row.is-selected > td{background:rgba(13,110,253,.06)}
#batch-invoicer-page .binv-customer-row.is-no-email > td{background:rgba(220,53,69,.035)}
#batch-invoicer-page .binv-customer-cell{display:flex;align-items:center;gap:.4rem;min-width:14rem}
#batch-invoicer-page .binv-customer-name{line-height:1.25}
#batch-invoicer-page .binv-toggle{flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;width:1.6rem;height:1.6rem;border:0;border-radius:.35rem;background:transparent;color:var(--binv-muted);transition:transform .15s ease,background .15s ease}
#batch-invoicer-page .binv-toggle:hover{background:var(--binv-soft);color:var(--bs-body-color)}
#batch-invoicer-page .binv-toggle.open{transform:rotate(90deg)}
#batch-invoicer-page .binv-aging-col{width:150px}
#batch-invoicer-page .binv-aging-bar{display:flex;width:130px;height:.55rem;border-radius:999px;overflow:hidden;background:var(--binv-line)}
#batch-invoicer-page .binv-aging-seg{display:block;height:100%}
#batch-invoicer-page .binv-aging-seg.binv-age-1_30{background:var(--binv-age-1_30)}
#batch-invoicer-page .binv-aging-seg.binv-age-31_60{background:var(--binv-age-31_60)}
#batch-invoicer-page .binv-aging-seg.binv-age-61_90{background:var(--binv-age-61_90)}
#batch-invoicer-page .binv-aging-seg.binv-age-90_plus{background:var(--binv-age-90_plus)}
#batch-invoicer-page .binv-age-badge{display:inline-block;padding:.12rem .5rem;border-radius:999px;font-size:.76rem;font-weight:600;white-space:nowrap}
#batch-invoicer-page .binv-age-badge.binv-age-1_30{background:var(--binv-age-1_30-bg);color:var(--binv-age-1_30-fg)}
#batch-invoicer-page .binv-age-badge.binv-age-31_60{background:var(--binv-age-31_60-bg);color:var(--binv-age-31_60-fg)}
#batch-invoicer-page .binv-age-badge.binv-age-61_90{background:var(--binv-age-61_90-bg);color:var(--binv-age-61_90-fg)}
#batch-invoicer-page .binv-age-badge.binv-age-90_plus{background:var(--binv-age-90_plus-bg);color:var(--binv-age-90_plus-fg)}
#batch-invoicer-page .binv-recent-badge{display:inline-flex;align-items:center;gap:.25rem;padding:.1rem .5rem;border-radius:999px;background:var(--binv-recent-bg);color:var(--binv-recent-fg);font-weight:600;white-space:nowrap}
#batch-invoicer-page .binv-recent-text{color:var(--binv-recent-fg);font-weight:600}
#batch-invoicer-page .binv-count-chip{display:inline-block;margin-left:.2rem;padding:0 .35rem;border-radius:.3rem;background:var(--binv-soft);border:1px solid var(--binv-line);font-size:.7rem;color:var(--binv-muted)}
#batch-invoicer-page .binv-detail-row > td{background:var(--bs-body-bg);padding-top:0 !important}
#batch-invoicer-page .binv-detail-wrap{margin:0 0 .6rem;border:1px solid var(--binv-line);border-left:3px solid #0d6efd;border-radius:.45rem;overflow-x:auto}
#batch-invoicer-page .binv-invoice-table thead th{background:var(--binv-soft);font-size:.72rem;color:var(--binv-muted);text-transform:uppercase;letter-spacing:.03em;white-space:nowrap !important}
#batch-invoicer-page .binv-invoice-table td{border-bottom-color:var(--binv-line);font-size:.85rem}
#batch-invoicer-page .binv-invoice-table tr:last-child td{border-bottom:0}
#batch-invoicer-page .binv-invoice-row.binv-filtered{display:none}
#batch-invoicer-page .binv-empty{padding:2rem 1rem !important;text-align:center;color:var(--binv-muted)}
#batch-invoicer-page .binv-selection-bar{position:sticky;bottom:0;z-index:5;display:flex;flex-wrap:wrap;align-items:center;gap:.5rem 1rem;padding:.65rem 1rem;border-top:1px solid var(--binv-line);border-radius:0 0 10px 10px;background:var(--bs-body-bg);box-shadow:0 -4px 12px rgba(15,23,42,.06)}
#batch-invoicer-page .binv-selection-bar.has-selection{border-top-color:rgba(13,110,253,.45)}
#batch-invoicer-page .binv-selection-count{font-size:1.1rem;font-weight:700}
#batch-invoicer-page .binv-sender-input{width:17rem}
#batch-invoicer-page .binv-history-toggle{color:var(--bs-body-color)}
#batch-invoicer-page .binv-history-toggle .bi-chevron-down{display:inline-block;transition:transform .15s ease}
#batch-invoicer-page .binv-history-toggle.collapsed .bi-chevron-down{transform:rotate(-90deg)}
#batch-invoicer-page .binv-history-search{max-width:16rem}
#batch-invoicer-page .binv-history-scroll{max-height:420px;overflow:auto}
#batch-invoicer-page .binv-history-scroll thead th{position:sticky;top:0;z-index:1;background:var(--binv-soft);font-size:.74rem;text-transform:uppercase;letter-spacing:.03em;color:var(--binv-muted)}

/* PO Hub: PO table system */
.po-hub-po.orders-table-wrapper{overflow-y:auto;overflow-x:auto;max-height:72vh}
.po-hub-po.orders-table-wrapper > table.po-table{
  border-collapse:separate;
  border-spacing:0;
  width:100%;
  max-width:100%;
  table-layout:fixed;
  border:1px solid #e4e9ef;
  border-radius:10px;
  overflow:hidden;
}
.po-hub-po.orders-table-wrapper > table.po-table thead th{
  white-space:normal;
  position:sticky;
  top:0;
  z-index:3;
  background:#f6f8fb;
  border-top:1px solid #e4e9ef;
  border-bottom:1px solid #dde3eb;
  font-size:0.72rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.035em;
  line-height:1.1;
  color:#4f5d73;
  overflow:visible;
  text-overflow:clip;
}
.po-hub-po.orders-table-wrapper > table.po-table th,
.po-hub-po.orders-table-wrapper > table.po-table td{
  padding:0.42rem 0.45rem;
  vertical-align:middle;
  border-right:1px solid #e8ecf2;
}
.po-hub-po.orders-table-wrapper > table.po-table td{
  font-size:0.9rem;
}
.po-hub-po.orders-table-wrapper > table.po-table th:last-child,
.po-hub-po.orders-table-wrapper > table.po-table td:last-child{border-right:none}
.po-hub-po.orders-table-wrapper > table.po-table tbody tr{height:auto;max-height:none}
.po-hub-po.orders-table-wrapper > table.po-table tbody td{
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  max-width:none;
  border-bottom:1px solid #e8ecf2;
}
.po-hub-po.orders-table-wrapper > table.po-table tbody tr{background:#ffffff}
.po-hub-po.orders-table-wrapper > table.po-table tbody tr:not(.po-fixture-row):hover{
  background:#f9fbfe !important;
}
.po-hub-po.orders-table-wrapper > table.po-table thead th.date-col,
.po-hub-po.orders-table-wrapper > table.po-table td.date-col{width:auto;min-width:0;max-width:none}

.po-hub-po.orders-table-wrapper > table.po-table thead th.toggle-col,
.po-hub-po.orders-table-wrapper > table.po-table tbody td.po-row-actions-cell{
  width:112px;
  min-width:112px;
  white-space:nowrap;
}

.po-hub-po.orders-table-wrapper > table.po-table thead th.toggle-col{
  text-align:center;
}

/* Keep the PO overview table inside card width with stable proportional columns. */
.po-hub-po.orders-table-wrapper > table.po-table thead th:nth-child(1){width:112px}
.po-hub-po.orders-table-wrapper > table.po-table thead th:nth-child(2){width:50px}

/* PO controls are scoped to the PO table namespace only. */
.po-hub-po.orders-table-wrapper > table.po-table td > .po-control,
.po-hub-po.orders-table-wrapper > table.po-table td > input.po-control,
.po-hub-po.orders-table-wrapper > table.po-table td > input[type="date"].po-control{
  border:none !important;
  border-bottom:1px solid rgba(0,0,0,0.12) !important;
  border-radius:0 !important;
  background:transparent !important;
  box-shadow:none !important;
  display:block;
  width:100%;
  box-sizing:border-box;
  margin:0;
  height:100%;
  padding:0.5rem 0.75rem !important;
}
.po-hub-po.orders-table-wrapper > table.po-table td > .po-control:focus,
.po-hub-po.orders-table-wrapper > table.po-table td > input.po-control:focus,
.po-hub-po.orders-table-wrapper > table.po-table td > input[type="date"].po-control:focus{
  outline:none !important;
  border-bottom-color:var(--brand) !important;
  background:rgba(13,110,253,0.03) !important;
  box-shadow:0 4px 12px rgba(13,110,253,0.06) inset !important;
}
.po-hub-po.orders-table-wrapper > table.po-table td > select.po-control,
.po-hub-po.orders-table-wrapper > table.po-table td > select.form-select.po-control,
.po-hub-po.orders-table-wrapper > table.po-table td > select.form-select-sm.po-control{
  border:none !important;
  border-bottom:1px solid rgba(0,0,0,0.12) !important;
  border-radius:0 !important;
  background:transparent !important;
  padding:0.5rem 0.75rem !important;
  box-shadow:none !important;
  width:100%;
  box-sizing:border-box;
  appearance:menulist-button;
  -webkit-appearance:menulist-button;
}
.po-hub-po.orders-table-wrapper > table.po-table td > select.po-control:focus{
  outline:none !important;
  border-bottom-color:var(--brand) !important;
  background:rgba(13,110,253,0.03) !important;
}
.po-control.saving,
.po-control-checkbox.saving{opacity:0.6}
.po-control.is-invalid{border-bottom-color:#dc3545 !important}

/* PO Hub: fixture table system */
.po-hub-fixture{
  background:#f8fafc;
  color:#1f2937;
  border:1px solid #e4e9ef;
  border-radius:10px;
  padding:.9rem;
  margin-top:.35rem;
  overflow-x:auto;
}
.po-hub-fixture .fixture-title{
  display:block;
  margin-bottom:.5rem;
  color:#4f5d73;
  font-size:.78rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.03em;
}
.po-hub-fixture .fixture-table{
  background:#fff;
  color:#1f2937;
  margin-bottom:0;
  table-layout:fixed;
  width:100%;
  max-width:100%;
  border-collapse:separate;
  border-spacing:0;
}
.po-hub-fixture .fixture-table thead th{
  position:relative;
  background:#f6f8fb;
  border-top:1px solid #e4e9ef;
  border-bottom:1px solid #dde3eb;
  border-right:1px solid #e8ecf2;
  font-size:inherit;
  font-weight:600;
  text-transform:none;
  letter-spacing:normal;
  color:#4f5d73;
  overflow:visible;
  min-width:0;
}
.po-hub-fixture .fixture-table tbody td{
  border-bottom:1px solid #edf1f6;
  border-right:1px solid #edf1f6;
  white-space:normal;
  overflow:visible;
  text-overflow:clip;
  max-width:none;
  height:auto;
  padding:0.45rem 0.5rem;
  vertical-align:middle;
  min-width:0;
}
.po-hub-fixture .fixture-table th:last-child,
.po-hub-fixture .fixture-table td:last-child{border-right:none}
.po-hub-fixture .fixture-table tbody tr:nth-child(odd),
.po-hub-fixture .fixture-table tbody tr:nth-child(even){background:#ffffff}
.po-hub-fixture .fixture-table tbody tr:nth-child(odd){background:#fbfdff}
.po-hub-fixture .fixture-table tbody tr:hover{background:#f4f8fc}

/* Fixture controls are scoped to fixture namespace only. */
.po-hub-fixture .fixture-control,
.po-hub-fixture .fixture-control.form-control,
.po-hub-fixture .fixture-control.form-control-sm{
  border:none !important;
  border-bottom:1px solid rgba(79,93,115,0.28) !important;
  border-radius:0 !important;
  background:transparent !important;
  color:#1f2937 !important;
  box-shadow:none !important;
  width:100%;
  min-width:0;
  box-sizing:border-box;
  padding:0.42rem 0 !important;
}
.po-hub-fixture .fixture-control:focus,
.po-hub-fixture .fixture-control.form-control:focus,
.po-hub-fixture .fixture-control.form-control-sm:focus{
  outline:none !important;
  border-bottom-color:#637eb4 !important;
  background:rgba(99,126,180,0.05) !important;
  box-shadow:0 4px 12px rgba(99,126,180,0.05) inset !important;
}
.fixture-control.saving,
.fixture-control-checkbox.saving{opacity:0.6}
.fixture-control.is-invalid{border-bottom-color:#dc3545 !important}
.col-resizer{
  position:absolute;right:-1px;top:0;bottom:0;width:12px;
  cursor:col-resize;z-index:4;
  /* Visible grip: two-pixel right border reveals itself on hover */
  border-right:2px solid transparent;
  transition:border-color 0.1s;
}
.col-resizer:hover,.col-resizer.dragging{
  border-right-color:rgba(99,126,180,0.7);
}
.modal .form-label{font-size:0.92rem;font-weight:600;color:#333}
.modal .form-control:focus{box-shadow:0 0 0 0.15rem rgba(13,110,253,0.12)}
.modal .modal-content{border-radius:10px}
#poDetailModal .modal-dialog,
#createOrderModal .modal-dialog{
  max-height:calc(100vh - 1rem);
}

#poDetailModal .modal-content,
#createOrderModal .modal-content{
  max-height:calc(100vh - 1rem);
  overflow:hidden;
}

#poDetailModal .modal-body,
#createOrderModal .modal-body{
  overflow-y:auto !important;
  -webkit-overflow-scrolling:touch;
}
.muted{color:var(--muted)}
.small-muted{font-size:0.9rem;color:var(--muted)}

/* Bigger, cleaner toggle switch (e.g. User Settings > Appearance > Dark Mode) -
   font-size scales on the .form-check container (not just the input) so
   Bootstrap's own padding-left/margin-left offset (both em-based) stay in
   sync - scaling only the input's font-size breaks that cancellation and
   drags the switch out of alignment with the rest of the page. */
.form-switch-lg{
  display:flex;
  align-items:center;
  font-size:1.6rem;
}
.form-switch-lg .form-check-input{
  margin-top:0;
  cursor:pointer;
  box-shadow:none;
  flex-shrink:0;
}
.form-switch-lg .form-check-label{
  font-size:1.05rem;
  padding-left:0.5rem;
  margin-bottom:0;
  line-height:1;
  cursor:pointer;
}

.btn-primary{background:var(--brand);border-color:var(--brand);}
.btn-primary:hover,.btn-primary:focus,.btn-primary:active{
  background:var(--brand-dark)!important;border-color:var(--brand-dark)!important;
}
.btn-outline-danger{color:var(--brand);border-color:var(--brand);}

#gmailThreadPanelModal .modal-dialog{
  display:flex;
  align-items:stretch;
  transition:max-width 0.22s ease;
}
#gmailThreadPanelModal .modal-dialog.attachment-open{
  max-width:min(1200px, calc(100vw - 2rem));
}
#gmailThreadPanelModal .modal-content{
  min-width:0;
  flex:1 1 auto;
}
#gmailThreadPanelModal .modal-dialog.attachment-open .modal-content{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
#gmailThreadPanelModal .gmail-attachment-slide-panel{
  flex:0 0 0;
  width:0;
  overflow:hidden;
  display:flex;
  flex-direction:column;
  background:#fff;
  border-left:1px solid #dee2e6;
  transition:flex-basis 0.22s ease, width 0.22s ease;
  /* .modal-dialog sets pointer-events:none (Bootstrap only re-enables it on .modal-content) -
     this panel is a sibling of .modal-content, not a descendant, so it needs its own override. */
  pointer-events:auto;
}
#gmailThreadPanelModal .modal-dialog.attachment-open .gmail-attachment-slide-panel{
  flex-basis:400px;
  width:400px;
  border-top-right-radius:10px;
  border-bottom-right-radius:10px;
}

/* PO file manager slide-out panel (Create Order / PO Detail modals) - same
   sibling-of-.modal-content growth technique as .gmail-attachment-slide-panel above. */
.po-file-manager-host .modal-dialog{
  display:flex;
  align-items:stretch;
  transition:max-width 0.22s ease;
}
.po-file-manager-host .modal-dialog.file-manager-open{
  max-width:min(1300px, calc(100vw - 2rem));
}
.po-file-manager-host .modal-content{
  min-width:0;
  flex:1 1 auto;
}
.po-file-manager-host .modal-dialog.file-manager-open .modal-content{
  border-top-right-radius:0;
  border-bottom-right-radius:0;
}
.po-file-manager-panel{
  flex:0 0 0;
  width:0;
  overflow:hidden;
  position:relative;
  display:flex;
  flex-direction:column;
  background:#fff;
  border-left:1px solid #dee2e6;
  transition:flex-basis 0.22s ease, width 0.22s ease;
  /* Sibling of .modal-content, not a descendant - needs its own pointer-events override. */
  pointer-events:auto;
}
.po-file-manager-host .modal-dialog.file-manager-open .po-file-manager-panel{
  flex-basis:540px;
  width:540px;
  border-top-right-radius:10px;
  border-bottom-right-radius:10px;
}
.po-file-manager-panel-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:0.5rem;
  border-bottom:1px solid #dee2e6;
  padding:0.6rem 0.75rem;
  flex-shrink:0;
}
.po-file-manager-panel-header strong{font-size:0.9rem;}
/* Permanent preview pane - top ~2/3 of the panel's remaining height. */
.po-file-preview-pane{
  flex:2 1 0;
  min-height:0;
  display:flex;
  flex-direction:column;
  border-bottom:1px solid #dee2e6;
  background:linear-gradient(180deg, #fbfcfe 0%, #f5f8fb 100%);
}
.po-file-preview-pane-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:0.5rem;
  padding:0.5rem 0.75rem;
  flex-shrink:0;
  border-bottom:1px solid #e9ecef;
}
.po-file-preview-pane-title-wrap{
  display:flex;
  align-items:center;
  gap:0.5rem;
  min-width:0;
  flex:1 1 auto;
}
.po-file-preview-pane-header strong{
  font-size:0.8rem;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
  color:#6c757d;
}
.po-file-preview-pane-body{
  flex:1 1 auto;
  overflow:auto;
  padding:0.75rem;
  min-height:0;
  display:flex;
  flex-direction:column;
}
.po-file-preview-pane-body img{
  max-width:100%;
  max-height:100%;
  object-fit:contain;
  margin:auto;
}
.po-file-preview-pane-body iframe{
  flex:1 1 auto;
  width:100%;
  height:100%;
  border:0;
}
.po-file-preview-pane-body pre{
  flex:1 1 auto;
  margin:0;
  overflow:auto;
}
.po-file-preview-empty{
  font-size:0.8rem;
  color:#9aa5b1;
  text-align:center;
  margin:auto;
}
/* Category file list - bottom ~1/3 of the panel's remaining height. Vertical stack so each
   filename can stay on one line; panel is widened to give the list more horizontal room. */
.po-file-manager-panel-body{
  flex:1 1 0;
  min-height:0;
  overflow-y:auto;
  padding:0.75rem;
}
.po-file-manager-section{
  display:flex;
  flex-direction:column;
  min-width:0;
  margin-bottom:0.85rem;
  border-radius:8px;
  transition:background-color 0.12s ease, outline-color 0.12s ease;
}
.po-file-manager-section:last-child{margin-bottom:0;}
.po-file-manager-section.is-drop-target{
  outline:2px dashed #0d6efd;
  outline-offset:3px;
  background:#e9f2ff;
}
.po-file-manager-section-title{
  font-size:0.72rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.03em;
  color:#6c757d;
  margin-bottom:0.4rem;
}
.po-file-manager-empty{
  font-size:0.78rem;
  color:#9aa5b1;
}

.po-file-dropzone {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px dashed #bfd7f2;
  border-radius: 6px;
  padding: 0.25rem 0.5rem;
  font-size: 0.75rem;
  color: #5b6774;
  cursor: pointer;
  background: #f8fafd;
  transition: border-color 0.15s ease, background-color 0.15s ease, color 0.15s ease;
}
.po-file-dropzone:hover{border-color: #7fb0ea; color: #1f3a5a;}
.po-file-dropzone.is-dragover{border-color: #0d6efd; background: #e9f2ff; color: #1f3a5a;}
.po-file-dropzone.is-disabled{cursor: not-allowed; opacity: 0.6;}
.po-file-dropzone i{font-size: 0.9rem; flex: 0 0 auto;}
.po-file-dropzone--wide{
  display: flex;
  width: 100%;
  justify-content: center;
  padding: 0.15rem 0.4rem;
  margin-top: 0.3rem;
  font-size: 0.68rem;
  line-height: 1.4;
}
.po-file-dropzone--wide span{
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.po-file-list{
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 140px;
  overflow-y: auto;
  margin-bottom: 0.25rem;
}
.po-file-list:empty{margin-bottom: 0;}
.po-file-row{
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.3rem 0.55rem;
  border: 1px solid #e7ecf2;
  border-radius: 6px;
  background: #fff;
  font-size: 0.8rem;
}
.po-file-row[draggable="true"]{cursor: grab;}
.po-file-row.is-dragging{opacity: 0.5;}
.po-file-row .po-file-name{
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: #1f3a5a;
  text-decoration: none;
  cursor: pointer;
  background: transparent;
  border: 0;
  text-align: left;
  padding: 0;
}
.po-file-row .po-file-name:hover{text-decoration: underline;}
.po-file-row .po-file-meta{color: #9aa5b1; font-size: 0.74rem; white-space: nowrap;}
.po-file-delete-btn{
  border: 0;
  background: transparent;
  color: #9aa5b1;
  font-size: 0.85rem;
  line-height: 1;
  padding: 0.1rem 0.2rem;
  cursor: pointer;
}
.po-file-delete-btn:hover:not(:disabled){color: #dc3545;}
.po-file-delete-btn:disabled{cursor: not-allowed; opacity: 0.5;}

.btn-outline-danger:hover{background:var(--brand);border-color:var(--brand);color:#fff;}
.form-control:focus,.form-select:focus{
  border-color:var(--brand);
  box-shadow:0 0 0 0.15rem rgba(227,33,25,0.18);
}

/* Internal messages modal (static/internal_messages.js) */
.im-dialog{max-width:1080px;}
.im-modal{height:min(82vh, 760px); border:0; border-radius:1rem; overflow:hidden;}
.im-modal .modal-body{overflow:hidden; min-height:0; display:flex; flex-direction:column;}
.im-modal .tab-content{flex:1 1 auto;}
.im-modal .tab-content,
.im-modal .tab-pane{min-height:0;}
.im-modal-header{gap:0.75rem; padding:0.6rem 1rem; border-bottom:1px solid #edf0f3;}
.im-brand-icon{
  display:inline-flex; align-items:center; justify-content:center;
  width:30px; height:30px; border-radius:0.6rem;
  background:var(--brand); color:#fff; font-size:0.95rem;
}
.im-segmented{
  background:#f1f3f5;
  border-radius:999px;
  padding:3px;
  gap:2px;
  flex-wrap:nowrap;
}
.im-segmented .nav-link{
  border-radius:999px;
  color:#495057;
  font-size:0.86rem;
  font-weight:500;
  padding:0.3rem 0.9rem;
  white-space:nowrap;
}
.im-segmented .nav-link:hover{color:#1f2a37;}
.im-segmented .nav-link.active{
  background:#fff;
  color:#1f2a37;
  box-shadow:0 1px 3px rgba(31,42,55,0.15);
}
.im-segmented .badge{font-size:0.65rem; vertical-align:1px;}

.im-layout{
  display:grid;
  grid-template-columns:300px minmax(0,1fr);
  height:100%;
  min-height:0;
}
.im-sidebar{
  display:flex; flex-direction:column; min-height:0;
  border-right:1px solid #edf0f3;
  background:#fafbfc;
}
.im-search{position:relative; padding:0.75rem 0.75rem 0.4rem;}
.im-search > .bi{
  position:absolute; left:1.45rem; top:50%; transform:translateY(-35%);
  color:#adb5bd; pointer-events:none; font-size:0.85rem;
}
.im-search .form-control{
  border-radius:999px; padding-left:2.1rem; font-size:0.88rem;
  background:#fff; border-color:#e3e7eb;
}
.im-search .internal-picker-results{left:0.75rem; right:0.75rem; width:auto !important;}
.im-section-label{
  padding:0.4rem 1rem 0.25rem;
  font-size:0.7rem; font-weight:600; letter-spacing:0.04em; text-transform:uppercase;
  color:#8a94a0;
}
.im-list{flex:1 1 auto; overflow-y:auto; overflow-x:hidden; padding:0 0.4rem 0.6rem;}
.im-list-empty{padding:1rem; font-size:0.85rem; color:#8a94a0; text-align:center;}
.im-item{
  display:flex; align-items:center; gap:0.65rem;
  padding:0.55rem 0.6rem;
  border-radius:0.7rem;
  cursor:pointer;
  position:relative;
  transition:background 0.12s ease;
}
.im-item:hover{background:#f0f2f5;}
.im-item:focus-visible{outline:2px solid rgba(227,33,25,0.35); outline-offset:-2px;}
.im-item.active{background:rgba(227,33,25,0.08);}
.im-item-body{flex:1 1 auto; min-width:0;}
.im-item-top,
.im-item-bottom{display:flex; align-items:center; gap:0.4rem; min-width:0;}
.im-item-title{flex:1 1 auto; min-width:0; font-weight:600; font-size:0.9rem; color:#1f2a37; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.im-item-time{flex-shrink:0; font-size:0.7rem; color:#8a94a0;}
.im-item-sub{flex:1 1 auto; min-width:0; font-size:0.8rem; color:#6c757d; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.im-item-unread .im-item-sub{color:#1f2a37; font-weight:500;}
.im-item-unread .im-item-time{color:var(--brand); font-weight:600;}
.im-unread{
  flex-shrink:0; min-width:1.2rem; height:1.2rem; padding:0 0.35rem;
  border-radius:999px; background:var(--brand); color:#fff;
  font-size:0.68rem; font-weight:700; line-height:1.2rem; text-align:center;
}
.im-item .badge{flex-shrink:0; font-size:0.62rem;}
.im-item-hide{
  flex-shrink:0; border:0; background:transparent; color:#adb5bd;
  padding:0 0.15rem; line-height:1; font-size:1rem; opacity:0;
  transition:opacity 0.12s ease;
}
.im-item:hover .im-item-hide,
.im-item:focus-within .im-item-hide{opacity:1;}
.im-item-hide:hover{color:var(--brand);}

.im-avatar{
  flex-shrink:0;
  display:inline-flex; align-items:center; justify-content:center;
  width:40px; height:40px; border-radius:50%;
  color:#fff; font-size:0.82rem; font-weight:600; letter-spacing:0.02em;
  user-select:none;
}
.im-avatar-sm{width:28px; height:28px; font-size:0.66rem;}
.im-avatar-po{background:rgba(25,135,84,0.14); color:#198754; border-radius:0.7rem; font-size:1.05rem;}
.im-avatar-archived{background:#e9ecef; color:#6c757d; border-radius:0.7rem; font-size:1.05rem;}
.im-avatar-sm.im-avatar-po,
.im-avatar-sm.im-avatar-archived{border-radius:0.5rem; font-size:0.8rem;}
.im-avatar-spacer{flex-shrink:0; width:28px;}

.im-main{display:flex; flex-direction:column; min-width:0; min-height:0; background:#fff;}
.im-main-header{
  display:flex; align-items:center; gap:0.6rem;
  min-height:62px;
  padding:0.6rem 1rem;
  border-bottom:1px solid #edf0f3;
}
.im-main-header:has(.im-header-body:empty){display:none;}
.im-back{display:none; border-radius:50%;}
.im-header-body{display:flex; align-items:center; gap:0.65rem; flex:1 1 auto; min-width:0;}
.im-header-text{min-width:0;}
.im-header-title{font-weight:600; font-size:0.98rem; color:#1f2a37; white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.im-header-sub{
  display:flex; align-items:center; gap:0.45rem; min-width:0;
  font-size:0.78rem; color:#6c757d;
}
.im-header-sub > span:last-child{white-space:nowrap; overflow:hidden; text-overflow:ellipsis;}
.im-status{
  flex-shrink:0;
  background:#f1f3f5; border-radius:999px; padding:0.05rem 0.5rem;
  font-weight:500; color:#495057;
}

.im-thread{
  flex:1 1 auto; min-height:0;
  overflow-y:auto;
  padding:1rem 1.1rem 0.5rem;
  background:#f7f8fa;
}
.im-empty{
  height:100%;
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  text-align:center; color:#8a94a0; padding:2rem;
}
.im-empty > .bi{font-size:2.6rem; color:#ced4da; margin-bottom:0.5rem;}
.im-empty-title{font-weight:600; color:#495057; font-size:1rem;}
.im-empty-text{font-size:0.85rem; max-width:340px; margin-top:0.25rem;}
.im-day{display:flex; align-items:center; gap:0.75rem; margin:0.9rem 0 0.6rem; color:#8a94a0; font-size:0.72rem; font-weight:600;}
.im-day::before,
.im-day::after{content:''; flex:1; height:1px; background:#e3e7eb;}
.im-event{text-align:center; margin:0.5rem 0; font-size:0.75rem; color:#6c757d;}
.im-event span{display:inline-block; background:#eceff2; border-radius:999px; padding:0.15rem 0.7rem;}
.im-msg{display:flex; align-items:flex-end; gap:0.5rem; margin-top:0.6rem;}
.im-msg-grouped{margin-top:0.15rem;}
.im-msg-mine{justify-content:flex-end;}
.im-msg-body{display:flex; flex-direction:column; max-width:72%; min-width:0;}
.im-msg-mine .im-msg-body{align-items:flex-end;}
.im-sender{font-size:0.74rem; font-weight:600; color:#6c757d; margin:0 0 0.15rem 0.6rem;}
.im-bubble{
  background:#fff;
  color:#1f2a37;
  border-radius:1rem;
  padding:0.45rem 0.75rem;
  box-shadow:0 1px 2px rgba(31,42,55,0.08);
}
.im-msg:not(.im-msg-mine):not(.im-msg-grouped) .im-bubble{border-top-left-radius:0.35rem;}
.im-msg-mine .im-bubble{background:var(--brand); color:#fff; box-shadow:none;}
.im-msg-mine:not(.im-msg-grouped) .im-bubble{border-top-right-radius:0.35rem;}
.im-text{display:block; font-size:0.9rem; line-height:1.4; white-space:pre-wrap; overflow-wrap:anywhere;}
.im-time{display:block; text-align:right; margin-top:0.1rem; font-size:0.66rem; opacity:0.6; white-space:nowrap;}
.im-mention{
  background:rgba(13,110,253,0.12);
  color:#0a58ca;
  border-radius:0.3rem;
  padding:0 0.2rem;
  font-weight:600;
}
.im-mention-me{background:rgba(255,193,7,0.35); color:#664d03;}
.im-msg-mine .im-mention{background:rgba(255,255,255,0.22); color:#fff;}
.im-po-ref{
  border:0;
  background:rgba(25,135,84,0.12);
  color:#146c43;
  border-radius:0.3rem;
  padding:0 0.25rem;
  font-weight:600;
  font-size:inherit;
  line-height:inherit;
  cursor:pointer;
}
.im-po-ref:hover{text-decoration:underline;}
.im-po-ref-archived{background:rgba(108,117,125,0.15); color:#495057;}
.im-msg-mine .im-po-ref{background:rgba(255,255,255,0.22); color:#fff;}

.im-composer{position:relative; padding:0.6rem 1rem 0.5rem; border-top:1px solid #edf0f3; background:#fff;}
.im-composer-box{
  display:flex; align-items:flex-end; gap:0.4rem;
  background:#f1f3f5;
  border:1px solid transparent;
  border-radius:1.4rem;
  padding:0.3rem 0.3rem 0.3rem 0.9rem;
  transition:border-color 0.12s ease, background 0.12s ease;
}
.im-composer-box:focus-within{background:#fff; border-color:rgba(227,33,25,0.35); box-shadow:0 0 0 0.15rem rgba(227,33,25,0.1);}
.im-composer textarea{
  resize:none; min-height:36px; max-height:160px;
  border:0; background:transparent; box-shadow:none !important;
  padding:0.45rem 0; font-size:0.92rem;
}
.im-composer textarea:disabled{background:transparent; cursor:not-allowed;}
.im-send{
  flex-shrink:0; width:36px; height:36px; border-radius:50%;
  padding:0; display:inline-flex; align-items:center; justify-content:center;
}
.im-composer-hint{font-size:0.7rem; color:#8a94a0; padding:0.3rem 0.4rem 0;}
.im-composer-hint b{font-weight:600; color:#6c757d;}
.im-compose-notice{
  font-size:0.78rem; color:#664d03; background:#fff3cd;
  border-radius:0.5rem; padding:0.3rem 0.6rem; margin-bottom:0.4rem;
}
.im-readonly-bar{
  padding:0.6rem 1rem; border-top:1px solid #edf0f3;
  font-size:0.8rem; color:#6c757d; text-align:center; background:#fff;
}
.im-suggest{
  position:absolute;
  left:1rem;
  right:1rem;
  bottom:calc(100% - 0.2rem);
  z-index:1085;
  max-height:280px;
  overflow-y:auto;
  border-radius:0.75rem;
  box-shadow:0 10px 30px rgba(31,42,55,0.2);
}
.im-suggest-item{display:flex !important; align-items:center; gap:0.55rem; font-size:0.86rem; padding:0.4rem 0.7rem;}
.im-suggest-text{flex:1 1 auto; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap;}
.im-suggest-item.active{background:rgba(227,33,25,0.08); color:#1f2a37; border-color:transparent;}
.im-suggest-item.active .text-muted{color:#6c757d !important;}

.internal-picker-results{
  top:calc(100% + 2px);
  left:0;
  z-index:1080;
  max-height:280px;
  overflow-y:auto;
  background:#fff;
  border:1px solid #d9e1ea;
  border-radius:0.375rem;
  box-shadow:0 8px 24px rgba(31,42,55,0.14);
}

.internal-picker-results .list-group-item{
  border-left:none;
  border-right:none;
  font-size:0.9rem;
  line-height:1.28;
}

.internal-picker-results .list-group-item:first-child{
  border-top:none;
}

.internal-picker-results .list-group-item:last-child{
  border-bottom:none;
}

/* Platform-wide searchable <select> (static/searchable_select.js) */
.searchable-select-native{
  position:absolute;
  width:1px;
  height:1px;
  padding:0;
  margin:-1px;
  overflow:hidden;
  left:-9999px;
}

.searchable-select-menu{
  max-height:260px;
  overflow-y:auto;
}

.searchable-select-option.active{
  background-color:#e9ecef;
  color:#1f2a37;
}

@media (max-width:767px){
  .main-container{padding:0 10px}
  .im-modal{height:92vh; border-radius:0.75rem;}
  .im-modal-header .modal-title{display:none !important;}
  .im-segmented .nav-link{padding:0.3rem 0.6rem; font-size:0.8rem;}
  .im-layout{grid-template-columns:minmax(0,1fr);}
  .im-layout.im-has-thread .im-sidebar{display:none;}
  .im-layout:not(.im-has-thread) .im-main{display:none;}
  .im-sidebar{border-right:0;}
  .im-back{display:inline-flex;}
  .im-msg-body{max-width:85%;}
}

/* Small toggle column for orders table */
.toggle-col,
.po-row-actions-cell{
  width:84px;
  min-width:84px;
  max-width:84px;
  white-space:nowrap;
  padding-left:0.35rem !important;
  padding-right:0.35rem !important;
}

/* PO overview table uses proportional widths only, no fixed action-cell px widths. */
.po-hub-po.orders-table-wrapper > table.po-table .toggle-col,
.po-hub-po.orders-table-wrapper > table.po-table .po-row-actions-cell{
  width:auto;
  min-width:0;
  max-width:none;
}

.table-ux-toolbar .table-ux-search{min-width:180px}
.table-ux-th{vertical-align:middle}
.table-ux-head-wrap{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:0.35rem;
  min-height:1.1rem;
}
.table-ux-label{
  display:inline-block;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.table-ux-head-tools .table-ux-filter-btn{
  color:#7b8798;
  text-decoration:none;
  line-height:1;
}
.table-ux-head-tools .table-ux-filter-btn:hover,
.table-ux-head-tools .table-ux-filter-btn:focus{color:#2f3b52}
.table-ux-th.table-ux-sortable{cursor:pointer}
.table-ux-th.table-ux-sortable::after{
  content:'\2195';
  font-size:0.62rem;
  margin-left:0.28rem;
  color:#9aa4b4;
}
.table-ux-th.is-sorted-asc::after{content:'\2191';color:#314f80}
.table-ux-th.is-sorted-desc::after{content:'\2193';color:#314f80}
.table-ux-th.is-filtered .table-ux-filter-btn{color:#314f80}

.table-ux-density-compact td,
.table-ux-density-compact th{padding-top:0.36rem !important;padding-bottom:0.36rem !important}
.table-ux-density-comfortable td,
.table-ux-density-comfortable th{padding-top:0.6rem !important;padding-bottom:0.6rem !important}

/* text-truncate on td: no display override — table-cell handles layout;
   overflow/ellipsis still clip long content as expected. */
.po-hub-po.orders-table-wrapper > table.po-table td.text-truncate{
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
/* Collapse toggle: rotate chevron when the subitem panel is open */
.collapse-toggle .bi-chevron-down{
  display:inline-block;
  transition:transform 0.2s ease;
}
.collapse-toggle[aria-expanded="true"] .bi-chevron-down{
  transform:rotate(180deg);
}

/* Main PO table columns are resizable. */
.po-hub-po.orders-table-wrapper > table.po-table thead th .col-resizer{display:block}

/* Any table opting in with data-col-resize uses the same visible drag handle. */
table[data-col-resize="1"] thead th .col-resizer{display:block}

/* PO Hub-style visible column separators for opted-in resizable tables. */
.orders-table-wrapper table[data-col-resize="1"] th,
.orders-table-wrapper table[data-col-resize="1"] td{
  border-right:1px solid #e8ecf2;
}
.orders-table-wrapper table[data-col-resize="1"] th:last-child,
.orders-table-wrapper table[data-col-resize="1"] td:last-child{
  border-right:none;
}

/* PO Hub fixture dropdown tables: resizable; widened columns scroll horizontally inside .po-hub-fixture. */
.po-hub-fixture .fixture-table thead th .col-resizer{display:block}

.po-row-actions{
  display:inline-flex;
  align-items:center;
  justify-content:flex-start;
  flex-wrap:nowrap;
  gap:0.4rem;
  white-space:nowrap;
}

.po-row-actions .btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  line-height:1;
}

.po-row-actions .bi{
  font-size:0.95rem;
}

.po-hub-details-toggle{
  width:28px;
  height:28px;
  border:1px solid #d5dae0;
  border-radius:6px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  color:#495057;
  background:#fff;
  padding:0;
}

.po-hub-details-toggle:hover,
.po-hub-details-toggle:focus{
  background:#f5f7fa;
  border-color:#c8d0db;
  color:#374151;
}

.po-hub-details-toggle .bi{
  transition:transform 0.15s ease;
}

.po-hub-details-toggle[aria-expanded="true"] .bi{
  transform:rotate(90deg);
}

.collapse-toggle:not(.po-hub-details-toggle) i{transition:transform .18s ease}
.collapse-toggle:not(.po-hub-details-toggle)[aria-expanded="true"] i{transform:rotate(180deg)}

/* Invoiced Orders: compact row layout for cleaner fit. */
#invoiced-main-table thead th,
#invoiced-main-table tbody td{
  padding-top:0.26rem !important;
  padding-bottom:0.26rem !important;
  vertical-align:middle;
}

#invoiced-main-table .record-payment-btn,
#invoiced-main-table .uninvoice-btn,
#invoiced-main-table .edit-invoice-btn{
  padding:0.22rem 0.48rem;
  line-height:1.1;
}

#invoiced-main-table th.invoiced-actions-col,
#invoiced-main-table td.invoiced-actions-col{
  width:auto;
  min-width:340px;
}

#invoiced-main-table td.invoiced-actions-col{
  white-space:normal !important;
  overflow:visible;
}

#invoiced-main-table .invoiced-actions-wrap{
  display:flex;
  gap:0.25rem;
  justify-content:flex-start;
  flex-wrap:wrap;
  white-space:normal;
  overflow:visible;
}

#invoiced-main-table .invoiced-actions-wrap .btn{
  flex:0 0 auto;
}

.orders-card .orders-table-wrapper.invoiced-main-table-wrap{
  margin:0;
  max-width:100%;
  overflow-x:auto;
  overflow-y:visible;
}

.orders-card .orders-table-wrapper.invoiced-main-table-wrap > #invoiced-main-table{
  width:max-content;
  min-width:100%;
}

.orders-card .orders-table-wrapper.commissions-main-table-wrap{
  margin:0;
  max-width:100%;
  overflow-x:hidden;
  overflow-y:hidden;
}

.orders-card .orders-table-wrapper.commissions-main-table-wrap > .commissions-main-table{
  width:100%;
  min-width:100%;
  max-width:100%;
  table-layout:fixed;
}

.commissions-main-table td.commissions-actions-cell{
  white-space:normal !important;
  overflow:visible;
}

.commissions-main-table td.commissions-actions-cell > .d-flex{
  flex-wrap:wrap;
  overflow:visible;
}

.commissions-main-table td.commissions-actions-cell .btn,
#invoiced-main-table .invoiced-actions-wrap .btn{
  white-space:nowrap;
}

.orders-card .orders-table-wrapper.master-po-table-wrap{
  margin:0;
  max-width:100%;
  overflow-x:hidden;
  overflow-y:hidden;
}

.orders-card .orders-table-wrapper.master-po-table-wrap > #master-po-table{
  width:100%;
  min-width:100%;
  max-width:100%;
  table-layout:fixed;
}

#invoiced-main-table thead th{
  white-space:normal !important;
  overflow-wrap:anywhere;
  word-break:break-word;
  text-overflow:clip;
}

/* Match Invoiced and Commissions main headers to PO Hub header visual style. */
.orders-table-wrapper > table#invoiced-main-table,
.orders-table-wrapper > table.commissions-main-table{
  border-collapse:separate;
  border-spacing:0;
  width:100%;
  max-width:100%;
  table-layout:fixed;
}

.orders-table-wrapper > table#invoiced-main-table thead th,
.orders-table-wrapper > table.commissions-main-table thead th{
  white-space:normal;
  position:sticky;
  top:0;
  z-index:3;
  background:#eef1f6;
  border-top:1px solid #dde2ec;
  border-bottom:2px solid #cdd4e0;
  font-size:0.72rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:0.035em;
  line-height:1.1;
  color:#4a5568;
  overflow:visible;
  text-overflow:clip;
}

@media (max-width: 767px){
  .toggle-col,
  .po-row-actions-cell{
    width:76px;
    min-width:76px;
    max-width:76px;
  }
  .po-row-actions{gap:0.3rem}
}

.po-modal-fixture-table td .form-control,
.po-modal-fixture-table td .form-select{
  min-width:0;
}

.po-modal-fixture-table{
  table-layout:fixed;
  width:100%;
  max-width:100%;
}

#poDetailModal .table-responsive,
#createOrderModal .table-responsive{
  overflow-x:auto;
}

.po-modal-fixture-table thead th{
  position:relative;
}

.po-modal-fixture-code{
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

#poDetailModal .po-modal-fixture-table thead th,
#createOrderModal .po-modal-fixture-table thead th{
  font-size:0.66rem;
  line-height:1.15;
  letter-spacing:0.01em;
  font-weight:600;
  white-space:normal;
}

#poDetailModal .po-modal-fixture-table td,
#createOrderModal .po-modal-fixture-table td{
  padding:0.18rem 0.3rem;
}

#poDetailModal .po-modal-fixture-table td .form-control,
#poDetailModal .po-modal-fixture-table td .form-select,
#createOrderModal .po-modal-fixture-table td .form-control,
#createOrderModal .po-modal-fixture-table td .form-select{
  font-size:0.77rem;
  line-height:1.12;
  padding:0.18rem 0.35rem;
}

#poDetailModal .po-modal-fixture-table th:nth-child(1),
#poDetailModal .po-modal-fixture-table td:nth-child(1),
#createOrderModal .po-modal-fixture-table th:nth-child(1),
#createOrderModal .po-modal-fixture-table td:nth-child(1){
  width:21px;
  min-width:21px;
  max-width:21px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(2),
#poDetailModal .po-modal-fixture-table td:nth-child(2),
#createOrderModal .po-modal-fixture-table th:nth-child(2),
#createOrderModal .po-modal-fixture-table td:nth-child(2){
  width:35px;
  min-width:35px;
  max-width:35px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(3),
#poDetailModal .po-modal-fixture-table td:nth-child(3),
#createOrderModal .po-modal-fixture-table th:nth-child(3),
#createOrderModal .po-modal-fixture-table td:nth-child(3){
  width:65px;
  min-width:65px;
  max-width:65px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(4),
#poDetailModal .po-modal-fixture-table td:nth-child(4),
#createOrderModal .po-modal-fixture-table th:nth-child(4),
#createOrderModal .po-modal-fixture-table td:nth-child(4){
  width:44px;
  min-width:44px;
  max-width:44px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(5),
#poDetailModal .po-modal-fixture-table td:nth-child(5),
#createOrderModal .po-modal-fixture-table th:nth-child(5),
#createOrderModal .po-modal-fixture-table td:nth-child(5){
  width:48px;
  min-width:48px;
  max-width:48px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(6),
#poDetailModal .po-modal-fixture-table td:nth-child(6),
#createOrderModal .po-modal-fixture-table th:nth-child(6),
#createOrderModal .po-modal-fixture-table td:nth-child(6){
  width:258px;
  min-width:258px;
  max-width:258px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(7),
#poDetailModal .po-modal-fixture-table td:nth-child(7),
#createOrderModal .po-modal-fixture-table th:nth-child(7),
#createOrderModal .po-modal-fixture-table td:nth-child(7){
  width:94px;
  min-width:94px;
  max-width:94px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(8),
#poDetailModal .po-modal-fixture-table td:nth-child(8),
#createOrderModal .po-modal-fixture-table th:nth-child(8),
#createOrderModal .po-modal-fixture-table td:nth-child(8){
  width:72px;
  min-width:72px;
  max-width:72px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(9),
#poDetailModal .po-modal-fixture-table td:nth-child(9),
#createOrderModal .po-modal-fixture-table th:nth-child(9),
#createOrderModal .po-modal-fixture-table td:nth-child(9){
  width:54px;
  min-width:54px;
  max-width:54px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(10),
#poDetailModal .po-modal-fixture-table td:nth-child(10),
#createOrderModal .po-modal-fixture-table th:nth-child(10),
#createOrderModal .po-modal-fixture-table td:nth-child(10){
  width:80px;
  min-width:80px;
  max-width:80px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(11),
#poDetailModal .po-modal-fixture-table td:nth-child(11),
#createOrderModal .po-modal-fixture-table th:nth-child(11),
#createOrderModal .po-modal-fixture-table td:nth-child(11){
  width:70px;
  min-width:70px;
  max-width:70px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(12),
#poDetailModal .po-modal-fixture-table td:nth-child(12),
#createOrderModal .po-modal-fixture-table th:nth-child(12),
#createOrderModal .po-modal-fixture-table td:nth-child(12){
  width:74px;
  min-width:74px;
  max-width:74px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(13),
#poDetailModal .po-modal-fixture-table td:nth-child(13),
#createOrderModal .po-modal-fixture-table th:nth-child(13),
#createOrderModal .po-modal-fixture-table td:nth-child(13){
  width:41px;
  min-width:41px;
  max-width:41px;
}

#poDetailModal .po-modal-fixture-table th:nth-child(14),
#poDetailModal .po-modal-fixture-table td:nth-child(14),
#createOrderModal .po-modal-fixture-table th:nth-child(14),
#createOrderModal .po-modal-fixture-table td:nth-child(14){
  width:49px;
  min-width:49px;
  max-width:49px;
}

#poDetailModal .po-modal-fixture-table .po-modal-fixture-actions,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-actions{
  padding:0.04rem 0;
  white-space:normal;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
}

#poDetailModal .po-modal-fixture-table .po-modal-fixture-actions .btn,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-actions .btn{
  width:14px;
  min-width:14px;
  height:14px;
  min-height:14px;
  padding:0;
  border-radius:3px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  margin:0;
}

#poDetailModal .po-modal-fixture-table .po-modal-fixture-actions i,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-actions i{
  font-size:0.54rem;
}

#poDetailModal .po-modal-fixture-table .po-modal-fixture-notes,
#poDetailModal .po-modal-fixture-table .po-modal-fixture-delete,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-notes,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-delete{
  padding:0;
  font-size:0.54rem;
  line-height:1;
}

#poDetailModal .po-modal-fixture-table .po-modal-fixture-notes i,
#poDetailModal .po-modal-fixture-table .po-modal-fixture-delete i,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-notes i,
#createOrderModal .po-modal-fixture-table .po-modal-fixture-delete i{
  font-size:0.54rem;
}

.fixture-adder-chip{
  display:inline-flex;
  align-items:center;
  gap:0.35rem;
  margin:0.1rem 0.18rem 0.1rem 0;
  padding-right:0.35rem;
}

.fixture-adder-chip-label{
  line-height:1.1;
}

.fixture-adder-chip-actions{
  display:inline-flex;
  align-items:center;
  gap:0.16rem;
}

.fixture-adder-chip-btn{
  padding:0;
  width:1.05rem;
  min-width:1.05rem;
  height:1.05rem;
  min-height:1.05rem;
  line-height:1;
  font-size:0.68rem;
  border-radius:999px;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}


/* Production planning board */
.planning-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:1rem;
}

.planning-controls #planning-date{width:165px}
.planning-controls #planning-mode{width:160px}

.planning-section-title{
  font-size:0.85rem;
  text-transform:uppercase;
  letter-spacing:.04em;
  color:#6b7280;
  margin-bottom:.45rem;
  font-weight:600;
}

.planning-po-tiles-title{
  margin-bottom:.9rem;
}

.planning-workers-wrap,
.planning-board-wrap{
  background:#fff;
  border:1px solid #e6ebf2;
  border-radius:10px;
  padding:.8rem;
  box-shadow:var(--card-shadow);
}

.planning-workers{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
}

.planning-worker-chip{
  display:inline-flex;
  align-items:center;
  gap:.45rem;
  border:1px solid #d8dfeb;
  background:#f7f9fc;
  border-radius:999px;
  padding:.28rem .55rem;
  cursor:grab;
  user-select:none;
}

.planning-worker-text{
  display:flex;
  flex-direction:column;
  min-width:0;
}

.planning-worker-name{
  font-size:.88rem;
  color:#1f2937;
  line-height:1.2;
}

.planning-worker-assigned{
  font-size:.74rem;
  color:#5f6b7a;
  line-height:1.2;
  max-width:220px;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.planning-worker-chip.is-allocated{
  background:#eceff3;
  border-color:#cfd6e2;
  cursor:not-allowed;
  opacity:.85;
}

.planning-worker-chip.is-allocated .planning-avatar{
  background:#7f8ea6;
}

.planning-worker-chip.is-allocated .planning-worker-name,
.planning-worker-chip.is-allocated .planning-worker-assigned{
  color:#5b6576;
}

.planning-avatar{
  width:28px;
  height:28px;
  border-radius:50%;
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#1e5aa9;
  color:#fff;
  font-size:.72rem;
  font-weight:700;
}

.planning-avatar.small{
  width:24px;
  height:24px;
  font-size:.66rem;
}

.planning-board{
  display:grid;
  grid-template-columns:repeat(auto-fill, minmax(260px, 1fr));
  gap:.75rem;
}

.planning-departments-list{
  display:flex;
  flex-direction:column;
  gap:.75rem;
}

.planning-department-section{
  border:1px solid #d9e2ef;
  border-radius:10px;
  background:#fdfefe;
  overflow:hidden;
  width:100%;
}

.planning-department-summary{
  list-style:none;
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:.5rem;
  padding:.62rem .75rem;
  cursor:pointer;
  background:#f7faff;
  border-bottom:1px solid #e7eef8;
}

.planning-department-summary::-webkit-details-marker{display:none}

.planning-department-summary::after{
  content:'▾';
  color:#5f6b7a;
  font-size:.9rem;
  margin-left:.25rem;
  transition:transform .15s ease;
}

.planning-department-section:not([open]) .planning-department-summary::after{
  transform:rotate(-90deg);
}

.planning-department-counts{
  font-size:.76rem;
  color:#5f6b7a;
  white-space:nowrap;
}

.planning-department-body{
  padding:.7rem;
}

.planning-department-layout{
  display:grid;
  grid-template-columns:minmax(260px, 340px) 1fr;
  gap:1rem;
  align-items:start;
}

.planning-department-members-col{
  display:flex;
  flex-direction:column;
  align-items:flex-start;
}

.planning-department-focus-col{
  display:flex;
  flex-direction:column;
  align-items:center;
}

.planning-department-focus-col .planning-meta{
  text-align:center;
  width:100%;
}

.planning-department-focus-row{
  width:100%;
  justify-content:flex-start;
  align-content:flex-start;
  gap:.25rem;
  min-height:92px;
  border:1px dashed #cfd9e8;
  border-radius:10px;
  padding:.55rem;
  background:#fbfdff;
}

.planning-department-members-col .planning-assigned-row{
  width:100%;
}

.planning-department-members-col .dept-member-drop{
  display:flex;
  flex-direction:column;
  flex-wrap:nowrap;
  align-items:stretch;
  gap:.35rem;
}

.planning-department-members-col .dept-member-drop .assignment-chip{
  width:100%;
  max-width:100%;
  border-radius:10px;
  justify-content:flex-start;
}

.planning-department-members-col .dept-member-drop .assignment-name{
  flex:1 1 auto;
  min-width:0;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

@media (max-width: 992px){
  .planning-department-layout{
    grid-template-columns:1fr;
    gap:.7rem;
  }

  .planning-department-focus-col{
    align-items:stretch;
  }

  .planning-department-focus-col .planning-meta{
    text-align:left;
  }

  .planning-department-focus-row{
    justify-content:flex-start;
    min-height:64px;
  }
}

.planning-department-pool-tile{
  min-height:initial;
  width:100%;
  cursor:default;
}

.planning-tile{
  border:1px solid #d9e2ef;
  border-radius:10px;
  padding:.7rem;
  background:#fdfefe;
  min-height:180px;
  cursor:pointer;
  position:relative;
}

.planning-tile.drop-active{
  border-color:#0d6efd;
  background:#f2f7ff;
}

.planning-tile-header{
  display:flex;
  justify-content:space-between;
  gap:.5rem;
  margin-bottom:.35rem;
}

.planning-po{font-weight:700}
.planning-status{font-size:.82rem;color:#5f6b7a}
.planning-meta{font-size:.82rem;color:#444c58;line-height:1.35}

.planning-week-scheduler{
  border:1px solid #d9e2ef;
  border-radius:10px;
  background:#fbfdff;
  padding:.75rem;
}

.planning-month-calendar{
  border:1px solid #d9e2ef;
  border-radius:10px;
  background:#fbfdff;
  padding:.65rem;
}

.planning-month-grid-head,
.planning-month-grid-body{
  display:grid;
  grid-template-columns:repeat(7,minmax(0,1fr));
  gap:.45rem;
}

.planning-month-weekday{
  text-align:center;
  font-size:.82rem;
  color:#5f6b7a;
  font-weight:600;
  padding:.2rem 0;
}

.planning-month-day{
  border:1px solid #d6e0ef;
  border-radius:8px;
  background:#fff;
  min-height:128px;
  padding:.38rem;
  display:flex;
  flex-direction:column;
  gap:.3rem;
}

.planning-month-day.is-outside{
  opacity:.55;
  background:#f7f9fd;
}

.planning-month-day-head{
  display:flex;
  justify-content:flex-end;
}

.planning-month-day-link{
  font-size:.8rem;
  text-decoration:none;
}

.planning-month-day-drop{
  flex:1 1 auto;
  border:1px dashed #d0dcec;
  border-radius:7px;
  background:#f9fbff;
  padding:.3rem;
  display:flex;
  flex-direction:column;
  gap:.25rem;
}

.planning-month-day-drop.drop-active{
  border-color:#0d6efd;
  background:#eaf3ff;
}

.planning-month-po-chip{
  border:1px solid #d6e0ef;
  border-radius:6px;
  background:#fff;
  padding:.18rem .35rem;
  font-size:.78rem;
  position:relative;
}

.planning-chip-unlink{
  position:absolute;
  top:1px;
  right:2px;
  border:0;
  background:transparent;
  color:#9aa5b5;
  line-height:1;
  font-size:.9rem;
  padding:0 2px;
  cursor:pointer;
}

.planning-chip-unlink:hover{
  color:#b42318;
}

.planning-week-drop-assign{
  border:1px dashed #99b5de;
  border-radius:8px;
  background:#eef5ff;
  color:#355685;
  padding:.45rem .6rem;
  font-size:.84rem;
}

.planning-week-drop-assign.drop-active{
  border-color:#0d6efd;
  background:#e0edff;
}

.planning-scheduler-separator{
  border-top:2px solid #d7e2f0;
  margin:.9rem 0 .75rem;
}

.planning-week-unscheduled-row{
  min-height:48px;
  border:1px dashed #c8d6ea;
  border-radius:8px;
  background:#f3f8ff;
  padding:.5rem;
  display:flex;
  flex-wrap:wrap;
  gap:.45rem;
}

.planning-week-grid{
  display:grid;
  grid-template-columns:repeat(5,minmax(0,1fr));
  gap:.6rem;
}

.planning-week-day{
  border:1px solid #d6e0ef;
  border-radius:8px;
  background:#fff;
  padding:.45rem;
}

.planning-week-day-link{
  font-size:.82rem;
  text-decoration:none;
  margin-bottom:.4rem;
}

.planning-week-dropzone{
  min-height:86px;
  border:1px dashed #d0dcec;
  border-radius:7px;
  background:#f9fbff;
  padding:.4rem;
  display:flex;
  flex-direction:column;
  gap:.35rem;
}

.planning-week-dropzone.drop-active{
  border-color:#0d6efd;
  background:#eaf3ff;
}

.planning-week-po,
.planning-week-day-po{
  border:1px solid #d6e0ef;
  border-radius:7px;
  background:#fff;
  padding:.35rem .45rem;
  position:relative;
}

.planning-week-po{
  cursor:grab;
}

@media (max-width: 992px){
  .planning-month-grid-head,
  .planning-month-grid-body{
    grid-template-columns:repeat(2,minmax(0,1fr));
  }

  .planning-month-day{
    min-height:110px;
  }

  .planning-week-grid{
    grid-template-columns:1fr;
  }
}

.planning-po-inline-details{
  margin-top:.45rem;
  border:1px solid #d9e2ef;
  border-radius:8px;
  background:#f8fbff;
  padding:.45rem .55rem;
}

.planning-inline-fixture-list{
  display:flex;
  flex-direction:column;
  gap:.5rem;
  margin-top:.2rem;
}

.planning-inline-fixture-row{
  border:1px solid #dde5f1;
  border-radius:8px;
  background:#fff;
  padding:.45rem;
}

.planning-inline-fixture-select{
  min-width:180px;
}

.planning-inline-fixture-drop{
  border:1px dashed #b9c9df;
  border-radius:8px;
  background:#f7fbff;
  color:#3c4d66;
  font-size:.82rem;
  padding:.25rem .5rem;
  min-height:26px;
  display:flex;
  align-items:center;
}

.planning-inline-fixture-drop.drop-active{
  border-color:#0d6efd;
  background:#eaf3ff;
}

.planning-inline-fixture-drop.is-disabled{
  opacity:.7;
}

.planning-tile.has-allocation-badges{
  padding-top:1.35rem;
}

.planning-po-allocation-badges{
  position:absolute;
  top:-13px;
  left:10px;
  display:flex;
  flex-wrap:wrap;
  gap:.28rem;
  max-width:calc(100% - 20px);
  pointer-events:none;
}

.planning-po-badge{
  display:inline-flex;
  align-items:center;
  max-width:100%;
  border-radius:999px;
  padding:.13rem .5rem;
  font-size:.72rem;
  line-height:1.15;
  font-weight:600;
  border:1px solid transparent;
  background:#f0f4fa;
  color:#2f4258;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}

.planning-po-badge-dept{
  border-color:#95b8ea;
  background:#eaf3ff;
  color:#274a79;
}

.planning-po-badge-lead{
  border-color:#d6af48;
  background:#fff6db;
  color:#6f5100;
}

.planning-assigned-title{
  margin-top:.5rem;
  margin-bottom:.35rem;
  font-size:.78rem;
  color:#6b7280;
  font-weight:600;
}

.planning-assigned-row{
  display:flex;
  flex-wrap:wrap;
  gap:.4rem;
  min-height:38px;
}

.assignment-chip{
  display:inline-flex;
  align-items:center;
  gap:.35rem;
  border:1px solid #d8dfeb;
  border-radius:999px;
  background:#fff;
  padding:.2rem .35rem;
  cursor:grab;
}

.team-worker-checklist{
  max-height:180px;
  overflow-y:auto;
  border:1px solid #d8dfeb;
  border-radius:6px;
  padding:.3rem .4rem;
  background:#fff;
}

.team-worker-check-row{
  /* Keep Bootstrap's .form-check left gutter or the scroll box clips the checkbox. */
  padding:.15rem .3rem .15rem 1.9em;
  border-radius:4px;
}

.team-worker-check-row.is-selected{
  background:#e7f1ff;
}

[data-bs-theme="dark"] .team-worker-check-row.is-selected{background:rgba(56,132,255,.28);}

[data-bs-theme="dark"] .team-worker-checklist{background:var(--dm-surface-2);border-color:var(--dm-border);}

/* Shared Week/Day planning PO field editor (static/planning_po_fields.js) */
.planning-po-fields{margin-top:.35rem;padding-top:.35rem;border-top:1px dashed #dde4ee;}
.planning-pf-grid{display:grid;grid-template-columns:repeat(auto-fit,minmax(130px,1fr));gap:4px 6px;}
.planning-pf-field{display:flex;flex-direction:column;gap:1px;margin:0;min-width:0;}
.planning-pf-field > span{font-size:.62rem;font-weight:700;color:#8a94a6;text-transform:uppercase;letter-spacing:.04em;}
.planning-pf-field .form-control,.planning-pf-field .form-select{font-size:.74rem;padding-top:.1rem;padding-bottom:.1rem;min-height:0;}
.planning-pf-checkpoints{display:flex;flex-wrap:wrap;align-items:center;gap:3px;margin-top:5px;}
.planning-pf-readiness{display:inline-flex;align-items:center;gap:3px;font-size:.68rem;font-weight:700;border-radius:999px;padding:1px 7px;color:#7c2d12;background:#ffedd5;border:1px solid #fdba74;}
.planning-pf-readiness.is-ready{color:#14532d;background:#dcfce7;border-color:#86efac;}
.planning-pf-checkpoint{display:inline-flex;align-items:center;gap:3px;border-radius:999px;padding:1px 6px;font-size:.68rem;border:1px solid #cfd8e5;background:#fff;color:#475569;line-height:1.3;}
.planning-pf-checkpoint.is-complete{background:#e8f5ee;border-color:#9fd0b5;color:#1f6b42;}
.planning-pf-checkpoint:disabled{opacity:.72;}
[data-bs-theme="dark"] .planning-po-fields{border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-pf-checkpoint{background:var(--dm-surface-2);border-color:var(--dm-border);color:inherit;}

/* Floating "move to week" drop target shown while dragging a scheduled PO (Week + Day planning) */
.planning-drop-bar{position:fixed;top:12px;left:50%;transform:translateX(-50%);z-index:1085;display:none;align-items:center;gap:8px;min-width:340px;justify-content:center;padding:12px 20px;border:2px dashed #1e5aa9;border-radius:10px;background:#eef4fc;color:#1e5aa9;font-weight:700;font-size:.9rem;box-shadow:0 8px 24px rgba(16,24,40,.18);}
.planning-drop-bar.is-visible{display:flex;}
.planning-drop-bar.drop-active{background:#1e5aa9;color:#fff;}

.dept-focus-chip{
  cursor:pointer;
}

.dept-focus-chip.is-active{
  border-color:#7ea8df;
  background:#edf5ff;
}

.planning-focus-item{
  flex:0 0 auto;
  min-width:0;
  max-width:none;
  width:auto;
}

.planning-focus-details{
  margin-top:.35rem;
  border:1px solid #d9e2ef;
  border-radius:8px;
  background:#f8fbff;
  padding:.45rem .55rem;
  width:100%;
  box-shadow:0 4px 14px rgba(19, 33, 68, .08);
}

@media (max-width: 768px){
  .planning-focus-details{
    width:100%;
  }
}

.assignment-chip.is-team-lead{
  border-color:#d8a200;
  background:linear-gradient(120deg, #fff4c4 0%, #ffe08a 100%);
  box-shadow:0 1px 0 rgba(0, 0, 0, .06);
}

.assignment-chip.is-team-lead .assignment-name{
  font-weight:700;
}

.assignment-name{font-size:.82rem;color:#2f3540}

.assignment-remove{
  border:none;
  background:transparent;
  color:#b02a37;
  font-size:1rem;
  line-height:1;
  padding:0 .15rem;
}

.workstep-card{
  border:1px solid #dce3ef;
  border-radius:8px;
  padding:.6rem;
  margin-bottom:.6rem;
  background:#fafcff;
}

.workstep-card-head{
  display:flex;
  align-items:center;
  gap:.5rem;
  margin-bottom:.5rem;
}

.workstep-order-badge{
  flex:0 0 auto;
  width:24px;
  height:24px;
  border-radius:50%;
  background:#1e5aa9;
  color:#fff;
  font-size:.74rem;
  font-weight:700;
  display:inline-flex;
  align-items:center;
  justify-content:center;
}

.workstep-card-actions{
  display:flex;
  gap:.4rem;
  margin-bottom:.55rem;
}

.workstep-assign-block{
  border-top:1px dashed #d7dfec;
  margin-top:.5rem;
  padding-top:.5rem;
}

.workstep-assign-label{
  display:block;
  font-size:.72rem;
  font-weight:700;
  text-transform:uppercase;
  letter-spacing:.03em;
  color:#6b7280;
  margin-bottom:.3rem;
}

.workfixture-steps-heading{
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:.82rem;
  font-weight:700;
  color:#374151;
  margin:.5rem 0 .35rem;
}

.workfixture-collapsible-summary{
  list-style:none;
  cursor:pointer;
  font-size:.8rem;
  font-weight:600;
  color:#1e5aa9;
  padding:.3rem 0;
}

.workfixture-collapsible-summary::-webkit-details-marker{display:none}

.workfixture-collapsible-summary::before{
  content:'▸';
  display:inline-block;
  margin-right:.35rem;
  transition:transform .15s ease;
}

details[open] > .workfixture-collapsible-summary::before{
  transform:rotate(90deg);
}

.workfixture-section{
  border:1px solid #dce3ef;
  border-radius:10px;
  background:#ffffff;
  padding:.7rem;
  margin-bottom:.8rem;
}

.workfixture-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:.45rem;
}

.workfixture-title{
  font-weight:700;
  color:#1f2937;
}

.workfixture-subtitle{
  font-size:.8rem;
  color:#5f6b7a;
}

.fixture-worker-select{
  min-height:30px;
}

.workstep-assignee-strip{
  display:flex;
  flex-wrap:wrap;
  gap:.35rem;
}

.workstep-assignee-tile{
  display:inline-flex;
  align-items:center;
  gap:.35rem;
  border:1px solid #cdd7e6;
  background:#eef4ff;
  border-radius:999px;
  padding:.18rem .38rem;
  font-size:.82rem;
  color:#1f2b3a;
}

.workstep-assignee-remove{
  border:none;
  background:transparent;
  color:#b02a37;
  font-size:1rem;
  line-height:1;
  padding:0 .1rem;
}

.workstep-images-wrap{
  border-top:1px dashed #d7dfec;
  margin-top:.35rem;
  padding-top:.45rem;
}

.workstep-images-grid{
  display:flex;
  flex-wrap:wrap;
  gap:.45rem;
}

.workstep-image-tile{
  width:88px;
  height:88px;
  border:1px solid #d4dcea;
  border-radius:8px;
  position:relative;
  overflow:hidden;
  background:#f8fafc;
}

.workstep-image-tile img{
  width:100%;
  height:100%;
  object-fit:cover;
}

.workstep-image-remove{
  position:absolute;
  top:3px;
  right:3px;
  border:none;
  border-radius:50%;
  width:22px;
  height:22px;
  line-height:1;
  background:rgba(176, 42, 55, .88);
  color:#fff;
}

.workstep-image-upload-row{
  display:flex;
  gap:.45rem;
}

.workstep-image-upload-row .workstep-image-input{
  flex:1;
}

.workfixture-template-note{
  border-left:3px solid #9ab2d5;
  padding-left:.45rem;
}

.planning-debug-wrap{
  background:#fff;
  border:1px dashed #cfd7e6;
  border-radius:8px;
  padding:.5rem .7rem;
}

.planning-debug-log{
  background:#0f172a;
  color:#d1e4ff;
  border-radius:6px;
  padding:.55rem;
  max-height:180px;
  overflow:auto;
  font-size:.75rem;
  margin:0;
}

/* =====================================================================
   Dark mode (per-user toggle, User.dark_mode_enabled -> <html data-bs-theme>)
   Additive-only overrides layered on top of every hardcoded light-theme
   rule above. Bootstrap's own components already re-theme automatically
   via data-bs-theme; only this app's custom hex colors need overriding.
   ===================================================================== */
:root[data-bs-theme="dark"]{
  /* Tells the browser to render native controls (select option lists,
     scrollbars, date pickers) dark - Bootstrap's own CSS can't reach
     into browser-native popup UI, only this can. */
  color-scheme:dark;
  --brand-light:#241a16;
  --muted:#93a0b0;
  --panel:#1c222b;
  --card-shadow:0 1px 8px rgba(0,0,0,0.35);
  --dm-bg:#161b22;
  --dm-surface:#1c222b;
  --dm-surface-2:#232a34;
  --dm-hover:#29313c;
  --dm-border:#323a46;
  --dm-border-soft:#3d4753;
  --dm-text:#ccd3db;
  --dm-text-muted:#8b96a5;
  --dm-accent-tint:rgba(88,140,196,0.14);
  --dm-accent-border:#4d7aa8;
  --dm-accent-text:#9fb9d4;
  --dm-warn-tint:rgba(191,157,94,0.16);
  --dm-warn-border:#8f7a4d;
  --dm-warn-text:#cdb98a;
  --dm-danger:#d97b83;
}

[data-bs-theme="dark"] body{background:var(--dm-bg);color:var(--dm-text);}

/* Bootstrap's static bg-* / text-dark utilities are NOT theme-aware (only the
   "-subtle" variants re-theme automatically) - used all over the app
   (layout.html chat panels, production day detail, parts, invoiced, etc.)
   so override them globally instead of chasing every page individually. */
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .bg-white{
  background-color:var(--dm-surface-2) !important;
  color:var(--dm-text) !important;
}
[data-bs-theme="dark"] .text-bg-light{
  background-color:var(--dm-surface-2) !important;
  color:var(--dm-text-muted) !important;
}
[data-bs-theme="dark"] .text-dark{color:var(--dm-text) !important;}

/* Bootstrap's "dark" button variant is a fixed near-black semantic color,
   not a dark-mode-aware one - btn-outline-dark/btn-dark text+border stayed
   near-black even against the app's dark background (e.g. Open PO Hub's
   "Import POs from Excel" button, Force unlock buttons, Master PO quick
   tools toggle), making them nearly invisible. Remap to the neutral surface
   palette so they read like a normal secondary button in dark mode. */
[data-bs-theme="dark"] .btn-outline-dark{
  color:var(--dm-text);
  border-color:var(--dm-border-soft);
}
[data-bs-theme="dark"] .btn-outline-dark:hover,
[data-bs-theme="dark"] .btn-outline-dark:focus{
  background-color:var(--dm-hover);
  border-color:var(--dm-border-soft);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .btn-dark{
  background-color:var(--dm-surface-2);
  border-color:var(--dm-border-soft);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .btn-dark:hover,
[data-bs-theme="dark"] .btn-dark:focus{
  background-color:var(--dm-hover);
  border-color:var(--dm-border-soft);
  color:var(--dm-text);
}

[data-bs-theme="dark"] .form-check-input{
  background-color:var(--dm-surface-2);
  border-color:var(--dm-border-soft);
}

[data-bs-theme="dark"] .orders-card{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  color:var(--dm-text);
}

/* Batch invoicer: redefine the page palette vars; consumers read them via var() */
[data-bs-theme="dark"] #batch-invoicer-page{
  --binv-age-1_30:#c9a24a;--binv-age-1_30-bg:rgba(201,162,74,0.16);--binv-age-1_30-fg:#dcc286;
  --binv-age-31_60:#c98a4a;--binv-age-31_60-bg:rgba(201,138,74,0.16);--binv-age-31_60-fg:#dfb084;
  --binv-age-61_90:#c9693f;--binv-age-61_90-bg:rgba(201,105,63,0.18);--binv-age-61_90-fg:#e39a7a;
  --binv-age-90_plus:#b84a4f;--binv-age-90_plus-bg:rgba(217,123,131,0.18);--binv-age-90_plus-fg:var(--dm-danger);
  --binv-line:var(--dm-border);--binv-soft:var(--dm-surface-2);--binv-muted:var(--dm-text-muted);
  --binv-recent-bg:var(--dm-warn-tint);--binv-recent-fg:var(--dm-warn-text);
}
[data-bs-theme="dark"] #batch-invoicer-page .binv-kpi,
[data-bs-theme="dark"] #batch-invoicer-page .binv-selection-bar,
[data-bs-theme="dark"] #batch-invoicer-page .binv-detail-row > td{background:var(--dm-surface);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-kpi-total{border-left-color:var(--dm-accent-border);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-kpi-value,
[data-bs-theme="dark"] #batch-invoicer-page .binv-pill strong,
[data-bs-theme="dark"] #batch-invoicer-page th.binv-sortable.is-sorted{color:var(--dm-text);}
[data-bs-theme="dark"] #batch-invoicer-page button.binv-kpi:not(:disabled):hover{box-shadow:0 2px 10px rgba(0,0,0,0.45);}
[data-bs-theme="dark"] #batch-invoicer-page button.binv-kpi.is-active{box-shadow:0 0 0 2px var(--dm-accent-border);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-active-filter{background:var(--dm-accent-tint);color:var(--dm-accent-text);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-customer-row:hover > td{background:var(--dm-hover);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-customer-row.is-selected > td{background:var(--dm-accent-tint);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-customer-row.is-no-email > td{background:rgba(217,123,131,0.06);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-toggle:hover{color:var(--dm-text);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-detail-wrap{border-left-color:var(--dm-accent-border);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-selection-bar{box-shadow:0 -4px 12px rgba(0,0,0,0.35);}
[data-bs-theme="dark"] #batch-invoicer-page .binv-selection-bar.has-selection{border-top-color:var(--dm-accent-border);}

/* PO Hub: PO table */
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table{border-color:var(--dm-border);}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table thead th{
  background:var(--dm-surface-2);
  border-top-color:var(--dm-border);
  border-bottom-color:var(--dm-border);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table th,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td{border-right-color:var(--dm-border);}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table tbody td{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table tbody tr{background:var(--dm-surface);}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table tbody tr:not(.po-fixture-row):hover{
  background:var(--dm-hover) !important;
}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > .po-control,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > input.po-control,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > input[type="date"].po-control,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > select.po-control{
  border-bottom-color:rgba(255,255,255,0.16) !important;
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > .po-control:focus,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > input.po-control:focus,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > input[type="date"].po-control:focus,
[data-bs-theme="dark"] .po-hub-po.orders-table-wrapper > table.po-table td > select.po-control:focus{
  background:var(--dm-accent-tint) !important;
}

/* PO Hub: fixture table */
[data-bs-theme="dark"] .po-hub-fixture{background:var(--dm-surface-2);color:var(--dm-text);border-color:var(--dm-border);}
[data-bs-theme="dark"] .po-hub-fixture .fixture-title{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-hub-fixture .fixture-table{background:var(--dm-surface);color:var(--dm-text);}
[data-bs-theme="dark"] .po-hub-fixture .fixture-table thead th{
  background:var(--dm-surface-2);
  border-top-color:var(--dm-border);
  border-bottom-color:var(--dm-border);
  border-right-color:var(--dm-border);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .po-hub-fixture .fixture-table tbody td{
  border-bottom-color:var(--dm-border);
  border-right-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-hub-fixture .fixture-table tbody tr:nth-child(odd),
[data-bs-theme="dark"] .po-hub-fixture .fixture-table tbody tr:nth-child(even){background:var(--dm-surface);}
[data-bs-theme="dark"] .po-hub-fixture .fixture-table tbody tr:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .po-hub-fixture .fixture-control,
[data-bs-theme="dark"] .po-hub-fixture .fixture-control.form-control,
[data-bs-theme="dark"] .po-hub-fixture .fixture-control.form-control-sm{
  border-bottom-color:rgba(255,255,255,0.2) !important;
  color:var(--dm-text) !important;
}
[data-bs-theme="dark"] .po-hub-fixture .fixture-control:focus,
[data-bs-theme="dark"] .po-hub-fixture .fixture-control.form-control:focus,
[data-bs-theme="dark"] .po-hub-fixture .fixture-control.form-control-sm:focus{
  border-bottom-color:var(--dm-accent-border) !important;
  background:var(--dm-accent-tint) !important;
}

[data-bs-theme="dark"] .modal .form-label{color:var(--dm-text);}

[data-bs-theme="dark"] #gmailThreadPanelModal .gmail-attachment-slide-panel{
  background:var(--dm-surface);
  border-left-color:var(--dm-border);
}

/* Matches .po-modal-section (--dm-surface) / .po-modal-topbar (--dm-surface-2 sunken areas)
   already used elsewhere in these same modals, so the panel reads as part of the same modal. */
[data-bs-theme="dark"] .po-file-manager-panel{
  background:var(--dm-surface);
  border-left-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-file-manager-panel-header{
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-file-preview-pane{
  background:var(--dm-surface-2);
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-file-preview-pane-header{
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-file-preview-pane-header strong,
[data-bs-theme="dark"] .po-file-preview-empty{
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .po-file-preview-pane-body{
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-file-manager-section-title,
[data-bs-theme="dark"] .po-file-manager-empty{
  color:var(--dm-text-muted);
}

/* Internal messages / searchable-select pickers */
[data-bs-theme="dark"] .internal-picker-results{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  box-shadow:0 8px 24px rgba(0,0,0,0.45);
}
[data-bs-theme="dark"] .internal-picker-results .list-group-item:hover,
[data-bs-theme="dark"] .internal-picker-results .list-group-item:focus{
  background:var(--dm-hover);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .im-modal-header,
[data-bs-theme="dark"] .im-main-header,
[data-bs-theme="dark"] .im-composer,
[data-bs-theme="dark"] .im-readonly-bar{border-color:var(--dm-border);}
[data-bs-theme="dark"] .im-main,
[data-bs-theme="dark"] .im-composer,
[data-bs-theme="dark"] .im-readonly-bar{background:var(--dm-surface);}
[data-bs-theme="dark"] .im-sidebar{background:var(--dm-surface); border-color:var(--dm-border);}
[data-bs-theme="dark"] .im-thread{background:var(--dm-bg, #1a1d21);}
[data-bs-theme="dark"] .im-segmented{background:var(--dm-hover);}
[data-bs-theme="dark"] .im-segmented .nav-link{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .im-segmented .nav-link.active{background:var(--dm-surface); color:var(--dm-text);}
[data-bs-theme="dark"] .im-search .form-control{background:var(--dm-hover); border-color:var(--dm-border); color:var(--dm-text);}
[data-bs-theme="dark"] .im-item:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .im-item.active{background:rgba(227,33,25,0.18);}
[data-bs-theme="dark"] .im-item-title,
[data-bs-theme="dark"] .im-header-title,
[data-bs-theme="dark"] .im-empty-title,
[data-bs-theme="dark"] .im-item-unread .im-item-sub{color:var(--dm-text);}
[data-bs-theme="dark"] .im-item-sub,
[data-bs-theme="dark"] .im-item-time,
[data-bs-theme="dark"] .im-header-sub,
[data-bs-theme="dark"] .im-section-label,
[data-bs-theme="dark"] .im-sender,
[data-bs-theme="dark"] .im-event,
[data-bs-theme="dark"] .im-day,
[data-bs-theme="dark"] .im-empty,
[data-bs-theme="dark"] .im-composer-hint,
[data-bs-theme="dark"] .im-composer-hint b,
[data-bs-theme="dark"] .im-readonly-bar{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .im-day::before,
[data-bs-theme="dark"] .im-day::after{background:var(--dm-border);}
[data-bs-theme="dark"] .im-status,
[data-bs-theme="dark"] .im-event span{background:var(--dm-hover); color:var(--dm-text-muted);}
[data-bs-theme="dark"] .im-bubble{background:var(--dm-hover); color:var(--dm-text); box-shadow:none;}
[data-bs-theme="dark"] .im-msg-mine .im-bubble{background:var(--brand); color:#fff;}
[data-bs-theme="dark"] .im-composer-box{background:var(--dm-hover);}
[data-bs-theme="dark"] .im-composer-box:focus-within{background:var(--dm-surface);}
[data-bs-theme="dark"] .im-composer textarea{color:var(--dm-text);}
[data-bs-theme="dark"] .im-avatar-archived{background:var(--dm-hover); color:var(--dm-text-muted);}
[data-bs-theme="dark"] .im-empty > .bi{color:var(--dm-border);}
[data-bs-theme="dark"] .im-mention{background:rgba(110,168,254,0.2); color:#9ec5fe;}
[data-bs-theme="dark"] .im-mention-me{background:rgba(255,193,7,0.3); color:#ffda6a;}
[data-bs-theme="dark"] .im-po-ref{background:rgba(117,183,152,0.2); color:#75b798;}
[data-bs-theme="dark"] .im-po-ref-archived{background:rgba(173,181,189,0.2); color:var(--dm-text-muted);}
[data-bs-theme="dark"] .im-suggest-item.active{background:var(--dm-hover); color:var(--dm-text);}
[data-bs-theme="dark"] .im-suggest{box-shadow:0 8px 24px rgba(0,0,0,0.45);}
[data-bs-theme="dark"] .searchable-select-option.active{
  background-color:var(--dm-hover);
  color:var(--dm-text);
}

/* table-ux toolbar / sort indicators */
[data-bs-theme="dark"] .table-ux-head-tools .table-ux-filter-btn{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .table-ux-head-tools .table-ux-filter-btn:hover,
[data-bs-theme="dark"] .table-ux-head-tools .table-ux-filter-btn:focus{color:var(--dm-text);}
[data-bs-theme="dark"] .table-ux-th.table-ux-sortable::after{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .table-ux-th.is-sorted-asc::after,
[data-bs-theme="dark"] .table-ux-th.is-sorted-desc::after,
[data-bs-theme="dark"] .table-ux-th.is-filtered .table-ux-filter-btn{color:var(--dm-accent-border);}

[data-bs-theme="dark"] .po-hub-details-toggle{
  border-color:var(--dm-border);
  color:var(--dm-text-muted);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] .po-hub-details-toggle:hover,
[data-bs-theme="dark"] .po-hub-details-toggle:focus{
  background:var(--dm-hover);
  border-color:var(--dm-border-soft);
  color:var(--dm-text);
}

/* Invoiced / Commissions / Master PO main tables */
[data-bs-theme="dark"] .orders-table-wrapper > table#invoiced-main-table thead th,
[data-bs-theme="dark"] .orders-table-wrapper > table.commissions-main-table thead th{
  background:var(--dm-surface-2);
  border-top-color:var(--dm-border);
  border-bottom-color:var(--dm-border-soft);
  color:var(--dm-text-muted);
}

/* Production planning board */
[data-bs-theme="dark"] .planning-section-title,
[data-bs-theme="dark"] .planning-worker-assigned,
[data-bs-theme="dark"] .planning-department-counts,
[data-bs-theme="dark"] .planning-department-summary::after,
[data-bs-theme="dark"] .planning-month-weekday,
[data-bs-theme="dark"] .planning-status,
[data-bs-theme="dark"] .workfixture-subtitle,
[data-bs-theme="dark"] .planning-assigned-title{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-meta{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-worker-name,
[data-bs-theme="dark"] .workfixture-title,
[data-bs-theme="dark"] .assignment-name,
[data-bs-theme="dark"] .workstep-worker-item{color:var(--dm-text);}

[data-bs-theme="dark"] .planning-workers-wrap,
[data-bs-theme="dark"] .planning-board-wrap,
[data-bs-theme="dark"] .planning-department-section,
[data-bs-theme="dark"] .planning-tile,
[data-bs-theme="dark"] .planning-week-scheduler,
[data-bs-theme="dark"] .planning-month-calendar,
[data-bs-theme="dark"] .planning-month-day,
[data-bs-theme="dark"] .planning-week-day,
[data-bs-theme="dark"] .planning-week-po,
[data-bs-theme="dark"] .planning-week-day-po,
[data-bs-theme="dark"] .planning-po-inline-details,
[data-bs-theme="dark"] .planning-inline-fixture-row,
[data-bs-theme="dark"] .planning-focus-details,
[data-bs-theme="dark"] .workstep-card,
[data-bs-theme="dark"] .workfixture-section,
[data-bs-theme="dark"] .planning-debug-wrap{
  background:var(--dm-surface);
  border-color:var(--dm-border);
}

[data-bs-theme="dark"] .planning-worker-chip{background:var(--dm-surface-2);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-worker-chip.is-allocated{background:var(--dm-hover);border-color:var(--dm-border-soft);}
[data-bs-theme="dark"] .planning-worker-chip.is-allocated .planning-worker-name,
[data-bs-theme="dark"] .planning-worker-chip.is-allocated .planning-worker-assigned{color:var(--dm-text-muted);}

[data-bs-theme="dark"] .planning-department-summary{background:var(--dm-surface-2);border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-department-focus-row,
[data-bs-theme="dark"] .planning-month-day-drop,
[data-bs-theme="dark"] .planning-inline-fixture-drop,
[data-bs-theme="dark"] .planning-week-unscheduled-row,
[data-bs-theme="dark"] .planning-week-dropzone{background:var(--dm-surface-2);border-color:var(--dm-border-soft);}
[data-bs-theme="dark"] .planning-inline-fixture-drop{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-month-day.is-outside{background:var(--dm-bg);}
[data-bs-theme="dark"] .planning-scheduler-separator{border-top-color:var(--dm-border);}

[data-bs-theme="dark"] .planning-tile.drop-active,
[data-bs-theme="dark"] .planning-month-day-drop.drop-active,
[data-bs-theme="dark"] .planning-inline-fixture-drop.drop-active,
[data-bs-theme="dark"] .planning-week-drop-assign.drop-active,
[data-bs-theme="dark"] .planning-week-dropzone.drop-active,
[data-bs-theme="dark"] .dept-focus-chip.is-active{
  border-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
}

[data-bs-theme="dark"] .planning-week-drop-assign{
  background:var(--dm-accent-tint);
  border-color:var(--dm-accent-border);
  color:var(--dm-accent-text);
}

[data-bs-theme="dark"] .planning-po-badge{background:var(--dm-surface-2);color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-po-badge-dept{border-color:var(--dm-accent-border);background:var(--dm-accent-tint);color:var(--dm-accent-text);}
[data-bs-theme="dark"] .planning-po-badge-lead{border-color:var(--dm-warn-border);background:var(--dm-warn-tint);color:var(--dm-warn-text);}

[data-bs-theme="dark"] .planning-chip-unlink{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-chip-unlink:hover{color:var(--dm-danger);}

[data-bs-theme="dark"] .assignment-chip{background:var(--dm-surface-2);border-color:var(--dm-border);}
[data-bs-theme="dark"] .assignment-chip.is-team-lead{
  border-color:var(--dm-warn-border);
  background:linear-gradient(120deg, #332a12 0%, #423519 100%);
}
[data-bs-theme="dark"] .assignment-remove,
[data-bs-theme="dark"] .workstep-assignee-remove{color:var(--dm-danger);}

[data-bs-theme="dark"] .workstep-assignee-tile{
  border-color:var(--dm-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .workstep-images-wrap{border-top-color:var(--dm-border);}
[data-bs-theme="dark"] .workstep-image-tile{border-color:var(--dm-border);background:var(--dm-surface-2);}
[data-bs-theme="dark"] .workfixture-template-note{border-left-color:var(--dm-accent-border);}
[data-bs-theme="dark"] .workstep-assign-block{border-top-color:var(--dm-border);}
[data-bs-theme="dark"] .workstep-assign-label{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .workfixture-steps-heading{color:var(--dm-text);}
[data-bs-theme="dark"] .workfixture-collapsible-summary{color:var(--dm-accent-text);}


@media (max-width: 991px){
  .planning-header{flex-direction:column;align-items:flex-start}
  .planning-controls{flex-wrap:wrap}
}

/* Production Calendar page (templates/production_calendar.html has its own inline <style>
   block with hardcoded light colors; these selectors are more specific so they win). */
[data-bs-theme="dark"] .planning-po-rail{border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-rail-tab{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .planning-rail-tab.is-active{
  background:var(--dm-accent-border);
  border-color:var(--dm-accent-border);
  color:#fff;
}
[data-bs-theme="dark"] .planning-rail-filters > summary{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-card-number{color:var(--dm-text);}
[data-bs-theme="dark"] .po-card-status{
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-card-sub,
[data-bs-theme="dark"] .po-card-esd{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-card-esd.is-past-due{color:var(--dm-danger);}
[data-bs-theme="dark"] .po-card-readiness{
  color:var(--dm-warn-text);
  background:var(--dm-warn-tint);
  border-color:var(--dm-warn-border);
}
[data-bs-theme="dark"] .po-card-readiness.is-ready{
  color:#8fcf9f;
  background:rgba(90,160,110,0.16);
  border-color:#4f7a5b;
}
[data-bs-theme="dark"] .po-card-fixtures-toggle{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-card-fixtures{border-top-color:var(--dm-border);}
[data-bs-theme="dark"] .po-fixture-line{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-fixture-line:nth-of-type(even){background:var(--dm-surface-2);}
[data-bs-theme="dark"] .po-fixture-line-head,
[data-bs-theme="dark"] .po-fixture-line-head:nth-of-type(even){
  background:var(--dm-surface);
  color:var(--dm-text-muted);
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-fixture-empty{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-month-day-drop.drop-blocked,
[data-bs-theme="dark"] .planning-week-dropzone.drop-blocked{background:rgba(217,123,131,0.16);}
[data-bs-theme="dark"] .planning-po-hovercard{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  box-shadow:0 8px 24px rgba(0,0,0,0.5);
}
[data-bs-theme="dark"] .planning-undo-toast button{color:var(--dm-accent-text);}

/* Orders Hub: Create Order + PO Details modals (templates/orders.html inline <style>) */
[data-bs-theme="dark"] .po-dept-chip{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-dept-avatar{
  border-color:var(--dm-border-soft);
  background:var(--dm-surface-2);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-dept-avatar.lead{
  border-color:var(--dm-warn-border);
  background:var(--dm-warn-tint);
  color:var(--dm-warn-text);
}
[data-bs-theme="dark"] .po-dept-avatar.assoc{
  border-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .po-modal-topbar{
  border-color:var(--dm-border);
  background:linear-gradient(180deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
}
[data-bs-theme="dark"] .po-modal-topbar .notes-wrap .form-label,
[data-bs-theme="dark"] .po-modal-total-meta .label,
[data-bs-theme="dark"] .po-modal-header-status .form-label,
[data-bs-theme="dark"] .po-ocr-status{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-modal-section{
  border-color:var(--dm-border);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] .po-modal-section-title{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-modal-total-meta .value{color:var(--dm-text);}
[data-bs-theme="dark"] .status-filter-chip{
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
  border-color:var(--dm-accent-border);
}
[data-bs-theme="dark"] .status-filter-chip-remove{color:var(--dm-accent-text);}
[data-bs-theme="dark"] .status-filter-chip-remove:hover,
[data-bs-theme="dark"] .status-filter-chip-remove:focus{color:var(--dm-text);}
[data-bs-theme="dark"] .po-file-dropzone{
  border-color:var(--dm-border-soft);
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .po-file-dropzone:hover{
  border-color:var(--dm-accent-border);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .po-file-dropzone.is-dragover{
  border-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .po-file-chip{
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
  border-color:var(--dm-accent-border);
}
[data-bs-theme="dark"] .po-file-row{
  border-color:var(--dm-border);
  background:var(--dm-surface-2);
}
[data-bs-theme="dark"] .po-file-row .po-file-name{color:var(--dm-accent-text);}
[data-bs-theme="dark"] .po-file-row .po-file-meta,
[data-bs-theme="dark"] .po-file-delete-btn{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-file-manager-section.is-drop-target{
  outline-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
}
[data-bs-theme="dark"] .po-modal-fixture-table tbody tr.po-modal-fixture-bulk-selected > td{
  background-color:var(--dm-warn-tint) !important;
}

/* PO Hub Create Order / PO Details redesign (.po-modal-v2 + .pom-* + fixture inspector in templates/orders.html) */
[data-bs-theme="dark"] .po-modal-v2 .modal-content{box-shadow:0 24px 64px rgba(0,0,0,0.55);}
[data-bs-theme="dark"] .po-modal-v2 .modal-header{
  background:linear-gradient(180deg, var(--dm-surface-2) 0%, var(--dm-surface) 100%);
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-modal-v2 .modal-body,
[data-bs-theme="dark"] .pom-section-nav{background:var(--dm-bg);}
[data-bs-theme="dark"] .pom-section-nav{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .pom-nav-link{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .pom-nav-link:hover{background:var(--dm-hover);color:var(--dm-text);}
[data-bs-theme="dark"] .pom-nav-link.active{
  background:var(--dm-surface-2);
  border-color:var(--dm-accent-border);
  color:var(--dm-accent-text);
  box-shadow:none;
}
[data-bs-theme="dark"] .pom-title-icon,
[data-bs-theme="dark"] .pom-count-badge{background:var(--dm-accent-tint);color:var(--dm-accent-text);}
[data-bs-theme="dark"] .pom-subtitle,
[data-bs-theme="dark"] .pom-card-header-note,
[data-bs-theme="dark"] .pom-panel-label,
[data-bs-theme="dark"] .pom-subhead,
[data-bs-theme="dark"] .pom-inspector-kicker,
[data-bs-theme="dark"] .pom-empty,
[data-bs-theme="dark"] .fixture-seg-label,
[data-bs-theme="dark"] .fixture-suggestion-meta,
[data-bs-theme="dark"] .fixture-suggestion-score,
[data-bs-theme="dark"] .fixture-code-chip-sep,
[data-bs-theme="dark"] .pom-footer-summary{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .pom-footer-summary strong,
[data-bs-theme="dark"] .pom-card-header,
[data-bs-theme="dark"] .pom-inspector-col-title,
[data-bs-theme="dark"] .po-modal-v2 .form-label{color:var(--dm-text);}
[data-bs-theme="dark"] .pom-card-header > i{color:var(--dm-accent-text);}
[data-bs-theme="dark"] .po-modal-v2 .po-modal-total-meta{
  background:var(--dm-surface-2);
  border-color:var(--dm-border-soft);
}
[data-bs-theme="dark"] .pom-card{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  box-shadow:none;
}
[data-bs-theme="dark"] .pom-card-header,
[data-bs-theme="dark"] .pom-subhead{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .pom-ai-panel,
[data-bs-theme="dark"] .pom-fixture-toolbar,
[data-bs-theme="dark"] .pom-callout{
  background:var(--dm-surface-2);
  border-color:var(--dm-border-soft);
}
[data-bs-theme="dark"] .pom-footer{
  background:var(--dm-surface);
  border-top-color:var(--dm-border);
}
[data-bs-theme="dark"] .pom-inspector{
  background:var(--dm-surface);
  border-color:var(--dm-border-soft);
}
[data-bs-theme="dark"] .pom-inspector-head{
  background:var(--dm-surface-2);
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .pom-inspector-col + .pom-inspector-col{border-color:var(--dm-border);}
[data-bs-theme="dark"] .fixture-code-chip{
  background:hsla(var(--seg-hue, 215), 45%, 45%, 0.18);
  color:hsl(var(--seg-hue, 215), 45%, 78%);
  border-color:hsla(var(--seg-hue, 215), 40%, 55%, 0.45);
}
[data-bs-theme="dark"] .fixture-code-chip.is-invalid-option,
[data-bs-theme="dark"] .fixture-catalog-status.is-missing{
  background:var(--dm-warn-tint);
  color:var(--dm-warn-text);
  border-color:var(--dm-warn-border);
}
[data-bs-theme="dark"] .fixture-seg-input{border-left-color:hsl(var(--seg-hue, 215), 40%, 55%) !important;}
[data-bs-theme="dark"] .fixture-seg.is-invalid-option .fixture-seg-input{
  border-color:var(--dm-warn-border);
  background-color:var(--dm-warn-tint);
}
[data-bs-theme="dark"] .fixture-seg-warn{color:var(--dm-warn-text);}
[data-bs-theme="dark"] .fixture-catalog-status.is-found{
  background:rgba(90,160,110,0.16);
  color:#8fcf9f;
  border-color:rgba(90,160,110,0.45);
}
[data-bs-theme="dark"] .fixture-suggestion{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .fixture-suggestion-code .seg-diff{background:var(--dm-warn-tint);color:var(--dm-warn-text);}
[data-bs-theme="dark"] #poDetailModal .po-modal-fixture-table td .fixture-code-not-in-catalog,
[data-bs-theme="dark"] #createOrderModal .po-modal-fixture-table td .fixture-code-not-in-catalog{
  border-color:var(--dm-warn-border);
  background-color:var(--dm-warn-tint);
}

/* Commissions page (templates/commissions.html defines --commission-* and page-scoped --cm-*
   tokens; dark mode only re-points those tokens plus a few light-only literals) */
:root[data-bs-theme="dark"]{
  --commission-external-fg:#e0a872;
  --commission-external-bg:rgba(124,70,30,0.16);
  --commission-external-border:#8a5f38;
  --commission-external-pill-bg:rgba(124,70,30,0.3);

  --commission-internal-fg:#7fc9bf;
  --commission-internal-bg:rgba(20,95,90,0.16);
  --commission-internal-border:#3f7a73;
  --commission-internal-pill-bg:rgba(20,95,90,0.3);

  --commission-randy-fg:#8fb4e3;
  --commission-randy-bg:rgba(35,68,140,0.18);
  --commission-randy-border:#44608f;
  --commission-randy-pill-bg:rgba(35,68,140,0.32);

  --commission-cree-fg:#83c497;
  --commission-cree-bg:rgba(30,95,58,0.16);
  --commission-cree-border:#3f7452;
  --commission-cree-pill-bg:rgba(30,95,58,0.3);

  --commission-danger-fg:var(--dm-danger);
  --commission-danger-bg:rgba(180,35,24,0.14);
  --commission-danger-border:#7a3a3a;
  --commission-danger-pill-bg:rgba(180,35,24,0.26);
}
[data-bs-theme="dark"] .commissions-page,
[data-bs-theme="dark"] .commission-modal{
  --cm-surface:var(--dm-surface);
  --cm-surface-2:var(--dm-surface-2);
  --cm-surface-3:var(--dm-bg);
  --cm-border:var(--dm-border);
  --cm-border-strong:var(--dm-border-soft);
  --cm-text:var(--dm-text);
  --cm-muted:var(--dm-text-muted);
  --cm-shadow:0 1px 8px rgba(0,0,0,0.35);
  --cm-shadow-hover:0 4px 18px rgba(0,0,0,0.5);

  --cm-paid-fg:#8fcf9f;
  --cm-paid-bg:rgba(90,160,110,0.16);
  --cm-paid-border:#4f7a5b;
  --cm-billed-fg:var(--dm-warn-text);
  --cm-billed-bg:var(--dm-warn-tint);
  --cm-billed-border:var(--dm-warn-border);
  --cm-upcoming-fg:var(--dm-accent-text);
  --cm-upcoming-bg:var(--dm-accent-tint);
  --cm-upcoming-border:var(--dm-accent-border);
  --cm-open-fg:var(--dm-text-muted);
  --cm-open-bg:var(--dm-surface-2);
  --cm-open-border:var(--dm-border-soft);
}
[data-bs-theme="dark"] .commissions-hero__icon{
  color:#f08a84;
  background:rgba(227,33,25,0.14);
  border-color:rgba(227,33,25,0.35);
}
[data-bs-theme="dark"] .commissions-tabs .nav-link.active{box-shadow:0 1px 4px rgba(0,0,0,0.4);}
[data-bs-theme="dark"] .commissions-page .orders-table-wrapper > table.commissions-main-table thead th{
  background:var(--cm-surface-2);
}

/* Production Planning page (templates/production_planning.html - distinct from
   Production Calendar, has its own inline <style> block, never covered before) */
[data-bs-theme="dark"] .planning-shell{background:var(--dm-bg);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-toolbar .form-label{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-summary-tile{background:var(--dm-surface);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-summary-value{color:var(--dm-text);}
[data-bs-theme="dark"] .planning-summary-label{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-week-bucket{background:var(--dm-surface);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-week-bucket-title{color:var(--dm-text);}
[data-bs-theme="dark"] .planning-week-bucket-badge.is-heavy{
  background:var(--dm-warn-tint);
  color:var(--dm-warn-text);
}
[data-bs-theme="dark"] .planning-week-bucket-badge.is-balanced{
  background:rgba(90,160,110,0.16);
  color:#8fcf9f;
}
[data-bs-theme="dark"] .planning-week-bucket-badge.is-light{
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .planning-week-stat{background:var(--dm-surface-2);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-week-stat-value{color:var(--dm-text);}
[data-bs-theme="dark"] .planning-week-stat-label{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-group{background:var(--dm-surface);border-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-group-header{background:var(--dm-surface-2);border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .planning-group-title{color:var(--dm-text);}
[data-bs-theme="dark"] .planning-table th{color:var(--dm-text-muted);background:var(--dm-surface-2);}
[data-bs-theme="dark"] .planning-po-number{color:var(--dm-text);}
[data-bs-theme="dark"] .planning-subtle{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .checkpoint-toggle{
  border-color:var(--dm-border-soft);
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .checkpoint-toggle.complete{
  background:rgba(90,160,110,0.16);
  border-color:#4f7a5b;
  color:#8fcf9f;
}
[data-bs-theme="dark"] .checkpoint-toggle.incomplete{background:var(--dm-surface-2);}
[data-bs-theme="dark"] .readiness-ready{
  color:#8fcf9f;
  background:rgba(90,160,110,0.16);
  border-color:#4f7a5b;
}
[data-bs-theme="dark"] .readiness-not-ready{
  color:var(--dm-warn-text);
  background:var(--dm-warn-tint);
  border-color:var(--dm-warn-border);
}
[data-bs-theme="dark"] .planning-expand-toggle{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .fixture-detail-row > td{background:var(--dm-surface-2);}
[data-bs-theme="dark"] .fixture-line:nth-of-type(even){background:var(--dm-hover);}
[data-bs-theme="dark"] .fixture-line-head{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .fixture-empty{color:var(--dm-text-muted);}

/* PO Invoice Ingest page (templates/accounting_po_ingest.html - own inline
   <style> block, never covered before) */
[data-bs-theme="dark"] .po-ingest-card,
[data-bs-theme="dark"] .po-allocation-po-block,
[data-bs-theme="dark"] .po-review-nav-item,
[data-bs-theme="dark"] .po-review-section,
[data-bs-theme="dark"] .po-review-summary-bar{
  background:var(--dm-surface);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-ingest-kpi,
[data-bs-theme="dark"] .po-review-nav,
[data-bs-theme="dark"] .po-review-nav-header,
[data-bs-theme="dark"] .po-review-table thead th,
[data-bs-theme="dark"] .po-review-chip{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-ingest-kpi .label{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-ingest-list{
  background:var(--dm-surface);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-allocation-table th,
[data-bs-theme="dark"] .po-allocation-table td,
[data-bs-theme="dark"] .po-review-table td,
[data-bs-theme="dark"] .po-review-nav-item{
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] .po-review-nav{border-right-color:var(--dm-border);}
[data-bs-theme="dark"] .po-review-section{
  border-left-color:var(--po-accent);
}
[data-bs-theme="dark"] .po-review-summary-bar{
  box-shadow:0 2px 6px rgba(0,0,0,0.45);
}
[data-bs-theme="dark"] .po-review-nav-item:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .po-review-nav-item.active,
[data-bs-theme="dark"] .po-review-qb-bill-candidate.active,
[data-bs-theme="dark"] .po-alloc-group.drag-over td{
  background:var(--dm-accent-tint);
  border-color:var(--dm-accent-border);
}
[data-bs-theme="dark"] .po-review-nav-po,
[data-bs-theme="dark"] .po-review-summary-title,
[data-bs-theme="dark"] .po-review-chip,
[data-bs-theme="dark"] .po-alloc-group-title,
[data-bs-theme="dark"] .po-alloc-code{
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-review-nav-customer,
[data-bs-theme="dark"] .po-review-summary-customer,
[data-bs-theme="dark"] .po-review-row-label{
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-review-nav-header,
[data-bs-theme="dark"] .po-review-nav-meta,
[data-bs-theme="dark"] .po-review-label,
[data-bs-theme="dark"] .po-review-chip .chip-label,
[data-bs-theme="dark"] .po-review-section-meta,
[data-bs-theme="dark"] .po-review-section-chevron,
[data-bs-theme="dark"] .po-review-table thead th,
[data-bs-theme="dark"] .po-alloc-count,
[data-bs-theme="dark"] .po-alloc-type,
[data-bs-theme="dark"] .po-alloc-drag-handle{
  color:var(--dm-text-muted);
}
/* Accent colors are tuned for light backgrounds - lighten them for the dark surface */
[data-bs-theme="dark"] .po-review-section-title{
  color:color-mix(in srgb, var(--po-accent) 55%, #fff);
}
[data-bs-theme="dark"] .po-review-chip.is-ok{background:rgba(25,135,84,0.18);border-color:rgba(25,135,84,0.5);color:#8fcf9f;}
[data-bs-theme="dark"] .po-review-chip.is-bad{background:rgba(220,53,69,0.18);border-color:rgba(220,53,69,0.5);color:var(--dm-danger);}
[data-bs-theme="dark"] .po-review-chip.is-warn{background:rgba(255,193,7,0.15);border-color:rgba(255,193,7,0.45);color:#ffd77a;}
[data-bs-theme="dark"] .po-review-chip.is-muted{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .po-review-issues{
  background:rgba(220,53,69,0.12);
  border-color:rgba(220,53,69,0.45);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .po-review-qb-invoice-menu{
  background:var(--dm-surface);
  box-shadow:0 4px 10px rgba(0,0,0,0.45);
}
[data-bs-theme="dark"] .po-alloc-group-total.mismatch{color:var(--dm-danger);}
[data-bs-theme="dark"] .po-alloc-group-total.match{color:#8fcf9f;}

/* Resizable-table column separators (Pending Invoices, Invoiced, ARON Sales
   & Commissions, Master PO, Commissions all opt in via data-col-resize="1") -
   this single hardcoded light border was showing as bright white lines
   through every one of those tables in dark mode. */
[data-bs-theme="dark"] .orders-table-wrapper table[data-col-resize="1"] th,
[data-bs-theme="dark"] .orders-table-wrapper table[data-col-resize="1"] td{
  border-right-color:var(--dm-border);
}

/* Pending Invoices (templates/pending_invoices.html inline <style>) */
[data-bs-theme="dark"] .pending-invoices-toggle-btn{
  border-color:var(--dm-border);
  background:var(--dm-surface);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .pending-invoice-detail-shell{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .pending-invoice-chip{
  border-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .pending-invoice-fixture-table th{
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}

/* Invoiced Orders (templates/invoiced.html inline <style>) */
[data-bs-theme="dark"] .invoiced-toggle-btn{
  border-color:var(--dm-border);
  background:var(--dm-surface);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .invoiced-detail-shell{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .invoiced-chip{
  border-color:var(--dm-accent-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .invoiced-balance-amount{color:var(--dm-text);}
[data-bs-theme="dark"] .invoiced-balance-due,
[data-bs-theme="dark"] .batch-field label,
[data-bs-theme="dark"] .batch-invoice-summary{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .invoiced-fixture-table th{
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .batch-invoice-summary-field{
  border-color:var(--dm-border-soft);
  background:var(--dm-surface-2);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .batch-group-cell{background:var(--dm-surface);}
[data-bs-theme="dark"] #recordMultiplePaymentsModal .modal-header,
[data-bs-theme="dark"] #recordMultiplePaymentsModal .modal-footer{background:var(--dm-surface-2);}
[data-bs-theme="dark"] #recordMultiplePaymentsModal .table-responsive{
  border-color:var(--dm-border);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] #invoiced-batch-payments-table thead th{
  background:var(--dm-surface-2);
  border-bottom-color:var(--dm-border);
}
[data-bs-theme="dark"] #invoiced-batch-payments-table .batch-payment-row:hover{background:var(--dm-hover);}

/* Master PO (templates/master_po.html inline <style>) */
[data-bs-theme="dark"] .master-po-toggle-btn{
  border-color:var(--dm-border);
  background:var(--dm-surface);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .master-po-detail-shell{
  background:var(--dm-surface-2);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .master-po-kpi-card,
[data-bs-theme="dark"] .master-po-panel{
  background:var(--dm-surface);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .master-po-kpi-label,
[data-bs-theme="dark"] .master-po-panel-title,
[data-bs-theme="dark"] .master-po-commission-meta,
[data-bs-theme="dark"] .master-po-commission-status,
[data-bs-theme="dark"] .master-po-meta-key,
[data-bs-theme="dark"] .master-po-invoice-date-pairs,
[data-bs-theme="dark"] .master-po-split-invoice-title,
[data-bs-theme="dark"] .master-po-split-invoice-card-meta,
[data-bs-theme="dark"] .master-po-fixture-table th{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .master-po-fixture-table th{background:var(--dm-surface-2);}
[data-bs-theme="dark"] .master-po-kpi-value,
[data-bs-theme="dark"] .master-po-meta-item,
[data-bs-theme="dark"] .master-po-note-text,
[data-bs-theme="dark"] .master-po-split-invoice-card-label{color:var(--dm-text);}
[data-bs-theme="dark"] .master-po-chip{
  border-color:var(--dm-border);
  background:var(--dm-surface-2);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .master-po-worker-chip{
  border-color:var(--dm-border);
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .master-po-split-invoice-panel{
  border-color:var(--dm-border);
  background:linear-gradient(180deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
}
[data-bs-theme="dark"] .master-po-split-invoice-card{
  border-color:var(--dm-border);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] .po-modal-shell.section-dividers .po-modal-section + .po-modal-section{
  border-top-color:var(--dm-border);
}
[data-bs-theme="dark"] .rb-commissionable-toggle{
  border-color:var(--dm-border);
  background:var(--dm-surface);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .rb-commissionable-toggle.is-yes{
  border-color:#4f7a5b;
  color:#8fcf9f;
  background:rgba(90,160,110,0.16);
}

/* Vendor RFQs (templates/vendor_rfqs.html inline <style>) */
[data-bs-theme="dark"] .rfq-part-card{border-color:var(--dm-border);}
[data-bs-theme="dark"] .rfq-part-card-header{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .rfq-qty-cost-row label,
[data-bs-theme="dark"] .rfq-line-saved-cost{color:var(--dm-text-muted);}

/* Planning nav pills - shared class used by production_calendar.html,
   production_planning.html and production_calendar_day_detail.html. */
[data-bs-theme="dark"] .planning-horizon-tab{
  border-color:var(--dm-border);
  background:var(--dm-surface);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .planning-horizon-tab.is-active{
  background:var(--dm-accent-border);
  border-color:var(--dm-accent-border);
  color:#fff;
}

/* Day Planning (templates/production_calendar_day_detail.html inline <style>) */
[data-bs-theme="dark"] .mini-day-calendar{
  border-color:var(--dm-border);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] .mini-day-calendar-weekday,
[data-bs-theme="dark"] .mini-day-calendar-cell.is-outside,
[data-bs-theme="dark"] .mini-day-calendar-cell.is-outside .mini-day-calendar-count{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .mini-day-calendar-cell{color:var(--dm-text);}
[data-bs-theme="dark"] .mini-day-calendar-cell:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .mini-day-calendar-cell.is-today{border-color:var(--dm-accent-border);}
[data-bs-theme="dark"] .mini-day-calendar-cell.is-selected,
[data-bs-theme="dark"] .mini-day-calendar-cell.is-selected:hover{background:var(--dm-accent-border);}
[data-bs-theme="dark"] .day-roster-panel{
  border-color:var(--dm-border);
  background:var(--dm-surface);
}
[data-bs-theme="dark"] .day-roster-title{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .day-roster-chip{
  border-color:var(--dm-border);
  background:var(--dm-surface-2);
  color:var(--dm-text-muted);
}
[data-bs-theme="dark"] .day-roster-chip.is-allocated{
  border-color:#4f7a5b;
  background:rgba(90,160,110,0.16);
  color:#8fcf9f;
}
[data-bs-theme="dark"] .day-roster-chip .planning-avatar{
  background:var(--dm-hover);
  color:var(--dm-text-muted);
}

/* Planning Hub (templates/planning_hub.html inline <style>) */
[data-bs-theme="dark"] .planning-hub-card{
  background:var(--dm-surface);
  border-color:var(--dm-border);
  box-shadow:0 2px 8px rgba(0,0,0,0.35);
}
[data-bs-theme="dark"] .planning-hub-card:hover{
  border-color:var(--dm-accent-border);
  box-shadow:0 8px 22px rgba(0,0,0,0.45);
}
[data-bs-theme="dark"] .planning-hub-kicker,
[data-bs-theme="dark"] .planning-hub-meta,
[data-bs-theme="dark"] .planning-hub-copy{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .planning-hub-title{color:var(--dm-text);}

/* Customer RFQs (templates/customer_rfqs.html inline <style>) */
[data-bs-theme="dark"] .fixture-result:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .rfq-line-card{border-color:var(--dm-border);}
[data-bs-theme="dark"] .rfq-line-card:hover{box-shadow:0 1px 6px rgba(0,0,0,0.4);}
[data-bs-theme="dark"] .rfq-line-card .pricing-tiers{border-top-color:var(--dm-border-soft);}
[data-bs-theme="dark"] .rfq-hero{
  background:linear-gradient(135deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .rfq-hero input{
  background:var(--dm-surface-2);
  color:var(--dm-text);
}
[data-bs-theme="dark"] .rfq-ai-panel{
  background:linear-gradient(135deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
  border-color:var(--dm-accent-border);
}
[data-bs-theme="dark"] .fixtures-section h6{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .quote-panel{
  background:rgba(90,160,110,0.12);
  border-color:#4f7a5b;
}
[data-bs-theme="dark"] .rfq-files-panel{
  background:linear-gradient(135deg, var(--dm-surface) 0%, var(--dm-surface-2) 100%);
  border-color:var(--dm-accent-border);
}
[data-bs-theme="dark"] .rfq-seg{background:var(--dm-surface-2);border-color:var(--dm-border-soft);color:var(--dm-text);}
[data-bs-theme="dark"] .rfq-seg.is-invalid{background:var(--dm-warn-tint);border-color:var(--dm-warn-border);}
[data-bs-theme="dark"] .rfq-seg.is-missing{background:var(--dm-warn-tint);border-color:var(--dm-warn-border);color:var(--dm-warn-text);}
[data-bs-theme="dark"] .rfq-file-row{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .rfq-terms-preview{background:var(--dm-surface-2);border-color:var(--dm-border);}
/* Template rules are scoped by #customer-rfqs-page, so the ID is required here to win. */
[data-bs-theme="dark"] #customer-rfqs-page .rfq-filter-card{background:var(--dm-surface);border-color:var(--dm-border);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-panel-title,
[data-bs-theme="dark"] #customer-rfqs-page .rfq-kpi-label,
[data-bs-theme="dark"] #customer-rfqs-page .rfq-kpi-sub{color:var(--dm-text-muted);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-kpi{
  background:var(--dm-surface);
  border-top-color:var(--dm-border);
  border-right-color:var(--dm-border);
  border-bottom-color:var(--dm-border);
  color:var(--dm-text);
}
[data-bs-theme="dark"] #customer-rfqs-page button.rfq-kpi:hover{box-shadow:0 2px 10px rgba(0,0,0,0.45);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-kpi-value{color:var(--dm-text);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-rep-table-wrap thead th{background:var(--dm-surface);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-table-scroll{border-color:var(--dm-border);}
[data-bs-theme="dark"] #customer-rfqs-page .rfq-table-scroll thead th{
  background:var(--dm-surface-2);
  box-shadow:inset 0 -1px 0 var(--dm-border);
}
[data-bs-theme="dark"] #customer-rfqs-page .customer-rfq-row.is-current > td{background:rgba(227,33,25,0.14);}

/* Rep Contacts (templates/rep_contacts.html inline <style>, ID-scoped) */
[data-bs-theme="dark"] #rep-contacts-page .rc-table-scroll{border-color:var(--dm-border);}
[data-bs-theme="dark"] #rep-contacts-page .rc-table-scroll thead th{
  background:var(--dm-surface-2);
  box-shadow:inset 0 -1px 0 var(--dm-border);
}
[data-bs-theme="dark"] #rep-contacts-page tr.rc-inactive > td{color:var(--dm-text-muted);}
[data-bs-theme="dark"] #rep-contacts-page .rc-domain{background:var(--dm-surface-2);border-color:var(--dm-border-soft);color:var(--dm-text);}

/* Fishbowl Center (templates/fishbowl_manufacturer_orders.html inline <style>) */
[data-bs-theme="dark"] .fb-wo-expand-toggle,
[data-bs-theme="dark"] .fb-wo-refresh-meta{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .fb-wo-detail-row > td{background:var(--dm-surface-2);}

/* File Manager (templates/file_manager.html inline <style>) */
[data-bs-theme="dark"] .fm-col{
  background:var(--dm-surface);
  border-color:var(--dm-border);
}
[data-bs-theme="dark"] .fm-agency-item.active,
[data-bs-theme="dark"] .fm-po-row-header.expanded{
  background:var(--dm-accent-tint);
  color:var(--dm-accent-text);
}
[data-bs-theme="dark"] .fm-po-row-header:hover{background:var(--dm-hover);}
[data-bs-theme="dark"] .fm-po-row{border-color:var(--dm-border-soft);}
[data-bs-theme="dark"] .fm-po-agency-name{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .fm-po-collapse .po-file-manager-panel{border-color:var(--dm-border);}

/* Label & Driver Center dark theme lives in static/label_driver_center.css. */

.production-home{
  --ph-surface:#fff;
  --ph-subtle:#f2f5f3;
  --ph-border:#dce3df;
  --ph-ink:#24312b;
  --ph-muted:#5f7067;
  --ph-accent:#b51811;
  --ph-green:#237151;
  color:var(--ph-ink);
}
.production-home-eyebrow{color:var(--ph-accent);font-size:.72rem;font-weight:700;text-transform:uppercase;}
.production-home-range{color:var(--ph-muted);font-size:.88rem;}
.production-home-overview{
  display:grid;
  grid-template-columns:repeat(4,minmax(0,1fr));
  background:var(--ph-subtle);
  border-top:2px solid var(--ph-green);
  border-bottom:1px solid var(--ph-border);
}
.production-home-overview.is-associate-only{grid-template-columns:repeat(3,minmax(0,1fr));}
.production-home-stat{display:flex;align-items:center;gap:.8rem;min-width:0;padding:1rem 1.25rem;font-size:.82rem;}
.production-home-stat + .production-home-stat{border-left:1px solid var(--ph-border);}
.production-home-stat i{font-size:1.15rem;color:var(--ph-green);}
.production-home-stat strong{font-size:1.45rem;line-height:1;}
.production-home-stat-label{color:var(--ph-muted);}
.production-home-step-trigger{display:flex;align-items:center;gap:.3rem;padding:0;border:0;background:none;color:var(--ph-ink);text-align:left;font-size:inherit;}
.production-home-step-trigger:hover,.production-home-step-trigger:focus-visible{color:var(--ph-green);}
.production-home-step-trigger > i{font-size:.7rem;margin-left:.2rem;}
.production-home-step-menu{width:min(370px,calc(100vw - 32px));max-height:340px;overflow-y:auto;background:var(--ph-surface);border-color:var(--ph-border);}
.production-home-step-menu .dropdown-header{color:var(--ph-muted);font-weight:700;}
.production-home-step-menu .dropdown-item{white-space:normal;overflow-wrap:anywhere;color:var(--ph-ink);}
.production-home-step-menu .dropdown-item:hover,.production-home-step-menu .dropdown-item:focus{background:var(--ph-subtle);}
.production-home-step-menu .dropdown-item span,.production-home-step-menu .dropdown-item small{display:block;}
.production-home-step-menu .dropdown-item small{color:var(--ph-muted);font-size:.73rem;}
.production-home-week{display:grid;grid-template-columns:repeat(5,minmax(0,1fr));gap:.55rem;}
.production-home-day{
  min-width:0;
  display:flex;
  flex-direction:column;
  gap:.15rem;
  padding:.65rem .8rem;
  border:1px solid var(--ph-border);
  border-bottom:3px solid var(--ph-border);
  background:var(--ph-surface);
  color:var(--ph-ink);
  text-decoration:none;
}
.production-home-day.is-today{border-bottom-color:var(--ph-accent);background:var(--ph-subtle);}
.production-home-day.is-selected{border-color:var(--ph-green);border-bottom-color:var(--ph-green);background:var(--ph-subtle);}
.production-home-day:is(a):hover,.production-home-day:is(a):focus-visible{border-bottom-color:var(--ph-green);color:var(--ph-ink);}
.production-home-day-name{font-size:.72rem;font-weight:700;text-transform:uppercase;color:var(--ph-muted);}
.production-home-day strong{font-size:1.25rem;line-height:1.2;}
.production-home-day-count{font-size:.75rem;color:var(--ph-muted);}
.production-home-group{scroll-margin-top:1rem;}
.production-home-group-heading{display:flex;align-items:baseline;gap:.75rem;border-bottom:1px solid var(--ph-border);padding-bottom:.5rem;margin-bottom:1rem;}
.production-home-group-heading h2{font-size:1rem;font-weight:700;margin:0;}
.production-home-group-heading span{font-size:.8rem;color:var(--ph-muted);}
.production-home-orders{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:.85rem;}
.production-home-order{min-width:0;padding:1rem 1.1rem;background:var(--ph-surface);border:1px solid var(--ph-border);border-radius:6px;}
.production-home-order-top{display:flex;justify-content:space-between;align-items:start;gap:.75rem;min-width:0;}
.production-home-order-identity{min-width:0;}
.production-home-tags{display:flex;flex-wrap:wrap;gap:.35rem;margin-bottom:.45rem;}
.production-home-tags span{font-size:.68rem;font-weight:700;text-transform:uppercase;color:var(--ph-muted);}
.production-home-tags .production-home-lead{color:var(--ph-green);}
.production-home-order h3{font-size:1.04rem;font-weight:700;margin:0 0 .2rem;}
.production-home-order h3 a{color:var(--ph-ink);text-decoration:none;}
.production-home-order h3 a:hover{text-decoration:underline;text-decoration-color:var(--ph-accent);}
.production-home-order h3 i{font-size:.75rem;color:var(--ph-accent);}
.production-home-customer{font-size:.84rem;color:var(--ph-muted);}
.production-home-order-meta{display:flex;flex-direction:column;align-items:flex-end;gap:.2rem;flex-shrink:0;font-size:.73rem;color:var(--ph-muted);text-align:right;}
.production-home-order-meta .production-home-late{color:var(--ph-accent);font-weight:700;}
.production-home-steps-header{display:flex;justify-content:space-between;gap:.6rem;margin-top:1rem;font-size:.76rem;font-weight:700;}
.production-home-steps-header span:last-child{color:var(--ph-muted);}
.production-home-progress{display:block;width:100%;height:5px;margin:.45rem 0 .7rem;border:0;background:var(--ph-subtle);}
.production-home-progress::-webkit-progress-bar{background:var(--ph-subtle);}
.production-home-progress::-webkit-progress-value{background:var(--ph-green);}
.production-home-progress::-moz-progress-bar{background:var(--ph-green);}
.production-home-steps{list-style:none;padding:0;margin:0;}
.production-home-steps li{display:flex;align-items:baseline;justify-content:space-between;gap:.6rem;padding:.4rem 0;border-top:1px solid var(--ph-border);font-size:.83rem;}
.production-home-steps li:target{background:var(--ph-subtle);outline:2px solid var(--ph-green);scroll-margin-top:2rem;}
.production-home-step-name{min-width:0;overflow-wrap:anywhere;}
.production-home-step-name small{color:var(--ph-muted);}
.production-home-step-assignees{display:block;margin-top:.15rem;color:var(--ph-muted);font-size:.73rem;}
.production-home-steps .badge{flex-shrink:0;font-size:.67rem;}
.production-home-no-steps{padding:.6rem 0;font-size:.82rem;color:var(--ph-muted);}
.production-home-empty{padding:2rem 1rem;text-align:center;background:var(--ph-subtle);color:var(--ph-muted);}
.production-home-empty i{font-size:1.5rem;color:var(--ph-green);}
.production-home-empty p{margin:.5rem 0 0;}
.production-home-calendar{background:var(--ph-surface);color:var(--ph-ink);}
.production-home-calendar-nav{display:flex;align-items:center;justify-content:space-between;gap:.5rem;margin-bottom:1rem;}
.production-home-calendar-nav strong{font-size:1rem;}
.production-home-calendar-nav .btn{position:relative;}
.production-home-nav-badge{position:absolute;top:-4px;right:-4px;width:9px;height:9px;border-radius:50%;background:var(--ph-accent);border:1px solid var(--ph-surface);}
.production-home-calendar-grid{display:grid;grid-template-columns:repeat(7,minmax(0,1fr));gap:2px;}
.production-home-calendar-weekday{text-align:center;font-size:.7rem;font-weight:700;text-transform:uppercase;color:var(--ph-muted);padding:.4rem 0;}
.production-home-calendar-day{display:flex;flex-direction:column;align-items:start;gap:.25rem;min-width:0;min-height:72px;padding:.45rem;border:1px solid var(--ph-border);background:var(--ph-surface);color:var(--ph-ink);text-decoration:none;font-size:.8rem;}
.production-home-calendar-day.is-outside{opacity:.55;}
.production-home-calendar-day.is-today{border-color:var(--ph-accent);}
.production-home-calendar-day:is(a):hover,.production-home-calendar-day:is(a):focus-visible{border-color:var(--ph-green);background:var(--ph-subtle);color:var(--ph-ink);}
.production-home-calendar-badge{display:inline-block;min-width:1.3rem;padding:0 .2rem;text-align:center;background:var(--ph-green);color:var(--ph-surface);border-radius:3px;font-size:.7rem;font-weight:700;}
.production-home-calendar-day small{font-size:.62rem;color:var(--ph-muted);}
[data-bs-theme="dark"] .production-home{
  --ph-surface:var(--dm-surface);
  --ph-subtle:var(--dm-surface-2);
  --ph-border:var(--dm-border);
  --ph-ink:var(--dm-text);
  --ph-muted:var(--dm-text-muted);
  --ph-accent:#f08b83;
  --ph-green:#8fceb1;
}
@media (max-width: 800px){
  .production-home-orders{grid-template-columns:1fr;}
  .production-home-overview{grid-template-columns:repeat(2,minmax(0,1fr));}
  .production-home-overview.is-associate-only{grid-template-columns:repeat(2,minmax(0,1fr));}
  .production-home-overview.is-associate-only .production-home-stat:last-child{grid-column:span 2;}
  .production-home-stat:nth-child(3){border-left:0;}
  .production-home-stat:nth-child(n+3){border-top:1px solid var(--ph-border);}
}
@media (max-width: 480px){
  .production-home-stat{gap:.45rem;padding:.8rem .6rem;font-size:.73rem;}
  .production-home-stat strong{font-size:1.15rem;}
  .production-home-week{grid-template-columns:repeat(5,minmax(0,1fr));}
  .production-home-day{padding:.55rem .3rem;}
  .production-home-day strong{font-size:1rem;}
  .production-home-day-count{font-size:.65rem;}
  .production-home-order-top{flex-wrap:wrap;}
  .production-home-order-meta{align-items:flex-start;text-align:left;}
  .production-home-calendar-day{min-height:62px;padding:.25rem;}
  .production-home-calendar-day small{font-size:.55rem;overflow-wrap:anywhere;}
}

/* ===== Personal reminders: Internal Messages ===== */
.im-avatar-reminder{background:rgba(253,126,20,0.15); color:#fd7e14; border-radius:0.7rem; font-size:1.05rem;}
.im-avatar-sm.im-avatar-reminder{border-radius:0.5rem; font-size:0.8rem;}
.im-reminder-card{display:flex; gap:0.6rem; align-items:flex-start; margin:0.6rem auto; max-width:85%; padding:0.6rem 0.8rem; background:#fff8ef; border:1px solid #ffe2c2; border-radius:0.75rem;}
.im-reminder-card > .bi{color:#fd7e14; font-size:1.1rem; line-height:1.3;}
.im-reminder-text{display:flex; flex-direction:column; min-width:0; white-space:pre-wrap; font-size:0.88rem;}
.im-reminder-text .im-time{align-self:flex-end; font-size:0.7rem; color:#8a94a0;}
[data-bs-theme="dark"] .im-reminder-card{background:var(--dm-surface-2); border-color:var(--dm-border);}
[data-bs-theme="dark"] .im-reminder-text{color:var(--dm-text);}

/* ===== Personal reminders: global toasts ===== */
.prm-toast-stack{position:fixed; top:72px; right:20px; z-index:1085; display:flex; flex-direction:column; gap:0.6rem; width:min(360px, calc(100vw - 40px)); pointer-events:none;}
.prm-toast{pointer-events:auto; background:#fff; border:1px solid #ffd8ad; border-left:4px solid #fd7e14; border-radius:0.75rem; box-shadow:0 10px 30px rgba(15,23,42,0.18); padding:0.75rem 0.85rem; animation:prmIn 0.25s ease-out;}
.prm-toast-head{display:flex; align-items:center; gap:0.5rem; font-size:0.72rem; font-weight:600; text-transform:uppercase; letter-spacing:0.04em; color:#c25e00;}
.prm-toast-title{font-weight:600; margin:0.25rem 0 0.15rem; word-break:break-word;}
.prm-toast-notes{font-size:0.83rem; color:#495057; white-space:pre-wrap; word-break:break-word; max-height:6.5em; overflow:auto;}
.prm-toast-actions{display:flex; flex-wrap:wrap; gap:0.35rem; margin-top:0.6rem;}
@keyframes prmIn{from{opacity:0; transform:translateY(-8px);} to{opacity:1; transform:none;}}
[data-bs-theme="dark"] .prm-toast{background:var(--dm-surface); border-color:var(--dm-border); border-left-color:#fd7e14; box-shadow:0 10px 30px rgba(0,0,0,0.45);}
[data-bs-theme="dark"] .prm-toast-head{color:#ffb066;}
[data-bs-theme="dark"] .prm-toast-notes{color:var(--dm-text-muted);}

/* ===== User Settings page ===== */
.us-hero{display:flex; align-items:center; gap:1rem; padding:1.1rem 1.25rem; margin-bottom:1.25rem; border-radius:1rem; background:linear-gradient(120deg, rgba(227,33,25,0.08), rgba(13,110,253,0.06)); border:1px solid rgba(15,15,20,0.06);}
.us-avatar{flex-shrink:0; width:56px; height:56px; border-radius:50%; display:flex; align-items:center; justify-content:center; font-weight:700; font-size:1.2rem; color:#fff; background:var(--brand, #e32119); box-shadow:0 4px 12px rgba(227,33,25,0.25);}
.us-hero h2{margin:0; font-size:1.5rem;}
.us-hero-meta{display:flex; flex-wrap:wrap; gap:0.4rem 0.9rem; font-size:0.85rem; color:#6c757d;}
.us-layout{display:grid; grid-template-columns:230px minmax(0,1fr); gap:1.25rem; align-items:start;}
.us-nav{position:sticky; top:80px; display:flex; flex-direction:column; gap:0.2rem; padding:0.5rem; border-radius:0.9rem; background:#fff; border:1px solid rgba(15,15,20,0.06); box-shadow:var(--card-shadow);}
.us-nav-link{display:flex; align-items:center; gap:0.6rem; width:100%; padding:0.55rem 0.75rem; border:0; border-radius:0.6rem; background:transparent; color:#344054; font-weight:500; text-align:left; text-decoration:none;}
.us-nav-link:hover{background:#f2f4f7; color:#101828;}
.us-nav-link.active{background:rgba(227,33,25,0.09); color:#b4120c;}
.us-nav-link .badge{margin-left:auto;}
.us-section{display:none;}
.us-section.active{display:block; animation:prmIn 0.2s ease-out;}
.us-card{background:#fff; border:1px solid rgba(15,15,20,0.06); border-radius:0.9rem; box-shadow:var(--card-shadow); margin-bottom:1.25rem;}
.us-card-header{display:flex; align-items:center; gap:0.6rem; padding:0.9rem 1.15rem; border-bottom:1px solid #eef0f3;}
.us-card-header h5{margin:0; font-size:1.05rem;}
.us-card-header .us-card-sub{font-size:0.82rem; color:#6c757d;}
.us-card-body{padding:1.15rem;}
.us-card-icon{width:34px; height:34px; border-radius:0.6rem; display:inline-flex; align-items:center; justify-content:center; background:#f2f4f7; color:#475467; flex-shrink:0;}
.us-theme-preview{display:flex; gap:0.75rem;}
.us-theme-swatch{flex:1; border-radius:0.7rem; border:2px solid transparent; padding:0.6rem; font-size:0.8rem;}
.us-theme-swatch.light{background:#f8f9fa; color:#212529; border-color:#dee2e6;}
.us-theme-swatch.dark{background:#161b22; color:#ccd3db; border-color:#323a46;}
.us-theme-swatch.current{border-color:var(--brand, #e32119);}
.us-seg .btn{min-width:7rem;}
.us-reminder-list{display:flex; flex-direction:column; gap:0.5rem;}
.us-reminder{display:flex; gap:0.75rem; align-items:flex-start; padding:0.7rem 0.85rem; border:1px solid #eaecf0; border-radius:0.75rem; background:#fff;}
.us-reminder.attention{border-color:#ffd8ad; background:#fff8ef;}
.us-reminder-icon{width:34px; height:34px; border-radius:0.6rem; display:inline-flex; align-items:center; justify-content:center; flex-shrink:0; background:rgba(13,110,253,0.1); color:#0d6efd;}
.us-reminder-icon.order{background:rgba(25,135,84,0.12); color:#198754;}
.us-reminder-body{flex:1 1 auto; min-width:0;}
.us-reminder-title{font-weight:600; word-break:break-word;}
.us-reminder-meta{display:flex; flex-wrap:wrap; gap:0.35rem 0.75rem; font-size:0.8rem; color:#6c757d; margin-top:0.15rem;}
.us-reminder-notes{font-size:0.83rem; color:#475467; white-space:pre-wrap; word-break:break-word; margin-top:0.25rem;}
.us-reminder-actions{display:flex; gap:0.25rem; flex-shrink:0;}
.us-po-results{position:absolute; z-index:20; left:0; right:0; max-height:260px; overflow:auto;}
.us-empty{text-align:center; color:#8a94a0; padding:1.25rem; font-size:0.9rem;}
@media (max-width: 991.98px){
  .us-layout{grid-template-columns:1fr;}
  .us-nav{position:static; flex-direction:row; overflow-x:auto;}
  .us-nav-link{white-space:nowrap; width:auto;}
}
[data-bs-theme="dark"] .us-hero{background:linear-gradient(120deg, rgba(227,33,25,0.14), rgba(88,140,196,0.10)); border-color:var(--dm-border);}
[data-bs-theme="dark"] .us-hero-meta,
[data-bs-theme="dark"] .us-card-header .us-card-sub,
[data-bs-theme="dark"] .us-reminder-meta,
[data-bs-theme="dark"] .us-empty{color:var(--dm-text-muted);}
[data-bs-theme="dark"] .us-nav,
[data-bs-theme="dark"] .us-card,
[data-bs-theme="dark"] .us-reminder{background:var(--dm-surface); border-color:var(--dm-border); box-shadow:none;}
[data-bs-theme="dark"] .us-card-header{border-bottom-color:var(--dm-border);}
[data-bs-theme="dark"] .us-nav-link{color:var(--dm-text);}
[data-bs-theme="dark"] .us-nav-link:hover{background:var(--dm-hover); color:var(--dm-text);}
[data-bs-theme="dark"] .us-nav-link.active{background:var(--dm-accent-tint); color:var(--dm-accent-text);}
[data-bs-theme="dark"] .us-card-icon{background:var(--dm-hover); color:var(--dm-text-muted);}
[data-bs-theme="dark"] .us-reminder.attention{background:var(--dm-surface-2); border-color:#7a4a1c;}
[data-bs-theme="dark"] .us-reminder-notes{color:var(--dm-text-muted);}


/* Do Not Ship Before warning badge (static/ship_hold_badge.js) */
.ship-hold-badge{white-space:nowrap; font-weight:600; vertical-align:middle;}
.modal-title .ship-hold-badge{font-size:.7rem;}
