:root {
    --sidebar-w: 220px;
    --sidebar-bg: #1f2d3d;
    --sidebar-bg-active: #16222f;
    --sidebar-text: #c2c9d1;
    --primary: #1e9fff;
    --bg: #f3f5f8;
    --border: #e6e9ef;
    --text: #333;
    --muted: #94a3b8;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    color: var(--text);
    background: var(--bg);
}

a { color: var(--primary); text-decoration: none; }
a:hover { opacity: .9; }

.layui-card { border-radius: 6px; box-shadow: 0 1px 2px rgba(15, 23, 42, .06); }
.layui-card-header { font-weight: 600; }

/* ---------- 后台布局 ---------- */
.admin-body { min-height: 100vh; }

.admin-layout { display: flex; min-height: 100vh; }

.admin-sidebar {
    width: var(--sidebar-w);
    position: fixed;
    inset: 0 auto 0 0;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .2s ease;
}

.admin-brand {
    height: 56px;
    display: flex;
    align-items: center;
    padding: 0 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}

.admin-brand-logo { display: block; height: 30px; width: auto; }

.admin-menu { flex: 1; overflow-y: auto; padding: 8px 0; }

.admin-menu-title {
    padding: 16px 18px 6px;
    font-size: 12px;
    color: #64748b;
    letter-spacing: .5px;
}

.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 11px 18px;
    color: var(--sidebar-text);
    font-size: 14px;
    border-left: 3px solid transparent;
}

.admin-menu-item:hover { background: rgba(255, 255, 255, .04); color: #fff; }

.admin-menu-item.active {
    background: var(--sidebar-bg-active);
    color: #fff;
    border-left-color: var(--primary);
}

.admin-menu-item .layui-icon { font-size: 17px; }

.admin-sidebar-footer {
    padding: 10px 18px;
    font-size: 12px;
    color: #64748b;
    border-top: 1px solid rgba(255, 255, 255, .06);
}

.admin-main {
    flex: 1;
    margin-left: var(--sidebar-w);
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-topbar {
    height: 56px;
    background: #fff;
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 14px;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .06);
    position: sticky;
    top: 0;
    z-index: 900;
}

.admin-menu-toggle {
    border: 0;
    background: transparent;
    cursor: pointer;
    color: #475569;
    font-size: 18px;
    padding: 4px 6px;
}

.admin-topbar-title { font-weight: 600; font-size: 15px; }

.admin-topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
}

