:root {
    --zmath-primary: #5F86A6;
    --zmath-text: #2E333A;
    --zmath-accent: #8FB6D8;
    --zmath-bg: #EDF4FA;
    --zmath-line: #CFE3F1;
    --zmath-white: #ffffff;
    --zmath-muted: #6b7785;
    --zmath-danger: #d45555;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html {
    scrollbar-gutter: stable;
}

html, body.zmath-body {
    min-height: 100%;
}

body.zmath-body {
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    color: var(--zmath-text);
    background: var(--zmath-bg);
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.zmath-main {
    flex: 1;
    width: 100%;
    max-width: 1120px;
    margin: 0 auto;
    padding: 24px 20px 24px;
}

.zmath-header {
    background: var(--zmath-white);
    border-bottom: 1px solid var(--zmath-line);
    position: sticky;
    top: 0;
    z-index: 20;
}

.zmath-header-inner {
    max-width: 1120px;
    margin: 0 auto;
    height: 64px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.zmath-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--zmath-text);
    font-weight: 600;
    font-size: 16px;
}

.zmath-brand img {
    width: 40px;
    height: 40px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
}

.zmath-header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.zmath-user {
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: var(--zmath-text);
    font-size: 14px;
}

.zmath-user img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--zmath-line);
}

.zmath-logout,
.zmath-login-link,
.zmath-backend {
    font-size: 14px;
    color: var(--zmath-primary);
    text-decoration: none;
    cursor: pointer;
}

.zmath-footer {
    background: var(--zmath-white);
    border-top: 1px solid var(--zmath-line);
    padding: 20px 20px;
    text-align: center;
}

.zmath-footer-inner {
    max-width: 720px;
    margin: 0 auto;
}

.zmath-footer h2 {
    font-size: 18px;
    font-weight: 600;
    color: var(--zmath-primary);
    margin-bottom: 12px;
}

.zmath-footer p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--zmath-muted);
}

.zmath-icp {
    display: inline-block;
    margin-top: 16px;
    font-size: 12px;
    color: var(--zmath-muted);
    text-decoration: none;
}

.zmath-page-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
}

.zmath-empty {
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 12px;
    padding: 48px 20px;
    text-align: center;
    color: var(--zmath-muted);
}

.zmath-course-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.zmath-course-card {
    display: flex;
    gap: 16px;
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 12px;
    padding: 16px;
    text-decoration: none;
    color: inherit;
}

.zmath-course-cover {
    width: 180px;
    flex-shrink: 0;
    border-radius: 8px;
    overflow: hidden;
    background: var(--zmath-line);
}

.zmath-course-cover img {
    width: 100%;
    height: 110px;
    object-fit: cover;
    display: block;
}

.zmath-course-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.zmath-course-name {
    font-size: 18px;
    font-weight: 600;
}

.zmath-course-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
    font-size: 13px;
    color: var(--zmath-muted);
}

.zmath-tag {
    background: var(--zmath-bg);
    color: var(--zmath-primary);
    border-radius: 4px;
    padding: 2px 8px;
}

.zmath-course-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.zmath-progress {
    flex: 1;
    min-width: 140px;
    height: 8px;
    background: var(--zmath-line);
    border-radius: 4px;
    overflow: hidden;
}

.zmath-progress span {
    display: block;
    height: 100%;
    background: var(--zmath-primary);
}

.zmath-course-action {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: var(--zmath-muted);
}

.zmath-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 36px;
    padding: 0 16px;
    border: none;
    border-radius: 8px;
    background: var(--zmath-primary);
    color: var(--zmath-white);
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
}

