:root {
    --bg: #f8f4ed;
    --card: #fffdfa;
    --ink: #1c1a18;
    --accent: #0f766e;
    --accent-strong: #115e59;
    --danger: #b42318;
    --danger-bg: #fef3f2;
    --success: #065f46;
    --success-bg: #ecfdf3;
    --line: #d7cec2;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: 'Assistant', sans-serif;
    color: var(--ink);
    background: url('back.avif') no-repeat center center fixed;
    background-size: cover;
    min-height: 100vh;
    line-height: 1.5;
}

.page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 1.5rem;
}

.card {
    width: min(920px, 100%);
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: 18px;
    padding: 1.5rem;
    box-shadow: 0 14px 30px rgba(17, 24, 39, 0.08);
}

.page-header {
    display: flex;
    justify-content: center;
    margin-bottom: 0.65rem;
}

.site-logo {
    width: min(260px, 70vw);
    height: auto;
}

h1 {
    margin-top: 0;
    margin-bottom: 0.4rem;
    font-size: clamp(1.35rem, 2.2vw, 2rem);
}

.subtitle {
    margin-top: 0;
    margin-bottom: 1.2rem;
    color: #5a544e;
}

.source-material {
    margin: 0 0 1rem;
    border: 1px solid #d8d1c6;
    border-radius: 12px;
    background: #fff;
    padding: 0.8rem;
}

.source-actions {
    display: flex;
    justify-content: flex-start;
    margin-bottom: 0.65rem;
}

.source-link {
    display: inline-block;
    text-decoration: none;
    color: #fff;
    background: #3b4d62;
    border-radius: 999px;
    padding: 0.4rem 0.85rem;
    font-weight: 700;
}

.source-pdf {
    display: block;
    border: 1px solid #e8e2d8;
    border-radius: 8px;
}

.source-image {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #e8e2d8;
    display: none;
}

.form-title {
    margin: 0 0 0.8rem;
    font-size: 1.1rem;
}

.success-screen {
    border: 1px solid #b7e4c7;
    background: linear-gradient(180deg, #f3fff7 0%, #eafff2 100%);
    border-radius: 14px;
    padding: 1.25rem;
    text-align: center;
}

.success-link {
    display: inline-block;
    margin-top: 0.5rem;
    text-decoration: none;
    background: var(--accent);
    color: #fff;
    border-radius: 999px;
    padding: 0.5rem 1rem;
    font-weight: 700;
}

.success-link:hover {
    background: var(--accent-strong);
}

.entries {
    display: grid;
    gap: 0.9rem;
}

.entry-row {
    border: 1px dashed var(--line);
    border-radius: 12px;
    padding: 0.85rem;
    display: grid;
    gap: 0.8rem;
    background: #fffcf6;
}

.fields {
    display: grid;
    gap: 0.8rem;
    grid-template-columns: repeat(2, minmax(140px, 1fr));
}

label {
    display: grid;
    gap: 0.35rem;
    font-weight: 600;
}

input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    min-height: 42px;
    padding: 0.55rem 0.7rem;
    font: inherit;
    background: #fff;
}

input:focus {
    outline: 2px solid #14b8a6;
    outline-offset: 1px;
}

.actions {
    margin-top: 1rem;
    display: flex;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.signature-area {
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
    padding: 0.65rem;
}

.signature-title {
    margin: 0 0 0.35rem;
    font-weight: 700;
}

.signature-canvas {
    width: 100%;
    height: 180px;
    border: 1px dashed #b7afa5;
    border-radius: 8px;
    background: repeating-linear-gradient(-45deg,
            #fff,
            #fff 8px,
            #fdfaf4 8px,
            #fdfaf4 16px);
    touch-action: none;
}

.clear-signature-btn {
    margin-top: 0.5rem;
    background: #f0ebe3;
    color: #2d2926;
}

button {
    border: 0;
    border-radius: 10px;
    min-height: 42px;
    padding: 0.55rem 1rem;
    font: inherit;
    font-weight: 700;
    cursor: pointer;
}

#addEntryBtn,
.remove-btn {
    background: #ece7dd;
    color: #2d2926;
}

.submit-btn {
    background: var(--accent);
    color: #fff;
}

.submit-btn:hover {
    background: var(--accent-strong);
}

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

.alert {
    border-radius: 10px;
    padding: 0.7rem 0.9rem;
    margin-bottom: 1rem;
    border: 1px solid;
}

.alert p {
    margin: 0;
}

.alert-error {
    border-color: #fecdca;
    color: var(--danger);
    background: var(--danger-bg);
}

.alert-success {
    border-color: #abefc6;
    color: var(--success);
    background: var(--success-bg);
}

.page-footer {
    width: min(920px, 100%);
    margin: 1rem auto 0;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    text-align: center;
    padding: 0.55rem 0.8rem;
}

.page-footer p {
    margin: 0;
}

.admin-login-form {
    display: grid;
    gap: 0.75rem;
    max-width: 380px;
}

.admin-actions {
    display: flex;
    gap: 0.65rem;
    align-items: center;
    flex-wrap: wrap;
    margin: 0 0 1rem;
}

.admin-actions form {
    margin: 0;
}

.admin-table-wrap {
    overflow-x: auto;
    border: 1px solid #ddd4c7;
    border-radius: 10px;
    background: #fff;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    min-width: 680px;
}

.admin-table th,
.admin-table td {
    border-bottom: 1px solid #efe8dd;
    padding: 0.55rem;
    text-align: right;
    vertical-align: middle;
}

.admin-table th {
    background: #f7f2e9;
    font-weight: 700;
}

.admin-signature {
    width: 140px;
    max-width: 100%;
    height: 46px;
    object-fit: contain;
    border: 1px solid #d6ccbe;
    border-radius: 6px;
    background: #fff;
}

.empty-cell {
    text-align: center;
    color: #6a645d;
}

@media (max-width: 768px) {
    body {
        background-attachment: scroll;
    }

    .page {
        padding: 0.75rem;
        place-items: start center;
    }

    .fields {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 0.9rem;
        border-radius: 14px;
    }

    .actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .actions button,
    .remove-btn,
    .clear-signature-btn,
    .source-link {
        width: 100%;
    }

    .signature-canvas {
        height: 150px;
    }

    .source-pdf {
        display: none;
    }

    .source-image {
        display: block;
    }

    .page-footer {
        margin-top: 0.75rem;
    }

    .success-screen {
        padding: 1rem;
    }

    .admin-actions {
        display: grid;
        grid-template-columns: 1fr;
    }

    .admin-actions .source-link,
    .admin-actions .remove-btn {
        width: 100%;
        text-align: center;
    }

    .admin-signature {
        width: 120px;
    }
}