:root {
    --ink: #16251f;
    --muted: #708078;
    --green: #0d4778;
    --lime: #5f9bd1;
    --paper: #f5f7f3;
    --line: #e2e8e3;
    --app-bg: #f4f7f9;
    --app-ink: #22303f;
    --app-muted: #697888;
    --app-primary: #0d4778;
    --app-primary-dark: #08365d;
    --app-primary-soft: #e8f1f8;
    --app-line: #e1e8ed;
    --app-card: #ffffff;
    --app-sidebar: #203342;
    --app-sidebar-hover: #2c4557;
    --app-success: #23855a;
    --app-warning: #ad7311;
    --app-danger: #c74343;
    --app-radius: 14px;
    --app-shadow: 0 1px 2px rgba(24, 39, 52, .03), 0 10px 32px rgba(24, 39, 52, .055);
}

* { box-sizing: border-box; }
body { margin: 0; background: var(--paper); color: var(--ink); font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif; }
svg { display: block; }

/* Área autenticada */
.authenticated { background: var(--app-bg); color: var(--app-ink); font-size: 14px; }
.authenticated .sidebar {
    position: fixed; inset: 0 auto 0 0; z-index: 40; width: 264px;
    display: flex; flex-direction: column; overflow: hidden;
    background: linear-gradient(180deg, #203443 0%, #1d303e 100%); color: #edf5f7;
    box-shadow: 12px 0 36px rgba(19, 38, 51, .06); transition: width .22s ease, transform .22s ease;
}
.sidebar-brand-row { min-height: 78px; display: flex; align-items: center; gap: 8px; padding: 16px 14px 14px 18px; }
.app-brand { min-width: 0; flex: 1; display: flex; align-items: center; gap: 11px; color: #fff; text-decoration: none; }
.app-brand:hover { color: #fff; }
.app-brand-mark, .avatar {
    display: grid; place-items: center; flex: none; font-weight: 800; letter-spacing: -.03em;
    background: linear-gradient(135deg, #2b6799, #0d4778); color: #fff;
}
.app-brand-logo { width: 205px; height: auto; max-height: 48px; object-fit: contain; object-position: left center; }
.login-logo { display: block; width: min(100%, 360px); height: auto; margin: 0 auto; }
.public-logo { display: block; width: min(100%, 280px); height: auto; margin: 0 auto 24px; }
.app-brand-mark { width: 40px; height: 40px; border-radius: 11px; box-shadow: 0 7px 18px rgba(56, 181, 183, .2); }
.app-brand-copy { min-width: 0; display: flex; flex-direction: column; line-height: 1.15; }
.app-brand-copy strong { font-size: 15px; letter-spacing: -.01em; }
.app-brand-copy small { margin-top: 4px; color: rgba(237,245,247,.55); font-size: 10px; letter-spacing: .04em; }
.sidebar-collapse, .profile-logout, .mobile-menu, .topbar-icon {
    border: 0; display: grid; place-items: center; cursor: pointer; transition: background .15s ease, color .15s ease;
}
.sidebar-collapse { width: 32px; height: 32px; border-radius: 9px; color: rgba(237,245,247,.66); background: transparent; }
.sidebar-collapse:hover, .profile-logout:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-collapse svg, .profile-logout svg, .mobile-menu svg, .topbar-icon svg { width: 19px; height: 19px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.sidebar-nav { flex: 1; overflow-y: auto; overflow-x: hidden; padding: 0 12px 18px; scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.15) transparent; }
.nav-section { padding: 13px 0 12px; border-bottom: 1px solid rgba(255,255,255,.075); }
.nav-section:first-child { padding-top: 4px; }
.nav-section-last { border-bottom: 0; }
.nav-section-label { display: block; padding: 0 11px 8px; color: rgba(227,239,243,.4); font-size: 9px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; white-space: nowrap; }
.authenticated .sidebar-nav .nav-link {
    width: 100%; min-height: 41px; display: flex; align-items: center; gap: 12px; margin: 2px 0; padding: 9px 11px;
    border: 0; border-radius: 9px; background: transparent; color: rgba(237,245,247,.72); font: inherit; font-weight: 500;
    text-align: left; text-decoration: none; white-space: nowrap; transition: background .15s ease, color .15s ease, transform .15s ease;
}
.authenticated .sidebar-nav .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.authenticated .sidebar-nav .nav-link.active { background: var(--app-sidebar-hover); color: #fff; box-shadow: inset 3px 0 #5f9bd1; font-weight: 650; }
.sidebar-nav .nav-link > svg { width: 19px; height: 19px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.nav-group-toggle { cursor: pointer; }
.nav-group-toggle span { flex: 1; }
.sidebar-nav .nav-group-toggle > .nav-chevron { width: 15px; transition: transform .18s ease; }
.nav-group-toggle[aria-expanded="true"] .nav-chevron { transform: rotate(90deg); }
.nav-submenu { display: none; margin: 4px 0 6px 20px; padding-left: 21px; border-left: 1px solid rgba(255,255,255,.13); }
.nav-submenu.open { display: block; }
.nav-sublink { display: block; padding: 8px 10px; border-radius: 8px; color: rgba(237,245,247,.58); font-size: 12px; text-decoration: none; }
.nav-sublink:hover, .nav-sublink.active { color: #fff; background: rgba(255,255,255,.055); }
.nav-sublink.active { font-weight: 650; }
.sidebar-profile { min-height: 70px; display: flex; align-items: center; gap: 10px; margin: 0 12px; padding: 13px 7px; border-top: 1px solid rgba(255,255,255,.09); }
.avatar { width: 36px; height: 36px; border-radius: 50%; font-size: 11px; }
.profile-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; line-height: 1.25; }
.profile-copy strong { overflow: hidden; color: #fff; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.profile-copy small { color: rgba(237,245,247,.5); font-size: 10px; }
.sidebar-profile form { margin: 0; }
.profile-logout { width: 34px; height: 34px; border-radius: 8px; background: transparent; color: rgba(237,245,247,.58); }
.profile-logout svg { width: 17px; height: 17px; }

.app-shell { min-height: 100vh; margin-left: 264px; transition: margin-left .22s ease; }
.authenticated .topbar {
    position: sticky; top: 0; z-index: 30; height: 68px; display: flex; align-items: center; gap: 18px; padding: 0 32px;
    background: rgba(255,255,255,.88); border-bottom: 1px solid rgba(219,228,234,.9); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
}
.global-search { position: relative; width: min(480px, 48vw); margin: 0; }
.global-search > svg { position: absolute; left: 13px; top: 50%; width: 18px; height: 18px; color: #80909d; fill: none; stroke: currentColor; stroke-width: 1.8; transform: translateY(-50%); }
.global-search input { width: 100%; height: 40px; padding: 0 66px 0 41px; border: 1px solid var(--app-line); border-radius: 10px; outline: 0; background: #f6f8fa; color: var(--app-ink); font: inherit; transition: border .15s ease, box-shadow .15s ease, background .15s ease; }
.global-search input::placeholder { color: #8b99a5; }
.global-search input:focus { border-color: #79bec8; background: #fff; box-shadow: 0 0 0 3px rgba(22,131,153,.1); }
.global-search kbd { position: absolute; right: 10px; top: 50%; padding: 3px 6px; border: 1px solid #dce4e8; border-bottom-width: 2px; border-radius: 5px; background: #fff; color: #86939e; font: 10px/1.2 inherit; transform: translateY(-50%); }
.global-search-results { position: absolute; top: calc(100% + 8px); left: 0; z-index: 100; width: min(540px, 80vw); overflow: hidden; border: 1px solid var(--app-line); border-radius: 11px; background: #fff; box-shadow: 0 14px 34px rgba(24,39,52,.16); }
.global-search-result { display: flex; align-items: center; gap: 10px; width: 100%; padding: 11px 13px; color: var(--app-ink); text-decoration: none; }
.global-search-result:hover, .global-search-result:focus { outline: 0; background: var(--app-primary-soft); }
.global-search-result-label { min-width: 0; overflow: hidden; flex: 1; font-size: 12px; font-weight: 650; text-overflow: ellipsis; white-space: nowrap; }
.global-search-result-badge { flex: none; padding: 3px 7px; border-radius: 999px; background: var(--app-primary-soft); color: var(--app-primary-dark); font-size: 9px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; }
.global-search-empty { padding: 13px; color: var(--app-muted); font-size: 12px; }
.user-role { display: inline-flex; padding: 4px 9px; border-radius: 999px; font-size: 10px; font-weight: 750; }
.user-role-admin { background: #e8f1f8; color: #0d4778; }
.user-role-leitor { background: #f1f4f5; color: #65737f; }
.user-role-operador { background: #eef6fb; color: #24638d; }
.contract-origin-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.contract-origin-option { position: relative; display: flex; align-items: flex-start; gap: 12px; min-height: 142px; padding: 20px 16px; border: 1px solid var(--app-line); border-radius: 14px; background: #fff; cursor: pointer; box-shadow: 0 2px 7px rgba(24,39,52,.035); transition: border-color .15s ease, background .15s ease, box-shadow .15s ease, transform .15s ease; }
.contract-origin-option:hover { border-color: #a9c8df; box-shadow: 0 9px 22px rgba(24,39,52,.08); transform: translateY(-1px); }
.contract-origin-option:has(input:checked) { border-color: var(--app-primary); background: var(--app-primary-soft); box-shadow: 0 0 0 3px rgba(13,71,120,.1), 0 9px 22px rgba(24,39,52,.08); }
.contract-origin-option input { position: absolute; opacity: 0; pointer-events: none; }
.contract-origin-option::before { display: grid; place-items: center; width: 42px; height: 42px; flex: none; border-radius: 12px; background: var(--app-primary-soft); color: var(--app-primary); font-size: 21px; }
.contract-origin-option:first-child::before { content: '✎'; }
.contract-origin-option:last-child::before { content: '▣'; }
.contract-origin-option span { display: block; padding-top: 2px; }
.contract-origin-option strong, .contract-origin-option small { display: block; }
.contract-origin-option strong { color: var(--app-ink); font-size: 14px; }
.contract-origin-option small { max-width: 180px; margin-top: 7px; color: var(--app-muted); font-size: 11px; line-height: 1.45; }
@media (max-width: 620px) { .contract-origin-options { grid-template-columns: 1fr; } }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-icon, .mobile-menu { position: relative; width: 38px; height: 38px; border-radius: 10px; background: transparent; color: #667684; }
.topbar-icon:hover, .mobile-menu:hover { background: #f0f4f6; color: var(--app-primary); }
.notification-dot { position: absolute; top: 7px; right: 8px; width: 7px; height: 7px; border: 2px solid #fff; border-radius: 50%; background: #e55858; }
.mobile-menu { display: none; }
.sidebar-overlay { display: none; }

.authenticated .content { width: 100%; max-width: 1600px; margin: 0 auto; padding: 34px 36px 52px; }
.app-alert { border: 0; border-radius: 11px; box-shadow: var(--app-shadow); }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 24px; margin-bottom: 28px; }
.page-head h1 { margin: 5px 0 5px; color: #21303d; font-size: clamp(26px, 2.4vw, 34px); font-weight: 720; letter-spacing: -.035em; }
.page-head p, .panel-head p { margin: 0; color: var(--app-muted); }
.eyebrow, .panel-kicker { color: var(--app-primary); font-size: 10px; font-weight: 800; letter-spacing: .15em; text-transform: uppercase; }
.authenticated .btn { min-height: 39px; border-radius: 9px; padding-inline: 14px; font-size: 13px; font-weight: 650; box-shadow: none; }
.authenticated .btn-sm { min-height: 32px; padding-inline: 11px; font-size: 12px; }
.authenticated .btn-primary { --bs-btn-bg: var(--app-primary); --bs-btn-border-color: var(--app-primary); --bs-btn-hover-bg: var(--app-primary-dark); --bs-btn-hover-border-color: var(--app-primary-dark); }
.authenticated .btn-light { --bs-btn-bg: #f5f7f8; --bs-btn-border-color: #e6ebee; --bs-btn-hover-bg: #eaf0f2; --bs-btn-hover-border-color: #dce4e8; color: #435261; }
.authenticated .btn-outline-secondary { --bs-btn-color: #536372; --bs-btn-border-color: #d4dde2; --bs-btn-hover-bg: #eef3f5; --bs-btn-hover-color: #263746; --bs-btn-hover-border-color: #cbd6dc; }
.metric-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 24px; }
.metric, .panel { background: var(--app-card); border: 1px solid var(--app-line); border-radius: var(--app-radius); box-shadow: var(--app-shadow); }
.metric { position: relative; min-width: 0; padding: 19px 20px 18px; overflow: hidden; transition: transform .18s ease, box-shadow .18s ease; }
.metric:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgba(24,39,52,.09); }
.metric-primary::after { content: ""; position: absolute; right: -36px; bottom: -46px; width: 110px; height: 110px; border-radius: 50%; background: rgba(22,131,153,.06); }
.metric-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.metric-icon { width: 37px; height: 37px; display: grid; place-items: center; border-radius: 10px; background: var(--app-primary-soft); color: var(--app-primary); font-size: 17px; }
.metric-icon-success { background: #e8f6ee; color: var(--app-success); }
.metric-icon-warning { background: #fff5e2; color: var(--app-warning); }
.metric-icon-info { background: #edf0fb; color: #6675b8; }
.metric-trend { padding: 4px 8px; border-radius: 999px; background: #eef7f8; color: var(--app-primary); font-size: 9px; font-weight: 700; }
.trend-success { background: #eaf7ef; color: var(--app-success); }
.trend-warning { background: #fff5e2; color: var(--app-warning); }
.trend-info { background: #eef0fb; color: #6572ad; }
.metric > strong { display: block; margin: 15px 0 1px; color: #21303d; font-size: 31px; line-height: 1; letter-spacing: -.04em; }
.metric > span:not(.metric-trend) { display: block; margin-top: 7px; font-weight: 650; }
.metric > small { display: block; margin-top: 3px; color: var(--app-muted); font-size: 11px; }
.panel { padding: 22px; }
.dashboard-panel { padding: 0; overflow: hidden; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-bottom: 18px; }
.dashboard-panel > .panel-head { margin: 0; padding: 20px 22px 17px; border-bottom: 1px solid var(--app-line); }
.panel-head h2, .panel > h2 { margin: 3px 0 3px; color: #253441; font-size: 17px; font-weight: 700; letter-spacing: -.015em; }
.panel-head a { color: var(--app-primary); font-size: 12px; font-weight: 700; text-decoration: none; white-space: nowrap; }
.panel-head a:hover, .back:hover { color: var(--app-primary-dark); }
.authenticated .table { --bs-table-bg: transparent; --bs-table-color: var(--app-ink); margin: 0; }
.authenticated .table th { padding: 12px 14px; border-color: var(--app-line); color: #7a8995; font-size: 10px; font-weight: 750; letter-spacing: .08em; text-transform: uppercase; white-space: nowrap; }
.authenticated .table td { padding: 14px; border-color: #e8edf0; color: #4a5966; font-size: 13px; vertical-align: middle; }
.authenticated .table tbody tr { transition: background .12s ease; }
.authenticated .table tbody tr:hover { background: #f8fafb; }
.table-code { color: var(--app-primary); font-weight: 750; text-decoration: none; }
.table-person { color: #2c3d4a; font-weight: 650; }
.row-action { width: 29px; height: 29px; display: inline-grid; place-items: center; border-radius: 8px; color: var(--app-primary); text-decoration: none; }
.row-action:hover { background: var(--app-primary-soft); }
.badge-status { display: inline-flex; align-items: center; gap: 5px; padding: 5px 9px; border: 1px solid #e0e6e9; border-radius: 999px; background: #f2f5f6; color: #61707d; font-size: 10px; font-weight: 700; text-transform: capitalize; white-space: nowrap; }
.badge-status::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: currentColor; opacity: .75; }
.status-vigente, .status-assinado, .status-concluida, .status-respondida { border-color: #c9e7d5; background: #e9f7ef; color: var(--app-success); }
.status-aguardando_assinatura, .status-pendente, .status-enviado { border-color: #efdda8; background: #fff6df; color: var(--app-warning); }
.status-cancelado, .status-rescindido, .status-atrasada { border-color: #efcdcd; background: #fceded; color: var(--app-danger); }
.status-rascunho, .status-encerrado { border-color: #dde3e7; background: #f1f4f5; color: #65737f; }
.empty { padding: 48px 20px; color: var(--app-muted); text-align: center; }
.empty a { color: var(--app-primary); font-weight: 650; }
.toolbar { display: flex; max-width: 720px; gap: 10px; margin-bottom: 22px; }
.authenticated .form-control, .authenticated .form-select { min-height: 42px; border-color: #d7e0e5; border-radius: 9px; background-color: #fff; color: var(--app-ink); padding: .65rem .8rem; font-size: 13px; }
.authenticated .form-control:focus, .authenticated .form-select:focus { border-color: #73bac6; box-shadow: 0 0 0 3px rgba(22,131,153,.1); }
.authenticated .form-label, .authenticated form > label { margin-bottom: 6px; color: #52616e; font-size: 12px; font-weight: 700; }
.form-panel { max-width: 980px; }
.base-tabs { display: flex; gap: 4px; margin: -8px 0 22px; padding: 5px; overflow-x: auto; border: 1px solid var(--app-line); border-radius: 11px; background: #fff; box-shadow: 0 1px 2px rgba(24,39,52,.025); scrollbar-width: thin; }
.base-tabs a { flex: 0 0 auto; padding: 9px 13px; border-radius: 8px; color: #687885; font-size: 12px; font-weight: 650; text-decoration: none; white-space: nowrap; transition: background .15s ease,color .15s ease; }
.base-tabs a:hover { background: #f2f6f7; color: #2f4553; }
.base-tabs a.active { background: var(--app-primary-soft); color: var(--app-primary-dark); box-shadow: inset 0 0 0 1px rgba(22,131,153,.08); }
.cadastro-panel .toolbar { max-width: 620px; }
.table-actions, .model-actions { display: flex; align-items: center; justify-content: flex-end; gap: 5px; }
.table-actions form, .model-actions form { margin: 0; }
.pagination-bar { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding-top: 17px; border-top: 1px solid var(--app-line); color: var(--app-muted); font-size: 12px; }
.pagination-bar > div { display: flex; gap: 6px; }
.subsection-head { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin: 2px 0 16px; }
.subsection-head h2 { margin: 0 0 3px; color: #253441; font-size: 18px; font-weight: 700; }
.subsection-head p { margin: 0; color: var(--app-muted); font-size: 13px; }
.model-card.is-archived { background: #f9fafb; opacity: .78; }
.model-actions { justify-content: flex-start; flex-wrap: wrap; margin-top: 20px; }
.form-actions { display: flex; justify-content: flex-end; gap: 9px; margin-top: 30px; padding-top: 21px; border-top: 1px solid var(--app-line); }
.back { display: inline-flex; margin-bottom: 3px; color: var(--app-primary); font-size: 12px; font-weight: 650; text-decoration: none; }
.authenticated .modal-content { border: 0; border-radius: 15px; box-shadow: 0 24px 80px rgba(25,42,55,.22); }
.authenticated .modal-header, .authenticated .modal-footer { border-color: var(--app-line); padding: 18px 20px; }
.authenticated .modal-body { padding: 20px; }
.authenticated .modal-title { color: #253441; font-weight: 700; }
.ajax-create-modal .modal-header { align-items: flex-start; }
.ajax-create-modal .modal-header .eyebrow { display: block; margin-bottom: 4px; }
.ajax-create-modal .modal-body { padding: 22px; }
.ajax-create-modal .modal-body > form.panel { max-width: none; padding: 0; border: 0; border-radius: 0; box-shadow: none; }
.ajax-create-modal .form-actions { margin-bottom: -3px; }
.cadastro-form-sections { display: grid; gap: 12px; }
.cadastro-form-section { padding: 15px; border: 1px solid #e1e8ec; border-radius: 12px; background: #fff; box-shadow: 0 1px 2px rgba(25,42,55,.025); }
.cadastro-form-section:not(:has(.cadastro-field)) { display: none; }
.cadastro-section-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cadastro-section-head > span { width: 7px; height: 7px; flex: none; border-radius: 50%; background: var(--app-primary); box-shadow: 0 0 0 4px var(--app-primary-soft); }
.cadastro-section-head h3 { margin: 0; color: #2c404e; font-size: 12px; font-weight: 800; letter-spacing: .055em; text-transform: uppercase; }
.cadastro-form-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 12px; }
.cadastro-field { grid-column: span 3; min-width: 0; }
.cadastro-field--wide { grid-column: span 6; }
.cadastro-field--compact { grid-column: span 3; }
.cadastro-field--full { grid-column: 1 / -1; }
.cadastro-field--span-3 { grid-column: span 3; }
.cadastro-field--span-4 { grid-column: span 4; }
.cadastro-field--span-6 { grid-column: span 6; }
.cadastro-field--span-12 { grid-column: 1 / -1; }
.cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="documento"],
.cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="nome"],
.cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="razao_social"] { grid-column: span 4; }
.cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="cnpj"],
.cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="razao_social"],
.cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="nome_fantasia"] { grid-column: span 4; }
.cadastro-form[data-resource="clientes"][data-client-kind="pf"] [data-field="documento"],
.cadastro-form[data-resource="clientes"][data-client-kind="pj"] [data-field="documento"] { order: 1; }
.cadastro-form[data-resource="clientes"][data-client-kind="pf"] [data-field="nome"],
.cadastro-form[data-resource="clientes"][data-client-kind="pj"] [data-field="razao_social"] { order: 2; }
.cadastro-form[data-resource="clientes"][data-client-kind="pf"] [data-field="razao_social"],
.cadastro-form[data-resource="clientes"][data-client-kind="pj"] [data-field="nome"] { order: 3; }
.ajax-create-modal .modal-dialog.modal-xl { width: calc(100% - 32px); max-width: 1180px; }
.ajax-quick-option-modal { z-index: 1085; }
.ajax-quick-option-modal .modal-dialog { max-width: 760px; }
.ajax-create-modal .modal-content { overflow: hidden; border-radius: 20px; box-shadow: 0 30px 90px rgba(25,42,55,.24); }
.ajax-create-modal .modal-header { position: relative; min-height: 84px; padding: 19px 72px 16px 22px; background: linear-gradient(135deg,#f7fbfc 0%,#eef7f8 100%); border-bottom: 1px solid #dce8eb; }
.ajax-create-modal .modal-header::before { content: ""; position: absolute; inset: 0 auto 0 0; width: 4px; background: linear-gradient(180deg,var(--app-primary),#5f9bd1); }
.ajax-create-modal .modal-header .btn-close { position: absolute; top: 18px; right: 20px; width: 34px; height: 34px; margin: 0!important; padding: 0!important; border-radius: 9px; background-color: rgba(255,255,255,.82); background-position: center; background-size: 11px; box-shadow: 0 1px 4px rgba(25,42,55,.08); }
.ajax-modal-heading .modal-title { margin: 2px 0 3px; color: #203441; font-size: 20px; font-weight: 750; letter-spacing: -.025em; }
.ajax-modal-heading p { margin: 0; color: #71818d; font-size: 12px; }
.ajax-create-modal .modal-body { padding: 18px; background: #f7f9fa; }
.ajax-create-modal .modal-body > form.panel { background: transparent; }
.authenticated .cadastro-form .form-control,.authenticated .cadastro-form .form-select { min-height: 37px; padding: .42rem .65rem; font-size: 12.5px; }
.authenticated .cadastro-form textarea.form-control { min-height: 76px; }
.ajax-create-modal .cadastro-field .form-label { margin-bottom: 5px; color: #425563; font-size: 10.5px; letter-spacing: .015em; }
.ajax-create-modal .cadastro-field .form-control,.ajax-create-modal .cadastro-field .form-select { min-height: 37px; border-color: #d5e0e5; box-shadow: 0 1px 2px rgba(25,42,55,.025); }
.ajax-create-modal .cadastro-field .document-check { width: 38px; min-width: 38px; min-height: 37px; padding: 0; }
.ajax-create-modal .cadastro-field .document-check-icon { width: 17px; height: 17px; font-size: 10px; }
.ajax-create-modal .cadastro-field .form-control:hover,.ajax-create-modal .cadastro-field .form-select:hover { border-color: #bdccd3; }
.ajax-create-modal .cadastro-field .form-control:focus,.ajax-create-modal .cadastro-field .form-select:focus { border-color: #6db7c3; box-shadow: 0 0 0 3px rgba(22,131,153,.105); }
.ajax-create-modal .form-actions { position: sticky; bottom: -18px; z-index: 2; margin: 18px -18px -18px; padding: 12px 18px; border-top: 1px solid #dfe7eb; background: rgba(255,255,255,.94); box-shadow: 0 -8px 24px rgba(31,51,65,.045); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.ajax-create-modal .form-actions .btn-primary { min-width: 150px; }
.modal-loading { min-height: 160px; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--app-muted); }
.ajax-form-error { margin-bottom: 18px; font-size: 12px; }
.ajax-toast { position: fixed; right: 22px; bottom: 22px; z-index: 1090; max-width: min(380px, calc(100vw - 30px)); padding: 12px 16px; border-radius: 10px; background: #203443; color: #fff; box-shadow: 0 16px 42px rgba(17,34,46,.24); font-size: 13px; font-weight: 650; opacity: 0; pointer-events: none; transform: translateY(10px); transition: opacity .18s ease, transform .18s ease; }
.ajax-toast.show { opacity: 1; transform: translateY(0); }
.ajax-toast.error { background: #a93d3d; }
.ajax-toast.info { background: #24566a; }

/* Configurações */
.settings-page-head { margin-bottom: 26px; }
.settings-section + .settings-section { margin-top: 30px; }
.settings-section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 18px; margin-bottom: 14px; }
.settings-section-head h2 { margin: 0 0 4px; color: #253441; font-size: 18px; font-weight: 720; letter-spacing: -.015em; }
.settings-section-head p { margin: 0; color: var(--app-muted); font-size: 13px; }
.settings-count { flex: none; color: var(--app-muted); font-size: 12px; }
.setup-card { width: 100%; display: flex; align-items: center; gap: 15px; padding: 18px 20px; border: 1px solid var(--app-line); border-radius: var(--app-radius); background: linear-gradient(100deg,#fff 0%,#f8fcfc 100%); color: var(--app-ink); box-shadow: var(--app-shadow); text-align: left; transition: transform .16s ease,border-color .16s ease,box-shadow .16s ease; }
.setup-card:hover { border-color: #b7dce1; box-shadow: 0 14px 34px rgba(24,39,52,.08); transform: translateY(-1px); }
.setup-card-icon { width: 45px; height: 45px; display: grid; place-items: center; flex: none; border-radius: 12px; background: var(--app-primary-soft); color: var(--app-primary); }
.setup-card-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; }
.setup-card-copy { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.setup-card-copy strong { color: #263743; font-size: 14px; }
.setup-card-copy small { margin-top: 3px; color: var(--app-muted); font-size: 12px; }
.setup-card-arrow { color: var(--app-primary); font-size: 18px; }
.configuration-status { display: inline-flex; align-items: center; gap: 6px; flex: none; padding: 5px 9px; border: 1px solid #e8d7a4; border-radius: 999px; background: #fff7e4; color: #9d6c12; font-size: 10px; font-weight: 750; white-space: nowrap; }
.configuration-status i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.integration-grid { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 15px; }
.integration-card { min-width: 0; min-height: 178px; display: flex; flex-direction: column; padding: 17px; border: 1px solid var(--app-line); border-radius: 13px; background: #fff; color: var(--app-ink); box-shadow: 0 1px 2px rgba(24,39,52,.025); text-align: left; transition: transform .16s ease,border-color .16s ease,box-shadow .16s ease; }
.integration-card:hover { border-color: #b8dce1; box-shadow: 0 12px 28px rgba(24,39,52,.075); transform: translateY(-2px); }
.integration-card-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; margin-bottom: 13px; }
.integration-icon { width: 39px; height: 39px; display: grid; place-items: center; border-radius: 10px; background: var(--app-primary-soft); color: var(--app-primary); font-size: 17px; }
.integration-card > strong { color: #293a47; font-size: 14px; }
.integration-card > small { min-height: 36px; margin-top: 4px; color: var(--app-muted); font-size: 12px; line-height: 1.45; }
.integration-action { display: flex; align-items: center; gap: 6px; margin-top: auto; padding-top: 13px; color: var(--app-primary); font-size: 11px; font-weight: 750; }
.integration-action b { font-size: 14px; transition: transform .15s ease; }
.integration-card:hover .integration-action b { transform: translateX(3px); }
.configuration-modal-heading { display: flex; align-items: center; gap: 12px; }
.configuration-modal-heading p { margin: 4px 0 0; color: var(--app-muted); font-size: 12px; }
.configuration-modal-icon { width: 42px; height: 42px; display: grid; place-items: center; flex: none; border-radius: 11px; background: var(--app-primary-soft); color: var(--app-primary); font-size: 18px; }
.configuration-notice { display: flex; flex-direction: column; gap: 3px; margin-bottom: 20px; padding: 12px 14px; border: 1px solid #d8e8eb; border-radius: 10px; background: #f2f9fa; color: #315967; }
.configuration-notice strong { font-size: 12px; }
.configuration-notice span { font-size: 11px; }
.integration-state { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 20px; padding: 13px 14px; border: 1px solid var(--app-line); border-radius: 10px; background: #f8fafb; }
.integration-state > div { display: flex; flex-direction: column; }
.integration-state strong { color: #344754; font-size: 12px; }
.integration-state span:not(.configuration-status) { margin-top: 2px; color: var(--app-muted); font-size: 11px; }

/* Wizard de contratos */
.contract-page-head { margin-bottom: 20px; }
.contract-page-head .back { display: block; }
.contract-wizard { max-width: 1240px; margin: 0 auto; padding: 0; overflow: hidden; }
.wizard-progress { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); padding: 0 18px; border-bottom: 1px solid var(--app-line); background: #f9fbfc; }
.wizard-progress-item { position: relative; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 17px 7px 15px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: #84919b; font: inherit; cursor: pointer; transition: color .16s ease,background .16s ease,border-color .16s ease; }
.wizard-progress-item:not(:last-child)::after { content: ""; position: absolute; right: -5px; width: 10px; height: 1px; background: #dbe4e8; }
.wizard-progress-item > span { width: 25px; height: 25px; display: grid; place-items: center; flex: none; border: 1px solid #d5e0e4; border-radius: 50%; background: #fff; font-size: 10px; font-weight: 800; }
.wizard-progress-item small { overflow: hidden; font-size: 10px; font-weight: 750; text-overflow: ellipsis; white-space: nowrap; }
.wizard-progress-item.active { border-color: var(--app-primary); color: var(--app-primary-dark); background: linear-gradient(180deg,transparent,rgba(22,131,153,.045)); }
.wizard-progress-item.active > span { border-color: var(--app-primary); background: var(--app-primary); color: #fff; box-shadow: 0 0 0 4px rgba(22,131,153,.1); }
.wizard-progress-item.complete { color: var(--app-success); }
.wizard-progress-item.complete > span { border-color: #b8dfc9; background: #eaf7ef; color: var(--app-success); }
.wizard-progress-item.complete > span { font-size: 0; }
.wizard-progress-item.complete > span::after { content: "✓"; font-size: 11px; }
.wizard-progress-item:disabled { cursor: default; opacity: .76; }
.wizard-stage { padding: 25px 28px 22px; background: linear-gradient(180deg,#fff 0%,#fdfefe 100%); }
.wizard-step[hidden] { display: none!important; }
.wizard-step { animation: wizard-in .2s ease; }
.wizard-step--choice { max-width: 920px; margin: 0 auto; }
@keyframes wizard-in { from { opacity: 0; transform: translateX(8px); } to { opacity: 1; transform: translateX(0); } }
.wizard-step-head { margin-bottom: 23px; outline: 0; }
.wizard-step-head > span { color: var(--app-primary); font-size: 9px; font-weight: 850; letter-spacing: .13em; text-transform: uppercase; }
.wizard-step-head h2 { margin: 6px 0 4px; color: #243745; font-size: 23px; font-weight: 750; letter-spacing: -.025em; }
.wizard-step-head p { margin: 0; color: var(--app-muted); font-size: 12px; }
.wizard-choice-card { width: 100%; padding: 20px; border: 1px solid #dbe6ea; border-radius: 13px; background: linear-gradient(145deg,#f9fbfc,#f5f9fa); box-shadow: 0 8px 26px rgba(32,55,69,.045); }
.wizard-select-action { display: flex; align-items: stretch; gap: 9px; }
.wizard-select-action .form-select { flex: 1; min-width: 0; }
.wizard-select-action .btn { white-space: nowrap; }
.wizard-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 22px; padding-top: 15px; border-top: 1px solid var(--app-line); }
.wizard-actions > :only-child { margin-left: auto; }
.wizard-actions .btn-primary { min-width: 132px; }
.wizard-fields { display: grid; grid-template-columns: repeat(12,minmax(0,1fr)); gap: 14px; }
.wizard-field { grid-column: span 4; min-width: 0; }
.wizard-field.span-1 { grid-column: span 1; }.wizard-field.span-3 { grid-column: span 3; }.wizard-field.span-4 { grid-column: span 4; }.wizard-field.span-5 { grid-column: span 5; }.wizard-field.span-6 { grid-column: span 6; }.wizard-field.span-8 { grid-column: span 8; }.wizard-field.span-12 { grid-column: 1/-1; }
.wizard-inline-select { display: flex; align-items: stretch; }
.wizard-inline-select .form-select { min-width: 0; border-radius: 9px 0 0 9px; }
.wizard-inline-select .btn { width: auto; min-width: 40px; padding-inline: 11px; border-left: 0; border-radius: 0 9px 9px 0; }
.wizard-field-help { display: block; min-height: 15px; margin-top: 4px; color: var(--app-muted); font-size: 10px; }
.wizard-insurance-fields { padding: 17px; border: 1px solid #dfe8ec; border-radius: 12px; background: #f9fbfc; }
.wizard-review { display: grid; grid-template-columns: repeat(4,minmax(0,1fr)); gap: 10px; margin-top: 16px; }
.wizard-review > div { min-width: 0; padding: 13px 14px; border: 1px solid #e2e9ed; border-radius: 10px; background: #fff; }
.wizard-review small { display: block; margin-bottom: 4px; color: #83909a; font-size: 9px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; }
.wizard-review strong { display: block; overflow: hidden; color: #344957; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

/* Menu recolhido */
.sidebar.collapsed { width: 78px; }
.sidebar.collapsed .sidebar-brand-row { padding-inline: 18px; }
.sidebar.collapsed .app-brand-logo { width: 40px; height: 40px; border-radius: 11px; object-fit: cover; object-position: left center; }
.sidebar.collapsed .app-brand-copy, .sidebar.collapsed .nav-section-label, .sidebar.collapsed .nav-link span, .sidebar.collapsed .nav-chevron, .sidebar.collapsed .nav-submenu, .sidebar.collapsed .profile-copy, .sidebar.collapsed .sidebar-profile form { display: none; }
.sidebar.collapsed .sidebar-collapse { position: absolute; top: 54px; right: 5px; width: 24px; height: 24px; border: 1px solid rgba(255,255,255,.09); background: #263d4e; }
.sidebar.collapsed .sidebar-collapse svg { width: 14px; transform: rotate(180deg); }
.sidebar.collapsed .sidebar-nav { padding: 13px 10px; }
.sidebar.collapsed .nav-section { padding-block: 10px; }
.sidebar.collapsed .sidebar-nav .nav-link { justify-content: center; padding-inline: 0; }
.sidebar.collapsed .sidebar-nav .nav-link.active { box-shadow: inset 2px 0 #5f9bd1; }
.sidebar.collapsed .sidebar-profile { justify-content: center; margin-inline: 10px; padding-inline: 0; }
.app-shell.sidebar-collapsed { margin-left: 78px; }

/* Login: preservado como estava */
.guest .brand { font-size: 23px; font-weight: 800; letter-spacing: -1px; color: white; text-decoration: none; }
.guest .brand span { color: var(--lime); }
.login-page { min-height: 100vh; display: grid; grid-template-columns: minmax(400px,42%) 1fr; background: white; }
.login-panel { position: relative; padding: 8vh 9vw; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.login-panel > form { width: min(100%, 420px); }
.login-tagline, .login-security { text-align: center; }
.login-footer { position: absolute; right: 9vw; bottom: 24px; left: 9vw; color: #87939d; font-size: 11px; text-align: center; }
.login-footer a { color: var(--green); font-weight: 700; text-decoration: none; }
.login-footer a:hover { text-decoration: underline; }
.guest .brand-dark { color: var(--ink); }
.login-page .form-label { font-size: 13px; font-weight: 650; }
.login-page .form-control { border-color: #d8e0da; padding: .7rem .85rem; }
.login-page .btn-primary { --bs-btn-bg: var(--green); --bs-btn-border-color: var(--green); --bs-btn-hover-bg: #08365d; }
.login-art { background: linear-gradient(145deg,rgba(6,38,77,.62),rgba(9,71,125,.38)),url('/assets/bg.jpg') center/cover; display: flex; align-items: end; padding: 10%; color: white; }
.login-art h1 { margin: 20px 0; font-size: 54px; line-height: 1.05; letter-spacing: -2.5px; }
.login-art em { color: var(--lime); font-style: normal; }
.login-art p { max-width: 560px; color: #d8e5de; font-size: 18px; }
.guest .login-art .eyebrow { color: #fff; }

@media (max-width: 1100px) {
    .metric-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .integration-grid { grid-template-columns: repeat(2,minmax(0,1fr)); }
    .authenticated .content { padding-inline: 26px; }
    .cadastro-field { grid-column: span 4; }
    .cadastro-field--compact { grid-column: span 3; }
    .cadastro-field--wide { grid-column: span 6; }
    .cadastro-field--full { grid-column: 1 / -1; }
    .wizard-progress-item { flex-direction: column; gap: 5px; }
}

@media (max-width: 980px) {
    .authenticated .sidebar, .authenticated .sidebar.collapsed { width: 280px; transform: translateX(-105%); }
    .authenticated .sidebar.mobile-open { transform: translateX(0); }
    .sidebar.collapsed .app-brand-copy, .sidebar.collapsed .nav-section-label, .sidebar.collapsed .nav-link span, .sidebar.collapsed .nav-chevron, .sidebar.collapsed .profile-copy, .sidebar.collapsed .sidebar-profile form { display: flex; }
    .sidebar.collapsed .nav-section-label { display: block; }
    .sidebar.collapsed .nav-submenu.open { display: block; }
    .sidebar.collapsed .sidebar-collapse { display: none; }
    .sidebar.collapsed .sidebar-nav { padding: 0 12px 18px; }
    .sidebar.collapsed .nav-section { padding: 13px 0 12px; }
    .sidebar.collapsed .sidebar-nav .nav-link { justify-content: flex-start; padding-inline: 11px; }
    .sidebar.collapsed .sidebar-profile { justify-content: flex-start; margin-inline: 12px; padding-inline: 7px; }
    .sidebar-collapse { display: none; }
    .app-shell, .app-shell.sidebar-collapsed { margin-left: 0; }
    .mobile-menu { display: grid; }
    .sidebar-overlay.show { position: fixed; inset: 0; z-index: 35; display: block; background: rgba(21,35,45,.45); backdrop-filter: blur(2px); }
}

@media (max-width: 700px) {
    .authenticated .topbar { height: 62px; padding: 0 14px; gap: 9px; }
    .global-search { width: auto; flex: 1; }
    .global-search input { padding-right: 12px; }
    .global-search kbd { display: none; }
    .topbar-actions { margin-left: 0; gap: 5px; }
    .topbar-user { padding-left: 7px; }
    .authenticated .content { padding: 24px 15px 40px; }
    .page-head { align-items: flex-start; flex-direction: column; gap: 16px; margin-bottom: 22px; }
    .page-head > div:last-child { display: flex; flex-wrap: wrap; gap: 7px; }
    .metric-grid { grid-template-columns: 1fr; gap: 12px; }
    .metric { padding: 17px; }
    .panel { padding: 17px; }
    .dashboard-panel { padding: 0; }
    .dashboard-panel > .panel-head { padding: 17px; }
    .toolbar { max-width: none; flex-direction: column; }
    .base-tabs { margin-top: -4px; }
    .table-actions { justify-content: flex-start; }
    .integration-grid { grid-template-columns: 1fr; }
    .setup-card { align-items: flex-start; flex-wrap: wrap; }
    .setup-card .configuration-status { margin-left: 60px; }
    .setup-card-arrow { margin-left: auto; }
    .settings-section-head { align-items: flex-start; flex-direction: column; gap: 6px; }
    .configuration-modal-heading { align-items: flex-start; }
    .integration-state { align-items: flex-start; flex-direction: column; }
    .form-actions { flex-wrap: wrap; }
    .form-actions .btn { flex: 1; }
    .ajax-create-modal .modal-dialog { width: calc(100% - 18px); margin: 9px auto; }
    .ajax-create-modal .modal-content { border-radius: 16px; }
    .ajax-create-modal .modal-header { min-height: 78px; padding: 16px 62px 14px 17px; }
    .ajax-create-modal .modal-header .btn-close { top: 14px; right: 15px; }
    .ajax-modal-heading .modal-title { font-size: 18px; }
    .ajax-modal-heading p { max-width: 440px; font-size: 11px; }
    .ajax-create-modal .modal-body { padding: 12px; }
    .cadastro-form-sections { gap: 9px; }
    .cadastro-form-section { padding: 12px; }
    .cadastro-form-grid { gap: 11px 10px; }
    .cadastro-field,.cadastro-field--compact { grid-column: span 6; }
    .cadastro-field--wide,.cadastro-field--full { grid-column: 1 / -1; }
    .cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="documento"],
    .cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="nome"],
    .cadastro-form[data-resource="clientes"] .cadastro-form-section--registration [data-field="razao_social"] { grid-column: 1 / -1; }
    .cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="cnpj"],
    .cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="razao_social"],
    .cadastro-form[data-resource="empresas"] .cadastro-form-section--registration [data-field="nome_fantasia"] { grid-column: 1 / -1; }
    .ajax-create-modal .form-actions { bottom: -12px; margin: 14px -12px -12px; padding: 11px 12px; }
    .contract-wizard { margin-inline: -2px; }
    .wizard-progress { grid-template-columns: repeat(6,74px); justify-content: start; padding: 0 8px; overflow-x: auto; scrollbar-width: none; scroll-behavior: smooth; overscroll-behavior-inline: contain; }
    .wizard-progress::-webkit-scrollbar { display: none; }
    .wizard-progress-item { padding: 11px 4px 9px; }
    .wizard-progress-item small { max-width: 68px; }
    .wizard-stage { min-height: 380px; padding: 19px 15px; }
    .wizard-step-head { margin-bottom: 17px; }
    .wizard-step-head h2 { font-size: 20px; }
    .wizard-choice-card { padding: 15px; }
    .wizard-select-action { align-items: stretch; flex-direction: column; }
    .wizard-fields { gap: 12px 10px; }
    .wizard-field,.wizard-field.span-3,.wizard-field.span-4,.wizard-field.span-5,.wizard-field.span-6,.wizard-field.span-8 { grid-column: span 6; }
    .wizard-field--title,.wizard-field--model,.wizard-field--supervisor { grid-column: 1/-1!important; }
    .wizard-field.span-1 { grid-column: span 3; }
    .wizard-field.span-12 { grid-column: 1/-1; }
    .wizard-review { grid-template-columns: repeat(2,minmax(0,1fr)); }
}

@media (max-width: 440px) {
    .ajax-create-modal .modal-dialog { width: 100%; min-height: 100dvh; margin: 0; }
    .ajax-create-modal .modal-dialog-scrollable .modal-content { max-height: 100dvh; min-height: 100dvh; border-radius: 0; }
    .cadastro-field,.cadastro-field--compact,.cadastro-field--wide,.cadastro-field--full { grid-column: 1 / -1; }
    .ajax-create-modal .form-actions { flex-direction: column-reverse; }
    .ajax-create-modal .form-actions .btn { width: 100%; }
    .wizard-field,.wizard-field.span-1,.wizard-field.span-3,.wizard-field.span-4,.wizard-field.span-5,.wizard-field.span-6,.wizard-field.span-8,.wizard-field.span-12 { grid-column: 1/-1; }
    .wizard-review { grid-template-columns: 1fr; }
    .wizard-actions { align-items: stretch; flex-direction: column-reverse; }
    .wizard-actions .btn { width: 100%; }
}

@media (max-width: 900px) {
    .login-page { display: block; }
    .login-panel { min-height: 100vh; padding: 40px; }
    .login-art { display: none; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; }
}
