:root {
    --bg: #eef1f4;
    --surface: #ffffff;
    --ink: #17191c;
    --muted: #68717c;
    --line: #d8dde3;
    --accent: #e86f1a;
    --accent-dark: #c9560d;
    --focus: rgba(232,111,26,.24);
    --shadow: 0 18px 55px rgba(19, 27, 38, .10);
}

* { box-sizing: border-box; }
html { background: var(--bg); }
body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: Arial, Helvetica, sans-serif;
    -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }

.app-header {
    position: sticky;
    top: 0;
    z-index: 50;
    background: rgba(255,255,255,.96);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(12px);
}
.header-inner {
    max-width: 1180px;
    margin: 0 auto;
    padding: 18px 22px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
}
.eyebrow {
    color: var(--accent);
    font-weight: 800;
    font-size: 11px;
    letter-spacing: .13em;
}
h1 { margin: 3px 0 2px; font-size: 24px; line-height: 1.1; }
.header-inner p { margin: 0; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; }

.primary-btn, .secondary-btn {
    min-height: 42px;
    border-radius: 10px;
    padding: 0 16px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
    transition: .18s ease;
}
.primary-btn { background: var(--accent); color: white; }
.primary-btn:hover { background: var(--accent-dark); transform: translateY(-1px); }
.primary-btn:disabled { opacity: .55; cursor: wait; transform: none; }
.secondary-btn { background: #fff; color: #24272b; border-color: var(--line); }
.secondary-btn:hover { border-color: #aab2bc; }
.primary-btn.large { min-height: 48px; padding: 0 22px; }

.app-shell { max-width: 1040px; margin: 26px auto 70px; padding: 0 18px; }
.document-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
}
.page-caption {
    min-height: 52px;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    border-bottom: 1px solid var(--line);
    background: #fbfbfc;
    color: var(--muted);
    font-size: 13px;
}
.page-caption strong { color: var(--ink); }
.page-scroll { padding: 18px; overflow-x: auto; background: #e7e9ec; }
.pdf-page {
    position: relative;
    width: 794px;
    max-width: none;
    margin: 0 auto;
    background: white;
    box-shadow: 0 3px 15px rgba(0,0,0,.15);
    overflow: hidden;
}
.pdf-page > img { width: 100%; height: auto; display: block; user-select: none; pointer-events: none; }
.interactive-page { container-type: inline-size; }
.pdf-input {
    position: absolute;
    z-index: 5;
    border: 0;
    margin: 0;
    padding: 0 5px;
    background: rgba(255,255,255,.02);
    color: #111;
    outline: none;
    border-radius: 2px;
    font-size: 1.45cqw;
    line-height: 1;
}
.pdf-input:hover { background: rgba(255,255,255,.28); }
.pdf-input:focus {
    background: rgba(255,255,255,.90);
    box-shadow: inset 0 0 0 2px var(--accent), 0 0 0 4px var(--focus);
    z-index: 10;
}

.signature-grid {
    padding: 18px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    border-top: 1px solid var(--line);
}
.signature-card {
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 13px;
    background: #fbfcfd;
}
.signature-title { font-size: 13px; font-weight: 700; margin-bottom: 10px; }
.signature-pad {
    display: block;
    width: 100%;
    height: 170px;
    background: #fff;
    border: 1px dashed #aeb6bf;
    border-radius: 8px;
    touch-action: none;
    cursor: crosshair;
}
.text-btn {
    margin-top: 8px;
    padding: 4px 0;
    background: transparent;
    border: 0;
    color: #555e67;
    cursor: pointer;
    text-decoration: underline;
}

.submit-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    box-shadow: var(--shadow);
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 22px;
}
.submit-card strong { font-size: 17px; }
.submit-card p { margin: 5px 0 0; color: var(--muted); font-size: 13px; max-width: 660px; }
.status { min-height: 24px; margin-top: 12px; font-size: 13px; font-weight: 700; }
.status.ok { color: #176b3a; }
.status.error { color: #ad2525; }
.status.busy { color: #72510d; }

@media (max-width: 820px) {
    .header-inner { align-items: flex-start; flex-direction: column; }
    .header-actions { width: 100%; justify-content: stretch; }
    .header-actions > * { flex: 1; }
    .pdf-page { width: 720px; }
    .signature-grid { grid-template-columns: 1fr; }
    .submit-card { align-items: stretch; flex-direction: column; }
    .submit-card .primary-btn { width: 100%; }
}

@media print {
    .app-header, .page-caption, .signature-grid, .submit-card, .status { display: none !important; }
    body, .app-shell, .document-card, .page-scroll { background: white !important; margin: 0 !important; padding: 0 !important; border: 0 !important; box-shadow: none !important; }
    .document-card { break-after: page; }
    .pdf-page { width: 210mm; box-shadow: none; }
    .pdf-input { border: 0; box-shadow: none; }
}
