/* ===== 基础 ===== */
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: -apple-system, BlinkMacSystemFont, "Microsoft YaHei", "PingFang SC", sans-serif;
    background: #f5f7fa;
    color: #333;
    font-size: 14px;
    line-height: 1.6;
    padding: 20px;
}
a { color: #1890ff; text-decoration: none; }
a:hover { text-decoration: underline; }
.text-danger { color: #ff4d4f !important; }

.container { max-width: 1400px; margin: 0 auto; }
.container-wide { max-width: 1400px; margin: 0 auto; }

/* ===== 顶部栏 ===== */
.topbar {
    display: flex; justify-content: space-between; align-items: center;
    background: #fff; padding: 12px 20px; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06); margin-bottom: 16px;
    flex-wrap: wrap; gap: 10px;
}
.topbar-left .logo { font-weight: 600; font-size: 16px; color: #1890ff; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.topbar-right .user-info { color: #666; margin-right: 6px; }
.topbar-right .badge {
    display: inline-block; background: #1890ff; color: #fff;
    font-size: 11px; padding: 1px 6px; border-radius: 8px; margin-left: 4px;
}

/* ===== 头部 ===== */
.header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px; background: #fff; padding: 18px 24px;
    border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
    flex-wrap: wrap; gap: 12px;
}
.header h1 { font-size: 20px; margin: 0; font-weight: 600; }
.header .actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ===== 按钮 ===== */
.btn {
    display: inline-block; padding: 10px 20px; border: 1px solid #d9d9d9;
    background: #fff; border-radius: 6px; text-decoration: none; color: #333;
    cursor: pointer; font-size: 14px; transition: all .2s; line-height: 1.4;
    font-family: inherit;
}
.btn:hover { background: #f0f0f0; border-color: #bfbfbf; text-decoration: none; }
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; border-color: #40a9ff; }
.btn-danger { background: #ff4d4f; color: #fff; border-color: #ff4d4f; }
.btn-danger:hover { background: #ff7875; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 8px; }
.btn-sm { padding: 5px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ===== 搜索栏 ===== */
.search-bar {
    margin-bottom: 16px; display: flex; gap: 8px; align-items: center;
    background: #fff; padding: 14px 16px; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06); flex-wrap: wrap;
}
.search-bar input, .search-bar select {
    padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
    font-size: 14px; outline: none; font-family: inherit;
}
.search-bar input { flex: 1; min-width: 180px; }
.search-bar input:focus, .search-bar select:focus {
    border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,.1);
}

/* ===== 表格 ===== */
.table-wrap {
    background: #fff; border-radius: 8px; overflow-x: auto;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
table.list-table { width: 100%; border-collapse: collapse; min-width: 800px; }
table.list-table th, table.list-table td {
    padding: 12px 16px; text-align: left; border-bottom: 1px solid #f0f0f0;
    font-size: 14px; vertical-align: middle;
}
table.list-table th { background: #fafafa; font-weight: 600; color: #555; white-space: nowrap; }
table.list-table tr:last-child td { border-bottom: none; }
table.list-table tr:hover td { background: #fafcff; }
table.list-table .ops a { margin-right: 10px; white-space: nowrap; }
table.list-table .empty { text-align: center; color: #999; padding: 40px 0; }

/* ===== 分页 ===== */
.pagination { display: flex; justify-content: center; gap: 6px; margin-top: 20px; flex-wrap: wrap; align-items: center; }
.pagination a, .pagination span {
    padding: 6px 12px; border: 1px solid #d9d9d9; border-radius: 6px;
    background: #fff; color: #333; font-size: 13px;
}
.pagination a:hover { border-color: #1890ff; color: #1890ff; text-decoration: none; }
.pagination .active { background: #1890ff; color: #fff; border-color: #1890ff; }
.pagination > span:last-child { border: none; background: transparent; color: #999; }

/* ===== 标签 ===== */
.tag { display: inline-block; padding: 2px 10px; border-radius: 12px; font-size: 12px; line-height: 1.6; }
.tag-green { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.tag-gray  { background: #f5f5f5; color: #888; border: 1px solid #e0e0e0; }
.tag-orange{ background: #fff7e6; color: #d46b08; border: 1px solid #ffd591; }
.tag-red   { background: #fff1f0; color: #cf1322; border: 1px solid #ffccc7; }
.tag-blue  { background: #e6f7ff; color: #096dd9; border: 1px solid #91d5ff; }

/* ===== 表单 ===== */
.form-item { margin-bottom: 16px; }
.form-item label {
    display: block; font-size: 13px; color: #555;
    margin-bottom: 6px; font-weight: 500;
}
.form-item label .required { color: #ff4d4f; margin-left: 4px; }
.form-item input, .form-item select, .form-item textarea {
    width: 100%; padding: 8px 12px; border: 1px solid #d9d9d9;
    border-radius: 6px; font-size: 14px; outline: none;
    font-family: inherit; transition: all .2s;
}
.form-item input:focus, .form-item select:focus, .form-item textarea:focus {
    border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,.1);
}
.form-item input.error { border-color: #ff4d4f; }
.form-item .err-msg { color: #ff4d4f; font-size: 12px; margin-top: 4px; display: none; }
.form-item.has-error .err-msg { display: block; }
.form-item.has-error input { border-color: #ff4d4f; }

.form-actions {
    display: flex; gap: 8px; margin-top: 24px;
    padding-top: 20px; border-top: 1px solid #f0f0f0;
    position: sticky; bottom: 0; background: #fff;
}

/* ===== 创建/编辑页布局 ===== */
.create-layout { display: flex; gap: 20px; align-items: flex-start; }
.form-panel {
    width: 420px; flex-shrink: 0; background: #fff; padding: 24px;
    border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
    max-height: calc(100vh - 200px); overflow-y: auto;
}
.preview-panel {
    flex: 1; background: #fff; padding: 24px;
    border-radius: 8px; box-shadow: 0 1px 4px rgba(0,0,0,.06);
    max-height: calc(100vh - 200px); overflow-y: auto;
}
.preview-title {
    font-size: 14px; color: #999; margin-bottom: 16px;
    padding-bottom: 12px; border-bottom: 1px solid #f0f0f0;
}
.preview-content { font-size: 13px; line-height: 1.9; color: #333; }
.preview-content h2 { text-align: center; font-size: 17px; margin: 0 0 20px; }
.preview-content p { margin: 4px 0; }
.preview-content table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.preview-content th, .preview-content td {
    border: 1px solid #333; padding: 6px 8px; font-size: 12px;
}
.preview-content .sign-table td { border: none; padding: 4px 0; }

/* ===== 合同详情 ===== */
.contract-detail {
    background: #fff; padding: 40px 60px; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    font-size: 14px; line-height: 1.9;
}
.contract-detail h2 { text-align: center; font-size: 20px; margin: 0 0 24px; }
.contract-detail p { margin: 6px 0; }
.contract-detail table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.contract-detail th, .contract-detail td {
    border: 1px solid #333; padding: 8px 10px; font-size: 13px;
}
.contract-detail .sign-table td { border: none; padding: 6px 0; }

/* ===== 提示 ===== */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 16px; font-size: 14px; }
.alert-error   { background: #fff1f0; color: #cf1322; border: 1px solid #ffccc7; }
.alert-success { background: #f6ffed; color: #389e0d; border: 1px solid #b7eb8f; }
.alert-info    { background: #e6f7ff; color: #096dd9; border: 1px solid #91d5ff; }
.alert-warning { background: #fffbe6; color: #d46b08; border: 1px solid #ffe58f; }

/* ===== 登录/注册页 ===== */
body.auth-page {
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; padding: 20px; background: linear-gradient(135deg, #e6f7ff 0%, #f0f5ff 100%);
}
.auth-box {
    width: 100%; max-width: 420px; background: #fff; padding: 36px 32px;
    border-radius: 12px; box-shadow: 0 8px 40px rgba(0,0,0,.08);
}
.auth-box h1 { font-size: 22px; text-align: center; margin: 0 0 6px; color: #1890ff; }
.auth-box .auth-tip { text-align: center; color: #999; font-size: 13px; margin: 0 0 24px; }
.auth-footer { text-align: center; margin-top: 20px; color: #999; font-size: 13px; }

/* ===== 统计卡片 ===== */
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat-card {
    background: #fff; padding: 20px 24px; border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
}
.stat-card .num { font-size: 28px; font-weight: 600; color: #1890ff; margin: 6px 0 0; }
.stat-card .label { font-size: 13px; color: #999; }
.stat-card.warn .num { color: #faad14; }
.stat-card.danger .num { color: #ff4d4f; }

/* ===== 加载遮罩 ===== */
.loading-mask {
    position: fixed; inset: 0; background: rgba(0,0,0,.3);
    display: none; align-items: center; justify-content: center; z-index: 9999;
}
.loading-mask.show { display: flex; }
.loading-mask .spinner {
    width: 40px; height: 40px; border: 3px solid rgba(255,255,255,.3);
    border-top-color: #fff; border-radius: 50%; animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== 移动端 ===== */
@media (max-width: 900px) {
    .create-layout { flex-direction: column; }
    .form-panel { width: 100%; max-height: none; }
    .preview-panel { max-height: none; }
    .contract-detail { padding: 20px; }
    .header h1 { font-size: 17px; }
}
/* ===== 后台 Tab 导航 ===== */
.admin-tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    border-radius: 8px;
    padding: 6px;
    margin-bottom: 16px;
    box-shadow: 0 1px 4px rgba(0,0,0,.06);
    overflow-x: auto;
}
.admin-tabs a {
    display: inline-flex;
    align-items: center;
    padding: 8px 18px;
    border-radius: 6px;
    color: #555;
    font-size: 14px;
    text-decoration: none;
    white-space: nowrap;
    transition: all .2s;
}
.admin-tabs a:hover {
    background: #f0f7ff;
    color: #1890ff;
    text-decoration: none;
}
.admin-tabs a.active {
    background: #1890ff;
    color: #fff;
    font-weight: 500;
}
.admin-tabs a .tab-badge {
    display: inline-block;
    background: #ff4d4f;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    padding: 3px 6px;
    border-radius: 10px;
    margin-left: 6px;
    min-width: 18px;
    text-align: center;
}
.admin-tabs a.active .tab-badge {
    background: #fff;
    color: #ff4d4f;
}
