/*
 * Tawseel merchant portal - design system (2026 redesign)
 * Loaded after Bootstrap 5.3. Restyles the existing Bootstrap / legacy markup of the merchant screens
 * and provides the new shell (sidebar, top bar) and dashboard components.
 * Theme: <html data-bs-theme="light|dark">, set by js/tws-portal.js.
 */

/* ---------------------------------------------------------------- tokens */
:root,
[data-bs-theme="light"] {
  --tw-bg: #F6F6F4;
  --tw-surface: #FFFFFF;
  --tw-surface-2: #F1F1EE;
  --tw-border: #E4E3DF;
  --tw-border-strong: #D3D2CD;
  --tw-text: #191918;
  --tw-text-2: #55544F;
  --tw-text-3: #6E6D68;
  --tw-brand: #D67C2A;
  --tw-brand-strong: #A3550F;
  --tw-brand-soft: #FCF0E4;
  --tw-btn-bg: #AE5A15;
  --tw-btn-fg: #FFFFFF;
  --tw-ink: #2F3A3D;
  --tw-danger: #B42318;
  --tw-st-del-fg: #17663F;  --tw-st-del-bg: #E3F2E9;
  --tw-st-tr-fg: #1F4FB5;   --tw-st-tr-bg: #E6EDFB;
  --tw-st-ofd-fg: #5B3BB0;  --tw-st-ofd-bg: #EEE9FA;
  --tw-st-pen-fg: #7A4E00;  --tw-st-pen-bg: #FBF0D6;
  --tw-st-ret-fg: #A3241A;  --tw-st-ret-bg: #FCE9E7;
  --tw-st-can-fg: #55544F;  --tw-st-can-bg: #EEEEEB;
  --tw-chart-1: #D67C2A; --tw-chart-2: #2F3A3D; --tw-chart-3: #3B6FD8;
  --tw-chart-4: #7C5CD6; --tw-chart-5: #C9A227; --tw-chart-6: #C2453B;
  --tw-grid: #ECEBE7;
  --tw-shadow: 0 1px 2px rgba(20, 20, 19, .04), 0 1px 3px rgba(20, 20, 19, .06);
  --tw-shadow-lg: 0 12px 32px rgba(20, 20, 19, .14);
  --tw-radius: 12px;
  --tw-radius-sm: 8px;
  --tw-sidebar-w: 248px;
  --tw-sidebar-w-collapsed: 76px;
}

[data-bs-theme="dark"] {
  --tw-bg: #0E0F11;
  --tw-surface: #16171A;
  --tw-surface-2: #1D1E22;
  --tw-border: #2A2B30;
  --tw-border-strong: #383A40;
  --tw-text: #EDECE8;
  --tw-text-2: #B0AFA9;
  --tw-text-3: #94938D;
  --tw-brand: #E2893A;
  --tw-brand-strong: #F2A866;
  --tw-brand-soft: #2B1E12;
  --tw-btn-bg: #E2893A;
  --tw-btn-fg: #1A0F05;
  --tw-ink: #EDECE8;
  --tw-danger: #F07F75;
  --tw-st-del-fg: #6FD39C;  --tw-st-del-bg: #123222;
  --tw-st-tr-fg: #8DB0FF;   --tw-st-tr-bg: #16233F;
  --tw-st-ofd-fg: #B9A4FF;  --tw-st-ofd-bg: #241B3F;
  --tw-st-pen-fg: #F2C463;  --tw-st-pen-bg: #33270C;
  --tw-st-ret-fg: #FF928A;  --tw-st-ret-bg: #3A1714;
  --tw-st-can-fg: #B0AFA9;  --tw-st-can-bg: #24252A;
  --tw-chart-1: #E2893A; --tw-chart-2: #C9CCD1; --tw-chart-3: #7EA2F5;
  --tw-chart-4: #A98DF0; --tw-chart-5: #E3C35A; --tw-chart-6: #F07F75;
  --tw-grid: #25262B;
  --tw-shadow: none;
  --tw-shadow-lg: 0 12px 32px rgba(0, 0, 0, .5);
}

/* Bootstrap variables mapped onto the tokens, so existing components follow the theme */
:root,
[data-bs-theme="light"],
[data-bs-theme="dark"] {
  --bs-body-bg: var(--tw-bg);
  --bs-body-color: var(--tw-text);
  --bs-secondary-color: var(--tw-text-2);
  --bs-tertiary-bg: var(--tw-surface-2);
  --bs-border-color: var(--tw-border);
  --bs-emphasis-color: var(--tw-text);
  --bs-link-color: var(--tw-brand-strong);
  --bs-link-color-rgb: 163, 85, 15;
  --bs-link-hover-color: var(--tw-text);
  --bs-body-font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --bs-body-font-size: 14px;
  --bs-border-radius: var(--tw-radius-sm);
  --bs-focus-ring-color: rgba(214, 124, 42, .25);
}
[data-bs-theme="dark"] { --bs-link-color-rgb: 242, 168, 102; }

/* ---------------------------------------------------------------- base */
html, body { background: var(--tw-bg); color: var(--tw-text); }
body {
  margin: 0;
  font-family: var(--bs-body-font-family);
  font-size: 14px;
  line-height: 1.5;
  font-feature-settings: "tnum" 1, "cv11" 1;
  -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font-family: inherit; }
a { color: var(--tw-brand-strong); text-decoration: none; }
a:hover { color: var(--tw-text); text-decoration: underline; }
:focus-visible { outline: 2px solid var(--tw-brand); outline-offset: 2px; }
h1, h2, h3, h4, h5, h6 { color: var(--tw-text); letter-spacing: -0.01em; }
.tw-sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* ---------------------------------------------------------------- shell */
.tw-app { display: flex; min-height: 100vh; }

.tw-sidebar {
  position: sticky; top: 0; align-self: flex-start;
  width: var(--tw-sidebar-w); height: 100vh; flex: 0 0 auto;
  display: flex; flex-direction: column; gap: 16px;
  padding: 16px 12px; box-sizing: border-box; overflow-y: auto;
  background: var(--tw-surface); border-right: 1px solid var(--tw-border);
  transition: width .15s ease;
}
/* Brand: full logo (transparent PNG); arrow-only mark when the sidebar is collapsed.
   The logo's charcoal parts need a light plate in dark mode. */
.tw-brand { display: flex; align-items: center; justify-content: center; padding: 6px 8px 2px; border-radius: 10px; text-decoration: none; }
.tw-brand:hover { text-decoration: none; }
.tw-brand-logo { display: block; width: auto; height: 92px; max-width: 100%; object-fit: contain; }
.tw-brand-mark { display: none; width: auto; height: 34px; }
html[data-bs-theme="dark"] .tw-brand { background: #F4F3EF; padding: 10px 8px 8px; }
.tw-account {
  display: flex; align-items: center; gap: 10px; padding: 10px;
  border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface-2);
}
.tw-avatar {
  width: 30px; height: 30px; flex: 0 0 30px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--tw-brand-soft); color: var(--tw-brand-strong); font-size: 12px; font-weight: 700;
}
.tw-account-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-account-meta { font-size: 12px; color: var(--tw-text-3); }
.tw-nav-group { display: flex; flex-direction: column; gap: 2px; }
.tw-nav-heading {
  padding: 0 10px 6px; font-size: 11px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--tw-text-3);
}
.tw-nav-link {
  display: flex; align-items: center; gap: 10px; min-height: 38px; padding: 0 10px;
  border-radius: 8px; color: var(--tw-text-2); font-size: 14px; font-weight: 500; text-decoration: none;
}
.tw-nav-link:hover { background: var(--tw-surface-2); color: var(--tw-text); text-decoration: none; }
.tw-nav-link.active { background: var(--tw-brand-soft); color: var(--tw-brand-strong); }
.tw-nav-link .bi { font-size: 17px; width: 18px; text-align: center; flex: 0 0 18px; }
.tw-nav-label { flex: 1 1 auto; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tw-sidebar-foot { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--tw-border); }

