/* ==========================================================================
   Bluechip Asist — "Golden Gate" theme
   Phong cách macOS 27 / Liquid Glass: kính mờ khúc xạ nền, bo lớn,
   sidebar vibrancy, accent macOS blue #007AFF.
   - Sáng/tối: theo html[data-theme] (attr chuẩn FluentUI v5) do lg-prefs.js đặt
     (localStorage, mặc định theo hệ điều hành). Fluent components theo cùng attr.
   - Độ trong kính: --lg-a (alpha) + --lg-blur, chỉnh bằng slider macOS 27.
   Dùng chung cho Blazor WebApp + MAUI Blazor Hybrid.
   ========================================================================== */

:root {
    --lg-accent: #007AFF;
    --lg-accent-hover: #0A84FF;
    --lg-radius: 18px;
    --lg-font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", Helvetica, Arial, sans-serif;
    --lg-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
    --lg-a: .55;          /* alpha mặt kính: slider ghi đè (clear .28 → opaque .85) */
    --lg-blur: 28px;      /* blur mặt kính: slider ghi đè (34px → 8px) */
    /* Fluent tokens (xuyên shadow-DOM): bo + accent đồng bộ macOS */
    --control-corner-radius: 10px;
    --layer-corner-radius: 16px;
    --accent-fill-rest: #007AFF;
    --accent-fill-hover: #0A84FF;
    --accent-fill-active: #0066D6;
    color-scheme: light dark;
}
html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] { color-scheme: light; }

html, body {
    font-family: var(--lg-font);
    margin: 0;
    -webkit-font-smoothing: antialiased;
}

/* ---- Wallpaper "aurora" cố định sau cửa sổ ---- */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    background:
        radial-gradient(1100px 600px at 12% -8%, rgba(64, 120, 255, .55), transparent 60%),
        radial-gradient(900px 620px at 88% 6%, rgba(190, 110, 255, .5), transparent 60%),
        radial-gradient(1000px 800px at 85% 95%, rgba(45, 200, 190, .45), transparent 62%),
        radial-gradient(800px 700px at 8% 90%, rgba(255, 150, 200, .4), transparent 60%),
        linear-gradient(180deg, #dfeaff 0%, #eef3ff 45%, #f6f2ff 100%);
}
html[data-theme="dark"] body::before {
    background:
        radial-gradient(1100px 600px at 12% -8%, rgba(40, 90, 220, .5), transparent 60%),
        radial-gradient(900px 620px at 88% 6%, rgba(140, 70, 220, .45), transparent 60%),
        radial-gradient(1000px 800px at 85% 95%, rgba(20, 150, 150, .4), transparent 62%),
        radial-gradient(800px 700px at 8% 90%, rgba(200, 80, 140, .32), transparent 60%),
        linear-gradient(180deg, #0b1026 0%, #101736 55%, #191225 100%);
}

/* ---- Khung cửa sổ ---- */
.lg-window {
    display: flex;
    height: 100dvh;
    gap: 12px;
    padding: 12px;
    box-sizing: border-box;
    color: #1d1d1f;
}
html[data-theme="dark"] .lg-window { color: #f5f5f7; }

/* ---- Sidebar vibrancy nổi ---- */
.lg-sidebar {
    width: 266px;
    flex: 0 0 auto;
    border-radius: var(--lg-radius);
    padding: 14px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.8);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.8);
    border: 3px solid rgba(255, 255, 255, .85);
    box-shadow: 0 12px 40px rgba(20, 40, 90, .14), inset 0 1px 0 rgba(255, 255, 255, .6);
    overflow-y: auto;
}
html[data-theme="dark"] .lg-sidebar {
    background: rgba(36, 36, 40, var(--lg-a));
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
}

