:root {
    --bg: #f5f6f7;
    --panel: #ffffff;
    --panel-soft: #fbfbfc;
    --line: #e3e5e8;
    --line-strong: #ccd1d7;
    --text: #22252a;
    --muted: #6e737c;
    --muted-2: #9aa0a8;
    --dark: #3f3f46;
    --dark-hover: #55555e;
    --btn: #eef0f2;
    --btn-hover: #f6f7f8;
    --success: #176b45;
    --danger: #ad244b;
    --danger-soft: rgba(215, 48, 92, .09);
    --success-soft: rgba(28, 126, 78, .09);
    --radius: 6px;
    --shadow: 0 16px 40px rgba(20, 25, 34, .055);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

html {
    min-height: 100%;
    font-family: var(--font);
    font-size: 14px;
    color: var(--text);
    background: var(--bg);
    -webkit-font-smoothing: antialiased;
    text-rendering: geometricPrecision;
}

body {
    min-height: 100%;
    margin: 0;
    background: var(--bg);
}

button,
input,
select,
textarea {
    font: inherit;
}

button {
    cursor: pointer;
}

a {
    color: inherit;
    text-decoration: none;
}

svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    display: block;
    flex: 0 0 auto;
}

.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

.sidebar {
    width: 220px;
    background: #fff;
    border-right: 1px solid var(--line);
    padding: 18px;
    position: sticky;
    top: 0;
    height: 100vh;
    z-index: 30;
    display: flex;
    flex-direction: column;
    flex: 0 0 220px;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 4px 18px;
    border-bottom: 1px solid var(--line);
    min-width: 0;
}

.brand-mark,
.auth-logo {
    width: 42px;
    height: 42px;
    border-radius: var(--radius);
    background: #eff0f240;
    display: grid;
    place-items: center;
    color: #4b4f56;
    flex: 0 0 auto;
}

.brand strong {
    display: block;
    font-size: 17px;
    line-height: 1.15;
    letter-spacing: -.02em;
}

.brand small {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: var(--muted);
}

.nav {
    min-height: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding-top: 16px;
}

.nav-main {
    display: grid;
    gap: 6px;
}

.nav-link,
.nav-sublink {
    min-height: 42px;
    border-radius: var(--radius);
    color: #4e535a;
    transition: background .14s ease, color .14s ease, border-color .14s ease;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
}

.nav-link:hover,
.nav-link.active,
.nav-sublink:hover,
.nav-sublink.active {
    background: #f1f2f4;
    color: #22252a;
    cursor: pointer;
}

.logout-link {
    margin-top: auto;
    border: 1px solid #dcdcdc;
}

.logout-link:hover {
    background: rgba(180, 35, 76, .09);
    color: var(--danger);
}

.nav-group {
    border-radius: var(--radius);
}

.nav-group summary {
    list-style: none;
}

.nav-group summary::-webkit-details-marker {
    display: none;
}

.nav-summary {
    width: 100%;
    user-select: none;
}

.nav-summary i {
    margin-left: auto;
    display: grid;
    place-items: center;
    color: var(--muted);
    transition: transform .14s ease;
}

.nav-group[open] .nav-summary i {
    transform: rotate(180deg);
}

.nav-submenu {
    display: grid;
    gap: 4px;
    padding: 6px 6px 6px 6px;
    border: 1px solid #ebebeb57;
    border-radius: 6px;
    margin-top: 5px;
}

.nav-sublink {
    display: flex;
    align-items: center;
    gap: 9px;
    min-height: 36px;
    padding: 8px 10px;
    font-size: 13px;
}

.nav-sublink svg {
    width: 16px;
    height: 16px;
}

.main {
    min-width: 0;
    flex: 1;
}

.topbar {
    min-height: 78px;
    background: #fff;
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    padding: 18px 30px;
    position: sticky;
    top: 0;
    z-index: 20;
}

.topbar-title {
    min-width: 0;
}

.topbar h1 {
    margin: 0;
    font-size: 21px;
    line-height: 1.15;
    letter-spacing: -.025em;
}

.topbar p {
    margin: 7px 0 0;
    color: var(--muted);
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 14px;
    left: 14px;
    width: 42px;
    height: 42px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: #3d4147;
    z-index: 60;
    box-shadow: var(--shadow);
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(20, 22, 26, .34);
    z-index: 25;
}

.page-content {
    padding: 28px 30px 40px;
}