/* collapsed sidebar (desktop) */
html.tw-collapsed .tw-sidebar { width: var(--tw-sidebar-w-collapsed); }
html.tw-collapsed .tw-nav-label,
html.tw-collapsed .tw-nav-heading,
html.tw-collapsed .tw-brand-logo,
html.tw-collapsed .tw-account { display: none; }
html.tw-collapsed .tw-brand-mark { display: block; }
html.tw-collapsed .tw-brand { padding: 6px 0; }
html.tw-collapsed .tw-nav-link,
html.tw-collapsed .tw-brand { justify-content: center; }

.tw-main { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; }
.tw-topbar {
  position: sticky; top: 0; z-index: 1020;
  display: flex; align-items: center; gap: 12px; min-height: 64px;
  /* Line the top bar up with the page content below it: same 1360px column and 32px side padding
     as .tw-content, so the breadcrumb and the right-hand controls sit on the cards' edges. */
  padding: 0 calc(max(0px, (100% - 1360px) / 2) + 32px);
  background: var(--tw-surface); border-bottom: 1px solid var(--tw-border);
}
.tw-icon-btn {
  width: 38px; height: 38px; flex: 0 0 38px; display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid var(--tw-border); border-radius: 8px; background: var(--tw-surface); color: var(--tw-text-2);
  cursor: pointer; padding: 0;
}
.tw-icon-btn:hover { background: var(--tw-surface-2); color: var(--tw-text); }
.tw-icon-btn .bi { font-size: 18px; }
.tw-crumbs { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--tw-text-3); white-space: nowrap; }
.tw-crumbs strong { color: var(--tw-text); font-weight: 500; }
.tw-search { position: relative; flex: 0 1 360px; max-width: 360px; margin: 0 0 0 auto; }
.tw-search .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--tw-text-3); pointer-events: none; }
.tw-search input {
  width: 100%; height: 38px; box-sizing: border-box; padding: 0 12px 0 36px;
  border: 1px solid var(--tw-border); border-radius: 8px; background: var(--tw-surface-2); color: var(--tw-text); font-size: 14px;
}
.tw-search input:focus { outline: none; border-color: var(--tw-brand); box-shadow: 0 0 0 3px var(--tw-brand-soft); background: var(--tw-surface); }
.tw-user-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; background: var(--tw-ink); color: var(--tw-surface);
  font-size: 13px; font-weight: 600; cursor: pointer;
}
.tw-menu-btn { display: none; }
.tw-content { width: 100%; max-width: 1360px; box-sizing: border-box; margin: 0 auto; padding: 24px 32px 48px; display: flex; flex-direction: column; gap: 20px; }
.tw-overlay { display: none; }

/* phones and tablets: sidebar becomes a drawer */
@media (max-width: 1023.98px) {
  .tw-sidebar {
    position: fixed; left: 0; top: 0; z-index: 1045; width: 280px; height: 100%;
    transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--tw-shadow-lg);
  }
  html.tw-collapsed .tw-sidebar { width: 280px; }
  html.tw-collapsed .tw-nav-label, html.tw-collapsed .tw-nav-heading { display: block; }
  html.tw-collapsed .tw-account { display: flex; }
  html.tw-collapsed .tw-brand-logo { display: block; }
  html.tw-collapsed .tw-brand-mark { display: none; }
  html.tw-collapsed .tw-nav-link { justify-content: flex-start; }
  html.tw-collapsed .tw-brand { justify-content: center; padding: 6px 8px 2px; }
  html.tw-drawer-open .tw-sidebar { transform: translateX(0); }
  html.tw-drawer-open .tw-overlay { display: block; position: fixed; inset: 0; z-index: 1040; background: rgba(0, 0, 0, .4); }
  .tw-menu-btn { display: inline-flex; width: 44px; height: 44px; flex-basis: 44px; }
  .tw-collapse-btn { display: none; }
  .tw-topbar { padding: 0 16px; min-height: 56px; gap: 8px; }
  .tw-crumbs { display: none; }
  .tw-content { padding: 16px 16px 40px; }
}
@media (max-width: 575.98px) {
  .tw-search { display: none; }
  .tw-topbar .tw-page-title-mobile { display: block; }
}
.tw-page-title-mobile { display: none; flex: 1 1 auto; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------------------------------------------------------------- page header & notice */
.tw-page-head { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; }
.tw-page-head h1 { margin: 0; font-size: 26px; line-height: 1.2; font-weight: 700; letter-spacing: -0.02em; }
.tw-page-head p { margin: 6px 0 0; font-size: 14px; color: var(--tw-text-2); }
.tw-notice {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--tw-border); border-radius: var(--tw-radius); background: var(--tw-brand-soft); color: var(--tw-text);
}
.tw-notice > .bi { color: var(--tw-brand-strong); font-size: 18px; }
.tw-notice p { margin: 0; flex: 1 1 auto; }
.tw-notice[hidden] { display: none; }

/* ---------------------------------------------------------------- cards */
.card, .tw-card {
  background: var(--tw-surface); color: var(--tw-text);
  border: 1px solid var(--tw-border) !important; border-radius: var(--tw-radius) !important;
  box-shadow: var(--tw-shadow) !important;
}
.card { --bs-card-bg: var(--tw-surface); --bs-card-cap-bg: var(--tw-surface); overflow: visible; }
/* The legacy views use "card-header bg-primary text-white" as a coloured title bar: show it as a page header instead */
.card > .card-header,
.card > .card-header.bg-primary {
  background: var(--tw-surface) !important; color: var(--tw-text) !important;
  border-bottom: 1px solid var(--tw-border) !important; padding: 18px 20px;
  border-radius: var(--tw-radius) var(--tw-radius) 0 0 !important;
}
.card > .card-header .card-title,
.card > .card-header h5 { font-size: 18px; font-weight: 700; letter-spacing: -0.01em; color: var(--tw-text); }
.card > .card-header.text-white * { color: inherit; }
.card-body { padding: 20px; }
.tw-card { padding: 20px; }
.tw-card-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.tw-card-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.tw-card-head p { margin: 4px 0 0; font-size: 13px; color: var(--tw-text-3); }

