:root {
    --bg: #efe9df;
    --bg-deep: #d8ccb9;
    --panel: rgba(255, 255, 255, 0.84);
    --panel-strong: #ffffff;
    --line: rgba(130, 106, 79, 0.18);
    --text: #221d18;
    --muted: #6c655d;
    --accent: #5d4b38;
    --accent-strong: #3d2f22;
    --accent-soft: #efe4d4;
    --success: #1f6a43;
    --danger: #8a3030;
    --shadow: 0 24px 48px rgba(44, 35, 24, 0.09);
}

* {
    box-sizing: border-box;
}

html {
    min-height: 100%;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: "Segoe UI", Arial, sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255,255,255,.65), transparent 28%),
        radial-gradient(circle at top right, rgba(208,190,165,.38), transparent 22%),
        linear-gradient(180deg, #f7f3ec 0%, var(--bg) 52%, #e4d8c7 100%);
}

p,
li,
.summary-line,
.detail-block,
.preview-pane pre {
    text-align: justify;
}

a {
    color: inherit;
}

.page-background {
    position: fixed;
    inset: 0;
    background:
        linear-gradient(135deg, rgba(255,255,255,.22), transparent 32%),
        linear-gradient(225deg, rgba(108,84,58,.05), transparent 35%);
    pointer-events: none;
}

.layout-shell {
    position: relative;
    width: min(1280px, calc(100% - 32px));
    margin: 22px auto;
}

.layout {
    display: grid;
    grid-template-columns: 292px minmax(0, 1fr);
    min-height: calc(100vh - 44px);
    border: 1px solid rgba(112, 92, 70, 0.14);
    border-radius: 28px;
    overflow: hidden;
    background: rgba(248, 244, 238, 0.58);
    box-shadow: var(--shadow);
    backdrop-filter: blur(18px);
}

.sidebar {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    gap: 26px;
    padding: 30px 26px;
    background:
        linear-gradient(180deg, rgba(37, 31, 26, 0.96) 0%, rgba(28, 24, 20, 0.98) 100%);
    color: #f7f0e5;
    border-right: 1px solid rgba(255,255,255,.06);
}

.brand-block {
    display: grid;
    gap: 12px;
}

