* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f4f5f7;
    color: #1f2329;
}

a {
    color: #ff2d7a;
    text-decoration: none;
}

/* ---------- 登录页 ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #fff0f6 0%, #f4f5f7 55%, #eef1f6 100%);
}

.login-card {
    width: 380px;
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px 32px;
    box-shadow: 0 12px 40px rgba(31, 35, 41, 0.1);
}

.login-logo {
    width: 56px;
    height: 56px;
    border-radius: 14px;
    background: linear-gradient(135deg, #ff5f9e, #ff2d7a);
    color: #fff;
    font-size: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.login-title {
    font-size: 22px;
    font-weight: 700;
    margin-bottom: 6px;
}

.login-sub {
    font-size: 13px;
    color: #8a8f99;
    margin-bottom: 26px;
}

.field {
    margin-bottom: 16px;
}

.field label {
    display: block;
    font-size: 13px;
    color: #4e5259;
    margin-bottom: 8px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    height: 42px;
    border: 1px solid #dfe2e8;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    outline: none;
    background: #fff;
    font-family: inherit;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: #ff2d7a;
    box-shadow: 0 0 0 3px rgba(255, 45, 122, 0.12);
}

.btn-primary {
    width: 100%;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #ff5f9e, #ff2d7a);
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    margin-top: 8px;
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-tip {
    margin-top: 18px;
    font-size: 12px;
    color: #8a8f99;
    line-height: 1.7;
    background: #f8f9fb;
    border-radius: 10px;
    padding: 12px 14px;
}

.form-error {
    color: #e0364c;
    font-size: 13px;
    min-height: 18px;
    margin-bottom: 4px;
}

/* ---------- 后台布局 ---------- */
.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 210px;
    background: #1f2430;
    color: #c8cdd8;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 22px 20px;
    color: #fff;
    font-weight: 700;
    font-size: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: linear-gradient(135deg, #ff5f9e, #ff2d7a);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.nav {
    padding: 14px 10px;
    flex: 1;
}

.nav-item {
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(255, 45, 122, 0.9), rgba(255, 95, 158, 0.75));
    color: #fff;
}

/* 动态二级菜单 */
.nav-loading {
    padding: 11px 14px;
    font-size: 13px;
    color: #7c8494;
}

.nav-icon {
    width: 18px;
    text-align: center;
    font-size: 15px;
    flex-shrink: 0;
}

.nav-text {
    flex: 1;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.nav-group {
    margin-bottom: 2px;
}

.nav-group-title {
    padding: 11px 14px;
    border-radius: 9px;
    font-size: 13px;
    color: #9aa3b2;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    user-select: none;
}

.nav-group-title:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-group-title .caret {
    font-size: 11px;
    transition: transform 0.18s ease;
}

.nav-group.collapsed .caret {
    transform: rotate(-90deg);
}

.nav-children {
    overflow: hidden;
}

.nav-group.collapsed .nav-children {
    display: none;
}

.nav-children .nav-item {
    padding-left: 38px;
    font-size: 13.5px;
}

.role-tag {
    font-size: 12px;
    color: #ff2d7a;
    background: #fff0f6;
    border-radius: 999px;
    padding: 3px 10px;
}

.tree-indent {
    color: #c3c8d0;
    margin-right: 6px;
}

.menu-icon {
    font-size: 15px;
}

/* 角色权限勾选树 */
.perm-tree {
    max-height: 320px;
    overflow-y: auto;
    border: 1px solid #e6e8ee;
    border-radius: 10px;
    padding: 10px 12px;
    background: #fafbfc;
}

.perm-block {
    padding: 4px 0;
    border-bottom: 1px dashed #edeff3;
}

.perm-block:last-child {
    border-bottom: none;
}

.perm-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    padding: 5px 2px;
    cursor: pointer;
    color: #1f2329;
}

.perm-item.child {
    padding-left: 22px;
    color: #4e5259;
}

.perm-item.perm-group {
    font-weight: 600;
    cursor: default;
    color: #1f2329;
}

.perm-item input[type="checkbox"] {
    width: 15px;
    height: 15px;
    accent-color: #ff2d7a;
}

