/* ================= 变量与重置 ================= */
:root {
    --primary-color: #2E8B57;
    --primary-hover: #257047;
    --bg-color: #F0F2F5;
    --sidebar-bg: #FFFFFF;
    --text-main: #333333;
    --text-sub: #8C8C8C;
    --danger: #F5222D;
    --warning: #FFB300;
    --border: #F0F0F0;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
body { background-color: var(--bg-color); color: var(--text-main); font-size: 14px; }
.hidden { display: none !important; }

/* ================= 登录页 ================= */
.login-page {
    position: fixed; inset: 0; z-index: 100;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #2E8B57 0%, #1f5c3a 100%);
}
.login-box {
    width: 360px; background: #fff; border-radius: 12px; padding: 40px 36px;
    box-shadow: 0 12px 40px rgba(0,0,0,.18);
}
.login-logo { font-size: 18px; font-weight: bold; color: var(--primary-color); margin-bottom: 26px; }
.login-logo span { background: var(--primary-color); color: #fff; padding: 2px 6px; border-radius: 4px; margin-right: 8px; font-size: 14px; }
.login-box h2 { font-size: 20px; margin-bottom: 6px; }
.login-sub { color: var(--text-sub); font-size: 13px; margin-bottom: 24px; }
.login-input {
    width: 100%; padding: 12px 14px; border: 1px solid #D9D9D9; border-radius: 8px;
    font-size: 14px; outline: none; margin-bottom: 14px; box-sizing: border-box;
}
.login-input:focus { border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(46,139,87,.1); }
.login-btn {
    width: 100%; padding: 12px; background: var(--primary-color); color: #fff; border: none;
    border-radius: 8px; font-size: 15px; font-weight: bold; cursor: pointer; margin-top: 6px;
}
.login-btn:hover { background: var(--primary-hover); }
.login-error { color: var(--danger); font-size: 13px; margin-top: 12px; min-height: 18px; text-align: center; }

/* ================= 框架 ================= */
.app { display: flex; height: 100vh; overflow: hidden; }
.sidebar {
    width: 220px; background: var(--sidebar-bg); border-right: 1px solid #E8E8E8;
    display: flex; flex-direction: column; flex-shrink: 0;
}
.logo {
    height: 60px; display: flex; align-items: center; padding-left: 22px; font-size: 17px;
    font-weight: bold; color: var(--primary-color); border-bottom: 1px solid #F0F0F0;
}
.logo span { background: var(--primary-color); color: #fff; padding: 2px 6px; border-radius: 4px; margin-right: 9px; font-size: 13px; }
.menu { flex: 1; padding: 14px 0; overflow-y: auto; }
.menu-item {
    padding: 11px 22px; display: flex; align-items: center; cursor: pointer; color: #595959;
    transition: all .25s; margin-bottom: 2px; font-size: 14px;
}
.menu-item:hover { color: var(--primary-color); background: #F6FFED; }
.menu-item.active { color: var(--primary-color); background: #E8F5E9; font-weight: bold; border-right: 3px solid var(--primary-color); }

.main-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.header {
    height: 60px; background: #fff; display: flex; justify-content: space-between; align-items: center;
    padding: 0 24px; border-bottom: 1px solid #E8E8E8; flex-shrink: 0;
}
.header-title { font-size: 16px; font-weight: bold; }
.user-info { display: flex; align-items: center; gap: 10px; font-size: 13px; color: #595959; }
.user-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--primary-color); color: #fff; display: inline-flex; align-items: center; justify-content: center; font-size: 13px; }
.logout { color: var(--primary-color); cursor: pointer; text-decoration: none; }
.content { flex: 1; padding: 22px; overflow-y: auto; }

/* ================= 卡片与表格 ================= */
.card { background: #fff; border-radius: 8px; padding: 22px; box-shadow: 0 1px 4px rgba(0,0,0,.04); margin-bottom: 22px; }
.card-title { font-size: 16px; font-weight: bold; margin-bottom: 18px; border-bottom: 1px solid var(--border); padding-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.card-desc { font-size: 13px; color: var(--text-sub); margin-bottom: 14px; margin-top: -8px; }

.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-card { background: #fff; border-radius: 8px; padding: 20px; box-shadow: 0 1px 4px rgba(0,0,0,.04); }
.stat-title { font-size: 13px; color: var(--text-sub); margin-bottom: 10px; }
.stat-value { font-size: 26px; font-weight: bold; }
.stat-trend { font-size: 12px; color: var(--primary-color); margin-top: 6px; }

.btn { padding: 8px 15px; border-radius: 6px; border: none; cursor: pointer; font-size: 13px; transition: all .2s; outline: none; }
.btn-primary { background: var(--primary-color); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { border: 1px solid #D9D9D9; background: #fff; color: #333; }
.btn-outline:hover { border-color: var(--primary-color); color: var(--primary-color); }
.btn-danger { background: #FFF1F0; color: var(--danger); border: 1px solid #FFA39E; }
.btn-danger:hover { background: #FFE7E5; }
.btn-gold { background: #FFF3E0; color: #E65100; border: 1px solid #FFD591; }
.btn-sm { padding: 4px 10px; font-size: 12px; border-radius: 4px; }
.btn-lg { padding: 10px 30px; font-size: 15px; }

.table-toolbar { display: flex; justify-content: space-between; margin-bottom: 14px; flex-wrap: wrap; gap: 10px; align-items: center; }
.search-group { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.search-input { padding: 8px 12px; border: 1px solid #D9D9D9; border-radius: 6px; width: 220px; outline: none; font-size: 13px; }
.search-input:focus { border-color: var(--primary-color); }
select.search-input { width: 140px; cursor: pointer; }

table { width: 100%; border-collapse: collapse; text-align: left; }
th { background: #FAFAFA; padding: 11px 14px; font-weight: 500; color: #595959; border-bottom: 1px solid var(--border); font-size: 13px; white-space: nowrap; }
td { padding: 13px 14px; border-bottom: 1px solid var(--border); color: #333; font-size: 13px; }
tr:hover td { background: #FAFAFA; }
.empty-row { text-align: center; color: var(--text-sub); padding: 40px 0 !important; }

.tag { padding: 2px 8px; border-radius: 4px; font-size: 12px; display: inline-block; white-space: nowrap; }
.tag-green { background: #E8F5E9; color: var(--primary-color); }
.tag-gold { background: #FFF3E0; color: #E65100; }
.tag-gray { background: #F5F5F5; color: #999; }
.tag-red { background: #FFF1F0; color: var(--danger); }
.tag-blue { background: #E3F2FD; color: #1976D2; }

.openid-text {
    font-family: Consolas, Monaco, monospace;
    color: #666;
    font-size: 12px;
    background: #F5F5F5;
    padding: 2px 6px;
    border-radius: 4px;
    display: inline-block;
    max-width: 170px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}
.link { color: var(--primary-color); cursor: pointer; text-decoration: none; margin-right: 10px; }
.link-danger { color: var(--danger); }
.avatar-img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; background: #EEE; }
.avatar-empty { width: 30px; height: 30px; border-radius: 50%; background: #EEE; color: #999; font-size: 11px; display: inline-flex; align-items: center; justify-content: center; }

/* ================= 图表 ================= */
.chart-container { display: flex; align-items: flex-end; height: 180px; gap: 14px; padding-top: 24px; border-bottom: 2px solid #E8E8E8; }
.chart-bar-wrapper { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.chart-bar { width: 42px; background: var(--primary-color); border-radius: 4px 4px 0 0; opacity: .85; transition: height .5s ease; min-height: 3px; }
.chart-bar:hover { opacity: 1; }
.chart-bar.today { background: var(--warning); }
.chart-label { font-size: 12px; color: #999; }
.chart-label.today { color: var(--warning); font-weight: bold; }
.chart-count { font-size: 12px; color: #666; }

/* ================= 配置表单 ================= */
.config-row { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 22px; padding-bottom: 22px; border-bottom: 1px dashed #EEE; }
.config-row:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.config-label { width: 210px; font-size: 14px; color: #333; font-weight: 500; flex-shrink: 0; }
.config-desc { font-size: 12px; color: #999; margin-top: 5px; font-weight: normal; }
.config-input-box { flex: 1; display: flex; align-items: center; gap: 10px; }
.config-input { width: 100%; max-width: 460px; padding: 9px 14px; border: 1px solid #D9D9D9; border-radius: 6px; outline: none; font-size: 13px; }
.config-input:focus { border-color: var(--primary-color); }
.config-input:disabled { background: #F5F5F5; color: #999; cursor: not-allowed; }
.unit { font-size: 13px; color: #333; white-space: nowrap; }
.form-hint { font-size: 12px; color: #999; margin-top: 6px; }
/* 字段级校验：就地红字提示，非法时不提交 */
.config-row .form-hint { flex-basis: 100%; }
.form-hint.is-error { color: var(--danger); font-weight: 500; }
/* 配置生效回显条：常驻直到下次保存或切页 */
.config-saved-bar {
    background: var(--sidebar-bg); border: 1px solid var(--border); border-left: 3px solid var(--primary-color);
    border-radius: 6px; padding: 10px 14px; margin-bottom: 18px;
    font-size: 13px; color: var(--text-sub);
}
/* 后端回传的 warnings（如 env-only 密钥提示）：回显条内分行展示 */
.config-saved-warn { margin-top: 6px; padding-top: 6px; border-top: 1px solid var(--border); }
/* 下拉选择控件：复用 .config-input 外观，仅补充指针与最小宽度 */
.config-select { cursor: pointer; max-width: 320px; }
/* 公告输入框：占满卡片宽度 */
.config-input-block { max-width: 100%; }
/* 卡片标题危险色（敏感配置分区） */
.card-title.is-danger { color: var(--danger); }
/* 密钥行：输入框 + 随机/复制按钮（参照 MP 后台「支付配置」） */
.secret-box { gap: 8px; }
.secret-input {
    font-family: Consolas, Monaco, monospace; font-size: 13px; letter-spacing: .3px;
}
.secret-btn { flex-shrink: 0; white-space: nowrap; }

/* ================= 支付配置卡片 ================= */
/* 两列布局：左侧字段名，右侧输入框（参照 MP 后台「支付配置」的样子） */
.config-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 24px; margin-bottom: 22px; }
.config-grid-item { min-width: 0; }
.config-label-sm { font-size: 13px; color: var(--text-main); font-weight: 500; margin-bottom: 7px; }
/* 单选项：支付方式（本产品只有虚拟支付一种） */
.radio-item { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-main); cursor: pointer; }
.radio-item input { cursor: pointer; margin: 0; }
/* 行内说明（跟在单选项右边，不另起一行） */
.inline-hint { margin-top: 0; margin-left: 8px; }
/* 卡片底部的整体提示条（说明密钥的注入方式） */
.config-tip {
    margin-top: 18px; padding: 10px 14px;
    background: var(--sidebar-bg); border: 1px solid var(--border); border-radius: 6px;
    font-size: 12px; color: var(--text-sub); line-height: 1.7;
}
.config-tip b { color: var(--text-main); }

/* ================= 弹窗 ================= */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: flex; justify-content: center; align-items: center; opacity: 0; visibility: hidden; transition: all .25s; z-index: 200; }
.modal-overlay.show { opacity: 1; visibility: visible; }
.modal { background: #fff; width: 620px; border-radius: 8px; padding: 24px; transform: scale(.92); transition: all .25s; box-shadow: 0 10px 30px rgba(0,0,0,.12); max-height: 82vh; overflow-y: auto; }
.modal-overlay.show .modal { transform: scale(1); }
.modal-header { font-size: 17px; font-weight: bold; margin-bottom: 18px; border-bottom: 1px solid #EEE; padding-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.modal-close { cursor: pointer; color: #999; font-size: 22px; line-height: 1; }
.modal-close:hover { color: #333; }
.modal-body { font-size: 13px; }
.modal-footer { margin-top: 20px; text-align: right; border-top: 1px solid #EEE; padding-top: 16px; }
.modal-footer .btn { margin-left: 10px; }
.modal-label { color: var(--text-sub); margin-bottom: 6px; display: block; }
.modal-input { width: 100%; padding: 9px 12px; border: 1px solid #D9D9D9; border-radius: 6px; outline: none; font-size: 13px; margin-bottom: 14px; }
.modal-input:focus { border-color: var(--primary-color); }
.detail-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 20px; margin-bottom: 18px; }
.detail-grid div { font-size: 13px; }
.detail-grid span { color: var(--text-sub); }
.sub-title { font-size: 14px; font-weight: bold; margin: 16px 0 10px; padding-left: 9px; border-left: 3px solid var(--primary-color); }

/* ================= 提示 ================= */
.toast {
    position: fixed; top: 22px; left: 50%; transform: translateX(-50%) translateY(-80px);
    background: rgba(0,0,0,.82); color: #fff; padding: 10px 20px; border-radius: 6px;
    font-size: 13px; z-index: 500; transition: all .3s; max-width: 70vw; text-align: center;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.error { background: rgba(220,38,38,.9); }
/* 成功态：绿底 + 左侧 ✓ 文本符号（不只靠颜色传达状态） */
.toast.success { background: var(--primary-color); }

/* ================= 响应式 ================= */
@media (max-width: 1100px) {
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .sidebar { width: 180px; }
    .config-label { width: 160px; }
}
