/* MTD81 Design System: component. Giá trị lấy từ mtd-tokens.css (var(--…)).
 * Mọi class có tiền tố mtd- để sống chung với Bootstrap 4 của template trong lúc chuyển dần từng trang.
 * Nguồn: components/bundle.css của design system + các component trang tổng quan (page-head, task, stat, chart). */

/* ---------- Khung trang ---------- */
/* Căn trái theo menu (không căn giữa như .container-fluid): tiêu đề trang đứng một chỗ khi chuyển trang,
 * và khớp mép với bảng kiểu cũ tràn hết chiều rộng. Trang chi tiết tối đa content-max; trang dữ liệu dùng --wide. */
.mtd-page { font-family: var(--font-sans); color: var(--ink); max-width: var(--content-max); margin-left: 0; margin-right: 0; }
.mtd-page h1, .mtd-page h2, .mtd-page h3, .mtd-page h4 { font-family: var(--font-sans); color: var(--ink); }
.mtd-page a { text-decoration: none; }
.mtd-page-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: var(--space-1) var(--space-3); margin: 0 0 var(--space-4); }
.mtd-page-head h1 { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; }
.mtd-page-head p { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.mtd-section { margin: 0 0 var(--space-5); }
.mtd-section__title { margin: 0 0 var(--space-2); font-size: 16px; line-height: 24px; font-weight: 700; color: var(--ink); }
.mtd-section__title small { font-size: 13px; line-height: 18px; font-weight: 400; color: var(--ink-muted); }
.mtd-grid-2 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: start; }
@media (min-width: 992px) { .mtd-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-5); } }
.mtd-num { font-variant-numeric: tabular-nums; }
.mtd-link { color: var(--brand-navy); text-decoration: none; }
.mtd-link:hover { color: var(--brand-navy-strong); text-decoration: underline; }
.mtd-ico-fa { width: 18px; text-align: center; flex: none; }

/* ---------- Button ---------- */
.mtd-btn { display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 var(--space-4); border: 1px solid transparent; border-radius: var(--radius-md); font-family: var(--font-sans); font-size: 15px; line-height: 22px; font-weight: 500; text-decoration: none; white-space: nowrap; cursor: pointer; background: transparent; color: var(--brand-navy); -webkit-tap-highlight-color: transparent; }
.mtd-btn:hover { text-decoration: none; }
.mtd-btn--primary { background: var(--brand-navy); color: var(--on-brand); }
.mtd-btn--primary:hover { background: var(--brand-navy-strong); color: var(--on-brand); }
.mtd-btn--secondary { background: var(--surface); border-color: var(--line-strong); color: var(--brand-navy); }
.mtd-btn--secondary:hover, .mtd-btn--ghost:hover { background: var(--brand-navy-soft); color: var(--brand-navy); }
.mtd-btn--danger { background: var(--brand-red); color: var(--on-brand); }
.mtd-btn--block { display: flex; width: 100%; }
.mtd-btn--sm { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: 14px; line-height: 20px; }
.mtd-btn:disabled, .mtd-btn[aria-disabled="true"] { background: var(--surface-sunken); border-color: var(--line); color: var(--ink-subtle); cursor: not-allowed; }
.mtd-btn:focus-visible, .mtd-chip:focus-visible, .mtd-seg button:focus-visible, .mtd-input:focus-visible, .mtd-iconbtn:focus-visible,
.mtd-item:focus-visible, .mtd-sheet__item:focus-visible, .mtd-task:focus-visible, .mtd-stat:focus-visible, .mtd-link:focus-visible,
.mtd-item__title a:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-btn__count { min-width: 20px; padding: 0 var(--space-1); border-radius: var(--radius-pill); background: var(--brand-navy); color: var(--on-brand); font-size: 12px; line-height: 20px; text-align: center; }

/* ---------- IconButton, Avatar ---------- */
.mtd-iconbtn { display: inline-flex; align-items: center; justify-content: center; width: var(--tap-target); height: var(--tap-target); padding: 0; border: 0; border-radius: var(--radius-pill); background: transparent; color: var(--ink); text-decoration: none; cursor: pointer; }
.mtd-iconbtn:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.mtd-iconbtn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-avatar { display: inline-flex; flex: none; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--brand-navy-soft); color: var(--brand-navy); font-size: 13px; line-height: 18px; font-weight: 700; }

/* ---------- StatusBadge ---------- */
.mtd-badge { display: inline-flex; align-items: center; gap: var(--space-1); padding: var(--space-1) var(--space-3); border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--ink-muted); font-size: 13px; line-height: 18px; font-weight: 500; white-space: nowrap; }
.mtd-badge::before { content: ""; width: 6px; height: 6px; border-radius: var(--radius-pill); background: currentColor; }
.mtd-badge--success { background: var(--success-soft); color: var(--success); }
.mtd-badge--warning { background: var(--warning-soft); color: var(--warning); }
.mtd-badge--danger { background: var(--brand-red-soft); color: var(--brand-red); }
.mtd-badge--info { background: var(--brand-teal-soft); color: var(--brand-teal); }
.mtd-badge--icon::before { display: none; }

/* ---------- Alert ---------- */
.mtd-alert { display: flex; gap: var(--space-3); align-items: flex-start; padding: var(--space-3) var(--space-4); margin: 0 0 var(--space-3); border-radius: var(--radius-md); background: var(--brand-teal-soft); color: var(--ink); }
.mtd-alert > .mtd-ico-fa { margin-top: 3px; color: var(--brand-teal); }
.mtd-alert__body { flex: 1; min-width: 0; }
.mtd-alert__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 500; }
.mtd-alert__text { margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.mtd-alert--warning { background: var(--warning-soft); }
.mtd-alert--warning > .mtd-ico-fa { color: var(--warning); }
.mtd-alert--danger { background: var(--brand-red-soft); }
.mtd-alert--danger > .mtd-ico-fa { color: var(--brand-red); }
.mtd-alert--success { background: var(--success-soft); }
.mtd-alert--success > .mtd-ico-fa { color: var(--success); }

/* ---------- Card ---------- */
.mtd-card { background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); overflow: hidden; }
.mtd-card__head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); min-height: 52px; padding: var(--space-2) var(--space-2) var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); }
.mtd-card__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 700; color: var(--ink); }
.mtd-card__body { padding: var(--space-4); }
.mtd-card__foot { padding: var(--space-1) var(--space-2); border-top: 1px solid var(--line); }

/* ---------- Việc cần xử lý (task list) ---------- */
.mtd-tasks { list-style: none; margin: 0; padding: 0; }
.mtd-task { display: flex; align-items: center; gap: var(--space-3); min-height: 56px; padding: var(--space-2) var(--space-3) var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); color: var(--ink); text-decoration: none; }
.mtd-tasks > li:last-child .mtd-task { border-bottom: 0; }
.mtd-task:hover { background: var(--surface-sunken); color: var(--ink); text-decoration: none; }
.mtd-task__count { flex: none; min-width: 64px; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); background: var(--neutral-soft); color: var(--ink); font-size: 18px; line-height: 26px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.mtd-task--danger .mtd-task__count { background: var(--brand-red-soft); color: var(--brand-red); }
.mtd-task--warning .mtd-task__count { background: var(--warning-soft); color: var(--warning); }
.mtd-task--info .mtd-task__count { background: var(--brand-teal-soft); color: var(--brand-teal); }
.mtd-task__text { flex: 1; min-width: 0; font-size: 15px; line-height: 22px; }
.mtd-task__hint { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.mtd-task__chev { flex: none; color: var(--ink-muted); }

/* ---------- Ô số liệu (stat tile) ---------- */
.mtd-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
@media (min-width: 768px) { .mtd-stats { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.mtd-stat { display: block; min-width: 0; padding: var(--space-3) var(--space-4); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); color: var(--ink); text-decoration: none; }
a.mtd-stat:hover { color: var(--ink); text-decoration: none; background: var(--brand-navy-soft); }
.mtd-stat__label { margin: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.mtd-stat__value { margin: var(--space-1) 0 0; font-size: 24px; line-height: 32px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mtd-stat__value--money { font-size: 20px; line-height: 32px; }
.mtd-stat__sub { margin: 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ---------- KeyValueList ---------- */
.mtd-kv { margin: 0; }
.mtd-kv__row { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-4); padding: var(--space-3) 0; border-bottom: 1px solid var(--line); }
.mtd-kv__row:first-child { padding-top: 0; }
.mtd-kv__row:last-child { padding-bottom: 0; border-bottom: 0; }
.mtd-kv dt { flex: none; max-width: 40%; font-size: 14px; line-height: 20px; font-weight: 400; color: var(--ink-muted); }
.mtd-kv dd { margin: 0; min-width: 0; text-align: right; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); overflow-wrap: anywhere; }

/* ---------- MoneySummary ---------- */
.mtd-money { padding: var(--space-4); }
.mtd-money__label { margin: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.mtd-money__value { margin: 0; font-size: 28px; line-height: 34px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.mtd-money__meta { display: flex; flex-wrap: wrap; gap: var(--space-1) var(--space-3); margin-top: var(--space-1); font-size: 14px; line-height: 20px; color: var(--ink-muted); }

/* ---------- DataList ---------- */
.mtd-list { list-style: none; margin: 0; padding: 0; }
.mtd-item { position: relative; display: flex; gap: var(--space-3); align-items: flex-start; min-height: var(--tap-target); padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--line); color: inherit; text-decoration: none; }
.mtd-list > li:last-child .mtd-item { border-bottom: 0; }
.mtd-item:hover { background: var(--surface-sunken); }
.mtd-item__main { flex: 1; min-width: 0; }
.mtd-item__title { margin: 0; font-size: 16px; line-height: 24px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.mtd-item__title a { color: var(--brand-navy); }
/* Cả dòng bấm được: link ở tiêu đề phủ cả mục; link khác trong mục nằm trên lớp phủ. */
.mtd-item__title a::after { content: ""; position: absolute; inset: 0; }
.mtd-item__meta { margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); overflow-wrap: anywhere; }
.mtd-item__meta a { position: relative; z-index: 1; color: var(--brand-navy); }
.mtd-item__side { flex: none; display: flex; flex-direction: column; align-items: flex-end; gap: var(--space-1); text-align: right; }
.mtd-item__amount { margin: 0; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); font-variant-numeric: tabular-nums; }
.mtd-item__sub { margin: 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.mtd-item__rank { flex: none; width: 28px; height: 28px; border-radius: var(--radius-pill); background: var(--neutral-soft); color: var(--ink-muted); font-size: 13px; line-height: 28px; font-weight: 700; text-align: center; font-variant-numeric: tabular-nums; }
.mtd-item__rank--top { background: var(--brand-navy-soft); color: var(--brand-navy); }
.mtd-empty { margin: 0; padding: var(--space-5) var(--space-4); text-align: center; font-size: 14px; line-height: 20px; color: var(--ink-muted); }

/* ---------- Biểu đồ ---------- */
.mtd-chart { position: relative; height: 220px; }
@media (min-width: 992px) { .mtd-chart { height: 260px; } }
/* Tổng quan trên màn rộng (từ 1800px, gồm 1920 và 2K): việc cần xử lý | số liệu hôm nay + toàn hệ thống; 4 biểu đồ một hàng.
 * Dưới 1800px .mtd-dash-top là khối thường, các phần xếp chồng như cũ. */
@media (min-width: 1800px) {
    .mtd-dash-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); gap: var(--space-5); align-items: start; }
    .mtd-dash-charts { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* ---------- Bổ sung cho trang chi tiết (phiếu xuất…) ---------- */
.mtd-backlink { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap-target); margin-bottom: var(--space-1); color: var(--brand-navy); font-size: 14px; font-weight: 500; text-decoration: none; }
.mtd-backlink:hover { color: var(--brand-navy-strong); text-decoration: underline; }
.mtd-badges { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: calc(-1 * var(--space-2)) 0 var(--space-4); }
.mtd-alert__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.mtd-money__meta strong { color: var(--ink); font-weight: 500; font-variant-numeric: tabular-nums; }
.mtd-money__meta .is-short { color: var(--brand-red); }
.mtd-money__note { margin: var(--space-1) 0 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.mtd-money__lines { margin: var(--space-3) 0 0; padding: var(--space-3) 0 0; border-top: 1px dashed var(--line); }
.mtd-money__line { display: flex; justify-content: space-between; gap: var(--space-3); padding: 2px 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.mtd-money__line span:last-child { color: var(--ink); font-variant-numeric: tabular-nums; }
.mtd-money__settle { margin: var(--space-3) 0 0; padding: var(--space-3) 0 0; border-top: 1px solid var(--line); }
.mtd-money__settle .mtd-money__line span.is-neg { color: var(--brand-red); }
/* Còn thiếu để thanh toán (ticket #21): dòng kế toán cần nhất, tô nền theo đủ/thiếu */
.mtd-money__due { display: flex; justify-content: space-between; align-items: baseline; gap: var(--space-3); margin-top: var(--space-2); padding: var(--space-2) var(--space-3); border-radius: var(--radius-md); font-size: 15px; line-height: 22px; font-weight: 500; }
.mtd-money__due strong { font-size: 20px; line-height: 26px; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.mtd-money__due.is-short { background: var(--brand-red-soft); color: var(--brand-red); }
.mtd-money__due.is-ok { background: var(--success-soft); color: var(--success); }
.mtd-money__due.is-pending { background: var(--warning-soft); color: var(--warning); }
.mtd-money__due.is-pending strong { font-size: 15px; line-height: 22px; }
.mtd-kv__sub { display: block; font-size: 13px; line-height: 18px; font-weight: 400; color: var(--ink-muted); }
.mtd-list__total { display: flex; justify-content: space-between; gap: var(--space-3); padding: var(--space-3) var(--space-4); background: var(--surface-sunken); font-size: 14px; line-height: 20px; color: var(--ink-muted); }
.mtd-list__total strong { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; }
.mtd-item__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); margin-top: var(--space-2); }
.mtd-btn--danger-text { color: var(--brand-red); }
.mtd-btn--danger-text:hover { background: var(--brand-red-soft); color: var(--brand-red); }

/* ---------- ActionBar: thao tác của một trang chi tiết ----------
 * Một danh sách nút duy nhất (không nhân đôi id), CSS sắp theo màn hình:
 * máy tính: một hàng nút, nút chính nền navy; mobile: thanh dính đáy (Thêm + nút chính) và ngăn trượt lên chứa phần còn lại. */
.mtd-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin: 0 0 var(--space-4); }
.mtd-actions__bar, .mtd-actions__sheet { display: contents; }
.mtd-actions__more, .mtd-actions__sheet-head, .mtd-actions__scrim, .mtd-actions__sep, .mtd-act__hint { display: none; }
.mtd-act { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--control-h-sm); padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--brand-navy); font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer; }
.mtd-act:hover { background: var(--brand-navy-soft); color: var(--brand-navy); text-decoration: none; }
.mtd-act:focus-visible, .mtd-actions__more:focus-visible, .mtd-backlink:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-act i { font-size: 18px; line-height: 1; }
.mtd-act--primary { order: -1; background: var(--brand-navy); border-color: var(--brand-navy); color: var(--on-brand); }
.mtd-act--primary:hover { background: var(--brand-navy-strong); color: var(--on-brand); }
.mtd-act--muted { background: var(--surface-sunken); border-color: var(--line); color: var(--ink-muted); }
/* Trang cũ tô .view-shipping-details thành viên thuốc xanh/cam chữ trắng: trong thanh hành động dùng kiểu nút chung. */
.mtd-actions .mtd-act.view-shipping-details { display: inline-flex; padding: 0 var(--space-3); border-radius: var(--radius-md); background: var(--surface); color: var(--brand-navy); }
.mtd-actions .mtd-act.view-shipping-details:hover { background: var(--brand-navy-soft); color: var(--brand-navy); opacity: 1; }

@media (max-width: 991.98px) {
    .mtd-page--with-actions { padding-bottom: 96px; }
    .mtd-actions { display: block; margin: 0; }
    .mtd-actions__bar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; display: flex; gap: var(--space-2); padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--surface); box-shadow: var(--shadow-bar); }
    .mtd-actions__more { display: inline-flex; flex: none; align-items: center; gap: var(--space-2); min-height: var(--control-h); padding: 0 var(--space-4); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--brand-navy); font-family: var(--font-sans); font-size: 15px; font-weight: 500; cursor: pointer; }
    .mtd-actions__more i { font-size: 18px; }
    .mtd-actions__bar .mtd-act { flex: 1; justify-content: center; min-height: var(--control-h); font-size: 15px; white-space: normal; text-align: center; }
    .mtd-actions__bar .mtd-act .mtd-act__text { overflow: hidden; text-overflow: ellipsis; }
    .mtd-actions__sheet { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1036; display: none; max-height: 80vh; overflow-y: auto; padding: 0 0 calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); background: var(--surface); border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-raised); }
    .mtd-actions.is-open .mtd-actions__sheet { display: block; }
    .mtd-actions.is-open .mtd-actions__scrim { position: fixed; inset: 0; z-index: 1035; display: block; background: rgba(16, 24, 40, 0.45); }
    .mtd-actions__sheet-head { display: block; padding: var(--space-2) var(--space-4) var(--space-1); font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
    .mtd-actions__grip { display: block; width: 40px; height: 4px; margin: 0 auto var(--space-3); border-radius: var(--radius-pill); background: var(--line); }
    .mtd-actions__sheet .mtd-act, .mtd-actions__sheet .mtd-act.view-shipping-details { display: flex; width: 100%; min-height: var(--tap-target); padding: var(--space-2) var(--space-4); border: 0; border-radius: 0; background: transparent; color: var(--ink); font-size: 15px; line-height: 22px; text-align: left; white-space: normal; }
    .mtd-actions__sheet .mtd-act i { width: 20px; color: var(--ink-muted); text-align: center; }
    .mtd-actions__sheet .mtd-act:hover { background: var(--surface-sunken); color: var(--ink); }
    .mtd-actions__sheet .mtd-act--muted, .mtd-actions__sheet .mtd-act--muted:hover { color: var(--ink-subtle); }
    .mtd-actions__sheet .mtd-act__hint { display: block; font-size: 12px; line-height: 16px; font-weight: 400; color: var(--ink-muted); }
    .mtd-actions__sep { display: block; height: 1px; margin: var(--space-2) 0; background: var(--line); }
}