.perm-code {
    font-size: 11px;
    color: #9aa0a8;
    background: #eef0f4;
    border-radius: 4px;
    padding: 1px 5px;
}

.check-line {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    color: #4e5259;
}

.check-line input {
    width: 16px;
    height: 16px;
    accent-color: #ff2d7a;
}

.modal-sm {
    width: 380px;
}

code {
    font-family: "SFMono-Regular", Menlo, Consolas, monospace;
}

.sidebar-foot {
    padding: 16px 20px;
    font-size: 12px;
    color: #7c8494;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.main {
    flex: 1;
    min-width: 0;
}

.topbar {
    height: 62px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 26px;
    border-bottom: 1px solid #ebedf1;
    position: sticky;
    top: 0;
    z-index: 5;
}

.page-title {
    font-size: 17px;
    font-weight: 700;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: #4e5259;
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #fff0f6;
    color: #ff2d7a;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}

.link-btn {
    background: none;
    border: 1px solid #dfe2e8;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: 13px;
    color: #4e5259;
    cursor: pointer;
}

.link-btn:hover {
    border-color: #ff2d7a;
    color: #ff2d7a;
}

.content {
    padding: 22px 26px 40px;
}

.pane {
    display: none;
}

.pane.active {
    display: block;
}

/* ---------- 卡片与表格 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px 20px;
    border: 1px solid #eef0f4;
}

.stat-label {
    font-size: 13px;
    color: #8a8f99;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 26px;
    font-weight: 700;
}

.stat-value.accent {
    color: #ff2d7a;
}

.card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #eef0f4;
    overflow: hidden;
    margin-bottom: 18px;
}

.card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid #f0f2f5;
    gap: 12px;
    flex-wrap: wrap;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
}

.toolbar {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.toolbar input,
.toolbar select {
    height: 36px;
    border: 1px solid #dfe2e8;
    border-radius: 9px;
    padding: 0 12px;
    font-size: 13px;
    outline: none;
}

.btn {
    height: 36px;
    padding: 0 16px;
    border-radius: 9px;
    border: 1px solid #dfe2e8;
    background: #fff;
    font-size: 13px;
    cursor: pointer;
    color: #1f2329;
}

.btn:hover {
    border-color: #ff2d7a;
    color: #ff2d7a;
}

.btn-pink {
    background: linear-gradient(90deg, #ff5f9e, #ff2d7a);
    border: none;
    color: #fff;
}

.btn-pink:hover {
    color: #fff;
    opacity: 0.92;
}

.btn-sm {
    height: 28px;
    padding: 0 10px;
    font-size: 12px;
    border-radius: 7px;
}

.btn-danger {
    color: #e0364c;
    border-color: #f6d3d8;
}

.btn-danger:hover {
    color: #e0364c;
    border-color: #e0364c;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th {
    text-align: left;
    font-weight: 600;
    color: #6b7280;
    background: #fafbfc;
    padding: 11px 16px;
    white-space: nowrap;
}

td {
    padding: 12px 16px;
    border-top: 1px solid #f2f4f7;
    vertical-align: middle;
}

tr:hover td {
    background: #fcfcfd;
}

.thumb {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.cell-title {
    font-weight: 600;
    line-height: 1.4;
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cell-sub {
    color: #8a8f99;
    font-size: 12px;
    margin-top: 3px;
}

.price {
    color: #ff2d7a;
    font-weight: 700;
}

.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    background: #f0f2f5;
    color: #4e5259;
}

.badge.on {
    background: #e8f8ef;
    color: #1a9c5b;
}

.badge.off {
    background: #f0f2f5;
    color: #8a8f99;
}

.badge.pending {
    background: #fff4e5;
    color: #c97a00;
}

.badge.done {
    background: #e8f8ef;
    color: #1a9c5b;
}

.badge.cancel {
    background: #fdecee;
    color: #e0364c;
}

.row-actions {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
}

.empty {
    padding: 46px 0;
    text-align: center;
    color: #9aa0aa;
    font-size: 13px;
}

/* ---------- 弹窗 ---------- */
.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(15, 20, 30, 0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 50;
}

.modal-mask.show {
    display: flex;
}

.modal {
    width: 560px;
    background: #fff;
    border-radius: 16px;
    padding: 24px 26px;
    max-height: 86vh;
    overflow-y: auto;
}

.modal h3 {
    margin: 0 0 18px;
    font-size: 17px;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px 16px;
}

.form-grid .full {
    grid-column: 1 / -1;
}

.modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 22px;
}

