:root {
    --bg: #f5f7fb;
    --surface: #ffffff;
    --text: #172033;
    --muted: #667085;
    --line: #d9e0ea;
    --primary: #0078be;
    --primary-dark: #005f99;
    --primary-deep: #004b83;
    --primary-soft: #e6f5fc;
    --ok: #137333;
    --warn: #b25e09;
    --bad: #b42318;
    --future: #475467;
    --cancel: #7f1d1d;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background:
        linear-gradient(180deg, #eef6fb 0, var(--bg) 210px),
        var(--bg);
    color: var(--text);
    font-family: Arial, Helvetica, sans-serif;
}

.app-page {
    background: var(--bg);
}

.app-shell {
    display: grid;
    grid-template-columns: 252px minmax(0, 1fr);
    min-height: 100vh;
}

.sidebar {
    position: sticky;
    z-index: 40;
    top: 0;
    display: flex;
    flex-direction: column;
    width: 252px;
    height: 100vh;
    padding: 18px 14px 14px;
    background: var(--primary-deep);
    color: #fff;
    box-shadow: 8px 0 26px rgba(16, 33, 63, .12);
}

.sidebar-brand {
    display: grid;
    gap: 12px;
    padding: 4px 8px 18px;
    border-bottom: 1px solid rgba(255, 255, 255, .14);
    text-decoration: none;
}

.sidebar-brand img {
    display: block;
    width: 170px;
    max-height: 50px;
    object-fit: contain;
    object-position: left center;
}

.sidebar-brand span,
.sidebar-brand strong,
.sidebar-brand small {
    display: block;
}

.sidebar-brand strong {
    font-size: 19px;
    line-height: 1.2;
}

.sidebar-brand small {
    margin-top: 4px;
    color: #cbe9f8;
    font-size: 11px;
}

.sidebar-primary-action {
    display: flex;
    justify-content: center;
    min-height: 42px;
    margin: 18px 6px 10px;
    padding: 11px 14px;
    border-radius: 6px;
    background: #fff;
    color: var(--primary-deep);
    font-weight: 800;
    text-decoration: none;
}

.sidebar-primary-action:hover {
    background: #eaf7fd;
}

.sidebar-nav {
    display: grid;
    gap: 4px;
    overflow-y: auto;
    padding: 4px 6px 16px;
}

.sidebar-section-label {
    margin: 18px 10px 6px;
    color: #9fd5ed;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.sidebar-link {
    min-height: 40px;
    padding: 11px 12px;
    border-radius: 6px;
    color: #eaf8ff;
    font-size: 14px;
    font-weight: 700;
    text-decoration: none;
}

.sidebar-link:hover {
    background: rgba(255, 255, 255, .1);
}

.sidebar-link.active {
    background: #fff;
    color: var(--primary-deep);
    box-shadow: 0 7px 18px rgba(0, 0, 0, .14);
}

.sidebar-user {
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) auto;
    gap: 9px;
    align-items: center;
    margin-top: auto;
    padding: 14px 7px 2px;
    border-top: 1px solid rgba(255, 255, 255, .14);
}

.user-avatar {
    display: grid;
    place-items: center;
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255, 255, 255, .15);
    font-size: 12px;
    font-weight: 800;
}

.user-details,
.user-details strong,
.user-details small {
    display: block;
    min-width: 0;
}