.zmath-btn:hover { background: #4e7391; }

.zmath-pager {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.zmath-pager a,
.zmath-pager span {
    padding: 10px 15px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    border: 1px solid var(--zmath-line);
    background: var(--zmath-white);
    color: var(--zmath-text);
    text-decoration: none;
    font-size: 14px;
    line-height: 1;
}

.zmath-pager .is-active {
    background: var(--zmath-primary);
    border-color: var(--zmath-primary);
    color: #fff;
}

.zmath-card {
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 12px;
    padding: 24px;
    margin-bottom: 16px;
}

.zmath-card h2 {
    font-size: 18px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--zmath-line);
}

.zmath-field {
    margin-bottom: 16px;
}

.zmath-field label {
    display: block;
    font-size: 13px;
    color: var(--zmath-muted);
    margin-bottom: 6px;
}

.zmath-field input {
    width: 100%;
    height: 44px;
    border: 1px solid var(--zmath-line);
    border-radius: 8px;
    background: var(--zmath-bg);
    padding: 0 12px;
    font-size: 15px;
    color: var(--zmath-text);
    font-family: inherit;
}

.zmath-field input:focus {
    outline: none;
    border-color: var(--zmath-primary);
    background: #fff;
}

.zmath-select {
    position: relative;
}

.zmath-select-trigger {
    width: 100%;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border: 1px solid var(--zmath-line);
    border-radius: 8px;
    background: var(--zmath-bg);
    padding: 0 12px;
    font-size: 15px;
    color: var(--zmath-text);
    font-family: inherit;
    cursor: pointer;
    text-align: left;
}

.zmath-select-trigger:hover {
    border-color: var(--zmath-accent);
}

.zmath-select.is-open .zmath-select-trigger,
.zmath-select-trigger:focus {
    outline: none;
    border-color: var(--zmath-primary);
    background: #fff;
}

.zmath-select-value {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.zmath-select-value.is-placeholder {
    color: var(--zmath-muted);
}

.zmath-select-chevron {
    width: 18px;
    height: 18px;
    color: var(--zmath-muted);
    flex-shrink: 0;
    transition: transform 0.18s ease;
}

.zmath-select.is-open .zmath-select-chevron {
    transform: rotate(180deg);
    color: var(--zmath-primary);
}

.zmath-select-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    max-height: 280px;
    overflow: auto;
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 10px;
    box-shadow: 0 10px 28px rgba(46, 51, 58, 0.12);
    z-index: 30;
    padding: 8px;
}

.zmath-select-group + .zmath-select-group {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px solid var(--zmath-line);
}

.zmath-select-group-title {
    padding: 6px 10px 4px;
    font-size: 12px;
    color: var(--zmath-muted);
    letter-spacing: 0.02em;
}

.zmath-select-option {
    width: 100%;
    display: block;
    border: none;
    background: transparent;
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--zmath-text);
    font-family: inherit;
    cursor: pointer;
}

.zmath-select-option:hover {
    background: var(--zmath-bg);
    color: var(--zmath-primary);
}

.zmath-select-option.is-active {
    background: #E4EEF6;
    color: var(--zmath-primary);
    font-weight: 600;
}

.zmath-toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(-12px);
    background: rgba(46, 51, 58, 0.92);
    color: #fff;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.zmath-toast.is-show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.zmath-toast.is-error { background: var(--zmath-danger); }

.zmath-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-bottom: 16px;
    color: var(--zmath-primary);
    text-decoration: none;
    font-size: 14px;
}

.zmath-back svg {
    width: 18px;
    height: 18px;
}

.zmath-back:hover {
    color: #4e7391;
}

.zmath-terms h1 {
    font-size: 22px;
    font-weight: 600;
    margin-bottom: 8px;
}

.zmath-terms-meta {
    font-size: 13px;
    color: var(--zmath-muted);
    margin-bottom: 20px;
}

.zmath-terms h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 24px 0 10px;
    padding-bottom: 0;
    border-bottom: none;
}

.zmath-terms p {
    font-size: 14px;
    line-height: 1.8;
    color: var(--zmath-text);
    margin-bottom: 8px;
}

/* ===== zmath item（课程详情 / 报名） ===== */
.zmath-item-hero {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.zmath-item-cover {
    width: 280px;
    flex-shrink: 0;
    border-radius: 10px;
    overflow: hidden;
    background: var(--zmath-bg);
}

.zmath-item-cover img {
    width: 100%;
    height: 100%;
    min-height: 180px;
    object-fit: cover;
    display: block;
}

.zmath-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.zmath-item-title {
    font-size: 22px;
    font-weight: 600;
    line-height: 1.35;
}

.zmath-item-desc {
    font-size: 14px;
    line-height: 1.7;
    color: var(--zmath-muted);
}

.zmath-item-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    font-size: 13px;
    line-height: 1.4;
}

.zmath-item-meta .zmath-tag {
    font-size: 13px;
    padding: 2px 7px;
    font-weight: 400;
}

.zmath-item-price {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 4px;
}

.zmath-item-amount {
    font-size: 28px;
    font-weight: 700;
    color: var(--zmath-danger);
}

.zmath-item-org {
    font-size: 14px;
    color: var(--zmath-muted);
}

.zmath-item-actions {
    margin-top: auto;
    padding-top: 8px;
}

.zmath-item-section-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 14px;
}

.zmath-collapse-item {
    border: 1px solid var(--zmath-line);
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 10px;
    background: #fff;
}

.zmath-collapse-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    cursor: pointer;
    font-size: 15px;
    font-weight: 600;
    background: var(--zmath-bg);
}

.zmath-collapse-toggle {
    font-size: 13px;
    font-weight: 400;
    color: var(--zmath-primary);
}

.zmath-collapse-body {
    display: none;
    padding: 6px 0;
}