/* Màu theo chức năng (data-tone trên .mtd-act): nhân viên nhận nút bằng màu từ giao diện cũ (phản hồi 30/11/2026: "màu mè cũ dễ phân biệt hơn").
 * fund = nạp tiền (xanh dương), pay = thanh toán / đã xong (xanh lá), notify = báo Zalo (đỏ), edit = sửa giá/phí (vàng, chữ ink), ship = giao hàng (cam).
 * Máy tính: nút tô đặc. Mobile: nút trên thanh đáy tô đặc, trong ngăn "Thêm" chỉ tô icon.
 * .mtd-actions--fixed: trên máy tính mỗi nút đứng yên theo thứ tự trong view (--pos), không đẩy nút chính lên đầu; vạch chia giữa các nhóm. */
.mtd-act[data-tone="fund"] { --act-tone: var(--action-fund); --act-on: var(--on-brand); --act-icon: var(--action-fund); }
.mtd-act[data-tone="pay"] { --act-tone: var(--success); --act-on: var(--on-brand); --act-icon: var(--success); }
.mtd-act[data-tone="notify"] { --act-tone: var(--brand-red); --act-on: var(--on-brand); --act-icon: var(--brand-red); }
.mtd-act[data-tone="edit"] { --act-tone: var(--warning-fill); --act-on: var(--ink); --act-icon: var(--warning); }
.mtd-act[data-tone="ship"] { --act-tone: var(--action-ship); --act-on: var(--on-brand); --act-icon: var(--action-ship); }
@media (min-width: 992px) {
    .mtd-actions--fixed .mtd-act, .mtd-actions--fixed .mtd-actions__sep { order: var(--pos, 0); }
    .mtd-actions--fixed .mtd-act--primary { background: var(--surface); border-color: var(--line-strong); color: var(--brand-navy); }
    .mtd-actions--fixed .mtd-act--primary:hover { background: var(--brand-navy-soft); color: var(--brand-navy); }
    .mtd-actions--fixed .mtd-actions__sep { display: block; align-self: stretch; width: 1px; margin: var(--space-1); background: var(--line-strong); }
    .mtd-actions--fixed .mtd-actions__sep--break { flex-basis: 100%; width: auto; height: 0; margin: 0; background: none; }
    .mtd-actions .mtd-act[data-tone], .mtd-actions .mtd-act[data-tone]:hover { background: var(--act-tone); border-color: var(--act-tone); color: var(--act-on); }
    .mtd-actions .mtd-act[data-tone]:hover { filter: brightness(0.92); }
}
@media (max-width: 991.98px) {
    .mtd-actions__bar .mtd-act[data-tone] { background: var(--act-tone); border-color: var(--act-tone); color: var(--act-on); }
    .mtd-actions__sheet .mtd-act[data-tone] i { color: var(--act-icon); }
    .mtd-actions__sheet-head + .mtd-actions__sep, .mtd-actions__sep + .mtd-actions__sep { display: none; }
}
.mtd-btn--edit { background: var(--warning-fill); border-color: var(--warning-fill); color: var(--ink); }
.mtd-btn--edit:hover { background: var(--warning-fill); color: var(--ink); filter: brightness(0.92); }
/* Ô giá của đơn chưa có giá (bảng đơn trong phiếu): chỉ tô trên màn hình, bản in giữ như cũ. */
@media screen { .mtd-noprice { background: var(--warning-soft) !important; color: var(--warning); font-weight: 600; } }

/* ---------- SegmentedTabs: mỗi tab một ô vuông riêng (bo radius-md, nền surface, viền line, shadow-card) ----------
 * Dùng cho nút trong một danh sách (button role=tab) hoặc link giữa các trang cùng nhóm (.mtd-seg--nav).
 * Tab đang chọn nền brand-navy chữ on-brand. Tab là một trạng thái có chấm màu (data-tone) cùng màu badge của trạng thái đó. */
.mtd-seg { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-3); padding: 0; font-family: var(--font-sans); }
.mtd-seg > a, .mtd-seg > button { flex: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: var(--control-h-sm); padding: 0 var(--space-4); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-card); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-weight: 500; white-space: nowrap; text-decoration: none; cursor: pointer; }
.mtd-seg > a:hover, .mtd-seg > button:hover { border-color: var(--line-strong); background: var(--brand-navy-soft); color: var(--ink); text-decoration: none; }
.mtd-seg > a[aria-current="page"], .mtd-seg > button[aria-selected="true"] { border-color: var(--brand-navy); background: var(--brand-navy); color: var(--on-brand); }
.mtd-seg > a:focus-visible, .mtd-seg > button:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-seg__count { font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.mtd-seg > a[aria-current="page"] .mtd-seg__count, .mtd-seg > button[aria-selected="true"] .mtd-seg__count,
.mtd-seg > a[aria-current="page"] .mtd-zh, .mtd-seg > button[aria-selected="true"] .mtd-zh { color: inherit; }
/* Chấm trạng thái; tab đang chọn thì chấm có viền trắng để vẫn thấy màu trên nền navy */
.mtd-seg > [data-tone]::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: var(--radius-pill); background: var(--ink-subtle); }
.mtd-seg > [data-tone="success"]::before { background: var(--success); }
.mtd-seg > [data-tone="warning"]::before { background: var(--warning-fill); }
.mtd-seg > [data-tone="danger"]::before { background: var(--brand-red); }
.mtd-seg > [data-tone="info"]::before { background: var(--brand-teal); }
.mtd-seg > [aria-current="page"][data-tone]::before, .mtd-seg > [aria-selected="true"][data-tone]::before { box-shadow: 0 0 0 2px var(--on-brand); }
/* Dưới 992px: một hàng cuộn ngang, tab cao đủ vùng chạm; chừa chỗ cho bóng không bị cắt */
@media (max-width: 991.98px) {
    .mtd-seg { flex-wrap: nowrap; overflow-x: auto; -webkit-overflow-scrolling: touch; margin: -4px -4px var(--space-2); padding: 4px 4px var(--space-2); }
    .mtd-seg > a, .mtd-seg > button { min-height: var(--control-h); }
}

/* ---------- Ô nhập, nhãn ---------- */
.mtd-input { box-sizing: border-box; display: block; width: 100%; height: var(--control-h); margin: 0; padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-md); background-color: var(--surface); color: var(--ink); font-family: var(--font-sans); font-size: 15px; line-height: 22px; }
.mtd-input:focus { border-color: var(--brand-navy); outline: 0; box-shadow: 0 0 0 3px var(--brand-navy-soft); }
.mtd-input::placeholder { color: var(--ink-subtle); }
.mtd-select { -webkit-appearance: none; appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='18' height='18' fill='none' stroke='%23545c6e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; }
.mtd-label { display: block; margin: 0 0 var(--space-1); font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); }
.mtd-fields { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); }
.mtd-field { min-width: 0; }
.mtd-field--pair { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-2); }
.mtd-field__error { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 16px; color: var(--brand-red); }

/* ---------- FilterBar: ô tìm + nút Bộ lọc + chip điều kiện ----------
 * Bảng lọc (.mtd-fpanel): máy tính là khối mở ra ngay dưới thanh; < 992px là ngăn trượt từ đáy. */