/* ---------------------------------------------------------------- buttons */
.btn {
  --bs-btn-font-size: 14px; --bs-btn-font-weight: 500; --bs-btn-border-radius: 8px;
  --bs-btn-padding-y: .5rem; --bs-btn-padding-x: 1rem;
  min-height: 40px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.btn-sm { min-height: 32px; --bs-btn-padding-y: .25rem; --bs-btn-padding-x: .75rem; --bs-btn-font-size: 13px; }
.btn-primary, .button {
  --bs-btn-bg: var(--tw-btn-bg); --bs-btn-border-color: var(--tw-btn-bg); --bs-btn-color: var(--tw-btn-fg);
  --bs-btn-hover-bg: var(--tw-btn-bg); --bs-btn-hover-border-color: var(--tw-btn-bg); --bs-btn-hover-color: var(--tw-btn-fg);
  --bs-btn-active-bg: var(--tw-btn-bg); --bs-btn-active-border-color: var(--tw-btn-bg); --bs-btn-active-color: var(--tw-btn-fg);
  --bs-btn-disabled-bg: var(--tw-surface-2); --bs-btn-disabled-border-color: var(--tw-surface-2); --bs-btn-disabled-color: var(--tw-text-3);
  --bs-btn-font-weight: 600;
  background-color: var(--tw-btn-bg) !important; border-color: var(--tw-btn-bg) !important; color: var(--tw-btn-fg) !important;
}
.btn-primary:hover, .button:hover { filter: brightness(1.08); }
.button { border: 1px solid; border-radius: 8px; min-height: 36px; padding: 0 14px; font-size: 14px; font-weight: 600; cursor: pointer; }
.btn-secondary, .btn-outline-secondary, .btn-light {
  --bs-btn-bg: var(--tw-surface); --bs-btn-border-color: var(--tw-border-strong); --bs-btn-color: var(--tw-text);
  --bs-btn-hover-bg: var(--tw-surface-2); --bs-btn-hover-border-color: var(--tw-border-strong); --bs-btn-hover-color: var(--tw-text);
  --bs-btn-active-bg: var(--tw-surface-2); --bs-btn-active-border-color: var(--tw-border-strong); --bs-btn-active-color: var(--tw-text);
}
.btn-danger { --bs-btn-bg: var(--tw-danger); --bs-btn-border-color: var(--tw-danger); --bs-btn-hover-bg: var(--tw-danger); --bs-btn-hover-border-color: var(--tw-danger); --bs-btn-font-weight: 600; }
.btn-success { --bs-btn-font-weight: 600; }
.btn:focus-visible { box-shadow: 0 0 0 3px var(--tw-brand-soft); outline: 2px solid var(--tw-brand); }

/* ---------------------------------------------------------------- forms */
.form-control, .form-select, input[type="text"], input[type="date"], input[type="number"], input[type="email"],
input[type="tel"], input[type="password"], input[type="search"], select, textarea {
  border-color: var(--tw-border-strong); border-radius: 8px; background-color: var(--tw-surface); color: var(--tw-text);
  font-size: 14px;
}
.form-control, .form-select { min-height: 40px; }
textarea.form-control { min-height: 96px; }
.form-control:focus, .form-select:focus, input:focus, select:focus, textarea:focus {
  border-color: var(--tw-brand); box-shadow: 0 0 0 3px var(--tw-brand-soft); outline: none;
}
.form-control::placeholder { color: var(--tw-text-3); }
.form-label, .col-form-label { font-size: 13px; font-weight: 600; color: var(--tw-text); }
.form-text { color: var(--tw-text-3); }
.form-check-input { width: 1.1em; height: 1.1em; border-color: var(--tw-border-strong); }
.form-check-input:checked { background-color: var(--tw-btn-bg); border-color: var(--tw-btn-bg); }
.form-check-input:focus { box-shadow: 0 0 0 3px var(--tw-brand-soft); border-color: var(--tw-brand); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--tw-btn-bg); }

/* ---------------------------------------------------------------- tables */
.table {
  --bs-table-bg: transparent; --bs-table-color: var(--tw-text); --bs-table-border-color: var(--tw-border);
  --bs-table-hover-bg: var(--tw-surface-2); --bs-table-hover-color: var(--tw-text);
  --bs-table-striped-bg: var(--tw-surface-2);
  margin-bottom: 0; font-size: 13px; vertical-align: middle;
}
.table > :not(caption) > * > * { padding: 11px 12px; border-bottom-color: var(--tw-border); }
.table thead th, .table > thead > tr > th {
  background: var(--tw-surface-2) !important; color: var(--tw-text-3) !important;
  font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--tw-border) !important; white-space: nowrap;
}
.table-bordered > :not(caption) > * > * { border-width: 0 0 1px 0; }
.table-bordered > :not(caption) > * { border-width: 0; }
/* Only wrappers that actually hold a table get a frame. Several legacy forms sit inside a
   .table-responsive div too, and a frame there made the fields touch its border. */
.table-responsive { border: none; border-radius: 0; }
.table-responsive:has(> table) { border: 1px solid var(--tw-border); border-radius: 10px; }
.table tbody tr:last-child > * { border-bottom: none; }
.table tfoot > tr > * { border-top: 1px solid var(--tw-border-strong); border-bottom: none; font-weight: 700; background: var(--tw-surface-2); }

/* Legacy form rows: "row" with inline overflow-x:hidden clipped the focus ring and put fields flush
   against the edge. Remove the negative gutter instead, and give each row a little vertical room. */
.card-body .row[style*="overflow-x"] { overflow: visible !important; margin-left: 0; margin-right: 0; padding-top: 2px; padding-bottom: 2px; }
.card-body form > .row, .card-body form .form-group { margin-left: 0; margin-right: 0; }
.card-body hr { border-color: var(--tw-border); opacity: 1; margin: 20px 0; }
.card-body .form-group.mt-3 { padding-top: 16px; border-top: 1px solid var(--tw-border); display: flex; flex-wrap: wrap; gap: 8px; }
@media (min-width: 768px) {
  .card-body .row > .col-form-label { padding-right: 16px; }
}

/* legacy table classes still used by some views */
.nicetable { width: 100%; border-collapse: collapse; font-size: 13px; }
.nicetableheader { padding: 10px 12px; background: var(--tw-surface-2); color: var(--tw-text-3); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--tw-border); }
.nicetablerow, .nicetablerow1 { padding: 10px 12px; border-bottom: 1px solid var(--tw-border); background: transparent; color: var(--tw-text); }
.mainsubheader { margin: 0 0 12px; padding: 0; font-size: 16px; font-weight: 600; color: var(--tw-text); }
.blueTable { width: 100%; border-collapse: collapse; font-size: 13px; }
.blueTable th { padding: 10px 12px; text-align: left; background: var(--tw-surface-2); color: var(--tw-text-3); font-size: 12px; font-weight: 600; }
.blueTable td { padding: 10px 12px; border-bottom: 1px solid var(--tw-border); }
.validation { color: var(--tw-danger); font-size: 13px; padding: 2px 0; }
td.validation { display: block; }
.imp { color: var(--tw-danger); }
.blueColor { color: var(--tw-st-tr-fg); }
.toggle-table td { width: 150px; word-wrap: break-word; white-space: normal; }
#map { width: 100%; height: 400px; border-radius: 10px; }
#suggestions, .suggestionsBox {
  position: absolute; z-index: 1050; min-width: 280px; max-height: 320px; overflow-y: auto;
  background: var(--tw-surface); border: 1px solid var(--tw-border); border-radius: 10px; box-shadow: var(--tw-shadow-lg);
}
.suggestionList ul, #suggestionsList ul { list-style: none; margin: 0; padding: 4px; }
.suggestionList li, #suggestionsList li { padding: 8px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; }
.suggestionList li:hover, #suggestionsList li:hover { background: var(--tw-surface-2); }

/* ---------------------------------------------------------------- alerts & badges */
.alert { border-radius: 10px; border: none; font-size: 14px; }
.alert-danger { background: var(--tw-st-ret-bg); color: var(--tw-st-ret-fg); }
.alert-success { background: var(--tw-st-del-bg); color: var(--tw-st-del-fg); }
.alert-info { background: var(--tw-st-tr-bg); color: var(--tw-st-tr-fg); }
.alert-warning { background: var(--tw-st-pen-bg); color: var(--tw-st-pen-fg); }
.text-danger { color: var(--tw-danger) !important; }
.text-success { color: var(--tw-st-del-fg) !important; }
.text-muted { color: var(--tw-text-3) !important; }
.bg-primary:not(.card-header) { background-color: var(--tw-btn-bg) !important; }

.tw-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; background: var(--tw-st-can-bg); color: var(--tw-st-can-fg);
}
.tw-badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.tw-badge.is-delivered { background: var(--tw-st-del-bg); color: var(--tw-st-del-fg); }
.tw-badge.is-transit   { background: var(--tw-st-tr-bg);  color: var(--tw-st-tr-fg); }
.tw-badge.is-ofd       { background: var(--tw-st-ofd-bg); color: var(--tw-st-ofd-fg); }
.tw-badge.is-pending   { background: var(--tw-st-pen-bg); color: var(--tw-st-pen-fg); }
.tw-badge.is-returned  { background: var(--tw-st-ret-bg); color: var(--tw-st-ret-fg); }
.tw-badge.is-cancelled { background: var(--tw-st-can-bg); color: var(--tw-st-can-fg); }