.toast {
    position: fixed;
    top: 22px;
    left: 50%;
    transform: translateX(-50%);
    background: #1f2430;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.22s ease;
    z-index: 99;
}

.toast.show {
    opacity: 1;
}

/* 分页条 */
.pager {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 14px 18px;
    border-top: 1px solid #eef0f4;
}

.pager-info {
    font-size: 13px;
    color: #6b7280;
}

.pager .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ---------- 设备二维码 ---------- */
.qr-tip {
    padding: 10px 20px;
    font-size: 12.5px;
    color: #6b7280;
    background: #fafbfc;
    border-bottom: 1px solid #f0f2f5;
    line-height: 1.7;
}

.qr-tip code {
    background: #eef0f4;
    border-radius: 4px;
    padding: 1px 5px;
    color: #ff2d7a;
}

.qr-thumb {
    width: 46px;
    height: 46px;
    border-radius: 8px;
    border: 1px solid #eef0f4;
    background: #fff;
    display: block;
}

.qr-preview {
    text-align: center;
    padding: 6px 0 14px;
}

.qr-preview img {
    width: 220px;
    height: 220px;
    border-radius: 12px;
    border: 1px solid #eef0f4;
    background: #fff;
}

.qr-view-no {
    margin-top: 10px;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.qr-view-meta {
    font-size: 12.5px;
    color: #8a8f99;
    margin-top: 4px;
}

/* ---------- H5 移动端适配 ---------- */
.menu-toggle {
    display: none;
}

@media (max-width: 768px) {
    /* 汉堡按钮 */
    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        flex-shrink: 0;
        border: 1px solid #dfe2e8;
        border-radius: 9px;
        background: #fff;
        font-size: 17px;
        color: #4e5259;
        cursor: pointer;
        margin-right: 10px;
        padding: 0;
    }

    /* 侧边栏改为抽屉 */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 250px;
        max-width: 78vw;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 60;
    }

    body.nav-open .sidebar {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.28);
    }

    .sidebar-mask {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(15, 20, 30, 0.45);
        z-index: 55;
    }

    body.nav-open .sidebar-mask {
        display: block;
    }

    .nav {
        overflow-y: auto;
    }

    /* 顶栏精简 */
    .topbar {
        height: 54px;
        padding: 0 14px;
    }

    .page-title {
        font-size: 16px;
    }

    #adminName,
    #roleTag {
        display: none;
    }

    .topbar-right {
        gap: 10px;
    }

    /* 内容区 */
    .content {
        padding: 14px 12px 32px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .stat-card {
        padding: 14px 16px;
        border-radius: 12px;
    }

    .stat-value {
        font-size: 22px;
    }

    /* 表格横向滑动 */
    .card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .card table {
        min-width: 620px;
    }

    .card-head {
        padding: 12px 14px;
    }

    th,
    td {
        padding: 10px 12px;
    }

    .cell-title {
        max-width: 220px;
    }

    .toolbar input,
    .toolbar select {
        flex: 1;
        min-width: 0;
        height: 34px;
    }

    .row-actions {
        flex-wrap: wrap;
    }

    .thumb {
        width: 40px;
        height: 40px;
    }

    /* 弹窗与表单 */
    .modal,
    .modal-sm {
        width: 92vw;
        max-width: 560px;
        max-height: 88vh;
        padding: 20px 16px;
        border-radius: 14px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    /* 登录页 */
    .login-card {
        width: 92vw;
        max-width: 380px;
        padding: 28px 22px 24px;
    }

    /* 分页 */
    .pager {
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        padding: 12px 10px;
    }

    .pager .btn {
        height: 34px;
    }
}

/* 超小屏（iPhone SE 等） */
@media (max-width: 380px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px 18px 20px;
    }
}