.mtd-filterbar { margin: 0 0 var(--space-3); }
.mtd-filter { display: flex; gap: var(--space-2); align-items: center; }
.mtd-search { position: relative; flex: 1; min-width: 0; margin: 0; }
.mtd-search > i { position: absolute; left: var(--space-3); top: 50%; transform: translateY(-50%); font-size: 20px; line-height: 1; color: var(--ink-muted); pointer-events: none; }
.mtd-search .mtd-input { padding-left: 40px; }
.mtd-filter .mtd-btn i { font-size: 18px; line-height: 1; }
.mtd-fpanel[hidden], .mtd-fpanel__scrim[hidden] { display: none !important; }
.mtd-fpanel { margin-top: var(--space-2); padding: var(--space-4); background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-card); }
.mtd-fpanel__head, .mtd-fpanel__scrim { display: none; }
.mtd-fpanel__title { margin: 0; font-size: 18px; line-height: 26px; font-weight: 700; color: var(--ink); }
.mtd-fpanel__foot { display: flex; justify-content: flex-end; gap: var(--space-2); margin-top: var(--space-4); }
@media (min-width: 992px) {
    .mtd-fpanel .mtd-fields { grid-template-columns: repeat(4, minmax(0, 1fr)); }
    .mtd-fpanel .mtd-field--pair { grid-column: span 2; }
}
@media (max-width: 991.98px) {
    /* chỉ còn icon nhưng vẫn giữ tên nút cho trình đọc màn hình */
    .mtd-filter__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .mtd-fpanel { position: fixed; left: 0; right: 0; bottom: 0; z-index: 1041; display: flex; flex-direction: column; max-height: 88vh; margin: 0; padding: 0; border-radius: var(--radius-lg) var(--radius-lg) 0 0; box-shadow: var(--shadow-raised); }
    .mtd-fpanel__head { position: relative; display: flex; align-items: center; justify-content: space-between; flex: none; padding: var(--space-4) var(--space-2) var(--space-2) var(--space-4); }
    .mtd-fpanel__grip { position: absolute; top: var(--space-2); left: 50%; width: 40px; height: 4px; margin-left: -20px; border-radius: var(--radius-pill); background: var(--line); }
    .mtd-fpanel .mtd-fields { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: var(--space-1) var(--space-4) var(--space-3); }
    .mtd-fpanel__foot { flex: none; margin: 0; padding: var(--space-3) var(--space-4) calc(var(--space-3) + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); }
    .mtd-fpanel__foot .mtd-btn { flex: 1; }
    .mtd-fpanel__scrim { position: fixed; inset: 0; z-index: 1040; display: block; background: rgba(16, 24, 40, 0.45); }
    body.mtd-sheet-open { overflow: hidden; }
}
/* Gợi ý của jQuery UI phải nổi trên ngăn lọc */
body.mtd-shell .ui-autocomplete { z-index: 1045; }

.mtd-chips { display: flex; flex-wrap: wrap; gap: var(--space-2); margin: 0 0 var(--space-4); }
.mtd-chips:empty { display: none; }
.mtd-chip { display: inline-flex; flex: none; align-items: center; gap: var(--space-1); min-height: var(--control-h-sm); padding: 0 var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-pill); background: var(--surface); color: var(--ink); font-family: var(--font-sans); font-size: 14px; line-height: 20px; white-space: nowrap; text-decoration: none; cursor: pointer; }
a.mtd-chip:hover { border-color: var(--brand-navy); color: var(--brand-navy); text-decoration: none; }
.mtd-chip.is-on, .mtd-chip[aria-pressed="true"] { background: var(--brand-navy-soft); border-color: var(--brand-navy); color: var(--brand-navy); font-weight: 500; }
.mtd-chip i { font-size: 16px; line-height: 1; }
.mtd-chip--clear { border-color: transparent; background: transparent; color: var(--ink-muted); }
.mtd-chip:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (max-width: 991.98px) {
    .mtd-chips--scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
    .mtd-chips--scroll::-webkit-scrollbar { display: none; }
}

/* ---------- Bảng (máy tính) ---------- */
.mtd-table { width: 100%; margin: 0; border-collapse: collapse; font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--ink); }
.mtd-table th { padding: var(--space-2) var(--space-3); border-bottom: 1px solid var(--line-strong); background: var(--surface); font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink-muted); text-align: left; white-space: nowrap; vertical-align: middle; }
.mtd-table td { padding: 10px var(--space-3); border-bottom: 1px solid var(--line); vertical-align: middle; }
.mtd-table tbody tr:last-child td { border-bottom: 0; }
.mtd-table tbody tr:hover { background: #fafbfc; }
.mtd-table .is-num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mtd-table .is-zero { color: var(--ink-subtle); }
.mtd-table .is-actions { white-space: nowrap; }
.mtd-table__id + .mtd-table__sub { white-space: nowrap; }
/* Badge gọn trong bảng để mỗi dòng không cao quá 2 badge */
.mtd-table .mtd-badge { padding: 2px var(--space-2); font-size: 12px; line-height: 16px; }
.mtd-table__check { width: 44px; text-align: center !important; }
.mtd-table__check input { width: 18px; height: 18px; margin: 0; vertical-align: middle; cursor: pointer; }
.mtd-table a { text-decoration: none; }
.mtd-table__id { font-weight: 700; color: var(--brand-navy); font-variant-numeric: tabular-nums; }
.mtd-table__id:hover { color: var(--brand-navy-strong); text-decoration: underline; }
.mtd-table__sub { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.mtd-table__badges { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); }
.mtd-table .mtd-iconbtn { width: 36px; height: 36px; color: var(--ink-muted); font-size: 16px; }
.mtd-table .mtd-iconbtn .mdi { font-size: 20px; line-height: 1; }
.mtd-iconbtn--danger:hover { background: var(--brand-red-soft); color: var(--brand-red); }

/* Thanh trên bảng: số phiếu, thao tác hàng loạt, phân trang */
.mtd-toolbar { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-2); }
.mtd-toolbar__info { font-size: 14px; line-height: 20px; color: var(--ink-muted); font-variant-numeric: tabular-nums; }
.mtd-toolbar .mtd-pager { margin-left: auto; }

/* Phân trang (Views/Pagers/bootstrap_pagination) */
.mtd-pager .pagination { display: flex; flex-wrap: wrap; gap: var(--space-1); margin: 0; padding: 0; list-style: none; }
.mtd-pager .page-link { display: inline-flex; align-items: center; justify-content: center; min-width: 36px; height: 36px; margin: 0; padding: 0 var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md) !important; background: var(--surface); color: var(--brand-navy); font-family: var(--font-sans); font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; text-decoration: none; }
.mtd-pager .page-link:hover { background: var(--brand-navy-soft); border-color: var(--line-strong); color: var(--brand-navy); }
.mtd-pager .page-item.active .page-link { background: var(--brand-navy); border-color: var(--brand-navy); color: var(--on-brand); }
.mtd-pager .page-link:focus { box-shadow: 0 0 0 2px var(--focus-ring); }
.mtd-pager--bottom { display: flex; justify-content: center; margin: var(--space-4) 0 0; }
@media (max-width: 991.98px) { .mtd-pager .page-link { min-width: 40px; height: 40px; } }

/* ---------- DataList: badge + nút trong mục ---------- */
.mtd-item__badges { display: flex; flex-wrap: wrap; gap: var(--space-1); margin-top: var(--space-2); }
.mtd-item__actions { align-items: flex-start; }
.mtd-item__actions > * { position: relative; z-index: 1; }
.mtd-item__actions .mtd-btn i { font-size: 16px; line-height: 1; }
.mtd-empty__action { margin: calc(-1 * var(--space-3)) 0 0; padding: 0 var(--space-4) var(--space-5); text-align: center; }

/* Nút bị chặn kèm lý do ngắn (vd. "Yêu cầu ship" khi chưa sửa giá) */
.mtd-blocked { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.mtd-blocked__why { font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ========== Danh sách đơn hàng (29/11/2026) ========== */
.mtd-page--wide { max-width: none; }
.mtd-head-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.mtd-head-actions .mtd-btn i { font-size: 18px; }
.mtd-field__hint { display: block; min-height: 16px; margin-top: var(--space-1); font-size: 12px; line-height: 16px; color: var(--success); }
.mtd-btn__count--light { background: var(--surface); color: var(--brand-navy); }

/* Menu thả xuống (Bootstrap dropdown) */
.mtd-menu { min-width: 220px; margin-top: var(--space-1); padding: var(--space-1) 0; border: 1px solid var(--line); border-radius: var(--radius-md); box-shadow: var(--shadow-raised); font-family: var(--font-sans); }
.mtd-menu .dropdown-item { display: flex; align-items: center; gap: var(--space-2); min-height: 40px; padding: 0 var(--space-4); font-size: 14px; color: var(--ink); }
.mtd-menu .dropdown-item i { font-size: 18px; color: var(--ink-muted); }
.mtd-menu .dropdown-item:hover, .mtd-menu .dropdown-item:focus { background: var(--surface-sunken); color: var(--ink); }

/* Bảng nhiều cột: cuộn ngang trong khung, cột đầu và cột thao tác đứng yên */
.mtd-table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.mtd-table--dense { font-size: 13px; line-height: 18px; }
.mtd-table--dense th { padding: var(--space-2) 6px; font-size: 12px; line-height: 16px; }
.mtd-table--dense td { padding: var(--space-2) 6px; }
.mtd-table--dense .mtd-table__badges .mtd-badge { padding: 1px 6px; }
.mtd-table--sticky tbody tr:hover { background: transparent; }
.mtd-table--sticky td { background: var(--surface); }
.mtd-table--sticky tbody tr:hover td { background: #fafbfc; }
.mtd-table--sticky th:first-child, .mtd-table--sticky td:first-child { position: sticky; left: 0; z-index: 1; box-shadow: inset -1px 0 0 var(--line); }
.mtd-table--sticky th:last-child, .mtd-table--sticky td:last-child { position: sticky; right: 0; z-index: 1; box-shadow: inset 1px 0 0 var(--line); }
.mtd-table--dense .mtd-iconbtn { width: 30px; height: 30px; }
.mtd-table--dense .mtd-iconbtn .mdi { font-size: 18px; }
.mtd-nowrap { white-space: nowrap; }
.mtd-ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mtd-stamp { display: block; white-space: nowrap; font-variant-numeric: tabular-nums; }
.mtd-stamp b { display: inline-block; min-width: 20px; font-size: 12px; font-weight: 700; color: var(--ink-muted); }
.mtd-goods { max-width: 120px; }
.mtd-order-code { min-width: 160px; }
.mtd-order-code__line { display: flex; align-items: center; gap: var(--space-1); white-space: nowrap; }
.mtd-order-code .mtd-table__sub a { color: var(--brand-navy); }
.mtd-order-code .mtd-table__sub, .mtd-table td.mtd-customer { white-space: nowrap; }
.mtd-table td.mtd-customer { max-width: 96px; }
.mtd-note { font-size: 16px; color: var(--brand-teal); cursor: help; }

/* Ô sửa số trong bảng */
.mtd-cell-input { box-sizing: border-box; width: 62px; height: 32px; padding: 0 var(--space-2); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--ink); font-family: var(--font-sans); font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; }
.mtd-cell-input--wide { width: 78px; }
.mtd-cell-input--sm { width: 58px; }
.mtd-cell-input:focus { border-color: var(--brand-navy); outline: 0; box-shadow: 0 0 0 3px var(--brand-navy-soft); }
.mtd-cell-input:disabled { border-color: transparent; background: transparent; color: var(--ink); }
.is-dirty .mtd-cell-input { border-color: var(--warning-fill); background: var(--warning-soft); }

/* Hàng thực phẩm 🐭: nền vàng nhạt + vạch trái để kho dễ nhận ra */
.mtd-table tbody tr.food-row td { background: var(--warning-soft); }
.mtd-table tbody tr.food-row:hover td { background: #ffeab8; }
.mtd-table tbody tr.food-row td:first-child { box-shadow: inset 4px 0 0 var(--warning-fill), inset -1px 0 0 var(--line); }
.mtd-list > li.food-row { background: var(--warning-soft); box-shadow: inset 4px 0 0 var(--warning-fill); }
.mtd-table .food-flag, .mtd-item .food-flag { position: relative; z-index: 1; font-size: 18px; line-height: 1; cursor: pointer; }
.mtd-table .food-flag.is-off, .mtd-item .food-flag.is-off { opacity: .25; filter: grayscale(100%); }

/* Gợi ý khách hàng (jQuery UI) */
.mtd-ac-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); font-family: var(--font-sans); font-size: 14px; }
.mtd-ac-item .mtd-badge { padding: 0 var(--space-2); font-size: 12px; line-height: 18px; }
/* Khung menu gợi ý theo design system (chỉ menu có mtd-ac-item; menu jQuery UI của trang cũ giữ nguyên) */
body.mtd-shell .ui-autocomplete:has(.mtd-ac-item) { max-height: 320px; overflow-y: auto; padding: var(--space-1) 0; border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-raised); }
body.mtd-shell .ui-autocomplete .mtd-ac-item { margin: 0; padding: var(--space-2) var(--space-3); border: 0; color: var(--ink); line-height: 20px; }
body.mtd-shell .ui-autocomplete .mtd-ac-item.ui-state-active { margin: 0; border: 0; background: var(--brand-navy-soft); color: var(--ink); }

/* Hộp thoại (Bootstrap modal): thêm class mtd-modal vào .modal. Nút đóng là mtd-iconbtn. */
.mtd-modal .modal-content { border: 0; border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-raised); font-family: var(--font-sans); color: var(--ink); }
.mtd-modal .modal-header { align-items: center; padding: var(--space-3) var(--space-3) var(--space-3) var(--space-5); border-bottom: 1px solid var(--line); }
.mtd-modal .modal-title { margin: 0; font-family: var(--font-sans); font-size: 18px; line-height: 26px; font-weight: 700; color: var(--ink); }
.mtd-modal .modal-header, .mtd-modal .modal-footer { border-radius: 0; }
.mtd-modal .modal-header .mtd-iconbtn { flex: none; margin-left: auto; }
.mtd-modal .modal-header .mtd-iconbtn i { font-size: 20px; line-height: 1; }
.mtd-modal .modal-body { padding: var(--space-5); font-size: 15px; line-height: 22px; color: var(--ink); }
.mtd-modal .modal-body a { color: var(--brand-navy); font-weight: 500; }
.mtd-modal .modal-body .mtd-alert:not([hidden]) + *, .mtd-modal .modal-body * + .mtd-alert { margin-top: var(--space-4); }
.mtd-modal .modal-body > :last-child { margin-bottom: 0; }
.mtd-modal .modal-footer { gap: var(--space-2); padding: var(--space-3) var(--space-5); border-top: 1px solid var(--line); }
.mtd-modal .modal-footer > * { margin: 0; }
@media (max-width: 575.98px) { .mtd-modal .modal-header { padding-left: var(--space-4); } .mtd-modal .modal-body { padding: var(--space-4); } .mtd-modal .modal-footer { padding: var(--space-3) var(--space-4); } }

