:root {
    color-scheme: light;
    font-family: Arial, Helvetica, sans-serif;
    background: #f3f5f8;
    color: #263248;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
}

.panel {
    width: min(100%, 660px);
    background: #ffffff;
    border: 1px solid #dce3ed;
    border-radius: 16px;
    padding: clamp(20px, 5vw, 40px);
    box-shadow: 0 12px 36px rgb(21 39 70 / 7%);
}

.brand {
    color: #17365b;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: 0.07em;
}

.brand span {
    color: #7d899b;
    font-size: 11px;
    font-weight: 600;
}

h1 {
    font-size: 26px;
    margin: 30px 0 12px;
}

h2 {
    font-size: 18px;
    margin-top: 32px;
}

p {
    line-height: 1.55;
}

label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin: 16px 0;
}

input,
textarea {
    display: block;
    width: 100%;
    margin-top: 7px;
    padding: 12px;
    font: inherit;
    border: 1px solid #bac5d5;
    border-radius: 8px;
}

textarea {
    min-height: 95px;
}

button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    padding: 13px;
    margin-top: 12px;
    background: #17365b;
    color: #ffffff;
    font-weight: 700;
    cursor: pointer;
}

button.secondary {
    background: #e7edf4;
    color: #17365b;
}

.error {
    color: #a52c35;
}

.hint {
    font-size: 13px;
    color: #66748b;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

th,
td {
    padding: 12px 8px;
    border-bottom: 1px solid #e3e9f0;
    text-align: left;
}

/* Cadastro do cliente - etapas e salvamento */
.draft-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    margin-top: 24px;
    color: #51637b;
    font-size: 13px;
}

.progress-track {
    height: 8px;
    background: #e7edf4;
    border-radius: 999px;
    overflow: hidden;
    margin: 12px 0 24px;
}

.progress-fill {
    height: 100%;
    width: 0;
    background: #17365b;
    transition: width 180ms ease;
}

.draft-step[hidden],
.draft-actions button[hidden] {
    display: none;
}

.draft-actions {
    display: flex;
    gap: 12px;
}

.draft-actions button {
    flex: 1;
}

.review-data dt {
    color: #61738b;
    font-size: 13px;
    margin-top: 16px;
}

.review-data dd {
    margin: 5px 0 0;
    overflow-wrap: anywhere;
}

#save-status[data-state="error"] {
    color: #a52c35;
}

/* Formulário completo do cliente */
body:has(#draft-form) {
    display: block;
    padding: 30px 16px;
}

body:has(#draft-form) .panel {
    max-width: 1080px;
    width: 100%;
    margin: 0 auto;
}

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

.form-grid label {
    min-width: 0;
}

select,
textarea {
    display: block;
    width: 100%;
    margin-top: 8px;
    border: 1px solid #bcc9d9;
    border-radius: 8px;
    background: #ffffff;
    padding: 12px;
    font: inherit;
    color: #263248;
}

input[readonly] {
    background: #f1f4f8;
}

.upload-box {
    padding: 20px;
    border: 1px solid #dce3ed;
    border-radius: 12px;
    margin-bottom: 18px;
}

.upload-box h3 {
    margin: 0 0 8px;
    font-size: 16px;
}

.upload-drop {
    border: 2px dashed #b7c8dc;
    border-radius: 10px;
    padding: 28px 16px;
    text-align: center;
    color: #51637b;
    background: #f8fafc;
}

.upload-drop.dragging {
    border-color: #17365b;
    background: #edf3fa;
}

.upload-buttons {
    display: flex;
    gap: 12px;
}

.upload-buttons button {
    flex: 1;
}

.upload-preview {
    margin-top: 18px;
    padding: 16px;
    background: #f4f7fb;
    border-radius: 10px;
}

.upload-preview[hidden],
.take-photo[hidden] {
    display: none;
}

.preview-content img,
.preview-content iframe {
    width: 100%;
    max-height: 460px;
    object-fit: contain;
    border: 0;
}

.preview-content iframe {
    height: 440px;
}

.attachment-list {
    padding-left: 20px;
    overflow-wrap: anywhere;
}

.attachment-list li {
    padding: 8px 0;
}

.attachment-list button {
    width: auto;
    padding: 7px 12px;
    margin: 0 0 0 8px;
}

.review-data {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 20px;
}

@media (max-width: 650px) {
    .form-grid,
    .review-data {
        grid-template-columns: 1fr;
    }

    .upload-buttons {
        flex-direction: column;
        gap: 0;
    }
}

/* Controles de anexos: seletores de arquivo nativos permanecem ocultos. */
.upload-box[hidden],
.file-picker[hidden],
.camera-picker[hidden],
.upload-preview[hidden],
.take-photo[hidden] {
    display: none;
}

.upload-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.upload-drop button {
    width: auto;
    min-width: 160px;
    margin: 0;
}

.document-kind {
    border: 1px solid #dce3ed;
    border-radius: 10px;
    margin: 18px 0 8px;
    padding: 14px;
}

.document-kind label {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    margin-right: 20px;
}

.document-kind input {
    width: auto;
}

/* Cadastro em etapas: largura adequada para formularios extensos. */
body:has(.draft-head) .panel {
    width: min(100%, 1080px);
}

body:has(.draft-head) .form-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

@media (max-width: 650px) {
    body:has(.draft-head) .form-grid {
        grid-template-columns: 1fr;
    }
}

/* Fluxo final - documentos assinados */
.declaration-consent {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin: 24px 0;
    line-height: 1.5;
}

.declaration-consent input[type="checkbox"] {
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin: 2px 0 0;
    padding: 0;
}

#signed-documents {
    margin: 28px 0;
}

#signed-documents[hidden],
#draft-form[hidden],
.draft-head[hidden],
.progress-track[hidden],
.declaration-consent[hidden] {
    display: none;
}

.signed-document {
    margin: 20px 0;
    padding: 20px;
    border: 1px solid #dce3ed;
    border-radius: 12px;
}

.signed-document h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.signed-document .upload-box {
    margin: 16px 0 0;
}

.draft-actions button {
    min-width: 0;
}

@media (max-width: 650px) {
    .draft-actions {
        flex-direction: column;
        gap: 0;
    }

    .signed-document {
        padding: 14px;
    }
}

/* Acoes dos PDFs gerados - Portal do cliente */
.signed-document-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
}

.signed-document-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    min-height: 42px;
    padding: 10px 16px;
    border: 1px solid #cbd6e3;
    border-radius: 9px;
    background: #f5f8fc;
    color: #17365b;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.signed-document-action:hover,
.signed-document-action:focus-visible {
    background: #e7eef7;
    border-color: #8ea8c6;
    text-decoration: none;
}

.signed-document-action:focus-visible {
    outline: 2px solid #17365b;
    outline-offset: 3px;
}

.signed-document-action svg {
    flex: none;
    width: 19px;
    height: 19px;
}

.signed-document-action-download {
    background: #17365b;
    border-color: #17365b;
    color: #ffffff;
}

.signed-document-action-download:hover,
.signed-document-action-download:focus-visible {
    background: #254b78;
    border-color: #254b78;
}

@media (max-width: 480px) {
    .signed-document-action {
        flex: 1 1 auto;
    }
}
