html, body {
    font-family: Inter, "Segoe UI", Roboto, Tahoma, Arial, sans-serif;
}

.kpi-card .kpi-value {
    font-size: 1.6rem;
    font-weight: 700;
    line-height: 1.2;
    font-variant-numeric: tabular-nums;
}

.money {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* Mọi ô nhập số dùng chung (NumberField: tiền VNĐ, % lãi suất, số kỳ...) căn phải, chữ số thẳng cột. */
input[data-emd-number] {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

.money-lg {
    font-size: 1.5rem;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.bar-chart {
    display: flex;
    align-items: flex-end;
    gap: 6px;
    height: 160px;
    padding-top: 8px;
}

.bar-chart .bar-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    height: 100%;
    min-width: 0;
}

.bar-chart .bar {
    width: 100%;
    max-width: 28px;
    border-radius: 4px 4px 0 0;
    background: var(--mud-palette-primary);
    min-height: 2px;
    transition: height .3s;
}

.bar-chart .bar-label {
    font-size: 10px;
    color: var(--mud-palette-text-secondary);
    margin-top: 4px;
    white-space: nowrap;
}

.kbd {
    display: inline-block;
    padding: 0 5px;
    border: 1px solid #9e9e9e;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    line-height: 16px;
    font-family: Consolas, monospace;
    background: #e0e0e0;
    color: #1b1b1b;
    margin-left: 4px;
}

.login-shell {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f3d3e 0%, #14532d 100%);
    padding: 16px;
}

.login-card {
    width: 100%;
    max-width: 400px;
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, .25);
}

.login-logo { display: block; width: 84px; height: 84px; margin: 0 auto 12px; }
.login-card h1 { margin: 0 0 4px; font-size: 1.5rem; color: #0f3d3e; text-align: center; }
.login-card p.sub { margin: 0 0 24px; color: #64748b; text-align: center; }
.login-card label { display: block; font-size: .85rem; color: #334155; margin-bottom: 4px; font-weight: 600; }
.login-card input[type=text], .login-card input[type=password] {
    width: 100%; box-sizing: border-box; padding: 10px 12px; border: 1px solid #cbd5e1; border-radius: 8px; font-size: 1rem; margin-bottom: 16px;
}
.login-card input:focus { outline: 2px solid #14532d; border-color: transparent; }
.login-card button {
    width: 100%; padding: 11px; border: 0; border-radius: 8px; background: #14532d; color: #fff; font-size: 1rem; font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: #166534; }
/* Ô mật khẩu kèm nút con mắt; ẩn nút "hiện mật khẩu" có sẵn của Edge/WebView2 để không có 2 con mắt. */
.login-card .password-field { position: relative; margin-bottom: 16px; }
.login-card .password-field input { margin-bottom: 0; padding-right: 46px; }
.login-card .password-field input::-ms-reveal, .login-card .password-field input::-ms-clear { display: none; }
.login-card button.password-toggle {
    position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 34px; height: 34px; padding: 0;
    display: flex; align-items: center; justify-content: center; background: transparent; color: #64748b; border-radius: 6px;
}
.login-card button.password-toggle:hover { background: #f1f5f9; color: #14532d; }
.login-card button.password-toggle .icon-hide, .login-card button.password-toggle[aria-pressed=true] .icon-show { display: none; }
.login-card button.password-toggle[aria-pressed=true] .icon-hide { display: block; }
.login-card .error { background: #fef2f2; color: #b91c1c; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; font-size: .9rem; }
.login-card .notice { background: #f0fdf4; color: #166534; border-radius: 8px; padding: 10px 12px; margin-bottom: 16px; font-size: .9rem; }
.login-card input.otp-input { text-align: center; font-size: 1.5rem; letter-spacing: .4em; }
.login-secondary { display: flex; gap: 8px; margin-top: 10px; }
.login-secondary form { flex: 1 1 0; }
.login-card button.secondary { background: #fff; color: #14532d; border: 1px solid #cbd5e1; font-weight: 500; }
.login-card button.secondary:hover { background: #f8fafc; }
.login-card button.secondary:disabled { color: #94a3b8; cursor: not-allowed; }

/* Logo màu xanh trên thanh tiêu đề xanh: đặt trên nền trắng để nhìn rõ */
.brand-logo { height: 32px; width: 32px; padding: 3px; box-sizing: border-box; background: #fff; border-radius: 6px; flex: none; }

#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 2000;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.appbar-account .mud-button-root { text-transform: none; white-space: nowrap; }
.appbar-account .mud-button-label { display: inline-flex; align-items: center; }
@media (max-width: 599px) {
    .appbar-account .mud-button-root { min-width: 0; max-width: 150px; overflow: hidden; }
}

/* Diff viewer nhật ký */
.audit-diff { width: 100%; border-collapse: collapse; font-size: .85rem; margin-top: 6px; }
.audit-diff th, .audit-diff td { padding: 6px 8px; border-bottom: 1px solid var(--mud-palette-lines-default); text-align: left; vertical-align: top; word-break: break-word; }
.audit-diff th { color: var(--mud-palette-text-secondary); font-weight: 600; }
.audit-diff td:first-child { font-weight: 600; min-width: 130px; }
.audit-diff td.old { background: rgba(220, 38, 38, .12); text-decoration: line-through; text-decoration-color: rgba(220, 38, 38, .5); }
.audit-diff td.new { background: rgba(22, 163, 74, .14); }
.audit-diff tr.same td { color: var(--mud-palette-text-secondary); }

/* Bảng điều khiển di động của chủ tiệm: mobile-first, một cột, không tràn ngang */
.owner-shell {
    min-height: 100dvh;
    max-width: 560px;
    margin: 0 auto;
    background: var(--mud-palette-background);
    color: var(--mud-palette-text-primary);
    overflow-x: clip;
}
.owner-bar {
    position: sticky; top: 0; z-index: 10;
    display: flex; align-items: center; gap: 2px;
    padding: 6px 4px 6px 16px;
    padding-top: max(6px, env(safe-area-inset-top));
    background: var(--mud-palette-appbar-background);
    color: var(--mud-palette-appbar-text);
}
.owner-bar-title { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.owner-bar-title strong { font-size: 1.05rem; }
.owner-bar-title span { font-size: .75rem; opacity: .85; }

.owner-branches {
    display: flex; gap: 8px; padding: 10px 16px;
    overflow-x: auto; scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.owner-branches::-webkit-scrollbar { display: none; }
.owner-chip {
    flex: none; scroll-snap-align: start;
    min-height: 40px; padding: 0 16px; border-radius: 20px;
    border: 1px solid var(--mud-palette-lines-default);
    background: var(--mud-palette-surface); color: var(--mud-palette-text-primary);
    font: inherit; font-size: .875rem; white-space: nowrap; cursor: pointer;
}
.owner-chip.active { background: var(--mud-palette-primary); color: var(--mud-palette-primary-text); border-color: transparent; font-weight: 600; }

.owner-main { padding: 0 16px calc(24px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 12px; }
.owner-label { font-size: .8rem; color: var(--mud-palette-text-secondary); }

@keyframes owner-flash { from { box-shadow: 0 0 0 3px var(--mud-palette-secondary); } to { box-shadow: 0 0 0 0 transparent; } }
.owner-hero, .owner-kpi { animation: owner-flash .9s ease-out; }

.owner-hero {
    display: flex; flex-direction: column; gap: 2px;
    padding: 16px; border-radius: 12px;
    background: var(--mud-palette-primary); color: var(--mud-palette-primary-text);
}
.owner-hero .owner-label { color: inherit; opacity: .85; }
.owner-hero-value { font-size: clamp(1.6rem, 8.5vw, 2.25rem); font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.2; overflow-wrap: anywhere; }
.owner-cash-strip {
    display: flex; gap: 8px; margin: 10px -16px -4px; padding: 0 16px 4px;
    overflow-x: auto; scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.owner-cash-strip::-webkit-scrollbar { display: none; }
.owner-cash-item {
    flex: none; scroll-snap-align: start; min-width: 120px; padding: 8px 12px; border-radius: 8px;
    background: rgba(255, 255, 255, .14); display: flex; flex-direction: column; font-size: .8rem;
}
.owner-cash-item b { font-size: 1rem; font-variant-numeric: tabular-nums; }

.owner-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.owner-kpi {
    display: flex; flex-direction: column; gap: 2px; min-width: 0;
    padding: 12px; border-radius: 12px;
    background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default);
}
.owner-kpi b { font-size: 1.25rem; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.25; }
.owner-kpi small { font-size: .75rem; color: var(--mud-palette-text-secondary); }
.owner-kpi small.good { color: var(--mud-palette-success); font-weight: 600; }
.owner-kpi small.bad, .owner-row-side .bad { color: var(--mud-palette-error); font-weight: 600; }

.owner-heading { font-size: 1rem; font-weight: 700; margin: 6px 0 -2px; }
.owner-alert { border-radius: 12px; background: var(--mud-palette-surface); border: 1px solid var(--mud-palette-lines-default); border-left-width: 4px; overflow: hidden; }
.owner-alert.danger { border-left-color: var(--mud-palette-error); }
.owner-alert.warn { border-left-color: var(--mud-palette-warning); }
.owner-alert summary {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    min-height: 48px; padding: 8px 14px; font-weight: 600; font-size: .9rem; cursor: pointer; list-style: none;
}
.owner-alert summary::-webkit-details-marker { display: none; }
.owner-alert summary b { flex: none; min-width: 28px; text-align: center; padding: 2px 8px; border-radius: 12px; background: var(--mud-palette-background-gray); }
.owner-alert.danger summary b { background: var(--mud-palette-error); color: var(--mud-palette-error-text); }
.owner-sum, .owner-empty { margin: 0; padding: 0 14px 10px; font-size: .8rem; color: var(--mud-palette-text-secondary); }
.owner-row {
    width: 100%; display: flex; justify-content: space-between; gap: 12px; text-align: left;
    min-height: 56px; padding: 10px 14px; background: none; color: inherit; font: inherit;
    border: 0; border-top: 1px solid var(--mud-palette-lines-default); cursor: pointer;
}
.owner-row:disabled { cursor: default; color: inherit; }
.owner-row-main, .owner-row-side { display: flex; flex-direction: column; font-size: .8rem; }
.owner-row-main { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.owner-row-main b { font-size: .875rem; }
.owner-row-main span, .owner-row-side span { color: var(--mud-palette-text-secondary); }
.owner-row-side { flex: none; max-width: 42%; text-align: right; }
.owner-fullsite { align-self: center; min-height: 44px; padding: 0 16px; background: none; border: 0; color: var(--mud-palette-primary); font: inherit; font-size: .875rem; cursor: pointer; text-decoration: underline; }

@media (prefers-reduced-motion: reduce) { .owner-hero, .owner-kpi { animation: none; } }

/* Hộp thoại: giới hạn theo chiều cao màn hình, cuộn bên trong, tiêu đề và nút luôn nhìn thấy */
.mud-dialog { max-height: 85vh; display: flex; flex-direction: column; }
.mud-dialog .mud-dialog-title, .mud-dialog .mud-dialog-actions { flex: none; }
.mud-dialog .mud-dialog-content { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.mud-dialog .mud-dialog-actions { flex-wrap: wrap; gap: 8px; }
.mud-dialog .mud-dialog-actions > .lost-doc-notice { flex: 0 0 100%; margin: 0; display: flex; align-items: center; gap: 6px; color: var(--mud-palette-error); font-weight: 600; }

/* Nút và số tiền không rớt dòng giữa chừng */
.mud-button-root { white-space: nowrap; }
.mud-main-content { overflow-x: clip; }

/* Thanh công cụ đầu trang: mọi nút và ô chọn cùng cao 36px, chữ thường, màu dịu */
:is(.page-toolbar, .report-filter-fields) { --toolbar-height: 36px; }
.page-toolbar .mud-button-root:not(.mud-icon-button) {
    height: var(--toolbar-height);
    padding: 0 12px;
    font-size: .875rem;
    font-weight: 500;
    letter-spacing: 0;
    line-height: 1;
    text-transform: none;
    box-shadow: none;
    border-radius: 6px;
}
/* Nút hành động chính: xanh thương hiệu đậm, chữ trắng */
.mud-button-filled-primary:not(:disabled),
.mud-button-filled-success:not(:disabled),
.page-toolbar .mud-button-outlined-primary:not(:disabled),
.page-toolbar .mud-button-outlined-success:not(:disabled) {
    background-color: #166534;
    border-color: #166534;
    color: #fff;
}
.mud-button-filled-primary:not(:disabled):hover,
.mud-button-filled-success:not(:disabled):hover,
.page-toolbar .mud-button-outlined-primary:not(:disabled):hover,
.page-toolbar .mud-button-outlined-success:not(:disabled):hover {
    background-color: #14532d;
    border-color: #14532d;
    box-shadow: none;
}
.page-toolbar .mud-tooltip-root { display: inline-flex; align-items: center; }
:is(.page-toolbar, .report-filter-fields) .mud-input-control.mud-input-control-margin-dense { margin: 0; width: auto; }
:is(.page-toolbar, .report-filter-fields) .mud-input.mud-input-outlined { height: var(--toolbar-height); font-size: .875rem; }
:is(.page-toolbar, .report-filter-fields) .mud-input.mud-input-outlined :is(div, input).mud-input-slot.mud-input-root-outlined { height: var(--toolbar-height); padding-top: 0; padding-bottom: 0; line-height: var(--toolbar-height); box-sizing: border-box; }
:is(.page-toolbar, .report-filter-fields) .mud-input-control > .mud-input-control-input-container > .mud-input-label-outlined { font-size: .875rem; }
.page-toolbar .mud-input-control-boolean-input { margin: 0; height: var(--toolbar-height); display: inline-flex; align-items: center; }
.page-toolbar .mud-switch { margin: 0; height: var(--toolbar-height); align-items: center; }
.page-toolbar .mud-switch .mud-typography { font-size: .875rem; }

/* Khung lọc báo cáo: hàng 1 chọn nhanh + xem theo, hàng 2 các ô lọc */
.report-filter-top { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 12px; }
.report-presets { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; flex: 1 1 320px; min-width: 0; }
.report-presets .mud-chip { height: 28px; margin: 0; padding: 0 8px; font-size: .8125rem; font-weight: 500; transition: none; }
.report-presets .mud-chip.mud-chip-outlined { border-color: color-mix(in srgb, var(--mud-palette-primary) 30%, transparent); }
.report-filter-fields { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.report-filter-fields > * { flex: 1 1 160px; min-width: 0; max-width: 260px; }
.report-filter-fields .mud-input-control.mud-input-control-margin-dense { width: 100%; }
.report-filter-fields > .report-filter-check { flex: 0 0 auto; max-width: none; white-space: nowrap; }
.report-filter-fields > .report-filter-check .mud-typography { font-size: .875rem; }
.report-filter-fields .mud-input:not(.mud-shrink):not(:focus-within) ~ .mud-input-label-outlined { transform: translate(14px, 9px) scale(1); }

/* Cụm nút liền khối, không bao giờ rớt dòng */
.segmented {
    display: inline-flex;
    flex: 0 0 auto;
    flex-wrap: nowrap;
    height: 36px;
    box-sizing: border-box;
    overflow: hidden;
    white-space: nowrap;
    border: 1px solid color-mix(in srgb, var(--mud-palette-primary) 30%, transparent);
    border-radius: 8px;
}
.segmented-item {
    height: 100%;
    padding: 0 10px;
    border: 0;
    background: transparent;
    color: var(--mud-palette-text-primary);
    font: inherit;
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
}
.segmented-item + .segmented-item { border-left: 1px solid color-mix(in srgb, var(--mud-palette-primary) 30%, transparent); }
.segmented-item:hover { background-color: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface)); }
.segmented-item.active { background-color: color-mix(in srgb, var(--mud-palette-primary) 14%, var(--mud-palette-surface)); color: var(--mud-palette-primary); }
.segmented-item:focus-visible { outline: 2px solid var(--mud-palette-primary); outline-offset: -2px; }

/* Chống tràn khung */
.mud-table-container { overflow-x: auto; }
.mud-simple-table td { overflow-wrap: anywhere; }
.mud-simple-table td.money { overflow-wrap: normal; }

/* Bộ chọn ngày: lịch MudBlazor, không có phần đầu màu xanh, nút Hôm nay ở chân lịch */
.mud-picker-toolbar { display: none !important; }
.mud-picker-popover-paper .mud-picker-actions { justify-content: center; padding: 2px 6px; }

/* Trang hai khối: phần trên đứng yên, chỉ phần thân cuộn */
.page-fixed { display: flex; flex-direction: column; height: var(--page-fixed-height, calc(100vh - 80px)); }
.page-fixed-head { flex: 0 0 auto; }
.page-fixed-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 0 4px 24px 0; }
@media (max-width: 959px) {
    .page-fixed--desktop { display: block; height: auto; }
    .page-fixed--desktop .page-fixed-body { overflow: visible; }
}
.dashboard .bar-chart { height: 104px; }

/* Lưới dữ liệu: mọi danh sách cùng kích thước với Danh sách hợp đồng; khung chỉ đổi khi đổi kích thước cửa sổ */
.emd-grid .mud-table-container { height: max(320px, calc(100vh - 300px)); }
/* Trang báo cáo cuộn dọc theo trang nên bảng không có thanh cuộn dọc riêng; chỉ cuộn ngang khi bảng rộng hơn khung. Tiêu đề cột do app.js giữ dưới thanh trên cùng. */
.emd-grid.report-grid .mud-table-container { height: auto; overflow-x: auto; overflow-y: hidden; }
/* Tiêu đề được app.js dịch xuống theo trang: phải nằm trên các ô đã ghim của thân bảng. */
.emd-grid.report-grid thead { position: relative; z-index: 5; }

.input-uppercase input { text-transform: uppercase; }

/* Menu trái thu gọn (mini drawer, như EMD Dental): chỉ còn cột icon phân hệ, ẩn chữ, mũi tên nhóm và phím tắt. */
.app-nav-drawer.mud-drawer--closed .mud-nav-link-expand-icon,
.app-nav-drawer.mud-drawer--closed .mud-nav-link-text { display: none; }
.app-nav-drawer.mud-drawer--closed .mud-navmenu { overflow-x: hidden; }
/* Mục menu không bao giờ rớt xuống dòng thứ hai: chữ dài bị cắt bằng "…" (rê chuột xem tên đầy đủ ở các mục báo cáo). */
/* line-height 1.5 + đệm 2px trên/dưới: dấu tiếng Việt và chân chữ g, q, p, y không bị overflow cắt mất. */
.app-nav-drawer .mud-nav-link-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; line-height: 1.5; padding-top: 2px; padding-bottom: 2px; }
.app-nav-drawer .mud-nav-link { min-width: 0; }

/* Khối Khách hàng trên form Lập hợp đồng (F2).
   Hàng 1: ô tìm khách cũ + [Khách mới] trải hết chiều ngang.
   Hàng 2 (Flexbox): 4 dòng nhập liệu (flex-grow-1) | cột nhận diện cố định 160px. Card ghim tuyệt đối vào cột (inset: 0)
   nên không tự đẩy chiều cao hàng: luôn cao đúng bằng 4 dòng bên trái (đỉnh = đỉnh ô Họ tên, đáy = đáy ô Địa chỉ).
   Màn hình < 600px: card xuống dưới, canh giữa. */
.cl-search { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cl-fields { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; align-content: start; }
.cl-fields .cl-7 { grid-column: span 7; }
.cl-fields .cl-5 { grid-column: span 5; }
.cl-fields .cl-6 { grid-column: span 6; }
.cl-fields .cl-12 { grid-column: span 12; }
/* Ô nhập Dense có sẵn lề trên 8px / dưới 4px: bỏ để đỉnh ô Họ tên và đáy ô Địa chỉ trùng mép hàng (khoảng cách dòng do gap đảm nhiệm). */
.cl-search .mud-input-control.mud-input-control-margin-dense,
.cl-fields .mud-input-control.mud-input-control-margin-dense { margin-top: 0; margin-bottom: 0; }
.face-id-col { position: relative; flex: 0 0 160px; }
.face-id-col > .face-id-card { position: absolute; inset: 0; }
@media (max-width: 599.98px) {
    .customer-row { flex-direction: column; }
    .face-id-col { align-self: center; }
    .face-id-col > .face-id-card { position: static; }
    .cl-fields .cl-7, .cl-fields .cl-5 { grid-column: span 12; }
}

/* Card nhận diện 160px ôm sát khung ảnh 145×135: viền mỏng, đệm 6px hai bên, không bóng đổ. */
.face-id-card { box-sizing: border-box; display: flex; flex-direction: column; align-items: center; justify-content: space-between;
                padding: 4px 6px; border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; background: var(--mud-palette-surface); overflow: hidden; }
.face-id-head { width: 100%; display: flex; align-items: center; justify-content: center; gap: 2px; height: 18px; font-size: .8rem; font-weight: 600; line-height: 18px; white-space: nowrap; overflow: hidden; }
.face-id-stage { position: relative; flex: 0 0 auto; width: 145px; height: 135px; border: 1px solid var(--mud-palette-lines-default); border-radius: 6px; overflow: hidden;
                 background: var(--mud-palette-background-gray); display: flex; align-items: center; justify-content: center; box-sizing: border-box; }
.face-id-video { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); display: block; }
/* Canvas giữ kích thước gốc của video: cắt cùng kiểu "cover" để khung mặt khớp đúng vị trí trên khung. */
.face-id-overlay { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; pointer-events: none; }
.face-id-photo { width: 100%; height: 100%; object-fit: cover; }
.face-id-corner { position: absolute; top: 2px; right: 2px; z-index: 2; }
.face-id-corner-btn.mud-icon-button { padding: 2px; background: color-mix(in srgb, var(--mud-palette-surface) 85%, transparent); }
.face-id-message { position: absolute; left: 3px; right: 3px; bottom: 3px; padding: 2px 4px; border-radius: 6px; font-size: .68rem; line-height: 1.2; text-align: center;
                   background: color-mix(in srgb, var(--mud-palette-surface) 90%, transparent); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* Hàng nút rộng đúng 145px (bằng khung ảnh), cao 30px ở cả 2 trạng thái. */
.face-id-actions { width: 145px; height: 30px; flex: 0 0 auto; display: flex; gap: 5px; }
.face-id-actions .mud-button-root { height: 30px; min-width: 0; padding-inline: 6px; white-space: nowrap; letter-spacing: 0; }
.face-id-btn-full.mud-button-root { width: 145px; }
.face-id-half { flex: 1 1 0; min-width: 0; }
.face-id-half .mud-button-root { width: 100%; }

/* Thanh trượt ngang nổi của bảng rộng; app.js đặt vị trí và độ rộng. */
.emd-float-scroll {
    position: fixed; z-index: 20; height: 14px;
    overflow-x: auto; overflow-y: hidden;
    background: var(--mud-palette-surface);
    border-top: 1px solid var(--mud-palette-lines-default);
    box-shadow: 0 -2px 6px rgba(0, 0, 0, .12);
}
.emd-float-scroll[hidden] { display: none; }
.emd-float-scroll > div { height: 1px; }
.emd-float-scroll::-webkit-scrollbar { height: 12px; }
.emd-float-scroll::-webkit-scrollbar-thumb { background: var(--mud-palette-action-disabled); border-radius: 6px; }
.emd-float-scroll::-webkit-scrollbar-thumb:hover { background: var(--mud-palette-text-secondary); }
@media print { .emd-float-scroll { display: none !important; } }
@media (min-width: 960px) {
    .emd-grid-auto .mud-table-container { max-height: calc(100vh - 220px); }
    .emd-grid .mud-table-head .mud-table-cell, .emd-grid-auto .mud-table-head .mud-table-cell { height: 44px; padding-top: 0; padding-bottom: 0; }
    .emd-grid .mud-table-body .mud-table-row, .emd-grid-auto .mud-table-body .mud-table-row { height: 54px; }
}

/* Trang có khối thông tin dày phía trên: cả trang vừa đúng khung nhìn, bảng nhận phần chiều cao còn lại
   nên thanh phân trang luôn thấy được và trang không phát sinh thanh cuộn ngoài. 96px = thanh tiêu đề + lề khung. */
@media (min-width: 960px) {
    .grid-screen { display: flex; flex-direction: column; height: calc(100vh - 96px); }
    .grid-screen > * { flex: 0 0 auto; }
    .grid-screen > .mud-tabs, .grid-screen > .grid-screen-fill { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
    .grid-screen .mud-tabs-tabbar { flex: 0 0 auto; }
    .grid-screen .mud-tabs-panels { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; overflow-y: auto; }
    .grid-screen .mud-tab-panel-active > * { flex: 0 0 auto; }
    .grid-screen .mud-tab-panel-active > .grid-screen-row { flex: 1 1 0; min-height: 0; flex-wrap: nowrap; }
    .grid-screen-row > .mud-grid-item { display: flex; flex-direction: column; align-self: stretch; min-height: 0; overflow-y: auto; }
    .grid-screen .mud-tab-panel-active > .emd-grid, .grid-screen .emd-grid { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; }
    .grid-screen .emd-grid .mud-table-container { flex: 1 1 0; min-height: 0; height: auto; }
    .grid-screen .emd-grid .mud-table-pagination, .grid-screen .grid-pager { flex: 0 0 auto; }
}

/* Mã hợp đồng: một màu duy nhất trên toàn hệ thống */
.contract-code { color: var(--mud-palette-primary); font-weight: 700; white-space: nowrap; }

/* Badge trong ô lưới: nền màu vừa khít chữ. Trạng thái kèm số ngày quá hạn xếp thành hai dòng trong ô. */
.mud-table-cell .mud-chip.mud-chip-size-small { height: auto; min-height: 0; margin: 1px 2px; padding: 1px 6px; font-size: .75rem; line-height: 1.35; border-radius: 4px; white-space: nowrap; }
.mud-table-cell .mud-chip.mud-chip-size-small .mud-chip-content { padding: 0; }
.mud-table-cell .status-stack { display: inline-flex; flex-direction: column; align-items: flex-start; gap: 2px; }
.mud-table-cell .status-stack .mud-chip.mud-chip-size-small { margin: 0; }

/* Thanh phân trang */
#collateral-section { scroll-margin-top: 8px; }
.grid-pager { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 12px; padding: 4px 12px; min-height: 48px; border-top: 1px solid var(--mud-palette-lines-default); }
.grid-pager-label { font-size: .85rem; color: var(--mud-palette-text-secondary); white-space: nowrap; }

/* Màu theo cụm menu */
/* Menu cha có nền riêng, menu con thụt vào với chữ và biểu tượng nhỏ hơn */
:is(.nav-tone, .nav-parent) > .mud-nav-link {
    background-color: color-mix(in srgb, var(--mud-palette-drawer-text) 7%, var(--mud-palette-drawer-background));
    font-weight: 600;
    margin-top: 4px;
}
:is(.nav-tone, .nav-parent) > .mud-nav-link:hover { background-color: color-mix(in srgb, var(--mud-palette-drawer-text) 12%, var(--mud-palette-drawer-background)); }
.nav-tone .mud-nav-item .mud-nav-link { padding-left: 36px; font-size: .8125rem; font-weight: 400; }
.nav-tone .mud-nav-item .mud-nav-link-icon { font-size: 1.125rem; width: 1.125rem; height: 1.125rem; }
.nav-tone { border-left: 3px solid var(--nav-tone); }
.nav-tone .mud-nav-link-icon { color: var(--nav-tone) !important; }
.nav-tone > .mud-nav-link .mud-nav-link-text { color: var(--nav-tone); font-weight: 600; }
.nav-tone .mud-nav-link.active:not(.mud-nav-link-disabled) { color: var(--nav-tone); background-color: color-mix(in srgb, var(--nav-tone) 14%, transparent); }
.nav-tone-contracts { --nav-tone: var(--mud-palette-primary); }
.nav-tone-transactions { --nav-tone: #e8710a; }
.nav-tone-cash { --nav-tone: #059669; }
.nav-tone-reports { --nav-tone: #4f5bd5; }
.nav-tone-admin { --nav-tone: #64748b; }

/* Bảng kê mệnh giá khi chốt két */
.cash-count td { padding: 2px 6px; vertical-align: middle; }
.cash-count .mud-input-control { margin-top: 0; }

@media (max-width: 959px) {
    .kbd { display: none; }
}

@media print {
    .mud-appbar, .mud-drawer, .no-print { display: none !important; }
}

/* Quản trị hệ thống / Cấp phép: bảng gọn đủ bề ngang, form ở ngăn trượt bên phải. */
/* Ghi đè khoảng đệm mặc định của bảng dense (24px phải) để 12 cột vừa khung 1366px. */
.lic-table.mud-table .mud-table-row .mud-table-cell { padding: 6px 8px; }
.lic-table.mud-table .mud-table-row .mud-table-cell:first-child { padding-left: 16px; }
.lic-table .mud-table-head .mud-table-cell { white-space: nowrap; }
.lic-table .lic-flag { text-align: center; white-space: nowrap; }
.lic-table .lic-num { white-space: nowrap; }
.lic-table .lic-action { width: 1%; white-space: nowrap; text-align: right; }
.lic-branch { white-space: nowrap; }
.lic-sub { font-size: .75rem; color: var(--mud-palette-text-secondary); white-space: nowrap; }
.lic-off { color: var(--mud-palette-text-disabled) !important; }
.lic-drawer-host { z-index: calc(var(--mud-zindex-appbar) + 3); }
.lic-drawer { display: flex; flex-direction: column; height: 100%; }
.lic-drawer-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 16px 16px 12px 20px; border-bottom: 1px solid var(--mud-palette-lines-default); }
.lic-drawer-body { flex: 1 1 auto; overflow-y: auto; padding: 16px 20px; display: flex; flex-direction: column; gap: 20px; }
.lic-drawer-foot { flex: 0 0 auto; display: flex; justify-content: flex-end; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--mud-palette-lines-default); background: var(--mud-palette-surface); }
.lic-section-title { font-size: .8rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--mud-palette-primary); margin-bottom: 10px; }
.lic-box { border: 1px solid var(--mud-palette-lines-default); border-radius: 8px; }
.lic-box > .lic-feature + .lic-feature, .lic-box > .lic-children { border-top: 1px solid var(--mud-palette-lines-default); }
.lic-feature { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 6px 10px 14px; }
.lic-feature-title { font-weight: 600; font-size: .9rem; }
.lic-feature-desc { font-size: .78rem; color: var(--mud-palette-text-secondary); }
.lic-children { margin-left: 28px; padding: 10px 14px 12px 14px; border-left: 3px solid var(--mud-palette-primary-lighten); }

/* Nhân viên & phân quyền: dùng chung khung ngăn trượt của trang cấp phép. */
.user-perm-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 520px) { .user-perm-grid { grid-template-columns: 1fr; } }
.user-perm-group { padding: 4px 10px 8px 6px; }
.user-perm-head { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--mud-palette-lines-default); margin-bottom: 4px; }
.user-perm-title .mud-typography { font-weight: 700; }
.user-perm-items .mud-checkbox .mud-typography { font-size: .82rem; }

/* Bảng nhiều cột cần vừa khung 1366px: khoảng đệm ô 8px thay cho 16px/24px mặc định của bảng dense. */
.compact-grid.mud-table .mud-table-row .mud-table-cell { padding-left: 8px; padding-right: 8px; }
.compact-grid.mud-table .mud-table-row .mud-table-cell:first-child { padding-left: 12px; }

/* Ô nhập số tiền căn phải (tiền đầu ca, số tờ). */
.num-right input { text-align: right; }
/* Chi tiết hồ sơ khách hàng (/customers): ảnh 140×140 | thông tin cá nhân; 4 thẻ thống kê; lịch sử giao dịch. */
.cp-head { display: flex; gap: 20px; align-items: flex-start; }
.cp-portrait-col { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; gap: 8px; width: 180px; }
.cp-portrait { position: relative; width: 140px; height: 140px; border-radius: 8px; overflow: hidden; border: 1px solid var(--mud-palette-lines-default);
               background: var(--mud-palette-background-gray); display: flex; align-items: center; justify-content: center; }
.cp-portrait img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cp-portrait-actions { display: flex; flex-direction: column; gap: 6px; width: 180px; }
.cp-portrait-actions .mud-button-root { width: 100%; white-space: nowrap; font-size: .72rem; padding-inline: 6px; letter-spacing: 0; }
.cp-info { flex: 1 1 auto; min-width: 0; }
.cp-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px 24px; margin: 0; }
.cp-fields > div { min-width: 0; }
.cp-fields .cp-wide { grid-column: 1 / -1; }
.cp-fields dt { font-size: .75rem; color: var(--mud-palette-text-secondary); }
.cp-fields dd { margin: 2px 0 0; font-weight: 500; overflow-wrap: anywhere; }
.cp-stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 16px; }
.cp-stat { border: 1px solid var(--mud-palette-lines-default); border-left: 4px solid var(--cp-accent, var(--mud-palette-primary)); border-radius: 8px; padding: 10px 12px; }
.cp-stat-label { font-size: .78rem; color: var(--mud-palette-text-secondary); font-weight: 600; text-transform: uppercase; letter-spacing: .02em; }
.cp-stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.3; }
.cp-stat-value span { font-size: .8rem; font-weight: 500; color: var(--mud-palette-text-secondary); }
.cp-stat-sub { font-size: .8rem; color: var(--mud-palette-text-secondary); }
.cp-stat-open { --cp-accent: var(--mud-palette-info); }
.cp-stat-interest { --cp-accent: var(--mud-palette-primary); }
.cp-stat-redeemed { --cp-accent: var(--mud-palette-success); }
.cp-stat-liquidated { --cp-accent: var(--mud-palette-warning); }
/* Một thanh cuộn duy nhất: hộp thoại khóa 88vh, phần đầu đứng yên, chỉ thân bảng lịch sử cuộn (tiêu đề cột cố định).
   Bảng cao tối đa 320px, tự co lại trên màn hình thấp để không đẩy nút Đóng ra ngoài. */
.cp-dialog { max-height: 88vh; overflow: hidden; display: flex; flex-direction: column; }
.cp-dialog .cp-dialog-content { flex: 1 1 auto; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.cp-dialog .cp-head, .cp-dialog .cp-stats, .cp-dialog #customer-history-title { flex: 0 0 auto; }
.cp-dialog .cp-history { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; }
.cp-dialog .cp-history .mud-table-container { flex: 1 1 auto; min-height: 120px; height: auto !important; max-height: 320px; overflow-y: auto; }
.cp-dialog .cp-history .mud-table-pagination { flex: 0 0 auto; }
@media (max-width: 959.98px) { .cp-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 599.98px) {
    .cp-head { flex-direction: column; align-items: center; }
    .cp-fields { grid-template-columns: minmax(0, 1fr); }
    /* Điện thoại: phần đầu xếp dọc quá cao, cho cả nội dung cuộn để không bị cắt. */
    .cp-dialog .cp-dialog-content { overflow-y: auto; }
}

/* Cấu hình lưu trữ dữ liệu (/settings, chỉ emd) */
.storage-test-ok { color: var(--mud-palette-success); }
.storage-test-fail { color: var(--mud-palette-error); }

/* F2: nhãn "Ảnh hồ sơ hiện tại" nổi ở đáy khung ảnh */
.face-id-badge { position: absolute; left: 3px; right: 3px; bottom: 3px; padding: 1px 4px; border-radius: 6px; font-size: .66rem; line-height: 1.3; text-align: center;
                 background: color-mix(in srgb, var(--mud-palette-surface) 88%, transparent); color: var(--mud-palette-text-secondary); }
.face-id-actions .face-id-btn-update.mud-button-root { font-size: .72rem; padding-inline: 4px; }