/* Chọn một trong vài cách (radio): mỗi lựa chọn là một ô bấm được, dòng tên + dòng giải thích */
.mtd-choices { display: grid; gap: var(--space-2); min-width: 0; margin: 0; padding: 0; border: 0; }
.mtd-choices > legend { margin: 0 0 var(--space-1); padding: 0; font-size: 13px; line-height: 18px; font-weight: 500; color: var(--ink); }
.mtd-choice { display: flex; align-items: flex-start; gap: var(--space-3); min-height: var(--tap-target); margin: 0; padding: var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); color: var(--ink); font-family: var(--font-sans); font-weight: 400; cursor: pointer; }
.mtd-choice:hover { background: var(--surface-sunken); }
.mtd-choice:has(input:checked) { border-color: var(--brand-navy); background: var(--brand-navy-soft); }
.mtd-choice:has(input:disabled) { background: var(--surface-sunken); color: var(--ink-subtle); cursor: not-allowed; }
.mtd-choice input { flex: none; width: 18px; height: 18px; margin: 2px 0 0; accent-color: var(--brand-navy); }
.mtd-choice input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-choice__title { display: block; font-size: 15px; line-height: 22px; font-weight: 500; }
.mtd-choice__text { display: block; font-size: 12px; line-height: 16px; color: var(--ink-muted); }

/* ---------- Trang hồ sơ (chi tiết khách hàng, mã phụ): cột thông tin + cột hoạt động ----------
 * Máy tính từ 1200px: cột trái 360px (ai, liên hệ, số dư, bảng giá), cột phải là hoạt động. Hẹp hơn thì xếp chồng. */
.mtd-profile { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
.mtd-profile__aside, .mtd-profile__main { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
@media (min-width: 1200px) { .mtd-profile { grid-template-columns: 360px minmax(0, 1fr); gap: var(--space-5); } }
.mtd-profile .mtd-section { margin: 0; }
.mtd-id { display: flex; align-items: center; gap: var(--space-3); padding: var(--space-4); }
.mtd-id .mtd-avatar { width: 48px; height: 48px; font-size: 20px; }
.mtd-id__name { min-width: 0; }
.mtd-id__name strong { display: block; font-size: 20px; line-height: 28px; font-weight: 700; color: var(--ink); overflow-wrap: anywhere; }
.mtd-id__name span { display: block; font-size: 14px; line-height: 20px; color: var(--ink-muted); overflow-wrap: anywhere; }
.mtd-id + .mtd-card__body { padding-top: 0; }
.mtd-kv dd a { color: var(--brand-navy); }
.mtd-stats--5 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (min-width: 768px) { .mtd-stats--5 { grid-template-columns: repeat(5, minmax(0, 1fr)); } }
.mtd-stat--static { cursor: default; }
.mtd-caption { margin: var(--space-2) 0 0; font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.mtd-money__value.is-neg, .mtd-table .is-neg, .mtd-item__amount.is-neg { color: var(--brand-red); }
.mtd-ctv { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-4); border-bottom: 1px solid var(--line); font-size: 14px; line-height: 20px; }
.mtd-ctv:last-child { border-bottom: 0; }
.mtd-ctv__side { display: flex; align-items: center; gap: var(--space-2); flex: none; }
.mtd-kv--compact .mtd-kv__row { padding: 6px 0; }
.mtd-kv__group { margin: var(--space-3) 0 var(--space-1); font-size: 13px; line-height: 18px; font-weight: 700; color: var(--ink); }

/* Lịch sử thay đổi: thu gọn mặc định (<details>), mở khi cần */
.mtd-collapse > summary { cursor: pointer; list-style: none; }
.mtd-collapse > summary::-webkit-details-marker { display: none; }
.mtd-collapse > summary .mtd-collapse__chev { font-size: 20px; line-height: 1; color: var(--ink-muted); transition: transform .15s; }
.mtd-collapse[open] > summary .mtd-collapse__chev { transform: rotate(180deg); }
.mtd-collapse > summary:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.mtd-change { margin: var(--space-1) 0 0; font-size: 13px; line-height: 18px; color: var(--ink); overflow-wrap: anywhere; }
.mtd-change del { color: var(--ink-muted); text-decoration: none; }
.mtd-change ins { color: var(--brand-navy); text-decoration: none; font-weight: 500; }

/* ---------- Form (thêm/sửa khách hàng, mã phụ) ---------- */
.mtd-form-layout { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); align-items: start; }
@media (min-width: 1200px) { .mtd-form-layout { grid-template-columns: minmax(0, 760px) minmax(0, 360px); gap: var(--space-5); } }
.mtd-form-layout__main, .mtd-form-layout__aside { display: flex; flex-direction: column; gap: var(--space-4); min-width: 0; }
/* Nút gửi đặt sau cột phải (trên mobile điền hết mới tới nút) nhưng trên máy tính luôn nằm dưới cột chính */
.mtd-form-layout > .mtd-form-actions { grid-column: 1; }
.mtd-form-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-4); }
@media (min-width: 768px) { .mtd-form-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-4) var(--space-5); } .mtd-form-grid .mtd-field--full { grid-column: 1 / -1; } }
.mtd-req { color: var(--brand-red); }
textarea.mtd-input { height: auto; min-height: 88px; padding: var(--space-2) var(--space-3); line-height: 22px; resize: vertical; }
.mtd-input[disabled], .mtd-input[readonly] { background: var(--surface-sunken); color: var(--ink-muted); }
.mtd-input.is-invalid { border-color: var(--brand-red); }
.mtd-input.is-valid { border-color: var(--success); }
.mtd-field__help { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 16px; color: var(--ink-muted); }
.mtd-suffix { position: relative; }
.mtd-suffix .mtd-input { padding-right: 44px; }
.mtd-suffix > span { position: absolute; right: var(--space-3); top: 50%; transform: translateY(-50%); font-size: 14px; color: var(--ink-muted); pointer-events: none; }
.mtd-form-actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mtd-form-actions .mtd-btn { min-width: 120px; justify-content: center; }
.mtd-notes { margin: 0; padding-left: var(--space-5); font-size: 14px; line-height: 22px; color: var(--ink); }
.mtd-notes li + li { margin-top: var(--space-2); }

/* Danh sách khách hàng: cột thông tin không giãn quá rộng trên màn lớn */
.mtd-table td.mtd-cell-address { max-width: 280px; }
.mtd-filter__select { flex: 0 1 320px; min-width: 0; }
@media (max-width: 767.98px) { .mtd-filter--wrap { flex-wrap: wrap; } .mtd-filter--wrap .mtd-filter__select { flex: 1 1 100%; order: 3; } }
.mtd-item__amount.is-pos { color: var(--success); }
.mtd-item__amount.is-zero { color: var(--ink-subtle); }
.mtd-card__body > .mtd-badges { margin: 0 0 var(--space-3); }
.mtd-card__head .mtd-head-actions { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.mtd-cell-address > .mtd-ellipsis { display: block; }
/* Màn 1200–1599px: cột phải của trang hồ sơ hẹp, hai danh sách xếp chồng; bảng khách hàng thu cột địa chỉ để vừa 1366px */
@media (min-width: 1200px) and (max-width: 1599.98px) { .mtd-profile__main .mtd-grid-2 { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 1599.98px) { .mtd-table td.mtd-cell-address { max-width: 180px; } }
.mtd-table td.mtd-cell-name { max-width: 220px; }
.mtd-cell-name .mtd-table__sub { overflow: hidden; text-overflow: ellipsis; }
.mtd-filter__select--sm { flex: 0 1 220px; }
@media (max-width: 767.98px) { .mtd-filter--stack { flex-wrap: wrap; } .mtd-filter--stack .mtd-filter__select { flex: 1 1 100%; } }

/* ---------- Thêm đơn hàng (/orders/create) ---------- */
/* Chữ Trung kèm nhãn tiếng Việt cho kho Trung Quốc: chữ phụ, không đậm */
.mtd-zh { margin-left: var(--space-1); font-weight: 400; color: var(--ink-muted); }
h1 .mtd-zh { font-size: 16px; }
.mtd-btn .mtd-zh, .mtd-badge .mtd-zh { color: inherit; }
/* Ba ô nhỏ chung một nhãn (dài × rộng × cao) */
.mtd-field--dims > div { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); }
.mtd-field__warn { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 16px; font-weight: 500; color: var(--warning); }
.mtd-input.is-warn { border-color: var(--warning-fill); background-color: var(--warning-soft); }
.mtd-picked { display: block; margin-top: var(--space-1); font-size: 12px; line-height: 16px; color: var(--success); }
/* Chọn kho làm việc: hai ô lớn trong hộp thoại */
.mtd-pick { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); }
.mtd-pick__opt { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-1); min-height: 112px; padding: var(--space-4); border: 2px solid var(--line); border-radius: var(--radius-lg); background: var(--surface); color: var(--ink); font-family: var(--font-sans); text-align: left; cursor: pointer; }
.mtd-pick__opt:hover { border-color: var(--line-strong); background: var(--surface-sunken); }
.mtd-pick__opt[aria-pressed="true"] { border-color: var(--brand-navy); background: var(--brand-navy-soft); }
.mtd-pick__opt:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-pick__opt:disabled { cursor: progress; opacity: .6; }
.mtd-pick__name { font-size: 18px; line-height: 26px; font-weight: 700; }
.mtd-pick__text { font-size: 12px; line-height: 16px; color: var(--ink-muted); }
@media (max-width: 575.98px) { .mtd-pick { grid-template-columns: minmax(0, 1fr); } .mtd-pick__opt { min-height: 0; } }
/* Bảng nhập nhiều đơn: ô nhập trong bảng dày, cột chữ căn trái */
.mtd-bulk .mtd-cell-input { width: 100%; min-width: 56px; }
.mtd-bulk .mtd-cell-input--text { text-align: left; font-variant-numeric: normal; }
.mtd-bulk select.mtd-cell-input { -webkit-appearance: auto; appearance: auto; padding: 0 var(--space-1); text-align: left; }
.mtd-bulk .mtd-cell-input.is-invalid { border-color: var(--brand-red); background: var(--brand-red-soft); }
.mtd-bulk .mtd-cell-input.is-warn { border-color: var(--warning-fill); background: var(--warning-soft); }
.mtd-bulk input[type="checkbox"] { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-navy); vertical-align: middle; }
.mtd-bulk .mtd-field__error, .mtd-bulk .mtd-field__warn, .mtd-bulk .mtd-picked { white-space: normal; }
.mtd-bulk__no { color: var(--ink-muted); text-align: right; font-variant-numeric: tabular-nums; }
.mtd-bulk tr.is-error td { background: var(--brand-red-soft); }
.mtd-bulk__foot { display: flex; flex-wrap: wrap; align-items: flex-end; gap: var(--space-3) var(--space-4); padding: var(--space-4); border-top: 1px solid var(--line); }
.mtd-bulk__foot .mtd-field { width: 200px; }
.mtd-bulk__foot .mtd-form-actions { margin-left: auto; align-items: center; }
.mtd-errlist { margin: var(--space-1) 0 0; padding-left: var(--space-5); font-size: 14px; line-height: 20px; color: var(--ink); }
.mtd-bulk th.is-code { min-width: 170px; } .mtd-bulk th.is-customer { min-width: 220px; } .mtd-bulk th.is-name { min-width: 150px; }
.mtd-bulk th.is-pkg { min-width: 96px; } .mtd-bulk th.is-qty { min-width: 60px; } .mtd-bulk th.is-kg { min-width: 76px; }
.mtd-bulk th.is-lot { min-width: 112px; } .mtd-bulk th.is-dim { min-width: 64px; } .mtd-bulk th.is-vol { min-width: 84px; }
/* Màn 1366–1599px: bảng nhập nhiều đơn vừa khung (chữ Trung của tiêu đề cột xuống dòng, ô hẹp hơn) */
@media (max-width: 1599.98px) {
    .mtd-bulk th { white-space: normal; }
    .mtd-bulk th .mtd-zh { display: block; margin-left: 0; }
    .mtd-bulk th, .mtd-bulk td { padding-left: var(--space-1); padding-right: var(--space-1); }
    .mtd-bulk th.is-code { min-width: 128px; } .mtd-bulk th.is-customer { min-width: 150px; } .mtd-bulk th.is-name { min-width: 92px; }
    .mtd-bulk th.is-pkg { min-width: 70px; } .mtd-bulk th.is-qty { min-width: 44px; } .mtd-bulk th.is-kg { min-width: 56px; }
    .mtd-bulk th.is-lot { min-width: 88px; } .mtd-bulk th.is-dim { min-width: 46px; } .mtd-bulk th.is-vol { min-width: 62px; }
    .mtd-bulk .mtd-cell-input { min-width: 0; padding: 0 var(--space-1); }
}

