/* Portal glue on top of aurolab.css (design system). Uses only design tokens; no Bootstrap. */

/* ---- Form controls (the design system styles .al-bs .form-control colours; Bootstrap geometry replaced) ---- */
.al-bs .form-control { display: block; height: 42px; padding: 0 12px; font: 400 14px var(--font-sans); min-width: 160px; }
.al-bs select.form-control { padding-right: 32px; appearance: none; -webkit-appearance: none; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--ink-muted) 50%), linear-gradient(135deg, var(--ink-muted) 50%, transparent 50%);
  background-position: calc(100% - 17px) 18px, calc(100% - 12px) 18px; background-size: 5px 5px; background-repeat: no-repeat; }
.al-bs .form-control[type="date"] { min-width: 150px; }
.al-filters .form-control { width: auto; min-width: 180px; }
.al-filters .al-filter-actions { display: flex; gap: 8px; align-items: flex-end; }
.al-filters .al-btn { height: 42px; }
.al-form-grid { display: grid; gap: 16px; max-width: 420px; }
.al-form-grid label { display: block; margin: 0 0 6px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.al-form-grid .form-control { width: 100%; }
.al-help { margin: 4px 0 0; font-size: 12px; line-height: 18px; color: var(--ink-muted); }

/* ---- Alerts (status always carries words, not colour alone) ---- */
.al-alert { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: var(--radius-lg); font-size: 14px; line-height: 21px; }
.al-alert svg { flex: none; margin-top: 2px; }
.al-alert ul { margin: 0; padding-left: 18px; }
.al-alert--danger { background: var(--danger-soft); color: var(--danger); }
.al-alert--warning { background: var(--warning-soft); color: var(--warning); }
.al-alert--success { background: var(--success-soft); color: var(--success); }
.al-alert--info { background: var(--brand-50); color: var(--ink); border: 1px solid var(--border); }

/* ---- Page head, context strip, pagination ---- */
.al-page-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.al-context-strip { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 10px 16px; border-radius: var(--radius-lg);
  background: var(--surface); border: 1px solid var(--border); font-size: 13px; }
.al-context-strip .al-avatar { width: 30px; height: 30px; font-size: 12px; }
.al-context-strip b { color: var(--ink); }
.al-pager { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; border-top: 1px solid var(--border);
  font-size: 13px; color: var(--ink-muted); }
.al-pager-links { display: flex; gap: 8px; }
.al-card-foot { padding: 14px 24px; border-top: 1px solid var(--border); font-size: 13px; color: var(--ink-muted); }
.al-grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 24px; }
@media (max-width: 560px) { .al-grid-2 { grid-template-columns: 1fr; } .al-content { padding: 20px 16px 40px; } }
.al-muted { color: var(--ink-muted); }
.al-small { font-size: 12px; line-height: 18px; }
.al-wrap { min-width: 12rem; }
.al-visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---- Tables: sortable heads, row states ---- */
table.sortable thead th { cursor: pointer; user-select: none; }
table.sortable thead th[aria-sort="ascending"]::after { content: " ▲"; font-size: 10px; }
table.sortable thead th[aria-sort="descending"]::after { content: " ▼"; font-size: 10px; }
table.sortable thead th:focus-visible { outline: none; box-shadow: inset var(--shadow-focus); }
.al-table tr.is-danger td { background: var(--danger-soft); }
.al-table tr.is-success td { background: var(--success-soft); }
.al-table tr.is-selected td { background: var(--brand-50); }
.al-table tr.is-muted td { color: var(--ink-muted); font-style: italic; }
.al-table td.al-wrap { white-space: normal; }
.al-table-search { display: flex; justify-content: flex-end; padding: 18px 24px 16px; }
.al-table-search .al-search { width: 400px; max-width: 100%; }
.al-table-search .al-search input { padding-right: 16px; }  /* no shortcut hint here, so the full placeholder fits */
.al-table .al-links a { margin-right: 12px; white-space: nowrap; }

/* ---- Order journey (al-order + al-steps from the design system) ---- */
.al-order { cursor: default; border-bottom: 1px solid var(--border); }
.al-order:last-child { border-bottom: 0; }
.al-order-no a { color: var(--ink); text-decoration: none; }
.al-order-no a:hover { color: var(--brand-text); text-decoration: underline; }
.al-step small { display: block; font-size: 11px; line-height: 15px; color: var(--ink-muted); font-weight: 400; max-width: 140px; }
.al-order .al-table-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); }
.al-order .al-table th, .al-order .al-table td { padding: 10px 14px; }
.al-courier { display: inline-flex; align-items: center; gap: 6px; }
.al-courier img { height: 18px; }
@media (max-width: 720px) { .al-steps { grid-template-columns: 1fr; gap: 10px; } .al-steps::before, .al-steps-fill { display: none; }
  .al-step { justify-items: start; grid-template-columns: 24px 1fr; text-align: left; } .al-order-meta { margin-left: 0; } }

/* ---- Bars (top-10 lists) ---- */
.al-bars { list-style: none; margin: 0; padding: 18px 24px; display: grid; gap: 12px; }
.al-bars li { display: grid; grid-template-columns: minmax(8rem, 15rem) 1fr auto; gap: 14px; align-items: center; font-size: 13px; }
.al-bars .al-bars-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.al-bars .al-bars-value { font-variant-numeric: tabular-nums; font-weight: 600; }
@media (max-width: 560px) { .al-bars li { grid-template-columns: 1fr; gap: 4px; } }

/* ---- Sidebar entrance stagger (the design uses inline animation-delay; CSP-safe equivalent) ---- */
.al-sidebar > .al-nav-group:nth-of-type(1) > summary { animation-delay: 100ms; }
.al-sidebar > .al-nav-group:nth-of-type(2) > summary { animation-delay: 160ms; }
.al-sidebar > .al-nav-group:nth-of-type(3) > summary { animation-delay: 220ms; }
.al-sidebar > .al-nav-group:nth-of-type(4) > summary { animation-delay: 280ms; }
.al-sidebar-foot small { display: block; }
.al-logout-form { margin: 0; display: contents; }

/* ---- Welcome banner inner block, dealer picker, error page ---- */
.al-welcome-body { position: relative; }
.al-picker { display: grid; gap: 12px; padding: 20px 24px; max-width: 640px; }
.al-picker select { width: 100%; height: auto; padding: 8px; }
.al-error { max-width: 640px; }
.al-error .al-card-body p:last-child { margin-bottom: 0; }
.al-plain-list { margin: 0; padding: 18px 24px; list-style: none; display: grid; gap: 10px; }
.al-plain-list li { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.al-code { font-family: var(--font-mono); font-size: 12px; color: var(--ink-muted); }

@media print {
  .al-sidebar, .al-topbar, .al-filters, .al-pager, .al-page-actions, .al-welcome .al-aperture { display: none !important; }
  .al-card, .al-stat { box-shadow: none; }
}

/* ---- Clickable stat tiles (hold reasons) ---- */
a.al-stat { color: inherit; text-decoration: none; }
a.al-stat:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.al-content a.al-stat:not(.al-btn) { color: inherit; }
.al-seg .al-btn { height: 30px; }

/* ---- Workspace switcher: visible current item before/without JS (the sliding thumb takes over when ready) ---- */
.al-modules:not(.is-ready) a[aria-current="true"] { background: var(--brand-500); box-shadow: var(--shadow-brand); }

/* ---- Order/customer IDs inside links: no underline on the chip ---- */
.al-content a:has(> .al-id) { text-decoration: none; }
.al-content a:has(> .al-id):hover .al-id { border-color: var(--brand-text); color: var(--brand-text); }

/* ---- Keep dates and figures on one line; long text columns opt in with .al-wrap ---- */
.al-table td { white-space: nowrap; }
.al-table td.al-wrap { white-space: normal; }

/* ---- Live orders cards (reference layout) ---- */
.lo-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); box-shadow: var(--shadow-sm); overflow: hidden; }
.lo-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; padding: 16px 24px;
  background: var(--surface-raised); border-bottom: 1px solid var(--border); }
