*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --bg: #f7f3ed;
    --surface: #ffffff;
    --primary: #8b5a2b;
    --primary-dark: #6d4520;
    --primary-light: #f0e6d8;
    --text: #2c2416;
    --text-muted: #7a6f60;
    --border: #e8dfd3;
    --success: #2d7a4f;
    --success-bg: #e8f5ee;
    --error: #b33a3a;
    --error-bg: #fdecec;
    --shadow: 0 4px 24px rgba(44, 36, 22, 0.08);
    --radius: 12px;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.page-wrap {
    max-width: 1100px;
    margin: 0 auto;
    padding: 24px 16px 48px;
}

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Auth */
.auth-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px 32px;
    margin-top: 40px;
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
}

.auth-header {
    text-align: center;
    margin-bottom: 28px;
}

.auth-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.auth-note {
    margin-top: 20px;
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Forms */
.form .field {
    display: block;
    margin-bottom: 16px;
}

.form .field span {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.form input[type="text"],
.form input[type="password"] {
    width: 100%;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: 8px;
    font-size: 1rem;
    background: #faf8f5;
    transition: border-color 0.2s;
}

.form input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    text-decoration: none;
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}

.btn-outline:hover {
    background: var(--primary-light);
    text-decoration: none;
}

.btn-muted {
    background: #eee;
    color: var(--text-muted);
}

.btn-danger {
    background: var(--error);
    color: #fff;
}

.btn-sm {
    padding: 4px 12px;
    font-size: 0.82rem;
}

.btn-block {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
}

.btn-lg {
    padding: 16px 40px;
    font-size: 1.05rem;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 0.92rem;
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
    border: 1px solid #f5c6c6;
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
    border: 1px solid #b8dfc8;
}

/* Survey */
.survey-page {
    max-width: 820px;
    margin: 0 auto;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.survey-hero {
    background: linear-gradient(135deg, var(--primary) 0%, #a0723c 100%);
    color: #fff;
    padding: 32px 28px;
}

.user-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    margin-bottom: 20px;
    opacity: 0.9;
}

.link-muted {
    color: rgba(255,255,255,0.85);
    font-size: 0.85rem;
}

.link-muted:hover {
    color: #fff;
}

.survey-hero h1 {
    font-size: 1.4rem;
    line-height: 1.4;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 0.95rem;
    opacity: 0.92;
    line-height: 1.7;
}

.info-box {
    background: rgba(255,255,255,0.15);
    border-radius: 8px;
    padding: 16px;
    margin-top: 20px;
    font-size: 0.88rem;
    line-height: 1.8;
}

.info-box strong {
    opacity: 0.85;
}

.survey-hero .alert-success {
    margin-top: 16px;
    margin-bottom: 0;
    background: rgba(255,255,255,0.2);
    color: #fff;
    border: 1px solid rgba(255,255,255,0.3);
}

.survey-form {
    padding: 8px 0 32px;
}

.survey-section {
    padding: 28px 28px 8px;
    border-bottom: 1px solid var(--border);
}

.survey-section h2 {
    font-size: 1.1rem;
    color: var(--primary);
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary-light);
}

.question-card {
    margin-bottom: 24px;
    padding: 20px;
    background: #faf8f5;
    border-radius: 10px;
    border: 1.5px solid transparent;
    transition: border-color 0.2s;
}

.question-card.question-error {
    border-color: var(--error);
    background: var(--error-bg);
}

.question-card h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.5;
}

.question-hint {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 14px;
}

.options {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px;
    background: var(--surface);
    border: 1.5px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.option-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.option-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.option-box {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--primary);
    border-radius: 4px;
    margin-top: 2px;
    position: relative;
    background: #fff;
}

.option-item input:checked ~ .option-box {
    background: var(--primary);
}

.option-item input:checked ~ .option-box::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 6px;
    height: 11px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.option-text {
    font-size: 0.92rem;
    line-height: 1.5;
}

.option-text strong {
    color: var(--primary);
    margin-right: 4px;
}

.submit-area {
    padding: 32px 28px;
    text-align: center;
}

.thanks-note {
    color: var(--text-muted);
    font-size: 0.92rem;
    margin-bottom: 20px;
    line-height: 1.7;
}

/* Done */
.done-card {
    text-align: center;
    max-width: 480px;
}

.done-icon {
    width: 64px;
    height: 64px;
    background: var(--success);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 20px;
}

.done-card h1 {
    font-size: 1.4rem;
    margin-bottom: 8px;
}

.done-desc {
    color: var(--text-muted);
    margin: 12px 0 24px;
    line-height: 1.7;
}

.done-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

/* Admin */
.admin-page {
    width: 100%;
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 28px;
}

.admin-header h1 {
    font-size: 1.5rem;
    color: var(--primary);
}

.admin-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-top: 4px;
}

.admin-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.back-link {
    display: inline-block;
    font-size: 0.88rem;
    margin-bottom: 8px;
    color: var(--text-muted);
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.admin-section {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

.admin-section h2 {
    font-size: 1.05rem;
    margin-bottom: 16px;
    color: var(--text);
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

th, td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

th {
    background: #faf8f5;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

td.empty {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
}

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 0.78rem;
    font-weight: 600;
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-pending {
    background: #fff3e0;
    color: #b36a00;
}

.text-muted {
    color: var(--text-muted);
}

.link {
    font-weight: 600;
}

code {
    background: #f0e6d8;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.inline-form {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

.inline-form .field {
    margin-bottom: 0;
    flex: 1;
    min-width: 140px;
}

.inline-delete {
    display: inline;
}

.detail-content {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 8px 0;
}

.detail-section {
    padding: 24px 28px;
    border-bottom: 1px solid var(--border);
}

.detail-section h2 {
    font-size: 1.05rem;
    color: var(--primary);
    margin-bottom: 16px;
}

.detail-question {
    margin-bottom: 20px;
}

.detail-question h3 {
    font-size: 0.95rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.detail-answer ul {
    list-style: none;
    padding-left: 0;
}

.detail-answer li {
    padding: 6px 0;
    font-size: 0.9rem;
    color: var(--text);
    border-bottom: 1px dashed var(--border);
}

.detail-answer li:last-child {
    border-bottom: none;
}

/* Responsive */
@media (max-width: 768px) {
    .page-wrap {
        padding: 16px 12px 40px;
    }

    .auth-card {
        padding: 28px 20px;
        margin-top: 20px;
    }

    .survey-hero {
        padding: 24px 18px;
    }

    .survey-hero h1 {
        font-size: 1.2rem;
    }

    .survey-section {
        padding: 20px 16px 8px;
    }

    .question-card {
        padding: 16px;
    }

    .submit-area {
        padding: 24px 16px;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .admin-header {
        flex-direction: column;
    }

    .inline-form {
        flex-direction: column;
    }

    .inline-form .field {
        width: 100%;
    }

    .done-actions {
        flex-direction: column;
    }

    .done-actions .btn {
        width: 100%;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .stat-value {
        font-size: 1.5rem;
    }
}