/* ---------- Bao hàng (/packages) ---------- */
/* Thanh lọc: ô tìm + khoảng ngày; dưới 768px ô tìm một hàng, hai ô ngày và nút Lọc hàng dưới */
.mtd-filter__date { flex: 0 0 172px; min-width: 0; }
@media (max-width: 767.98px) {
    .mtd-filter--dates { flex-wrap: wrap; }
    .mtd-filter--dates .mtd-search { flex: 1 1 100%; }
    .mtd-filter--dates .mtd-filter__date { flex: 1 1 0; }
}
/* Xem theo ngày: nút ngày trước/sau quanh ngày đang xem, tổng của ngày bên phải */
.mtd-daynav__date { min-width: 104px; font-size: 16px; line-height: 24px; text-align: center; font-variant-numeric: tabular-nums; color: var(--ink); }
.mtd-daynav__sum { margin-left: auto; }
@media (max-width: 767.98px) { .mtd-daynav__sum { flex: 1 1 100%; margin-left: 0; } }
.mtd-table__id.mtd-nocode, .mtd-item__title .mtd-nocode { font-weight: 400; }

/* ---------- Đầu trang danh sách gọn (Mali: "tối ưu khoảng trống") ----------
 * .mtd-listbar: tab trạng thái và thanh tìm chung một hàng khi đủ chỗ (FullHD); thiếu chỗ thì thanh tìm xuống dòng.
 * Chip lọc (đang bật / lọc nhanh) nằm trong .mtd-toolbar cạnh số dòng và phân trang, không thêm hàng riêng. */
.mtd-listbar { display: flex; flex-wrap: wrap; align-items: flex-start; gap: var(--space-2) var(--space-3); margin: 0 0 var(--space-3); }
.mtd-listbar > .mtd-seg { flex: none; max-width: 100%; margin: 0; }
.mtd-listbar > .mtd-filterbar { flex: 1 1 100%; min-width: 0; margin: 0; }
.mtd-toolbar__chips { flex: 0 1 auto; min-width: 0; margin: 0; }
@media (max-width: 991.98px) {
    .mtd-listbar > .mtd-seg { flex: 1 1 100%; margin: -4px -4px 0; }
    .mtd-toolbar__chips { flex: 1 1 100%; }
}
/* Máy tính: mọi ô của hàng đầu cao 36px (bằng tab, chip, phân trang); thanh tìm rộng vừa đủ, neo lề phải
 * thẳng cột với nút ở đầu trang và phân trang; bảng lọc là khung nổi dưới thanh tìm, bấm ra ngoài thì đóng. */
@media (min-width: 992px) {
    .mtd-listbar { align-items: center; }
    .mtd-listbar > .mtd-filterbar { position: relative; flex: 0 1 auto; margin-left: auto; }
    .mtd-listbar .mtd-search { flex: 0 1 auto; width: 360px; min-width: 180px; }
    .mtd-listbar .mtd-filter .mtd-input { height: var(--control-h-sm); font-size: 14px; line-height: 20px; }
    .mtd-listbar .mtd-search .mtd-input { padding-left: 36px; }
    .mtd-listbar .mtd-search > i { left: 10px; font-size: 18px; }
    .mtd-listbar .mtd-filter > .mtd-btn { min-height: var(--control-h-sm); padding: 0 var(--space-3); font-size: 14px; line-height: 20px; }
    .mtd-listbar .mtd-filter__date { flex: 0 0 150px; }
    .mtd-listbar .mtd-filter__select { flex: 0 1 280px; }
    .mtd-listbar .mtd-fpanel { position: absolute; top: calc(100% + var(--space-2)); right: 0; z-index: 30; width: min(760px, calc(100vw - 300px)); margin: 0; border: 1px solid var(--line); box-shadow: var(--shadow-raised); }
    .mtd-listbar .mtd-fpanel__scrim:not([hidden]) { position: fixed; inset: 0; z-index: 29; display: block; background: transparent; }
}
/* 992–1599px (1366): nút "Bộ lọc" chỉ còn icon + số, tab lề hẹp hơn, ô tìm 220px để tab và thanh tìm vừa một hàng
 * (kể cả khi Windows có thanh cuộn 17px); tên nút vẫn có cho trình đọc màn hình */
@media (min-width: 992px) and (max-width: 1599.98px) {
    .mtd-listbar .mtd-filter__label { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .mtd-listbar > .mtd-seg > a, .mtd-listbar > .mtd-seg > button { padding: 0 var(--space-3); }
    .mtd-listbar .mtd-search { width: 220px; }
}
/* Chip lọc vuông như tab (bo radius-md) */
.mtd-chip { border-radius: var(--radius-md); }
/* Dưới 1600px (1366): bỏ dòng "Đơn 1–30 / N" ở hàng có chip để chip và phân trang chung một hàng (tổng đã có ở đầu trang) */
@media (max-width: 1599.98px) { .mtd-toolbar:has(> .mtd-toolbar__chips) > .mtd-toolbar__info:not(.mtd-daynav__sum) { display: none !important; } }
/* Link riêng ở cột phải của mục danh sách (vd. số đơn của mã phụ) nằm trên lớp phủ link tiêu đề để bấm được */
.mtd-item__side a { position: relative; z-index: 1; }
/* Chip lọc là hàng phụ nên nhẹ hơn tab (tab là ô trắng có bóng): nền trong suốt, viền line.
 * Chip là một trạng thái có chấm màu (data-tone) như tab và badge, màu lấy từ bảng màu trạng thái chung (status_helper). */
.mtd-chip { border-color: var(--line); background: transparent; }
.mtd-chip:not(.is-on):not(.mtd-chip--clear):hover { border-color: var(--line-strong); background: var(--surface); }
.mtd-chip[data-tone]::before { content: ""; flex: none; width: 8px; height: 8px; margin-right: 2px; border-radius: var(--radius-pill); background: var(--ink-subtle); }
.mtd-chip[data-tone="success"]::before { background: var(--success); }
.mtd-chip[data-tone="warning"]::before { background: var(--warning-fill); }
.mtd-chip[data-tone="danger"]::before { background: var(--brand-red); }
.mtd-chip[data-tone="info"]::before { background: var(--brand-teal); }
/* Nút thao tác ở hàng công cụ (Cập nhật giá, Xuất phiếu đã chọn) cùng độ nhẹ với chip */
.mtd-toolbar > .mtd-btn--secondary { border-color: var(--line); }
.mtd-toolbar > .mtd-btn--secondary:hover { border-color: var(--line-strong); }

/* ---------- Chi tiết bao hàng ---------- */
/* Thanh tiến độ (thẻ <progress>): nền neutral-soft, phần đã xong màu success */
.mtd-progress { display: block; width: 100%; height: 8px; margin: var(--space-2) 0 0; border: 0; border-radius: var(--radius-pill); background: var(--neutral-soft); overflow: hidden; -webkit-appearance: none; appearance: none; }
.mtd-progress::-webkit-progress-bar { background: var(--neutral-soft); border-radius: var(--radius-pill); }
.mtd-progress::-webkit-progress-value { background: var(--success); border-radius: var(--radius-pill); }
.mtd-progress::-moz-progress-bar { background: var(--success); border-radius: var(--radius-pill); }
.mtd-stat__value.is-zero { color: var(--ink-subtle); }
/* Thao tác hàng loạt ở hàng đầu (cạnh tab), neo lề phải như thanh tìm */
.mtd-bulkbar { align-items: center; gap: var(--space-3); }
@media (min-width: 992px) { .mtd-listbar > .mtd-bulkbar { margin-left: auto; } }
/* Nút phụ lặp lại ở mỗi dòng bảng (Về kho VN, Yêu cầu ship) viền nhạt để bảng không nặng */
.mtd-table .mtd-btn--secondary { border-color: var(--line); }
.mtd-table .mtd-btn--secondary:hover { border-color: var(--line-strong); }

/* ---------- Xếp xe (/loading) ---------- */
/* Thao tác hàng loạt nằm bên trái hàng đầu (ô mã lô + nút Xếp xe + gợi ý), thanh tìm bên phải */
.mtd-bulkbar--start { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-3); min-width: 0; }
@media (min-width: 992px) {
    .mtd-listbar > .mtd-bulkbar--start { margin-left: 0; }
    .mtd-bulkbar .mtd-input { height: var(--control-h-sm); font-size: 14px; line-height: 20px; }
}
.mtd-bulkbar__lot { width: 160px; }
@media (max-width: 991.98px) { .mtd-listbar > .mtd-bulkbar--start { flex: 1 1 100%; } .mtd-bulkbar__lot { flex: 1 1 140px; width: auto; } }
/* Mục danh sách có ô chọn (mobile) */
.mtd-item--check > input[type="checkbox"] { position: relative; z-index: 1; flex: none; width: 20px; height: 20px; margin: 2px 0 0; accent-color: var(--brand-navy); }
@media (min-width: 992px) { .mtd-fpanel .mtd-field--wide { grid-column: span 2; } }

/* ---------- Tạo phiếu xuất (giỏ, /invoices/cart) ---------- */
/* Ô bắn mã lớn (máy quét gửi Enter), nút thêm bên phải */
.mtd-scanbar { display: flex; gap: var(--space-2); align-items: center; max-width: 720px; margin: 0 0 var(--space-4); }
.mtd-scanbar .mtd-search { flex: 1 1 auto; }
.mtd-scanbar .mtd-input { font-size: 16px; }
.mtd-cartgroup__name { margin-left: var(--space-1); font-weight: 400; color: var(--ink-muted); }
.mtd-cartsub + .mtd-cartsub { border-top: 1px solid var(--line-strong); }
.mtd-cartsub__head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: var(--space-2) var(--space-4); padding: var(--space-3) var(--space-4); background: var(--surface); border-bottom: 1px solid var(--line); }
.mtd-cartsub__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 700; color: var(--ink); }
.mtd-cartsub__meta { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); margin: 2px 0 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
@media (max-width: 575.98px) { .mtd-scanbar .mtd-btn { padding: 0 var(--space-3); } }

/* ---------- Nhập kho Việt Nam (/orders/vncheck2) ---------- */
/* Mốc thời gian của đơn (nhập kho TQ, nhập kho VN...) */
.mtd-timeline { position: relative; margin: 0; padding: 0 0 0 var(--space-5); list-style: none; }
.mtd-timeline::before { content: ""; position: absolute; top: 6px; bottom: 6px; left: 7px; width: 2px; background: var(--line); }
.mtd-timeline li { position: relative; padding: 2px 0 var(--space-3); font-size: 15px; line-height: 22px; color: var(--ink); }
.mtd-timeline li:last-child { padding-bottom: 0; }
.mtd-timeline li::before { content: ""; position: absolute; left: calc(-1 * var(--space-5) + 2px); top: 7px; width: 12px; height: 12px; border: 2px solid var(--surface); border-radius: var(--radius-pill); background: var(--brand-navy); box-shadow: 0 0 0 1px var(--brand-navy); }
.mtd-timeline__time { display: inline-block; min-width: 128px; font-weight: 500; font-variant-numeric: tabular-nums; color: var(--ink-muted); }
.mtd-vnform { display: grid; gap: var(--space-3); margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--line); }
.mtd-vnform .mtd-alert, .mtd-vnform .mtd-field__help { margin: 0; }
/* Cảnh báo hàng thực phẩm cho kho: to, nổi, đọc được từ xa */
.mtd-foodwarn { display: flex; align-items: center; gap: var(--space-5); margin: 0 0 var(--space-4); padding: var(--space-4) var(--space-5); border: 3px solid var(--warning-fill); border-radius: var(--radius-lg); background: var(--warning-soft); }
.mtd-foodwarn__icon { flex: none; font-size: 56px; line-height: 1; }
.mtd-foodwarn__body { min-width: 0; }
.mtd-foodwarn__title { margin: 0; font-size: 26px; line-height: 32px; font-weight: 700; color: var(--warning); }
.mtd-foodwarn__text { margin: var(--space-1) 0 0; font-size: 16px; line-height: 24px; color: var(--ink); }
@media (max-width: 575.98px) { .mtd-foodwarn { gap: var(--space-3); padding: var(--space-3); } .mtd-foodwarn__icon { font-size: 40px; } .mtd-foodwarn__title { font-size: 20px; line-height: 26px; } }

