 :root {
    color-scheme: light;
    --ink: #1c2430;
    --muted: #627084;
    --line: #d7dde6;
    --soft: #f5f7fa;
    --accent: #0f766e;
    --danger: #b42318;
}
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: Arial, Helvetica, sans-serif;
    color: var(--ink);
    background: #eef1f5;
}
main {
    width: min(980px, calc(100% - 24px));
    margin: 24px auto;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: clamp(18px, 4vw, 36px);
}
.document {
    max-width: 900px;
    background: #fff;
    border: 1px solid #cfd6df;
    box-shadow: 0 12px 30px rgba(28, 36, 48, 0.08);
    padding: clamp(22px, 5vw, 54px);
}
.document-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 30px;
    border-top: 8px solid #2e333a;
    padding-top: 18px;
}
.document-header img {
    width: min(190px, 46vw);
    height: auto;
    object-fit: contain;
}
.simple-header {
    display: flex;
    justify-content: center;
    margin-bottom: 22px;
}
.simple-header img {
    width: min(180px, 50vw);
    height: auto;
    object-fit: contain;
}
.document-meta {
    display: grid;
    justify-items: end;
    gap: 4px;
    color: var(--muted);
    font-size: 13px;
    text-align: right;
    text-transform: uppercase;
}
.document-meta strong {
    color: var(--ink);
    font-size: 18px;
}
h1 {
    margin: 0 0 24px;
    text-align: center;
    font-size: clamp(22px, 4vw, 32px);
    text-decoration: underline;
}
h2 {
    margin: 24px 0 12px;
    font-size: 20px;
    text-decoration: underline;
}
.grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 14px 18px;
}
label {
    display: grid;
    gap: 6px;
    font-weight: 700;
    font-size: 14px;
}
input, textarea, select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 10px 12px;
    font: inherit;
    background: #fff;
}
textarea { min-height: 88px; resize: vertical; }
.full { grid-column: 1 / -1; }
.narrow { max-width: 420px; margin: 0 auto; }
.logout { display: flex; justify-content: flex-end; margin: -12px 0 12px; }
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
}
.table-wrap {
    overflow-x: auto;
}
th, td {
    border: 1px solid var(--line);
    padding: 10px;
    text-align: left;
    vertical-align: top;
    word-break: break-word;
}
th { background: var(--soft); }
a {
    color: #0b4f8a;
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}
canvas {
    width: 100%;
    height: 170px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    touch-action: none;
}
.readonly {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 18px;
}
.readonly div {
    border-bottom: 1px solid var(--line);
    padding: 8px 0;
    overflow-wrap: anywhere;
}
.document .readonly div {
    min-height: 44px;
    border-bottom-color: #9fa8b4;
}
.readonly strong {
    display: block;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 3px;
}
.hash-box {
    display: inline-block;
    max-width: 100%;
    padding: 6px 10px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--soft);
    font-family: Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    overflow-wrap: anywhere;
}
.signature-preview {
    display: block;
    width: min(460px, 100%);
    max-height: 220px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    object-fit: contain;
    padding: 8px;
}
.actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 18px;
}
button {
    border: 0;
    border-radius: 6px;
    padding: 11px 16px;
    font-weight: 700;
    cursor: pointer;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: #e7ebf0; color: var(--ink); }
.danger { background: #b42318; color: #fff; }
.message {
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 18px;
}
.share-link {
    min-width: 280px;
    font-size: 12px;
}
.share-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}
.copy-btn {
    white-space: nowrap;
}
.success { background: #e7f7ef; color: #05603a; }
.error { background: #fdecec; color: var(--danger); }
.note {
    color: var(--muted);
    line-height: 1.5;
}
@media (max-width: 720px) {
    main {
        width: calc(100% - 16px);
        margin: 8px auto;
        padding: 14px;
    }
    .grid, .readonly { grid-template-columns: 1fr; }
    .document-header {
        display: grid;
        justify-items: start;
    }
    .document-meta {
        justify-items: start;
        text-align: left;
    }
    table, thead, tbody, tr, th, td { display: block; width: 100%; }
    thead { display: none; }
    td { border-top: 0; }
    td::before {
        content: attr(data-label);
        display: block;
        font-weight: 700;
        margin-bottom: 6px;
    }
}

@media (max-width: 480px) {
    h1 {
        font-size: 24px;
    }
    h2 {
        font-size: 18px;
    }
    button {
        width: 100%;
    }
    .actions {
        flex-direction: column;
    }
    .share-actions {
        flex-direction: column;
        align-items: stretch;
    }
    .share-link {
        min-width: 0;
    }
    .signature-preview {
        max-height: 180px;
    }
}