.card {
    background: var(--panel);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.soft-card {
    box-shadow: none;
    background: var(--panel-soft);
}

.toolbar,
.pts-actions {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 14px;
    padding: 16px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.toolbar {
    display: grid;
    gap: 5px;
    grid-auto-flow: column;
    justify-content: stretch;
}
.pts-actions > div:first-child {
    min-width: min(420px, 100%);
    flex: 1 1 420px;
}

.pts-actions h2,
.card h2,
.admin-form h2,
.table-card h2 {
    margin: 0 0 6px;
    font-size: 18px;
    line-height: 1.25;
    letter-spacing: -.015em;
}

.pts-actions p,
.modal p,
.help-text {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.field,
.form-stack label {
    display: grid;
    gap: 7px;
}

.field span,
.form-stack label span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
}

.inline-field {
    width: 100%;
}

.inline-field.small {
    width: min(156px, 100%);
}

.unit-switch {
    min-width: min(260px, 100%);
}

.unit-switch select,
.field select,
.field input,
.field textarea,
.form-stack input,
.form-stack select,
.form-stack textarea,
.excel-table input,
.excel-table select,
.excel-table textarea,
.hash-search input {
    border: 1px solid var(--line-strong);
    background: #fff;
    color: var(--text);
    border-radius: var(--radius);
    outline: none;
    min-height: 38px;
    padding: 9px 10px;
    transition: border-color .14s ease, box-shadow .14s ease, background .14s ease;
    width: 100%;
    height: 41px;
}

.unit-switch select:focus,
.field select:focus,
.field input:focus,
.field textarea:focus,
.form-stack input:focus,
.form-stack select:focus,
.form-stack textarea:focus,
.excel-table input:focus,
.excel-table select:focus,
.excel-table textarea:focus,
.hash-search input:focus {
    border-color: #a8adb4;
    box-shadow: 0 0 0 3px rgba(63, 63, 70, .08);
}

.btn,
.icon-btn {
    border: 1px solid var(--line-strong);
    background: var(--btn);
    color: #33363b;
    border-radius: var(--radius);
    min-height: 38px;
    padding: 9px 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background .14s ease, border-color .14s ease, transform .14s ease;
}

.btn:hover,
.icon-btn:hover {
    background: var(--btn-hover);
    border-color: #bcc2c9;
}

.btn:active,
.icon-btn:active {
    transform: translateY(1px);
}

.btn-dark {
    background: var(--dark);
    color: #fff;
    border-color: var(--dark);
}

.btn-dark:hover {
    background: var(--dark-hover);
    border-color: var(--dark-hover);
}

.btn.tiny {
    min-height: 30px;
    padding: 6px 10px;
    font-size: 12px;
}

.action-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: end;
}

.cards-grid {
    display: grid;
    grid-template-columns: repeat(6, minmax(140px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.metric-card {
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
    min-width: 0;
}

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

.metric-card strong {
    display: block;
    margin-top: 8px;
    font-size: clamp(22px, 2.2vw, 29px);
    line-height: 1;
    letter-spacing: -.04em;
}

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

.chart-card {
    padding: 16px;
    min-height: 340px;
    overflow: hidden;
}

.chart-card h2 {
    font-size: 17px;
}

/* ApexCharts precisa escapar da regra global de SVG usada nos ícones do sistema.
   Sem isso, os gráficos ficam reduzidos a 18x18px e parecem vazios. */
.chart-card > div[id^="chart"] {
    min-height: 290px;
}

.chart-card .apexcharts-canvas,
.chart-card .apexcharts-canvas svg.apexcharts-svg {
    width: 100% !important;
    max-width: 100% !important;
}

.chart-card .apexcharts-canvas svg.apexcharts-svg {
    height: 100% !important;
    display: block;
    flex: none;
    fill: initial;
}

.consulta-action-head,
.consulta-action-col {
    width: 92px;
    min-width: 92px;
    text-align: center;
}

.consulta-delete-btn {
    width: 34px;
    height: 34px;
    display: inline-grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    color: var(--danger);
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.consulta-delete-btn:hover {
    background: var(--danger-soft);
    border-color: rgba(173, 36, 75, .28);
}

.consulta-delete-btn:disabled {
    opacity: .55;
    cursor: not-allowed;
}

.excel-wrap {
    overflow: auto;
    max-width: 100%;
    border-radius: var(--radius);
    max-height: calc(100vh - 235px);
}

.excel-table {
    width: 100%;
    min-width: 2460px;
    border-collapse: separate;
    border-spacing: 0;
    table-layout: fixed;
    font-size: 13px;
}

.excel-table th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: #f0f1f3;
    color: #2d3137;
    border-bottom: 1px solid var(--line-strong);
    border-right: 1px solid var(--line);
    text-align: left;
    font-size: 12px;
    font-weight: 750;
    padding: 11px 10px;
    white-space: nowrap;
}

.excel-table td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    background: #fff;
    padding: 8px;
    vertical-align: top;
}

.excel-table tr:hover td {
    background: #fcfcfd;
}

.pts-row.is-locked td {
    background: #fbfbfc;
}

.pts-row.is-locked:hover td {
    background: #f7f8fa;
}

.pts-row.is-locked input:disabled, .pts-row.is-locked textarea:disabled, .pts-row.is-locked select:disabled, .pts-row.is-locked button:disabled:not(.row-edit-btn):not(.copy-row-hash) {
    opacity: 1;
    color: #303030;
    background: #f3f4f6;
    border-color: #d1d1d1;
    cursor: not-allowed;
}

.pts-row.is-editing td {
    background: #fff;
}

.edit-control-cell {
    text-align: center;
    background: #fafafa !important;
}

.row-edit-btn {
    margin: 0 auto;
}

.row-edit-btn.is-editing {
    color: #fff;
    background: var(--dark);
    border-color: var(--dark);
}

.row-lock-status {
    display: block;
    margin-top: 6px;
    color: var(--muted);
    font-size: 11px;
    line-height: 1.2;
    white-space: nowrap;
}

.row-lock-status.is-editing {
    color: var(--success);
    font-weight: 700;
}

 .excel-table th:nth-child(1), .excel-table td:nth-child(1) { width: 72px; }
.excel-table th:nth-child(2), .excel-table td:nth-child(2) { width: 140px; }
.excel-table th:nth-child(3), .excel-table td:nth-child(3) { width: 180px; }
.excel-table th:nth-child(4), .excel-table td:nth-child(4) { width: 132px; }
.excel-table th:nth-child(5), .excel-table td:nth-child(5) { width: 82px; }
.excel-table th:nth-child(6), .excel-table td:nth-child(6) { width: 130px; }
.excel-table th:nth-child(7), .excel-table td:nth-child(7) { width: 190px; }
.excel-table th:nth-child(8), .excel-table td:nth-child(8) { width: 220px; }
.excel-table th:nth-child(9), .excel-table td:nth-child(9) { width: 200px; }
.excel-table th:nth-child(10), .excel-table td:nth-child(10) { width: 250px; }
.excel-table th:nth-child(11), .excel-table td:nth-child(11) { width: 250px; }
.excel-table th:nth-child(12), .excel-table td:nth-child(12) { width: 250px; }
.excel-table th:nth-child(13), .excel-table td:nth-child(13) { width: 500px; }
.excel-table th:nth-child(14), .excel-table td:nth-child(14) { width: 270px; }
.excel-table th:nth-child(15), .excel-table td:nth-child(15) { width: 270px; }
.excel-table th:nth-child(16), .excel-table td:nth-child(16) { width: 100px; }
.excel-table th:nth-child(17), .excel-table td:nth-child(17) { width: 235px; }
.excel-table th:nth-child(18), .excel-table td:nth-child(18) { width: 55px; }

.excel-table input, .excel-table textarea, .excel-table select {
    width: 100%;
    min-width: 0;
    box-shadow: none;
    padding: 5px 5px;
    height: 35px;
}

.excel-table textarea {
    min-height: 74px;
    resize: vertical;
}

.profession-dropdown {
    position: relative;
    display: grid;
    gap: 6px;
    min-width: 0;
}

.profession-toggle {
    width: 100%;
    min-height: 38px;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 18px;
    align-items: center;
    gap: 8px;
    border: 1px solid var(--line-strong);
    background: #fff;
    border-radius: var(--radius);
    padding: 8px 10px;
    color: var(--text);
    text-align: left;
    cursor: pointer;
}

.profession-toggle:hover {
    background: #f8f9fb;
}

.profession-toggle svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    opacity: .72;
    transition: transform .16s ease;
}

.profession-dropdown.is-open .profession-toggle svg {
    transform: rotate(180deg);
}

.profession-summary {
    display: block;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.profession-menu {
    border: 1px solid var(--line-strong);
    background: #fff;
    border-radius: var(--radius);
    padding: 6px;
    max-height: 178px;
    overflow: auto;
    box-shadow: 0 14px 35px rgba(20, 22, 26, .10);
}

.profession-menu[hidden] {
    display: none;
}

.profession-option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: var(--radius);
    color: var(--text);
    cursor: pointer;
    font-size: 13px;
}

.profession-option:hover {
    background: #f3f4f6;
}

.profession-option input {
    width: 16px !important;
    height: 16px;
    min-width: 16px !important;
    accent-color: var(--dark);
}

.profession-option span {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.profession-empty {
    padding: 10px;
    color: var(--muted);
    font-size: 12px;
}

.pts-row.is-locked .profession-toggle:disabled,
.pts-row.is-locked .profession-check:disabled {
    opacity: 1;
    color: #6f7680;
    background: #f3f4f6;
    border-color: #e0e3e7;
    cursor: not-allowed;
}

.profession-count,
.doc-name,
.hash-chip {
    display: block;
    color: var(--muted);
    font-size: 12px;
}

.profession-count {
    margin-top: 6px;
}

.monitor-stack,
.data-bubble-stack,
.doc-actions {
    display: grid;
    gap: 7px;
}

.monitor-line, .bubble-line {
    display: grid;
    grid-template-columns: minmax(100px, 1fr) 65px;
    gap: 6px;
    align-items: center;
    min-height: 36px;
}

.monitor-line span,
.bubble-line span {
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bubble-line .icon-btn {
    min-height: 34px;
    padding: 7px;
}

.acoes-pts-cell {
    display: grid;
    gap: 7px;
    align-items: start;
    min-width: 150px;
}

.acoes-pts-btn {
    width: 100%;
    justify-content: center;
    white-space: nowrap;
}

.acoes-pts-btn.has-value {
    background: var(--panel-soft);
    border-color: #b8bec6;
}

.acoes-pts-status {
    color: var(--muted);
    font-size: 12px;
}

.acoes-pts-status.is-filled {
    color: var(--success);
    font-weight: 650;
}

.profession-dependent {
    display: grid;
    gap: 8px;
}

.profession-line,
.profession-action-line,
.profession-text-line {
    display: grid;
    gap: 6px;
    align-items: center;
    min-height: 36px;
}

.profession-line,
.profession-action-line {
    grid-template-columns: minmax(72px, .85fr) minmax(0, 1.15fr);
    align-items: center;
}

.profession-action-line {
    grid-template-columns: minmax(125px, 0.75fr) minmax(100px, 1fr);
    align-items: center;
}

.profession-action-line .acoes-pts-status {
    grid-column: 2;
    margin-top: -2px;
    display: none;
}

.profession-text-line {
    grid-template-columns: minmax(75px, 1fr) minmax(0, 1.75fr);
}

.profession-line > span,
.profession-action-line > span,
.profession-text-line > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profession-text-line textarea {
    min-height: 78px;
}

.profession-dependent input,
.profession-dependent select,
.profession-dependent textarea {
    min-height: 36px;
}


.icon-btn {
    width: 38px;
    padding: 8px;
}

.doc-actions {
    grid-template-columns: 38px 38px;
    min-width: 0;
}

.doc-name {
    margin: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.hash-cell {
    display: grid;
    gap: 7px;
    align-items: start;
    grid-auto-columns: 130px 80px;
    grid-auto-flow: column;
}

.hash-chip {
    max-width: 100%;
    padding: 7px 8px;
    border: 1px solid var(--line);
    background: #fafafa;
    border-radius: var(--radius);
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.offline-banner {
    margin-bottom: 12px;
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(215, 48, 92, .22);
    border-radius: var(--radius);
    padding: 11px 14px;
    font-weight: 650;
}

.toast-stack {
    position: fixed;
    right: 18px;
    bottom: 18px;
    display: grid;
    gap: 10px;
    z-index: 1000;
    width: min(390px, calc(100vw - 36px));
}

.toast {
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: #fff;
    box-shadow: var(--shadow);
    padding: 12px 14px;
    color: var(--text);
    font-size: 13px;
    transition: opacity .2s ease, transform .2s ease;
}

.toast.success {
    background: #effbff;
    border-color: rgba(28, 126, 78, .24);
    color: var(--success);
}

.toast.error {
    background: #ffd0d0;
    border-color: rgba(215, 48, 92, .24);
    color: var(--danger);
}

.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 22, 26, .36);
    display: grid;
    place-items: center;
    padding: 18px;
    z-index: 500;
}

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

.modal {
    width: min(780px, 100%);
    max-height: min(92vh, 980px);
    overflow: auto;
    background: #fff;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    box-shadow: 0 28px 90px rgba(0, 0, 0, .18);
    padding: 18px;
    position: relative;
}

.small-modal {
    width: min(620px, 100%);
}

.doc-modal {
    width: min(1260px, calc(100vw - 28px));
    max-height: min(94vh, 1080px);
    padding: 20px;
}

.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
    border: 1px solid var(--line);
    background: var(--btn);
    border-radius: var(--radius);
    font-size: 22px;
    line-height: 1;
}

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

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

.modal-actions,
.modal-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    flex-wrap: wrap;
}

.doc-heading {
    padding-right: 42px;
}

.doc-heading h2 {
    margin-bottom: 6px;
}

.doc-heading p {
    max-width: 760px;
}

.doc-editor-shell {
    margin-top: 16px;
    border-radius: var(--radius);
    min-height: 460px;
}

.doc-editor-textarea {
    width: 100%;
    min-height: 610px;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    padding: 18px;
    outline: none;
    resize: vertical;
    font: 400 14px/1.5 Arial, Helvetica, sans-serif;
}

.doc-modal .tox.tox-tinymce {
    border: 1px solid var(--line-strong);
    border-radius: var(--radius);
    overflow: hidden;
}

.doc-modal .tox .tox-toolbar,
.doc-modal .tox .tox-toolbar__overflow,
.doc-modal .tox .tox-toolbar__primary,
.doc-modal .tox .tox-menubar {
    background: #f6f7f9;
}

.doc-modal .tox .tox-tbtn,
.doc-modal .tox .tox-mbtn {
    border-radius: var(--radius);
}

.doc-modal .tox .tox-edit-area::before {
    border: 0;
}

.doc-modal .tox .tox-statusbar {
    border-top: 1px solid var(--line);
    background: #fafafa;
}

.auth-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background-image: url('../../background_fuabc.png');
    background-position: bottom;
    background-size: cover;
}

.auth-card {
    width: min(420px, 100%);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 26px;
}

.auth-logo {
    margin-bottom: 16px;
    display: grid;
    width: 100%;
    background: none;
    height: 55px;
}

.auth-card h1 {
    margin: 0 0 6px;
    font-size: 22px;
    letter-spacing: -.02em;
    text-align: center;
}

.auth-card p {
    margin: 0 0 18px;
    color: var(--muted);
    text-align: center;
}

.form-stack {
    display: grid;
    gap: 13px;
}

.muted-link {
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.alert {
    border-radius: var(--radius);
    padding: 11px 12px;
    margin-bottom: 14px;
    font-size: 13px;
}

.alert-error {
    background: var(--danger-soft);
    color: var(--danger);
    border: 1px solid rgba(215, 48, 92, .24);
}

.alert-success {
    background: var(--success-soft);
    color: var(--success);
    border: 1px solid rgba(28, 126, 78, .24);
}

.admin-grid {
    display: grid;
    grid-template-columns: minmax(280px, 380px) minmax(0, 1fr);
    gap: 16px;
    align-items: start;
}

.admin-form,
.table-card {
    padding: 16px;
}

.table-scroll {
    width: 100%;
    overflow: auto;
}

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

.data-table th,
.data-table td {
    border-bottom: 1px solid var(--line);
    padding: 10px 8px;
    text-align: left;
    vertical-align: middle;
}

.data-table th {
    color: var(--muted);
    font-size: 12px;
    background: #fafafa;
    font-weight: 750;
}

.data-table .hash-col {
    font-family: ui-monospace, SFMono-Regular, Consolas, "Liberation Mono", monospace;
    font-size: 12px;
    color: var(--muted);
    max-width: 210px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.switch-row {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.switch-row input {
    display: none;
}

.switch-row i {
    width: 46px;
    height: 25px;
    background: #d7dade;
    border-radius: 999px;
    position: relative;
    transition: background .14s ease;
}

.switch-row i::after {
    content: "";
    position: absolute;
    top: 3px;
    left: 3px;
    width: 19px;
    height: 19px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .15);
    transition: transform .14s ease;
}

.switch-row input:checked + i {
    background: #56565f;
}

.switch-row input:checked + i::after {
    transform: translateX(21px);
}

.hash-search {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    padding: 16px;
    margin-bottom: 16px;
}

.hash-search .field {
    flex: 1 1 420px;
}

.hash-result {
    display: grid;
    gap: 16px;
}

.audit-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.audit-box {
    padding: 14px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.audit-box span {
    display: block;
    font-size: 12px;
    color: var(--muted);
    font-weight: 650;
    margin-bottom: 5px;
}

.audit-box strong {
    display: block;
    font-size: 14px;
    overflow-wrap: anywhere;
}

.payload-pre {
    margin: 0;
    padding: 14px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fafafa;
    overflow: auto;
    font-size: 12px;
    line-height: 1.55;
    color: #343840;
}

@media (max-width: 1240px) {
    .cards-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

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

@media (max-width: 980px) {
    .mobile-menu-btn {
        display: grid;
        place-items: center;
    }

    .app-shell {
        display: block;
    }

    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-105%);
        transition: transform .18s ease;
        box-shadow: 20px 0 60px rgba(0, 0, 0, .14);
    }

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

    .topbar {
        position: sticky;
        min-height: 68px;
        padding: 16px 20px 16px 68px;
    }

    .page-content {
        padding: 18px;
    }

    .chart-grid,
    .admin-grid,
    .form-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 720px) {
    .cards-grid,
    .audit-grid {
        grid-template-columns: 1fr;
    }

    .toolbar,
    .pts-actions,
    .modal-heading {
        align-items: stretch;
        flex-direction: column;
    }

    .inline-field,
    .toolbar .btn,
    .action-row .btn,
    .action-row .field,
    .unit-switch {
        width: 100%;
    }

    .action-row {
        width: 100%;
        display: grid;
        grid-template-columns: 1fr;
    }

    .excel-wrap {
        overflow: visible;
        max-height: none;
        border: 0;
        box-shadow: none;
        background: transparent;
    }

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

    .excel-table thead {
        display: none;
    }

    .excel-table tr {
        background: #fff;
        border: 1px solid var(--line);
        border-radius: var(--radius);
        box-shadow: var(--shadow);
        margin-bottom: 14px;
        overflow: hidden;
    }

    .excel-table td {
        border-right: 0;
        padding: 10px;
    }

    .excel-table td::before {
        content: attr(data-label);
        display: block;
        margin-bottom: 7px;
        color: var(--muted);
        font-size: 12px;
        font-weight: 750;
    }

    .doc-actions {
        grid-template-columns: 38px 38px minmax(0, 1fr);
    }

    .topbar h1 {
        font-size: 19px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: min(290px, calc(100vw - 34px));
        flex-basis: auto;
    }

    .page-content {
        padding: 14px;
    }

    .auth-card {
        padding: 20px;
    }
}

.mt-14 { margin-top: 14px; }

/* Ajustes PTS - filtros, responsividade e ações */
.pts-actions {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 18px;
    padding: 18px 20px;
}

.pts-title-block {
    min-width: 0;
}

.pts-filter-actions {
    display: grid;
    grid-template-columns: minmax(240px, 340px) auto;
    gap: 10px;
    align-items: end;
    justify-content: end;
}

.pts-filter-actions .btn {
    min-width: 122px;
}

.pts-bottom-actions {
    display: flex;
    justify-content: flex-start;
    gap: 10px;
    margin-top: 12px;
}

.pts-bottom-actions .btn {
    min-width: 126px;
}

.prospect-field {
    align-items: start;
}

.prospect-date-list {
    display: grid;
    gap: 8px;
}

.prospect-date-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 38px;
    gap: 8px;
    align-items: center;
}

.prospect-date-row .icon-btn {
    min-height: 38px;
}

.switch-row i {
    background: #d94c66;
}

.switch-row input:checked + i {
    background: #17834f;
}

.row-actions {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.danger-btn {
    color: var(--danger);
    background: rgba(173, 36, 75, .08);
    border-color: rgba(173, 36, 75, .18);
}

.danger-btn:hover {
    color: var(--danger);
    background: rgba(173, 36, 75, .13);
    border-color: rgba(173, 36, 75, .28);
}

@media (max-width: 900px) {
    .pts-actions,
    .pts-filter-actions {
        grid-template-columns: 1fr;
        align-items: stretch;
        justify-content: stretch;
    }

    .pts-filter-actions .btn,
    .pts-bottom-actions .btn,
    .unit-switch {
        width: 100%;
    }
}

@media (max-width: 520px) {
    .modal {
        padding: 16px;
    }

    .prospect-date-row {
        grid-template-columns: 1fr;
    }

    .prospect-date-row .icon-btn {
        width: 100%;
    }
}

/* Editor Word rich text */
@media (max-width: 760px) {
    .doc-modal {
        width: calc(100vw - 20px);
        padding: 14px;
    }

    .doc-heading {
        align-items: stretch;
        padding-right: 38px;
    }

    .doc-heading .btn {
        width: 100%;
    }

    .doc-editor-shell,
    .doc-editor-textarea {
        min-height: 430px;
    }

    .doc-modal .tox .tox-toolbar__primary {
        overflow-x: auto;
    }
}

/* Ajustes PTS: indicadores, filtros, botão superior e arquivo clicável */
.pts-indicators-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
    margin-bottom: 14px;
}

.indicator-card {
    min-height: 86px;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
    display: grid;
    align-content: space-between;
    gap: 10px;
}

.indicator-card span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
}

.indicator-card strong {
    color: var(--text);
    font-size: 26px;
    line-height: 1;
    letter-spacing: -.04em;
}

.pts-filter-panel {
    padding: 16px;
    margin-bottom: 12px;
}

.pts-filter-title {
    margin-bottom: 13px;
}

.pts-filter-title h3 {
    margin: 0 0 5px;
    font-size: 15px;
    line-height: 1.25;
    letter-spacing: -.015em;
}

.pts-filter-title p {
    margin: 0;
    color: var(--muted);
    font-size: 12px;
}

.pts-filter-grid {
    display: grid;
    grid-template-columns: minmax(150px, 1fr) minmax(220px, 1.4fr) minmax(120px, .55fr) minmax(120px, .55fr) auto;
    align-items: end;
    gap: 10px;
}

.pts-filter-grid .btn {
    min-height: 42px;
    white-space: nowrap;
}

.pts-grid-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin: 0 0 10px;
}