/* ---------- Hợp đồng chính ngạch (/official-orders) ---------- */
.mtd-stats--3 { grid-template-columns: repeat(1, minmax(0, 1fr)); }
@media (min-width: 576px) { .mtd-stats--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
/* Trạng thái do người dùng tự đặt (tên + màu): nhãn trung tính, chỉ chấm mang màu đã đặt (--status). */
.mtd-badge--custom { background: var(--neutral-soft); color: var(--ink); }
.mtd-badge--custom::before { background: var(--status, var(--ink-muted)); }
/* Ô chữ dài (ghi chú sản phẩm...) trong bảng: một dòng, cắt "…", xem đủ ở title */
.mtd-table td.mtd-cell-clip { max-width: 280px; }
.mtd-cell-clip > .mtd-ellipsis { display: block; }
@media (max-width: 1599.98px) { .mtd-table td.mtd-cell-clip { max-width: 180px; } }
.mtd-table td.mtd-cell-nowrap { white-space: nowrap; }
.mtd-cell-clip .mtd-table__sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- Tạo hợp đồng chính ngạch (/official-orders/create) ---------- */
.mtd-choices--row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.mtd-choices--row > .mtd-field__error { grid-column: 1 / -1; margin-top: 0; }
.mtd-choices--row .mtd-choice { align-items: center; }
.mtd-stack { display: flex; flex-direction: column; gap: var(--space-4); }
.mtd-section-help { margin: 0 0 var(--space-3); }
.mtd-field > .mtd-search { display: block; }

/* ---------- Trạng thái hợp đồng (/official-order-statuses) ---------- */
/* Ô màu người dùng đặt (màu lấy từ dữ liệu, qua --swatch) */
.mtd-swatch { display: inline-block; width: 16px; height: 16px; border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--swatch, transparent); vertical-align: -3px; }
.mtd-table td.mtd-cell-wrap { max-width: 360px; white-space: normal; }
@media (max-width: 1599.98px) { .mtd-table td.mtd-cell-wrap { max-width: 260px; } }
.mtd-iconbtn:disabled { color: var(--ink-subtle); cursor: not-allowed; }
.mtd-iconbtn:disabled:hover { background: transparent; }

/* ---------- Lịch sử hoạt động hợp đồng (/official-order-logs) ---------- */
/* Thanh lọc không có ô tìm: chip điều kiện bên trái, nút Bộ lọc bên phải */
.mtd-listbar > .mtd-chips { flex: 1 1 0; min-width: 0; align-self: center; margin: 0; }
@media (max-width: 991.98px) { .mtd-listbar > .mtd-chips { flex-basis: 100%; } }

/* ---------- Hàng không tên (/unnamed-orders): ảnh hàng ---------- */
.mtd-gallery { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.mtd-thumbs { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mtd-thumbs:empty { display: none; }
.mtd-thumb { position: relative; display: inline-block; }
.mtd-thumb__open { display: block; width: 48px; height: 48px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); cursor: zoom-in; }
.mtd-thumb__open img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mtd-thumb__open:focus-visible, .mtd-thumb__del:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-thumb__del { position: absolute; top: -8px; right: -8px; display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; padding: 0; border: 2px solid var(--surface); border-radius: var(--radius-pill); background: var(--brand-red); color: var(--on-brand); font-size: 12px; line-height: 1; cursor: pointer; }
@media (max-width: 991.98px) { .mtd-thumb__open { width: 64px; height: 64px; } .mtd-thumb__del { width: 28px; height: 28px; font-size: 16px; } }
.mtd-table td.mtd-cell-gallery { min-width: 200px; }
/* Trên mobile, link tiêu đề phủ cả thẻ: khung ảnh và badge có link phải nằm trên lớp đó */
.mtd-item__gallery { position: relative; z-index: 1; margin-top: var(--space-3); }
.mtd-badge-link { position: relative; z-index: 1; text-decoration: none; }
.mtd-badge-link:hover .mtd-badge { text-decoration: underline; }
.mtd-thumb-preview { position: fixed; z-index: 1060; padding: var(--space-1); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); box-shadow: var(--shadow-raised); pointer-events: none; }
.mtd-thumb-preview img { display: block; max-width: 400px; max-height: 400px; border-radius: var(--radius-sm); }
/* Xem ảnh lớn */
.mtd-lightbox .modal-dialog { max-width: min(1100px, 94vw); }
.mtd-lightbox .modal-content { border: 0; border-radius: var(--radius-lg); background: var(--ink); color: var(--on-brand); }
.mtd-lightbox__head { display: flex; align-items: center; justify-content: space-between; padding: var(--space-2) var(--space-2) 0 var(--space-4); }
.mtd-lightbox__count { font-size: 14px; line-height: 20px; font-variant-numeric: tabular-nums; }
.mtd-lightbox .mtd-lightbox__btn { color: var(--on-brand); }
.mtd-lightbox .mtd-lightbox__btn:hover { background: var(--ink-muted); }
.mtd-lightbox__stage { position: relative; display: flex; align-items: center; justify-content: center; min-height: 300px; padding: var(--space-2) var(--space-6); }
.mtd-lightbox__stage img { max-width: 100%; max-height: 76vh; border-radius: var(--radius-md); }
.mtd-lightbox__nav { position: absolute; top: 50%; transform: translateY(-50%); background: var(--ink-muted); font-size: 28px; }
.mtd-lightbox__nav--prev { left: var(--space-2); }
.mtd-lightbox__nav--next { right: var(--space-2); }
.mtd-lightbox__strip { display: flex; flex-wrap: wrap; justify-content: center; gap: var(--space-2); padding: var(--space-3); }
.mtd-lightbox__thumb { width: 52px; height: 52px; padding: 0; overflow: hidden; border: 2px solid transparent; border-radius: var(--radius-sm); background: none; opacity: .55; cursor: pointer; }
.mtd-lightbox__thumb img { display: block; width: 100%; height: 100%; object-fit: cover; }
.mtd-lightbox__thumb[aria-current="true"] { border-color: var(--on-brand); opacity: 1; }
@media (max-width: 575.98px) { .mtd-lightbox__stage { padding: var(--space-2); } }

/* ---------- Yêu cầu nhận hàng (/order-claims) ---------- */
.mtd-row-actions { display: inline-flex; flex-wrap: wrap; gap: var(--space-1); }
/* Ảnh khách gửi: viền teal để phân biệt với ảnh chụp trong kho */
.mtd-thumb--claim .mtd-thumb__open { border: 2px solid var(--brand-teal); }
.mtd-modal__text { margin: 0 0 var(--space-2); }
.mtd-claim-compare { display: flex; flex-wrap: wrap; gap: var(--space-4); }
.mtd-claim-compare .mtd-item__meta { margin-bottom: var(--space-1); }

/* ---------- Kiểm đơn (/order-inspections) ---------- */
/* Cột thao tác có nút lúc có lúc không: căn phải để nút cuối luôn thẳng hàng */
.mtd-table--end-actions .is-actions { text-align: right; }

/* ---------- Quản lý giao hàng (/shipping-manager) ---------- */
.mtd-filter__invoice { flex: 0 0 150px; width: 150px; }
.mtd-listbar .mtd-filter > .mtd-filter__invoice { height: var(--control-h-sm); font-size: 14px; }
@media (max-width: 991.98px) { .mtd-filter__invoice { flex: 0 1 130px; width: 130px; } }
.mtd-table__sub--warn { color: var(--warning); }

/* ---------- Giao dịch khách hàng (/transactions) ---------- */
.mtd-stat__value.is-neg { color: var(--brand-red); }

/* ---------- Công nợ & số dư khách (/accounting-statistics) ---------- */
/* Tiêu đề cột bấm để sắp xếp */
.mtd-sort { display: inline-flex; align-items: center; gap: 2px; color: inherit; text-decoration: none; }
.mtd-sort:hover { color: var(--brand-navy); text-decoration: underline; }
.mtd-sort.is-on { color: var(--brand-navy); }
.mtd-sort:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
/* Dòng tổng cuối bảng */
.mtd-table tfoot th { border-top: 2px solid var(--line-strong); border-bottom: 0; background: var(--surface); color: var(--ink); font-size: 14px; line-height: 20px; font-weight: 700; font-variant-numeric: tabular-nums; }
@media (min-width: 992px) { .mtd-listbar .mtd-fpanel--narrow { width: 420px; } }
.mtd-item__meta .is-neg { color: var(--brand-red); }

/* ---------- Tất cả giao dịch theo quỹ (/financial/fund-transactions) ---------- */
/* Nút dạng chữ nhỏ trong dòng phụ của bảng (vd. "đổi nội dung") */
.mtd-linkbtn { display: inline; padding: 0; border: 0; background: none; color: var(--brand-navy); font: inherit; text-decoration: underline; cursor: pointer; }
.mtd-linkbtn:hover { color: var(--brand-navy-strong); }
.mtd-linkbtn:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
@media (min-width: 992px) { .mtd-listbar .mtd-filter > .mtd-filter__select { width: 280px; } }

/* ---------- Loại giao dịch (/transaction-types) ---------- */
/* Hai bảng cạnh nhau chỉ khi đủ rộng (từ 1600px), hẹp hơn thì xếp chồng */
@media (min-width: 992px) and (max-width: 1599.98px) { .mtd-grid-2--wide { grid-template-columns: minmax(0, 1fr); } }
.mtd-card__title > .mdi { color: var(--ink-muted); }
.mtd-card__count { margin-left: var(--space-1); font-weight: 500; color: var(--ink-muted); font-variant-numeric: tabular-nums; }

/* ---------- Cài đặt giao dịch (/transaction-action-config) ---------- */
/* Dòng "thao tác → loại giao dịch" */
.mtd-item--actions { align-items: center; }
.mtd-mapto { display: flex; align-items: center; gap: var(--space-3); flex: 0 1 340px; min-width: 0; font-size: 15px; line-height: 22px; color: var(--ink); }
.mtd-mapto > .mdi { flex: none; font-size: 20px; color: var(--ink-muted); }
.mtd-mapto .mtd-item__meta { display: block; margin: 0; }
@media (max-width: 767.98px) { .mtd-item--actions { flex-wrap: wrap; } .mtd-mapto { flex-basis: 100%; order: 2; } }
.mtd-item--actions .mtd-iconbtn { position: relative; z-index: 1; font-size: 20px; color: var(--ink-muted); }

/* ---------- Hoa hồng CTV (/affiliate-commission/dashboard) ---------- */
.mtd-filter__month { flex: 0 0 130px; width: 130px; }
.mtd-card__note { padding-right: var(--space-2); font-size: 13px; line-height: 18px; color: var(--ink-muted); text-align: right; }
/* Ô nhập + nút ngay trong dòng bảng */
.mtd-inline-form { display: flex; align-items: center; gap: var(--space-2); margin: 0; }
.mtd-inline-form .mtd-suffix { flex: 0 1 160px; }
.mtd-table .mtd-inline-form .mtd-input { height: 32px; font-size: 14px; }
.mtd-btn.is-disabled { pointer-events: none; opacity: .7; }
@media (max-width: 767.98px) { .mtd-card__head { flex-wrap: wrap; } .mtd-card__note { text-align: left; } }

/* ---------- Liên kết CTV (/affiliate-mapping) ---------- */
.mtd-table tr.is-muted td { color: var(--ink-muted); }
@media (min-width: 992px) { .mtd-listbar .mtd-filter > .mtd-filter__select--sm { width: 200px; } }

/* ---------- Nhân viên (/user) ---------- */
.mtd-listbar__note { display: flex; align-items: center; gap: var(--space-1); margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); align-self: center; }
.mtd-listbar__note > .mdi { font-size: 16px; }
@media (max-width: 991.98px) { .mtd-listbar__note { flex: 1 1 100%; } }
/* Ảnh chữ cái + tên trong ô bảng */
.mtd-person { display: flex; align-items: center; gap: var(--space-3); min-width: 0; }
.mtd-item > .mtd-avatar { margin-top: 2px; }

/* ---------- Vai trò (/user/manageRoles) ---------- */
.mtd-grid-3 { display: grid; grid-template-columns: minmax(0, 1fr); gap: var(--space-3); align-items: start; }
@media (min-width: 992px) { .mtd-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-4); } }
.mtd-people { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; }
.mtd-people li { display: flex; align-items: center; gap: var(--space-2); min-width: 0; font-size: 14px; line-height: 20px; }
.mtd-people a { color: var(--brand-navy); font-weight: 500; }
.mtd-people__meta { margin-left: auto; font-size: 12px; line-height: 16px; color: var(--ink-muted); white-space: nowrap; }
.mtd-people li.is-muted a { color: var(--ink-muted); }
.mtd-empty--inline { padding: 0; text-align: left; }

/* ---------- Chức năng (/permissions) ---------- */
.mtd-table th.is-center, .mtd-table td.is-center { text-align: center; }
.mtd-tick { font-size: 20px; line-height: 1; color: var(--success); }

/* ---------- Thêm loại sản phẩm (/product-types/create) ---------- */
/* Gợi ý loại đã có tên gần giống khi gõ */
.mtd-similar { margin-top: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--brand-teal-soft); }
.mtd-similar.is-exact { background: var(--warning-soft); }
.mtd-similar__title { margin: 0 0 var(--space-2); font-size: 13px; line-height: 18px; color: var(--ink); }
.mtd-similar__list { display: flex; flex-wrap: wrap; gap: var(--space-1); }
.mtd-similar .mtd-chip { background: var(--surface); }

/* ---------- Hồ sơ cá nhân (/profile) ---------- */
@media (min-width: 992px) { .mtd-form-grid--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); } }
.mtd-form-actions--top { margin-top: var(--space-4); }
.mtd-card__lead { margin: 0; padding: var(--space-3) var(--space-4) 0; }
.mtd-card__head .mtd-search--sm { flex: 0 1 220px; }
.mtd-search--sm .mtd-input { height: var(--control-h-sm); font-size: 14px; padding-left: 36px; }
.mtd-search--sm > i { left: 10px; font-size: 18px; }

