:root {
    --bg: #f5f7fa;
    --surface: #ffffff;
    --border: #e6e9ee;
    --border-strong: #d5dae2;
    --text: #1f2329;
    --muted: #6b7280;
    --faint: #9aa1ab;
    --primary: #1769e0;
    --primary-dark: #1257bd;
    --primary-soft: #eef4ff;
    --danger: #d93a2b;
    --success: #1a7f4b;
    --warn: #b25a00;
    --radius: 14px;
}

* {
    box-sizing: border-box;
}

html,
body {
    margin: 0;
    padding: 0;
}

body {
    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
        "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.55;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ---------- topbar ---------- */
.topbar {
    display: flex;
    position: sticky;
    top: 0;
    z-index: 20;
    height: 60px;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: saturate(160%) blur(8px);
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.brand-mark {
    display: flex;
    width: 28px;
    height: 28px;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    background: var(--primary);
    color: #ffffff;
    font-size: 15px;
    font-weight: 700;
}

.brand-name {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.2px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.hint {
    color: var(--faint);
    font-size: 12.5px;
}

/* ---------- layout ---------- */
.container {
    max-width: 1120px;
    margin: 0 auto;
    padding: 32px 24px 72px;
}

.page-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 24px;
    gap: 16px;
}

.page-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: 0.2px;
}

.page-sub {
    margin: 6px 0 0;
    color: var(--muted);
    font-size: 13px;
}

.link-back {
    margin-bottom: 16px;
    padding: 0;
    border: none;
    background: none;
    color: var(--muted);
    cursor: pointer;
    font-size: 13px;
}

.link-back:hover {
    color: var(--primary);
}

/* ---------- login ---------- */
.login-card {
    max-width: 400px;
    margin: 8vh auto 0;
    padding: 36px 32px 32px;
    border: 1px solid var(--border);
    border-radius: 18px;
    background: var(--surface);
    box-shadow: 0 12px 32px rgba(23, 37, 63, 0.06);
}

.login-title {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
}

.login-desc {
    margin: 8px 0 24px;
    color: var(--muted);
    font-size: 13px;
}

/* ---------- form controls ---------- */
.input,
.select,
.textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-strong);
    border-radius: 10px;
    background: #ffffff;
    color: var(--text);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input:focus,
.select:focus,
.textarea:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.12);
}

.textarea {
    min-height: 76px;
    resize: vertical;
}

.input-sm,
.select-sm {
    padding: 6px 10px;
    font-size: 13px;
}

.field {
    margin-bottom: 16px;
}

.field-label {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 12.5px;
    font-weight: 500;
}

.error-text {
    min-height: 18px;
    margin: 10px 0 10px;
    color: var(--danger);
    font-size: 12.5px;
}

/* ---------- buttons ---------- */
.btn {
    display: inline-flex;
    height: 38px;
    align-items: center;
    justify-content: center;
    padding: 0 18px;
    border: 1px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
}

.btn-ghost {
    border-color: var(--border-strong);
    background: #ffffff;
    color: var(--text);
}

.btn-ghost:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-danger {
    border-color: #f3cfcb;
    background: #ffffff;
    color: var(--danger);
}

.btn-danger:hover:not(:disabled) {
    background: #fdf1f0;
}

.btn-sm {
    height: 32px;
    padding: 0 12px;
    font-size: 13px;
}

.btn-block {
    width: 100%;
}

.btn-link {
    padding: 0;
    border: none;
    background: none;
    color: var(--primary);
    cursor: pointer;
    font-size: 13px;
}

/* ---------- survey list ---------- */
.survey-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.survey-card {
    display: flex;
    flex-direction: column;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.survey-card:hover {
    border-color: #c9d8f3;
    box-shadow: 0 8px 24px rgba(23, 37, 63, 0.07);
    transform: translateY(-1px);
}

.survey-card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
}

.survey-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.45;
    word-break: break-word;
}

.survey-card-desc {
    display: -webkit-box;
    overflow: hidden;
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

.survey-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid #f1f3f6;
    color: var(--faint);
    font-size: 12.5px;
}

.survey-card-stat strong {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
}

/* ---------- pills ---------- */
.pill {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
}

.pill-open {
    background: #e8f6ee;
    color: var(--success);
}

.pill-draft {
    background: #f1f3f6;
    color: var(--muted);
}

.pill-closed {
    background: #fdf2e6;
    color: var(--warn);
}

/* ---------- detail ---------- */
.detail-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.detail-title {
    margin: 10px 0 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.4;
}

.detail-desc {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 13px;
    white-space: pre-wrap;
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-row {
    display: flex;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.stat {
    flex: 1;
    min-width: 150px;
    padding: 16px 18px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.stat-label {
    color: var(--faint);
    font-size: 12.5px;
}

.stat-value {
    margin-top: 4px;
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 0.3px;
}

.panel {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}

.panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 14.5px;
    font-weight: 600;
}

.table-wrap {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    padding: 11px 14px;
    border-bottom: 1px solid #f1f3f6;
    text-align: left;
    vertical-align: top;
    white-space: nowrap;
}

th {
    position: sticky;
    top: 0;
    background: #f8fafc;
    color: var(--muted);
    font-weight: 600;
    font-size: 12.5px;
}

tbody tr:hover {
    background: #fafbfd;
}

td.wrap {
    min-width: 220px;
    max-width: 380px;
    white-space: normal;
    word-break: break-word;
}

.cell-empty {
    color: #c8ccd3;
}

.empty-box {
    padding: 56px 24px;
    color: var(--faint);
    font-size: 13.5px;
    text-align: center;
}

/* ---------- editor ---------- */
.editor-card {
    padding: 24px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
}

.editor-section-title {
    margin: 0 0 14px;
    font-size: 15px;
    font-weight: 600;
}

.question-card {
    margin-top: 14px;
    padding: 18px;
    border: 1px solid var(--border);
    border-radius: 12px;
    background: #fcfdff;
}

.question-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    gap: 12px;
}

.question-index {
    color: var(--faint);
    font-size: 12.5px;
    font-weight: 600;
}

.question-tools {
    display: flex;
    align-items: center;
    gap: 10px;
}

.checkbox-line {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12.5px;
    cursor: pointer;
}

.option-row {
    display: grid;
    align-items: center;
    margin-top: 8px;
    gap: 8px;
    grid-template-columns: 1fr 150px 32px;
}

.option-row.no-jump {
    grid-template-columns: 1fr 32px;
}

.icon-button {
    display: inline-flex;
    width: 30px;
    height: 30px;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--border-strong);
    border-radius: 8px;
    background: #ffffff;
    color: var(--muted);
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
}

.icon-button:hover {
    border-color: var(--danger);
    color: var(--danger);
}

.editor-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    margin-top: 22px;
    gap: 10px;
    flex-wrap: wrap;
}

.add-question-bar {
    display: flex;
    align-items: center;
    margin-top: 16px;
    gap: 10px;
    flex-wrap: wrap;
}

.muted-note {
    color: var(--faint);
    font-size: 12.5px;
}

/* ---------- toast ---------- */
.toast {
    position: fixed;
    bottom: 28px;
    left: 50%;
    z-index: 60;
    padding: 10px 18px;
    border-radius: 10px;
    background: rgba(31, 35, 41, 0.92);
    color: #ffffff;
    font-size: 13px;
    transform: translateX(-50%);
}

@media (max-width: 640px) {
    .container {
        padding: 20px 16px 64px;
    }

    .option-row,
    .option-row.no-jump {
        grid-template-columns: 1fr;
    }

    .topbar {
        padding: 0 16px;
    }

    .hint {
        display: none;
    }
}