.pts-grid-toolbar .btn {
    min-width: 130px;
}

.doc-actions {
    align-items: flex-start;
}

.doc-file-name {
    min-width: 0;
    display: block;
    grid-column: 1 / -1;
    margin-top: 3px;
}

.doc-link,
.doc-name {
    display: inline-block;
    max-width: 100%;
    color: #343840;
    font-size: 12px;
    line-height: 1.35;
    text-decoration: underline;
    text-underline-offset: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: top;
}

.doc-link:hover {
    color: #111827;
    background: rgba(17, 24, 39, .04);
    border-radius: 4px;
}

.doc-empty {
    display: inline-block;
    color: var(--muted);
    font-size: 12px;
    line-height: 1.35;
}

.doc-empty[hidden],
.doc-link[hidden] {
    display: none !important;
}

.pts-row[hidden] {
    display: none !important;
}

/* Consulta hash: grade e rastreabilidade organizada */
.hash-result .table-card {
    overflow: hidden;
}

.hash-result h2 {
    margin-bottom: 6px;
}

.hash-result .responsive-table {
    width: 100%;
    overflow: auto;
    border: 1px solid var(--line);
    border-radius: var(--radius);
    background: #fff;
}

.hash-result .responsive-table table {
    width: 100%;
    min-width: 920px;
    border-collapse: collapse;
    table-layout: fixed;
    font-size: 12px;
}

