:root {
    --bg: #ffffff;
    --panel: #ffffff;
    --ink: #111111;
    --muted: #555555;
    --line: #d2d2d2;
    --brand: #222222;
    --brand-dark: #000000;
    --accent: #f4b400;
    --shadow: none;
    --radius: 0;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    color: var(--ink);
    background: #ffffff;
    overflow: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

.page-shell {
    height: 100vh;
    display: grid;
    grid-template-columns: 48% 52%;
    justify-content: stretch;
    gap: 0;
    padding: 0;
}

.centered-page {
    grid-template-columns: minmax(320px, 1100px);
    justify-content: center;
    align-content: center;
}

.home-panel {
    text-align: center;
}

.home-title {
    margin: 0 0 20px;
    font-size: 2rem;
}

.home-actions {
    justify-content: center;
    flex-wrap: nowrap;
    overflow-x: auto;
}

.home-actions .button {
    white-space: nowrap;
}

.panel {
    background: var(--panel);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.form-sidebar {
    padding: 18px 20px;
    overflow: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--line);
}

.preview-panel {
    padding: 8px;
    overflow: hidden;
    height: 100vh;
}

.preview-card {
    background: #ffffff;
    border: 0;
    border-radius: 0;
    padding: 0;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.form-preview {
    position: relative;
    width: 100%;
    max-height: 100%;
    display: flex;
    justify-content: center;
}

.form-preview img {
    width: auto;
    max-width: 100%;
    max-height: calc(100vh - 16px);
    display: block;
    border-radius: 0;
    object-fit: contain;
}

.pdf-preview-frame {
    height: 100%;
    align-items: stretch;
}

.pdf-preview-frame iframe {
    width: 100%;
    height: 100%;
    border: 0;
    background: #ffffff;
}

.intro-panel,
.wide-panel {
    padding: 20px;
}

.wide-panel {
    max-width: 1200px;
    width: 100%;
}

.eyebrow {
    margin: 0 0 8px;
    color: #555555;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: 0.78rem;
}

h1 {
    margin: 0 0 12px;
    font-size: 1.1rem;
}

.muted,
p {
    color: var(--muted);
}

.back-link {
    display: inline-flex;
    margin-bottom: 12px;
    color: #000000;
    font-weight: 400;
}

.field-grid {
    display: grid;
    gap: 14px;
}

.compact-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px 14px;
}

.field {
    display: grid;
    gap: 6px;
}

.signature-field {
    grid-column: 1 / -1;
}

.field span,
.detail-item strong {
    font-size: 0.88rem;
    font-weight: 700;
}

input,
textarea,
select {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 3px;
    padding: 8px 10px;
    font: inherit;
    color: var(--ink);
    background: #ffffff;
}

textarea {
    min-height: 120px;
    resize: vertical;
}

.signature-pad {
    border: 1px solid var(--line);
    background: #ffffff;
    border-radius: 3px;
    overflow: hidden;
}

.signature-pad canvas {
    display: block;
    width: 100%;
    height: 140px;
    background: #ffffff;
    touch-action: none;
    cursor: crosshair;
}

.signature-actions {
    display: flex;
    justify-content: flex-end;
}

.choices {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.choice {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 7px 10px;
}

.choice input {
    width: auto;
    margin: 0;
}

.field-error {
    color: #c0362c;
    font-size: 0.85rem;
}

.submit-bar,
.actions,
.table-header {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    align-items: center;
}

.submit-bar {
    margin-top: 14px;
    justify-content: flex-end;
}

.step-tabs {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-bottom: 12px;
}

.step-tab {
    border: 1px solid var(--line);
    border-radius: 3px;
    background: #ffffff;
    color: #222222;
    padding: 8px 6px;
    font: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
}

.step-tab.is-active {
    background: #222222;
    color: #fff;
    border-color: #222222;
}

.step-panel {
    display: none;
    flex: 1;
}

.step-panel.is-active {
    display: block;
}

.step-actions {
    display: flex;
    gap: 12px;
    justify-content: space-between;
    margin-top: 12px;
}

.table-header {
    justify-content: space-between;
    margin-bottom: 18px;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #222222;
    border-radius: 3px;
    background: #222222;
    color: #fff;
    padding: 9px 12px;
    font-weight: 700;
    cursor: pointer;
}

.button.secondary {
    background: #ffffff;
    color: #222222;
    border: 1px solid var(--line);
}

.table-wrap {
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: 0;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    text-align: left;
    padding: 14px 16px;
    border-bottom: 1px solid var(--line);
}

th {
    background: #f3f3f3;
}

.actions-cell {
    display: flex;
    gap: 12px;
}

.actions-cell a {
    color: var(--brand);
    font-weight: 600;
}

.details-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
}

.admin-submission-sidebar {
    overflow-y: auto;
}

.admin-submission-header {
    align-items: flex-start;
}

.admin-details-grid {
    grid-template-columns: 1fr;
}

.detail-item {
    display: grid;
    gap: 6px;
    border: 1px solid var(--line);
    border-radius: 0;
    padding: 14px;
    background: #ffffff;
}

.auth-panel {
    width: 100%;
    max-width: 420px;
}

.auth-form {
    display: grid;
    gap: 12px;
}

.submission-preview-wrap {
    margin-bottom: 18px;
    border: 1px solid var(--line);
    padding: 12px;
    overflow: auto;
    background: #ffffff;
}

.submission-preview-image {
    display: block;
    max-width: 100%;
    height: auto;
    margin: 0 auto;
}

.submission-preview {
    max-height: 100%;
    height: 100%;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    background: #f3f3f3;
}

.submission-preview-image {
    width: 100%;
    max-width: none;
    height: auto;
    margin: 0;
}

.submission-preview-frame {
    width: 100%;
    height: 100%;
    min-height: calc(100vh - 16px);
    border: 0;
    background: #ffffff;
}

.empty-state {
    padding: 28px;
    border: 1px dashed var(--line);
    border-radius: 0;
    background: #ffffff;
}

.calibration-page {
    display: grid;
    grid-template-columns: 360px 1fr;
    height: 100vh;
}

.calibration-sidebar {
    border-right: 1px solid var(--line);
    padding: 16px;
    overflow: auto;
}

.calibration-toolbar,
.calibration-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.calibration-editor {
    border: 1px solid var(--line);
    padding: 12px;
    margin-top: 12px;
}

.calibration-list {
    margin-top: 12px;
    font-size: 0.9rem;
    color: var(--muted);
}

.calibration-stage {
    overflow: auto;
    padding: 16px;
    background: #f7f7f7;
}

.calibration-canvas-wrap {
    position: relative;
    display: inline-block;
    line-height: 0;
}

.calibration-image {
    max-width: calc(100vw - 420px);
    max-height: calc(100vh - 32px);
    display: block;
}

.calibration-marker {
    position: absolute;
    transform: translateY(-100%);
    border: 1px dashed #d22;
    background: rgba(255, 255, 255, 0.85);
    color: #0b3f8e;
    font-size: 12px;
    padding: 2px 4px;
    cursor: move;
    line-height: 1.1;
    min-width: 24px;
}

.calibration-marker.active {
    border-style: solid;
    border-color: #222;
    background: #fff6d8;
}

.calibration-marker.mark {
    transform: translate(-50%, -60%);
    min-width: 0;
    padding: 2px 4px;
    font-weight: 700;
}


@media (max-width: 1024px) {
    body {
        overflow: auto;
    }

    .page-shell {
        grid-template-columns: 1fr;
        height: auto;
        justify-content: stretch;
    }

    .form-sidebar {
        height: auto;
        overflow: visible;
        border-right: 0;
    }

    .preview-panel {
        height: auto;
        overflow: visible;
    }

    .preview-card {
        height: auto;
    }

    .form-preview img {
        width: 100%;
        max-height: none;
    }

    .compact-grid,
    .step-tabs {
        grid-template-columns: 1fr;
    }

    .home-actions {
        flex-wrap: wrap;
        overflow-x: visible;
    }

    .calibration-page {
        grid-template-columns: 1fr;
        height: auto;
    }

    .calibration-image {
        max-width: 100%;
        max-height: none;
    }
}
