/* @doc 布局层：页面骨架、容器、页脚（四端共用） */

.tk-page {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.tk-page__head {
    position: sticky;
    top: 0;
    z-index: var(--z-nav);
    background: var(--c-card);
    border-bottom: 1px solid var(--c-line);
    padding: var(--sp-3) var(--sp-4);
    font-size: var(--fs-lg);
    font-weight: 600;
    text-align: center;
}

.tk-page__body {
    flex: 1;
    padding: var(--sp-4);
    padding-bottom: calc(var(--sp-6) + env(safe-area-inset-bottom));
}

/* 底部固定操作条（移动端主按钮） */
.tk-page__foot {
    padding: var(--sp-3) var(--sp-4);
    background: var(--c-card);
    border-top: 1px solid var(--c-line);
}

/* 官网内容作用域容器：🔴 自定义 HTML 必须包在此容器内，避免污染全站样式 */
.site-cms {
    display: block;
}

/* 全站统一页脚 */
.site-footer {
    background: transparent;
    border: 0;
    text-align: center;
    color: var(--c-text-weak);
    font-size: var(--fs-xs);
    line-height: 1.8;
    padding: var(--sp-4) var(--sp-4) calc(var(--sp-5) + env(safe-area-inset-bottom));
}

.site-footer__brand a {
    color: var(--c-text-weak);
}

/* 页脚：备案号与站点名称（🔴 由 layout/main.php 输出，必须有样式定义） */
.site-footer__icp,
.site-footer__name {
    color: var(--c-text-weak);
}

.site-footer__name {
    margin-bottom: var(--sp-1);
}

/* 断点：≥768px 内容居中，宽度受限，阅读更舒适 */
@media (min-width: 768px) {
    .tk-page__body {
        max-width: 720px;
        margin: 0 auto;
        width: 100%;
    }
}

/* 断点：≥1200px 后台最大宽 1200px 居中 */
@media (min-width: 1200px) {
    .tk-page__body {
        max-width: 1200px;
    }
}

/* ============================================================
   后台骨架（admin）：大屏容器 + 紧凑精致
   依据：约定/css样式文档.md §九（后台视觉规范）
        约定/布局与前端结构规范.md §1.2（后台骨架）
   🔴 与前台/操作员/业务员的 .tk-page（移动端骨架）分离，互不影响
   🔴 内容区 w-full，禁用 max-width 压窄（主站 §9.3 红线）
   ============================================================ */

.tk-admin {
    min-height: 100vh;
    padding-top: 56px;              /* 给固定顶栏留位 */
    background: var(--c-bg);
}

/* 顶栏：固定 56px，内边距与内容区左对齐 */
.tk-admin__topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: var(--z-nav);
    height: 56px;
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: 0 var(--sp-6);
    background: var(--c-card);
    border-bottom: 1px solid var(--c-line);
    box-shadow: var(--shadow-sm);
}

.tk-admin__burger {
    display: none;                  /* 桌面隐藏，<1024px 显示 */
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--c-line);
    border-radius: var(--r-btn);
    background: var(--c-card);
    color: var(--c-text-sub);
    cursor: pointer;
}

.tk-admin__brand {
    font-size: var(--fs-base);
    font-weight: 600;
    color: var(--c-text);
    white-space: nowrap;
}

.tk-admin__title {
    flex: 1;
    min-width: 0;
    font-size: var(--fs-sm);
    color: var(--c-text-sub);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tk-admin__user {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    font-size: var(--fs-sm);
    color: var(--c-text-sub);
    white-space: nowrap;
}

/* 主体：侧栏 + 内容区 */
.tk-admin__body {
    display: flex;
    align-items: flex-start;
}

/* 侧边栏：240px 固定，浅灰底 */
.tk-admin__side {
    position: sticky;
    top: 56px;
    flex: 0 0 240px;
    width: 240px;
    height: calc(100vh - 56px);
    overflow-y: auto;
    padding: var(--sp-3) var(--sp-2);
    background: var(--c-card);
    border-right: 1px solid var(--c-line);
}

/* 内容区：铺满剩余宽度；🔴 禁 max-width；内边距由此处统一提供 */
.tk-admin__main {
    flex: 1;
    min-width: 0;                   /* 🔴 防宽表格撑破布局 */
    width: 100%;
    padding: var(--sp-5) var(--sp-6);
}

/* 移动端遮罩（默认隐藏，JS 切换 .is-open） */
.tk-admin__mask {
    display: none;
}

/* 通用栅格：后台统计卡 / 表单双列（间距 4 的倍数） */
.tk-grid {
    display: grid;
    gap: var(--sp-4);
    margin-bottom: var(--sp-5);
}

.tk-grid--2 { grid-template-columns: repeat(2, 1fr); }
.tk-grid--3 { grid-template-columns: repeat(3, 1fr); }

/* 断点：<1024px 侧栏收成抽屉 */
@media (max-width: 1023px) {
    .tk-admin__topbar {
        padding: 0 var(--sp-4);
    }

    .tk-admin__burger {
        display: inline-flex;
    }

    .tk-admin__side {
        position: fixed;
        top: 56px;
        bottom: 0;
        left: 0;
        height: auto;
        transform: translateX(-100%);
        transition: transform .2s ease;
        z-index: var(--z-sheet);
    }

    .tk-admin.is-open .tk-admin__side {
        transform: translateX(0);
        box-shadow: 0 8px 24px rgba(17, 24, 39, .12);
    }

    /* 遮罩层级必须低于侧栏，否则会把抽屉盖住 */
    .tk-admin__mask {
        display: none;
        position: fixed;
        top: 56px;
        right: 0;
        bottom: 0;
        left: 0;
        background: rgba(17, 24, 39, .45);
        z-index: calc(var(--z-sheet) - 1);
    }

    .tk-admin.is-open .tk-admin__mask {
        display: block;
    }

    .tk-admin__main {
        padding: var(--sp-4);
    }
}

/* 断点：窄屏栅格降为单列 */
@media (max-width: 767px) {
    .tk-grid--2,
    .tk-grid--3 {
        grid-template-columns: 1fr;
    }
}

/* 后台内容区：区块（卡片）纵向间距 —— 紧凑档 24px
   依据：约定/css样式文档.md §9.6 分档表（区块之间 紧凑档 mb-6）
   🔴 只作用于后台，不影响前台/操作员/业务员端 */
.tk-admin__main .tk-card + .tk-card,
.tk-admin__main .tk-grid + .tk-card,
.tk-admin__main .tk-card + .tk-grid {
    margin-top: var(--sp-6);
}