.hash-result .responsive-table th,
.hash-result .responsive-table td {
    border-right: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
    padding: 11px 10px;
    text-align: left;
    vertical-align: top;
    overflow-wrap: anywhere;
}

.hash-result .responsive-table th:last-child,
.hash-result .responsive-table td:last-child {
    border-right: 0;
}

.hash-result .responsive-table tbody tr:last-child td {
    border-bottom: 0;
}

.hash-result .responsive-table th {
    position: sticky;
    top: 0;
    z-index: 1;
    background: #f0f1f3;
    color: #30343a;
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
}

.hash-result .responsive-table tbody tr:hover td {
    background: #fbfbfc;
}

.hash-result .responsive-table td:nth-child(1) { width: 140px; }
.hash-result .responsive-table td:nth-child(2) { width: 190px; }
.hash-result .responsive-table td:nth-child(3) { width: 220px; }
.hash-result .responsive-table td:nth-child(4) { width: 190px; }
.hash-result .responsive-table td:nth-child(5) { width: 220px; }
.hash-result .responsive-table td:nth-child(6) { width: 110px; }

.payload-pre {
    max-height: 460px;
}

@media (max-width: 1240px) {
    .pts-indicators-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

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

    .pts-filter-grid .btn {
        width: 100%;
    }
}