/* ---------- Tra cứu đơn hàng công khai (/tracking, trang đứng riêng không có layout quản trị) ---------- */
.mtd-track-page { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font-sans); }
.mtd-track { max-width: 640px; margin: 0 auto; padding: var(--space-6) var(--space-4) var(--space-7); }
.mtd-track__brand { display: flex; justify-content: center; margin-bottom: var(--space-5); }
.mtd-track__brand img { width: auto; height: 36px; }
.mtd-track h1 { margin: 0 0 var(--space-1); font-size: 24px; line-height: 32px; font-weight: 700; text-align: center; }
.mtd-track__lead { margin: 0 0 var(--space-5); font-size: 15px; line-height: 22px; color: var(--ink-muted); text-align: center; }
.mtd-track .mtd-scanbar { max-width: none; }
.mtd-track__now { flex-wrap: wrap; }
.mtd-track__specs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-2); margin: 0 0 var(--space-4); }
.mtd-track__specs div { padding: var(--space-3); border-radius: var(--radius-md); background: var(--canvas); }
.mtd-track__specs dt { margin: 0; font-size: 12px; line-height: 16px; font-weight: 500; color: var(--ink-muted); }
.mtd-track__specs dd { margin: 2px 0 0; font-size: 16px; line-height: 24px; font-weight: 600; font-variant-numeric: tabular-nums; }
@media (max-width: 479.98px) { .mtd-track { padding-top: var(--space-4); } .mtd-track__specs { grid-template-columns: minmax(0, 1fr); } }

/* ---------- Lịch sử hệ thống (/system-logs) ---------- */
.mtd-ink-muted { color: var(--ink-muted); }

/* ---------- Chi tiết hợp đồng chính ngạch (/official-orders/view) ---------- */
.mtd-page-head .mtd-badges { margin: var(--space-2) 0 0; }
.mtd-pre { white-space: pre-line; }
/* Bảng hàng sửa trực tiếp: ô nhập rộng theo cột, tên sản phẩm là ô nhiều dòng, kích thước 3 ô liền */
.mtd-oitems th.is-name { min-width: 220px; } .mtd-oitems th.is-hs { min-width: 96px; } .mtd-oitems th.is-spec { min-width: 120px; }
.mtd-oitems th.is-num { min-width: 84px; } .mtd-oitems th.is-qty { min-width: 60px; } .mtd-oitems th.is-money { min-width: 112px; } .mtd-oitems th.is-dims { min-width: 186px; }
.mtd-oitems th .mtd-table__sub { font-weight: 400; }
.mtd-oitems th.is-num, .mtd-oitems th.is-qty, .mtd-oitems th.is-money { text-align: right; }
@media (max-width: 1599.98px) {
    .mtd-oitems th.is-name { min-width: 170px; } .mtd-oitems th.is-hs { min-width: 84px; } .mtd-oitems th.is-spec { min-width: 100px; }
    .mtd-oitems th.is-money { min-width: 100px; } .mtd-oitems th.is-dims { min-width: 156px; }
}
.mtd-oitems td { vertical-align: top; }
.mtd-oitems td .mtd-table__sub { margin-top: 2px; text-align: right; }
.mtd-oitems textarea.mtd-cell-input { display: block; height: auto; min-height: 52px; padding: 6px var(--space-2); line-height: 18px; resize: vertical; }
.mtd-oitems .mtd-cell-input.is-invalid { border-color: var(--brand-red); background: var(--brand-red-soft); }
.mtd-dims { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--space-1); }
.mtd-oitems tfoot th { text-align: right; white-space: nowrap; }
.mtd-oitems tfoot th[scope="row"] { text-align: left; }
.mtd-oitems__alert { margin: var(--space-3) var(--space-4) 0; }
.mtd-oitems__foot { display: flex; align-items: center; justify-content: flex-end; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.mtd-oitems__state { display: inline-flex; align-items: center; font-size: 14px; line-height: 20px; color: var(--warning); }
.mtd-oitems__state .mdi { font-size: 20px; }

/* ---------- Thêm / sửa trạng thái chính ngạch ---------- */
/* Ô màu: ô chọn màu vuông + ô mã màu */
.mtd-color { display: flex; gap: var(--space-2); }
.mtd-color input[type="color"] { flex: none; box-sizing: border-box; width: var(--control-h); height: var(--control-h); padding: 4px; border: 1px solid var(--line-strong); border-radius: var(--radius-md); background: var(--surface); cursor: pointer; }
.mtd-color input[type="color"]:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-badges.mtd-preview { margin: 0 0 var(--space-3); }

/* ---------- Chi tiết lịch sử (official-order-logs/view, system-logs/view): partials/log_details ---------- */
.mtd-code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13px; line-height: 18px; color: var(--ink); overflow-wrap: anywhere; }
.mtd-logdetail th[scope="row"] { min-width: 160px; font-weight: 500; text-align: left; }
.mtd-logdetail td { min-width: 120px; overflow-wrap: anywhere; }
.mtd-logdetail--rows td { min-width: 56px; }
.mtd-logdetail--rows td:nth-child(2) { min-width: 240px; }
.mtd-logdetail tr.is-changed th, .mtd-logdetail tr.is-changed td { background: var(--warning-soft); }
.mtd-logdetail__meta { margin-bottom: var(--space-4); }
.mtd-logdetail__hint { margin: var(--space-2) 0 0; }
.mtd-logdetail__raw { margin-top: var(--space-4); border-top: 1px solid var(--line); }
.mtd-logdetail__raw > summary { display: flex; align-items: center; gap: var(--space-1); min-height: var(--tap-target); font-size: 14px; line-height: 20px; font-weight: 500; color: var(--brand-navy); }
.mtd-json { max-height: 420px; margin: 0; padding: var(--space-3); overflow: auto; border-radius: var(--radius-md); background: var(--surface-sunken); font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: 13px; line-height: 18px; color: var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
h3.mtd-kv__group { font-family: var(--font-sans); }

/* ---------- Chi tiết đơn hàng (/orders/detail) ---------- */
/* Cột bên nằm phải (nội dung chính rộng hơn) */
@media (min-width: 1200px) { .mtd-profile--end { grid-template-columns: minmax(0, 1fr) 360px; } }
.mtd-kv__row--total { border-top: 2px solid var(--line-strong); }
.mtd-kv__row--total dt, .mtd-kv__row--total dd { font-weight: 700; color: var(--ink); }
.mtd-kv__row--total dd { font-size: 18px; line-height: 26px; color: var(--brand-navy); }
.mtd-kv .mtd-linkbtn { display: block; margin-left: auto; }
/* Hành trình: mỗi mốc một chấm có icon, tô theo tone; mốc cuối viền đậm */
.mtd-steps { margin: 0; padding: 0; list-style: none; }
.mtd-step { position: relative; display: flex; gap: var(--space-3); padding-bottom: var(--space-4); }
.mtd-step:last-child { padding-bottom: 0; }
.mtd-step:not(:last-child)::before { content: ""; position: absolute; top: 32px; bottom: 0; left: 15px; width: 2px; background: var(--line); }
.mtd-step__dot { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; border-radius: var(--radius-pill); background: var(--brand-navy-soft); color: var(--brand-navy); font-size: 18px; }
.mtd-step[data-tone="success"] .mtd-step__dot { background: var(--success-soft); color: var(--success); }
.mtd-step[data-tone="warning"] .mtd-step__dot { background: var(--warning-soft); color: var(--warning); }
.mtd-step[data-tone="info"] .mtd-step__dot { background: var(--brand-teal-soft); color: var(--brand-teal); }
.mtd-step.is-current .mtd-step__dot { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px currentColor; }
.mtd-step__body { min-width: 0; padding-top: 5px; }
.mtd-step__title { margin: 0; font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink); }
.mtd-step__meta { margin: 0; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.mtd-audit__note { margin: 0; font-weight: 500; }
.mtd-audit__more { display: inline-block; margin-top: var(--space-1); font-size: 13px; line-height: 18px; color: var(--brand-navy); }
.mtd-audit td { vertical-align: top; }

/* ---------- Sửa đơn hàng (/orders/edit) ---------- */
@media (min-width: 1600px) { .mtd-form-layout--wide { grid-template-columns: minmax(0, 920px) minmax(0, 400px); } }
.mtd-section-gap { margin-top: var(--space-5); }
.mtd-cost__total { margin-bottom: var(--space-3); }
.mtd-cost__note { margin: var(--space-3) 0 0; }
/* Phiếu chi phí nội địa đã ghi vào quỹ */
.mtd-pnd { padding: var(--space-3) var(--space-4); border-radius: var(--radius-md); background: var(--success-soft); }
.mtd-pnd__title { display: flex; align-items: center; gap: var(--space-1); margin: 0 0 var(--space-2); font-size: 14px; line-height: 20px; font-weight: 700; color: var(--success); }
.mtd-pnd__title .mdi { font-size: 18px; }
.mtd-pnd__list { display: grid; gap: var(--space-2); margin: 0; padding: 0; list-style: none; font-size: 14px; line-height: 20px; color: var(--ink); }
.mtd-pnd__list li { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-1) var(--space-2); }
.mtd-pnd__sub { flex-basis: 100%; font-size: 13px; line-height: 18px; color: var(--ink-muted); }
.mtd-pnd__hint { margin: calc(-1 * var(--space-2)) 0 0; color: var(--success); font-weight: 500; }
.mtd-pnd__actions { display: flex; flex-wrap: wrap; gap: var(--space-2); }
/* Ảnh đơn ở cột bên: ảnh nhỏ to hơn danh sách */
.mtd-thumbs--lg .mtd-thumb__open { width: 72px; height: 72px; }

/* ---------- Import đơn hàng (/orders/import) ---------- */
.mtd-import { max-width: 760px; }
.mtd-file { height: auto; padding: var(--space-2) var(--space-3); line-height: 26px; cursor: pointer; }
.mtd-file::file-selector-button { margin-right: var(--space-3); padding: var(--space-1) var(--space-3); border: 1px solid var(--line-strong); border-radius: var(--radius-sm); background: var(--surface); color: var(--brand-navy); font: 500 14px/20px var(--font-sans); cursor: pointer; }
.mtd-import__scroll { max-height: 60vh; overflow: auto; }
.mtd-import__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: var(--space-3); padding: var(--space-3) var(--space-4); }
.mtd-import__foot .mtd-field__help { margin: 0 auto 0 0; }

/* ---------- Đơn cần xử lý (/orders/china-stock, /orders/vietnam-stock, /orders/zero-price) ---------- */
.mtd-filter__days { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); white-space: nowrap; }
.mtd-filter__days .mtd-input { width: 76px; height: var(--control-h-sm); text-align: right; }
.mtd-listbar .mtd-filter .mtd-filter__select { height: var(--control-h-sm); }
.mtd-zp-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); margin-bottom: var(--space-4); padding: var(--space-3); }
.mtd-zp-filter .mtd-input { width: auto; height: var(--control-h-sm); font-size: 14px; }
.mtd-zp-filter .mtd-select { max-width: 240px; }
.mtd-zp-filter__q { flex: 0 1 240px; }
.mtd-zp-filter__q .mtd-input { width: 100%; }
.mtd-zp-filter__date { display: inline-flex; align-items: center; gap: var(--space-2); margin: 0; font-size: 14px; line-height: 20px; color: var(--ink-muted); white-space: nowrap; }
.mtd-zp-filter .mtd-btn { height: var(--control-h-sm); min-height: var(--control-h-sm); }
@media (max-width: 767.98px) { .mtd-zp-filter__q, .mtd-zp-filter .mtd-select { flex: 1 1 100%; max-width: none; } .mtd-zp-filter .mtd-select { width: 100%; } }

/* ---------- Kiểm đơn trong phiếu xuất (/invoices/check) ---------- */
.mtd-check { margin-bottom: var(--space-4); }
.mtd-check__scan .mtd-card__body { display: grid; gap: var(--space-3); }
.mtd-check__progress { max-width: 720px; }
.mtd-check__count { margin: 0; font-size: 28px; line-height: 34px; font-weight: 700; color: var(--ink); font-variant-numeric: tabular-nums; }
.mtd-check__unit { font-size: 15px; line-height: 22px; font-weight: 500; color: var(--ink-muted); }
.mtd-check .mtd-scanbar { margin: 0; }
.mtd-check__result { max-width: 720px; margin: 0; }
.mtd-check__opts { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2) var(--space-4); }
.mtd-check__opt { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap-target); margin: 0; font-family: var(--font-sans); font-size: 14px; line-height: 20px; color: var(--ink); cursor: pointer; }
.mtd-check__opt input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-navy); }
.mtd-check__icon { font-size: 20px; line-height: 1; color: var(--line-strong); }
.mtd-check__table tr.is-checked td { background: var(--success-soft); }
.mtd-check__table tr.is-checked .mtd-check__icon { color: var(--success); }
.mtd-check__code { font-weight: 700; font-variant-numeric: tabular-nums; }

/* ---------- Form một cột trong card (thêm / sửa danh mục nhỏ: đơn vị vận chuyển...) ---------- */
.mtd-form-card { max-width: 640px; }
.mtd-form-card__foot { display: flex; justify-content: flex-end; gap: var(--space-2); padding: var(--space-3) var(--space-4); }
@media (max-width: 575.98px) { .mtd-form-card__foot .mtd-btn { flex: 1 1 0; } }
.mtd-field__help a { color: var(--brand-navy); font-weight: 500; }
.mtd-field--narrow { max-width: 220px; }

