:root {
    --bg: #f4efe7;
    --card: #fffdf8;
    --ink: #2d2419;
    --muted: #756756;
    --line: #382f26;
    --soft-line: #cdbda7;
    --accent: #7d2222;
    --accent-soft: #f0d9d9;
    --success: #21613d;
    --success-soft: #ddf2e4;
    --warning: #8a5a16;
    --warning-soft: #faecd5;
    --archive: #5a5a5a;
    --archive-soft: #ececec;
    --shadow: 0 14px 40px rgba(49, 33, 14, 0.08);
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    color: var(--ink);
    font-family: "Noto Serif SC", "Songti SC", "STSong", serif;
    background:
        radial-gradient(circle at top left, rgba(173, 120, 61, 0.09), transparent 30%),
        linear-gradient(180deg, #f8f3ec 0%, #f1e8da 100%);
}

a {
    color: inherit;
}

.page-shell {
    width: min(1120px, calc(100% - 32px));
    margin: 32px auto 48px;
}

.card {
    background: var(--card);
    border: 1px solid rgba(56, 47, 38, 0.14);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.hero-card,
.admin-card,
.sheet,
.table-card {
    background: var(--card);
    border: 1px solid rgba(56, 47, 38, 0.14);
    border-radius: 18px;
    box-shadow: var(--shadow);
}

.hero-card,
.admin-card,
.table-card {
    padding: 28px;
}

.page-title {
    margin: 0 0 10px;
    font-size: clamp(28px, 4vw, 42px);
    line-height: 1.15;
}

.page-subtitle,
.muted,
.field-tip,
.privacy-note,
.empty-tip {
    color: var(--muted);
}

.split-grid {
    display: grid;
    grid-template-columns: 1.1fr 0.9fr;
    gap: 24px;
    align-items: start;
}

.feature-list,
.info-list {
    margin: 18px 0 0;
    padding-left: 20px;
    line-height: 1.7;
}

.query-form,
.stack-form {
    display: grid;
    gap: 18px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
}

.form-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px;
}

.field {
    display: grid;
    gap: 8px;
}

.field.full {
    grid-column: 1 / -1;
}

label,
.field-label {
    font-size: 14px;
    font-weight: 700;
}

input,
select,
textarea,
button {
    font: inherit;
}

input,
select,
textarea {
    width: 100%;
    padding: 12px 14px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--soft-line);
    border-radius: 12px;
    outline: none;
    transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

textarea {
    min-height: 140px;
    resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
    border-color: rgba(125, 34, 34, 0.5);
    box-shadow: 0 0 0 4px rgba(125, 34, 34, 0.08);
}

.btn-row,
.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border: none;
    border-radius: 999px;
    cursor: pointer;
    text-decoration: none;
    transition: transform 0.18s ease, opacity 0.18s ease, box-shadow 0.18s ease;
}

.btn:hover {
    transform: translateY(-1px);
}