.brand-kicker {
    display: inline-flex;
    width: fit-content;
    min-height: 28px;
    align-items: center;
    padding: 0 10px;
    border-radius: 999px;
    background: rgba(239, 228, 212, 0.12);
    color: #d8c4a7;
    font-size: 12px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.sidebar h1 {
    margin: 0;
    font-size: 40px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.sidebar p {
    margin: 0;
    color: #cbbca7;
    line-height: 1.7;
    font-size: 14px;
}

.sidebar-nav {
    display: grid;
    gap: 10px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    min-height: 44px;
    padding: 0 14px;
    border-radius: 14px;
    color: #efe6d9;
    text-decoration: none;
    background: rgba(255,255,255,.03);
    border: 1px solid transparent;
    transition: background .18s ease, border-color .18s ease, transform .18s ease;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,.07);
    border-color: rgba(255,255,255,.08);
    transform: translateX(2px);
}

.sidebar-user {
    padding: 18px 16px;
    border: 1px solid rgba(255,255,255,.08);
    border-radius: 18px;
    background: rgba(255,255,255,.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.sidebar-user a {
    color: #f8f5ef;
    text-decoration: none;
    white-space: nowrap;
    font-size: 13px;
}

.content {
    padding: 26px;
    min-width: 0;
}

.content-inner {
    display: grid;
    gap: 20px;
}

.grid {
    display: grid;
    gap: 20px;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: 24px;
    padding: 24px;
    box-shadow: 0 14px 28px rgba(41, 36, 29, 0.04);
    backdrop-filter: blur(10px);
}

.label {
    display: inline-block;
    background: var(--accent-soft);
    color: var(--accent-strong);
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

.metric {
    font-size: 46px;
    line-height: 1;
    margin: 16px 0 10px;
    letter-spacing: -0.05em;
}

.analysis-topline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.analysis-metrics {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.metric-card {
    display: grid;
    gap: 6px;
    width: 100%;
    text-align: center;
    padding: 6px 10px;
    border-radius: 18px;
    border: 1px solid var(--line);
    background: rgba(252, 251, 249, 0.88);
}

.metric-card span {
    font-size: 22px;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.analysis-grid {
    align-items: start;
}

.muted {
    color: var(--muted);
    text-align: justify;
}

.page-header {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
    margin-bottom: 4px;
}

.workflow-nav {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.workflow-step {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 46px;
    padding: 0 12px;
    border-radius: 14px;
    border: 1px solid var(--line);
    text-decoration: none;
    background: rgba(255,255,255,.72);
    color: var(--muted);
    font-weight: 700;
}

.workflow-step-current {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.workflow-step-completed {
    background: rgba(217, 239, 226, 0.85);
    color: var(--success);
    border-color: rgba(31, 106, 67, 0.18);
}

.workflow-step-upcoming {
    background: rgba(255,255,255,.7);
}

.page-header h2 {
    margin: 12px 0 10px;
    font-size: clamp(32px, 3vw, 52px);
    line-height: 1.02;
    letter-spacing: -0.05em;
}

.page-header p {
    max-width: 760px;
    margin: 0;
    line-height: 1.7;
}

.header-actions {
    display: flex;
    gap: 10px;
    align-items: center;
}

.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 0 18px;
    border-radius: 14px;
    border: 1px solid var(--accent);
    background: var(--accent);
    color: #fff;
    text-decoration: none;
    cursor: pointer;
    font-weight: 700;
    box-shadow: 0 10px 20px rgba(61, 47, 34, 0.12);
    transition: transform .18s ease, box-shadow .18s ease, background .18s ease;
}

.button:hover {
    transform: translateY(-1px);
    box-shadow: 0 14px 24px rgba(61, 47, 34, 0.14);
}

.button-secondary {
    background: rgba(255,255,255,.75);
    color: var(--accent-strong);
    border-color: rgba(93, 75, 56, 0.18);
    box-shadow: none;
}

.button-danger {
    background: #8f4242;
    border-color: #8f4242;
    color: #fff;
}

.button-small {
    min-height: 36px;
    padding: 0 12px;
    font-size: 13px;
    border-radius: 12px;
}

.content-grid2 {
    width: 100%;
    gap: 20px;
    margin-bottom: 20px;
}

.content-grid {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.form-stack {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

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

.field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.field input,
.field select,
.field textarea {
    width: 100%;
    border: 1px solid var(--line);
    background: rgba(252, 251, 249, 0.94);
    border-radius: 16px;
    padding: 13px 15px;
    color: var(--text);
    font: inherit;
    text-align: justify;
    transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}

.field input::placeholder,
.field textarea::placeholder {
    color: #9c9082;
    text-align: left;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
    outline: none;
    border-color: rgba(93, 75, 56, 0.45);
    box-shadow: 0 0 0 4px rgba(93, 75, 56, 0.08);
    background: #fff;
}

.field textarea {
    resize: vertical;
}

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

.form-actions-stacked {
    margin-top: 18px;
    flex-direction: column;
}

.form-actions-stacked .button {
    width: 100%;
}

.model-actions {
    gap: 8px;
}

.next-step-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
}

.next-step-card h3 {
    margin-top: 8px;
}

.upload-inline {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) minmax(220px, 1.3fr) auto;
    gap: 12px;
    align-items: end;
}

.upload-category {
    min-width: 0;
}

.file-picker {
    display: inline-flex;
    align-items: center;
    min-width: 0;
    min-height: 46px;
    padding: 0 14px;
    border: 1px dashed rgba(93, 75, 56, 0.35);
    border-radius: 14px;
    background: rgba(252, 251, 249, 0.86);
    color: var(--accent-strong);
    cursor: pointer;
}

.file-picker input {
    position: absolute;
    inline-size: 1px;
    block-size: 1px;
    opacity: 0;
    pointer-events: none;
}

.file-picker span {
    display: block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 700;
}

.upload-file,
.upload-submit {
    align-self: end;
}

.ficha-import-inline {
    grid-template-columns: minmax(220px, 1fr) auto;
}

.error-text {
    color: #a43838;
}

.alert {
    display: grid;
    gap: 4px;
    border-radius: 18px;
    padding: 15px 18px;
    margin-bottom: 18px;
    border: 1px solid var(--line);
    background: rgba(255,255,255,.9);
    box-shadow: 0 12px 30px rgba(61, 47, 34, 0.06);
}

.alert strong {
    font-size: 14px;
    letter-spacing: 0.02em;
}

.alert span,
.alert li {
    line-height: 1.55;
}

.alert-success {
    border-color: #b6d5be;
    background: #eef7f0;
    color: #245234;
}

.alert-error {
    border-color: #e0b7b7;
    background: #fcf1f1;
    color: #7f2b2b;
}

.alert-info {
    border-color: #c8d5e3;
    background: #f1f6fb;
    color: #2e506f;
}

.alert-warning {
    border-color: #e3d2a8;
    background: #fbf6e7;
    color: #6d5522;
}

.confirm-modal[hidden] {
    display: none;
}

.confirm-modal {
    position: fixed;
    inset: 0;
    z-index: 80;
    display: grid;
    place-items: center;
    padding: 22px;
}

.confirm-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(31, 26, 22, 0.46);
    backdrop-filter: blur(8px);
}

.confirm-modal__panel {
    position: relative;
    z-index: 1;
    width: min(100%, 460px);
    display: grid;
    gap: 14px;
    padding: 28px;
    border: 1px solid rgba(93, 75, 56, 0.16);
    border-radius: 26px;
    background: rgba(255, 253, 249, 0.98);
    box-shadow: 0 32px 90px rgba(37, 31, 26, 0.26);
}

.confirm-modal__panel h2 {
    margin: 0;
    font-size: 28px;
    letter-spacing: -0.03em;
}

.confirm-modal__panel p {
    margin: 0;
}

.confirm-modal__actions {
    justify-content: flex-end;
    margin-top: 6px;
}

.confirm-modal--danger .confirm-modal__panel {
    border-color: rgba(143, 66, 66, 0.28);
}

.confirm-modal--danger [data-confirm-accept] {
    background: #8f4242;
    border-color: #8f4242;
}

.confirm-modal--warning .confirm-modal__panel {
    border-color: rgba(163, 123, 48, 0.28);
}

.side-panel {
    align-self: start;
}

.simple-list {
    margin: 0;
    padding-left: 18px;
    color: var(--muted);
    text-align: justify;
}

.summary-box {
    margin-top: 18px;
    border-top: 1px solid var(--line);
    padding-top: 14px;
}

.summary-item {
    display: grid;
    gap: 6px;
    margin-bottom: 14px;
}

.summary-item strong {
    font-size: 13px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.summary-item > span:not(.status-badge) {
    overflow-wrap: anywhere;
    color: var(--muted);
}

.summary-line {
    margin-bottom: 8px;
}

.table-clean {
    width: 100%;
    border-collapse: collapse;
}

.table-fixed {
    table-layout: fixed;
}

.table-clean th,
.table-clean td {
    text-align: left;
    padding: 6px 6px;
    border-bottom: 1px solid var(--line);
    vertical-align: top;
    min-width: 0;
}

.attachment-table th:nth-child(1), .attachment-table td:nth-child(1) { width: 53%; } /* Nome maior */
.attachment-table th:nth-child(2), .attachment-table td:nth-child(2) { width: 25%; } /* Categoria */
.attachment-table th:nth-child(3), .attachment-table td:nth-child(3) { width: 12%; text-align: center; } /* Tamanho */
.table-clean th:nth-child(4), .table-clean td:nth-child(4) { width: 10%; text-align: center; }  /* Ação */

.table-clean:not(.attachment-table) th,
.table-clean:not(.attachment-table) td {
    width: auto;
}

.table-clean:not(.attachment-table) th:nth-child(4),
.table-clean:not(.attachment-table) td:nth-child(4) {
    text-align: left;
}

.table-clean thead th {
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-weight: 700;
}

.table-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

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

.break-anywhere {
    word-break: break-word;
    overflow-wrap: anywhere;
}

.import-summary {
    padding: 14px 16px;
    border-radius: 16px;
    border: 1px solid var(--line);
    background: rgba(252, 251, 249, 0.88);
}

.completion-block {
    display: grid;
    gap: 8px;
}

.completion-block-compact {
    margin-bottom: 12px;
}

.completion-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}

.completion-head span {
    font-weight: 700;
    color: var(--accent-strong);
}

.completion-bar {
    position: relative;
    width: 100%;
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: rgba(93, 75, 56, 0.12);
}

.completion-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #b68f61 0%, #6f573f 100%);
}

.access-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.access-profile-badges {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.access-table td {
    vertical-align: top;
}

.access-table tr.row-dirty td {
    background: rgba(239, 228, 212, 0.26);
}

.user-stack,
.user-context {
    display: grid;
    gap: 6px;
}

.profile-checklist {
    display: grid;
    gap: 10px;
    min-width: 320px;
}

.checkbox-card {
    display: grid;
    grid-template-columns: 18px minmax(0, 1fr);
    gap: 12px;
    align-items: start;
    padding: 12px 14px;
    border: 1px solid var(--line);
    border-radius: 16px;
    background: rgba(252, 251, 249, 0.88);
}

.checkbox-card input {
    margin-top: 4px;
}

.checkbox-card span {
    display: grid;
    gap: 4px;
}

.checkbox-card small {
    color: var(--muted);
    line-height: 1.5;
}

.status-admin-native {
    background: rgba(61, 47, 34, 0.12);
    color: var(--accent-strong);
}

.section-headline {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 16px;
}

.section-catalog {
    display: grid;
    gap: 16px;
}

.section-card {
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 20px;
    background: rgba(252, 251, 249, 0.82);
}

.section-toggle {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 12px;
}

.section-meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.subsection-list {
    display: grid;
    gap: 10px;
}

.subsection-toggle {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    text-align: justify;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 0 10px;
    border-radius: 999px;
    background: var(--accent-soft);
    color: var(--accent-strong);
    font-size: 12px;
    font-weight: 600;
}

.detail-block {
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--line);
}

.detail-block-first {
    margin-top: 0;
    padding-top: 0;
    border-top: 0;
}

.detail-block h4 {
    margin: 0 0 8px;
}

.review-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.5fr) minmax(320px, 0.9fr);
    gap: 18px;
}

.review-main,
.review-sidebar {
    align-self: start;
}

.history-list {
    display: grid;
    gap: 10px;
}

.history-card {
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 12px;
    background: rgba(252, 251, 249, 0.85);
}

.preview-pane {
    border: 1px solid var(--line);
    border-radius: 20px;
    background: rgba(252, 251, 249, 0.88);
    padding: 22px;
}

.preview-document {
    color: var(--text);
    font: 15px/1.75 "Georgia", "Times New Roman", serif;
}

.preview-heading,
.preview-subheading,
.preview-paragraph,
.preview-empty,
.preview-doc-header {
    margin: 0;
}

.preview-heading {
    margin-top: 32px;
    margin-bottom: 14px;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.preview-heading:first-child {
    margin-top: 0;
}

.preview-doc-header {
    margin-top: 0;
    margin-bottom: 4px;
    text-align: center;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.08em;
}

.preview-subheading {
    margin-top: 20px;
    margin-bottom: 8px;
    font-size: 0.98rem;
    font-weight: 700;
}

.preview-paragraph {
    margin-top: 0;
    margin-bottom: 14px;
    text-align: justify;
    text-indent: 1cm;
}

.preview-alpha {
    padding-left: 1.2rem;
    text-indent: -1.2rem;
}

.preview-roman {
    padding-left: 3.2rem;
    text-indent: -1.6rem;
}

.preview-empty {
    color: var(--muted);
}

.auth-shell {
    min-height: calc(100vh - 64px);
    display: grid;
    place-items: center;
}

.auth-card {
    width: min(460px, 100%);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--line);
    border-radius: 28px;
    padding: 30px;
    box-shadow: 0 24px 44px rgba(41, 36, 29, 0.1);
}

.auth-button {
    width: 100%;
}

.status-rascunho { background: #ebe4da; color: #6e5b48; }
.status-pendente { background: #f6e8c8; color: #89651c; }
.status-gerado { background: #dfeadc; color: #2f6b36; }
.status-revisado { background: #dbe8f2; color: #28597a; }
.status-aprovado { background: #d9efe2; color: #1f6a43; }
.status-rejeitado { background: #f3d7d7; color: #8a3030; }

@media (max-width: 1100px) {
    .layout-shell {
        width: min(100%, calc(100% - 20px));
        margin: 10px auto;
    }

    .layout {
        grid-template-columns: 1fr;
        min-height: auto;
    }

    .sidebar {
        border-right: 0;
        border-bottom: 1px solid rgba(255,255,255,.06);
    }
}

@media (max-width: 900px) {
    .layout {
        border-radius: 22px;
    }

    .page-header,
    .content-grid,
    .content-grid2,
    .upload-inline,
    .form-grid,
    .review-layout,
    .workflow-nav {
        grid-template-columns: 1fr;
        display: grid;
    }

    .content {
        padding: 18px;
    }

    .card {
        padding: 18px;
        border-radius: 20px;
    }

    .page-header h2 {
        font-size: 30px;
    }

    .analysis-topline,
    .analysis-metrics {
        grid-template-columns: 1fr;
        display: grid;
    }

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

    .access-profile-badges {
        justify-content: flex-start;
    }

    .profile-checklist {
        min-width: 240px;
    }
}