@media (max-width: 720px) {
    .pts-indicators-grid,
    .pts-filter-grid {
        grid-template-columns: 1fr;
    }

    .pts-grid-toolbar .btn {
        width: 100%;
    }

    .indicator-card {
        min-height: 74px;
    }

    .indicator-card strong {
        font-size: 23px;
    }

    .hash-result .responsive-table {
        border: 0;
        overflow: visible;
    }

    .hash-result .responsive-table table,
    .hash-result .responsive-table thead,
    .hash-result .responsive-table tbody,
    .hash-result .responsive-table tr,
    .hash-result .responsive-table td {
        display: block;
        width: 100% !important;
        min-width: 0;
    }

    .hash-result .responsive-table thead {
        display: none;
    }

    .hash-result .responsive-table tr {
        border: 1px solid var(--line);
        border-radius: var(--radius);
        background: #fff;
        margin-bottom: 10px;
        overflow: hidden;
    }

    .hash-result .responsive-table td {
        border-right: 0;
        padding: 10px 12px 10px 44%;
        position: relative;
        min-height: 38px;
    }

    .hash-result .responsive-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 12px;
        top: 10px;
        width: 36%;
        color: var(--muted);
        font-weight: 800;
        font-size: 11px;
    }
}

/* Consulta PTS */
.consulta-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 18px;
    margin-bottom: 16px;
    padding: 15px;
}

