/* ═══════════════════════════════════════════════════════════════
   Trang Phân quyền hệ thống — flat hiện đại, bóng đổ mềm
   ═══════════════════════════════════════════════════════════════ */

.pqu-page {
    position: relative;
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--topbar-h));
    min-height: 0;
    gap: 12px;
    padding: 14px 18px 18px;
    overflow: hidden;
    background: linear-gradient(180deg, #f7f9fc 0%, #edf1f7 100%);
    user-select: none;
}

.pqu-page * { min-width: 0; }

/* ── Nền động chuyên nghiệp ── */
.pqu-bg { position: absolute; inset: 0; overflow: hidden; pointer-events: none; z-index: 0; }
.pqu-blob { position: absolute; border-radius: 50%; filter: blur(80px); opacity: .34; animation: pquFloat 22s ease-in-out infinite; }
.pqu-blob.b1 { width: 460px; height: 460px; top: -180px; right: -120px; background: #b9e8d3; }
.pqu-blob.b2 { width: 380px; height: 380px; bottom: -150px; left: -120px; background: #c4e2f5; animation-delay: -8s; }
.pqu-blob.b3 { width: 320px; height: 320px; top: 42%; left: 48%; background: #dcd6f5; animation-delay: -13s; opacity: .26; }
.pqu-blob.b4 { width: 240px; height: 240px; top: 6%; left: 6%; background: #f5e3c8; animation-delay: -17s; opacity: .22; }

@keyframes pquFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    33% { transform: translate(36px, -26px) scale(1.08); }
    66% { transform: translate(-24px, 20px) scale(.94); }
}

@keyframes pquIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

/* ── Thanh trên: thống kê + thao tác nhanh ── */
.pqu-topbar {
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05), 0 0 0 1px rgba(255, 255, 255, .6) inset;
}

.pqu-stats { display: flex; align-items: center; gap: 26px; flex-wrap: wrap; }
.pqu-stat { display: flex; align-items: center; gap: 11px; }
.pqu-stat-icon {
    width: 40px; height: 40px; border-radius: 12px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 17px;
}
.pqu-stat-icon.ic-groups { background: #e0e7ff; color: #4338ca; }
.pqu-stat-icon.ic-active { background: #d1fae5; color: #047857; }
.pqu-stat-icon.ic-total { background: #dbeafe; color: #1d4ed8; }
.pqu-stat-icon.ic-granted { background: #fef3c7; color: #b45309; }
.pqu-stat-body { display: flex; flex-direction: column; line-height: 1.15; }
.pqu-stat-body strong { font-size: 20px; font-weight: 800; color: #0f172a; font-variant-numeric: tabular-nums; letter-spacing: -.02em; }
.pqu-stat-body small { font-size: 11px; color: #64748b; font-weight: 600; }

.pqu-topbar-actions { display: flex; gap: 8px; flex-shrink: 0; }
.pqu-icon-btn {
    width: 36px; height: 36px; border-radius: 10px; border: none;
    display: inline-flex; align-items: center; justify-content: center; font-size: 15px;
    background: #f1f5f9; color: #475569; cursor: pointer;
    transition: background .15s ease, color .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pqu-icon-btn:hover { background: #e2e8f0; color: #059669; transform: translateY(-1px); }

/* ── Không gian làm việc ── */
.pqu-workspace {
    --permission-left-width: 300px;
    position: relative;
    z-index: 1;
    flex: 1 1 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(220px, var(--permission-left-width)) 10px minmax(0, 1fr);
    gap: 10px;
    align-items: stretch;
    overflow: hidden;
}

.pqu-workspace.right-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 2000;
    width: 100vw;
    height: 100vh;
    padding: 14px 18px 18px;
    grid-template-columns: minmax(0, 1fr);
    background: #f7f9fb;
}

.pqu-workspace.right-fullscreen > .pqu-side,
.pqu-workspace.right-fullscreen > .permission-resizer { display: none; }

/* ── Cột trái: nhóm quyền ── */
.pqu-side {
    display: flex;
    flex-direction: column;
    min-height: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05), 0 0 0 1px rgba(255, 255, 255, .6) inset;
    overflow: hidden;
}

.pqu-side-head {
    display: flex; align-items: center; gap: 8px; flex-shrink: 0;
    padding: 11px 12px; border-bottom: 1px solid #f1f5f9;
}
.pqu-side-icon {
    width: 28px; height: 28px; border-radius: 8px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    background: linear-gradient(135deg, #34d399, #059669); color: #fff;
    box-shadow: 0 2px 6px rgba(5, 150, 105, .3);
}
.pqu-side-title { font-size: 13.5px; font-weight: 800; color: #0f172a; }
.pqu-side-count {
    min-width: 22px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
    background: #f1f5f9; color: #475569; text-align: center;
}
.pqu-add {
    margin-left: auto; width: 30px; height: 30px; border-radius: 9px; border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-size: 16px; color: #fff;
    background: #10b981; box-shadow: 0 2px 8px rgba(16, 185, 129, .35);
    transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.pqu-add:hover:not(:disabled) { background: #059669; transform: translateY(-1px); box-shadow: 0 4px 14px rgba(5, 150, 105, .4); }
.pqu-add:disabled { opacity: .45; cursor: not-allowed; }

.pqu-search {
    display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center;
    min-height: 36px; margin: 12px 12px 4px; border-radius: 10px;
    background: #f1f5f9; flex-shrink: 0;
    transition: background .15s ease, box-shadow .15s ease;
}
.pqu-search:focus-within { background: #fff; box-shadow: 0 0 0 3px rgba(16, 185, 129, .15), 0 1px 2px rgba(15,23,42,.06); }
.pqu-search i { color: #94a3b8; text-align: center; }
.pqu-search input { width: 100%; border: 0; outline: 0; background: transparent; color: #0f172a; font-size: 12.5px; padding-right: 8px; }
.pqu-search input::placeholder { color: #94a3b8; }

.pqu-side-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 5px; padding: 8px 12px 12px; }
.pqu-side-list::-webkit-scrollbar { width: 6px; }
.pqu-side-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }
.pqu-side-list::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

.pqu-side-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    min-height: 120px; padding: 20px; border-radius: 12px;
    background: #f8fafc; color: #94a3b8; font-size: 12px; font-weight: 600; text-align: center;
}
.pqu-side-empty i { font-size: 28px; color: #cbd5e1; }

.pqu-group-item {
    position: relative; width: 100%; display: grid;
    grid-template-columns: 34px minmax(0, 1fr) auto 8px; gap: 8px; align-items: center;
    padding: 9px 10px; border: none; border-radius: 10px;
    background: transparent; color: #0f172a; text-align: left; cursor: pointer;
    transition: background .15s ease, box-shadow .15s ease;
}
.pqu-group-item:hover { background: #f8fafc; }
.pqu-group-item.active { background: #ecfdf5; box-shadow: inset 3px 0 0 #10b981; }

.pqu-group-icon {
    width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 14px;
    background: #f1f5f9; color: #64748b;
}
.pqu-group-item.active .pqu-group-icon { background: #d1fae5; color: #047857; }
.pqu-group-icon.inactive { background: #fef2f2; color: #dc2626; }

.pqu-group-info { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pqu-group-info strong { font-size: 12.5px; font-weight: 700; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-group-info small { font-size: 10.5px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pqu-group-users {
    display: inline-flex; align-items: center; gap: 4px; flex-shrink: 0;
    min-width: 26px; padding: 2px 7px; border-radius: 99px;
    font-size: 10.5px; font-weight: 800; font-variant-numeric: tabular-nums;
    background: #f1f5f9; color: #64748b;
}
.pqu-group-users i { font-size: 11px; }
.pqu-group-item.active .pqu-group-users { background: #d1fae5; color: #047857; }

.pqu-group-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.pqu-group-dot.on { background: #10b981; }
.pqu-group-dot.off { background: #f59e0b; }

/* ── Resizer ── */
.permission-resizer {
    position: relative;
    min-width: 10px;
    border-radius: 6px;
    cursor: col-resize;
    touch-action: none;
    background: transparent;
}
.permission-resizer::before {
    content: "";
    position: absolute;
    top: 50%; left: 50%; transform: translate(-50%, -50%);
    width: 2px; height: 34px; border-radius: 2px;
    background: #e2e8f0;
    transition: background .15s ease, width .15s ease;
}
.permission-resizer:hover::before,
.permission-resizer.dragging::before { background: #10b981; width: 3px; }
body.permission-resizing { cursor: col-resize; user-select: none; }

/* ── Cột phải: cấu hình quyền ── */
.pqu-main {
    min-height: 0;
    min-width: 0;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 6px 20px rgba(15, 23, 42, .09), 0 2px 6px rgba(15, 23, 42, .05), 0 0 0 1px rgba(255, 255, 255, .6) inset;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.pqu-empty-hero {
    flex: 1 1 auto; display: flex; flex-direction: column; align-items: center; justify-content: center;
    gap: 14px; padding: 40px; text-align: center;
}
.pqu-empty-icon {
    width: 76px; height: 76px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 32px; color: #059669;
    background: #d1fae5;
    box-shadow: 0 8px 20px rgba(16, 185, 129, .2);
}
.pqu-empty-hero h3 { margin: 0; font-size: 15px; font-weight: 800; color: #0f172a; }
.pqu-empty-hero p { margin: 0; max-width: 300px; font-size: 12.5px; color: #64748b; line-height: 1.5; }

/* Editor */
.pqu-editor { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

.pqu-editor-head {
    flex-shrink: 0; display: flex; align-items: center; justify-content: space-between; gap: 12px;
    flex-wrap: wrap; padding: 10px 14px; border-bottom: 1px solid #f1f5f9;
    background: #fbfcfe;
}

.pqu-group-summary { display: flex; align-items: center; gap: 10px; flex: 1 1 auto; min-width: 0; }
.pqu-group-summary-icon {
    width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 17px;
    background: #d1fae5; color: #047857;
}
.pqu-group-summary-icon.inactive { background: #fef2f2; color: #dc2626; }
.pqu-group-summary-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pqu-group-summary-text strong { font-size: 14px; font-weight: 800; color: #0f172a; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-group-summary-text small { font-size: 11px; color: #64748b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.pqu-badge {
    display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0;
    padding: 4px 11px; border-radius: 99px; font-size: 11px; font-weight: 700;
}
.pqu-badge .dot { width: 6px; height: 6px; border-radius: 50%; }
.pqu-badge.on { background: #d1fae5; color: #047857; }
.pqu-badge.on .dot { background: #10b981; }
.pqu-badge.off { background: #fef3c7; color: #b45309; }
.pqu-badge.off .dot { background: #f59e0b; }

.pqu-editor-actions { display: flex; gap: 6px; flex-shrink: 0; flex-wrap: wrap; }
.pqu-act {
    display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 0 12px;
    border-radius: 9px; border: none; font-size: 12px; font-weight: 700; cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.pqu-act:hover:not(:disabled) { transform: translateY(-1px); }
.pqu-act:disabled { opacity: .45; cursor: not-allowed; }
.pqu-act.primary { background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16, 185, 129, .3); }
.pqu-act.primary:hover:not(:disabled) { background: #059669; box-shadow: 0 4px 14px rgba(5, 150, 105, .36); }
.pqu-act.ghost { background: #f1f5f9; color: #475569; }
.pqu-act.ghost:hover:not(:disabled) { background: #e2e8f0; color: #059669; }
.pqu-act.danger { background: #fef2f2; color: #dc2626; }
.pqu-act.danger:hover:not(:disabled) { background: #fee2e2; }
.pqu-act.icon { padding: 0; width: 32px; min-height: 32px; justify-content: center; background: #f1f5f9; color: #475569; }
.pqu-act.icon:hover:not(:disabled) { background: #e2e8f0; color: #059669; }

/* Filter bar */
.pqu-filterbar {
    flex-shrink: 0; display: grid; grid-template-columns: minmax(220px, 1.2fr) auto minmax(300px, auto);
    gap: 8px; align-items: center; padding: 10px 14px; border-bottom: 1px solid #f1f5f9;
    background: #fbfcfe;
}

.pqu-filter-search {
    display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; align-items: center;
    min-height: 36px; border-radius: 10px; background: #f1f5f9;
    transition: background .15s ease, box-shadow .15s ease;
}
.pqu-filter-search:focus-within { background: #fff; box-shadow: 0 0 0 3px rgba(16, 185, 129, .15), 0 1px 2px rgba(15,23,42,.06); }
.pqu-filter-search i { color: #94a3b8; text-align: center; }
.pqu-filter-search input { width: 100%; border: 0; outline: 0; background: transparent; color: #0f172a; font-size: 12.5px; padding-right: 8px; }
.pqu-filter-search input::placeholder { color: #94a3b8; }

.pqu-filter-tabs { display: inline-flex; align-items: center; padding: 3px; border-radius: 10px; background: #f1f5f9; }
.pqu-filter-tabs button {
    min-height: 28px; padding: 0 11px; border: none; border-radius: 7px; background: transparent;
    color: #64748b; font-size: 11.5px; font-weight: 700; cursor: pointer; transition: background .15s ease, color .15s ease, box-shadow .15s ease;
}
.pqu-filter-tabs button.active { background: #fff; color: #047857; box-shadow: 0 1px 3px rgba(16, 24, 40, .12); }

.pqu-bulk {
    display: inline-flex; align-items: center; justify-content: flex-end; gap: 8px; min-height: 36px;
    padding: 4px 6px 4px 10px; border-radius: 10px;
    background: #f1f5f9; color: #64748b; font-size: 11.5px; white-space: nowrap;
}
.pqu-bulk > span { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; }
.pqu-bulk > span i { color: #059669; }
.pqu-bulk strong { color: #047857; }
.pqu-bulk > div { display: inline-flex; gap: 5px; }
.pqu-collapse-actions { padding-left: 6px; border-left: 1px solid #e2e8f0; }

.pqu-mini {
    display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 9px;
    border: none; border-radius: 8px; background: #fff;
    color: #475569; font-size: 11px; font-weight: 700; cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.pqu-mini.success { color: #047857; }
.pqu-mini:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 2px 6px rgba(15, 23, 42, .1); }
.pqu-mini:disabled { opacity: .5; cursor: not-allowed; }

/* Ma trận quyền */
.pqu-matrix {
    flex: 1 1 auto; min-height: 0; overflow-y: auto;
    padding: 12px 14px;
    background: #f7f9fb;
}
.pqu-matrix::-webkit-scrollbar { width: 8px; }
.pqu-matrix::-webkit-scrollbar-track { background: transparent; }
.pqu-matrix::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }
.pqu-matrix::-webkit-scrollbar-thumb:hover { background: #cbd5e1; }

.pqu-page-card {
    flex-shrink: 0;
    margin-bottom: 12px;
    border-radius: 14px; overflow: hidden;
    background: #fff;
    border: 1px solid #e3e9f1;
    box-shadow: 0 2px 8px rgba(15, 23, 42, .06);
    animation: pquIn .25s ease both;
}
.pqu-page-card:last-child { margin-bottom: 0; }

.pqu-page-head {
    display: flex; align-items: center; gap: 10px; min-height: 50px; padding: 9px 13px;
    border-bottom: 1px solid #e3e9f1;
    background: linear-gradient(180deg, #fbfcfe, #f3f6fa);
    cursor: pointer;
    transition: background .15s ease;
}
.pqu-page-card.open .pqu-page-head { background: linear-gradient(180deg, #f0fdf7, #f5fbf8); border-bottom: 1px solid #c9efdc; }
.pqu-page-head:hover { background: #eef2f7; }

.pqu-page-chevron {
    width: 20px; height: 20px; flex-shrink: 0; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 13px; color: #64748b; background: #eef2f7;
    transition: background .15s ease, color .15s ease;
}
.pqu-page-card.open .pqu-page-chevron { background: #d1fae5; color: #047857; }
.pqu-page-chevron i { display: inline-block; transition: transform .2s ease; }
.pqu-page-card.open .pqu-page-chevron i { transform: rotate(90deg); }

.pqu-page-icon {
    width: 32px; height: 32px; border-radius: 9px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center; font-size: 15px;
    background: linear-gradient(135deg, #d1fae5, #a7f3d0); color: #047857;
    box-shadow: 0 2px 6px rgba(16, 185, 129, .18);
}
.pqu-page-title { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 0 1 auto; }
.pqu-page-title h4 { margin: 0; font-size: 13px; font-weight: 800; color: #0f172a; line-height: 1.2; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-page-title span { font-size: 10.5px; color: #64748b; font-weight: 500; }

.pqu-page-progress { flex: 1 1 60px; min-width: 50px; max-width: 180px; height: 7px; border-radius: 99px; background: #e4e9f0; overflow: hidden; box-shadow: inset 0 1px 2px rgba(15,23,42,.05); }
.pqu-page-progress span { display: block; height: 100%; border-radius: 99px; background: linear-gradient(90deg, #34d399, #059669); transition: width .4s cubic-bezier(.4, 0, .2, 1); }

.pqu-page-count {
    flex-shrink: 0; min-width: 44px; padding: 3px 9px; border-radius: 99px;
    font-size: 11px; font-weight: 800; font-variant-numeric: tabular-nums; text-align: center;
    background: #eef2f7; color: #64748b;
    box-shadow: inset 0 0 0 1px #e3e9f1;
}
.pqu-page-count.has { background: #d1fae5; color: #047857; box-shadow: inset 0 0 0 1px #86d3ab; }

.pqu-page-actions { display: inline-flex; gap: 5px; flex-shrink: 0; }
.pqu-page-actions button {
    display: inline-flex; align-items: center; gap: 5px; min-height: 28px; padding: 0 9px;
    border: none; border-radius: 8px; background: #fff;
    color: #475569; font-size: 11px; font-weight: 700; cursor: pointer;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease, color .15s ease;
}
.pqu-page-actions button.success { color: #047857; }
.pqu-page-actions button:hover:not(:disabled) { transform: translateY(-1px); color: #047857; box-shadow: 0 2px 6px rgba(15, 23, 42, .1); }
.pqu-page-actions button:disabled { opacity: .5; cursor: not-allowed; }

.pqu-page-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px;
    padding: 12px;
    background: #f6f9f8;
}

.pqu-permit {
    position: relative; display: grid; grid-template-columns: 24px minmax(0, 1fr); gap: 10px; align-items: flex-start;
    padding: 11px 12px; border-radius: 12px; background: #fff;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    cursor: pointer; transition: transform .16s ease, background .16s ease, box-shadow .16s ease;
}
.pqu-permit:hover { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(15, 23, 42, .1); }
.pqu-permit.checked {
    background: linear-gradient(135deg, #ecfdf5, #f0fdf9);
    box-shadow: inset 0 0 0 1.5px #6ee7b7, 0 3px 10px rgba(16, 185, 129, .14);
}
.pqu-permit.checked::before {
    content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px;
    border-radius: 3px; background: #10b981;
}
.pqu-permit input { position: absolute; opacity: 0; pointer-events: none; }

.pqu-permit-check {
    display: inline-flex; align-items: center; justify-content: center;
    width: 22px; height: 22px; border-radius: 7px;
    background: #fff; color: transparent; font-size: 13px; margin-top: 1px;
    box-shadow: inset 0 0 0 1.5px #cbd5e1;
    transition: background .16s ease, color .16s ease, transform .16s ease, box-shadow .16s ease;
}
.pqu-permit.checked .pqu-permit-check {
    background: linear-gradient(135deg, #34d399, #10b981); color: #fff; transform: scale(1.08);
    box-shadow: 0 3px 10px rgba(16, 185, 129, .35);
}

.pqu-permit-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.pqu-permit-body strong { color: #1e293b; font-size: 12px; font-weight: 700; line-height: 1.22; overflow-wrap: anywhere; }
.pqu-permit-body small { color: #64748b; font-size: 10.5px; line-height: 1.25; overflow-wrap: anywhere; }
.pqu-permit-body code {
    width: fit-content; max-width: 100%; padding: 2px 6px; border-radius: 5px;
    background: #eef2f7; color: #475569; font-size: 10px; font-family: 'SF Mono', 'Cascadia Code', monospace;
    line-height: 1.3; overflow-wrap: anywhere;
}
.pqu-permit.checked .pqu-permit-body code { background: #d1fae5; color: #047857; }
.pqu-permit.checked .pqu-permit-body strong { color: #047857; }

.pqu-empty {
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
    min-height: 140px; padding: 24px; border-radius: 12px;
    background: #f8fafc; color: #94a3b8; font-size: 12.5px; font-weight: 600; text-align: center;
}
.pqu-empty i { font-size: 28px; color: #cbd5e1; }

/* ── Modal ── */
.pqu-modal-overlay {
    position: fixed; inset: 0; z-index: 1200; background: rgba(15, 23, 42, .5); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center; padding: 20px; animation: pquIn .18s ease both;
}
.pqu-modal { width: 100%; max-width: 440px; background: #fff; border-radius: 16px; padding: 22px; box-shadow: 0 24px 60px rgba(15, 23, 42, .28); }
.pqu-modal-lg { max-width: 620px; }
.pqu-modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.pqu-modal-head h3 { margin: 0; font-size: 16px; font-weight: 800; color: #0f172a; display: flex; align-items: center; gap: 8px; }
.pqu-modal-head h3 i { color: #059669; }
.pqu-modal-close { border: none; background: #f1f5f9; font-size: 14px; color: #64748b; cursor: pointer; padding: 6px; border-radius: 8px; width: 30px; height: 30px; display: inline-flex; align-items: center; justify-content: center; }
.pqu-modal-close:hover { background: #e2e8f0; color: #0f172a; }
.pqu-modal-sub { font-size: 12.5px; color: #64748b; margin: 0 0 14px; line-height: 1.5; }
.pqu-modal-sub strong { color: #0f172a; }

.pqu-modal-form { display: flex; flex-direction: column; gap: 12px; margin-bottom: 18px; }
.pqu-modal-form .app-form-group { margin: 0; }

.pqu-modal-list { display: flex; flex-direction: column; gap: 7px; max-height: 300px; overflow-y: auto; margin-bottom: 18px; padding-right: 2px; }
.pqu-modal-item {
    display: grid; grid-template-columns: 30px minmax(0, 1fr) 20px; gap: 10px; align-items: center;
    padding: 9px 10px; border: none; border-radius: 10px; background: #f8fafc;
    cursor: pointer; text-align: left; transition: background .15s ease;
}
.pqu-modal-item:hover { background: #f1f5f9; }
.pqu-modal-item.active { background: #ecfdf5; box-shadow: inset 0 0 0 1px #a7f3d0; }
.pqu-modal-item > i:first-child { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: 14px; background: #eef2f7; color: #64748b; }
.pqu-modal-item.active > i:first-child { background: #d1fae5; color: #047857; }
.pqu-modal-item > span { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.pqu-modal-item > span strong { font-size: 12.5px; font-weight: 700; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-modal-item > span small { font-size: 10.5px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-modal-check { font-size: 15px; color: #10b981; opacity: 0; transition: opacity .15s ease; }
.pqu-modal-item.active .pqu-modal-check { opacity: 1; }
.pqu-modal-empty { padding: 22px; text-align: center; color: #94a3b8; font-size: 12.5px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.pqu-modal-empty i { font-size: 26px; color: #cbd5e1; }

.pqu-modal-actions { display: flex; gap: 10px; }
.pqu-modal-actions-top { margin-top: 16px; }
.pqu-modal-cancel, .pqu-modal-confirm {
    flex: 1; display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    padding: 11px 16px; border-radius: 10px; font-size: 13.5px; font-weight: 700; cursor: pointer;
    border: none; transition: all .15s ease;
}
.pqu-modal-cancel { background: #f1f5f9; color: #334155; }
.pqu-modal-cancel:hover { background: #e2e8f0; }
.pqu-modal-confirm { background: #10b981; color: #fff; box-shadow: 0 4px 12px rgba(16, 185, 129, .3); }
.pqu-modal-confirm:hover:not(:disabled) { background: #059669; transform: translateY(-1px); }
.pqu-modal-confirm:disabled { opacity: .6; cursor: not-allowed; }

/* ── Nút xóa tìm kiếm ── */
.pqu-search-clear {
    width: 26px; height: 26px; margin-right: 4px; border: none; border-radius: 7px;
    background: transparent; color: #94a3b8; cursor: pointer; font-size: 14px;
    display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
    transition: background .15s ease, color .15s ease;
}
.pqu-search-clear:hover { background: #e2e8f0; color: #475569; }

/* ── Modal thành viên ── */
.pqu-member-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.pqu-member-count { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; font-weight: 700; color: #475569; }
.pqu-member-count i { color: #10b981; font-size: 15px; }
.pqu-member-add-btn {
    display: inline-flex; align-items: center; gap: 6px; min-height: 34px; padding: 0 14px;
    border: none; border-radius: 9px; font-size: 12.5px; font-weight: 700; cursor: pointer;
    background: #10b981; color: #fff; box-shadow: 0 2px 8px rgba(16, 185, 129, .3);
    transition: background .15s ease, box-shadow .15s ease, transform .15s ease;
}
.pqu-member-add-btn:hover:not(:disabled) { background: #059669; box-shadow: 0 4px 14px rgba(5, 150, 105, .36); transform: translateY(-1px); }
.pqu-member-add-btn:disabled { opacity: .45; cursor: not-allowed; }

.pqu-member-search { margin-bottom: 10px; }

.pqu-member-list { display: flex; flex-direction: column; gap: 8px; max-height: 360px; overflow-y: auto; padding-right: 2px; }
.pqu-member-list::-webkit-scrollbar { width: 6px; }
.pqu-member-list::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

.pqu-member {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 12px; border-radius: 12px; background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    transition: box-shadow .15s ease, transform .15s ease;
}
.pqu-member:hover { box-shadow: 0 4px 14px rgba(15, 23, 42, .08); }
.pqu-member .avatar { flex-shrink: 0; }

.pqu-member-info { display: flex; flex-direction: column; gap: 3px; min-width: 0; flex: 1 1 auto; }
.pqu-member-info strong { font-size: 13px; font-weight: 700; color: #0f172a; }
.pqu-member-meta { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pqu-member-username { font-size: 11px; font-weight: 600; color: #64748b; font-family: 'SF Mono', 'Cascadia Code', monospace; }
.pqu-member-dept { display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; color: #475569; background: #f1f5f9; padding: 1px 7px; border-radius: 5px; }
.pqu-member-dept i { color: #94a3b8; font-size: 10px; }
.pqu-member-groups { display: flex; flex-wrap: wrap; gap: 4px; }
.pqu-member-groups span {
    padding: 2px 8px; border-radius: 99px; font-size: 10px; font-weight: 700;
    background: #eef2f7; color: #64748b;
}
.pqu-member-groups span.current { background: #d1fae5; color: #047857; }

.pqu-member-remove {
    display: inline-flex; align-items: center; gap: 5px; flex-shrink: 0;
    min-height: 30px; padding: 0 11px; border: none; border-radius: 8px;
    background: #fef2f2; color: #dc2626; font-size: 11.5px; font-weight: 700; cursor: pointer;
    transition: background .15s ease, transform .15s ease;
}
.pqu-member-remove:hover:not(:disabled) { background: #fee2e2; transform: translateY(-1px); }
.pqu-member-remove:disabled { opacity: .5; cursor: not-allowed; }

/* ── Danh sách ứng viên thêm thành viên ── */
.pqu-member-candidates {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 8px;
    max-height: 380px; overflow-y: auto; padding-right: 2px;
}
.pqu-member-candidates::-webkit-scrollbar { width: 6px; }
.pqu-member-candidates::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 3px; }

.pqu-member-candidate {
    display: flex; align-items: center; gap: 10px; min-width: 0;
    padding: 9px 11px; border: none; border-radius: 12px; background: #fff;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
    cursor: pointer; text-align: left; color: #334155;
    transition: box-shadow .15s ease, transform .15s ease, background .15s ease;
}
.pqu-member-candidate:hover:not(:disabled) { background: #f0fdf7; box-shadow: 0 4px 14px rgba(16, 185, 129, .14); transform: translateY(-1px); }
.pqu-member-candidate:disabled { opacity: .5; cursor: not-allowed; }
.pqu-member-candidate .avatar { flex-shrink: 0; }
.pqu-member-candidate-info { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pqu-member-candidate-info strong { font-size: 12.5px; font-weight: 700; color: #1e293b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-member-candidate-info small { font-size: 10.5px; color: #94a3b8; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pqu-member-candidate > i:last-child { color: #10b981; font-size: 16px; flex-shrink: 0; }

/* ── Responsive ── */
@media (max-width: 980px) {
    .pqu-workspace { grid-template-columns: 1fr; grid-template-rows: minmax(150px, .4fr) minmax(0, 1fr); }
    .permission-resizer { display: none; }
    .pqu-filterbar { grid-template-columns: 1fr; }
    .pqu-bulk { justify-content: flex-start; }
}

@media (max-width: 640px) {
    .pqu-page { padding: 10px 12px 14px; }
    .pqu-stats { gap: 18px; }
    .pqu-page-list { grid-template-columns: 1fr; }
    .pqu-editor-head { align-items: stretch; }
    .pqu-editor-actions { justify-content: flex-end; }
    .pqu-member-candidates { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    .pqu-page-card, .pqu-permit { animation: none !important; transition: none !important; }
}