/* ---------------------------------------------------------------- screen layouts (orders, finance) */
.card > .card-header.tw-header-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.card > .card-header .tw-header-sub { margin-top: 4px; font-size: 13px; color: var(--tw-text-2); }
.tw-btn-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.card-body.tw-flush { padding: 0; }
.tw-flush .table-responsive, .tw-flush .table-responsive:has(> table) { border: none; border-top: 1px solid var(--tw-border); border-radius: 0; }

.tw-tabs {
  display: flex; gap: 4px; padding: 6px 16px 0; overflow-x: auto; scrollbar-width: thin;
  border-bottom: 1px solid var(--tw-border); background: var(--tw-surface);
}
.tw-tab {
  flex: 0 0 auto; display: inline-flex; align-items: center; height: 44px; padding: 0 12px;
  border: none; border-bottom: 2px solid transparent; background: transparent;
  color: var(--tw-text-3); font-size: 14px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer;
}
.tw-tab:hover { color: var(--tw-text); text-decoration: none; }
.tw-tab.active { color: var(--tw-text); border-bottom-color: var(--tw-brand); }

.tw-toolbar { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px; padding: 16px; }
.tw-field { display: flex; flex-direction: column; gap: 4px; flex: 1 1 200px; max-width: 280px; margin: 0; }
.tw-field > span { font-size: 12px; font-weight: 600; color: var(--tw-text-2); }
.tw-toolbar-note { margin-left: auto; font-size: 13px; color: var(--tw-text-3); padding-bottom: 10px; }
@media (max-width: 575.98px) { .tw-field { max-width: none; flex-basis: 100%; } .tw-toolbar-note { margin-left: 0; } }

.tw-col-check { width: 44px; }
.tw-muted-icon { color: var(--tw-text-3); }
.tw-link-btn {
  padding: 0; border: none; background: none; color: var(--tw-brand-strong); font-weight: 600; cursor: pointer;
  font-variant-numeric: tabular-nums;
}
.tw-link-btn:hover { color: var(--tw-text); text-decoration: underline; }
.tw-row-btn {
  width: 32px; height: 32px; display: inline-flex; align-items: center; justify-content: center;
  border: none; border-radius: 6px; background: transparent; color: var(--tw-text-2); cursor: pointer; text-decoration: none;
}
.tw-row-btn:hover { background: var(--tw-surface-2); color: var(--tw-text); text-decoration: none; }
.tw-row-btn[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }
.tw-detail-row > td { background: var(--tw-surface-2) !important; padding: 0 !important; }
.tw-detail { display: flex; flex-direction: column; gap: 16px; padding: 18px 20px 20px 64px; }
.tw-dl { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px 20px; margin: 0; }
.tw-dl dt { font-size: 12px; font-weight: 500; color: var(--tw-text-3); }
.tw-dl dd { margin: 2px 0 0; font-size: 13px; font-weight: 500; color: var(--tw-text); overflow-wrap: anywhere; }
.tw-dl-wide { grid-column: 1 / -1; }
.tw-detail-ajax:empty { display: none; }
.tw-search-results .tw-detail { padding-left: 20px; }
.tw-detail-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px 32px; }
.tw-detail-title { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 13px; font-weight: 600; color: var(--tw-text-2); text-transform: uppercase; letter-spacing: .04em; }
@media (max-width: 767.98px) { .tw-detail-cols { grid-template-columns: minmax(0, 1fr); } }
/* lists without a checkbox column don't need the deep left indent */
.tw-flush .tw-detail-row .tw-detail { padding-left: 20px; }
#cr_request .tw-detail-row .tw-detail { padding-left: 64px; }
@media (max-width: 767.98px) { #cr_request .tw-detail-row .tw-detail, .tw-flush .tw-detail-row .tw-detail { padding: 16px; } }
.tw-search-results + .tw-table-foot { border-top: none; padding-left: 4px; }
.tw-inline-form { padding: 12px 14px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface); }
.tw-inline-form .form-label { font-size: 13px; }
.tw-detail-ajax { background: var(--tw-surface); border: 1px solid var(--tw-border); border-radius: 10px; padding: 4px; }
.tw-detail-ajax .card-body { padding: 8px; }
@media (max-width: 767.98px) { .tw-detail { padding: 16px; } }

.tw-table-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 16px; border-top: 1px solid var(--tw-border); font-size: 13px; color: var(--tw-text-2); }
.tw-pager { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
/* Standard pager (tws_pager): numbered pages, gaps, prev/next and the page-size menu. */
.tw-pager-num { min-width: 32px; height: 32px; padding: 0 8px; display: inline-flex; align-items: center; justify-content: center; border-radius: 8px; border: 1px solid var(--tw-border); color: var(--tw-text); text-decoration: none; font-variant-numeric: tabular-nums; }
.tw-pager-num:hover { background: var(--tw-surface-2, var(--tw-surface)); color: var(--tw-text); }
.tw-pager-num.is-current { background: var(--tw-ink); border-color: var(--tw-ink); color: var(--tw-surface); font-weight: 600; }
.tw-pager-gap { padding: 0 2px; color: var(--tw-text-2); }
.tw-pager .btn.disabled { opacity: .45; pointer-events: none; }
.tw-pager-size { margin-left: 6px; }
.tw-pager-size .form-select { width: auto; min-height: 32px; padding-top: 2px; padding-bottom: 2px; font-size: 13px; }
/* "Select all N ready orders" inside the selection bar */
.tw-selbar-text { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; }
.tw-selbar .tw-link-btn { color: inherit; text-decoration: underline; text-underline-offset: 3px; font-weight: 600; }
.tw-selbar .tw-link-btn[hidden] { display: none; }
.tw-selbar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-top: 1px solid var(--tw-border); background: var(--tw-surface);
  border-radius: 0 0 var(--tw-radius) var(--tw-radius); font-size: 14px; color: var(--tw-text-2);
}
.tw-selbar.is-active { background: var(--tw-ink); color: var(--tw-surface); font-weight: 600; }
.tw-selbar.is-static { position: static; border-top: none; border-bottom: 1px solid var(--tw-border); border-radius: 0; }

.tw-empty-state { display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 56px 24px; text-align: center; }
.tw-empty-state h2 { margin: 0; font-size: 16px; font-weight: 600; }
.tw-empty-state p { margin: 0; max-width: 380px; font-size: 14px; color: var(--tw-text-2); }
.tw-empty-icon { width: 52px; height: 52px; border-radius: 14px; display: flex; align-items: center; justify-content: center; background: var(--tw-surface-2); color: var(--tw-text-3); font-size: 24px; }

.tw-summary { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 20px; }
.tw-summary-item { display: flex; flex-direction: column; gap: 6px; padding: 16px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface); }
.tw-summary-label { font-size: 13px; font-weight: 500; color: var(--tw-text-2); }
.tw-summary-value { font-size: 22px; font-weight: 700; letter-spacing: -0.02em; }
.tw-summary-value small { font-size: 12px; font-weight: 500; color: var(--tw-text-3); letter-spacing: 0; }
.tw-summary-note { font-size: 12px; color: var(--tw-text-3); }
.tw-footnote { margin: 12px 0 0; font-size: 13px; color: var(--tw-text-3); }
.tw-table-numeric td, .tw-table-numeric th { white-space: nowrap; }