.btn-primary {
    color: #fff;
    background: linear-gradient(135deg, #8f2b2b, #631919);
    box-shadow: 0 10px 18px rgba(99, 25, 25, 0.18);
}

.btn-light {
    color: var(--ink);
    background: #f5ece1;
}

.btn-outline {
    color: var(--ink);
    background: transparent;
    border: 1px solid var(--soft-line);
}

.alert-group {
    display: grid;
    gap: 12px;
    margin-bottom: 18px;
}

.alert {
    padding: 14px 16px;
    border-radius: 14px;
    border: 1px solid transparent;
}

.alert-success {
    background: var(--success-soft);
    border-color: rgba(33, 97, 61, 0.2);
}

.alert-error {
    background: var(--accent-soft);
    border-color: rgba(125, 34, 34, 0.18);
}

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

.brand-title {
    margin: 0;
    font-size: 24px;
}

.section-title {
    margin: 0 0 10px;
    font-size: 24px;
}

.topbar-meta {
    color: var(--muted);
    font-size: 14px;
}

.sheet-scroll {
    display: grid;
    gap: 24px;
}

.sheet {
    position: relative;
    padding: 28px;
    background:
        linear-gradient(180deg, rgba(200, 180, 150, 0.08), transparent 90px),
        #fff;
}

.sheet-page-number {
    position: absolute;
    top: 18px;
    right: 28px;
    font-size: 18px;
}

.sheet-header {
    text-align: center;
    margin-bottom: 18px;
}

.sheet-header h1 {
    margin: 8px 0 6px;
    font-size: 26px;
}

.sheet-header p {
    margin: 0;
    font-size: 18px;
    letter-spacing: 0.02em;
}

.sheet-meta {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    margin-top: 16px;
    text-align: left;
}

.sheet-toolbar {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.sheet-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.sheet-table th,
.sheet-table td {
    padding: 10px 12px;
    border: 1.4px solid var(--line);
    vertical-align: top;
    word-break: break-word;
}

.sheet-table th span,
.pledge-table span {
    color: var(--muted);
    font-size: 13px;
    font-weight: 400;
}

.center-text {
    text-align: center;
}

.section-heading {
    text-align: left;
    background: rgba(245, 236, 225, 0.7);
}

.photo-cell {
    width: 170px;
    text-align: center;
    vertical-align: middle;
}

.photo-placeholder,
.member-photo {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 128px;
    height: 168px;
    margin: 0 auto;
    border: 1px dashed rgba(56, 47, 38, 0.45);
    background: #faf6f1;
}

.photo-placeholder {
    font-size: 24px;
    letter-spacing: 0.2em;
}

.member-photo {
    object-fit: cover;
    background: #fff;
}

.text-block-cell {
    padding: 0;
}

.lined-text {
    padding: 10px 12px;
    white-space: pre-wrap;
    line-height: 40px;
    background-image: linear-gradient(to bottom, transparent 38px, rgba(56, 47, 38, 0.22) 39px, transparent 40px);
    background-size: 100% 40px;
    min-height: 160px;
}

.lines-5 {
    min-height: 200px;
}

.lines-9 {
    min-height: 360px;
}

.lines-10 {
    min-height: 400px;
}

.pledge-table {
    margin-top: 20px;
}

.pledge-title {
    font-size: 20px;
    padding-top: 18px;
    padding-bottom: 18px;
}

.privacy-note {
    margin: 16px 0 0;
}

.proof-preview-image,
.proof-preview-pdf {
    display: block;
    width: 100%;
    border: 1px solid #eadfce;
    border-radius: 16px;
    background: #fff;
}

.proof-preview-image {
    max-height: 720px;
    object-fit: contain;
}

.proof-preview-pdf {
    min-height: 720px;
}

.table-card table {
    width: 100%;
    border-collapse: collapse;
}

.table-card th,
.table-card td {
    padding: 14px 12px;
    border-bottom: 1px solid #eadfce;
    text-align: left;
}

.table-card th {
    color: var(--muted);
    font-weight: 700;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
}

.status-pending {
    color: var(--warning);
    background: var(--warning-soft);
}

.status-approved {
    color: var(--success);
    background: var(--success-soft);
}

.status-archived {
    color: var(--archive);
    background: var(--archive-soft);
}

.auth-shell {
    width: min(560px, calc(100% - 32px));
    margin: 48px auto;
}

.empty-state {
    padding: 32px;
    text-align: center;
}

.inline-text {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.inline-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 700;
}

.chip-safe {
    color: var(--success);
    background: var(--success-soft);
}

.chip-warn {
    color: var(--warning);
    background: var(--warning-soft);
}

.security-panel {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
}

.mfa-secret-box,
.mfa-uri-box {
    border: 1px solid #eadfce;
    border-radius: 16px;
    background: #fffaf4;
}

.mfa-secret-box {
    margin-top: 18px;
    padding: 18px;
}

.mfa-secret-value,
.mfa-uri-box {
    font-family: "SFMono-Regular", "Menlo", monospace;
    word-break: break-all;
}

.mfa-secret-value {
    margin-top: 8px;
    font-size: 24px;
    letter-spacing: 0.18em;
}

.mfa-uri-box {
    margin-top: 12px;
    padding: 14px 16px;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 900px) {
    .split-grid,
    .form-grid,
    .form-grid-3,
    .topbar,
    .sheet-meta,
    .security-panel {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .page-shell {
        width: min(100% - 20px, 1120px);
        margin-top: 20px;
    }

    .hero-card,
    .admin-card,
    .table-card,
    .sheet {
        padding: 18px;
    }

    .sheet {
        overflow-x: auto;
    }

    .sheet-page-number {
        right: 18px;
    }
}

@media print {
    body {
        background: #fff;
    }

    .topbar,
    .hero-card,
    .admin-card,
    .table-card,
    .sheet-toolbar,
    .privacy-note,
    .no-print {
        display: none !important;
    }

    .page-shell {
        width: 100%;
        margin: 0;
    }

    .sheet {
        border: none;
        box-shadow: none;
        padding: 10mm 8mm;
        break-inside: avoid;
    }

    .sheet-break {
        page-break-before: always;
    }
}