/* Đèn giao thông macOS (chỉ trang trí trên Web; MAUI đã có đèn thật của OS) */
.lg-traffic { display: flex; gap: 8px; padding: 2px 4px 6px; }
.lg-traffic .t { width: 12px; height: 12px; border-radius: 50%; box-shadow: inset 0 0 2px rgba(0,0,0,.25); }
.lg-traffic .r { background: #FF5F57; }
.lg-traffic .y { background: #FEBC2E; }
.lg-traffic .g { background: #28C840; }
.bc-maui .lg-traffic { display: none; }

.lg-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 17px;
    font-weight: 700;
    letter-spacing: -0.02em;
    padding: 2px 6px 8px;
}
.lg-appicon {
    width: 34px;
    height: 34px;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 20px;
    border-radius: 9px;
    background: linear-gradient(145deg, #4da3ff, #007AFF 60%, #5856D6);
    box-shadow: 0 4px 14px rgba(0, 122, 255, .4), inset 0 1px 0 rgba(255,255,255,.5);
}

/* ---- Nav kiểu Finder (dùng FluentNav/FluentNavItem v5, class lg-* tự gắn) ----
   FluentNav v5 tự đổ nền xám (colorNeutralBackground4) lên cả nav lẫn item qua
   var(--nav-bg-color). Ép transparent bằng var (kế thừa xuống item, miễn nhiễm
   specificity/thứ tự load) + selector .lg-sidebar... mạnh hơn để đè nốt
   padding/row-gap/pill :after mặc định của Fluent. */
.lg-sidebar .lg-nav {
    --nav-bg-color: transparent;
    --nav-bg-color-hover: transparent;
    display: flex;
    flex-direction: column;
    gap: 2px;
    row-gap: 2px;
    width: 100%;
    background: transparent;
    background-color: transparent;
    border: none;
    border-right: none;
    padding: 0;
    color: inherit;
}
.lg-sidebar .lg-nav .lg-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 7px 10px;
    border-radius: 10px;
    color: inherit;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    font-family: inherit;
    background: transparent;
    background-color: transparent;
    border: none;
    width: 100%;
    text-align: left;
    cursor: pointer;
}
.lg-sidebar .lg-nav .lg-link:hover { background: rgba(120, 120, 128, .16); background-color: rgba(120, 120, 128, .16); text-decoration: none; color: inherit; }
.lg-sidebar .lg-nav .lg-link.lg-active { background: var(--lg-accent); background-color: var(--lg-accent); color: #fff; box-shadow: 0 3px 10px rgba(0,122,255,.35); }
.lg-sidebar .lg-nav .lg-link.lg-active:hover { background: var(--lg-accent-hover); background-color: var(--lg-accent-hover); color: #fff; }
.lg-sidebar .lg-nav .lg-link:focus-visible { outline: 2px solid var(--lg-accent); outline-offset: 1px; }
/* Gỡ pill báo active 4px mặc định của FluentNavItem (ta đã có nền accent bo tròn) */
.lg-sidebar .lg-nav .fluent-navitem.active::after { content: none; }
/* Ẩn spacer icon mặc định của FluentNavItem (ta dùng glyph riêng) */
.lg-nav .fluent-navitem > span[style] { display: none; }
.lg-glyph {
    width: 28px;
    height: 28px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 15px;
    border-radius: 7px;
    color: #fff;
    text-shadow: 0 1px 2px rgba(0,0,0,.25);
}
.g-blue { background: linear-gradient(145deg, #4da3ff, #007AFF); }
.g-purple { background: linear-gradient(145deg, #c86dd7, #AF52DE); }
.g-green { background: linear-gradient(145deg, #5bd97a, #30a34e); }
.g-orange { background: linear-gradient(145deg, #ffb340, #FF9500); }
.g-red { background: linear-gradient(145deg, #ff7a72, #FF3B30); }
.g-teal { background: linear-gradient(145deg, #4fd6d0, #14919b); }
.g-gray { background: linear-gradient(145deg, #b9bcc4, #8E8E93); }
.lg-count {
    margin-left: auto;
    min-width: 22px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    border-radius: 11px;
    padding: 1px 7px;
    background: #FF3B30;
    color: #fff;
}

/* ---- Thu gọn sidebar (nút ◧ trên toolbar, bcNav nhớ trạng thái localStorage) ---- */
.lg-sidebar {
    transition: width .22s ease, padding-left .22s ease, padding-right .22s ease,
        opacity .18s ease, border-color .22s ease, visibility 0s;
}
.lg-window.lg-nav-collapsed .lg-sidebar {
    width: 0;
    min-width: 0;
    padding-left: 0;
    padding-right: 0;
    margin-inline-end: -12px; /* nuốt luôn gap 12px của .lg-window */
    opacity: 0;
    overflow: hidden;
    border-color: transparent;
    visibility: hidden;
    transition: width .22s ease, padding-left .22s ease, padding-right .22s ease,
        opacity .18s ease, border-color .22s ease, visibility 0s linear .22s;
}
.lg-navtoggle {
    width: 30px;
    height: 30px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 16px;
    flex: 0 0 auto;
}

/* ---- Chân sidebar: điều khiển kính + theme ---- */
.lg-sidefoot {
    margin-top: auto;
    border-radius: 12px;
    padding: 10px 12px;
    background: rgba(120, 120, 128, .14);
    border: 1px solid rgba(120, 120, 128, .22);
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.lg-glassctl { display: flex; flex-direction: column; gap: 10px; font-size: 13px; }
.lg-glassrow { display: flex; align-items: center; gap: 8px; }
.lg-glassrow span { white-space: nowrap; opacity: .8; }
.lg-glassrow input[type="range"] { flex: 1 1 auto; accent-color: var(--lg-accent); cursor: pointer; }
.lg-seg {
    display: inline-flex;
    align-self: center;
    border-radius: 9px;
    padding: 2px;
    gap: 2px;
    background: rgba(120, 120, 128, .22);
    border: 1px solid rgba(120, 120, 128, .25);
}
.lg-segbtn {
    border: none;
    background: transparent;
    border-radius: 7px;
    width: 34px;
    height: 26px;
    font-size: 14px;
    cursor: pointer;
    color: inherit;
    opacity: .65;
}
.lg-segbtn:hover { opacity: 1; }
.lg-segbtn.on {
    opacity: 1;
    background: rgba(255, 255, 255, .85);
    box-shadow: 0 1px 4px rgba(0, 0, 0, .25);
}
html[data-theme="dark"] .lg-segbtn.on { background: rgba(90, 90, 96, .9); }

/* ---- Cột nội dung ---- */
.lg-main { flex: 1 1 auto; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

.lg-toolbar {
    position: relative;
    z-index: 50;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-radius: var(--lg-radius);
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.8);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.8);
    border: 3px solid rgba(255, 255, 255, .85);
    box-shadow: 0 12px 40px rgba(20, 40, 90, .12), inset 0 1px 0 rgba(255, 255, 255, .6);
    font-size: 14px;
}
html[data-theme="dark"] .lg-toolbar {
    background: rgba(36, 36, 40, var(--lg-a));
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .45), inset 0 1px 0 rgba(255, 255, 255, .08);
}

.lg-userchip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
}
.lg-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(145deg, #9d7bff, #5856D6);
}
.lg-toolbar a { color: var(--lg-accent); text-decoration: none; font-weight: 600; }
.lg-btn-ghost {
    border: 1px solid rgba(120,120,128,.4);
    background: rgba(255,255,255,.4);
    border-radius: 9px;
    padding: 4px 12px;
    font: inherit;
    font-size: 13px;
    cursor: pointer;
    color: inherit;
}
.lg-btn-ghost:hover { background: rgba(120,120,128,.18); }

/* ---- FluentButton macOS Tahoe (xuất shadow-DOM bằng CSS variables + host) ---- */
fluent-button {
    --control-corner-radius: 10px;        /* bo góc nút */
    --layer-corner-radius: 10px;          /* bo góc layer overlay */
    font-family: var(--lg-font);
    font-size: 13.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
}
fluent-button::part(control) {
    border-radius: var(--control-corner-radius);
    padding: 6px 16px;
    min-height: 36px;
    transition: background .12s ease, box-shadow .12s ease, transform .06s ease;
}
/* Primary = accent macOS blue */
fluent-button[appearance="primary"]::part(control) {
    background: var(--accent-fill-rest);
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px rgba(0,122,255,.25);
}
fluent-button[appearance="primary"]:hover::part(control) {
    background: var(--accent-fill-hover);
    box-shadow: 0 4px 14px rgba(0,122,255,.35);
}
fluent-button[appearance="primary"]:active::part(control) {
    background: var(--accent-fill-active);
    transform: scale(0.985);
}
fluent-button[appearance="primary"]:focus-visible::part(control) {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}
/* Outline = viền kính trong suốt */
fluent-button[appearance="outline"]::part(control) {
    background: transparent;
    border: 1px solid var(--colorTransparentStroke);
    color: inherit;
    backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
}
fluent-button[appearance="outline"]:hover::part(control) {
    background: rgba(120,120,128,.12);
    border-color: rgba(120,120,128,.5);
}
fluent-button[appearance="outline"]:active::part(control) {
    background: rgba(120,120,128,.18);
}
fluent-button[appearance="outline"]:focus-visible::part(control) {
    outline: 2px solid var(--accent-fill-rest);
    outline-offset: 2px;
}
fluent-button[disabled]::part(control) { opacity: .5; cursor: not-allowed; }
fluent-button[appearance="primary"][disabled]::part(control) { box-shadow: none; }

/* Subtle/Transparent appearance fallback */
fluent-button[appearance="subtle"]::part(control),
fluent-button[appearance="transparent"]::part(control) {
    background: transparent;
    border: none;
}
fluent-button[appearance="subtle"]:hover::part(control),
fluent-button[appearance="transparent"]:hover::part(control) {
    background: rgba(120,120,128,.12);
}

.lg-content { flex: 1 1 auto; overflow-y: auto; padding: 2px 2px 24px; }
.lg-content h3 { font-size: 22px; letter-spacing: -0.02em; margin: 6px 0 8px; }
.lg-content h4 { font-size: 16px; margin: 18px 0 10px; }

/* ---- Thẻ kính ---- */
.lg-card {
    border-radius: 16px;
    padding: 14px 16px;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    border: 3px solid rgba(255, 255, 255, .85);
    box-shadow: 0 8px 28px rgba(20, 40, 90, .1), inset 0 1px 0 rgba(255, 255, 255, .55);
}
.lg-card + .lg-card { margin-top: 10px; }
html[data-theme="dark"] .lg-card {
    background: rgba(30, 30, 34, 0.85);
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 8px 28px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .07);
}

/* ---- Cột số / cột hành động trong FluentDataGrid ---- */
th.lg-num-col, td.lg-num-col {
    text-align: right;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}
th.lg-actions-col, td.lg-actions-col { text-align: right; white-space: nowrap; }

/* ---- Hàng nút hành động trong grid ---- */
/* KHÔNG đặt width/height/padding lên .lg-row-btn: FluentUI v5 render <button>
   trong shadow DOM nên kích thước bị cắt. */
.lg-row-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
}
.lg-row-actions .lg-row-btn { white-space: nowrap; }

/* ---- Nút hành động icon-only (Components) ---- */
.lg-actions {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 8px;
    background: rgba(120, 120, 128, .08);
    border: 1px solid rgba(120, 120, 128, .12);
}
.lg-actions .lg-act {
    border-color: transparent;
    background: transparent;
    color: rgba(60, 60, 67, .65);
    min-width: 28px;
    height: 28px;
    padding: 0 6px;
    border-radius: 6px;
    transition: background .12s ease, color .12s ease;
}
.lg-actions .lg-act:hover {
    background: rgba(120, 120, 128, .18);
    color: rgba(60, 60, 67, .95);
}
.lg-actions .lg-act-danger:hover {
    background: rgba(255, 59, 48, .15);
    color: #ff3b30;
}
.lg-actions .lg-act svg { display: block; margin: 0 auto; }
html[data-theme="dark"] .lg-actions {
    background: rgba(255, 255, 255, .06);
    border-color: rgba(255, 255, 255, .1);
}
html[data-theme="dark"] .lg-actions .lg-act { color: rgba(255, 255, 255, .6); }
html[data-theme="dark"] .lg-actions .lg-act:hover {
    background: rgba(255, 255, 255, .14);
    color: #fff;
}
html[data-theme="dark"] .lg-actions .lg-act-danger:hover {
    background: rgba(255, 59, 48, .25);
    color: #ff6961;
}

/* ---- Bảng kiểu danh sách macOS ---- */
.lg-content table.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13.5px;
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    border: 3px solid rgba(255, 255, 255, .85);
    box-shadow: 0 8px 28px rgba(20, 40, 90, .1);
}
html[data-theme="dark"] .lg-content table.table {
    background: rgba(30, 30, 34, 0.85);
    border-color: rgba(255, 255, 255, .5);
}
.lg-content table.table th {
    text-align: left;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .04em;
    opacity: .6;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(120, 120, 128, .3);
}
.lg-content table.table td { padding: 9px 12px; border-bottom: 1px solid rgba(120, 120, 128, .2); vertical-align: top; }
.lg-content table.table tr:last-child td { border-bottom: none; }
.lg-content table.table tbody tr:hover { background: rgba(0, 122, 255, .07); }

/* ---- FluentDataGrid kiểu danh sách macOS (kế thừa kính + bo như table.table) ---- */
.lg-content fluent-data-grid {
    --control-corner-radius: 10px;
    border-radius: 18px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    border: 3px solid rgba(255, 255, 255, .85);
    box-shadow: 0 8px 28px rgba(20, 40, 90, .1);
}
html[data-theme="dark"] .lg-content fluent-data-grid {
    background: rgba(30, 30, 34, 0.85);
    border-color: rgba(255, 255, 255, .5);
}
.lg-content fluent-data-grid::part(row):hover {
    background: rgba(0, 122, 255, .07);
}

/* Code/log kiểu SF Mono, nền grouped */
.lg-content pre {
    font-family: var(--lg-mono);
    font-size: 12.5px;
    border-radius: 10px;
    padding: 10px 12px;
    background: rgba(120, 120, 128, .14);
    border: 1px solid rgba(120, 120, 128, .22);
    overflow: auto;
    white-space: pre-wrap;
}

/* Form controls thuần của trang: bo macOS */
.lg-content select, .lg-content input[type="text"], .lg-content input[type="checkbox"] { accent-color: var(--lg-accent); }
.lg-content select {
    font: inherit;
    font-size: 13.5px;
    border-radius: 8px;
    padding: 5px 8px;
    border: 1px solid rgba(120, 120, 128, .45);
    background: rgba(255, 255, 255, .6);
    color: inherit;
}
html[data-theme="dark"] .lg-content select { background: rgba(60, 60, 66, .8); }

/* Label bọc input (v5 bỏ Label trên TextInput/TextArea) */
.lg-field { display: inline-flex; flex-direction: column; gap: 4px; font-size: 13px; }
.lg-field > span, .lg-field > fluent-label { font-weight: 600; opacity: .75; }
.lg-field fluent-text-input { min-width: 180px; }

/* ---- Responsive: sidebar thành dải ngang ---- */
@media (max-width: 880px) {
    .lg-window { flex-direction: column; height: auto; min-height: 100dvh; }
    .lg-sidebar { width: auto; }
    .lg-window.lg-nav-collapsed .lg-sidebar { display: none; }
    .lg-traffic { display: none; }
    .lg-nav { flex-direction: row; flex-wrap: wrap; }
    .lg-sidefoot { margin-top: 8px; }
    .lg-main { min-height: 60dvh; }
    .lg-navtoggle { display: none; }
}
.lg-dialog-head h4 { font-size: 17px; letter-spacing: -0.01em; margin: 2px 2px 12px; }
.lg-dialog-body { display: flex; flex-direction: column; gap: 10px; min-width: min(560px, 80vw); }
.lg-dialog-foot { display: flex; gap: 8px; justify-content: flex-end; margin-top: 14px; }
.lg-pager { display: flex; align-items: center; gap: .5rem; margin-top: .75rem; font-size: 13.5px; }
.lg-error { color: #b3261e; background: rgba(255, 59, 48, .12); border: 1px solid rgba(255, 59, 48, .4); border-radius: 10px; padding: .6rem .8rem; margin-bottom: .75rem; }
.lg-summary { display: flex; justify-content: flex-end; padding: 8px 4px 0; font-size: 13px; font-weight: 600; opacity: .7; font-variant-numeric: tabular-nums; }
/* Dòng đang chọn trong FluentDataGrid — RowClass gắn class này, nhưng <tr> do
   FluentDataGrid render nên phải đặt global (không dùng được CSS isolation). */
.selected-row { background: color-mix(in srgb, var(--lg-accent, #007AFF) 14%, transparent) !important; }
.selected-row td { font-weight: 600; }
html[data-theme="dark"] .selected-row { background: color-mix(in srgb, var(--lg-accent, #0A84FF) 22%, transparent) !important; }
/* Grid lấp đầy chiều cao còn lại của viewport: chỉ cuộn trong grid, không cuộn trang.
   Cha .lg-content (flex:1 trong cột 100dvh) cho chiều cao xác định -> height:100% ăn theo.
   LƯU Ý: FluentDataGrid render ra <table class="fluent-data-grid"> với display:grid
   + grid-template-rows:auto 1fr. Nếu để chính table làm flex item, bị kéo giãn và
   các spacer row của Virtualize đẩy nội dung lên — phải bọc trong .grid-scroll. */
.grid-page { display: flex; flex-direction: column; height: 100%; min-height: 0; }
.grid-page > h3,
.grid-page > .home-header,
.grid-page > .lg-card,
.grid-page > .lg-error,
.grid-page > .lg-summary { flex: 0 0 auto; }
.grid-scroll { flex: 1 1 auto; min-height: 0; overflow: auto; }
.grid-scroll > .fluent-data-grid { min-width: 0; }

/* ---- Home Launchpad: icon + ten, khong khung card ---- */
.module-launch-tile { display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 10px 6px; background: transparent; border: none; cursor: pointer; font-family: inherit; color: inherit; min-width: 104px; max-width: 124px; transition: transform .12s ease; }
.module-launch-tile:disabled { cursor: default; opacity: .5; }
.module-launch-icon { display: block; width: 76px; height: 76px; border-radius: 20px; overflow: hidden; box-shadow: 0 6px 18px rgba(20,40,90,.18); transition: transform .12s ease, box-shadow .12s ease; }
.module-launch-icon img { width: 100%; height: 100%; object-fit: cover; display: block; }
.module-launch-tile:hover .module-launch-icon { transform: scale(1.06); box-shadow: 0 10px 26px rgba(20,40,90,.24); }
.module-launch-tile:active .module-launch-icon { transform: scale(.94); }
.module-launch-tile:focus-visible { outline: 2px solid var(--lg-accent); outline-offset: 4px; border-radius: 12px; }
.module-launch-label { font-size: 13px; font-weight: 500; text-align: center; line-height: 1.25; opacity: .9; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
html[data-theme="dark"] .module-launch-icon { box-shadow: 0 6px 18px rgba(0,0,0,.45); }
html[data-theme="dark"] .module-launch-tile:hover .module-launch-icon { box-shadow: 0 10px 26px rgba(0,0,0,.55); }

/* ---- Module Gallery (macOS Launchpad style app tiles) ---- */
/* FluentUI v5: <button> thật nằm trong shadow DOM, phải style ::part(control) */
fluent-button.module-app-tile {
    display: block;
    min-width: 200px; max-width: 200px; min-height: 120px;
    padding: 0;
    background: transparent;
    border: none;
    box-shadow: none;
}
fluent-button.module-app-tile::part(control) {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    width: 100%;
    min-height: 120px;
    padding: 16px 14px;
    border-radius: 16px;
    border: 3px solid rgba(255, 255, 255, .85);
    background: rgba(255, 255, 255, 0.75);
    -webkit-backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    backdrop-filter: blur(var(--lg-blur)) saturate(1.6);
    box-shadow: 0 6px 20px rgba(20, 40, 90, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
    color: inherit;
    font-family: inherit;
    cursor: pointer;
    transition: transform .12s cubic-bezier(.2,.8,.2,1), box-shadow .12s cubic-bezier(.2,.8,.2,1), background .12s;
}
fluent-button.module-app-tile:hover::part(control) {
    transform: translateY(-2px) scale(1.03);
    background: rgba(255, 255, 255, calc(var(--lg-a) + 0.06));
    box-shadow: 0 16px 40px rgba(20, 40, 90, .18), inset 0 1px 0 rgba(255, 255, 255, .6);
}
fluent-button.module-app-tile:active::part(control) {
    transform: scale(.95);
    box-shadow: 0 2px 8px rgba(20, 40, 90, .08), inset 0 1px 0 rgba(255, 255, 255, .5);
    transition: transform .05s, box-shadow .05s;
}
fluent-button.module-app-tile:focus-visible::part(control) {
    outline: 2px solid var(--lg-accent);
    outline-offset: 3px;
}
fluent-button.module-app-tile.empty::part(control) {
    opacity: .38;
    cursor: not-allowed;
}
fluent-button.module-app-tile.empty:hover::part(control) {
    transform: none;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: 0 6px 20px rgba(20, 40, 90, .12), inset 0 1px 0 rgba(255, 255, 255, .7);
}
html[data-theme="dark"] fluent-button.module-app-tile::part(control) {
    background: rgba(30, 30, 34, 0.85);
    border-color: rgba(255, 255, 255, .5);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .12);
}
html[data-theme="dark"] fluent-button.module-app-tile:hover::part(control) {
    background: rgba(44, 44, 48, calc(var(--lg-a) + 0.06));
    box-shadow: 0 16px 40px rgba(0, 0, 0, .5), inset 0 1px 0 rgba(255, 255, 255, .15);
}
html[data-theme="dark"] fluent-button.module-app-tile.empty:hover::part(control) {
    background: rgba(30, 30, 34, 0.85);
    box-shadow: 0 8px 24px rgba(0, 0, 0, .4), inset 0 1px 0 rgba(255, 255, 255, .12);
}

/* Icon app 56x56 bo góc, glyph trắng trên nền gradient */
.module-app-icon-wrapper { flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 72px; height: 72px;
    border-radius: 18px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .18), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.module-app-icon { font-size: 32px; line-height: 1; }
.module-app-tile.empty .module-app-icon-wrapper { flex-shrink: 0;
    background: rgba(120, 120, 128, .18);
    box-shadow: none;
}
.module-app-icon-empty { font-size: 36px; opacity: .45; }

/* Nhãn app */
.module-app-label { min-width: 0; width: 100%; flex-shrink: 1;
    font-size: 12.5px;
    font-weight: 500;
    letter-spacing: -0.01em;
    line-height: 1.2;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    opacity: .85;
}
.module-app-tile.empty .module-app-label { min-width: 0; width: 100%; flex-shrink: 1; opacity: .4; }

/* Grid responsive: macOS Launchpad uses fixed icon size, variable columns */
.module-grid {
    display: grid;
    gap: 16px 24px;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    justify-items: center;
    align-content: start;
}
@media (max-width: 480px) {
    .module-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }
}
@media (min-width: 481px) and (max-width: 768px) {
    .module-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}
@media (min-width: 769px) and (max-width: 1024px) {
    .module-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}
@media (min-width: 1025px) {
    .module-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}
@media (min-width: 1400px) {
    .module-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}
@media (min-width: 1800px) {
    .module-grid {
        grid-template-columns: repeat(7, 1fr);
    }
}

.module-grid-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    padding: 40px 24px;
    border-radius: 18px;
    text-align: center;
    color: inherit;
    background: rgba(120, 120, 128, .1);
    border: 1px dashed rgba(120, 120, 128, .25);
    grid-column: 1 / -1;
    min-height: 160px;
}
.module-grid-empty-icon { font-size: 40px; opacity: .35; }
.module-grid-empty-title { font-size: 15px; font-weight: 600; opacity: .6; }
.module-grid-empty-desc { font-size: 12.5px; opacity: .45; }

/* ---- PWA install banner ---- */
.pwa-banner { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.pwa-banner-icon { font-size: 28px; line-height: 1; }
.pwa-banner-text { flex: 1 1 220px; margin: 0; font-size: 14px; }

/* Home page layout */
.home-page { padding: 0 0 24px; }
.home-header { margin-bottom: 20px; }
.home-header h3 { font-size: 22px; letter-spacing: -0.02em; margin: 0 0 6px; }
.home-header p { font-size: 14px; opacity: .7; margin: 0; }
.home-footer { margin-top: 28px; padding-top: 20px; border-top: 1px solid rgba(120, 120, 128, .15); text-align: center; }
.home-footer p { font-size: 13px; opacity: .55; margin: 0; }
/* ---- Login-required dialog ---- */
.lg-lock-icon { font-size: 44px; line-height: 1; }
.lg-lock-text { font-size: 14px; text-align: center; margin: 0; max-width: 320px; }

/* ---- App switcher menu (goc trai toolbar) ---- */
.appmenu { position: relative; display: inline-flex; }
.appmenu-overlay { position: fixed; inset: 0; z-index: 998; background: transparent; }
.appmenu-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 999; min-width: 230px; padding: 6px; border-radius: 14px; background: rgba(255, 255, 255, .85); -webkit-backdrop-filter: blur(28px) saturate(1.6); backdrop-filter: blur(28px) saturate(1.6); border: 1px solid rgba(255, 255, 255, .55); box-shadow: 0 16px 40px rgba(20, 40, 90, .2); display: flex; flex-direction: column; gap: 2px; }
html[data-theme="dark"] .appmenu-pop { background: rgba(44, 44, 48, .88); border-color: rgba(255, 255, 255, .14); box-shadow: 0 16px 40px rgba(0, 0, 0, .5); }
.appmenu-row { width: 100%; }
.appmenu-pop .appmenu-row::part(control) { width: 100%; justify-content: flex-start; text-align: left; padding: 6px 10px; }
.appmenu-row-in { display: flex; align-items: center; gap: 10px; width: 100%; font-size: 13.5px; text-align: left; }
.appmenu-pop.settings-pop { left: auto; right: 0; min-width: 240px; padding: 12px 14px; }
.settings-title { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .55; margin-bottom: 8px; }
.appmenu-item { display: inline-flex; align-items: center; gap: 10px; font-size: 13.5px; }
.appmenu-thumb { width: 24px; height: 24px; border-radius: 7px; object-fit: cover; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.appmenu-home { width: 24px; height: 24px; border-radius: 7px; display: inline-flex; align-items: center; justify-content: center; font-size: 14px; background: rgba(120,120,128,.18); }

/* ---- Variant matrix (Mau x Size) ---- */
.matrix-table th.mx-corner, .matrix-table th.mx-rowh { white-space: nowrap; }
.matrix-table th.mx-h { text-align: right; white-space: nowrap; }
.matrix-table td.mx-cell { text-align: right; vertical-align: middle; min-width: 110px; }
.matrix-table td.mx-cell fluent-number-field { max-width: 110px; }
.matrix-table .mx-id { font-size: 11px; opacity: .55; font-variant-numeric: tabular-nums; margin-bottom: 2px; }
.matrix-table .mx-na { opacity: .35; }
.matrix-table td.mx-total, .matrix-table th.mx-total { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; }
.matrix-table .mx-grand { font-size: 14px; }
.matrix-table tfoot th, .matrix-table tfoot td { border-top: 2px solid rgba(120,120,128,.35); }
.matrix-table .mx-sep { opacity: .4; }

/* ---- CRM sub-nav (FluentNav ngang trong card) ---- */
.crm-nav { padding: 10px 12px; margin-bottom: 12px; }
.crm-nav .lg-nav { display: flex; flex-direction: row; flex-wrap: wrap; gap: 4px; width: 100%; background: transparent; border: none; padding: 0; }
.crm-nav .lg-nav .lg-link { display: flex; align-items: center; gap: 10px; padding: 7px 12px; border-radius: 10px; color: inherit; text-decoration: none; font-size: 14px; font-weight: 500; font-family: inherit; background: transparent; border: none; cursor: pointer; }
.crm-nav .lg-nav .lg-link:hover { background: rgba(120, 120, 128, .16); text-decoration: none; color: inherit; }
.crm-nav .lg-nav .lg-link.lg-active { background: var(--lg-accent); color: #fff; box-shadow: 0 3px 10px rgba(0,122,255,.35); }
.crm-nav .lg-nav .lg-link.lg-active:hover { background: var(--lg-accent-hover); color: #fff; }
.crm-nav .lg-nav .lg-link:focus-visible { outline: 2px solid var(--lg-accent); outline-offset: 1px; }
.crm-nav .fluent-navitem.active::after { content: none; }
.crm-nav .fluent-navitem > span[style] { display: none; }
/* Sidebar trai cua CrmLayout: nav doc full-width, khong card */
.crm-side { width: 250px; }
.crm-nav.crm-nav-vertical { padding: 4px 2px; margin-bottom: 0; background: transparent; border: none; box-shadow: none; }
.crm-nav.crm-nav-vertical .lg-nav { flex-direction: column; align-items: stretch; }
.crm-nav.crm-nav-vertical .lg-nav .lg-link { width: 100%; }

/* ---- FluentDialog kieu macOS Tahoe ---- */
/* Selector fluent-dialog[fuib] copy tu chinh CSS cua library (bundle.scp.css) */
body fluent-dialog[fuib]::part(dialog) {
    width: 620px;
    max-width: min(620px, calc(100vw - 48px));
    border-radius: 18px;
    border: 1px solid rgba(255,255,255,.55);
    background: rgba(255,255,255,.82);
    -webkit-backdrop-filter: blur(28px) saturate(1.6);
    backdrop-filter: blur(28px) saturate(1.6);
    box-shadow: 0 24px 70px rgba(20,40,90,.25), inset 0 1px 0 rgba(255,255,255,.6);
    padding: 0;
    color: #1d1d1f;
    font-family: var(--lg-font);
}
html[data-theme="dark"] body fluent-dialog[fuib]::part(dialog) {
    background: rgba(36,36,40,.88);
    border-color: rgba(255,255,255,.14);
    box-shadow: 0 24px 70px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08);
    color: #f5f5f7;
}
body fluent-dialog-body[fuib] > div[slot=action] {
    gap: 8px;
    padding: 12px 20px 16px;
    border-top: 1px solid rgba(120,120,128,.25);
}
/* Section trong dialog san pham */
.lg-pdlg { display: flex; flex-direction: column; gap: 16px; padding: 18px 20px 4px; }
.lg-pdlg-sec { display: flex; flex-direction: column; gap: 8px; }
.lg-pdlg-sec > h5 { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; opacity: .55; margin: 0; }
.lg-pdlg-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: flex-end; }
.lg-pdlg-row > * { flex: 1 1 150px; }
/* Dialog san pham 2 cot: form trai + anh dai dien phai */
.lg-pdlg2 { display: flex; gap: 18px; align-items: flex-start; padding: 18px 20px 4px; }
.lg-pdlg2-main { flex: 1 1 auto; min-width: 0; }
.lg-pdlg2-main > .lg-pdlg { padding: 0; }
.lg-pdlg2-side { flex: 0 0 200px; display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; }
.lg-pimg-box { width: 200px; height: 200px; border-radius: 14px; overflow: hidden; background: rgba(120,120,128,.12); border: 1px solid rgba(120,120,128,.25); display: flex; align-items: center; justify-content: center; color: rgba(120,120,128,.8); }
.lg-pimg-box img { width: 100%; height: 100%; object-fit: cover; display: block; }
html[data-theme="dark"] .lg-pimg-box { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.12); }
@media (max-width: 600px) { .lg-pdlg2 { flex-direction: column; } .lg-pdlg2-side { flex: none; width: 100%; } .lg-pimg-box { width: 100%; height: 180px; } }

/* ---- FluentSpinner centered in parent ---- */
fluent-spinner { display: block; margin: 1.5rem auto; }
*:has(> fluent-spinner:only-child) {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60px;
}

/* ---- FluentTextInput macOS style ----
   FluentUI web component shadow DOM:
     <div part="root">  <-- outer box: border, radius, background, padding
       <input part="control">  <-- inner input (border:none by default)
     </div>
   Style the ::part(root) box only; keep ::part(control) borderless,
   otherwise the input gets TWO frames (root border + control border). */
fluent-text-input::part(root),
fluent-text-field::part(root) {
    border: 1px solid rgba(120, 120, 128, .45);
    border-radius: 10px;
    background: rgba(255, 255, 255, .6);
    box-shadow: none;
    transition: border-color .12s ease, box-shadow .12s ease;
}
fluent-text-input::part(control),
fluent-text-field::part(control) {
    border: none;
    outline: none;
    background: transparent;
    box-shadow: none;
    color: inherit;
    font-family: var(--lg-font);
    font-size: 13.5px;
    padding: 0;
}
fluent-text-input:focus-within::part(root),
fluent-text-field:focus-within::part(root) {
    border-color: var(--lg-accent);
    box-shadow: 0 0 0 3px rgba(0, 122, 255, .15);
}
html[data-theme="dark"] fluent-text-input::part(root),
html[data-theme="dark"] fluent-text-field::part(root) {
    background: rgba(60, 60, 66, .8);
    border-color: rgba(255, 255, 255, .15);
}
/* Search pill */
fluent-text-input.lg-search::part(root),
fluent-text-field.lg-search::part(root) {
    border-radius: 20px;
}
fluent-text-input.lg-search::part(control),
fluent-text-field.lg-search::part(control) {
    padding-left: 20px;
}
/* Hosts themselves carry no frame */
fluent-text-input,
fluent-text-field,
fluent-field {
    border: none;
    background: transparent;
    box-shadow: none;
}

/* ---- Icon-only action buttons in grid rows ---- */
fluent-button[appearance="transparent"]::part(control) { padding: 2px 4px; min-height: 24px; border-radius: 4px; }