/* ---------- Thống kê theo loại giao dịch (/transaction-types/statistics) ---------- */
.mtd-tts-filter { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.mtd-tts-filter .mtd-input { width: auto; height: var(--control-h-sm); font-size: 14px; }
.mtd-tts-filter .mtd-btn { height: var(--control-h-sm); min-height: var(--control-h-sm); }
/* Thanh tỷ trọng: nền xám, phần tô theo nhóm (thu xanh, chi đỏ) */
.mtd-share { display: inline-flex; align-items: center; gap: var(--space-2); min-width: 200px; }
.mtd-share::before { content: ""; display: none; }
.mtd-share__bar { position: relative; flex: 0 0 140px; height: 8px; border-radius: var(--radius-pill); background: var(--neutral-soft); overflow: hidden; }
.mtd-share__bar::after { content: ""; position: absolute; inset: 0 auto 0 0; width: var(--w, 0); border-radius: var(--radius-pill); background: var(--success); }
.mtd-share[data-cat="expense"] .mtd-share__bar::after { background: var(--brand-red); }
.mtd-share__pct { min-width: 48px; font-size: 13px; line-height: 18px; color: var(--ink-muted); font-variant-numeric: tabular-nums; text-align: right; }
.mtd-ac-item__meta { flex: none; font-size: 12px; line-height: 16px; color: var(--warning); }
.mtd-stat__value--text { font-size: 18px; line-height: 26px; font-weight: 600; }

/* ---------- Thêm / sửa nhân viên (/user/create, /user/edit) ---------- */
.mtd-avatar-pick { display: flex; justify-content: center; }
.mtd-avatar-pick img { width: 96px; height: 96px; border-radius: var(--radius-pill); object-fit: cover; border: 1px solid var(--line); }
.mtd-avatar--lg { width: 96px; height: 96px; font-size: 36px; line-height: 1; }

/* ---------- Hồ sơ nhân viên (/user/detail) ---------- */
.mtd-sort--btn { padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.mtd-avatar--img { object-fit: cover; padding: 0; }
.mtd-id .mtd-avatar--img { width: 48px; height: 48px; }

/* ---------- Ticket: tạo / chi tiết (/tickets/create, /tickets/detail) ----------
 * Giữ các phần tử tk-* của ticket-dropzone.js và ô soạn thảo Quill, chỉ đổi màu / bo / chữ theo token. */
.mtd-ticket .tk-dropzone { padding: var(--space-5) var(--space-4); border: 2px dashed var(--line-strong); border-radius: var(--radius-md); background: var(--surface); color: var(--ink-muted); font-family: var(--font-sans); font-size: 14px; line-height: 20px; }
.mtd-ticket .tk-dropzone:hover, .mtd-ticket .tk-dropzone:focus-visible, .mtd-ticket .tk-dropzone.dragover { border-color: var(--brand-navy); background: var(--brand-navy-soft); color: var(--brand-navy); outline: 0; }
.mtd-ticket .tk-dropzone i { color: inherit; }
.mtd-ticket .tk-thumb, .mtd-ticket .tk-gallery .tk-img { border: 1px solid var(--line); border-radius: var(--radius-md); }
.mtd-ticket .tk-thumb-x, .mtd-ticket .tk-gallery .tk-img-del, .mtd-ticket .tk-file-del { width: 24px; height: 24px; line-height: 22px; background: var(--brand-red); color: var(--on-brand); }
.mtd-ticket .tk-file-chip { padding: 4px var(--space-2); border-radius: var(--radius-sm); background: var(--surface-sunken); color: var(--ink-muted); font-size: 13px; line-height: 18px; }
.mtd-ticket .tk-file-chip.over { background: var(--brand-red-soft); color: var(--brand-red); }
.mtd-ticket .tk-file { gap: var(--space-2); padding: var(--space-2) var(--space-3); border: 1px solid var(--line); border-radius: var(--radius-md); background: var(--surface); }
.mtd-ticket .tk-file-name { color: var(--brand-navy); font-size: 14px; line-height: 20px; }
.mtd-ticket .tk-file-size { color: var(--ink-muted); font-size: 12px; }
.mtd-ticket .ql-toolbar.ql-snow { border-color: var(--line-strong); border-radius: var(--radius-md) var(--radius-md) 0 0; font-family: var(--font-sans); }
.mtd-ticket .ql-container.ql-snow { border-color: var(--line-strong); border-radius: 0 0 var(--radius-md) var(--radius-md); font-family: var(--font-sans); font-size: 15px; }
.mtd-ticket .ql-editor { min-height: 140px; line-height: 22px; color: var(--ink); }
.mtd-ticket .ql-editor.ql-blank::before { color: var(--ink-subtle); font-style: normal; }
.mtd-guide { margin: 0; padding-left: var(--space-5); font-size: 14px; line-height: 20px; color: var(--ink); }
.mtd-guide li + li { margin-top: var(--space-2); }
/* Chi tiết ticket: dòng trao đổi, form trả lời, nút trạng thái */
.mtd-tk-meta { display: flex; align-items: center; gap: var(--space-2); margin: 0; font-size: 14px; line-height: 20px; }
.mtd-tk-gallery .tk-img { width: 120px; height: 120px; }
.mtd-tk-files { max-width: 640px; }
.mtd-thread { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; padding: 0; list-style: none; }
.mtd-thread__item { display: flex; gap: var(--space-3); align-items: flex-start; }
.mtd-thread__body { display: flex; flex-direction: column; gap: var(--space-2); flex: 1; min-width: 0; }
.mtd-thread__who { margin: 0; font-size: 14px; line-height: 20px; }
.mtd-thread__who .mtd-ink-muted { margin-left: var(--space-2); font-size: 13px; }
.mtd-thread__system { align-self: center; padding: 4px var(--space-3); border-radius: var(--radius-pill); background: var(--surface-sunken); color: var(--ink-muted); font-size: 13px; line-height: 18px; text-align: center; }
.mtd-thread__system .mdi { color: var(--ink-subtle); }
.mtd-tk-reply { display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-4); background: var(--surface-sunken); }
.mtd-tk-reply .mtd-alert { margin: 0; }
.mtd-tk-reply .mtd-label { margin: 0; }
.mtd-tk-reply .ql-container.ql-snow, .mtd-tk-reply .ql-toolbar.ql-snow { background: var(--surface); }
.mtd-tk-reply .ql-editor { min-height: 100px; }
.mtd-tk-reply__row { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: var(--space-3); }
.mtd-tk-reply__row .mtd-field { flex: 1 1 320px; min-width: 0; }
.mtd-ticket .mtd-card__body > .mtd-tk-now { margin: 0; }
.mtd-tk-status { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.mtd-tk-status .mtd-btn:disabled { opacity: 1; cursor: default; }
.mtd-ticket .mtd-page-head .mtd-badges { align-items: center; }
/* Nội dung soạn thảo trong ticket: liên kết đủ tương phản, bảng dùng token */
.mtd-ticket .rich-text a { color: var(--brand-navy); text-decoration: underline; text-underline-offset: 2px; }
.mtd-ticket .rich-text table th, .mtd-ticket .rich-text table td { border-color: var(--line); }
.mtd-ticket .rich-text table th { background: var(--surface-sunken); color: var(--ink); }
.mtd-ticket .rich-text a:hover { color: var(--brand-navy-strong); }

/* Đăng nhập quản trị (/login): trang đứng riêng, khung giữa màn hình; vạch 3 màu lấy từ logo */
.mtd-auth-page { margin: 0; background: var(--canvas); color: var(--ink); font-family: var(--font-sans); }
.mtd-auth { box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: var(--space-4); min-height: 100vh; min-height: 100dvh; padding: var(--space-6) var(--space-4); }
.mtd-auth__card { box-sizing: border-box; position: relative; width: 100%; max-width: 420px; padding: var(--space-6); border-radius: var(--radius-lg); background: var(--surface); box-shadow: var(--shadow-card); overflow: hidden; }
.mtd-auth__card::before { content: ""; position: absolute; top: 0; left: 0; right: 0; height: 4px; background: linear-gradient(90deg, var(--brand-navy) 0 34%, var(--brand-red) 34% 67%, var(--brand-teal) 67%); }
.mtd-auth__brand { display: flex; justify-content: center; margin: 0 0 var(--space-4); }
.mtd-auth__brand img { width: auto; height: 48px; }
.mtd-auth__title { margin: 0; font-size: 24px; line-height: 32px; font-weight: 700; text-align: center; color: var(--ink); }
.mtd-auth__lead { margin: var(--space-1) 0 var(--space-5); font-size: 15px; line-height: 22px; text-align: center; color: var(--ink-muted); }
.mtd-auth .mtd-fields { gap: var(--space-4); }
.mtd-auth__pw { position: relative; }
.mtd-auth__pw .mtd-input { padding-right: 48px; }
.mtd-auth__eye { position: absolute; top: 0; right: 0; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: var(--control-h); padding: 0; border: 0; border-radius: 0 var(--radius-md) var(--radius-md) 0; background: transparent; color: var(--ink-muted); font-size: 20px; cursor: pointer; }
.mtd-auth__eye:hover { color: var(--brand-navy); }
.mtd-auth__eye:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: -2px; }
.mtd-auth__remember { display: inline-flex; align-items: center; gap: var(--space-2); min-height: var(--tap-target); margin: calc(var(--space-2) * -1) 0; font-size: 15px; line-height: 22px; color: var(--ink); cursor: pointer; justify-self: start; }
.mtd-auth__remember input { width: 18px; height: 18px; margin: 0; accent-color: var(--brand-navy); }
.mtd-auth__remember input:focus-visible { outline: 2px solid var(--focus-ring); outline-offset: 2px; }
.mtd-auth__submit { width: 100%; font-size: 16px; }
.mtd-auth__submit:disabled { opacity: .7; cursor: progress; }
.mtd-auth__help { margin: var(--space-4) 0 0; font-size: 14px; line-height: 20px; text-align: center; color: var(--ink-muted); }
.mtd-auth__alt { display: inline-flex; align-items: center; gap: var(--space-1); min-height: var(--tap-target); padding: 0 var(--space-2); font-size: 15px; line-height: 22px; font-weight: 500; color: var(--brand-navy); text-decoration: none; }
.mtd-auth__alt:hover { color: var(--brand-navy-strong); text-decoration: underline; text-underline-offset: 2px; }
.mtd-auth .mtd-alert { margin: 0 0 var(--space-4); }
.mtd-auth [hidden] { display: none; }
@media (max-width: 479.98px) { .mtd-auth { justify-content: flex-start; padding-top: var(--space-5); } .mtd-auth__card { padding: var(--space-5) var(--space-4); } }

/* ---------- Điện thoại / máy tính bảng gọn (Mali 30/11: "các button nhỏ lại, sắp xếp hạn chế khoảng trống") ----------
 * Dưới 992px: nút nhỏ 36px (trước ép 44px), tab 36px, ô tìm 40px, chip 32px, nút trong mục danh sách 32px.
 * Đầu trang: tiêu đề và nút cùng một hàng khi đủ chỗ. Dưới 576px nút có .mtd-hide-xs chỉ còn icon (giữ tên cho trình đọc màn hình).
 * Mục danh sách có hàng chân (.mtd-item--foot > .mtd-item__foot): trạng thái bên trái, thao tác bên phải, trải hết bề ngang
 * (cả phần dưới cột số tiền) để không xuống dòng. */
.mtd-item--foot { flex-wrap: wrap; row-gap: var(--space-2); }
.mtd-item__foot { display: flex; flex: 1 1 100%; flex-wrap: wrap; align-items: center; gap: var(--space-2); min-width: 0; }
.mtd-item__foot > .mtd-item__badges { flex: 1 1 auto; margin: 0; }
.mtd-item__foot > .mtd-item__actions { flex-wrap: nowrap; align-items: center; gap: var(--space-1); margin: 0 0 0 auto; }
.mtd-item__foot .mtd-iconbtn { width: 32px; height: 32px; font-size: 18px; color: var(--brand-navy); }
.mtd-item__foot .mtd-iconbtn--danger { color: var(--brand-red); }
.mtd-item__foot .mtd-iconbtn:hover { background: var(--brand-navy-soft); }
.mtd-item__foot .mtd-iconbtn--danger:hover { background: var(--brand-red-soft); }
@media (max-width: 991.98px) {
    .mtd-page-head { align-items: center; margin-bottom: var(--space-3); }
    .mtd-seg > a, .mtd-seg > button { min-height: var(--control-h-sm); padding: 0 var(--space-3); }
    .mtd-listbar { margin-bottom: var(--space-2); }
    .mtd-listbar > .mtd-seg { padding-bottom: var(--space-1); }
    .mtd-listbar .mtd-filter .mtd-input { height: 40px; }
    .mtd-listbar .mtd-filter > .mtd-btn { min-height: 40px; padding: 0 var(--space-3); }
    .mtd-chip { min-height: 32px; padding: 0 10px; font-size: 13px; line-height: 18px; }
    .mtd-item__actions .mtd-btn--sm { min-height: 32px; padding: 0 10px; }
}
@media (max-width: 575.98px) {
    .mtd-hide-xs { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
    .mtd-page-head { column-gap: var(--space-2); }
    .mtd-page-head h1 { font-size: 22px; line-height: 28px; }
    .mtd-page-head > .mtd-head-actions { gap: var(--space-1); }
    .mtd-head-actions .mtd-btn--sm { padding: 0 10px; }
}