/* ---------------------------------------------------------------- forms (orders, pickup requests) */
.tw-order-form { display: flex; flex-direction: column; gap: 0; }
.tw-form-section {
  display: grid; grid-template-columns: minmax(0, 240px) minmax(0, 1fr); gap: 12px 32px;
  padding: 24px 0; border-top: 1px solid var(--tw-border);
}
.tw-order-form > .tw-form-section:first-child,
.tw-order-form > .tw-summary + .tw-form-section { border-top: none; padding-top: 4px; }
.tw-form-section-head h3 { margin: 0; font-size: 15px; font-weight: 600; color: var(--tw-text); }
.tw-form-section-head p { margin: 4px 0 0; font-size: 13px; color: var(--tw-text-3); }
.tw-form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; align-content: start; }
.tw-form-grid > * { min-width: 0; }
.tw-span-2 { grid-column: 1 / -1; }
.tw-form-grid fieldset, .tw-form-section fieldset { margin: 0; padding: 0; border: 0; min-width: 0; }
.tw-form-grid legend.form-label { float: none; width: auto; margin-bottom: .5rem; font-size: 14px; }
.tw-optional { margin-left: 4px; font-size: 12px; font-weight: 400; color: var(--tw-text-3); }
.tw-form-hint { margin: 6px 0 0; font-size: 12px; color: var(--tw-text-3); }
.tw-form-hint:empty, #PopUp:has(#PopUpText:empty) { display: none; }

.tw-choices { display: flex; flex-wrap: wrap; gap: 8px; }
.tw-choice {
  display: inline-flex; align-items: center; gap: 8px; min-height: 40px; padding: 8px 14px; margin: 0;
  border: 1px solid var(--tw-border-strong); border-radius: 10px; background: var(--tw-surface);
  font-size: 14px; font-weight: 500; color: var(--tw-text); cursor: pointer;
}
.tw-choice .form-check-input { margin: 0; flex: 0 0 auto; }
.tw-choice:hover { background: var(--tw-surface-2); }
.tw-choice:has(input:checked) { border-color: var(--tw-brand); box-shadow: inset 0 0 0 1px var(--tw-brand); }
.tw-choice:has(input:focus-visible) { outline: 2px solid var(--tw-brand); outline-offset: 2px; }
.tw-choice-lg { padding: 12px 18px; }
.tw-choice-lg .bi { font-size: 20px; color: var(--tw-text-2); }

.tw-cod { display: flex; flex-direction: column; gap: 12px; padding: 14px 16px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface-2); }
.tw-cod .form-check { margin: 0; }
.tw-cod-amount { max-width: 320px; }
.tw-cod-amount[hidden] { display: none; }
.input-group-text { background: var(--tw-surface-2); border-color: var(--tw-border-strong); color: var(--tw-text-2); font-size: 13px; }

.tw-form-actions {
  position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px;
  margin: 8px -20px -20px; padding: 14px 20px; border-top: 1px solid var(--tw-border);
  background: var(--tw-surface); border-radius: 0 0 var(--tw-radius) var(--tw-radius);
}
.tw-form-actions-start { margin-right: auto; }
/* forms followed by results on the same page (Track & search, Send inventory): no sticky bar */
.tw-form-actions.is-inline { position: static; margin: 4px 0 0; padding: 16px 0 0; border-radius: 0; background: transparent; }
.card-body + .card-body { border-top: 1px solid var(--tw-border); }
.tw-search-results { margin-top: 20px; }

.tw-half { max-width: calc(50% - 10px); }
@media (max-width: 575.98px) { .tw-half { max-width: none; } }
.tw-or { display: flex; align-items: center; gap: 12px; color: var(--tw-text-3); font-size: 12px; text-transform: uppercase; letter-spacing: .06em; }
.tw-or::before, .tw-or::after { content: ""; flex: 1 1 auto; height: 1px; background: var(--tw-border); }

.tw-choices-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
.tw-choice-card { align-items: flex-start; padding: 12px 14px; }
.tw-choice-card .form-check-input { margin-top: 3px; }
.tw-choice-card > span { display: flex; flex-direction: column; gap: 2px; }
.tw-choice-card small { font-size: 12px; font-weight: 400; color: var(--tw-text-3); }

.tw-result { display: flex; flex-direction: column; gap: 4px; margin-bottom: 20px; padding: 18px 20px; border-radius: 10px; background: var(--tw-st-del-bg); color: var(--tw-st-del-fg); }
.tw-result.is-empty { background: var(--tw-st-ret-bg); color: var(--tw-st-ret-fg); }
.tw-result-label { font-size: 13px; font-weight: 600; }
.tw-result-value { font-size: 28px; font-weight: 700; letter-spacing: -0.02em; color: var(--tw-text); }
.tw-result-value small { font-size: 14px; font-weight: 600; color: var(--tw-text-2); }
.tw-result-note { font-size: 13px; color: var(--tw-text-2); }

.tw-input-table td { padding-top: 8px; padding-bottom: 8px; }
.tw-section-title { padding: 16px 16px 12px; }
.tw-section-title h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tw-col-num { width: 48px; color: var(--tw-text-3); font-variant-numeric: tabular-nums; }

.tw-lookup-form { margin-bottom: 20px; padding-bottom: 20px; border-bottom: 1px solid var(--tw-border); }
.tw-lookup { position: relative; max-width: 560px; }
.tw-lookup > .bi { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--tw-text-3); pointer-events: none; }
.tw-lookup > .form-control { padding-left: 36px; }
.tw-lookup #suggestions { top: calc(100% + 4px); left: 0; right: 0; }

.tw-address-card { display: flex; gap: 12px; padding: 14px 16px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface-2); }
.tw-address-card > .bi { font-size: 18px; color: var(--tw-brand); margin-top: 1px; }
.tw-address-card > div { display: flex; flex-direction: column; gap: 2px; min-width: 0; font-size: 14px; }
.tw-address-card span { color: var(--tw-text-2); overflow-wrap: anywhere; }
.tw-inline-select { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 6px; }
.tw-inline-select label { font-size: 13px; color: var(--tw-text-2); }
.tw-inline-select .form-select { width: auto; min-width: 200px; max-width: 100%; }
@media (max-width: 575.98px) { .tw-inline-select .form-select { flex: 1 1 100%; min-width: 0; } }
.tw-error-list { width: 100%; margin: 0; }
.tw-error-list td.validation { color: inherit; padding: 2px 0; }

.tw-disclosure { margin-bottom: 8px; padding: 12px 0; border-top: 1px solid var(--tw-border); font-size: 13px; }
.tw-disclosure summary { cursor: pointer; font-weight: 500; color: var(--tw-text-2); }
.tw-awb-list { margin: 8px 0 0; color: var(--tw-text-2); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.tw-num-link { display: inline-flex; align-items: center; gap: 6px; color: var(--tw-text); font-weight: 600; font-variant-numeric: tabular-nums; text-decoration: none; }
.tw-num-link .bi { font-size: 12px; color: var(--tw-text-3); }
.tw-num-link:hover { color: var(--tw-brand-strong); text-decoration: none; }

.tw-error-box > strong { display: block; margin-bottom: 6px; }
.tw-ref-section { margin-top: 28px; padding: 18px 20px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface-2); }
.tw-ref-section h3 { margin: 0; font-size: 15px; font-weight: 600; }
.tw-ref-section > p { margin: 4px 0 14px; font-size: 13px; color: var(--tw-text-3); }
.tw-chip-list { display: flex; flex-wrap: wrap; gap: 8px; margin: 0; padding: 0; list-style: none; }
.tw-chip-list li { padding: 5px 12px; border: 1px solid var(--tw-border); border-radius: 999px; background: var(--tw-surface); font-size: 13px; font-weight: 500; }

.tw-selbar.is-error { background: var(--tw-st-ret-bg); color: var(--tw-st-ret-fg); font-weight: 600; }
.btn:disabled, .btn.disabled { opacity: .5; cursor: not-allowed; pointer-events: auto; }