.admin-user-name { color: #475569; display: inline-flex; align-items: center; gap: 4px; }

.admin-content { padding: 20px; flex: 1; }

.admin-footer {
    padding: 14px 20px;
    text-align: center;
    color: var(--muted);
    font-size: 12px;
}

/* ---------- 页头 / 卡片 ---------- */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.page-title { margin: 0; font-size: 20px; font-weight: 600; color: #1e293b; }
.page-desc { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.page-header-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.admin-card { margin-bottom: 16px; }

/* ---------- 搜索栏 ---------- */
.search-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    padding: 14px 16px;
}

/* 只作用于搜索栏最外层的关键词输入框：避免命中 layui 下拉框内部的 input，
   否则下拉框内部输入框会被撑宽，覆盖后面的“搜索”按钮 */
.search-bar > .layui-input { width: 220px; height: 34px; }
.search-bar .layui-form-select .layui-input { width: 100%; height: 34px; }
.search-bar .layui-form-label { width: auto; padding: 7px 8px 7px 0; }
.search-bar-item { display: inline-flex; align-items: center; gap: 8px; }
.search-bar .layui-btn { flex: 0 0 auto; }

/* ---------- 表格 ---------- */
.layui-table { margin: 0; }
.layui-table th { background: #f8fafc; color: #475569; font-weight: 600; }
.layui-table td, .layui-table th { padding: 9px 12px; }
.table-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.inline-form { display: inline-block; margin: 0; }
.text-right { text-align: right; }
.text-muted { color: var(--muted); }
.text-nowrap { white-space: nowrap; }
.money { font-variant-numeric: tabular-nums; }

/* ---------- 组织架构 ---------- */
.dept-name { display: inline-flex; align-items: center; gap: 6px; }
.dept-tree-line { color: #cbd5e1; letter-spacing: -2px; margin-right: 2px; }
.dept-arrow { color: #94a3b8; font-size: 12px; }
.dept-code { color: #94a3b8; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.dept-level-tag { font-size: 12px; color: #fff; background: #94a3b8; border-radius: 3px; padding: 0 6px; }

/* ---------- 角色 / 权限 ---------- */
.role-code { color: #94a3b8; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.perm-groups { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 14px; }
.perm-group .layui-card-header { display: flex; align-items: center; justify-content: space-between; }
.perm-group-items { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 4px 14px; }
.perm-item { display: flex; align-items: flex-start; gap: 6px; padding: 5px 0; font-size: 13px; }
.perm-item .layui-form-checkbox[lay-skin=primary] { margin-top: 0; }
.perm-code { display: block; color: #94a3b8; font-size: 12px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.role-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.role-chip { display: inline-block; padding: 1px 8px; border-radius: 10px; background: #eef6ff; color: #1e6fd9; font-size: 12px; }
.role-chip.is-super { background: #fff1e6; color: #d46b08; }

/* ---------- 表单 ---------- */
.admin-content .layui-form-label {
    width: 160px;
    padding: 9px 12px 9px 0;
    white-space: normal;
    line-height: 20px;
}
.admin-content .layui-input-block { margin-left: 160px; }
.required { color: #ff5722; margin-left: 2px; }
.form-error { color: #ff5722; font-size: 12px; margin-top: 4px; }

/* ---------- 占位文字 ---------- */
/* 输入框 / 文本域 / Layui 下拉框空值提示统一调浅，避免正文观感过重 */
.layui-input::placeholder,
.layui-textarea::placeholder {
    color: #b7bec9;
    opacity: 1;
}
.layui-input::-webkit-input-placeholder,
.layui-textarea::-webkit-input-placeholder {
    color: #b7bec9;
}
.layui-input::-moz-placeholder,
.layui-textarea::-moz-placeholder {
    color: #b7bec9;
    opacity: 1;
}
.form-help { color: var(--muted); font-size: 12px; margin-top: 4px; }
.is-invalid { border-color: #ff5722 !important; }
.form-actions { padding: 10px 0 4px; margin-left: 160px; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 18px; }
.form-grid .layui-form-item { margin-bottom: 12px; }
.form-section-title {
    font-weight: 600;
    color: #1e293b;
    margin: 6px 0 14px;
    padding-left: 8px;
    border-left: 3px solid var(--primary);
}
.survey-table { width: 100%; border-collapse: collapse; }
.survey-table th, .survey-table td { border: 1px solid var(--border); padding: 8px 10px; font-size: 13px; }
.survey-table th { background: #f8fafc; text-align: left; font-weight: 600; white-space: nowrap; }
.survey-table .layui-input { height: 32px; }

/* ---------- 徽章 / 提示 ---------- */
.layui-badge { margin-right: 2px; }

.admin-flash {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    padding: 10px 14px;
    border-radius: 6px;
    margin-bottom: 14px;
    font-size: 13px;
}

.admin-flash ul { margin: 0; padding-left: 16px; }
.admin-flash-success { background: #f0f9eb; color: #3b7c2a; border: 1px solid #e1f3d8; }
.admin-flash-error { background: #fef0f0; color: #b91c1c; border: 1px solid #fde2e2; }

/* ---------- 工作台 ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; margin-bottom: 16px; }

.stat-card {
    background: #fff;
    border-radius: 6px;
    padding: 16px;
    display: flex;
    gap: 12px;
    align-items: center;
    box-shadow: 0 1px 2px rgba(15, 23, 42, .06);
}

.stat-card-icon {
    width: 42px;
    height: 42px;
    border-radius: 8px;
    background: #eef6ff;
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.stat-card-label { color: var(--muted); font-size: 12px; }
.stat-card-value { font-size: 22px; font-weight: 600; color: #1e293b; line-height: 1.3; }
.stat-card-hint { color: var(--muted); font-size: 12px; }

.dashboard-grid { display: grid; grid-template-columns: 3fr 2fr; gap: 16px; align-items: start; }

.timeline-item { padding: 8px 0 14px 18px; border-left: 2px solid var(--border); position: relative; }
.timeline-item::before {
    content: "";
    width: 8px; height: 8px; border-radius: 50%;
    background: var(--primary); position: absolute; left: -5px; top: 14px;
}
.timeline-time { color: var(--muted); font-size: 12px; }
.timeline-title { font-weight: 600; margin: 2px 0; }
.timeline-content { color: #475569; font-size: 13px; white-space: pre-wrap; }

/* ---------- 分页 ---------- */
.admin-pagination { margin-top: 14px; text-align: right; }
.admin-pagination .layui-laypage { margin: 0; }

/* ---------- 空状态 ---------- */
.empty-state { padding: 28px 0; text-align: center; color: var(--muted); }
.empty-state .layui-icon { font-size: 30px; display: block; margin-bottom: 6px; }
.empty-state p { margin: 0; font-size: 13px; }

/* ---------- 登录/注册 ---------- */
.guest-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1f2d3d 0%, #24405a 55%, #1e9fff 160%);
}

.guest-wrap { width: 100%; max-width: 400px; padding: 24px; }

.guest-brand { text-align: center; color: #fff; margin-bottom: 22px; }
.guest-brand .layui-icon { font-size: 34px; color: #7cc8ff; }
.guest-brand-mark { width: 40px; height: 40px; margin: 0 auto 10px; }
.guest-brand h1 { font-size: 20px; margin: 8px 0 4px; font-weight: 600; }
.guest-brand p { margin: 0; font-size: 12px; color: rgba(255, 255, 255, .65); }

.guest-card {
    background: #fff;
    border-radius: 10px;
    padding: 26px 24px;
    box-shadow: 0 20px 40px rgba(15, 23, 42, .25);
}

.guest-card .layui-form-item { margin-bottom: 16px; }
.guest-card .layui-form-label { width: 70px; padding: 9px 8px 9px 0; text-align: left; }
.guest-card .layui-input-block { margin-left: 70px; }
.guest-card .layui-btn-fluid { margin-top: 6px; }
.guest-links { display: flex; justify-content: space-between; font-size: 13px; margin-top: 12px; }
.guest-footer { text-align: center; color: rgba(255, 255, 255, .5); font-size: 12px; margin-top: 18px; }

/* ---------- 响应式 ---------- */
@media (max-width: 900px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-body.sidebar-open .admin-sidebar { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .form-grid { grid-template-columns: 1fr; }
    .search-bar > .layui-input { width: 100%; }
    .search-bar .layui-form-select { width: 100% !important; }
    .search-bar-item { flex: 1 1 100%; }
}