.zmath-lesson-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    font-size: 14px;
    border-top: 1px solid var(--zmath-line);
}

.zmath-lesson-row.is-lock {
    cursor: pointer;
    color: var(--zmath-muted);
}

.zmath-lesson-lock {
    font-size: 12px;
    color: var(--zmath-muted);
    border: 1px solid var(--zmath-line);
    border-radius: 4px;
    padding: 1px 6px;
}

.zmath-pay-mask {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20, 30, 40, 0.45);
    z-index: 1000;
}

.zmath-pay-mask.is-open,
.zmath-pay-modal.is-open,
.zmath-warn-modal.is-open {
    display: block;
}

.zmath-pay-modal,
.zmath-warn-modal {
    display: none;
    position: fixed;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: min(360px, calc(100vw - 32px));
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--zmath-line);
    padding: 24px 20px 20px;
    z-index: 1001;
    text-align: center;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.12);
}

.zmath-pay-close {
    position: absolute;
    right: 12px;
    top: 8px;
    border: 0;
    background: transparent;
    font-size: 24px;
    line-height: 1;
    color: #999;
    cursor: pointer;
}

.zmath-pay-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.zmath-pay-price {
    font-size: 22px;
    font-weight: 700;
    color: var(--zmath-danger);
    margin-bottom: 16px;
}

.zmath-pay-qr {
    width: 170px;
    height: 170px;
    margin: 0 auto 12px;
}

.zmath-pay-hint,
.zmath-pay-status,
.zmath-warn-text {
    font-size: 13px;
    color: var(--zmath-muted);
}

.zmath-warn-text {
    margin: 8px 0 20px;
    font-size: 15px;
    color: var(--zmath-text);
}

.zmath-warn-actions {
    display: flex;
    justify-content: center;
    gap: 12px;
}

.zmath-btn-ghost {
    background: #fff;
    color: var(--zmath-text);
    border: 1px solid var(--zmath-line);
}

.zmath-btn-ghost:hover {
    background: var(--zmath-bg);
}

