:root {
    --g: 12px;
    --hl: #f0f9ff;
    --hl-b: #bae6fd;
}

/* Đảm bảo nền của body nếu được đặt ở ngoài sẽ được thừa hưởng, nhưng form thì clean */
#frmDK input,
#frmDK select,
#frmDK button {
    filter: none !important;
    transition: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* Các fieldset */
fieldset {
    padding: 16px 12px !important;
    margin: 0 0 16px 0 !important;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--surface);
    box-shadow: var(--shadow);
}

legend {
    font-size: 16px;
    font-weight: 700;
    padding: 0 8px;
    color: var(--primary);
}

/* VĐV Card (cho đồng diễn) */
.vdv-card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    background: var(--surface);
    box-shadow: var(--shadow);
}

.vdv-title {
    font-weight: 700;
    font-size: 18px;
    margin: 0 0 4px;
    color: var(--text-main);
}

/* Bố cục hàng */
.vdv-rowhead {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--g);
    margin-top: 12px;
}

.vdv-rowhead .label {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
    white-space: nowrap;
}

.vdv-rowhead .actions {
    display: flex !important;
    gap: 8px !important;
    flex-wrap: wrap;
}

/* Grid 2 cột */
.vdv-two {
    display: grid;
    grid-template-columns: minmax(200px, 2.6fr) minmax(90px, 1fr);
    gap: var(--g);
    margin-top: 8px;
}

/* Inputs */
.vdv-input,
.ns-input {
    width: 100%;
    padding: 10px 12px !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px !important;
    font-family: inherit;
    transition: all 0.2s ease;
    background: var(--surface);
    color: var(--text-main);
}

.vdv-input:focus,
.ns-input:focus,
.vdv-input-for:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(15, 74, 138, 0.1);
}

.vdv-input-for {
    width: 100%;
    height: auto;
    min-height: 120px;
    padding: 10px 12px !important;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px !important;
    font-family: inherit;
    transition: all 0.2s ease;
    resize: vertical;
    line-height: 1.5;
    background: var(--surface);
}

.ns-input {
    text-align: center;
    letter-spacing: 0.5px;
}

.ns-input::-webkit-outer-spin-button,
.ns-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.ns-input[type="number"] {
    -moz-appearance: textfield;
}

.vdv-unitline {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 12px;
}

.vdv-unitline .label {
    white-space: nowrap;
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
}

.vdv-unitline .grow {
    flex: 1;
}

.vdv-grid-desktop {
    display: flex;
    gap: var(--g);
    margin-top: 8px;
}
.vdv-grid-desktop .input-col {
    flex: 1;
    position: relative;
}

.vdv-unit-email-phone {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: var(--g);
    margin-top: 12px;
}

/* Reponsive cho form */
@media (max-width:480px) {
    .vdv-two {
        grid-template-columns: 1fr;
    }

    .vdv-two.vdv-inline {
        grid-template-columns: 3fr 1.2fr !important;
    }

    .ns-input {
        max-width: 100%;
        justify-self: stretch !important;
    }

    fieldset {
        padding: 12px 8px !important;
    }
    
    .vdv-grid-desktop {
        flex-direction: column;
    }
    .vdv-unit-email-phone {
        grid-template-columns: 1fr;
    }
}

@media (min-width:560px) {
    .vdv-two {
        grid-template-columns: 3fr 1fr;
    }
}

@media (min-width:900px) {
    .vdv-card {
        padding: 20px;
    }
}

/* Danh sách chọn hạng (Nội dung) */
.grp {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    margin: 10px 0;
    background: var(--surface);
    overflow: hidden;
}

.grp-hd {
    cursor: pointer;
    padding: 6px 10px;
    background: var(--bg-color);
    user-select: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-main);
    font-weight: 600;
}

.grp-bd {
    display: none;
    padding: 12px 16px;
}

.grp.open .grp-bd {
    display: block;
    border-top: 1px solid var(--border);
}

.chev {
    transition: transform .2s ease;
}

.grp.open .chev {
    transform: rotate(90deg);
    color: var(--primary);
}

