/* ===== 基础全局样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
body {
    font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
    background: #f5f7fa;
    padding: 16px;
    color: #333;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.container {
    width: 100%;
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    padding: 30px 35px;
    position: relative;
}

/* ===== 通用链接 & 标题 ===== */
.admin-link {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 14px;
    color: #3498db;
    text-decoration: none;
    border: 1px solid #3498db;
    padding: 6px 16px;
    border-radius: 20px;
    transition: 0.25s;
    line-height: 1;
    white-space: nowrap;
}
.admin-link:hover {
    background: #3498db;
    color: #fff;
}
h1 {
    font-size: 26px;
    margin: 30px 0 6px 0;
    color: #2c3e50;
    word-break: break-word;
}
.subtitle {
    color: #7f8c8d;
    font-size: 15px;
    margin-bottom: 25px;
    border-bottom: 1px solid #ecf0f1;
    padding-bottom: 15px;
}
.back-link {
    display: inline-block;
    margin-top: 15px;
    color: #3498db;
    text-decoration: none;
}
.back-link:hover {
    text-decoration: underline;
}

/* ===== 消息提示 ===== */
.message {
    padding: 12px 18px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 15px;
    line-height: 1.5;
}
.message.success {
    background: #eafaf1;
    color: #1e8449;
    border: 1px solid #a9dfbf;
}
.message.error {
    background: #fdedec;
    color: #922b21;
    border: 1px solid #f5b7b1;
}

/* ===== 表单元素 ===== */
.form-group {
    margin-bottom: 20px;
}
label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    font-size: 15px;
    color: #2c3e50;
}
label .required {
    color: #e74c3c;
    margin-left: 2px;
}
input[type="text"],
input[type="email"],
input[type="password"],
select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #dcdfe6;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.2s;
    background: #fafbfc;
    appearance: none;
    -webkit-appearance: none;
}
select {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 40px;
    cursor: pointer;
}
input:focus,
select:focus {
    outline: none;
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52,152,219,0.12);
}
.radio-group {
    display: flex;
    gap: 24px;
    padding-top: 4px;
    flex-wrap: wrap;
}
.radio-group label {
    font-weight: normal;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 16px;
}
.radio-group input[type="radio"] {
    width: 20px;
    height: 20px;
    accent-color: #3498db;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
.btn-submit {
    width: 100%;
    padding: 16px;
    background: #2ecc71;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
    margin-top: 8px;
    touch-action: manipulation;
}
.btn-submit:hover {
    background: #27ae60;
}
.btn-submit:active {
    transform: scale(0.98);
}

/* ===== 页脚 ===== */
.footnote {
    margin-top: 24px;
    font-size: 14px;
    color: #95a5a6;
    text-align: center;
}

/* ============================================================
   管理员后台专用样式
   ============================================================ */

/* --- 登录面板 --- */
.login-panel {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 25px 20px 20px;
    margin: 10px 0 20px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.login-panel .login-icon {
    text-align: center;
    font-size: 42px;
    margin-bottom: 10px;
}
.login-panel .login-welcome {
    text-align: center;
    color: #5a6c7d;
    font-size: 16px;
    margin-bottom: 20px;
}
.login-panel .form-group {
    margin-bottom: 18px;
}
.login-panel .btn-submit {
    background: #3498db;
}
.login-panel .btn-submit:hover {
    background: #2980b9;
}

/* --- 管理头部 --- */
.admin-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}
.stats {
    font-size: 15px;
    color: #7f8c8d;
}
.stats strong {
    color: #2c3e50;
}
.action-links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}
.logout-link {
    color: #e74c3c;
    text-decoration: none;
    border: 1px solid #e74c3c;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 14px;
    transition: 0.25s;
}
.logout-link:hover {
    background: #e74c3c;
    color: #fff;
}

/* --- 表格区域 --- */
.table-section {
    margin-top: 25px;
    border-top: 2px solid #ecf0f1;
    padding-top: 20px;
}
.table-section:first-of-type {
    border-top: none;
    padding-top: 0;
}
.table-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}
.table-header h2 {
    font-size: 18px;
    color: #2c3e50;
    margin: 0;
}
.location-tag {
    display: inline-block;
    font-size: 13px;
    background: #3498db;
    color: #fff;
    padding: 2px 12px;
    border-radius: 12px;
    margin-left: 8px;
}
.export-small-btn {
    display: inline-block;
    background: #2ecc71;
    color: #fff;
    padding: 6px 16px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 14px;
    transition: background 0.2s;
    border: none;
    cursor: pointer;
}
.export-small-btn:hover {
    background: #27ae60;
}
.table-container {
    overflow-x: auto;
    border-radius: 6px;
    border: 1px solid #ecf0f1;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    min-width: 700px;
}
th, td {
    padding: 12px 10px;
    text-align: left;
    border-bottom: 1px solid #ecf0f1;
    white-space: nowrap;
}
th {
    background: #f8f9fa;
    font-weight: 600;
    color: #2c3e50;
    position: sticky;
    top: 0;
    z-index: 2;
}
tr:hover {
    background: #f5f7fa;
}
.empty-note {
    padding: 20px;
    text-align: center;
    color: #95a5a6;
}