@media (max-width: 768px) {
    .zmath-header-inner { height: 56px; padding: 0 12px; }
    .zmath-header-right { gap: 10px; }
    .zmath-brand span { font-size: 15px; }
    .zmath-user span:first-child { display: none; }
    .zmath-user span { max-width: 72px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .zmath-course-card { flex-direction: column; }
    .zmath-course-cover { width: 100%; }
    .zmath-course-cover img { height: 160px; }
    .zmath-main { padding: 16px 12px 24px; }
    .zmath-item-hero { flex-direction: column; }
    .zmath-item-cover { width: 100%; }
    .zmath-item-cover img { min-height: 160px; height: 160px; }
}

.zmath-with-side {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    width: 100%;
    gap: 20px;
    align-items: start;
}

.zmath-side {
    width: 180px;
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 12px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.zmath-side a {
    display: block;
    padding: 10px 12px;
    border-radius: 8px;
    color: var(--zmath-text);
    background: transparent;
    text-decoration: none;
    font-size: 15px;
}

.zmath-side a.is-active {
    background: var(--zmath-primary);
    color: #fff;
}

.zmath-side a:hover:not(.is-active) {
    background: var(--zmath-bg);
    color: var(--zmath-primary);
}

.zmath-with-side-main {
    min-width: 0;
    width: 100%;
}

body.zmath-is-admin .zmath-main {
    max-width: 1120px;
}

.zmath-admin-panel {
    background: var(--zmath-white);
    border: 1px solid var(--zmath-line);
    border-radius: 12px;
    padding: 20px;
    width: 100%;
    overflow-x: auto;
}

.zmath-admin-panel .to-flex,
.zmath-admin-panel .to-center-y {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.zmath-admin-panel .to-margin-b10 { margin-bottom: 10px; }
.zmath-admin-panel .to-margin-b15 { margin-bottom: 15px; }
.zmath-admin-panel .to-margin-b20 { margin-bottom: 20px; }
.zmath-admin-panel .to-margin-l10 { margin-left: 10px; }

.zmath-admin-panel .btn-primary {
    background: var(--zmath-primary);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 8px 16px;
    cursor: pointer;
}

.zmath-admin-link {
    color: var(--zmath-primary);
    text-decoration: none;
    font-size: 14px;
}

.zmath-admin-panel .pagination-comm { margin-top: 16px; }
.zmath-admin-panel .font-color { color: #606266; font-size: 13px; line-height: 1.6; }

.zmath-chapter-title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding-right: 12px;
    gap: 8px;
}

.zmath-pdf-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.zmath-admin-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.zmath-admin-search {
    flex: 1 1 220px;
    min-width: 0;
}

.zmath-admin-table-wrap {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 768px) {
    body.zmath-is-admin {
        overflow-x: hidden;
    }

    body.zmath-is-admin .zmath-main {
        padding: 12px 10px 20px;
        max-width: 100%;
    }

    .zmath-with-side {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .zmath-side {
        width: 100%;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: sticky;
        top: 56px;
        z-index: 16;
        padding: 6px;
        gap: 6px;
    }

    .zmath-side a {
        flex: 1 0 auto;
        text-align: center;
        padding: 8px 12px;
        font-size: 14px;
        white-space: nowrap;
    }

    .zmath-admin-panel {
        padding: 12px;
        border-radius: 10px;
        overflow-x: visible;
    }

    .zmath-admin-panel h2 {
        font-size: 16px !important;
        margin-bottom: 12px !important;
    }

    .zmath-admin-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .zmath-admin-toolbar .btn-primary,
    .zmath-admin-panel .btn-primary {
        width: 100%;
        text-align: center;
        padding: 10px 16px;
    }

    .zmath-admin-toolbar .zmath-admin-link {
        text-align: center;
        display: block;
        padding: 6px 0;
    }

    .zmath-admin-search {
        flex: 1 1 auto;
        width: 100%;
    }

    .zmath-admin-search .el-input {
        width: 100% !important;
        max-width: 100%;
        display: block;
    }

    .zmath-admin-panel .el-input,
    .zmath-admin-panel .el-select,
    .zmath-admin-panel .el-textarea,
    .zmath-admin-panel .el-input-group {
        width: 100% !important;
        max-width: 100%;
    }

    .zmath-admin-panel .el-select .el-input {
        width: 100% !important;
    }

    .zmath-admin-panel .el-form-item {
        margin-bottom: 14px;
    }

    .zmath-admin-panel .el-form-item__label {
        float: none !important;
        display: block;
        text-align: left !important;
        width: auto !important;
        line-height: 1.4;
        padding: 0 0 6px;
    }

    .zmath-admin-panel .el-form-item__content {
        margin-left: 0 !important;
        line-height: 1.4;
    }

    .zmath-admin-panel .el-radio-group {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .zmath-admin-panel .el-radio {
        margin-right: 0;
        white-space: normal;
    }

    .zmath-admin-panel .el-tabs__header {
        margin-bottom: 12px;
    }

    .zmath-admin-panel .el-tabs__nav-wrap {
        overflow-x: auto;
        overflow-y: hidden;
    }

    .zmath-admin-panel .el-tabs__nav-wrap::after {
        display: none;
    }

    .zmath-admin-panel .el-collapse-item__header {
        height: auto;
        line-height: 1.4;
        padding: 8px 0;
        white-space: normal;
    }

    .zmath-chapter-title {
        flex-wrap: wrap;
        padding-right: 0;
    }

    .zmath-chapter-title span:last-child {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }

    .zmath-pdf-row {
        flex-wrap: wrap;
    }

    .zmath-pdf-row .el-input {
        width: 100% !important;
    }

    .zmath-admin-table-wrap {
        margin: 0 -4px;
        padding-bottom: 4px;
    }

    .zmath-admin-table-wrap .el-table {
        min-width: 560px;
    }

    .zmath-admin-table-wrap.is-wide .el-table {
        min-width: 980px;
    }

    .zmath-admin-panel .el-table .cell {
        white-space: nowrap;
    }

    .zmath-admin-panel .el-table .el-button {
        margin: 2px 4px 2px 0;
        padding: 7px 10px;
    }

    .zmath-admin-panel .pagination-comm {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .zmath-admin-panel .el-pagination {
        white-space: nowrap;
        padding: 2px 0;
        text-align: left;
    }

    .zmath-admin-panel .el-pagination .el-pagination__total {
        display: none;
    }

    .zmath-admin-panel .el-pager li {
        min-width: 28px;
    }

    body.zmath-is-admin .el-dialog {
        width: 92vw !important;
        margin-top: 8vh !important;
    }

    body.zmath-is-admin .el-dialog__body {
        padding: 10px 14px 4px;
    }

    body.zmath-is-admin .el-dialog .el-form-item__label {
        float: none !important;
        display: block;
        text-align: left !important;
        width: auto !important;
        line-height: 1.4;
        padding: 0 0 6px;
    }

    body.zmath-is-admin .el-dialog .el-form-item__content {
        margin-left: 0 !important;
    }

    body.zmath-is-admin .el-dialog .el-input,
    body.zmath-is-admin .el-dialog .el-select {
        width: 100% !important;
    }

    body.zmath-is-admin .el-message-box {
        width: 90vw !important;
        max-width: 400px;
    }

    body.zmath-is-admin .el-select-dropdown {
        max-width: calc(100vw - 20px);
    }
}