/* Legacy screens: tables, alerts and blocks that follow a form or a row of buttons were flush against them. */
.card-body:not(.tw-flush) form:not(.tw-order-form):not(.tw-lookup-form) ~ :is(table, .table-responsive, .alert, [class*="col-md-12"]),
.card-body:not(.tw-flush) .form-group ~ :is(table, .table-responsive),
.card-body:not(.tw-flush) > .btn ~ :is(table, .table-responsive) { margin-top: 20px; }
.card-body .btn.mb-3 ~ .table-responsive { margin-top: 4px; }
/* Several legacy screens (Track & search, On-demand, Pickup locations) put a whole form inside a
   .table-responsive wrapper. That wrapper must not draw a frame (the fields and the Search button ended up
   against it) and needs a little room so focus rings aren't clipped by its scroll box. The results table
   keeps its own frame instead. */
.table-responsive:has(form), .table-responsive:has(form):has(> table) { border: none; border-radius: 0; padding: 4px 0; }
.table-responsive:has(form) > table { border: 1px solid var(--tw-border); }
/* Buttons placed straight after a table (Fulfilment add products) sat on the table's border. */
.card-body :is(.table-responsive, table) ~ :is(.btn, .form-group) { margin-top: 16px; }

@media (max-width: 991.98px) {
  .tw-form-section { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

/* ---------------------------------------------------------------- tracking panel (ajaxcodes.php q=98) */
.tw-track { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.tw-track.has-pod { grid-template-columns: minmax(0, 2fr) minmax(220px, 1fr); align-items: start; }
.tw-track-main { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.tw-track-card { padding: 18px 20px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface); min-width: 0; }
.tw-track-card h3 { margin: 0 0 14px; font-size: 15px; font-weight: 600; }
.tw-track-sub { margin: -10px 0 12px; font-size: 13px; color: var(--tw-text-3); }
.tw-track-card .table-responsive, .tw-track-card .table-responsive:has(> table) { border: none; border-radius: 0; }
.tw-track-card .table > :not(caption) > * > * { padding-left: 0; }
.tw-track-pod { display: flex; flex-direction: column; gap: 12px; }
.tw-track-pod h3 { margin: 0; }
.tw-track-pod img { display: block; width: 100%; max-height: 320px; object-fit: contain; border-radius: 8px; border: 1px solid var(--tw-border); background: var(--tw-surface-2); }
.tw-track-pod .btn { align-self: flex-start; }
.tw-track-empty { padding: 14px 16px; font-size: 14px; color: var(--tw-text-2); }

.tw-timeline { list-style: none; margin: 0; padding: 0; }
.tw-timeline li { position: relative; display: flex; gap: 14px; padding-bottom: 18px; --dot: var(--tw-brand); }
.tw-timeline li:last-child { padding-bottom: 0; }
.tw-timeline li::before { content: ""; position: absolute; left: 6px; top: 18px; bottom: 0; width: 2px; background: var(--tw-border); }
.tw-timeline li:last-child::before { display: none; }
.tw-timeline-dot { flex: 0 0 14px; width: 14px; height: 14px; margin-top: 3px; border-radius: 50%; background: var(--dot); border: 2px solid var(--tw-surface); box-shadow: 0 0 0 1px var(--dot); position: relative; z-index: 1; }
.tw-timeline li.is-done { --dot: var(--tw-brand); }
.tw-detail-ajax:has(> .tw-track), .tw-detail-ajax:has(> .tw-track-empty) { padding: 0; border: none; background: transparent; }
.tw-timeline li.is-current { --dot: var(--tw-brand); }
.tw-timeline li.is-delivered { --dot: var(--tw-st-del-fg); }
.tw-timeline li.is-returned { --dot: var(--tw-st-ret-fg); }
.tw-timeline-body { flex: 1 1 auto; min-width: 0; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.tw-timeline-body > div { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tw-timeline-body strong { font-size: 14px; font-weight: 600; }
.tw-timeline-body span { font-size: 13px; color: var(--tw-text-2); overflow-wrap: anywhere; }
.tw-timeline-body time { font-size: 13px; color: var(--tw-text-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.tw-timeline li.is-done .tw-timeline-body strong { font-weight: 500; }
@media (max-width: 767.98px) { .tw-track.has-pod { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 575.98px) {
  .tw-form-grid { grid-template-columns: minmax(0, 1fr); }
  .tw-form-actions .btn { flex: 1 1 auto; }
  .tw-form-actions-start { margin-right: 0; order: 3; flex-basis: 100%; }
}

/* ---------------------------------------------------------------- dashboard */
/* Motion: cards rise in one after another, the trend lines draw left to right, the donut sweeps round,
   the monthly bars grow and the figures count up (js/tws-portal.js). Off for "reduce motion". */
@media (prefers-reduced-motion: no-preference) {
  .tw-anim { animation: tw-rise .55s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(var(--i, 0) * 55ms); }
  .tw-reveal { animation: tw-reveal 1.3s cubic-bezier(.45, 0, .2, 1) .55s both; }
  .tw-donut-seg { animation: tw-sweep .9s cubic-bezier(.3, .7, .2, 1) both; animation-delay: calc(.6s + var(--i, 0) * 110ms); }
  .tw-donut-center { animation: tw-pop .5s cubic-bezier(.3, 1.4, .5, 1) 1s both; }
  .tw-bar div { transform-origin: 50% 100%; animation: tw-grow .7s cubic-bezier(.2, .7, .2, 1) both; animation-delay: calc(.7s + var(--i, 0) * 45ms); }
  .tw-bar span { animation: tw-fade .4s ease both; animation-delay: calc(1.1s + var(--i, 0) * 45ms); }
  .tw-bar.is-current div { animation: tw-grow .7s cubic-bezier(.2, .7, .2, 1) both, tw-glow 2.4s ease-in-out 1.8s infinite; animation-delay: calc(.7s + var(--i, 0) * 45ms), 1.8s; }
  .tw-kpi-dot { animation: tw-pulse 2.6s ease-out 1.2s 2; }
  .tw-kpi, .tw-action { transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease; }
  a.tw-kpi:hover, .tw-action:hover { transform: translateY(-2px); box-shadow: var(--tw-shadow-lg); }
}
@keyframes tw-rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes tw-fade { from { opacity: 0; } }
@keyframes tw-reveal { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
@keyframes tw-sweep { from { stroke-dasharray: 0 352; } }
@keyframes tw-pop { from { opacity: 0; transform: scale(.85); } }
@keyframes tw-grow { from { transform: scaleY(0); } }
@keyframes tw-glow { 50% { filter: brightness(1.15); box-shadow: 0 0 0 4px var(--tw-brand-soft); } }
@keyframes tw-pulse { 0% { box-shadow: 0 0 0 0 var(--tw-brand-soft); } 60% { box-shadow: 0 0 0 7px var(--tw-brand-soft); } 100% { box-shadow: 0 0 0 0 transparent; } }
.tw-range { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px; }
.tw-range .form-control { width: auto; }
.tw-seg { display: inline-flex; padding: 3px; border: 1px solid var(--tw-border); border-radius: 10px; background: var(--tw-surface); }
.tw-seg button {
  height: 32px; padding: 0 12px; border: none; border-radius: 7px; background: transparent;
  color: var(--tw-text-2); font-size: 13px; font-weight: 500; cursor: pointer;
}
.tw-seg button[aria-pressed="true"] { background: var(--tw-ink); color: var(--tw-surface); }
.tw-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.tw-kpi {
  display: flex; flex-direction: column; gap: 10px; padding: 18px; color: var(--tw-text);
  background: var(--tw-surface); border: 1px solid var(--tw-border); border-radius: var(--tw-radius); box-shadow: var(--tw-shadow);
}
a.tw-kpi:hover { text-decoration: none; color: var(--tw-text); border-color: var(--tw-border-strong); }
.tw-kpi-label { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--tw-text-2); }
.tw-kpi-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 8px; }
.tw-kpi-value { font-size: 28px; line-height: 1.1; font-weight: 700; letter-spacing: -0.02em; }
.tw-kpi-value small { font-size: 13px; font-weight: 500; color: var(--tw-text-3); letter-spacing: 0; }
.tw-kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--tw-text-3); }
.tw-pill { padding: 2px 8px; border-radius: 999px; font-weight: 600; background: var(--tw-surface-2); color: var(--tw-text-2); }
.tw-row { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tw-stack { display: flex; flex-direction: column; gap: 16px; }
.tw-legend { display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--tw-text-2); }
.tw-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tw-legend i { display: inline-block; width: 14px; height: 3px; border-radius: 2px; }
.tw-chart { display: flex; gap: 10px; }
.tw-chart-y { display: flex; flex-direction: column; justify-content: space-between; height: 220px; min-width: 32px; font-size: 11px; color: var(--tw-text-3); text-align: right; }
.tw-chart-body { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.tw-chart svg { display: block; width: 100%; height: 220px; }
.tw-chart-x { display: flex; justify-content: space-between; font-size: 11px; color: var(--tw-text-3); }
.tw-bars { display: flex; align-items: flex-end; gap: 10px; height: 200px; border-bottom: 1px solid var(--tw-grid); }
.tw-bar { flex: 1 1 0; min-width: 0; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 6px; }
.tw-bar span { font-size: 10px; color: var(--tw-text-3); }
.tw-bar div { width: 100%; max-width: 34px; border-radius: 6px 6px 0 0; background: var(--tw-border-strong); min-height: 2px; }
.tw-bar.is-current div { background: var(--tw-chart-1); }
.tw-bars-x { display: flex; gap: 10px; font-size: 11px; color: var(--tw-text-3); }
.tw-bars-x span { flex: 1 1 0; text-align: center; }
.tw-donut-wrap { display: flex; flex-wrap: wrap; align-items: center; gap: 20px; }
.tw-donut { position: relative; width: 148px; height: 148px; flex: 0 0 148px; }
.tw-donut-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.tw-donut-center strong { font-size: 22px; }
.tw-donut-center span { font-size: 11px; color: var(--tw-text-3); }
.tw-donut-list { flex: 1 1 160px; display: flex; flex-direction: column; gap: 9px; margin: 0; padding: 0; list-style: none; font-size: 13px; }
.tw-donut-list li { display: flex; align-items: center; gap: 8px; }
.tw-donut-list i { width: 10px; height: 10px; border-radius: 3px; flex: 0 0 10px; }
.tw-donut-list span { flex: 1 1 auto; color: var(--tw-text-2); }
.tw-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.tw-action {
  display: flex; flex-direction: column; gap: 6px; padding: 14px; min-height: 44px;
  border: 1px solid var(--tw-border); border-radius: 10px; color: var(--tw-text); text-decoration: none;
}
.tw-action:hover { background: var(--tw-surface-2); color: var(--tw-text); text-decoration: none; }
.tw-action .bi { font-size: 20px; color: var(--tw-brand); }
.tw-action strong { font-size: 14px; font-weight: 600; }
.tw-action span { font-size: 12px; color: var(--tw-text-3); }
.tw-list { margin: 0; padding: 0; list-style: none; }
.tw-list li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-top: 1px solid var(--tw-border); font-size: 13px; }
.tw-list li:first-child { border-top: none; }
.tw-list .tw-grow { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.tw-list .tw-meta { color: var(--tw-text-3); }
.tw-table-card { padding: 0; overflow: hidden; }
.tw-table-card .tw-card-head { padding: 18px 20px 0; }
.tw-table-card .table-responsive { border: none; border-radius: 0; border-top: 1px solid var(--tw-border); }
.tw-empty { padding: 32px 16px; text-align: center; color: var(--tw-text-2); font-size: 14px; }

@media (max-width: 1200px) { .tw-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 1100px) { .tw-row { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 560px)  { .tw-kpis, .tw-actions { grid-template-columns: minmax(0, 1fr); } }

/* ---------------------------------------------------------------- expandable rows: no page jump */
/* Browser scroll anchoring moved the page when a detail row opened; js/tws-portal.js keeps the clicked row in place instead. */
.tw-content, .tw-content table { overflow-anchor: none; }
.tw-detail.tw-detail-ajax-only { padding: 12px 16px; }
.tw-detail.tw-detail-ajax-only:empty { display: none; }

/* AWB numbers must not turn into phone links on iPhones (format-detection is also off in the page head). */
a[x-apple-data-detectors] {
  color: inherit !important; text-decoration: none !important; pointer-events: none;
  font: inherit !important;
}

/* ---------------------------------------------------------------- keep every page inside the screen */
/* Wide tables scroll inside their own box; nothing may make the page itself wider than the screen
   (phones zoom the whole page out when that happens). */
body { overflow-x: hidden; }
.tw-main { overflow-x: clip; }
.tw-content > *, .card, .card-body, .card > form, .tw-card { min-width: 0; max-width: 100%; }
.table-responsive { max-width: 100%; container-type: inline-size; }
.table-responsive > table { margin-bottom: 0; }
.card-body img, .card-body iframe, .card-body video { max-width: 100%; }
#suggestions, .suggestionsBox { max-width: calc(100% - 8px); }
@media (max-width: 575.98px) { #suggestions, .suggestionsBox { min-width: 0; left: 0; right: 0; } }

/* ---------------------------------------------------------------- phones and small tablets */
.tw-show-sm { display: none; }
@media (max-width: 767.98px) {
  .tw-content > * { min-width: 0; }
  .card-body { padding: 16px; }
  .tw-form-actions { margin: 8px -16px -16px; padding: 12px 16px; }
  .card > .card-header.tw-header-actions { align-items: stretch; }
  .card > .card-header.tw-header-actions > .tw-btn-row,
  .card > .card-header.tw-header-actions > .btn { width: 100%; }
  .card > .card-header.tw-header-actions .btn { justify-content: center; }
  .card > .card-header.tw-header-actions > .tw-btn-row > .btn { flex: 1 1 auto; }
  .tw-hide-sm { display: none !important; }
  .tw-show-sm { display: block; }

  /* tables: tighter cells; an opened detail panel stays on screen even when the table scrolls sideways */
  .table > :not(caption) > * > * { padding: 10px; }
  /* Sized from the table's own scroll box (container query units), never from the screen: on Android a
     100vw-based width could make the page wider than the screen and the browser zoomed the whole page out. */
  .tw-detail-row .tw-detail { position: sticky; left: 0; width: 100cqw; max-width: 100cqw; box-sizing: border-box; }
  .tw-dl { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
  .tw-detail .tw-btn-row .btn { flex: 1 1 auto; justify-content: center; }
  .table.w-75 { width: 100% !important; }
  .tw-tabs { padding: 4px 8px 0; }
  .tw-toolbar { padding: 12px 16px; }
  .tw-table-foot { padding: 12px 16px; }

  /* forms: 16px text stops iPhone zooming in on focus */
  .form-control, .form-select, .tw-search input { font-size: 16px; }
  .card-body img { max-width: 100%; height: auto; }
  #map { height: 280px; }

  /* tracking panel */
  .tw-track-card { padding: 14px; }
  .tw-timeline-body time { white-space: normal; }

  /* dashboard */
  .tw-page-head h1 { font-size: 22px; }
  /* date range: quick ranges as four equal buttons, From and To side by side, Update full width */
  .tw-page-head { align-items: stretch; }
  .tw-page-head > div:first-child { width: 100%; }
  .tw-range { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; width: 100%; }
  .tw-range > .tw-seg { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); width: 100%; box-sizing: border-box; }
  .tw-range > .tw-seg button { height: 36px; padding: 0 4px; white-space: nowrap; }
  .tw-range > div:not(.tw-seg) { min-width: 0; }
  .tw-range .form-label { font-size: 12px; }
  .tw-range input[type="date"] {
    display: block; width: 100%; min-width: 0; max-width: 100%; min-height: 42px; box-sizing: border-box;
    -webkit-appearance: none; appearance: none; text-align: left; line-height: 1.2;
  }
  .tw-range input[type="date"]::-webkit-date-and-time-value { text-align: left; }
  .tw-range > .btn { grid-column: 1 / -1; justify-content: center; min-height: 42px; }
  .tw-kpi-value { font-size: 24px; }
  .tw-donut-wrap { justify-content: center; }
}
/* Buttons on phones (all pages): no stray legacy margins inside button rows, equal widths in a row,
   comfortable tap targets, and older screens' loose buttons stacked with even spacing. */
@media (max-width: 767.98px) {
  .tw-btn-row > .btn, .tw-form-actions > .btn, .card-body .form-group.mt-3 > .btn,
  .card > .card-header.tw-header-actions .btn { margin: 0 !important; }
  .tw-row-btn { width: 40px; height: 40px; }
  .tw-toolbar .tw-toolbar-reset { width: 100%; justify-content: center; }
  .tw-inline-form .tw-btn-row > * { flex: 1 1 100%; max-width: none !important; }
  .tw-pager { width: 100%; justify-content: space-between; }
  .tw-empty-state .btn { width: 100%; max-width: 320px; }
  .tw-track-pod .btn { align-self: stretch; }
  /* legacy screens: buttons placed straight in the card body */
  .card-body > .btn, .card-body > .table-responsive > .btn { display: flex; width: 100%; margin: 0 0 10px !important; }
  .float-end { float: none !important; }
}
@media (max-width: 575.98px) {
  .tw-btn-row > .btn { flex: 1 1 calc(50% - 4px); justify-content: center; }
  .tw-btn-row > .btn:only-child { flex-basis: 100%; }
  .table td > .tw-btn-row > .btn { flex: 0 0 auto; }
  .tw-dl { grid-template-columns: minmax(0, 1fr); }
  .tw-selbar { padding: 10px 12px; }
  .tw-selbar .btn { flex: 1 1 100%; justify-content: center; }
  .tw-choice { flex: 1 1 calc(50% - 4px); justify-content: flex-start; }
  .tw-cod-amount { max-width: none; }
  .tw-chip-list li { font-size: 12px; }
  .card-body .form-group.mt-3 .btn { flex: 1 1 auto; justify-content: center; }
}

/* ---------------------------------------------------------------- sign-in */
.tw-auth { display: flex; min-height: 100vh; }
.tw-auth-hero {
  flex: 0 0 44%; box-sizing: border-box; padding: 48px 56px; display: flex; flex-direction: column; justify-content: space-between;
  background: #2F3A3D; color: #F4F3EF;
}
[data-bs-theme="dark"] .tw-auth-hero { background: #1D2326; }
.tw-auth-hero h1 { color: #F4F3EF; margin: 0; font-size: 40px; line-height: 1.1; font-weight: 700; letter-spacing: -0.03em; max-width: 460px; }
.tw-auth-points { display: flex; flex-direction: column; gap: 18px; margin: 28px 0 0; padding: 0; list-style: none; max-width: 460px; }
.tw-auth-points li { display: flex; gap: 14px; }
.tw-auth-points .bi {
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, .08); color: #E08A3A; font-size: 17px;
}
.tw-auth-points strong { display: block; font-size: 15px; font-weight: 600; }
.tw-auth-points span { display: block; margin-top: 4px; font-size: 14px; color: #C9C8C2; }
.tw-auth-main { flex: 1 1 0; min-width: 0; display: flex; align-items: center; justify-content: center; padding: 40px 20px; box-sizing: border-box; }
.tw-auth-box { width: 100%; max-width: 400px; display: flex; flex-direction: column; gap: 24px; }
.tw-auth-logo { display: block; width: auto; height: 120px; align-self: flex-start; object-fit: contain; }
html[data-bs-theme="dark"] .tw-auth-logo { padding: 10px 12px; border-radius: 12px; background: #F4F3EF; box-sizing: content-box; }
.tw-auth-box h2 { margin: 0; font-size: 26px; font-weight: 700; letter-spacing: -0.02em; }
.tw-auth-box .form-control { min-height: 44px; font-size: 15px; }
.tw-auth-box .btn-primary { min-height: 46px; width: 100%; font-size: 15px; }
.tw-auth-help { padding-top: 20px; border-top: 1px solid var(--tw-border); font-size: 14px; color: var(--tw-text-2); }
.tw-auth-help p { margin: 0 0 8px; }
.tw-pw { position: relative; }
.tw-pw .form-control { padding-right: 48px; }
.tw-pw button { position: absolute; right: 2px; top: 2px; width: 40px; height: 40px; border: none; background: transparent; color: var(--tw-text-3); border-radius: 8px; }
@media (max-width: 900px) { .tw-auth-hero { display: none; } }

/* ---------------------------------------------------------------- print */
@media print {
  .tw-sidebar, .tw-topbar, .tw-notice, .tw-overlay { display: none !important; }
  .tw-content { max-width: none; padding: 0; }
  .card, .tw-card, .tw-kpi { box-shadow: none !important; }
}

/* Order tickets (Nov 2026): conversation, status line, unread dot, menu badge */
.tw-ticket-status { display: flex; align-items: center; gap: 8px; margin-bottom: 16px; font-size: 13px; color: var(--tw-text-2); }
.tw-ticket-order { margin-top: 12px; }
.tw-thread { list-style: none; margin: 16px 0 24px; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.tw-msg { max-width: 760px; padding: 12px 16px; border: 1px solid var(--tw-border); border-radius: var(--tw-radius); background: var(--tw-surface); }
.tw-msg.is-staff { background: var(--tw-brand-soft); border-color: transparent; }
.tw-msg.is-merchant { margin-left: auto; }
.tw-msg.is-system { max-width: none; padding: 0; border: none; background: transparent; text-align: center; font-size: 13px; color: var(--tw-text-3); }
.tw-msg-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.tw-msg-head time, .tw-msg.is-system time { color: var(--tw-text-3); font-variant-numeric: tabular-nums; }
.tw-msg-head time { margin-left: auto; }
.tw-msg-body { font-size: 14px; overflow-wrap: anywhere; white-space: normal; }
.tw-reply { border-top: 1px solid var(--tw-border); padding-top: 16px; }
.tw-ticket-close { margin-top: 12px; }
.tw-new-dot { display: inline-block; width: 8px; height: 8px; margin-left: 6px; border-radius: 50%; background: var(--tw-danger); vertical-align: middle; }
.tw-nav-badge { margin-left: auto; min-width: 20px; padding: 1px 6px; border-radius: 999px; background: var(--tw-danger); color: #fff; font-size: 11px; font-weight: 700; text-align: center; line-height: 18px; }
.tw-collapsed .tw-nav-badge { display: none; }
@media (max-width: 575.98px) { .tw-msg { max-width: none; } .tw-msg.is-merchant { margin-left: 0; } }
.tw-reply .tw-section-title { font-size: 16px; font-weight: 600; margin: 0 0 12px; padding: 0; }
/* Dashboard: order tickets summary tiles */
.tw-ticket-sum { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tw-ticket-sum a { display: flex; flex-direction: column; gap: 2px; padding: 10px 12px; border: 1px solid var(--tw-border); border-radius: 8px; color: inherit; text-decoration: none; }
.tw-ticket-sum a:hover, .tw-ticket-sum a:focus-visible { border-color: var(--tw-border-strong); background: var(--tw-grid); }
.tw-ticket-sum strong { font-size: 20px; line-height: 1.2; }
.tw-ticket-sum span { font-size: 12px; color: var(--tw-text-2); }