.lo-no { font-size: 15px; }
.lo-no span { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.lo-no a { font: 700 18px/1 var(--font-mono); color: var(--ink) !important; text-decoration: none; letter-spacing: .02em; }
.lo-no a:hover { color: var(--brand-text) !important; }
.lo-qty { font-size: 16px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.lo-qty b { font-size: 18px; } .lo-qty .is-full { color: var(--success); } .lo-qty .is-part { color: var(--warning); }
.lo-rpo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; padding: 12px 24px; background: var(--brand-50);
  border-bottom: 1px solid var(--border); font-weight: 700; color: var(--brand-text); text-transform: uppercase; letter-spacing: .02em; }
.lo-row { display: grid; grid-template-columns: 170px 1fr 170px; gap: 16px; align-items: center; padding: 20px 24px; }
.lo-row + .lo-row { border-top: 1px dashed var(--border); }
.lo-doc { display: grid; gap: 8px; justify-items: center; }
.lo-docno { font: 700 15px/1.2 var(--font-mono); color: var(--ink); word-break: break-all; text-align: center; }
.lo-muted { color: var(--ink-muted); font-weight: 500; }
.lo-track { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.lo-step { position: relative; display: grid; justify-items: center; gap: 4px; text-align: center; font-size: 14px; }
.lo-step::before { content: ""; position: absolute; top: 26px; left: -50%; width: 100%; height: 4px; background: var(--border); z-index: 0; }
.lo-step:first-child::before { display: none; }
.lo-step.is-done::before { background: var(--brand-500); }
.lo-dot { position: relative; z-index: 1; width: 54px; height: 54px; border-radius: 50%; display: grid; place-items: center;
  background: var(--surface-raised); border: 2px solid var(--border); color: var(--ink-muted); margin-bottom: 6px; }
.lo-step.is-done .lo-dot { background: var(--brand-500); border-color: var(--brand-500); color: var(--on-brand); }
.lo-step b { font-weight: 600; color: var(--ink); }
.lo-step:not(.is-done) b { color: var(--ink-muted); }
.lo-date { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.lo-courier { display: grid; justify-items: center; gap: 6px; font-size: 15px; text-align: center; }
.lo-courier img { width: 64px; height: 64px; object-fit: contain; border-radius: 50%; border: 1px solid var(--border); background: #fff; padding: 6px; }
.lo-courier-name { font-weight: 600; }
@media (max-width: 900px) {
  .lo-row { grid-template-columns: 1fr; }
  .lo-dot { width: 42px; height: 42px; } .lo-step::before { top: 20px; }
}

/* ---- Products pop-up ---- */
.lo-dialog { width: min(750px, calc(100vw - 32px)); max-height: 80vh; padding: 0; border: 1px solid var(--border);
  border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); box-shadow: var(--shadow-lg); }
.lo-dialog::backdrop { background: rgba(1, 47, 61, .45); }
.lo-dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 16px 20px; border-bottom: 1px solid var(--border); }
.lo-dialog-head h2 { margin: 0; font-size: 18px; }
.lo-dialog-head .al-icon-btn { font-size: 22px; line-height: 1; }
.lo-dialog-body { overflow: auto; max-height: calc(80vh - 70px); }
.lo-dialog .al-table tfoot th { padding: 12px var(--space-4); border-top: 2px solid var(--border); text-align: left; }
.lo-dialog .al-table tfoot .al-num { text-align: right; }

/* Products pop-up, as in the reference portal: 70/30 columns, sticky header, scale-in */
.lo-dialog-body { max-height: 65vh; }
.lo-products { font-size: 14px; }
.lo-products thead th { position: sticky; top: 0; z-index: 1; }
.lo-products .lo-col-product { width: 70%; } .lo-products .lo-col-qty { width: 30%; }
.lo-dialog[open] { animation: lo-scale-in .2s var(--al-ease); }
@keyframes lo-scale-in { from { transform: scale(.96); opacity: 0; } to { transform: scale(1); opacity: 1; } }

/* ---- Table toolbar: "Show N entries" ---- */
.al-table-toolbar { display: flex; justify-content: flex-start; padding: 14px 24px 0; }
.al-entries { margin: 0; }
.al-entries label { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.al-bs .al-entries select.form-control { min-width: 0; width: 76px; height: 36px; }

/* ---- Numbered pager: Page x of y · Previous 1 2 [3] 4 5 … 58 Next ---- */
.al-pager { flex-wrap: wrap; }
.al-pages { display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; flex-wrap: wrap; }
.al-pages a, .al-pages span { display: inline-grid; place-items: center; min-width: 44px; height: 44px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); color: var(--brand-text);
  font-size: 15px; text-decoration: none; transition: background var(--al-fast), border-color var(--al-fast); }
.al-pages a:hover { background: var(--brand-50); border-color: var(--brand-text); }
.al-pages a:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.al-pages .is-current { background: var(--brand-500); border-color: var(--brand-500); color: var(--on-brand); font-weight: 600; }
.al-pages .is-disabled { color: var(--ink-muted); opacity: .55; }
.al-pages .is-gap { border-color: transparent; background: none; color: var(--ink-muted); min-width: 32px; padding: 0 4px; }
.al-content .al-pages a:not(.al-btn) { color: var(--brand-text); }

/* ---- Finance header: title · filter · (right) Show N entries ---- */
.al-toolhead { display: flex; align-items: flex-end; gap: 16px 28px; flex-wrap: wrap; }
.al-toolhead h1 { margin: 0 0 6px; font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; }
.al-toolhead-filter { margin-left: auto; }
.al-toolhead-size { padding-bottom: 4px; }
.al-inline-filter { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; margin: 0; }
.al-inline-filter label { display: block; margin: 0 0 4px; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.al-bs .al-inline-filter .form-control { width: 160px; min-width: 0; height: 42px; }
.al-inline-filter .al-btn { height: 42px; }
@media (max-width: 720px) { .al-toolhead-filter { margin-left: 0; } }

/* ---- Sidebar keeps its width when several groups are open (no shrink when the menu scrolls) ---- */
.al-app > .al-sidebar { flex: 0 0 240px; width: 240px; min-width: 240px; overflow-x: hidden;
  scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.25) transparent; }  /* slim, only when the menu is taller than the screen */
.al-sidebar .al-nav-sub a, .al-sidebar .al-nav-item span { white-space: nowrap; }
@media (max-width: 991px) { .al-app > .al-sidebar { flex-basis: 240px; } }

/* ---- Live orders: RPO beside the order number; subtitle under the title in tool heads ---- */
.lo-no { display: flex; align-items: center; gap: 10px 24px; flex-wrap: wrap; }
.lo-rpo-inline { font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--brand-text) !important; }
.lo-rpo-inline b { font: 700 15px/1 var(--font-mono); letter-spacing: .02em; }
.al-toolhead-sub { margin: 0 0 6px; color: var(--ink-muted); }
.al-toolhead > div > h1 { margin: 0 0 4px; font-size: 24px; line-height: 32px; font-weight: 700; letter-spacing: -.01em; }
.al-inline-actions { display: flex; gap: 8px; }
.al-inline-actions .al-btn { height: 42px; }

/* ---- Compact table that fits the card width (Shipped orders) ---- */
.al-table--fit { table-layout: auto; width: 100%; }
.al-table--fit th { white-space: normal; padding: 10px 10px; line-height: 15px; vertical-align: bottom; }
.al-table--fit td { padding: 12px 10px; }
.al-table--fit th:first-child, .al-table--fit td:first-child { padding-left: 16px; }
.al-table--fit td:nth-child(5) { white-space: normal; min-width: 0; }
.al-table--fit .al-icon-btn { width: 34px; height: 34px; }
.al-table--fit th:nth-last-child(-n+2), .al-table--fit td:nth-last-child(-n+2) { text-align: center; }
.al-table--fit td:nth-last-child(-n+2) .al-icon-btn { margin: 0 auto; }

/* ---- Reset: small refresh-icon button beside Search / Apply ---- */
.al-reset { width: 42px; height: 42px; flex: none; color: var(--brand-text); }
.al-reset svg { transition: transform var(--al-med) var(--al-ease); }
.al-reset:hover svg { transform: rotate(-180deg); }

/* ---- Pointer spotlight (soft teal circle following the mouse) switched off for now.
        Delete this block and restore the pointermove handler in aurolab.js to bring it back. ---- */
.al-stat::before, .al-spot::before, .al-stock .kpi-card::after { display: none !important; }

/* ---- Clear button beside Search (small, text) ---- */
.al-clear { height: 42px; padding: 0 14px; font-size: 13px; }
.al-inline-filter .al-clear, .al-filter-actions .al-clear { height: 42px; }

/* ---- "Show N entries" at the bottom, left of the pager ---- */
.al-pager-info { display: inline-flex; align-items: center; gap: 20px; flex-wrap: wrap; }
.al-pager .al-entries label { font-size: 13px; color: var(--ink-muted); }

/* ---- One stat card (Outstanding) ---- */
.al-stats--single { grid-template-columns: minmax(260px, 360px); }
.al-stats--pair { grid-template-columns: repeat(2, minmax(260px, 360px)); }
@media (max-width: 720px) { .al-stats--pair { grid-template-columns: 1fr; } }

/* ---- Compact stat cards (Outstanding): same style for both, smaller size ---- */
.al-stats--compact { grid-template-columns: repeat(2, minmax(200px, 260px)); gap: 12px; }
.al-stats--compact .al-stat { padding: 12px 16px; gap: 2px; }
.al-stats--compact .al-stat-icon { width: 28px; height: 28px; }
.al-stats--compact .al-stat-icon svg { width: 15px; height: 15px; }
.al-stats--compact .al-stat-label { font-size: 11px; }
.al-stats--compact .al-stat-value { font-size: 22px; line-height: 28px; }
.al-stats--compact .al-stat-sub { font-size: 12px; line-height: 16px; }
.al-stats--compact .al-stat-ring { display: none; }
@media (max-width: 560px) { .al-stats--compact { grid-template-columns: 1fr; } }

/* ---- Compact cards that wrap (stock dashboard: 7 cards) ---- */
.al-stats--compact.al-stats--wrap { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.al-stats--compact .al-stat-formula { font: 500 11px/15px var(--font-mono); color: var(--ink-muted); margin-top: 4px; }

/* ---- Clickable stat card (Extended outstanding) ---- */
.al-stats a.al-stat { cursor: pointer; }
.al-stats a.al-stat.is-active { border-color: var(--brand-500); box-shadow: 0 0 0 2px var(--brand-500); }

/* ---- Filter bars: dropdowns share the row, Apply / Clear stay on the same line at the end ---- */
.al-filters { flex-wrap: nowrap; }
.al-filters > div:not(.al-filter-actions) { flex: 1 1 0; min-width: 0; }
.al-filters .form-control, .al-bs .al-filters select.form-control { width: 100%; min-width: 0; }
.al-filters .al-filter-actions { flex: none; }
@media (max-width: 900px) {
  .al-filters { flex-wrap: wrap; }
  .al-filters > div:not(.al-filter-actions) { flex: 1 1 160px; }
}

/* RGA > New request (line table, lot lookup, done dialog) */
.rga-card { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.rga-tbl-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); overflow: auto; }
.rga-tbl { width: 100%; table-layout: fixed; margin: 0; }
.rga-tbl tbody tr { animation: none; }
.rga-tbl tbody tr:hover { background: transparent; }
.rga-tbl th { white-space: normal; padding: 12px 8px; }
.rga-tbl td { vertical-align: middle; padding: 10px 8px; white-space: normal; overflow-wrap: anywhere; }
.rga-tbl [data-f="product"] { display: block; line-height: 1.4; }
.rga-status td.rga-wrap { white-space: normal; overflow-wrap: anywhere; min-width: 180px; max-width: 280px; }
.rga-tbl .form-control { width: 100%; min-width: 0; padding-left: 10px; padding-right: 10px; }
.rga-c-sno { width: 52px; text-align: center; }
.rga-c-lot { width: 12%; }
.rga-c-serial { width: 7%; }
.rga-c-prod { width: 18%; }  /* product name wraps inside this width */
.rga-c-invdt { width: 9%; }  /* invoice date */
.rga-c-inv { width: 19%; }   /* invoice no / type on one line, e.g. ALFDI252620239 - Sales */
.rga-c-qty { width: 7%; }
.rga-c-cond { width: 10%; }  /* just the condition badge: no wide gap before the × */
.rga-c-exp { width: 11%; }
.rga-tbl [data-f="invdate"], .rga-tbl [data-f="expiry"] { white-space: nowrap; }  /* dates on one line */
.rga-tbl [data-f="invoice"] { white-space: nowrap; }
.rga-c-act { width: 40px; text-align: center; }
@media (max-width: 900px) { .rga-tbl { min-width: 860px; } }
.rga-c-act .al-icon-btn { width: 28px; height: 28px; margin: 0 auto; font-size: 16px; line-height: 1; }
.rga-c-act .al-icon-btn:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.rga-c-act .al-icon-btn[hidden] { display: none; }
.rga-tbl th.rga-c-act, .rga-tbl td.rga-c-act { padding-left: 4px; padding-right: 4px; }
.rga-qty { text-align: center; }
.rga-sno { width: 30px; height: 30px; border-radius: 999px; background: var(--brand-100); color: var(--brand-text);
  display: inline-grid; place-items: center; font-weight: 700; font-size: 13px; }
.rga-mono { font-family: var(--font-mono); }
.rga-dim { color: var(--ink-muted); }
.rga-strong { font-weight: 600; color: var(--ink); }
.rga-bad { color: var(--danger); font-weight: 500; }
.rga-err { color: var(--danger); font-size: 14px; }
.rga-tbl input.is-ok { border-color: var(--success); }
.rga-tbl input.is-bad, .rga-dup input[name="lot"] { border-color: var(--danger); }
.rga-row { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.rga-submit { border-top: 1px solid var(--border); padding-top: 20px; }
.lo-dialog.rga-dialog { width: min(400px, calc(100vw / var(--page-zoom, 1) - 32px)); border-radius: 18px; }
.rga-done-body { padding: 28px 24px 24px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.rga-done-body h2 { margin: 10px 0 6px; font: 700 19px var(--font-display); color: var(--ink); }
.rga-done-body p { margin: 0; max-width: 320px; font-size: 13px; line-height: 1.5; }
.rga-done-icon { width: 68px; height: 68px; border-radius: 999px; background: var(--success-soft); color: var(--success);
  display: inline-grid; place-items: center; }
.rga-done-no { margin-top: 14px; padding: 4px 14px; border-radius: 999px; border: 1px solid var(--success);
  background: var(--success-soft); color: var(--success); font: 700 16px var(--font-mono); letter-spacing: .04em; }
.rga-status tr.rga-new td { background: var(--brand-50); }
.rga-done-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 20px; }
.rga-done-actions .al-btn { min-width: 76px; }
/* Animated tick: the circle pops in, then the check mark draws itself (replayed each time the dialog opens). */
.rga-dialog[open] .rga-done-icon { animation: rga-pop .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.rga-tick { stroke-dasharray: 48; stroke-dashoffset: 48; }
.rga-dialog[open] .rga-tick { animation: rga-draw .5s .3s ease-out forwards; }
.rga-dialog[open] .rga-done-no { animation: rga-fade .4s .55s ease-out both; }
@keyframes rga-pop { from { transform: scale(.3); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes rga-draw { to { stroke-dashoffset: 0; } }
@keyframes rga-fade { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) {
  .rga-dialog[open] .rga-done-icon, .rga-dialog[open] .rga-done-no { animation: none; }
  .rga-tick, .rga-dialog[open] .rga-tick { animation: none; stroke-dashoffset: 0; }
}

/* Four cards in one row (Finance > Outstanding); 2 per row on tablets, 1 on phones */
.al-stats--row4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.al-stats--row4 .al-stat-ring { display: none; }
@media (max-width: 1100px) { .al-stats--row4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .al-stats--row4 { grid-template-columns: 1fr; } }

/* ---- Page scale: 100% browser zoom looks like the former 90% (everything 10% smaller) ----
   Change --page-zoom to adjust. Full-screen heights are divided by it so they still fill the window. */
:root { --page-zoom: 0.9; }
html { zoom: var(--page-zoom); }
body.al-bs, .al-app { min-height: calc(100vh / var(--page-zoom)); }
.al-app > .al-sidebar { height: calc(100vh / var(--page-zoom)); }
.lo-dialog { width: min(750px, calc(100vw / var(--page-zoom) - 32px)); max-height: calc(80vh / var(--page-zoom)); }
.lo-dialog-body { max-height: calc(65vh / var(--page-zoom)); }

/* RGA > Approvals (ASM / ZSM / NSM) */
.rga-tabs { margin-bottom: 16px; }
.rga-appr { padding: 18px 20px; display: flex; flex-direction: column; gap: 14px; }
.rga-appr-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.rga-appr-head > div { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rga-appr-dealer { font-size: 15px; color: var(--ink); }
.rga-appr-meta { font-size: 13px; }
.rga-trail { list-style: none; margin: 0; padding: 0 0 0 14px; border-left: 2px solid var(--border); display: grid; gap: 6px; font-size: 13px; }
.rga-trail li { position: relative; }
.rga-trail li::before { content: ""; position: absolute; left: -20px; top: 5px; width: 10px; height: 10px; border-radius: 50%;
  background: var(--brand-500); box-shadow: 0 0 0 2px var(--surface); }
.rga-trail .rga-trail-rejected::before { background: var(--danger); }
.rga-trail .rga-trail-approved::before { background: var(--success); }
.rga-trail .rga-trail-next { color: var(--ink-muted); font-style: italic; }
.rga-trail .rga-trail-next::before { background: var(--surface); border: 2px dashed var(--ink-muted); width: 6px; height: 6px; }
.rga-trail-remarks { color: var(--ink-muted); margin-top: 2px; }
.rga-act { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--border); padding-top: 14px; }
.rga-act-remarks { flex: 1 1 280px; }
.rga-act-remarks .form-control { width: 100%; min-width: 0; height: 36px; }
.rga-act .rga-reject:hover { border-color: var(--danger); color: var(--danger); background: var(--danger-soft); }
.rga-appr-pager { padding: 8px 16px; }

/* Select a dealer (ASM / ZSM / NSM / admin): searchable table */
.dp-card { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.dp-head { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.dp-search { flex: 1 1 320px; max-width: 520px; }
.dp-wrap { border: 1px solid var(--border); border-radius: var(--radius-md); }  /* the page scrolls, not the list */
.dp-table { margin: 0; }
.dp-table td { padding-top: 10px; padding-bottom: 10px; }
.dp-c-no { width: 64px; color: var(--ink-muted); }
.dp-c-act { width: 1%; text-align: right; }
.dp-name { color: var(--ink); font-weight: 600; text-decoration: none; }
.dp-name:hover { color: var(--brand-text); text-decoration: underline; }
.dp-none { margin: 0; text-align: center; padding: 12px; }

/* RGA > Approvals: per-line Approve / Reject, then Submit */
.rga-pick { display: inline-flex; gap: 8px; }
.rga-pick label { position: relative; cursor: pointer; }
.rga-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.rga-pick span { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 14px; border-radius: 8px;
  border: 1.5px solid; background: var(--surface); font-size: 12px; font-weight: 700; white-space: nowrap;
  transition: background var(--al-fast), color var(--al-fast), box-shadow var(--al-fast); }
.rga-pick input:focus-visible + span { box-shadow: var(--shadow-focus); }
/* Approve: green outline, filled green when chosen */
.rga-pick-ok span { border-color: var(--success); color: var(--success); }
.rga-pick-ok span::before { content: "\2713"; }
.rga-pick-ok:hover span { background: var(--success-soft); }
.rga-pick-ok input:checked + span { background: var(--success); border-color: var(--success); color: #fff; }
/* Reject: red outline, filled red when chosen */
.rga-pick-no span { border-color: var(--danger); color: var(--danger); }
.rga-pick-no span::before { content: "\2715"; }
.rga-pick-no:hover span { background: var(--danger-soft); }
.rga-pick-no input:checked + span { background: var(--danger); border-color: var(--danger); color: #fff; }
.rga-lines-tbl tr.rga-line-ok td { background: color-mix(in srgb, var(--success-soft) 60%, transparent); }
.rga-lines-tbl tr.rga-line-no td { background: color-mix(in srgb, var(--danger-soft) 60%, transparent); }
.rga-lines-tbl tr.rga-line-closed td { color: var(--ink-muted); }
.rga-lines-tbl .rga-line-remarks { width: 100%; min-width: 180px; height: 34px; }
.rga-lines-tbl .rga-line-remarks:required { border-color: var(--danger); }
.rga-reason { margin-top: 4px; font-size: 12px; color: var(--danger); white-space: normal; max-width: 260px; }
.rga-decide { display: flex; flex-direction: column; gap: 12px; }
.rga-decide-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--border); padding-top: 12px; font-size: 13px; }
.rga-trail-box summary { cursor: pointer; font-size: 13px; font-weight: 600; color: var(--brand-text); margin-bottom: 8px; }

/* RGA: one summary row per request (Approvals + Request status); click to show its lines */
.rga-req { padding: 0; gap: 0; margin-bottom: 12px; }
.rga-req > summary { list-style: none; cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  gap: 12px; flex-wrap: wrap; padding: 14px 20px; border-radius: inherit; }
.rga-req > summary::-webkit-details-marker { display: none; }
.rga-req > summary:hover { background: var(--surface-raised); }
.rga-req > summary:focus-visible { outline: none; box-shadow: var(--shadow-focus); }
.rga-req-main, .rga-req-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rga-req-meta { font-size: 13px; }
.rga-req-products { color: var(--ink); font-weight: 500; }
.rga-chev { color: var(--ink-muted); transition: transform var(--al-fast); }
.rga-req[open] > summary .rga-chev { transform: rotate(180deg); }
.rga-req[open] > summary { border-bottom: 1px solid var(--border); border-bottom-left-radius: 0; border-bottom-right-radius: 0; }
.rga-req[open] > :not(summary) { margin: 14px 20px; }
.rga-req[open] > .rga-decide > .al-table-wrap, .rga-req[open] > .al-table-wrap { margin-top: 14px; }
.rga-req.rga-new > summary { background: var(--brand-50); }

/* Sticky table headers stay on top while scrolling: rows animate in (transform), which would otherwise paint
   them over the header. Solid background so nothing shows through (brand-50 over the card surface). */
.al-table thead th { z-index: 3; background: linear-gradient(var(--brand-50), var(--brand-50)), var(--surface); }
.dp-wrap .dp-table thead th { top: 0; box-shadow: inset 0 -1px 0 var(--border); }

/* RGA > Approvals: send button follows the choices; red when every line is rejected */
.rga-send:disabled { opacity: .55; cursor: not-allowed; box-shadow: none; }
.al-btn.rga-send--reject { background: var(--danger); border-color: var(--danger); color: #fff; }
.al-btn.rga-send--reject:hover { filter: brightness(.92); }

/* RGA > Approvals: table of requests + pop-up per request */
.rga-c-action { width: 1%; text-align: right; white-space: nowrap; }
.lo-dialog.rga-dlg { width: min(1180px, calc(100vw / var(--page-zoom, 1) - 32px)); max-height: calc(88vh / var(--page-zoom, 1)); }
.rga-dlg .lo-dialog-head { align-items: flex-start; }
.rga-dlg-title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rga-dlg-title h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 17px; }
.rga-dlg-title > .al-muted { font-size: 13px; }
.rga-dlg .lo-dialog-body.rga-dlg-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 14px;
  max-height: calc(88vh / var(--page-zoom, 1) - 80px); }

/* RGA > Approved requests (support team) */
.rga-support-bar { display: flex; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.rga-support-bar .al-inline-filter { margin-left: auto; }
.rga-support-export { align-self: flex-end; height: 42px; display: inline-flex; align-items: center; gap: 6px; }
.rga-c-action .al-btn + .al-btn { margin-left: 6px; }
.rga-sup-chain { margin: 0; font-size: 13px; }
.rga-sup-done { margin: 0; display: flex; align-items: center; gap: 6px; color: var(--success); font-weight: 600; font-size: 14px; }
.rga-sup-remarks { flex: 1 1 280px; min-width: 0; height: 36px; }

/* RGA > New request: serial no comes only from the scanned barcode (read-only) */
.rga-tbl .rga-serial { cursor: default; }
.rga-tbl .rga-serial:focus { box-shadow: none; }

/* Live orders: courier logo card (opens tracking) with the AWB underneath */
.lo-courier-card { position: relative; display: grid; place-items: center; width: 150px; height: 58px; padding: 8px 22px 8px 12px;
  box-sizing: border-box; border: 1.5px solid var(--border-strong, var(--border)); border-radius: 12px; background: #fff;
  text-decoration: none; transition: border-color var(--al-fast), box-shadow var(--al-fast); }
a.lo-courier-card:hover { border-color: var(--brand-500); box-shadow: var(--shadow-sm); }
.lo-courier .lo-courier-card img { width: 100%; height: 100%; max-height: 40px; object-fit: contain; border: 0; border-radius: 0;
  padding: 0; background: none; }
.lo-courier-ext { position: absolute; top: 6px; right: 6px; color: var(--ink-muted); line-height: 0; }
.lo-courier-card .lo-courier-name { color: #0f2a33; font-weight: 700; font-size: 13px; }
.lo-awb { font: 600 12px var(--font-mono); color: var(--brand-text); letter-spacing: .02em; }
a.lo-awb { text-decoration: underline; text-underline-offset: 3px; }

/* Finance > Ledger: opening balance as one centred, bold row */
.al-table tr.ledger-opening td { text-align: center; font-weight: 700; color: var(--ink);
  font-variant-numeric: tabular-nums; }
/* Grand total row at the foot of the Ledger / Payments tables (whole date range) */
.al-table tr.al-grand-total td { font-weight: 700; color: var(--ink); border-top: 2px solid var(--border);
  font-variant-numeric: tabular-nums; }

/* ---- Live orders: one row per shipment: document | Booked (first row) + fork | Pick, Invoice, Despatch | courier ----
   Each step box is the dot only (40px); its label and date hang below, so dots and lines sit on the row's centre
   line. Rows have a fixed height, so the fork (a vertical line just right of Booked) runs from one row's centre
   to the next. */
.lo-flow { --lo-row: 120px; --lo-dot: 40px; --lo-line: 3px; --lo-fork-x: 108px; padding: 4px 20px 10px; }
.lo-flow .lo-step { height: var(--lo-dot); align-self: center; gap: 0; font-size: 13px; }
.lo-flow .lo-step b, .lo-flow .lo-step .lo-date { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.lo-flow .lo-step b { top: calc(var(--lo-dot) + 5px); font-size: 13px; }
.lo-flow .lo-step .lo-date { top: calc(var(--lo-dot) + 23px); font-size: 12px; }
.lo-flow .lo-dot { width: var(--lo-dot); height: var(--lo-dot); border-width: 2px; }
.lo-flow .lo-dot svg { width: 16px; height: 16px; }
.lo-flow .lo-step::before { top: calc(var(--lo-dot) / 2 - var(--lo-line) / 2); height: var(--lo-line); }

.lo-branch { position: relative; height: var(--lo-row); display: grid; align-items: center;
  grid-template-columns: 150px 120px minmax(0, 1fr) 160px; }
.lo-branch + .lo-branch { background-image: linear-gradient(90deg, var(--border) 50%, transparent 0); background-size: 8px 1px;
  background-repeat: repeat-x; background-position: 150px 0; }
.lo-branch .lo-doc { gap: 6px; padding-right: 12px; }
.lo-branch .lo-docno { font-size: 14px; }
.lo-branch .lo-courier { gap: 4px; padding-left: 12px; }
.lo-branch .lo-courier-card { width: 140px; height: 52px; }

/* Booked (first row): dot near the left of its column, a line from it to the end of the column */
.lo-fork { position: relative; align-self: stretch; }
.lo-fork .lo-step { position: absolute; left: 22px; top: calc(50% - var(--lo-dot) / 2); width: var(--lo-dot); }
.lo-fork .lo-step::before { display: none; }
.lo-branch.is-first .lo-fork::after { content: ""; position: absolute; top: calc(50% - var(--lo-line) / 2);
  left: calc(22px + var(--lo-dot)); right: 0; height: var(--lo-line); background: var(--brand-500); }
/* further rows: a vertical line from the previous row's centre down to this one, then right into Pick */
.lo-branch:not(.is-first) .lo-fork::before { content: ""; position: absolute; left: var(--lo-fork-x);
  top: calc(var(--lo-line) / 2 - var(--lo-row) / 2); height: var(--lo-row); width: var(--lo-line); background: var(--brand-500); }
.lo-branch:not(.is-first) .lo-fork::after { content: ""; position: absolute; top: calc(50% - var(--lo-line) / 2);
  left: var(--lo-fork-x); right: 0; height: var(--lo-line); background: var(--brand-500); }

/* Pick, Invoice, Despatch: the first line runs from the start of the track into the Pick dot */
.lo-branch .lo-track { grid-template-columns: repeat(3, 1fr); align-self: stretch; align-items: center; }
.lo-branch .lo-step:first-child::before { display: block; left: 0; width: calc(50% - var(--lo-dot) / 2); background: var(--border); }
.lo-branch .lo-step.is-done:first-child::before { background: var(--brand-500); }

@media (max-width: 1100px) {
  .lo-branch { grid-template-columns: 130px 112px minmax(0, 1fr) 145px; }
  .lo-branch .lo-courier-card { width: 128px; }
}
@media (max-width: 900px) {  /* phones / narrow: each shipment stacks, no fork */
  .lo-flow { padding: 8px 14px 14px; }
  .lo-branch { height: auto; grid-template-columns: 1fr; gap: 10px; padding: 12px 0 18px; }
  .lo-fork { height: 84px; } .lo-branch:not(.is-first) .lo-fork { display: none; }
  .lo-fork::before, .lo-fork::after { display: none; }
  .lo-branch .lo-track { height: 84px; align-items: start; }
  .lo-branch .lo-step:first-child::before { display: none; }
}


/* Tables in half-width cards (stock dashboard "By division", Items by stock status…): tighter cells so they fit
   the card without a horizontal scrollbar */
.al-grid-2 .al-table { width: 100%; font-size: 13px; }
.al-grid-2 .al-table th { padding: 10px 10px; white-space: normal; }
.al-grid-2 .al-table td { padding: 10px 10px; }
.al-grid-2 .al-table th:first-child, .al-grid-2 .al-table td:first-child { padding-left: 16px; }
.al-grid-2 .al-table th:last-child, .al-grid-2 .al-table td:last-child { padding-right: 16px; }
.al-grid-2 .al-table .al-div { padding: 2px 8px; font-size: 12px; }

/* Pop-ups: rows appear at once (the slide-in made the body a few px taller than its box -> scrollbar) */
.lo-dialog .al-table tbody tr { animation: none; }
.lo-dialog-body.is-fit { overflow-y: hidden; }

/* Table boxes scroll sideways only when a table is really wider than its card; they never scroll up/down (the
   page does). Without this, overflow-x: auto also turns on vertical scrolling and a 1-2px rounding overflow (90%
   page scale, rows sliding in) shows a vertical scrollbar. */
.al-table-wrap { overflow-y: hidden; }

/* ---- Dealer home ---- */
.al-welcome-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 14px; position: relative; }
.hd-progress { font-variant-numeric: tabular-nums; color: var(--ink-muted); font-size: 13px; }
.hd-progress .is-full { color: var(--success); } .hd-progress .is-part { color: var(--warning); }
.hd-despatch { list-style: none; margin: 0; padding: 0 20px 16px; display: grid; gap: 4px; }
.hd-despatch li { display: grid; grid-template-columns: 110px minmax(0, 1fr) auto; align-items: center; gap: 14px;
  padding: 10px 0; border-bottom: 1px solid var(--border); }
.hd-despatch li:last-child { border-bottom: 0; }
.hd-courier { display: grid; place-items: center; height: 40px; padding: 4px 8px; border: 1px solid var(--border);
  border-radius: 10px; background: #fff; font-size: 12px; color: #0f2a33; text-align: center; }
.hd-courier img { max-width: 100%; max-height: 30px; object-fit: contain; }
.hd-despatch-doc { display: grid; gap: 2px; font-size: 13px; min-width: 0; }
.hd-figures { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; padding: 4px 20px 16px; }
.hd-figures > div { display: grid; gap: 2px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--surface-raised); }
.hd-figures span { font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted); }
.hd-figures b { font: 700 20px var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums; }
.hd-figures small { font-size: 12px; color: var(--ink-muted); }
.hd-expiry { margin: 0 20px 16px; text-decoration: none; }
.hd-links { display: flex; flex-wrap: wrap; gap: 8px 18px; padding: 12px 20px 16px; border-top: 1px solid var(--border); }
.hd-links a { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600; color: var(--brand-text); text-decoration: none; }
.hd-links a:hover { text-decoration: underline; }

/* Dealer home banner: all three buttons plain (glass); the teal fill only on hover / keyboard focus */
.al-welcome-actions .al-btn--glass:hover, .al-welcome-actions .al-btn--glass:focus-visible {
  background: var(--secondary); border-color: var(--secondary); color: var(--on-secondary);
  box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Half-width cards (dealer home Orders, …): long status badges ("Received – processing") may wrap and ID chips
   are a little smaller, so the table fits the card without a horizontal scrollbar */
.al-grid-2 .al-table .al-badge { white-space: normal; height: auto; min-height: 24px; padding-top: 2px; padding-bottom: 2px;
  line-height: 1.25; text-align: left; }
.al-grid-2 .al-table .al-id { font-size: 12px; padding: 2px 6px; }
.al-grid-2 .al-table th, .al-grid-2 .al-table td { padding-left: 8px; padding-right: 8px; }
.al-grid-2 .al-table th:first-child, .al-grid-2 .al-table td:first-child { padding-left: 16px; }
.al-grid-2 .al-table th:last-child, .al-grid-2 .al-table td:last-child { padding-right: 16px; }
.hd-progress { white-space: nowrap; }

/* ---- Dealer home: card rows are plain and take the dark teal (hero) look on hover; each card is a link ---- */
.hd-cards .al-stat { transition: transform var(--al-med) var(--al-ease), box-shadow var(--al-med) var(--al-ease),
  background-color var(--al-med), border-color var(--al-med); }
.hd-cards .al-stat::after { content: ""; position: absolute; inset: 0; z-index: -1; opacity: 0; transition: opacity var(--al-med);
  background: radial-gradient(120% 90% at 100% 0%, rgba(27,177,175,.35), transparent 60%),
              radial-gradient(90% 90% at 0% 100%, rgba(1,100,129,.6), transparent 60%); }
.hd-cards .al-stat:hover, .hd-cards .al-stat:focus-visible { background: var(--stage); border-color: transparent; color: var(--stage-ink); }
.hd-cards .al-stat:hover::after, .hd-cards .al-stat:focus-visible::after { opacity: 1; }
.hd-cards .al-stat:hover .al-stat-value, .hd-cards .al-stat:focus-visible .al-stat-value { color: #ffffff; }
.hd-cards .al-stat:hover .al-stat-label, .hd-cards .al-stat:hover .al-stat-sub,
.hd-cards .al-stat:focus-visible .al-stat-label, .hd-cards .al-stat:focus-visible .al-stat-sub { color: var(--stage-muted); }
.hd-cards .al-stat:hover .al-stat-icon, .hd-cards .al-stat:focus-visible .al-stat-icon { background: var(--secondary); color: var(--on-secondary); }
.al-grid-2.hd-one { grid-template-columns: minmax(0, 1fr); }
.al-stats.hd-cards + .hd-expiry { margin: 0; }

/* ---- Support > Approved requests: fit the card width (no horizontal scrollbar) ---- */
#rga-sup-table { width: 100%; }
#rga-sup-table th, #rga-sup-table td { padding-left: 10px; padding-right: 10px; }
#rga-sup-table th { white-space: normal; }
#rga-sup-table th:first-child, #rga-sup-table td:first-child { padding-left: 20px; }
#rga-sup-table th:last-child, #rga-sup-table td:last-child { padding-right: 20px; }
#rga-sup-table td.rga-wrap { min-width: 140px; max-width: 240px; }
#rga-sup-table .rga-c-action .al-btn { height: 32px; padding: 0 12px; gap: 4px; }

/* ---- Stock filters in the page header (or their own row): boxes only, no card / background / border ---- */
.al-filters.al-filters--inline { padding: 0; border: 0; background: none; flex-wrap: wrap; justify-content: flex-end; }
.al-filters--inline .form-control { min-width: 170px; }
.al-page-head .al-page-actions:has(.al-filters--inline) { margin-left: auto; }
.al-filter-row { display: flex; justify-content: flex-end; }
/* Filters and the page's own buttons (e.g. Download full CSV) share one line, bottom-aligned */
.al-page-actions:has(.al-filters--inline) { display: flex; align-items: flex-end; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.al-page-actions:has(.al-filters--inline) > .al-btn { height: 42px; }
/* Finance tables: "Showing 1–10 of 57 entries" next to the page number */
.al-pager-count { color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.al-pager-count b { color: var(--ink); }
/* Pager stays on one line: "Show / Showing x–y of N / Page" on the left, page buttons on the right.
   (The count made the left side wider, so the buttons used to wrap to a second line on many-page tables.) */
.al-pager { flex-wrap: nowrap; }
.al-pager .al-pager-info { flex: 1 1 auto; min-width: 0; gap: 8px 16px; }
.al-pager .al-pages { flex: none; flex-wrap: nowrap; margin-left: auto; }
.al-pager .al-pages a, .al-pager .al-pages span { min-width: 40px; height: 40px; padding: 0 12px; }
@media (max-width: 1100px) { .al-pager { flex-wrap: wrap; } .al-pager .al-pages { flex-wrap: wrap; } }

/* ---- Pending orders: search box in the reason card's header ---- */
.hold-search { display: flex; align-items: center; gap: 8px; margin: 0 0 0 auto; flex-wrap: wrap; }
.hold-search .al-search { width: 340px; max-width: 100%; }
.hold-search .al-btn { height: 42px; }
/* No browser "×" clear button inside search boxes (Edge / Chrome); the pages have their own Clear buttons */
input[type="search"]::-webkit-search-cancel-button, input[type="search"]::-webkit-search-decoration { -webkit-appearance: none; appearance: none; display: none; }
input[type="search"]::-ms-clear { display: none; width: 0; height: 0; }

/* ---- Dealer home: credit limit + the four outstanding cards in one row (4 when no credit limit is found) ---- */
.al-stats--row5 { grid-auto-flow: column; grid-auto-columns: minmax(0, 1fr); grid-template-columns: none; }
.al-stats--row5 .al-stat-ring { display: none; }
.al-stats--row5 .al-stat { padding: 16px 18px; }
.al-stats--row5 .al-stat-value { font-size: 24px; line-height: 30px; white-space: nowrap; }
@media (max-width: 1250px) { .al-stats--row5 { grid-auto-flow: row; grid-template-columns: repeat(3, minmax(0, 1fr)); } }
@media (max-width: 800px) { .al-stats--row5 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .al-stats--row5 { grid-template-columns: 1fr; } }

/* ---- Live orders: "On hold: …" badge – solid orange so it stands out from the status / progress text ---- */
.al-badge.lo-hold { --hold-bg: #bd4833; --hold-ink: #ffffff; display: inline-flex; align-items: center; gap: 6px;
  background: var(--hold-bg); color: var(--hold-ink); border: 1px solid var(--hold-bg); font-weight: 700; }
.al-badge.lo-hold::before { display: none; }  /* the icon replaces the dot */
.al-badge.lo-hold svg { flex: none; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .al-badge.lo-hold { --hold-bg: #bd4833; --hold-ink: #ffffff; } }
:root[data-theme="dark"] .al-badge.lo-hold { --hold-bg: #bd4833; --hold-ink: #ffffff; }

/* ---- Pending orders: a reason with no lines is shown at 0, muted and not clickable ---- */
.al-stat.hold-zero { opacity: .6; box-shadow: none; }
.al-stat.hold-zero:hover { transform: none; box-shadow: none; border-color: var(--border); }
.al-stat.hold-zero:hover::before { opacity: 0; }

/* ---- Dealer home: credit limit warning – edge to edge in the gap under the top bar: a fixed red
   "Credit limit exceeded" label, then the details running right to left on a light red band. Hover pauses it. ---- */
.hd-credit-alert { display: flex; align-items: stretch; overflow: hidden; margin: -28px -32px -4px; min-height: 44px;
  background: #fde8e7; text-decoration: none; font-size: 14px; font-weight: 700; }
.hd-credit-alert-tag { flex: none; display: inline-flex; align-items: center; gap: 8px; padding: 0 18px;
  background: #ba161c; color: #ffffff; white-space: nowrap; }
.hd-credit-alert-run { flex: 1 1 auto; min-width: 0; overflow: hidden; display: flex; align-items: center; }
/* colour on the track, not the link, so the generic content-link colour cannot override it */
.hd-credit-alert-track { display: flex; width: max-content; color: #ba161c; animation: hd-credit-run 28s linear infinite; }
.hd-credit-alert-track > span { padding: 0 64px 0 32px; white-space: nowrap; }
.hd-credit-alert:hover .hd-credit-alert-track { animation-play-state: paused; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .hd-credit-alert { background: #4a2a2e; }
  :root:not([data-theme="light"]) .hd-credit-alert-track { color: #ffb4b0; } }
:root[data-theme="dark"] .hd-credit-alert { background: #4a2a2e; }
:root[data-theme="dark"] .hd-credit-alert-track { color: #ffb4b0; }
@media (max-width: 560px) { .hd-credit-alert { margin: -20px -16px -4px; } }
@keyframes hd-credit-run { to { transform: translateX(-50%); } }
/* No motion requested: show the message still, wrapped */
@media (prefers-reduced-motion: reduce) {
  .hd-credit-alert-track { animation: none; width: auto; }
  .hd-credit-alert-track > span { white-space: normal; padding: 8px 16px; }
  .hd-credit-alert-track > span[aria-hidden] { display: none; }
}

/* ---- Live orders: order value in the order header, before the shipped / ordered qty (same look as RPO no) ---- */
.lo-qty .lo-value { margin-right: 24px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase;
  color: var(--brand-text); }
.lo-qty .lo-value b { font: 700 15px/1 var(--font-mono); letter-spacing: .02em; color: var(--ink); }

/* ---- Live orders: order header on one line (order no · RPO · on-hold badge … order value · qty) ---- */
.lo-head { flex-wrap: nowrap; }
.lo-head .lo-no { flex-wrap: nowrap; gap: 10px 18px; min-width: 0; }
.lo-head .lo-no > * { white-space: nowrap; }
.lo-head .lo-qty { flex: none; white-space: nowrap; }
.lo-qty .lo-value { margin-right: 16px; }
@media (max-width: 1200px) { .lo-head, .lo-head .lo-no { flex-wrap: wrap; } }
/* Shipment no under the invoice no */
.lo-shipno { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-muted);
  text-align: center; }
.lo-shipno b { font: 600 12px/1.2 var(--font-mono); letter-spacing: 0; text-transform: none; color: var(--ink); }

/* ---- Pop-ups (Products, RGA, ...): while one is open the page behind does not scroll; scrolling inside the
   pop-up stays inside it ---- */
html:has(dialog[open]) { overflow: hidden; }  /* html only: locking body too made it the scroll box and hid the sticky side menu */
/* only the pop-up and its scrolling body stop the scroll; on every element, the table box (a sideways scroller)
   swallowed the mouse wheel, so a long list of lines could not be scrolled */
dialog[open], dialog[open] .lo-dialog-body { overscroll-behavior: contain; }
/* Products pop-up: total qty on the right of the header, before the close button */
.lo-dialog-total { margin-left: auto; margin-right: 12px; padding: 7px 14px; border-radius: 6px;
  background: var(--brand-500); color: var(--on-brand); font-size: 13px; font-weight: 700; letter-spacing: .04em;
  text-transform: uppercase; white-space: nowrap; font-variant-numeric: tabular-nums; box-shadow: var(--shadow-sm); }

/* ---- Live orders: three-column order header – order value | order no + RPO no | hold badge, quantity, bar ---- */
.lo-head.lo-head3 { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center;
  gap: 8px 32px; padding: 10px 24px; flex-wrap: nowrap; }  /* slimmer header band */
.lo-head3 .lo-h-label { display: block; font-size: 14px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase;
  color: var(--ink-muted); }
/* left: order value */
.lo-head3 .lo-h-value { display: grid; gap: 2px; justify-items: start; }
.lo-head3 .lo-h-value b { font: 700 15px/1.2 var(--font-display); color: var(--ink); font-variant-numeric: tabular-nums;
  white-space: nowrap; }
/* centre: order no, RPO no under it */
.lo-head3 .lo-h-order { display: grid; gap: 2px; justify-items: center; text-align: center; }
.lo-head3 .lo-h-order > a { font: 700 18px/1.2 var(--font-display); color: var(--ink) !important; text-decoration: none;
  letter-spacing: .01em; white-space: nowrap; }
.lo-head3 .lo-h-order > a:hover { color: var(--brand-text) !important; }
.lo-head3 .lo-h-rpo { display: inline-flex; align-items: baseline; gap: 10px; }
.lo-head3 .lo-h-rpo .lo-h-label { display: inline; }
.lo-head3 .lo-h-rpo b { font: 700 14px/1.2 var(--font-display); color: var(--brand-text); }
/* right: hold badge on top, quantity line, progress bar */
.lo-head3 .lo-h-qty { display: grid; gap: 6px; justify-items: end; justify-self: end; min-width: 0; max-width: 100%; }
.lo-head3 .lo-h-qty .lo-hold { justify-self: end; height: auto; max-width: 100%; white-space: normal; text-align: left;
  line-height: 1.35; padding: 5px 14px; font-size: 14px; letter-spacing: .04em;
  text-transform: uppercase; }
.lo-head3 .lo-h-qtyline { display: flex; align-items: baseline; justify-content: flex-end; gap: 16px;
  font-size: 16px; color: var(--ink-muted); white-space: nowrap; }
.lo-head3 .lo-h-qtyline b { color: var(--ink); font-variant-numeric: tabular-nums; }
.lo-head3 .lo-h-pct { font-size: 18px; }
.lo-head3 .lo-h-pct.is-full { color: var(--success); } .lo-head3 .lo-h-pct.is-part { color: #a16207; }
.lo-head3 .lo-h-bar { height: 8px; border-radius: 999px; background: var(--border); overflow: hidden; }
.lo-head3 .lo-h-bar i { display: block; height: 100%; width: var(--v, 0%); border-radius: inherit;
  transition: width .6s var(--al-ease); }
.lo-head3 .lo-h-bar.is-part i { background: #d4952b; } .lo-head3 .lo-h-bar.is-full i { background: var(--success); }
@media (max-width: 1200px) {
  .lo-head.lo-head3 { grid-template-columns: 1fr; justify-items: stretch; }
  .lo-head3 .lo-h-order { justify-items: start; text-align: left; }
  .lo-head3 .lo-h-order > a { font-size: 22px; } .lo-head3 .lo-h-value b { font-size: 20px; }
}

/* ---- RGA new request: condition checkboxes -> one section per ticked condition; upload + Submit top right ---- */
#rga-form { display: grid; gap: 16px; }  /* spacing between the head, documents, conditions and sections */
.rga-head { align-items: center; }
.rga-head-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rga-head-actions .al-btn { height: 42px; }
.rga-upload-btn { cursor: pointer; display: inline-flex; align-items: center; gap: 8px; }
.rga-upload-btn:focus-within { box-shadow: var(--shadow-focus); }
.rga-doc-hint { margin: 0; font-size: 12px; }
.rga-err:not([hidden]) { display: block; font-weight: 600; }
/* chosen documents */
.rga-docs { display: flex; flex-wrap: wrap; gap: 8px; }
.rga-docs[hidden], .rga-err[hidden] { display: none; }
.rga-doc { display: inline-flex; align-items: center; gap: 8px; padding: 6px 6px 6px 12px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); font-size: 13px; max-width: 100%; }
.rga-doc b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.rga-doc-del { border: 0; background: none; width: 24px; height: 24px; border-radius: 4px; cursor: pointer;
  color: var(--ink-muted); font-size: 16px; line-height: 1; }
.rga-doc-del:hover { background: var(--danger-soft); color: var(--danger); }
/* condition checkboxes */
.rga-conds { margin: 0; padding: 0 0 4px; border: 0; display: grid; gap: 14px; min-width: 0; }
.rga-conds legend { padding: 0; margin-bottom: 14px; }
.rga-cond-list { display: flex; flex-wrap: wrap; gap: 10px; }
.rga-cond { display: inline-flex; align-items: center; gap: 10px; padding: 10px 16px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); cursor: pointer; font-weight: 600; font-size: 14px;
  transition: border-color var(--al-fast), background var(--al-fast); }
.rga-cond input { width: 18px; height: 18px; accent-color: var(--brand-500); margin: 0; cursor: pointer; }
.rga-cond:hover { border-color: var(--brand-500); }
.rga-cond.is-on { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-text); }
.rga-cond:has(input:focus-visible) { box-shadow: var(--shadow-focus); }
.rga-none { margin: 0; padding: 24px; text-align: center; color: var(--ink-muted); border: 1px dashed var(--border);
  border-radius: var(--radius-lg); }
.rga-none[hidden] { display: none; }
/* the chosen condition, shown in each line's Condition of product column */
.rga-line-cond { display: inline-block; padding: 4px 10px; border-radius: 6px; background: var(--brand-50);
  color: var(--brand-text); font-size: 13px; font-weight: 600; white-space: nowrap; }
.rga-line-cond.is-empty { background: none; padding: 0; color: var(--ink-muted); font-weight: 400; font-style: italic; }
/* RGA pop-ups: the documents uploaded with the request, under its lines */
.rga-dlg-docs { display: flex; align-items: flex-start; gap: 8px 16px; flex-wrap: wrap; padding: 14px 0 4px;
  border-top: 1px solid var(--border); margin-top: 12px; font-size: 13px; }
.rga-dlg-docs-title { font-size: 12px; font-weight: 700; letter-spacing: .08em; text-transform: uppercase;
  color: var(--ink-muted); padding-top: 3px; }
.rga-dlg-docs ul { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.rga-dlg-docs li { display: inline-flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border: 1px solid var(--border);
  border-radius: 6px; background: var(--surface); }
.rga-dlg-docs li > a:first-child { display: inline-flex; align-items: center; gap: 6px; font-weight: 600; }
.rga-dlg-dl { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 4px; }
.rga-dlg-dl:hover { background: var(--brand-50); }
/* RGA new request: Comments button (top right) and its pop-up */
.rga-comment-btn { display: inline-flex; align-items: center; gap: 8px; }
.rga-comment-btn.is-set { border-color: var(--brand-500); background: var(--brand-50); color: var(--brand-text); }
.rga-comment-dlg { width: min(560px, calc(100vw - 32px)); }
.rga-comment-body { display: grid; gap: 10px; padding: 16px 20px 20px; }
.rga-comment-body label { font-size: 13px; }
.rga-comment-body textarea { width: 100%; min-height: 120px; resize: vertical; }
.rga-comment-actions { display: flex; align-items: center; justify-content: flex-end; gap: 10px; }
.rga-comment-actions .rga-dim { margin-right: auto; font-size: 12px; }
.rga-lines-area { display: grid; gap: 16px; }
.rga-lines-area[hidden] { display: none; }

/* ---- Dealer home: short expiry strip in the dashboard's teal (light teal band, teal text, icon on a teal tile) ---- */
.al-content a.hd-expiry { display: flex; align-items: center; gap: 12px; padding: 12px 18px; border-radius: var(--radius-lg);
  background: var(--brand-50); border: 1px solid var(--brand-100); color: var(--brand-text); font-weight: 500;
  transition: border-color var(--al-med), box-shadow var(--al-med); }
.al-content a.hd-expiry > svg { box-sizing: content-box; padding: 7px; border-radius: 8px; flex: none;
  background: var(--brand-500); color: var(--on-brand); }
.al-content a.hd-expiry b { color: var(--brand-500); font-size: 16px; }
.al-content a.hd-expiry:hover { border-color: var(--brand-500); box-shadow: var(--shadow-sm); }
.al-content a.hd-expiry:hover .al-arrow { transform: translateX(3px); }

/* ---- Admin > Login users: the add form fits on one row and wraps on narrow screens ---- */
.adm-user-form { flex-wrap: wrap; }
.adm-user-form .form-control { min-width: 170px; }
/* Live orders: a long hold text (two reasons, e.g. "Credit limit exceeded, Await Payment") – smaller, one line */
.lo-head3 .lo-h-qty .lo-hold.lo-hold--long { white-space: nowrap; font-size: 11.5px; letter-spacing: .02em;
  padding: 5px 12px; gap: 6px; }
/* RGA new request: the return limit next to the title */
.rga-title { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.rga-limit { display: inline-flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 6px;
  background: var(--surface); border: 1px solid var(--border); color: var(--brand-text); box-shadow: var(--shadow-sm);
  font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.rga-limit b { font: 700 16px/1 var(--font-display); letter-spacing: 0; text-transform: none; color: var(--brand-500); }
.rga-limit.is-empty b { color: var(--ink-muted); font-weight: 600; }
.rga-limit { cursor: default; }

/* ---- NSM > Credit position: over the credit limit = red row, overdue = amber row ---- */
.cp-table tr.cp-over td { background: none; }   /* very light red tint */
.cp-table tr.cp-over td:first-child { box-shadow: inset 4px 0 0 #ba161c; }
.cp-table tr.cp-due td:first-child { box-shadow: inset 4px 0 0 #d4952b; }
.cp-table tr.cp-due td { background: none; }   /* very light amber tint */
.cp-bad { color: #ba161c; white-space: nowrap; }
.cp-warn { color: #a16207; white-space: nowrap; }
.al-badge.cp-badge-over { background: #ba161c; color: #fff; font-weight: 700; display: inline-flex; gap: 6px; }
.al-badge.cp-badge-over::before { display: none; }
.cp-table td.al-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.cp-legend { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-muted); flex-wrap: wrap; }
.cp-key { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-left: 8px; }
.cp-key--over { background: rgba(186, 22, 28, .08); box-shadow: inset 3px 0 0 #ba161c; }
.cp-key--due { background: rgba(212, 149, 43, .10); box-shadow: inset 3px 0 0 #d4952b; }
/* Dealer Watchlist table fits the page: full width, tighter cells, the dealer name wraps */
.cp-table { width: 100%; table-layout: auto; }
.cp-table th, .cp-table td { padding-left: 12px; padding-right: 12px; }
.cp-table th { white-space: normal; }
.cp-table td.cp-c-dealer { white-space: normal; overflow-wrap: anywhere; min-width: 180px; max-width: 320px; }
.cp-table th:first-child, .cp-table td:first-child { padding-left: 20px; }
.cp-table .al-badge { white-space: nowrap; }
/* Dealer Watchlist header: colour key beside the title, filter box on the right */
.cp-title { display: flex; align-items: center; gap: 8px 20px; flex-wrap: wrap; }
.cp-title .cp-legend .cp-key:first-child { margin-left: 0; }
.cp-search { width: 340px; max-width: 100%; flex: none; }
/* Dealer Watchlist: solid dark amber "Overdue" badge (white text), like the red "Limit exceeded" one */
.al-badge.cp-badge-due { background: #b45309; color: #fff; font-weight: 700; display: inline-flex; gap: 6px; }
.al-badge.cp-badge-due::before { display: none; }

/* ---- Dealer Watchlist: "Limit exceeded" pulses (a red ring grows and fades every 2 s); the "Overdue" clock hand
   ticks round. They keep running on mouse-over; they stop only for users who ask for less motion. ---- */
.al-badge.cp-badge-over { animation: cp-pulse 2s ease-out infinite; }
@keyframes cp-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(186, 22, 28, .55); }
  70%  { box-shadow: 0 0 0 9px rgba(186, 22, 28, 0); }
  100% { box-shadow: 0 0 0 0 rgba(186, 22, 28, 0); }
}
.al-badge.cp-badge-due svg path { transform-box: view-box; transform-origin: 12px 12px;
  animation: cp-tick 6s steps(12, end) infinite; }
@keyframes cp-tick { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .al-badge.cp-badge-over, .al-badge.cp-badge-due svg path { animation: none; }
}
/* Dealer Watchlist: two count cards beside the title (replace the colour key) */
.cp-count { display: inline-flex; align-items: center; gap: 8px; padding: 6px 14px; border-radius: 8px;
  border: 1px solid; font-size: 13px; font-weight: 600; white-space: nowrap; }
.cp-count b { font: 700 20px/1 var(--font-display); }
.cp-count--over { background: rgba(186, 22, 28, .06); border-color: rgba(186, 22, 28, .35); color: #ba161c; }
.cp-count--due { background: rgba(212, 149, 43, .08); border-color: rgba(212, 149, 43, .45); color: #a16207; }
.cp-count svg { flex: none; }
.cp-count--ok { background: rgba(15, 122, 75, .06); border-color: rgba(15, 122, 75, .35); color: #0f7a4b; }

/* ---- Finance > Dealer Ageing: amounts in ₹, the older the bucket the stronger the text colour ---- */
.ag-table { width: 100%; }
.ag-table th, .ag-table td { padding-left: 10px; padding-right: 10px; }
.ag-table th { white-space: normal; }
.ag-table td.al-num { white-space: nowrap; font-variant-numeric: tabular-nums; }
.ag-table td.ag-c-dealer { white-space: normal; overflow-wrap: anywhere; min-width: 170px; max-width: 280px; }
.ag-table th:first-child, .ag-table td:first-child { padding-left: 20px; }
.ag-table td.ag-has { font-weight: 600; }
.ag-table td.ag-b0, .ag-table td.ag-b1 { color: #a16207; }
.ag-table td.ag-b2, .ag-table td.ag-b3 { color: #c2410c; }
.ag-table td.ag-b4, .ag-table td.ag-b5 { color: #ba161c; }
/* Dealer Ageing: customer no under the dealer name; bigger, clearer amounts */
.ag-table .ag-no { display: inline-block; margin-top: 4px; font-size: 11.5px; }
.ag-table td.al-num { font-size: 15px; }
.ag-table tfoot td.al-num { font-size: 15px; }
/* Dealer Ageing: the dealer column no longer takes the spare width (the amount columns share it) */
.ag-table th.ag-c-dealer { width: 20%; }
.ag-table td.ag-c-dealer { max-width: 240px; padding-right: 8px; }
.ag-table th.al-num, .ag-table td.al-num { padding-left: 8px; }
/* Dealer Ageing: Not Due and the age buckets centred (Total stays right-aligned) */
.ag-table th.ag-mid, .ag-table td.ag-mid { text-align: center; }

/* ---- Dealer Ageing: a table that stands apart from the card – solid teal header with white text, a border,
   light zebra rows and a tinted Grand Total row ---- */
.ag-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; border-collapse: separate; border-spacing: 0; }
.al-table.ag-table thead th { background: var(--brand-500); color: #ffffff; font-weight: 700;
  border-bottom: 2px solid var(--brand-700, #014d63); }
.al-table.ag-table thead th[aria-sort="ascending"], .al-table.ag-table thead th[aria-sort="descending"] { background: #01546c; }
.al-table.ag-table thead th:hover { background: #01546c; }
.al-table.ag-table tbody tr:nth-child(even) td { background: var(--brand-50); }
.al-table.ag-table tbody tr:hover td { background: var(--brand-100); }
.al-table.ag-table tfoot td { background: var(--secondary-soft); border-top: 2px solid var(--brand-500); }
.al-table.ag-table thead th a, .al-table.ag-table thead th .al-sort { color: inherit; }
/* Dealer Ageing page head: the dealer count beside the title; the table card has no head of its own */
.ag-title { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.ag-count { display: inline-flex; align-items: center; padding: 4px 12px; border-radius: 6px; border: 1px solid var(--brand-100);
  background: var(--surface); color: var(--brand-text); font-size: 13px; font-weight: 600; white-space: nowrap; }
.ag-card { padding: 3px; }

/* ---- Dealer Watchlist table: the same solid teal header and border as Dealer Ageing (the red / amber row tints
   of the watchlist stay; no zebra rows) ---- */
.cp-table { border: 1px solid var(--border); border-radius: 8px; overflow: hidden; border-collapse: separate; border-spacing: 0; }
.al-table.cp-table thead th { background: var(--brand-500); color: #ffffff; font-weight: 700;
  border-bottom: 2px solid var(--brand-700, #014d63); }
.al-table.cp-table thead th:hover,
.al-table.cp-table thead th[aria-sort="ascending"], .al-table.cp-table thead th[aria-sort="descending"] { background: #01546c; }
/* Dealer Ageing: bolder, deeper colours for the amounts (later rules win over the ones above) */
.ag-table td.ag-mid { font-weight: 600; color: var(--ink); }                 /* Not Due */
.ag-table td.ag-has { font-weight: 800; }                                    /* overdue amounts */
.ag-table td.ag-b0, .ag-table td.ag-b1 { color: #b45309; }                   /* 0-7, 8-15: deep amber */
.ag-table td.ag-b2, .ag-table td.ag-b3 { color: #c2410c; }                   /* 16-30, 31-45: deep orange */
.ag-table td.ag-b4, .ag-table td.ag-b5 { color: #b91c1c; }                   /* 46-60, Above 60: deep red */
/* Dealer Watchlist head: title, count cards and the filter box on one line (wraps only on narrow screens) */
.cp-head { display: block; }
.cp-headline { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.cp-headline h1 { margin: 0; cursor: default; }
.cp-headline .cp-head-search { margin-left: auto; width: 320px; }
.cp-head > p { margin: 6px 0 0; color: var(--ink-muted); }

/* ---- Dark theme: Dealer Watchlist and Dealer Ageing table headers in dark slate-teal (light theme keeps teal) ---- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .al-table.cp-table thead th,
  :root:not([data-theme="light"]) .al-table.ag-table thead th { background: #14363f; border-bottom-color: #0d252c; }
  :root:not([data-theme="light"]) .al-table.cp-table thead th:hover,
  :root:not([data-theme="light"]) .al-table.ag-table thead th:hover { background: #1b4651; }
}
:root[data-theme="dark"] .al-table.cp-table thead th,
:root[data-theme="dark"] .al-table.ag-table thead th { background: #14363f; border-bottom-color: #0d252c; }
:root[data-theme="dark"] .al-table.cp-table thead th:hover,
:root[data-theme="dark"] .al-table.ag-table thead th:hover,
:root[data-theme="dark"] .al-table.cp-table thead th[aria-sort="ascending"],
:root[data-theme="dark"] .al-table.cp-table thead th[aria-sort="descending"],
:root[data-theme="dark"] .al-table.ag-table thead th[aria-sort="ascending"],
:root[data-theme="dark"] .al-table.ag-table thead th[aria-sort="descending"] { background: #1b4651; }
.lo-head3 .lo-h-value b[title] { cursor: default; }
/* Live orders header: the order date above the order no (in place of the "Order no" label) */
.lo-head3 .lo-h-date { font-size: 14px; font-weight: 600; color: var(--ink-muted); letter-spacing: .04em;
  font-variant-numeric: tabular-nums; }

/* ---- Pending orders: "Credit limit exceeded" column – red tick for orders held for credit, dash for the rest ---- */
.ph-c-credit { text-align: center; white-space: normal; }
.ph-tick { color: #ba161c; font-size: 18px; font-weight: 800; line-height: 1; }
/* Pending orders table fits the page: wrapping headers, tighter cells, narrow tick column */
.ph-table { width: 100%; }
.ph-table th { white-space: normal; line-height: 1.25; }
.ph-table th, .ph-table td { padding-left: 10px; padding-right: 10px; }
.ph-table th:first-child, .ph-table td:first-child { padding-left: 16px; }
.ph-table td { overflow-wrap: anywhere; }
.ph-table th.ph-c-credit, .ph-table td.ph-c-credit { width: 90px; max-width: 90px; }
.ph-table td:has(> a) { white-space: nowrap; }   /* order no stays on one line */
/* RGA new request: the invoice date under the invoice no / type (same cell, the table keeps its width) */
.rga-tbl [data-f="invoice"] .rga-inv-date { display: block; margin-top: 2px; font-size: 12px; font-weight: 500;
  color: var(--ink-muted); white-space: nowrap; }

/* ---- Pending orders: one row per order (click → pop-up with its lines) ---- */
.ph-orders tr.ph-row { cursor: pointer; }
.ph-orders tr.ph-row:hover td { background: var(--brand-50); }
.ph-orders tr.ph-row:focus-visible { outline: 2px solid var(--brand-500); outline-offset: -2px; }
.ph-orders .ph-order { color: var(--brand-text); white-space: nowrap; }
.ph-orders td .al-badge { margin: 1px 0; }
.ph-dlg { width: min(1100px, calc(100vw - 32px)); }
.ph-dlg .lo-dialog-head { gap: 12px; }
.ph-dlg-title { display: flex; align-items: center; gap: 8px 14px; flex-wrap: wrap; margin-right: auto; }
.ph-dlg-title h2 { margin: 0; font: 700 18px var(--font-mono); }

/* Approved RGA requests: the dealer's return limit column stays on one line */
.rga-sup-limit { white-space: nowrap; font-weight: 600; }

/* Live orders: the qty of an order not fully shipped is a button -> pop-up of the items still to ship */
.lo-head3 .lo-h-remaining { padding: 2px 6px; margin: -2px -6px; border: 0; border-radius: 6px; background: none;
  font: inherit; color: inherit; cursor: pointer; text-decoration: underline dotted; text-underline-offset: 4px; }
.lo-head3 .lo-h-remaining:hover { background: var(--brand-50); }
.lo-head3 .lo-h-remaining:focus-visible { outline: 2px solid var(--brand-500); outline-offset: 2px; }
.lo-remaining td:last-child b { color: #a16207; }
/* Pending orders: booked order value of credit-held orders, after the Credit limit exceeded column */
.ph-table th.ph-c-value, .ph-table td.ph-c-value { white-space: nowrap; }
.ph-table td.ph-c-value b { color: var(--ink); font-variant-numeric: tabular-nums; }