.user-details strong {
    overflow: hidden;
    font-size: 12px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-details small {
    overflow: hidden;
    margin-top: 3px;
    color: #bfe2f2;
    font-size: 10px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.logout-link {
    padding: 7px 5px;
    color: #dff5ff;
    font-size: 11px;
    font-weight: 700;
    text-decoration: none;
}

.app-content {
    min-width: 0;
}

.app-content > .container {
    width: min(1440px, calc(100% - 40px));
    margin: 24px auto 40px;
}

.app-content > .container.narrow {
    width: min(980px, calc(100% - 40px));
}

.mobile-topbar,
.sidebar-overlay {
    display: none;
}

.login-page {
    display: grid;
    place-items: center;
    padding: 24px;
    background: var(--primary-deep);
}

.login-shell {
    width: min(430px, 100%);
}

.login-card {
    overflow: hidden;
    padding: 0;
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}

.login-logo {
    display: grid;
    place-items: center;
    padding: 28px 28px 24px;
    background: var(--primary-deep);
}

.login-logo img {
    width: min(290px, 100%);
    height: auto;
    display: block;
}

.login-brand {
    padding: 28px 28px 0;
    margin-bottom: 22px;
    text-align: center;
}

.login-brand strong {
    display: block;
    font-size: 24px;
}

.login-brand span {
    display: block;
    margin-top: 6px;
    color: var(--muted);
}

.login-card .alert,
.login-card form {
    margin-left: 28px;
    margin-right: 28px;
}

.login-card form {
    padding-bottom: 28px;
}

a {
    color: inherit;
}

a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
summary:focus-visible,
[tabindex]:focus-visible {
    outline: 3px solid rgba(0, 120, 190, .28);
    outline-offset: 2px;
}

.topbar {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: center;
    padding: 16px 26px;
    background: linear-gradient(90deg, var(--primary-dark) 0, var(--primary) 48%, #0087cc 100%);
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, .16);
    box-shadow: 0 10px 28px rgba(0, 95, 153, .18);
}

.topbar > div {
    display: grid;
    grid-template-columns: 148px 1fr;
    column-gap: 8px;
    align-items: center;
    min-width: 360px;
}

.topbar > div::before {
    content: "";
    grid-row: 1 / span 2;
    width: 148px;
    height: 48px;
    background: url("img/LOGO_CMI_LIGHT.png") left center / contain no-repeat;
}

.topbar strong {
    display: block;
    font-size: 28px;
    line-height: 1;
    letter-spacing: .2px;
}

.topbar span {
    display: block;
    margin-top: 6px;
    color: #dff5ff;
    font-size: 14px;
    font-weight: 600;
}

.topbar nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.topbar a {
    padding: 9px 12px;
    border: 1px solid rgba(255, 255, 255, .22);
    border-radius: 6px;
    background: rgba(255, 255, 255, .06);
    text-decoration: none;
}

.container {
    width: min(1180px, calc(100% - 32px));
    margin: 30px auto;
}

.narrow {
    width: min(880px, calc(100% - 32px));
}

.panel {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 22px;
    box-shadow: 0 18px 45px rgba(16, 33, 63, .08);
}

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

.section-head h1 {
    margin: 0 0 6px;
    font-size: 24px;
}

.section-head p {
    margin: 0;
    color: var(--muted);
}

.alert {
    margin-bottom: 16px;
    padding: 12px 14px;
    border: 1px solid #a9d9ef;
    border-radius: 8px;
    background: var(--primary-soft);
}

.config-user-form {
    display: grid;
    grid-template-columns: 1.2fr 1fr 160px auto;
    gap: 12px;
    align-items: end;
}

.inline-config-form {
    display: grid;
    grid-template-columns: minmax(180px, 1fr) 130px 130px auto;
    gap: 10px;
    align-items: center;
}

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

.profile-card {
    display: grid;
    gap: 12px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.profile-card-head {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: flex-start;
}

.profile-card-head strong,
.profile-card-head span {
    display: block;
}

.profile-card-head span {
    margin-top: 3px;
    color: var(--muted);
    font-size: 12px;
}

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

.check-line,
.switch-line {
    display: flex;
    grid-template-columns: none;
    gap: 8px;
    align-items: center;
    color: var(--text);
    font-weight: 400;
}

.check-line input,
.switch-line input {
    width: auto;
    min-height: auto;
}

.metrics {
    display: grid;
    grid-template-columns: repeat(5, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 18px;
}

.compact-metrics {
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
}

.dashboard-metrics {
    grid-template-columns: repeat(4, minmax(150px, 1fr));
}

.metric {
    display: block;
    position: relative;
    overflow: hidden;
    padding: 16px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 8px;
    box-shadow: 0 8px 22px rgba(16, 33, 63, .05);
    text-decoration: none;
}

.metric::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: #c8d7e8;
}

.metric.active {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.metric.active::before {
    background: var(--primary);
}

.metric span {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.metric strong {
    display: block;
    margin-top: 6px;
    font-size: 26px;
}

.metric.status-concluido::before {
    background: var(--ok);
}

.metric.status-em_andamento::before {
    background: var(--primary);
}

.metric.status-planejamento::before,
.metric.status-aguardando::before {
    background: var(--warn);
}

.metric.status-fracassado::before {
    background: var(--bad);
}

.metric.status-cancelado::before {
    background: var(--cancel);
}

.filters,
.upload {
    display: grid;
    grid-template-columns: 1fr 210px auto auto;
    gap: 10px;
    margin-bottom: 16px;
}

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

.panel-toolbar h1 {
    margin: 0 0 4px;
    font-size: 22px;
}

.panel-toolbar p {
    margin: 0;
    color: var(--muted);
}

.process-filters {
    grid-template-columns: minmax(220px, 1fr) 170px 190px auto auto;
    align-items: end;
}

.process-search {
    display: grid;
    gap: 10px;
    margin-bottom: 18px;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.process-search-main {
    display: grid;
    grid-template-columns: minmax(280px, 1fr) 210px auto auto;
    gap: 10px;
    align-items: end;
}

.advanced-filters {
    border-top: 1px solid var(--line);
    padding-top: 10px;
}

.advanced-filters summary {
    width: fit-content;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
}

.advanced-filter-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    margin-top: 14px;
}

.agent-filters {
    grid-template-columns: minmax(240px, 1fr) 180px 180px auto auto;
    align-items: end;
}

.report-filters {
    grid-template-columns: repeat(4, minmax(150px, 1fr)) auto auto;
    align-items: end;
}

.print-only {
    display: none;
}

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

.report-page-head h1 {
    margin: 0 0 5px;
    font-size: 28px;
}

.report-page-head p {
    margin: 0;
    color: var(--muted);
}

.horizontal-actions {
    flex-direction: row;
}

.report-filter-panel {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 14px;
    align-items: end;
    margin-bottom: 18px;
    padding: 16px;
    box-shadow: 0 8px 24px rgba(16, 33, 63, .05);
}

.report-filter-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(150px, 1fr));
    gap: 12px;
}

.report-filter-actions {
    display: flex;
    gap: 8px;
}

.report-kpis {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.report-kpis .metric {
    padding: 14px;
}

.report-kpis .metric strong {
    font-size: 23px;
}

.report-kpis .metric-money {
    font-size: 17px;
    line-height: 1.3;
}

.report-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.report-summary h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.report-insights {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 14px;
}

.report-insights h3 {
    margin: 0 0 10px;
    font-size: 16px;
}

.report-link {
    color: inherit;
    text-decoration: none;
}

.report-link:hover {
    border-color: var(--primary);
    box-shadow: inset 0 0 0 1px var(--primary);
}

.report-print-area {
    display: grid;
    gap: 18px;
}

.report-letterhead,
.report-footer {
    overflow: hidden;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
}

.report-letterhead img,
.report-footer img {
    display: block;
    width: 100%;
    height: auto;
}

.report-letterhead div {
    padding: 16px 18px 18px;
}

.report-letterhead h1 {
    margin: 0 0 6px;
    font-size: 22px;
}

.report-letterhead p {
    margin: 0;
    color: var(--muted);
}

.report-footer {
    margin-top: 4px;
}

input,
select,
textarea {
    width: 100%;
    min-height: 42px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 6px;
    color: var(--text);
    font: inherit;
}

textarea {
    resize: vertical;
}

button,
.button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 10px 14px;
    border: 0;
    border-radius: 6px;
    background: var(--primary);
    color: #fff;
    font: inherit;
    font-weight: 700;
    text-decoration: none;
    cursor: pointer;
}

button:hover,
.button:hover {
    background: var(--primary-dark);
}

.secondary {
    background: #eef2f7;
    color: var(--text);
}

.secondary:hover {
    background: #e1e7ef;
}

.danger {
    background: var(--bad);
    color: #fff;
}

.danger:hover {
    background: #8f1c13;
}

.small {
    min-height: 34px;
    padding: 7px 10px;
    font-size: 13px;
}

.disabled {
    opacity: .48;
    pointer-events: none;
}

.table-wrap {
    overflow-x: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
}

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

th,
td {
    padding: 12px;
    border-bottom: 1px solid var(--line);
    text-align: left;
    vertical-align: middle;
}

th {
    position: sticky;
    z-index: 2;
    top: 0;
    background: #f4f7fa;
    color: var(--muted);
    font-size: 12px;
    text-transform: uppercase;
}

td small,
.list-item small {
    display: block;
    margin-top: 4px;
    color: var(--muted);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    min-height: 28px;
    padding: 5px 9px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--text);
    font-size: 12px;
    font-weight: 700;
}

.badge.light {
    background: #f3f6fa;
    color: var(--text);
}

.alert-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    min-width: 150px;
}

.alert-chips .badge {
    min-height: 24px;
    padding: 4px 7px;
    font-size: 11px;
}

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

.process-table tbody tr {
    background: var(--surface);
    transition: background .15s ease;
}

.process-table tbody tr:last-child td {
    border-bottom: 0;
}

.clickable-row {
    cursor: pointer;
}

.clickable-row:hover,
.clickable-row:focus {
    background: #f4fafe;
    outline: none;
}

.process-table td:first-child {
    min-width: 280px;
}

.process-table td:last-child {
    text-align: right;
}

.process-number {
    display: block;
    margin-bottom: 5px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
}

.object-title {
    display: -webkit-box;
    overflow: hidden;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    line-height: 1.35;
}

.process-object-link {
    color: var(--text);
    font-weight: 800;
    text-decoration: none;
}

.process-object-link:hover {
    color: var(--primary-dark);
}

.process-attention {
    display: block;
    font-size: 12px;
    font-weight: 800;
}

.process-attention.has-pending,
.deadline-overdue {
    color: var(--bad) !important;
    font-weight: 800;
}

.process-attention.is-complete {
    color: var(--ok);
}

.money-cell {
    white-space: nowrap;
    font-weight: 700;
}

.row-open-cell {
    width: 1%;
    white-space: nowrap;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    margin-top: 16px;
    color: var(--muted);
    font-size: 13px;
}

.pagination span {
    padding: 0 4px;
}

.pagination-pages {
    display: flex;
    gap: 5px;
}

.page-number {
    display: grid;
    place-items: center;
    min-width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--text);
    font-weight: 700;
    text-decoration: none;
}