/* ============================================================
   调查页面（survey.php & survey_stats.php）专用样式
   ============================================================ */

/* --- 多选复选框网格 --- */
.checkbox-group {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 20px;
    padding-top: 4px;
}
.checkbox-group label {
    font-weight: normal;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 15px;
    line-height: 1.4;
}
.checkbox-group input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: #3498db;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}
/* 查看统计链接 */
.stats-link {
    display: inline-block;
    margin-top: 10px;
    color: #3498db;
    text-decoration: none;
    font-size: 15px;
}
.stats-link:hover {
    text-decoration: underline;
}

/* --- 统计图表容器 --- */
.chart-container {
    width: 100%;
    max-width: 700px;
    height: 500px;
    margin: 20px auto;
    border: 1px solid #ecf0f1;
    border-radius: 8px;
    padding: 10px;
    background: #fafbfc;
}
.stats-summary {
    text-align: center;
    font-size: 16px;
    color: #2c3e50;
    margin-bottom: 10px;
}

/* --- 统计表格（覆盖通用表格样式） --- */
.stats-table {
    width: 100%;
    max-width: 700px;
    margin: 20px auto;
    border-collapse: collapse;
    font-size: 14px;
}
.stats-table th,
.stats-table td {
    padding: 8px 10px;
    border-bottom: 1px solid #ecf0f1;
    text-align: left;
    white-space: normal;   /* 允许换行 */
}
.stats-table th {
    background: #f8f9fa;
    font-weight: 600;
}
.stats-table tr:hover {
    background: #f5f7fa;
}
/* 第一列（领导人名称）限制宽度并换行 */
.stats-table th:first-child,
.stats-table td:first-child {
    max-width: 200px;
    word-break: break-word;
    white-space: normal;
}
/* 后两列（票数、占比）保持紧凑居中 */
.stats-table th:nth-child(2),
.stats-table td:nth-child(2),
.stats-table th:nth-child(3),
.stats-table td:nth-child(3) {
    white-space: nowrap;
    text-align: center;
}

/* ============================================================
   响应式适配
   ============================================================ */

/* 手机端 (≤480px) */
@media (max-width: 480px) {
    body { padding: 12px; }
    .container { padding: 20px 18px; border-radius: 8px; }
    .admin-link { top: 14px; right: 16px; font-size: 12px; padding: 4px 12px; }
    h1 { font-size: 22px; }
    .subtitle { font-size: 14px; margin-bottom: 20px; padding-bottom: 12px; }
    .message { font-size: 14px; padding: 10px 14px; }
    label { font-size: 14px; }
    input[type="text"], input[type="email"], input[type="password"], select {
        padding: 12px 12px;
        font-size: 16px;
        padding-right: 36px;
    }
    .radio-group { gap: 16px; flex-direction: column; align-items: flex-start; }
    .radio-group label { font-size: 16px; }
    .btn-submit { font-size: 17px; padding: 15px; }
    .footnote { font-size: 13px; margin-top: 18px; }

    /* 管理员后台 */
    .admin-header { flex-direction: column; align-items: stretch; }
    .action-links { justify-content: flex-start; }
    .table-header { flex-direction: column; align-items: flex-start; gap: 8px; }
    table { font-size: 13px; min-width: 600px; }
    th, td { padding: 8px 6px; }
    .export-small-btn, .logout-link { font-size: 14px; padding: 6px 14px; }
    .login-panel { padding: 18px 14px; }
    .login-panel .login-icon { font-size: 34px; }

    /* 调查页面复选框 */
    .checkbox-group {
        grid-template-columns: 1fr 1fr;
        gap: 8px 12px;
    }
    .checkbox-group label { font-size: 14px; }
}
/* 超小屏 (≤380px) */
@media (max-width: 380px) {
    .container { padding: 16px 12px; }
    h1 { font-size: 20px; }
    .admin-link { top: 10px; right: 10px; font-size: 11px; padding: 3px 10px; }
    input[type="text"], input[type="email"], input[type="password"], select {
        padding: 11px 10px;
        font-size: 16px;
    }
    .btn-submit { font-size: 16px; padding: 14px; }
    .checkbox-group { grid-template-columns: 1fr; }
}
/* 平板 (481px~768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .container { padding: 25px 30px; }
}