/* ===== Reset & Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f6fa;
    color: #333;
    line-height: 1.6;
    font-size: 15px;
}
a { text-decoration: none; color: inherit; }

/* ===== Login ===== */
.login-body {
    display: flex; justify-content: center; align-items: center;
    min-height: 100vh; background: #f5f6fa; padding: 24px;
}
.login-card {
    background: #fff; padding: 48px 40px; border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08); width: 100%; max-width: 400px;
    text-align: center;
}
.login-card h2 { color: #333; font-size: 26px; margin-bottom: 6px; }
.login-card .subtitle { color: #999; font-size: 15px; margin-bottom: 32px; }
.login-hint { color: #ccc; font-size: 13px; margin-top: 20px; }

/* ===== Sidebar (desktop) ===== */
.sidebar {
    width: 220px; background: #fff;
    color: #666; height: 100vh; position: fixed; left: 0; top: 0;
    display: flex; flex-direction: column; z-index: 200;
    border-right: 1px solid #e8e8e8;
}
.sidebar-brand {
    padding: 24px 20px; font-size: 18px; font-weight: 700; color: #333;
    border-bottom: 1px solid #e8e8e8; flex-shrink: 0;
}
.sidebar-brand small { display: block; font-size: 12px; color: #999; font-weight: 400; margin-top: 2px; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.sidebar-nav a {
    display: flex; align-items: center; gap: 10px;
    padding: 12px 20px; color: #666; text-decoration: none;
    font-size: 15px; transition: all 0.15s;
}
.sidebar-nav a:hover { background: #f5f6fa; color: #333; }
.sidebar-nav a.active { color: #1890ff; font-weight: 600; }
.sidebar-nav .nav-icon { flex-shrink: 0; width: 20px; text-align: center; font-size: 16px; }
.sidebar-section { padding: 14px 20px 4px; font-size: 11px; color: #bbb; letter-spacing: 1px; text-transform: uppercase; font-weight: 600; }
.sidebar-nav .nav-divider { height: 1px; background: #f0f0f0; margin: 8px 20px; }
.sidebar-footer { padding: 14px 20px; border-top: 1px solid #e8e8e8; flex-shrink: 0; }
.sidebar-footer a { color: #999; font-size: 14px; }
.sidebar-footer a:hover { color: #ef4444; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.3); z-index: 190; }

/* ===== Main ===== */
.main-content { margin-left: 220px; min-height: 100vh; display: flex; flex-direction: column; background: #f5f6fa; }
.topbar {
    background: #fff; padding: 0 28px; height: 56px;
    display: flex; align-items: center; justify-content: space-between;
    border-bottom: 1px solid #e8e8e8; position: sticky; top: 0; z-index: 100; flex-shrink: 0;
}
.topbar-menu { display: none; background: none; border: none; font-size: 20px; cursor: pointer; padding: 6px; margin-right: 10px; color: #333; }
.topbar-title { font-size: 17px; font-weight: 600; color: #333; }
.topbar-user { font-size: 14px; color: #999; }
.container { padding: 24px 28px; flex: 1; }

/* ===== Flash ===== */
.flash { padding: 12px 16px; background: #f6ffed; color: #52c41a; border-radius: 4px; font-size: 14px; border-left: 3px solid #52c41a; margin-bottom: 16px; }
.flash-error { padding: 12px 16px; background: #fff2f0; color: #ff4d4f; border-radius: 4px; font-size: 14px; border-left: 3px solid #ff4d4f; margin-bottom: 16px; }

/* ===== Stats ===== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
    background: #fff; padding: 20px 16px; border-radius: 6px;
    text-align: center; border: 1px solid #e8e8e8;
}
.stat-num { font-size: 32px; font-weight: 700; color: #1890ff; line-height: 1.1; }
.stat-label { font-size: 14px; color: #999; margin-top: 6px; }

/* ===== Village Tabs ===== */
.village-tabs { display: flex; gap: 0; margin-bottom: 20px; border-bottom: 1px solid #e8e8e8; }
.village-tab {
    padding: 12px 20px; font-size: 15px; color: #666; white-space: nowrap;
    border-bottom: 2px solid transparent; margin-bottom: -1px;
    cursor: pointer; background: none; border-top: none; border-left: none; border-right: none;
    font-family: inherit; transition: all 0.15s;
}
.village-tab:hover { color: #1890ff; }
.village-tab.active { color: #1890ff; border-bottom-color: #1890ff; font-weight: 600; }
.village-tab .tab-count { background: #f0f0f0; padding: 1px 8px; border-radius: 10px; font-size: 12px; color: #999; margin-left: 6px; }
.village-tab.active .tab-count { background: #1890ff; color: #fff; }

/* ===== Cards ===== */
.card { background: #fff; border-radius: 6px; padding: 20px; margin-bottom: 16px; border: 1px solid #e8e8e8; }
.card-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.card-header h2 { font-size: 18px; color: #333; font-weight: 600; }

/* ===== Data Tables ===== */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
    background: #fafafa; padding: 12px 16px; text-align: left;
    font-weight: 600; font-size: 14px; color: #999; border-bottom: 1px solid #e8e8e8;
}
.data-table td { padding: 14px 16px; border-bottom: 1px solid #f0f0f0; font-size: 14px; color: #333; }
.data-table tbody tr:hover { background: #fafafa; }

/* ===== Buttons ===== */
.btn {
    padding: 8px 20px; border-radius: 4px; font-size: 14px;
    text-decoration: none; display: inline-flex; align-items: center; gap: 6px;
    border: 1px solid #d9d9d9; cursor: pointer; transition: all 0.15s; font-family: inherit; white-space: nowrap;
}
.btn-primary { background: #1890ff; color: #fff; border-color: #1890ff; }
.btn-primary:hover { background: #40a9ff; }
.btn-secondary { background: #fff; color: #333; }
.btn-secondary:hover { color: #1890ff; border-color: #1890ff; }
.btn-danger { color: #ff4d4f; border-color: #ff4d4f; }
.btn-danger:hover { background: #fff2f0; }
.btn-sm { padding: 4px 12px; font-size: 13px; }

/* ===== Detail ===== */
.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.detail-header h2 { font-size: 20px; font-weight: 700; color: #333; }
.detail-card { background: #fff; border-radius: 6px; border: 1px solid #e8e8e8; margin-bottom: 16px; overflow: hidden; }
.detail-section { padding: 20px; }
.detail-section h3 { font-size: 16px; color: #333; margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid #f0f0f0; font-weight: 600; }
.detail-table { width: 100%; }
.detail-table th { text-align: left; padding: 10px 16px; width: 120px; color: #999; font-weight: 500; font-size: 14px; }
.detail-table td { padding: 10px 16px; font-size: 15px; color: #333; border-bottom: 1px solid #f5f5f5; }
.detail-table tr:last-child td { border-bottom: none; }
.detail-table td a { color: #1890ff; }

/* ===== Forms ===== */
.form-section { padding: 20px; background: #fff; }
.form-section-light { background: #fafafa; }
.form-section-dark { background: #fff; }
.form-section-title { font-size: 16px; color: #333; margin-bottom: 16px; font-weight: 600; }
.form-group { display: flex; flex-direction: column; margin-bottom: 16px; }
.form-group label { font-size: 14px; color: #666; margin-bottom: 6px; }
.form-group input, .form-group select, .form-group textarea {
    padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 4px;
    font-size: 14px; font-family: inherit; background: #fff; transition: border-color 0.15s;
}
.form-group input:focus, .form-group select:focus { outline: none; border-color: #1890ff; box-shadow: 0 0 0 2px rgba(24,144,255,0.1); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }
.form-actions { margin-top: 20px; display: flex; gap: 10px; }

/* ===== Edit ===== */
.edit-form { background: #fff; border-radius: 6px; border: 1px solid #e8e8e8; overflow: hidden; }

/* ===== Report Builder ===== */
.report-field-list { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 16px; }
.report-field-chip {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 16px; border-radius: 4px; font-size: 14px; cursor: pointer;
    border: 1px solid #d9d9d9; background: #fff; transition: all 0.15s; user-select: none;
}
.report-field-chip:hover { border-color: #1890ff; color: #1890ff; }
.report-field-chip.selected { background: #1890ff; color: #fff; border-color: #1890ff; }
.report-field-chip input { display: none; }
.report-preview-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.report-preview-table th { background: #fafafa; padding: 10px 12px; text-align: left; font-weight: 600; color: #666; border-bottom: 1px solid #e8e8e8; }
.report-preview-table td { padding: 10px 12px; border-bottom: 1px solid #f0f0f0; }

/* ===== Bottom Nav ===== */
.bottom-nav { display: none; }

/* ===== Person List (desktop table) ===== */
.list-wrap { background: #fff; border-radius: 6px; overflow: hidden; }

.person-table { width: 100%; border-collapse: collapse; }
.person-table th {
    text-align: left; padding: 14px 20px; font-weight: 600; font-size: 17px; color: #999;
    background: #fafafa; border-bottom: 2px solid #e8e8e8;
}
.person-table td {
    padding: 14px 20px; font-size: 18px; color: #333; border-bottom: 1px solid #f0f0f0;
}
.person-table tbody tr:hover { background: #f5f7fa; }
.person-table tbody tr:last-child td { border-bottom: none; }

.pr-gender-m { color: #1890ff; }
.pr-gender-f { color: #eb2f96; }

.loading-tip { text-align: center; padding: 20px; color: #ccc; font-size: 16px; }

/* ===== Filter Bar ===== */
.search-card { padding: 16px; }
.search-bar { display: flex; gap: 10px; align-items: center; }
.search-bar input {
    flex: 1; padding: 8px 12px; border: 1px solid #d9d9d9; border-radius: 4px;
    font-size: 14px; max-width: 360px;
}
.search-bar input:focus { outline: none; border-color: #1890ff; }

/* ===== Responsive — 平板侧边栏收起 ===== */
@media (max-width: 1024px) {
    .sidebar { width: 60px; }
    .sidebar-brand { font-size: 14px; padding: 16px 6px; text-align: center; line-height: 1.3; }
    .sidebar-brand small { display: none; }
    .sidebar-section { display: none; }
    .sidebar-nav a span:not(.nav-icon) { display: none; }
    .sidebar-nav a { justify-content: center; padding: 14px 6px; gap: 0; }
    .sidebar-footer span { display: none; }
    .main-content { margin-left: 60px; }
}

/* ===== Responsive — 手机 ===== */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); width: 260px; }
    .sidebar.open { transform: translateX(0); }
    .sidebar.open ~ .sidebar-overlay { display: block; }
    .sidebar-overlay.open { display: block; }
    .main-content { margin-left: 0; }
    .topbar { padding: 0 16px; height: 50px; }
    .topbar-menu { display: flex; align-items: center; justify-content: center; }
    .topbar-title { font-size: 16px; }
    .topbar-user { display: none; }
    .container { padding: 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .stat-card { padding: 16px 12px; }
    .stat-num { font-size: 26px; }
    .stat-label { font-size: 13px; }

    .card { padding: 16px; }

    .list-wrap { border-radius: 0; border: none; }
    .person-table { font-size: 16px; }
    .person-table th { font-size: 15px; padding: 12px 14px; }
    .person-table td { font-size: 16px; padding: 12px 14px; }

    .search-bar { flex-direction: column; }
    .search-bar input { max-width: 100%; width: 100%; }
    .search-bar .btn { width: 100%; justify-content: center; }

    .village-tabs { margin-bottom: 12px; }
    .village-tab { padding: 10px 14px; font-size: 14px; }

    .detail-header { flex-direction: column; gap: 10px; }
    .detail-header .btn { width: 100%; justify-content: center; }
    .detail-section { padding: 16px; }
    .detail-section h3 { font-size: 15px; }
    .detail-table th { font-size: 13px; width: 100px; }
    .detail-table td { font-size: 14px; }

    .form-grid { grid-template-columns: 1fr; }
    .form-group input, .form-group select { font-size: 16px; }
    .form-section { padding: 16px; }

    .bottom-nav {
        display: flex; position: fixed; bottom: 0; left: 0; right: 0;
        background: #fff; border-top: 1px solid #e8e8e8; z-index: 150;
        height: 60px; padding-bottom: env(safe-area-inset-bottom, 0);
    }
    .bottom-nav-item {
        flex: 1; display: flex; flex-direction: column; align-items: center;
        justify-content: center; text-decoration: none; color: #999; font-size: 12px;
        gap: 2px; -webkit-tap-highlight-color: transparent;
    }
    .bottom-nav-item.active { color: #1890ff; }
    .bni-icon { font-size: 20px; line-height: 1; }
    .bni-label { line-height: 1; }

    .login-card { padding: 36px 24px; }
    .login-card h2 { font-size: 22px; }
}

@media (max-width: 380px) {
    .stats-grid { gap: 8px; }
    .stat-card { padding: 14px 8px; }
    .stat-num { font-size: 24px; }
}