.grp-hd .count-badge {
    margin-left: 6px;
    color: var(--text-muted);
    font-size: 13px;
    font-weight: 500;
}

#frmDK .grp-bd ul.clean {
    list-style: none;
    padding-left: 0;
    margin: 0;
}

#frmDK .grp-bd li {
    margin: 8px 0;
}

#frmDK .grp-bd li label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    cursor: pointer;
    background: var(--bg-color);
    font-size: 12.5px;
}

#frmDK .grp-bd li:hover label {
    background: #e2e8f0;
    border-color: var(--border);
}

#frmDK .grp-bd li.selected label {
    background: var(--hl);
    border-color: var(--hl-b);
    box-shadow: 0 0 0 1px var(--hl-b) inset;
    color: var(--primary);
    font-weight: 500;
}

#frmDK .grp-bd input[type="checkbox"] {
    margin: 0 4px 0 0;
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

#frmDK .grp .grp-hd .pill {
    background: var(--hl);
    color: var(--primary);
    padding: 2px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

/* Modal VĐV / Create Private */
.vmodal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 9999 !important;
    background: rgba(15, 23, 42, 0.6) !important;
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
}

.vpanel {
    background: var(--surface) !important;
    color: var(--text-main) !important;
    border-radius: var(--radius);
    max-width: 600px;
    width: 95%;
    max-height: 85vh;
    overflow: auto;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.vpanel .modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-weight: 700;
    font-size: 18px;
    color: var(--primary);
}

.vtop {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.vtop input,
.vtop select {
    flex: 1;
    min-width: 140px;
}

#vdvList .vdv-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

#vdvList .vdv-item:last-child {
    border-bottom: none;
}

#vdvList .vdv-item .nm {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

#vdvList .pick-btn {
    margin-left: auto;
}

#vdvList button[data-pickvdv] {
    float: right;
    margin-left: 8px;
}

#vdvList::after {
    content: "";
    display: block;
    clear: both;
}

/* Giai Dropdown & Badge */
#giai_id option {
    white-space: normal;
}

.giai-selected {
    margin-top: 8px;
    padding: 12px 16px;
    background: var(--hl);
    border: 1px solid var(--hl-b);
    color: var(--primary);
    border-radius: var(--radius-sm);
    line-height: 1.4;
    white-space: normal;
    word-break: break-word;
    font-weight: 600;
}

.grp-hd.has-selection {
    background-color: var(--hl);
    color: var(--primary);
    font-weight: bold;
    border-left: 4px solid var(--primary);
}

/* Premium Card Layout */
.reg-card {
    background: #ffffff;
    border-radius: 16px;
    padding: 24px 20px !important;
    margin: 0 0 24px 0 !important;
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.08);
    border: 1px solid rgba(0, 0, 0, 0.04);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.reg-card:hover {
    box-shadow: 0 15px 35px -10px rgba(0, 0, 0, 0.12);
}

.reg-card-title {
    font-size: 18px;
    font-weight: 800;
    color: #1e293b;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 2px solid #f1f5f9;
    letter-spacing: 0.2px;
    display: inline-block;
}

/* Floating Submit Bar */
.floating-submit-bar {
    position: sticky;
    bottom: 20px;
    margin-top: 40px;
    z-index: 50;
    display: flex;
    justify-content: center;
    pointer-events: none;
    /* Let clicks pass through empty spaces */
}

.floating-submit-inner {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 12px 24px;
    border-radius: 16px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.4);
    display: flex;
    gap: 12px;
    align-items: center;
    pointer-events: auto;
    /* Re-enable clicks on the bar */
    animation: slideUpFade 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes slideUpFade {
    0% {
        opacity: 0;
        transform: translateY(40px);
    }

    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Smooth input styling */
.vdv-input,
.ns-input {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}

.vdv-input:focus,
.ns-input:focus {
    background: #ffffff;
    border-color: #3b82f6;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

/* Validation styles inline */
.err-inline {
    animation: shake 0.4s ease-in-out;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-4px);
    }

    75% {
        transform: translateX(4px);
    }
}