.page-number:hover,
.page-number.active {
    border-color: var(--primary);
    background: var(--primary-soft);
    color: var(--primary-dark);
}

.row-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 7px;
}

.row-actions form {
    margin: 0;
}

.document-actions {
    flex: 0 0 auto;
}

.status-concluido {
    color: var(--ok);
}

.status-em_andamento {
    color: var(--primary);
}

.status-planejamento,
.status-aguardando {
    color: var(--warn);
}

.status-fracassado {
    color: var(--bad);
}

.status-futuro,
.status-deserto,
.status-revogado,
.status-anulado {
    color: var(--future);
}

.status-cancelado {
    color: var(--cancel);
}

.badge.status-concluido {
    background: #e7f6ed;
}

.badge.status-em_andamento {
    background: var(--primary-soft);
}

.badge.status-planejamento,
.badge.status-aguardando {
    background: #fff4e5;
}

.badge.status-fracassado {
    background: #fdecec;
}

.badge.status-futuro,
.badge.status-deserto,
.badge.status-revogado,
.badge.status-anulado {
    background: #eef2f7;
}

.badge.status-cancelado {
    background: #fae8e8;
}

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

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

.form-hero h1 {
    margin: 0 0 6px;
    font-size: 28px;
}

.form-hero p {
    max-width: 760px;
    margin: 0;
    color: var(--muted);
    line-height: 1.45;
}