.consulta-hero h2 {
    margin: 0 0 6px;
    font-size: 18px;
}

.consulta-hero p {
    margin: 0;
    color: var(--muted);
    font-size: 13px;
}

.consulta-date-shell {
    position: relative;
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 50px;
    align-items: stretch;
    gap: 5px;
    margin-bottom: 16px;
    padding: 5px;
}

.date-arrow-stack {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    min-height: 114px;
    max-width: 50px;
    display: grid;
    place-items: center;
    gap: 3px;
    padding: 8px 4px;
    color: var(--text);
    cursor: pointer;
    transition: .2s ease;
}

.date-arrow-stack:hover {
    background: #f8f9fb;
    border-color: #cfd4dc;
}

.date-arrow-stack span {
    display: grid;
    place-items: center;
    width: 32px;
    height: 28px;
    border-radius: 6px;
}

.date-arrow-stack span:hover {
    background: #edf0f4;
}

.date-arrow-stack svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.date-arrow-stack small {
    display: block;
    width: 100%;
    font-size: 10px;
    color: var(--muted);
    line-height: 1;
    text-align: center;
}

.date-center-panel {
    position: relative;
    display: grid;
    align-content: center;
    gap: 5px;
}

.date-mode-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    justify-content: center;
}

.date-mode-tabs button {
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 13px;
    color: var(--muted);
    transition: .2s ease;
}

