:root {
    --app-primary: #1677ff;
    --app-primary-hover: #4096ff;
    --app-danger: #ff4d4f;
    --app-ok: #52c41a;
    --app-border: #eaecef;
    --app-text: rgba(0, 0, 0, .88);
    --app-text-2: rgba(0, 0, 0, .55);
    --app-bg: #f5f6f8;
    --app-radius: 8px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    min-height: 100%;
    background: var(--app-bg);
    color: var(--app-text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.5;
}

a { color: var(--app-primary); text-decoration: none; }
a:hover { color: var(--app-primary-hover); }
code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; }

/* ---------- 布局（左侧栏与顶部固定，仅内容区滚动） ---------- */
.app-shell { display: block; min-height: 100vh; }

.app-side {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    width: 200px;
    overflow-y: auto;
    z-index: 110;
    background: #001529;
    color: #fff;
    display: flex;
    flex-direction: column;
}

.app-logo {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-nav { padding: 12px 0; flex: 1; }

.app-nav-item {
    display: block;
    padding: 10px 20px;
    color: rgba(255, 255, 255, .72);
    font-size: 14px;
    transition: all .2s;
}
.app-nav-item:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.app-nav-item.is-active { color: #fff; background: var(--app-primary); }

.app-side-foot {
    padding: 14px 20px;
    font-size: 12px;
    color: rgba(255, 255, 255, .35);
    border-top: 1px solid rgba(255, 255, 255, .08);
}

.app-main { margin-left: 200px; min-width: 0; min-height: 100vh; display: flex; flex-direction: column; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 56px;
    background: #fff;
    border-bottom: 1px solid var(--app-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
}
.app-header-title { font-size: 16px; font-weight: 600; }

/* 右上角用户下拉（antd dropdown / avatar 原生结构） */
.app-user-trigger {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 6px;
    border-radius: 6px;
    cursor: pointer;
    color: var(--app-text);
    transition: background .2s;
    user-select: none;
}
.app-user-trigger:hover { background: #f5f5f5; }
.app-user-trigger .anticon { font-size: 10px; color: var(--app-text-2); transition: transform .2s; }
.app-user-trigger[aria-expanded="true"] .anticon { transform: rotate(180deg); }
.app-user-dropdown .ant-dropdown-menu-item { cursor: pointer; }
.app-user-dropdown { z-index: 1050; padding-top: 0; } /* 无箭头，去掉 antd 预留的 padding-top */
.app-user-dropdown .ant-dropdown-menu-item a { display: block; }
.app-logout { color: var(--app-danger); }

.app-content { padding: 24px; flex: 1; }

/* ---------- 卡片 / 面板 ---------- */
.app-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
@media (max-width: 1100px) { .app-cards { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 640px) { .app-cards { grid-template-columns: 1fr; } }

.app-card {
    background: #fff;
    border-radius: var(--app-radius);
    padding: 18px 20px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
}
.app-card-label { color: var(--app-text-2); font-size: 13px; }
.app-card-value { font-size: 26px; font-weight: 600; margin: 6px 0; }
.app-card-value-sm { font-size: 15px; word-break: break-all; }
.app-card-foot { color: var(--app-text-2); font-size: 12px; }

.app-panel {
    background: #fff;
    border-radius: var(--app-radius);
    box-shadow: 0 1px 2px rgba(0, 0, 0, .04);
    margin-bottom: 20px;
    overflow: hidden;
}
.app-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--app-border);
    font-weight: 600;
}
.app-panel-body { padding: 20px; }

/* ---------- 表格 ---------- */
.app-table-wrap { overflow-x: auto; }
.app-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.app-table th, .app-table td {
    padding: 11px 14px;
    text-align: left;
    border-bottom: 1px solid var(--app-border);
    vertical-align: middle;
}
.app-table thead th { background: #fafafa; color: var(--app-text-2); font-weight: 500; white-space: nowrap; }
.app-table tbody tr:hover { background: #fafcff; }
.app-td-label { color: var(--app-text-2); width: 160px; }
/* 表格内空状态：覆盖 .app-table td 的 text-align:left，保证水平居中 */
.app-table .app-empty { text-align: center; }
.app-empty { text-align: center; color: var(--app-text-2); padding: 28px 0 !important; }
.app-row-detail td { background: #fff5f5; }
.app-detail { color: var(--app-danger); font-size: 12px; word-break: break-all; }
.app-col-op { white-space: nowrap; }
/* 状态列：徽标文字不换行、不被挤压 */
.app-col-status { white-space: nowrap; }
/* 操作列按钮组（antd 原生按钮） */
.app-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.app-actions-form { margin: 0; display: inline-flex; }
.app-ellipsis { max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-nowrap { white-space: nowrap; }
.app-center { text-align: center; }

/* ---------- 徽标 / 标签 ---------- */
.app-badge {
    display: inline-block;
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    background: #f0f0f0;
    color: var(--app-text-2);
    line-height: 18px;
    white-space: nowrap;
}
.app-badge-ok { background: #f6ffed; color: var(--app-ok); border: 1px solid #b7eb8f; }
.app-badge-fail { background: #fff1f0; color: var(--app-danger); border: 1px solid #ffa39e; }
.app-badge-info { background: #e6f4ff; color: var(--app-primary); border: 1px solid #91caff; }
.app-badge-off { background: #fafafa; color: var(--app-text-2); border: 1px solid #d9d9d9; }
.app-tag { display: inline-block; padding: 0 6px; border-radius: 4px; background: #f5f5f5; color: var(--app-text-2); font-size: 12px; }

/* ---------- 按钮 ---------- */
.app-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    height: 32px;
    padding: 0 15px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    background: #fff;
    color: var(--app-text);
    font-size: 14px;
    cursor: pointer;
    transition: all .2s;
    white-space: nowrap;
}
.app-btn:hover { border-color: var(--app-primary); color: var(--app-primary); }
.app-btn-primary { background: var(--app-primary); border-color: var(--app-primary); color: #fff; }
.app-btn-primary:hover { background: var(--app-primary-hover); border-color: var(--app-primary-hover); color: #fff; }
.app-btn-danger { background: var(--app-danger); border-color: var(--app-danger); color: #fff; }
.app-btn-danger:hover { background: #ff7875; border-color: #ff7875; color: #fff; }
.app-btn-sm { height: 28px; padding: 0 11px; font-size: 13px; }
.app-btn-block { width: 100%; height: 40px; font-size: 15px; }

.app-link {
    border: 0;
    background: none;
    color: var(--app-primary);
    cursor: pointer;
    padding: 0;
    font-size: 13px;
    font-family: inherit;
}
.app-link:hover { color: var(--app-primary-hover); }
.app-link-danger { color: var(--app-danger); }
.app-link-danger:hover { color: #ff7875; }
.app-inline { display: inline; margin: 0 0 0 10px; }
.app-inline:first-child { margin-left: 0; }

/* ---------- 表单 ---------- */
.app-field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 16px; }
.app-field > label { color: var(--app-text); font-size: 13px; }
.app-field > label i { color: var(--app-danger); font-style: normal; }
.app-field input[type=text], .app-field input[type=password], .app-field input[type=number],
.app-field input[type=date], .app-field input[type=file], .app-field select, .app-field textarea {
    width: 100%;
    padding: 6px 11px;
    border: 1px solid #d9d9d9;
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    color: var(--app-text);
    background: #fff;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.app-field input:focus, .app-field select:focus, .app-field textarea:focus {
    border-color: var(--app-primary);
    box-shadow: 0 0 0 2px rgba(22, 119, 255, .1);
}
.app-field textarea { resize: vertical; min-height: 120px; }
.app-help { color: var(--app-text-2); font-size: 12px; }

.app-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0 20px; }
.app-grid .app-field-full { grid-column: 1 / -1; }
@media (max-width: 720px) { .app-grid { grid-template-columns: 1fr; } }

.app-field-check { justify-content: flex-end; }
.app-check { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.app-check input { width: auto; }

.app-form-foot { display: flex; gap: 12px; padding-top: 4px; }

/* 筛选条：查询/重置按钮与输入框同行同高对齐（按钮字段用隐藏 label 占位） */
.app-filter { display: flex; flex-wrap: wrap; gap: 12px; align-items: stretch; }
.app-filter .app-field { margin-bottom: 0; flex: 1 1 170px; min-width: 0; }
.app-filter .app-field-btn { flex: 0 0 auto; }
.app-filter .app-field-btn > label { visibility: hidden; }
.app-field-btn-group { display: flex; gap: 8px; }
.app-field-btn-group .app-btn { margin: 0; }

/* ---------- 分页（antd 原生 .ant-pagination） ---------- */
.app-pager { display: flex; align-items: center; justify-content: flex-end; gap: 12px; padding: 14px 20px; }
.app-pager-info { color: var(--app-text-2); font-size: 13px; }
/* 全局 a 颜色会覆盖 antd，这里按 antd 原生还原 prev/next/jump 的配色与交互反馈 */
.ant-pagination-prev .ant-pagination-item-link,
.ant-pagination-next .ant-pagination-item-link,
.ant-pagination-jump-prev .ant-pagination-item-link,
.ant-pagination-jump-next .ant-pagination-item-link { color: rgba(0, 0, 0, .85); }
.ant-pagination-prev:hover .ant-pagination-item-link,
.ant-pagination-next:hover .ant-pagination-item-link { color: #1890ff; }
.ant-pagination-disabled .ant-pagination-item-link,
.ant-pagination-disabled:hover .ant-pagination-item-link { color: rgba(0, 0, 0, .25); }
/* 省略号占位项：垂直居中，且 hover 时保持省略号可见（未渲染跳页图标） */
.ant-pagination-jump-prev .ant-pagination-item-ellipsis,
.ant-pagination-jump-next .ant-pagination-item-ellipsis { line-height: 30px; }
.ant-pagination-jump-prev:hover .ant-pagination-item-ellipsis,
.ant-pagination-jump-next:hover .ant-pagination-item-ellipsis { opacity: 1; }

/* ---------- 提示 ---------- */
.app-alert {
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 16px;
    font-size: 14px;
    border: 1px solid transparent;
}
.app-alert-success { background: #f6ffed; border-color: #b7eb8f; color: #389e0d; }
.app-alert-error { background: #fff1f0; border-color: #ffa39e; color: #cf1322; }

.app-tip {
    color: var(--app-text-2);
    font-size: 13px;
    padding: 12px 20px;
    background: #fff;
    border-radius: var(--app-radius);
    margin-bottom: 20px;
}
.app-tip code, .app-inline-code {
    padding: 1px 6px;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 13px;
    word-break: break-all;
}

/* ---------- 键值展示 ---------- */
.app-kv { display: flex; padding: 8px 0; border-bottom: 1px dashed var(--app-border); align-items: center; gap: 12px; }
.app-kv:last-child { border-bottom: 0; }
.app-kv-label { width: 90px; color: var(--app-text-2); flex: 0 0 90px; }
.app-kv-value { flex: 1; display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

/* ---------- 代码块 ---------- */
.app-code-wrap { position: relative; }
.app-code {
    margin: 0;
    padding: 14px 16px;
    background: #0d1117;
    color: #e6edf3;
    border-radius: 6px;
    font-size: 13px;
    line-height: 1.6;
    overflow-x: auto;
    white-space: pre;
}
.app-code-copy { position: absolute; top: 8px; right: 8px; z-index: 2; }

/* ---------- 登录页 ---------- */
.app-guest { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.app-login { width: 100%; max-width: 380px; }
.app-login-card {
    background: #fff;
    border-radius: 12px;
    padding: 32px 28px;
    box-shadow: 0 6px 30px rgba(0, 0, 0, .08);
}
.app-login-title { margin: 0 0 4px; font-size: 20px; text-align: center; }
.app-login-sub { margin: 0 0 22px; text-align: center; color: var(--app-text-2); font-size: 13px; }

.app-404-title { font-size: 44px; margin: 0 0 6px; }

/* ---------- 移动端自适应 ---------- */
/* 侧栏抽屉遮罩与菜单按钮（桌面端隐藏） */
.app-side-mask {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 108;
    background: rgba(0, 0, 0, .45);
}
.app-menu-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    margin-right: 8px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--app-text);
    font-size: 18px;
    cursor: pointer;
    transition: background .2s;
}
.app-menu-toggle:hover { background: #f5f5f5; }

@media (max-width: 768px) {
    /* 侧栏改为左侧抽屉 */
    .app-side {
        transform: translateX(-100%);
        transition: transform .2s;
        z-index: 109;
    }
    .app-side.is-open { transform: none; }
    .app-side-mask.is-open { display: block; }

    .app-main { margin-left: 0; }

    .app-header { padding: 0 12px; }
    .app-menu-toggle { display: inline-flex; }
    .app-header-title { flex: 1; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .app-user-trigger { gap: 6px; padding: 4px; }
    .app-user { display: inline-block; max-width: 96px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    .app-content { padding: 12px; }
    .app-panel-head { flex-wrap: wrap; }
    .app-panel-body { padding: 14px; }
    .app-cards { margin-bottom: 12px; }
    .app-card { padding: 14px 16px; }

    /* 筛选条在手机上纵向堆叠、按钮等宽 */
    .app-filter .app-field,
    .app-filter .app-field-btn { flex: 1 1 100%; }
    .app-filter .app-field-btn > label { display: none; }
    .app-field-btn-group { width: 100%; }
    .app-field-btn-group .app-btn { flex: 1; }

    .app-pager { flex-wrap: wrap; justify-content: center; }
    /* 手机上缩小分页尺寸，避免溢出换行 */
    .ant-pagination-item,
    .ant-pagination-prev,
    .ant-pagination-next,
    .ant-pagination-jump-prev,
    .ant-pagination-jump-next { min-width: 28px; height: 28px; }
    .ant-pagination-item { line-height: 26px; }
    .ant-pagination-prev,
    .ant-pagination-next,
    .ant-pagination-jump-prev,
    .ant-pagination-jump-next { line-height: 28px; }
    .ant-pagination-item a { padding: 0 4px; }
    .ant-pagination-jump-prev .ant-pagination-item-ellipsis,
    .ant-pagination-jump-next .ant-pagination-item-ellipsis { line-height: 26px; }

    /* 键值列表纵向排列 */
    .app-kv { flex-direction: column; align-items: flex-start; gap: 4px; }
    .app-kv-label { flex: none; width: auto; }

    .app-ellipsis { max-width: 180px; }
    .app-td-label { width: auto; }
    .app-login-card { padding: 24px 18px; }

    /* 弹窗在手机上更贴合屏幕 */
    .ant-modal { top: 24px; max-width: calc(100vw - 16px); }
    .ant-modal-header { padding: 14px 16px; }
    .ant-modal-body { padding: 16px; }
    .ant-modal-close-x { width: 48px; height: 48px; line-height: 48px; }
}