.process-form {
    display: grid;
    gap: 22px;
}

.form-section-nav {
    position: sticky;
    z-index: 12;
    top: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 12px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 6px 18px rgba(16, 33, 63, .06);
}

.form-section-nav a {
    flex: 0 0 auto;
    padding: 8px 11px;
    border-radius: 6px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.form-section-nav a:hover,
.form-section-nav a:focus {
    background: var(--primary-soft);
}

.form-section {
    display: grid;
    gap: 16px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
    scroll-margin-top: 76px;
}

.form-section:last-of-type {
    padding-bottom: 0;
    border-bottom: 0;
}

.form-section-head {
    display: flex;
    justify-content: space-between;
    gap: 18px;
    align-items: flex-start;
}

.form-section-head h2 {
    margin: 0;
    font-size: 18px;
}

.form-section-head p {
    max-width: 620px;
    margin: 0;
    color: var(--muted);
    font-size: 13px;
    line-height: 1.45;
}

label {
    display: grid;
    gap: 7px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 700;
}

.label-help {
    display: inline-flex;
    gap: 6px;
    align-items: center;
}

.help-tip {
    position: relative;
    display: inline-grid;
    place-items: center;
    width: 18px;
    height: 18px;
    min-height: 18px;
    padding: 0;
    border-radius: 999px;
    background: #e6eef8;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

.help-tip:hover {
    background: #e6eef8;
    color: var(--primary-dark);
}

.help-tip:focus {
    background: var(--primary);
    color: #fff;
    outline: none;
}

.help-tip:focus::after {
    content: attr(aria-label);
    position: absolute;
    z-index: 20;
    left: 50%;
    bottom: calc(100% + 8px);
    width: min(280px, 80vw);
    padding: 9px 10px;
    border-radius: 6px;
    background: #172033;
    color: #fff;
    box-shadow: 0 10px 24px rgba(23, 32, 51, .22);
    font-size: 12px;
    font-weight: 400;
    line-height: 1.35;
    text-align: left;
    transform: translateX(-50%);
}

.field-hint {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.field-disabled {
    opacity: .58;
}

.field-disabled select {
    background: #eef2f7;
}

.field-recommended .label-help::after {
    content: "Obrigatorio";
    display: inline-flex;
    align-items: center;
    min-height: 20px;
    padding: 2px 7px;
    border-radius: 999px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 800;
}

.orientation-note {
    padding: 12px 14px;
    border: 1px solid #c7e4f2;
    border-radius: 8px;
    background: #f0f9fd;
    color: #31516b;
    font-size: 13px;
    line-height: 1.45;
}

.stack-note {
    margin-bottom: 14px;
}

.stack-note strong {
    display: block;
    margin-bottom: 4px;
}

.full {
    grid-column: 1 / -1;
}

.actions {
    display: flex;
    gap: 10px;
}

.form-sticky-actions {
    position: sticky;
    z-index: 10;
    bottom: 0;
    margin: 0 -22px -22px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    border-radius: 0 0 8px 8px;
    background: rgba(255, 255, 255, .97);
    box-shadow: 0 -8px 22px rgba(16, 33, 63, .08);
}

.detail-head {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
    margin-bottom: 18px;
}

.detail-head h1 {
    margin: 12px 0;
    font-size: 26px;
}

.detail-title-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 9px;
    align-items: center;
}

.detail-title-meta .process-number {
    margin: 0;
}

.detail-edit-action {
    margin-top: 6px;
}

.detail-head p {
    color: var(--muted);
    line-height: 1.5;
}

.summary-strip {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 14px;
    margin: 18px 0;
}

.process-summary {
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.detail-section-nav {
    position: sticky;
    z-index: 12;
    top: 0;
    display: flex;
    gap: 6px;
    overflow-x: auto;
    margin-bottom: 18px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 6px 18px rgba(16, 33, 63, .06);
}

.detail-section-nav a {
    flex: 0 0 auto;
    padding: 8px 11px;
    border-radius: 6px;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
}

.detail-section-nav a:hover,
.detail-section-nav a:focus {
    background: var(--primary-soft);
}

#fluxo,
#documentos,
#responsabilidades,
#historico {
    scroll-margin-top: 76px;
}

.summary-card {
    position: relative;
    overflow: hidden;
    padding: 15px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--surface);
    box-shadow: 0 10px 26px rgba(16, 33, 63, .05);
}

.summary-card::before {
    content: "";
    position: absolute;
    inset: 0 0 auto;
    height: 3px;
    background: #c8d7e8;
}

.summary-card.ok::before {
    background: var(--ok);
}

.summary-card.attention::before {
    background: var(--warn);
}

.summary-card span,
.summary-card small {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.summary-card strong {
    display: block;
    overflow: hidden;
    margin: 7px 0 5px;
    font-size: 20px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

dl {
    display: grid;
    grid-template-columns: 110px 1fr;
    gap: 10px;
    margin: 0;
}

dt {
    color: var(--muted);
    font-weight: 700;
}

dd {
    margin: 0;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1.2fr .8fr;
    gap: 18px;
}

.flow-panel {
    margin-bottom: 18px;
}

.step-flow {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.step-item {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 8px;
    align-items: center;
    min-width: 180px;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.step-item span {
    display: inline-grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: 999px;
    background: #e4eaf3;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.step-item strong {
    display: block;
    font-size: 13px;
}

.step-item small {
    display: block;
    margin-top: 3px;
    color: var(--primary-dark);
    font-size: 10px;
    font-weight: 700;
}

.step-item.previous {
    border-color: #cbd5e1;
    background: #f4f6f8;
}

.step-item.previous span {
    background: #dfe5ec;
    color: #475467;
}

.step-item.current {
    border-color: #95d4ee;
    background: var(--primary-soft);
}

.step-item.current span {
    background: var(--primary);
    color: #fff;
}

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

.checklist-item {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 10px;
    align-items: center;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.checklist-status {
    grid-column: 2;
    grid-row: 1;
    padding: 4px 7px;
    border-radius: 999px;
    background: #eef2f7;
    color: var(--muted);
    font-size: 11px;
    font-weight: 700;
}

.checklist-item-title {
    display: flex;
    grid-column: 1;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    min-width: 0;
}

.checklist-item-title strong {
    font-size: 13px;
}

.checklist-item-actions,
.checklist-upload {
    display: flex;
    gap: 6px;
    align-items: center;
}

.checklist-upload {
    margin: 0;
}

.checklist-item > small {
    grid-column: 1 / -1;
    color: var(--muted);
}

.checklist-item.ok {
    border-color: #bfe6ce;
}

.checklist-item.ok .checklist-status {
    background: #e7f6ed;
    color: var(--ok);
}

.checklist-item.missing .checklist-status {
    background: #fff4e5;
    color: var(--warn);
}

.checklist-item.requirement-aplicavel {
    border-style: dashed;
}

.checklist-item.requirement-aplicavel.missing .checklist-status {
    background: #eef2f7;
    color: var(--muted);
}

.icon-button {
    display: inline-grid;
    place-items: center;
    width: 34px;
    height: 34px;
    min-height: 34px;
    flex: 0 0 34px;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    color: var(--primary-dark);
    text-decoration: none;
}

label.icon-button {
    cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
    border-color: #95d4ee;
    background: var(--primary-soft);
}

.checklist-upload input[type="file"]:focus-visible + .icon-button {
    outline: 3px solid rgba(14, 165, 233, .25);
    outline-offset: 2px;
    border-color: #95d4ee;
}

.icon-button.compact {
    width: 28px;
    height: 28px;
    min-height: 28px;
    flex-basis: 28px;
}

.icon {
    width: 18px;
    height: 18px;
}

.visually-hidden {
    position: absolute !important;
    overflow: hidden !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    border: 0 !important;
    clip: rect(0 0 0 0) !important;
    white-space: nowrap !important;
}

.document-extra-upload {
    margin-top: 4px;
    border-top: 1px solid var(--line);
}

.document-extra-upload summary {
    display: flex;
    gap: 8px;
    align-items: center;
    padding: 13px 0;
    color: var(--primary-dark);
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    list-style: none;
}

.document-extra-upload summary::-webkit-details-marker {
    display: none;
}

.document-extra-upload[open] summary {
    margin-bottom: 4px;
}

.documents-history-head {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    align-items: center;
    margin: 22px 0 10px;
}

.documents-history-head h3,
.documents-history-head p {
    margin: 0;
}

.documents-history-head h3 {
    font-size: 15px;
}

.documents-history-head p,
.documents-history-head > span {
    color: var(--muted);
    font-size: 12px;
}

.document-info {
    min-width: 0;
}

.document-file-name {
    display: block;
    overflow-wrap: anywhere;
    color: var(--text);
    text-decoration: none;
}

a.document-file-name:hover,
a.document-file-name:focus-visible {
    color: var(--primary-dark);
    text-decoration: underline;
}

.document-file-name.plain {
    color: var(--muted);
}

.document-meta {
    margin-top: 3px;
}

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

.responsibility-list {
    display: grid;
    gap: 10px;
    margin-bottom: 22px;
}

.responsibility-list div {
    padding: 11px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f8fafc;
}

.responsibility-list span,
.responsibility-list strong {
    display: block;
}

.responsibility-list span {
    color: var(--muted);
    font-size: 12px;
}

.responsibility-list strong {
    margin-top: 4px;
}

.list-item {
    display: flex;
    justify-content: space-between;
    gap: 14px;
    align-items: center;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
}

.list-item span {
    display: block;
    color: var(--muted);
}

.stack {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
}

.timeline {
    display: grid;
    gap: 10px;
}

.timeline div {
    padding-left: 12px;
    border-left: 3px solid var(--primary);
}

.timeline span,
.timeline small {
    display: block;
    color: var(--muted);
    font-size: 13px;
}

@media (max-width: 800px) {
    .sidebar-open {
        overflow: hidden;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        inset: 0 auto 0 0;
        width: min(286px, calc(100vw - 44px));
        transform: translateX(-105%);
        transition: transform .2s ease;
    }

    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    .sidebar-overlay {
        position: fixed;
        z-index: 35;
        inset: 0;
        width: 100%;
        height: 100%;
        padding: 0;
        border-radius: 0;
        background: rgba(16, 33, 63, .48);
        opacity: 0;
        pointer-events: none;
        transition: opacity .2s ease;
    }

    .sidebar-overlay:hover {
        background: rgba(16, 33, 63, .48);
    }

    .sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-topbar {
        position: sticky;
        z-index: 30;
        top: 0;
        display: grid;
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 12px;
        align-items: center;
        min-height: 66px;
        padding: 10px 16px;
        background: var(--primary-deep);
        color: #fff;
        box-shadow: 0 5px 18px rgba(16, 33, 63, .16);
    }

    .mobile-topbar strong,
    .mobile-topbar span {
        display: block;
    }

    .mobile-topbar strong {
        font-size: 16px;
    }

    .mobile-topbar span {
        overflow: hidden;
        margin-top: 3px;
        color: #cbe9f8;
        font-size: 11px;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .menu-toggle {
        width: 42px;
        min-height: 42px;
        padding: 0;
        border: 1px solid rgba(255, 255, 255, .24);
        background: transparent;
        font-size: 22px;
        line-height: 1;
    }

    .menu-toggle:hover {
        background: rgba(255, 255, 255, .1);
    }

    .app-content > .container,
    .app-content > .container.narrow {
        width: min(100% - 24px, 100%);
        margin: 16px auto 28px;
    }

    .topbar,
    .detail-head,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .topbar {
        display: grid;
        padding: 16px;
    }

    .topbar > div {
        grid-template-columns: 128px 1fr;
        column-gap: 8px;
        min-width: 0;
    }

    .topbar > div::before {
        width: 128px;
        height: 42px;
    }

    .topbar strong {
        font-size: 22px;
    }

    .form-hero,
    .form-section-head {
        display: grid;
    }

    .metrics,
    .summary-strip,
    .filters,
    .upload,
    .form-hero,
    .form-section-head,
    .report-summary,
    .report-insights,
    .panel-toolbar,
    .checklist,
    .config-user-form,
    .inline-config-form,
    .profile-grid,
    .permissions-list,
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-section-nav {
        top: 66px;
        margin-right: -12px;
        margin-left: -12px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

    .detail-section-nav {
        top: 66px;
        margin-right: -12px;
        margin-left: -12px;
        border-right: 0;
        border-left: 0;
        border-radius: 0;
    }

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

    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .report-page-head,
    .report-filter-panel {
        display: grid;
        grid-template-columns: 1fr;
    }

    .report-page-head .actions,
    .report-filter-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .report-filter-grid {
        grid-template-columns: 1fr;
    }

    .report-kpis {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .dashboard-metrics .metric {
        padding: 13px;
    }

    .dashboard-metrics .metric strong {
        font-size: 22px;
    }

    .process-search-main,
    .advanced-filter-grid {
        grid-template-columns: 1fr;
    }

    .process-search-main .button,
    .process-search-main button {
        width: 100%;
    }

    .process-table,
    .process-table tbody,
    .process-table tr,
    .process-table td {
        display: block;
        width: 100%;
    }

    .process-table thead {
        position: absolute;
        overflow: hidden;
        width: 1px;
        height: 1px;
        clip: rect(0 0 0 0);
    }

    .process-table tbody {
        display: grid;
        gap: 10px;
        padding: 10px;
        background: #eef2f7;
    }

    .process-table tbody tr {
        overflow: hidden;
        border: 1px solid var(--line);
        border-radius: 8px;
        box-shadow: 0 5px 14px rgba(16, 33, 63, .05);
    }

    .process-table td {
        display: grid;
        grid-template-columns: 112px minmax(0, 1fr);
        gap: 10px;
        min-width: 0 !important;
        padding: 10px 12px;
        border-bottom: 1px solid #e8edf3;
        text-align: left !important;
    }

    .process-table td::before {
        content: attr(data-label);
        color: var(--muted);
        font-size: 10px;
        font-weight: 800;
        text-transform: uppercase;
    }

    .process-table td:first-child {
        display: block;
        padding: 14px 12px;
        background: #f8fafc;
    }

    .process-table td:first-child::before,
    .process-table .row-open-cell::before {
        display: none;
    }

    .process-table .row-open-cell {
        display: block;
    }

    .process-table .row-open-cell .button {
        width: 100%;
    }

    .process-table td > small,
    .process-table td > span:not(.process-number) {
        grid-column: 2;
    }

    .pagination {
        flex-wrap: wrap;
    }

    .pagination-pages {
        order: -1;
        justify-content: center;
        width: 100%;
    }

    .actions {
        flex-direction: column;
    }

    .list-item {
        align-items: flex-start;
        flex-direction: column;
    }

    .document-actions {
        justify-content: flex-start;
        width: 100%;
    }

    .documents-history-head {
        align-items: flex-start;
    }

    .panel-toolbar {
        align-items: stretch;
    }

    .pagination {
        justify-content: stretch;
    }

    .pagination .button {
        flex: 1;
    }
}

@media print {
    @page {
        margin: 12mm;
    }

    body {
        background: #fff;
        color: #000;
    }

    .app-shell {
        display: block;
    }

    .app-content {
        width: 100%;
    }

    .topbar,
    .sidebar,
    .sidebar-overlay,
    .mobile-topbar,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .container {
        width: 100%;
        margin: 0;
    }

    .panel,
    .metric,
    .summary-card,
    .report-letterhead,
    .report-footer {
        box-shadow: none;
    }

    .panel {
        break-inside: avoid;
        padding: 14px;
    }

    .metrics,
    .report-kpis {
        grid-template-columns: repeat(4, 1fr);
    }

    .report-kpis {
        gap: 8px;
    }

    .report-kpis .metric {
        padding: 10px;
    }

    .report-letterhead img {
        max-height: 38mm;
        object-fit: contain;
    }

    .report-footer img {
        max-height: 24mm;
        object-fit: contain;
    }

    .report-insights,
    .report-summary {
        grid-template-columns: repeat(3, 1fr);
    }

    .report-link {
        border-color: var(--line);
    }

    .button,
    .process-table th:last-child,
    .process-table td:last-child {
        display: none;
    }

    th,
    td {
        padding: 8px;
    }
}