.date-mode-tabs button.is-active,
.date-mode-tabs button:hover {
    background: #20242a;
    border-color: #004cbe;
    color: #fff;
}

.date-display {
    width: 100%;
    border: 1px solid var(--line);
    background: #fff;
    border-radius: 6px;
    padding: 16px;
    text-align: center;
    cursor: pointer;
    transition: .2s ease;
}

.date-display:hover {
    border-color: #c9ced6;
    background: #fbfcfd;
}

.date-display strong,
.date-display span {
    display: block;
}

.date-display strong {
    font-size: 18px;
    margin-bottom: 3px;
}

.date-display span {
    font-size: 13px;
    color: var(--muted);
}

.calendar-popover {
    position: absolute;
    z-index: 30;
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    width: 374px;
    max-width: calc(100vw - 40px);
    padding: 18px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    box-shadow: var(--shadow);
}

.calendar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 5px;
}

.calendar-head strong {
    font-size: 15px;
}

.calendar-weekdays, .calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 3px;
}

.calendar-weekdays span {
    text-align: center;
    font-size: 11px;
    color: var(--muted);
    padding: 5px 0;
}

.calendar-empty-day,
.calendar-day {
    min-height: 36px;
}

.calendar-day {
    border: 1px solid var(--line);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    transition: .2s ease;
}

.calendar-day:hover {
    background: #f2f4f7;
}

.calendar-day.is-today {
    border-color: #9198a3;
    font-weight: 700;
}

.calendar-day.is-selected,
.calendar-day.is-month-selected,
.calendar-day.is-range {
    background: #20242a;
    border-color: #20242a;
    color: #fff;
}

.calendar-range-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
    margin-top: 5px;
}

.calendar-range-fields label {
    display: grid;
    gap: 5px;
}

.calendar-range-fields span {
    font-size: 11px;
    color: var(--muted);
}

.calendar-range-fields input {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 9px 10px;
}

.calendar-actions {
    display: flex;
    justify-content: flex-end;
    gap: 5px;
    margin-top: 5px;
}

.consulta-filters {
    display: grid;
    grid-template-columns: repeat(4, minmax(150px, 1fr));
    gap: 12px;
    align-items: end;
    margin-bottom: 16px;
    padding: 15px;
}

.consulta-filters .btn {
    min-height: 40px;
}

.consulta-cards {
    margin-bottom: 16px;
}

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

.consulta-table {
    min-width: 3860px;
    table-layout: fixed;
    border: 1px solid var(--line);
}

.consulta-table td,
.consulta-table th {
    vertical-align: top;
}

.consulta-table th {
    height: 44px;
    background: #eef0f3;
    color: #252a31;
    letter-spacing: -.01em;
}

.consulta-table td {
    padding: 9px;
    line-height: 1.35;
    align-content: center;
}

.consulta-table th:nth-child(1), .consulta-table td:nth-child(1) { width: 135px; }
.consulta-table th:nth-child(2), .consulta-table td:nth-child(2) { width: 230px; }
.consulta-table th:nth-child(3), .consulta-table td:nth-child(3) { width: 130px; }
.consulta-table th:nth-child(4), .consulta-table td:nth-child(4) { width: 245px; }
.consulta-table th:nth-child(5), .consulta-table td:nth-child(5) { width: 115px; }
.consulta-table th:nth-child(6), .consulta-table td:nth-child(6) { width: 76px; }
.consulta-table th:nth-child(7), .consulta-table td:nth-child(7) { width: 150px; }
.consulta-table th:nth-child(8), .consulta-table td:nth-child(8) { width: 230px; }
.consulta-table th:nth-child(9), .consulta-table td:nth-child(9) { width: 245px; }
.consulta-table th:nth-child(10), .consulta-table td:nth-child(10) { width: 220px; }
.consulta-table th:nth-child(11), .consulta-table td:nth-child(11) { width: 220px; }
.consulta-table th:nth-child(12), .consulta-table td:nth-child(12) { width: 240px; }
.consulta-table th:nth-child(13), .consulta-table td:nth-child(13) { width: 290px; }
.consulta-table th:nth-child(14), .consulta-table td:nth-child(14) { width: 360px; }
.consulta-table th:nth-child(15), .consulta-table td:nth-child(15) { width: 430px; }
.consulta-table th:nth-child(16), .consulta-table td:nth-child(16) { width: 115px; }
.consulta-table th:nth-child(17), .consulta-table td:nth-child(17) { width: 135px; }
.consulta-table th:nth-child(18), .consulta-table td:nth-child(18) { width: 185px; }
.consulta-table th:nth-child(19), .consulta-table td:nth-child(19) { width: 155px; }

.consulta-table tbody tr:nth-child(even) td {
    background: #fcfcfd;
}

.consulta-table tbody tr:hover td {
    background: #f7f8fa;
}

.consulta-cell-text,
.consulta-profession-stack,
.consulta-prospect-line {
    width: 100%;
    min-width: 0;
}

.consulta-cell-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    border: 1px solid #e8eaef;
    background: #fbfcfd;
    border-radius: 6px;
    padding: 8px 9px;
    max-height: 155px;
    overflow: auto;
    color: #2f343b;
}

.consulta-cell-text.compact {
    max-height: 96px;
}

.consulta-cell-text.strong {
    font-weight: 700;
    color: #1f2937;
}

.consulta-cell-text.long-text {
    min-height: 48px;
    max-height: 240px;
}

.consulta-profession-stack {
    display: grid;
    gap: 7px;
}

.consulta-meta-line, .consulta-prospect-line {
    border: 1px solid #e8eaef;
    background: #fbfcfd;
    border-radius: 6px;
    padding: 8px;
    display: grid;
    grid-auto-flow: column;
    align-items: center;
    justify-content: space-between;
}

.consulta-meta-line {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    align-items: center;
}

.consulta-meta-line strong,
.consulta-prospect-line strong {
    display: block;
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    line-height: 1.25;
    color: #1f2937;
}

.consulta-meta-line span:not(.consulta-badge),
.consulta-prospect-line div {
    min-width: 0;
    overflow-wrap: anywhere;
    font-size: 12px;
    color: #3f4650;
}

.consulta-badge,
.consulta-date-pill {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    border-radius: 999px;
    min-height: 24px;
    padding: 4px 9px;
    font-size: 11px;
    font-weight: 800;
    line-height: 1;
    white-space: nowrap;
}

.consulta-badge.success {
    background: #eaf7ef;
    border-color: #ccebd7;
    color: #176c35;
}

.consulta-badge.muted {
    background: #f1f3f5;
    border-color: #dde1e6;
    color: #59616c;
}

.consulta-badge.neutral {
    background: #fff;
    color: var(--muted);
}

.consulta-date-pill {
    margin: 3px 4px 3px 0;
    background: #fff;
    color: #30343a;
}

.consulta-file-link {
    display: inline-flex;
    max-width: 100%;
    align-items: center;
    border: 1px solid var(--line);
    border-radius: 6px;
    padding: 7px 9px;
    background: #fbfcfd;
    color: #252a31;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.consulta-empty-cell {
    text-align: center;
    color: var(--muted);
    padding: 18px !important;
}

.muted-table-text {
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 900px) {
    .consulta-hero {
        align-items: stretch;
        flex-direction: column;
    }

    .consulta-date-shell {
        grid-template-columns: 54px minmax(0, 1fr) 54px;
        gap: 10px;
    }

    .consulta-filters {
        grid-template-columns: repeat(2, minmax(140px, 1fr));
    }
}

@media (max-width: 640px) {
    .consulta-date-shell,
    .consulta-filters,
    .calendar-range-fields {
        grid-template-columns: 1fr;
    }

    .date-arrow-stack {
        min-height: auto;
        grid-auto-flow: column;
        grid-template-columns: 1fr auto 1fr auto;
    }

    .calendar-popover {
        position: static;
        transform: none;
        width: 100%;
        max-width: 100%;
        margin-top: 10px;
    }
}

.muted-page-note {
    margin: 5px 0 0;
    color: var(--muted);
    font-size: 13px;
}
