/* ======================================================================================
   Gestor de Frota — sistema visual
   Tokens derivados de uma unica cor primaria (terracota #c2410c, aplicavel via branding) + neutros ardósia.
   Regras: divisores funcionais de 1px, sem sombras em superficies estaticas, elevacao
   apenas na camada flutuante, raio de 2/3/4px, espacamento em multiplos de 4.
   ====================================================================================== */

:root {
    /* Neutros — rampa slate (fria, moderna, baixo contraste de fundo) */
    --bg: #f1f5f9;
    --surface: #ffffff;
    --surface-soft: #f8fafc;
    --surface-sunken: #e2e8f0;
    --border: #e2e8f0;
    --border-strong: #cbd5e1;
    --text: #0f172a;
    --text-secondary: #475569;
    --muted: #575f6b;

    /* Primaria (acao principal) — laranja Transdalla; sobrescrita por branding no HTML */
    --brand: #ea580c;
    --brand-dark: color-mix(in srgb, var(--brand) 78%, #000000);
    --brand-soft: color-mix(in srgb, var(--brand) 9%, #ffffff);
    --brand-border: color-mix(in srgb, var(--brand) 28%, #ffffff);

    /* Semaforo — apenas para status real */
    --danger: #dc2626;
    --danger-soft: #fee2e2;
    --danger-border: #fecaca;
    --warning: #b45309;
    --warning-soft: #fef3c7;
    --warning-border: #fde68a;
    --ok: #16a34a;
    --ok-soft: #dcfce7;
    --ok-border: #bbf7d0;
    --neutral-soft: var(--surface-sunken);
    --neutral-text: #64748b;

    /* Navegacao lateral (derivada da paleta primaria) */
    --sidebar: #0f172a;
    --sidebar-header: #020617;
    --sidebar-hover: #1e293b;
    --sidebar-border: rgba(255, 255, 255, 0.08);
    --sidebar-text: #94a3b8;
    --sidebar-text-strong: #f8fafc;
    --sidebar-accent: var(--brand);
    --sidebar-active-text: #ffffff;

    /* Raio curto (identidade quadricular) */
    --radius-sm: 2px;
    --radius: 3px;
    --radius-lg: 4px;

    /* Escala 4px (Linear/Vercel Admin) */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 24px;

    /* Controles: toolbar 36 / form 32 / compact 28 */
    --control-h: 36px;
    --control-h-form: 32px;
    --control-h-sm: 28px;
    --row-h: 40px;

    /* Elevacao — exclusiva da camada flutuante */
    --shadow-pop: 0 1px 2px rgba(15, 23, 42, 0.08), 0 10px 24px -12px rgba(15, 23, 42, 0.28);
    --focus-ring: 0 0 0 2px var(--surface), 0 0 0 4px color-mix(in srgb, var(--brand) 55%, transparent);

    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-feature-settings: "tnum" 1;
}

* {
    box-sizing: border-box;
}

[hidden] {
    display: none !important;
}

body {
    margin: 0;
    min-height: 100vh;
    display: flex;
    color: var(--text);
    background: var(--bg);
    font-size: 14px;
    line-height: 1.45;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

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

button {
    cursor: pointer;
    transition: background-color 0.12s linear, border-color 0.12s linear, color 0.12s linear;
}

button:disabled {
    cursor: not-allowed;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

code {
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
    font-size: 12px;
    background: var(--surface-sunken);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
}

/* ======================================================================================
   Navegacao lateral
   ====================================================================================== */

.sidebar {
    width: 236px;
    flex: 0 0 236px;
    min-height: 100vh;
    box-sizing: border-box;
    background: var(--sidebar);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.25s ease;
    overflow: hidden;
}

.sidebar-collapsed {
    width: 64px;
    flex: 0 0 64px;
}

.sidebar-header {
    height: 56px;
    background: var(--sidebar-header);
    border-bottom: 1px solid var(--sidebar-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    padding: 0 6px 0 10px;
    flex-shrink: 0;
}

.sidebar-header-brand {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar-header-brand span {
    color: var(--sidebar-text-strong);
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.sidebar-collapsed .sidebar-header-brand span,
.sidebar-collapsed .sidebar-section-label,
.sidebar-collapsed .nav-label {
    display: none;
}

.sidebar-toggle {
    border: 0;
    background: transparent;
    color: #7f8d9b;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    display: grid;
    place-items: center;
    flex-shrink: 0;
    padding: 0;
}

.sidebar-toggle:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
}

.sidebar-toggle-icon {
    width: 18px;
    height: 18px;
}

.sidebar-toggle-icon-expand {
    display: none;
}

.sidebar-collapsed .sidebar-toggle-icon-collapse {
    display: none;
}

.sidebar-collapsed .sidebar-toggle-icon-expand {
    display: block;
}

.sidebar-collapsed .sidebar-header {
    flex-direction: column;
    justify-content: center;
    height: auto;
    padding: 8px 0;
    gap: 6px;
}

.sidebar-collapsed .sidebar-header-brand {
    display: flex;
    justify-content: center;
}

.sidebar-section-label {
    padding: 4px 12px 6px;
    margin-top: 14px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.01em;
    line-height: 1.2;
    text-transform: none;
    color: #94a3b8;
    position: relative;
    flex-shrink: 0;
}

/* Divisoria suave entre grupos de navegacao */
.sidebar-section-label::after {
    content: "";
    position: absolute;
    left: 12px;
    right: 12px;
    top: -6px;
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    pointer-events: none;
}

.sidebar-nav-scroll .sidebar-section-label:first-child::after {
    content: none;
}

.sidebar-nav-scroll {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding-bottom: 8px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.18) var(--sidebar);
}

.sidebar-nav-scroll::-webkit-scrollbar {
    width: 4px;
}

.sidebar-nav-scroll::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.18);
    border-radius: 2px;
}

.sidebar-nav {
    display: grid;
    align-content: start;
}

.nav-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-button,
.nav-link {
    width: auto;
    box-sizing: border-box;
    border: 0;
    border-radius: var(--radius-sm);
    margin: 2px 10px;
    padding: 0 12px;
    height: var(--control-h);
    background: transparent;
    color: var(--sidebar-text);
    text-align: left;
    font-weight: 500;
    font-size: 13px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}

.nav-button:hover,
.nav-link:hover {
    background: var(--sidebar-hover);
    color: var(--sidebar-text-strong);
}

.nav-button.active,
.nav-link.active {
    background: var(--brand);
    color: #ffffff;
    font-weight: 600;
}

/* Barra lateral da pagina ativa, colada na borda do menu */
.nav-button.active::before,
.nav-link.active::before {
    content: "";
    position: absolute;
    left: -10px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    border-radius: 2px;
    background: #ffffff;
}

.nav-button.active .nav-icon,
.nav-link.active .nav-icon {
    color: #ffffff;
}

.sidebar-collapsed .nav-button.active::before,
.sidebar-collapsed .nav-link.active::before {
    left: -8px;
}

.sidebar-collapsed .nav-icon {
    width: 18px;
    height: 18px;
}

.sidebar-footer {
    padding: 10px 14px 12px;
    border-top: 1px solid var(--sidebar-border);
    font-size: 9.5px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.38);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
}

.sidebar-footer-link {
    color: rgba(255, 255, 255, 0.58);
    text-decoration: none;
    transition: color 0.15s ease;
}

.sidebar-footer-link:hover {
    color: var(--sidebar-text-strong);
    text-decoration: underline;
}

.sidebar-collapsed .sidebar-footer {
    display: none;
}

.user-name {
    color: var(--sidebar-text-strong);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role-badge {
    display: inline-flex;
    margin-top: 3px;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--sidebar-border);
    background: rgba(111, 156, 203, 0.16);
    color: #a8c6e2;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.brand-mark {
    width: 40px;
    height: 40px;
    display: block;
    flex-shrink: 0;
    border-radius: var(--radius-sm);
    object-fit: contain;
}

/* ======================================================================================
   Estrutura: shell, topbar, conteudo
   ====================================================================================== */

.app-shell {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.topbar {
    min-height: 56px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 8px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.topbar > div {
    min-width: 0;
}

.topbar h2 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.25;
}

.topbar-title {
    flex: 1;
}

#page-subtitle,
.topbar #page-subtitle {
    color: var(--muted);
    font-size: 12.5px;
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.topbar-user {
    position: relative;
}

.user-avatar-button {
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    display: grid;
    place-items: center;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    padding: 0;
}

.user-avatar-button:hover {
    background: var(--brand-dark);
}

.topbar-user-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    min-width: 200px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
    padding: 8px;
    display: grid;
    gap: 4px;
    z-index: 40;
}

.topbar-user-meta {
    padding: 4px 8px 8px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 4px;
}

.topbar-user-meta .user-name {
    color: var(--text);
    font-size: 13px;
    font-weight: 600;
}

.topbar-user-meta .user-role-badge {
    margin-top: 2px;
    display: inline-flex;
    padding: 1px 6px;
    border-radius: var(--radius-sm);
    background: var(--brand-soft);
    color: var(--brand-dark);
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.topbar-user-link {
    display: flex;
    align-items: center;
    width: 100%;
    border: 0;
    background: transparent;
    color: var(--text);
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    text-align: left;
    cursor: pointer;
}

.topbar-user-link:hover {
    background: var(--surface-soft);
    color: var(--brand);
}

.topbar-user-link-danger {
    color: var(--danger);
}

.topbar-user-link-danger:hover {
    background: var(--danger-soft);
    color: var(--danger);
}

.topbar-logout-form {
    margin: 0;
}

#menu-button {
    display: none;
}

.content {
    padding: 16px 20px 32px;
    overflow: auto;
    scrollbar-width: thin;
    scrollbar-color: #c2cbd5 transparent;
}

.content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.content::-webkit-scrollbar-thumb {
    background: #c2cbd5;
    border: 3px solid var(--bg);
    border-radius: 4px;
}

.content::-webkit-scrollbar-track {
    background: transparent;
}

/* ======================================================================================
   Barra de filtros
   ====================================================================================== */

.tab-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 8px 12px;
    margin-bottom: 12px;
}

.panel .tab-toolbar {
    padding: 10px 14px 0;
}

.toolbar-start {
    display: flex;
    align-items: flex-end;
    flex-wrap: wrap;
    gap: 8px 12px;
    min-width: 0;
}

.toolbar-end {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 10px;
    margin-left: auto;
}

@media (max-width: 1100px) {
    .toolbar-end {
        flex-direction: column;
        align-items: flex-end;
        gap: 4px;
    }
}

.tab-toolbar .primary-button,
.tab-toolbar .secondary-button,
.tab-toolbar .icon-button {
    height: var(--control-h);
}

.filter-field {
    display: grid;
    gap: 4px;
}

.filter-field > span {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

.filter-field select,
.filter-field input {
    min-width: 168px;
}

.filter-field input[type="date"],
.filter-field input[type="number"] {
    min-width: 148px;
}

.documents-count {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-align: right;
    letter-spacing: 0;
}

.documents-count b {
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 600;
    margin-right: 2px;
}

.tab-toolbar .form-hint-inline {
    align-self: center;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* ======================================================================================
   Painéis e tabelas
   ====================================================================================== */

.panel {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}

.panel-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: -0.005em;
}

.panel-header > span {
    color: var(--muted);
    font-size: 12px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.panel-subtitle {
    display: block;
    margin-top: 1px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

.panel-header > .panel-note {
    color: var(--muted);
    font-size: 12px;
    font-weight: 400;
}

/* Atalho discreto para a aba Documentos no cabeçalho dos painéis do painel geral */
.panel-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 0 0 auto;
    margin-left: auto;
}

.panel-header > div:first-child {
    flex: 1 1 auto;
    min-width: 0;
}

.panel-link {
    background: none;
    border: 0;
    padding: 0;
    margin-left: 4px;
    font: inherit;
    font-size: 12px;
    font-weight: 600;
    color: var(--brand);
    cursor: pointer;
    border-radius: var(--radius-sm);
    white-space: nowrap;
    transition: color 0.12s ease;
}

.panel-link:hover {
    color: var(--brand-dark);
    text-decoration: underline;
}

.panel-link:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.panel h3,
.modal h3 {
    margin: 0;
}

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

.split-grid-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    margin-bottom: 16px;
}

.split-grid table {
    min-width: 0;
    width: 100%;
    font-size: 12.5px;
}

.split-grid th,
.split-grid td {
    padding: 7px 8px;
}

.split-grid td {
    word-break: break-word;
}

.dashboard-companies-panel {
    margin-bottom: 0;
}

/* ======================================================================================
   Sub-abas internas (configurações)
   ====================================================================================== */

.settings-nav {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}

.settings-nav-button {
    background: none;
    border: 0;
    margin-bottom: -1px;
    padding: 8px 14px 10px;
    font-size: 13px;
    font-weight: 600;
    color: var(--muted);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: color 0.12s ease, border-color 0.12s ease;
}

.settings-nav-button:hover {
    color: var(--text);
}

.settings-nav-button.active {
    color: var(--brand);
    border-bottom-color: var(--brand);
}

.settings-nav-button:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
    border-radius: var(--radius-sm);
}

.settings-subtab {
    display: none;
}

.settings-subtab.active {
    display: block;
    animation: settings-reveal 0.12s ease;
}

@keyframes settings-reveal {
    from { opacity: 0.4; }
    to { opacity: 1; }
}

/* ======================================================================================
   Painel geral como central de ação
   - Aba em coluna flex (sem rolagem de página), listas rolam dentro do painel
   ====================================================================================== */

.content.is-filled {
    display: flex;
    flex-direction: column;
    padding-bottom: 16px;
}

.content.is-filled .tab-panel.active {
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
    min-height: 0;
}

.content.is-filled .summary-panel {
    margin-bottom: 0;
    flex: 0 0 auto;
}

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

.metric-card .panel-header {
    padding: 10px 12px 4px;
}

.metric-card .metric-total {
    background: var(--brand-soft);
    border: 1px solid var(--brand-border);
    color: var(--brand-dark);
    margin-right: 4px;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-size: 11.5px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.metric-card {
    display: flex;
    flex-direction: column;
}

.metric-rows {
    display: flex;
    flex-direction: column;
    flex: 1;
    justify-content: center;
    padding: 6px 8px 8px;
}

.metric-row {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    min-height: 28px;
    padding: 4px 6px;
    text-align: left;
}

button.metric-row {
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background-color 0.12s ease;
}

button.metric-row:hover {
    background: var(--surface-soft);
}

button.metric-row:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.metric-dot {
    flex: none;
    width: 8px;
    height: 8px;
    border-radius: 1px;
}

.metric-dot.critical { background: var(--danger); }
.metric-dot.attention { background: var(--warning); }
.metric-dot.regular { background: var(--ok); }
.metric-dot.ok { background: var(--ok); }
.metric-dot.warning { background: var(--warning); }
.metric-dot.neutral { background: var(--border-strong); }

.metric-label {
    flex: 1 1 auto;
    color: var(--text-secondary);
    font-size: 12.5px;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.metric-count {
    margin-left: auto;
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.metric-pct {
    flex: none;
    width: 40px;
    text-align: right;
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.metric-money {
    font-size: 13px;
}

.metric-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
    padding: 8px 12px 12px;
}

.metric-action {
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    font-size: 11.5px;
    font-weight: 500;
    padding: 5px 7px;
    text-align: left;
    white-space: normal;
    line-height: 1.25;
    min-height: 34px;
    transition: border-color 0.12s ease, background-color 0.12s ease;
}

.metric-action:hover {
    background: var(--brand-soft);
    border-color: var(--brand-border);
}

.metric-action:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

/* ======================================================================================
   Documentos Fiscais — documentos importados, boletos e visualizador DANFE/DACTE
   ====================================================================================== */

.fiscal-status-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 10px 14px 8px;
    border-bottom: 1px solid var(--border);
}

.fiscal-status-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--surface-soft);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    padding: 5px 10px;
    cursor: pointer;
    transition: border-color 0.12s ease, color 0.12s ease, background 0.12s ease;
}

.fiscal-status-tab:hover {
    border-color: var(--brand-border);
    color: var(--text);
}

.fiscal-status-tab.active {
    background: var(--brand-soft);
    border-color: var(--brand);
    color: var(--brand-dark);
}

.fiscal-tab-count {
    min-width: 22px;
    text-align: center;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-variant-numeric: tabular-nums;
    color: var(--text-secondary);
}

.fiscal-status-tab.active .fiscal-tab-count {
    border-color: var(--brand-border);
    color: var(--brand-dark);
}

.status-info,
.status-pill.status-info {
    background: var(--brand-soft);
    border: 1px solid var(--brand-border);
    color: var(--brand-dark);
}

.fiscal-viewer-body .fiscal-viewer-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px 18px;
    margin: 0 0 12px;
    padding: 0;
}

.fiscal-viewer-fields div {
    min-width: 0;
}

.fiscal-viewer-fields dt {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
}

.fiscal-viewer-fields dd {
    margin: 2px 0 0;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.fiscal-key {
    font-family: ui-monospace, Consolas, monospace;
    font-size: 12px;
}

.fiscal-viewer-parcelas table {
    width: 100%;
}

.fiscal-viewer-body,
.fiscal-viewer-parcelas {
    padding: 14px 16px 12px;
}

.fiscal-result {
    margin: 0;
    padding: 6px 16px 12px;
}

.fiscal-result:empty {
    display: none;
}

.history-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    color: var(--muted);
}

.history-badge svg {
    width: 15px;
    height: 15px;
    stroke-width: 1.8;
}

.modal-card.wide {
    max-width: 720px;
}

.dashboard-docs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    flex: 1 1 auto;
    min-height: 0;
}

@media (min-width: 1680px) {
    .dashboard-docs {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

.dashboard-docs .panel {
    display: flex;
    flex-direction: column;
    min-height: 0;
    margin-bottom: 0;
}

.dashboard-docs .panel-header {
    flex: 0 0 auto;
}

.dashboard-docs .table-wrap {
    flex: 1 1 auto;
    min-height: 0;
    min-width: 0;
    overflow-y: auto;
    overflow-x: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

.dashboard-docs thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-soft);
    box-shadow: inset 0 -1px 0 var(--border);
}

.dashboard-docs table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 12.5px;
    border-collapse: separate;
    border-spacing: 0;
}

.dashboard-docs th,
.dashboard-docs td {
    padding: 7px 8px;
    vertical-align: middle;
}

.dashboard-docs th:nth-child(1),
.dashboard-docs td:nth-child(1) {
    width: 34%;
    min-width: 0;
    overflow: hidden;
}

.dashboard-docs td:nth-child(1) strong {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-docs td:nth-child(1) .muted {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    white-space: normal;
    margin-top: 1px;
    line-height: 1.3;
    max-height: 2.6em;
}

.dashboard-docs th:nth-child(2),
.dashboard-docs td:nth-child(2) {
    width: 15%;
    min-width: 0;
}

.dashboard-docs td:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-docs th:nth-child(3),
.dashboard-docs td:nth-child(3) {
    width: 14%;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.dashboard-docs th:nth-child(4),
.dashboard-docs td:nth-child(4) {
    width: 22%;
    white-space: nowrap;
}

.dashboard-docs th:nth-child(5),
.dashboard-docs td:nth-child(5) {
    width: 16%;
    white-space: nowrap;
    overflow: visible;
}

.dashboard-docs td:nth-child(5) .table-actions {
    overflow: visible;
}

.dashboard-docs .status-pill {
    max-width: none;
    white-space: nowrap;
}

.dashboard-docs .table-actions {
    flex-wrap: nowrap;
}

.dashboard-docs .table-actions .secondary-button {
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
    white-space: nowrap;
}

@media (max-width: 1400px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1360px) {
    .dashboard-docs {
        grid-template-columns: minmax(0, 1fr);
    }
}

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

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 620px;
    font-size: 13.5px;
    font-variant-numeric: tabular-nums;
}

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

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

tbody tr:hover td {
    background: var(--surface-soft);
}

th {
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
    padding: 8px 12px;
}

td strong {
    font-weight: 600;
}

.muted {
    color: var(--muted);
    font-size: 12.5px;
}

td .muted {
    display: inline-block;
    margin-top: 1px;
}

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

.fiscal-actions {
    gap: 6px;
    flex-wrap: nowrap;
}

.fiscal-actions .secondary-button {
    height: 28px;
    padding: 0 8px;
    font-size: 12px;
}

.fiscal-actions .icon-btn {
    width: 30px;
    height: 30px;
}

.num {
    text-align: right;
    white-space: nowrap;
}

.check-cell {
    width: 32px;
    text-align: center;
    padding-right: 0;
}

.audit-date {
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

.check-cell input {
    display: block;
    margin: 0 auto;
}

/* ======================================================================================
   Botoes
   ====================================================================================== */

.primary-button,
.secondary-button,
.danger-button,
.icon-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 32px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 0 12px;
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    white-space: nowrap;
}

.primary-button {
    background: var(--brand);
    border-color: var(--brand);
    color: #fff;
}

.primary-button:hover {
    background: var(--brand-dark);
    border-color: var(--brand-dark);
}

.secondary-button,
.icon-button {
    background: var(--surface);
    color: var(--text-secondary);
    border-color: var(--border-strong);
}

.secondary-button:hover,
.icon-button:hover {
    background: var(--surface-sunken);
    color: var(--text);
}

.danger-button {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger-border);
}

.danger-button:hover {
    background: var(--danger-soft);
}

.danger-button:disabled,
.secondary-button:disabled {
    opacity: 0.5;
}

.danger-button:disabled:hover,
.secondary-button:disabled:hover {
    background: var(--surface);
}

.icon-button {
    padding: 0 10px;
}

.icon-btn {
    width: 30px;
    height: 30px;
    padding: 0;
}

.icon-btn svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.icon-btn.danger {
    background: var(--surface);
    color: var(--danger);
    border-color: var(--danger-border);
}

.icon-btn.danger:hover {
    background: var(--danger-soft);
}

.kebab-wrap {
    position: relative;
    display: inline-flex;
}

.kebab-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    bottom: auto;
    z-index: 40;
    min-width: 200px;
    display: grid;
    gap: 0;
    padding: 6px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-pop);
}

.kebab-menu--up {
    top: auto;
    bottom: calc(100% + 4px);
}

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

.kebab-menu .kebab-item,
.kebab-menu .kebab-item-link {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 7px 10px;
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    text-align: left;
    text-decoration: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    white-space: nowrap;
}

.kebab-menu .kebab-item:hover,
.kebab-menu .kebab-item-link:hover {
    background: var(--surface-sunken);
    color: var(--text);
}

.kebab-menu .kebab-item svg,
.kebab-menu .kebab-item-link svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.kebab-menu .kebab-item.danger,
.kebab-menu .kebab-item-link.danger {
    color: var(--danger);
}

.kebab-menu .kebab-item.danger:hover,
.kebab-menu .kebab-item-link.danger:hover {
    background: var(--danger-soft);
}

/* Folgas: alternancia de modo (lista/calendario) e mini-calendario por motorista */
.view-toggle {
    display: inline-flex;
    align-items: center;
    height: var(--control-h);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
    flex-shrink: 0;
}

.view-toggle-button {
    border: 0;
    background: transparent;
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    padding: 0 14px;
    height: 100%;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.view-toggle-button + .view-toggle-button {
    border-left: 1px solid var(--border);
}

.view-toggle-button:hover {
    background: var(--surface-sunken);
    color: var(--text);
}

.view-toggle-button.active {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 600;
}

.time-off-grid {
    padding: 14px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 12px;
}

.time-off-card {
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface);
    overflow: hidden;
}

.time-off-card-head {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    background: var(--surface-soft);
}

.time-off-card-head strong {
    font-size: 13px;
    font-weight: 600;
}

.time-off-card-head .muted {
    font-size: 11.5px;
}

.mini-cal-title {
    padding: 10px 14px 0;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

.mini-cal {
    padding: 8px 12px 14px;
    display: grid;
    grid-template-columns: repeat(7, 30px);
    gap: 1px;
    justify-content: space-evenly;
}

.mini-cal-head,
.mini-day {
    width: 30px;
    height: 26px;
    display: grid;
    place-items: center;
    font-size: 11.5px;
    font-variant-numeric: tabular-nums;
    border-radius: var(--radius-sm);
}

.mini-cal-head {
    color: var(--muted);
    font-weight: 600;
    height: 20px;
}

.mini-day {
    color: var(--text-secondary);
}

.mini-day.weekend {
    color: var(--muted);
    background: var(--surface-soft);
}

.mini-day.c-folga {
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 700;
    border: 1px solid var(--brand-border);
    cursor: help;
}

.mini-day.c-ferias {
    background: var(--ok-soft);
    color: var(--ok);
    font-weight: 700;
    border: 1px solid var(--ok-border);
    cursor: help;
}

.mini-day.c-atestado {
    background: var(--danger-soft);
    color: var(--danger);
    font-weight: 700;
    border: 1px solid var(--danger-border);
    cursor: help;
}

.mini-day.c-licenca {
    background: #cffafe;
    color: #0e7490;
    font-weight: 700;
    border: 1px solid #a5f3fc;
    cursor: help;
}

.mini-day.c-outro,
.mini-day.off {
    background: var(--neutral-soft);
    color: var(--neutral-text);
    font-weight: 700;
    border: 1px solid var(--border);
    cursor: help;
}

.mini-day.cancelled {
    opacity: 0.55;
    text-decoration: line-through;
}

.mini-cal-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 12px;
    padding: 0 14px 12px;
    font-size: 11px;
    color: var(--text-secondary);
}

.legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-dot.c-folga {
    background: var(--brand);
}

.legend-dot.c-ferias {
    background: var(--ok);
}

.legend-dot.c-atestado {
    background: var(--danger);
}

.legend-dot.c-licenca {
    background: #0891b2;
}

.legend-dot.c-outro,
.legend-dot.off {
    background: #94a3b8;
}

.legend-dot.cancelled {
    background: var(--surface-sunken);
    border: 1px solid var(--border-strong);
}
.mini-day.empty {
    visibility: hidden;
}

.empty-state.full {
    padding: 24px 16px;
    text-align: center;
}

.full-width {
    width: 100%;
}

/* ======================================================================================
   Badges de status
   ====================================================================================== */

.status-pill {
    display: inline-flex;
    align-items: center;
    border-radius: var(--radius-sm);
    padding: 2px 7px;
    font-size: 11.5px;
    font-weight: 600;
    letter-spacing: 0.01em;
    white-space: nowrap;
}

.status-danger {
    background: var(--danger-soft);
    color: var(--danger);
}

.status-warning {
    background: var(--warning-soft);
    color: var(--warning);
}

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

.status-muted {
    background: var(--neutral-soft);
    color: var(--neutral-text);
}

.color-presets {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin: 8px 0 4px;
}

.color-preset {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    cursor: pointer;
    padding: 0;
    transition: transform 0.12s ease, border-color 0.12s ease;
}

.color-preset:hover {
    transform: scale(1.08);
    border-color: var(--text);
}

/* ======================================================================================
   Resumo operacional (painel geral)
   ====================================================================================== */

.summary-panel {
    margin-bottom: 16px;
}

.summary-line {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    min-height: 46px;
    padding: 4px 6px;
}

.summary-item {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 6px 12px;
}

.summary-item + .summary-item {
    border-left: 1px solid var(--border);
}

/* Itens de status agem como atalho para a aba Documentos */
button.summary-item {
    background: none;
    border: 0;
    font: inherit;
    color: inherit;
    cursor: pointer;
    border-radius: var(--radius);
    transition: background-color 0.12s ease;
}

button.summary-item:hover {
    background: var(--surface-soft);
}

button.summary-item:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: -2px;
}

.summary-label {
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    white-space: nowrap;
}

.summary-value {
    color: var(--text);
    font-size: 15px;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
}

.summary-pct {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.summary-mark {
    width: 3px;
    height: 14px;
    border-radius: 1px;
    background: var(--border-strong);
    flex-shrink: 0;
}

.summary-mark.critical {
    background: var(--danger);
}

.summary-mark.attention {
    background: var(--warning);
}

.summary-mark.regular {
    background: var(--ok);
}


/* ======================================================================================
   Fichas de cadastro (cartoes)
   ====================================================================================== */

.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 12px;
}

.entity-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px 14px;
    display: grid;
    gap: 8px;
    align-content: start;
}

.entity-card-inactive {
    background: var(--surface-soft);
}

.entity-card header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 10px;
}

.entity-card-body {
    min-width: 0;
}

.entity-card h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
    word-break: break-word;
}

.card-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    margin-top: 2px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
}

.card-actions .muted {
    flex-basis: 100%;
    font-size: 11.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.card-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    flex: 0 0 auto;
    max-width: 60%;
}

.card-actions .primary-button,
.card-actions .secondary-button,
.card-actions .danger-button {
    height: 28px;
    padding: 0 9px;
    font-size: 12.5px;
}

.empty-card {
    grid-column: 1 / -1;
}

/* ======================================================================================
   Formularios
   ====================================================================================== */

.form-grid,
.documents-grid {
    padding: 16px;
    display: grid;
    gap: 12px 16px;
}

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

.form-grid.three {
    grid-template-columns: repeat(3, minmax(0, 1fr));
}

.documents-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding-top: 0;
}

label > span,
label span:not(.check-label span) {
    display: block;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

input,
select {
    width: 100%;
    height: var(--control-h);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    color: var(--text);
    background: var(--surface);
}

input::placeholder {
    color: #66727f;
}

input:hover:not(:disabled),
select:hover:not(:disabled) {
    border-color: #a9b5c1;
}

input:disabled,
select:disabled {
    background: var(--surface-sunken);
    color: var(--muted);
}

input[type="checkbox"],
input[type="radio"] {
    width: 15px;
    height: 15px;
    padding: 0;
    accent-color: var(--brand);
    flex-shrink: 0;
}

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

.check-label {
    display: flex;
    align-items: center;
    gap: 8px;
    align-self: center;
    font-size: 13px;
    cursor: pointer;
}

.check-label > span {
    margin: 0;
    font-size: 13px;
    font-weight: 500;
}

.field-error {
    display: block;
    min-height: 14px;
    color: var(--danger);
    font-size: 12px;
    margin-top: 4px;
}

.is-invalid {
    border-color: var(--danger) !important;
}

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

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.form-hint {
    margin: 0;
    color: var(--muted);
    font-size: 12.5px;
}

.permissions-block {
    display: grid;
    gap: 6px;
}

.permissions-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px 10px;
}

.permissions-grid label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text);
    font-weight: 400;
}

.permissions-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.settings-form {
    padding: 16px;
    display: grid;
    gap: 12px;
}

.branding-row {
    display: flex;
    align-items: flex-start;
    gap: 20px;
    flex-wrap: wrap;
}

/* Foco maior na imagem: tile 96px em cinza neutro (melhor para PNG transparente).
   A margem superior alinha o tile ao campo de upload (rotulo + gap). */
.branding-logo-preview {
    margin-top: 23px;
    width: 96px;
    height: 96px;
    object-fit: contain;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    background: var(--surface-sunken);
}

.branding-controls {
    display: grid;
    gap: 10px;
    flex: 1 1 280px;
}

.branding-controls .form-actions {
    justify-content: flex-start;
}

/* ======================================================================================
   Seletor de arquivo (upload limpo)
   ====================================================================================== */

.form-field {
    display: grid;
    gap: 5px;
    min-width: 0;
}

.form-field-label {
    display: block;
    color: var(--text-secondary);
    font-size: 12.5px;
    font-weight: 500;
}

.file-picker {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 52px;
    padding: 8px 12px;
    border: 1px dashed var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    cursor: pointer;
    transition: border-color 120ms ease, background 120ms ease;
}

.file-picker:hover,
.file-picker:focus-within {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.file-picker input[type="file"] {
    display: none;
}

.file-picker-icon {
    width: 20px;
    height: 20px;
    flex: none;
    color: var(--brand);
}

.file-picker-text {
    display: grid;
    gap: 2px;
    min-width: 0;
    flex: 1 1 auto;
    text-align: left;
}

.file-picker-button {
    color: var(--brand);
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
}

.file-picker-name {
    overflow: hidden;
    color: var(--muted);
    font-size: 12px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.file-picker.has-file {
    border-style: solid;
    border-color: var(--brand-border);
    background: var(--brand-soft);
}

.file-picker.has-file .file-picker-name {
    color: var(--text);
    font-weight: 500;
}

.file-picker.compact {
    display: flex;
    min-width: 200px;
    min-height: var(--control-h);
    height: var(--control-h);
    padding: 0 12px;
}

label.filter-field > span.file-picker {
    display: flex;
    text-transform: none;
    font-size: 14px;
    color: var(--text);
}

.file-picker.compact .file-picker-text {
    display: flex;
    align-items: baseline;
    overflow: hidden;
    gap: 6px;
}

.file-picker.compact .file-picker-name {
    flex: 1 1 auto;
    text-align: right;
}

/* ======================================================================================
   Certificado digital da empresa (modal Empresa)
   ====================================================================================== */

.certificate-block {
    margin-top: 4px;
    padding: 12px 14px 4px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

.certificate-block .certificate-header {
    border-bottom: 1px solid var(--border);
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.certificate-block .certificate-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
}

.certificate-fields {
    margin-bottom: 8px;
}

.certificate-status {
    color: var(--muted);
    font-size: 11.5px;
    font-weight: 500;
    white-space: nowrap;
}

.certificate-status[data-state="ok"] {
    color: var(--ok);
}

.certificate-status[data-state="warning"] {
    color: var(--warning);
}

.certificate-status[data-state="expired"] {
    color: var(--danger);
}

.auth-panel {
    max-width: 520px;
    padding: 16px;
}

.auth-panel .form-hint {
    margin: 0;
}

/* ======================================================================================
   Modais
   ====================================================================================== */

.modal {
    width: min(760px, calc(100vw - 24px));
    max-height: calc(100vh - 48px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0;
    box-shadow: var(--shadow-pop);
    color: var(--text);
    background: var(--surface);
}

.modal::backdrop {
    background: rgba(19, 27, 36, 0.52);
}

.modal-card {
    padding: 0;
    max-height: calc(100vh - 48px);
    display: flex;
    flex-direction: column;
}

.modal-card header,
.modal-card footer {
    padding: 12px 16px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-shrink: 0;
}

.modal-card header h3 {
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.005em;
}

.modal-card footer {
    border-top: 1px solid var(--border);
    border-bottom: 0;
    justify-content: flex-end;
    gap: var(--space-2);
}

.modal-card h4 {
    margin: 16px 16px 0;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

.modal-card > .muted {
    margin: 12px 16px 0;
}

.modal-card > label,
.modal-card > .form-hint {
    margin: 12px 16px 0;
}

.modal-card > .form-hint {
    margin-bottom: 10px;
}

.modal-card .form-grid + .form-hint {
    margin-top: 8px;
}

.modal-card > .form-grid:last-of-type {
    padding-bottom: 0;
}

/* Grid imediatamente antes do footer precisa do respiro inferior */
.modal-card > .form-grid:last-of-type:has(+ footer) {
    padding-bottom: 16px;
}

.modal-actions {
    margin-top: 16px;
}

.section-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 16px 16px 0;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.section-head h4 {
    margin: 0;
}

/* Veiculos vinculados: secao plana, sem caixa dentro da caixa */
.linked-vehicles-panel {
    margin: 4px 16px 0;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
}

.linked-vehicles-panel[hidden] {
    display: none;
}

.linked-vehicles-title {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

.linked-vehicles-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
    min-height: 26px;
}

.linked-vehicles-chip {
    display: inline-flex;
    align-items: center;
    padding: 4px 9px;
    border-radius: var(--radius-sm);
    background: var(--surface-soft);
    border: 1px solid var(--border);
    font-size: 12.5px;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.linked-vehicles-empty {
    color: var(--muted);
    font-size: 13px;
}

.linked-vehicles-hint {
    margin: 8px 0 0;
    color: var(--muted);
    font-size: 12px;
}

/* Ficha do motorista */
.sheet-dialog {
    width: min(680px, calc(100vw - 24px));
}

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

.sheet-modal .sheet-header-title {
    min-width: 0;
}

.sheet-modal .sheet-header-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--muted);
    margin-bottom: 1px;
}

.sheet-modal header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    letter-spacing: -0.005em;
    color: var(--text);
    line-height: 1.3;
    word-break: break-word;
}

.sheet-content {
    padding: 14px 16px 16px;
    display: grid;
    gap: 12px;
    overflow: auto;
}

.sheet-section {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    overflow: hidden;
}

.sheet-section-header {
    padding: 7px 12px;
    background: var(--surface-soft);
    border-bottom: 1px solid var(--border);
}

.sheet-section-title {
    display: block;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0;
    text-transform: none;
    color: var(--text-secondary);
}

.sheet-meta {
    padding: 10px 12px;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px 16px;
    font-size: 13px;
}

.sheet-meta strong {
    font-weight: 500;
    color: var(--text-secondary);
}

.sheet-meta-wide {
    grid-column: 1 / -1;
}

.sheet-docs-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
    min-width: 0;
}

.sheet-docs-table th,
.sheet-docs-table td {
    padding: 6px 12px;
    text-align: left;
    border-top: 1px solid var(--border);
    vertical-align: middle;
}

.sheet-docs-table th {
    font-size: 10.5px;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    background: var(--surface-soft);
}

.sheet-docs-table td:last-child {
    width: 140px;
}

.sheet-vehicle-block {
    padding-bottom: 4px;
}

.sheet-vehicle-block + .sheet-vehicle-block {
    border-top: 1px solid var(--border);
}

.sheet-vehicle-title {
    padding: 8px 12px 4px;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text);
    font-variant-numeric: tabular-nums;
}

.sheet-empty-inline {
    padding: 0 12px 10px;
    color: var(--muted);
    font-size: 12.5px;
}

/* ======================================================================================
   Busca global
   ====================================================================================== */

.search-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: var(--control-h);
    border: 1px solid var(--border-strong);
    background: var(--surface-soft);
    color: var(--muted);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    font-size: 13px;
    cursor: pointer;
    min-width: 210px;
    justify-content: flex-start;
}

.search-trigger:hover {
    background: var(--surface);
    color: var(--text-secondary);
}

.search-trigger svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.search-trigger span {
    flex: 1;
    text-align: left;
}

.kbd-button {
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.kbd-button svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
}

.kbd-button kbd {
    font-size: 11px;
    padding: 0 5px;
    line-height: 16px;
}

kbd {
    display: inline-block;
    border: 1px solid var(--border-strong);
    border-bottom-width: 1px;
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: 1px 5px;
    font-size: 11px;
    font-family: inherit;
    color: var(--text-secondary);
    white-space: nowrap;
}

#search-modal {
    width: min(620px, calc(100vw - 24px));
}

.search-dialog {
    width: auto;
}

.modal-card > .search-field {
    margin: 12px 16px 0;
    padding: 0;
}

.search-dialog .search-field {
    display: block;
}

.search-field input {
    width: 100%;
    height: var(--control-h);
    font-size: 14px;
    padding: 0 12px;
}

.search-results {
    padding: 12px 16px 16px;
    max-height: min(48vh, 420px);
    overflow-y: auto;
    overflow-x: hidden;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    scrollbar-width: thin;
    scrollbar-color: #c8d1db transparent;
}

.search-results::-webkit-scrollbar {
    width: 8px;
}

.search-results::-webkit-scrollbar-track {
    background: transparent;
}

.search-results::-webkit-scrollbar-thumb {
    background: #c8d1db;
    border: 2px solid var(--surface);
    border-radius: 4px;
}

.search-hint {
    padding: 20px 0;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
    overflow-wrap: anywhere;
}

.search-result {
    display: flex;
    align-items: baseline;
    gap: 10px;
    width: 100%;
    min-width: 0;
    overflow: hidden;
    text-align: left;
    border: 1px solid transparent;
    background: transparent;
    border-radius: var(--radius-sm);
    padding: 7px 10px;
    cursor: pointer;
    font: inherit;
    color: inherit;
}

.search-result:hover {
    background: var(--brand-soft);
    border-color: var(--brand-border);
}

.search-result-title {
    font-weight: 600;
    font-size: 13.5px;
    white-space: nowrap;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-subtitle {
    color: var(--muted);
    font-size: 12.5px;
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-result .status-pill {
    flex: none;
}

/* ======================================================================================
   Atalhos, historico, transferencia
   ====================================================================================== */

.shortcut-list {
    display: grid;
    padding: 8px 16px 16px;
}

.shortcut-list > div {
    display: grid;
    grid-template-columns: 132px 1fr;
    align-items: center;
    gap: 12px;
    padding: 5px 0;
    font-size: 13px;
    border-bottom: 1px solid var(--border);
}

.shortcut-list > div:last-child {
    border-bottom: 0;
}

.shortcut-keys {
    display: flex;
    align-items: center;
    gap: 4px;
    color: var(--text-secondary);
}

.shortcut-desc {
    color: var(--text);
}

.timeline {
    padding: 16px;
    display: grid;
    gap: 14px;
    overflow: auto;
}

.timeline-item {
    border-left: 2px solid var(--brand-border);
    padding-left: 12px;
    font-size: 13px;
}

.timeline-item strong {
    display: block;
    font-weight: 600;
}

.timeline-item .muted {
    font-size: 12.5px;
}

.transfer-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 12px 16px 0;
}

/* ======================================================================================
   Barra em lote
   ====================================================================================== */

.bulk-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    border-bottom: 1px solid var(--border);
    background: var(--brand-soft);
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
}

.bulk-bar[hidden] {
    display: none;
}

/* ======================================================================================
   Estados vazios e alertas
   ====================================================================================== */

.empty-state {
    padding: 28px 16px;
    text-align: center;
    color: var(--muted);
    font-size: 13px;
}

table .empty-state {
    padding: 28px 16px;
}

.alert {
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    padding: 10px 12px;
    margin-bottom: 12px;
    font-size: 13px;
}

.alert-error {
    background: var(--danger-soft);
    border-color: var(--danger-border);
    color: var(--danger);
}

.alert-success {
    background: var(--ok-soft);
    border-color: var(--ok-border);
    color: var(--ok);
}

/* ======================================================================================
   Avisos flutuantes
   ====================================================================================== */

.toast-container {
    position: fixed;
    right: 16px;
    bottom: 16px;
    display: grid;
    gap: 8px;
    z-index: 40;
}

.toast {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-left: 3px solid var(--text-secondary);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    box-shadow: var(--shadow-pop);
    font-size: 13px;
    max-width: 380px;
    --toast-accent: var(--text-secondary);
}

.toast-success {
    --toast-accent: var(--ok);
    border-left-color: var(--ok);
}

.toast-error {
    --toast-accent: var(--danger);
    border-left-color: var(--danger);
}

.toast-warning {
    --toast-accent: var(--warning);
    border-left-color: var(--warning);
}

.toast-info {
    --toast-accent: var(--sidebar-accent);
    border-left-color: var(--sidebar-accent);
}

/* ======================================================================================
   Login
   ====================================================================================== */

.login-body {
    display: grid;
    place-items: center;
    background: var(--bg);
}

.login-shell {
    width: min(400px, calc(100vw - 24px));
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-top: 3px solid var(--brand);
    border-radius: var(--radius);
    padding: 28px 28px 24px;
    box-shadow: none;
}

.login-card h1 {
    margin: 14px 0 4px;
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.login-card p {
    margin: 0 0 20px;
    color: var(--muted);
    font-size: 13px;
}

.form-actions .secondary-button {
    text-decoration: none;
}

/* ======================================================================================
   Responsivo
   ====================================================================================== */

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

@media (max-width: 920px) {
    body {
        display: block;
        overflow: auto;
    }

    .app-shell {
        height: auto;
        min-height: 100vh;
    }

    #menu-button {
        display: inline-flex;
    }

    .sidebar {
        display: none;
        position: fixed;
        inset: 0 auto 0 0;
        z-index: 30;
        width: min(248px, 88vw);
        min-height: 100vh;
    }

    .sidebar.open {
        display: flex;
    }

    .sidebar-collapsed {
        width: min(248px, 88vw);
    }

    .split-grid,
    .split-grid-two,
    .form-grid.two,
    .form-grid.three,
    .documents-grid {
        grid-template-columns: 1fr;
    }

    .summary-item + .summary-item {
        border-left: 0;
    }

    .summary-line {
        padding: 4px 10px;
        gap: 4px 0;
    }

    .search-trigger span {
        display: none;
    }

    .search-trigger {
        min-width: 0;
    }
}

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



.modal-card > footer,
form.modal-card > footer,
.modal footer {
    justify-content: flex-end !important;
}

.panel,
.entity-card,
.metric-card,
.summary-panel,
.content-card,
.table-shell {
    box-shadow: none !important;
}

/* ======================================================================================
   Polimento visual 2026-11-05 — identidade Transdalla + anti-slop
   ====================================================================================== */

.modal-card header {
    position: relative;
    justify-content: flex-end;
    min-height: 48px;
    padding: var(--space-3) var(--space-4);
}

.modal-card header h3 {
    position: absolute;
    left: 48px;
    right: 48px;
    margin: 0;
    text-align: center;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: -0.01em;
    line-height: 1.3;
    pointer-events: none;
}

.modal-close {
    width: 28px;
    height: 28px;
    padding: 0;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-secondary);
    display: inline-grid;
    place-items: center;
    flex-shrink: 0;
    z-index: 1;
}

.modal-close:hover {
    background: var(--surface-sunken);
    color: var(--text);
    border-color: color-mix(in srgb, var(--border-strong) 70%, var(--text-secondary));
}

.modal-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.modal-card footer {
    padding: var(--space-3) var(--space-4);
}

input::placeholder,
textarea::placeholder {
    color: #66727f;
    opacity: 1;
}

.form-field-label,
label > span,
.toolbar-field > span,
.filters label > span {
    letter-spacing: 0 !important;
    text-transform: none !important;
    font-weight: 600;
    color: var(--text-secondary);
}

@media (max-width: 1400px) {
    .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 1360px) {
    .dashboard-docs {
        grid-template-columns: minmax(0, 1fr);
    }
    .tab-toolbar {
        align-items: flex-end;
    }
}

.entity-card,
.panel,
.metric-card {
    box-shadow: none;
}

.status-pill,
.badge {
    letter-spacing: 0;
    text-transform: none;
}

.login-card .brand-mark {
    width: 48px;
    height: 48px;
}

.login-card .primary-button {
    margin-top: 4px;
    height: 40px;
    font-weight: 600;
}

/* Loop2: badges e ações sem truncar em tabelas gerais */
.table-wrap {
    min-width: 0;
    overflow-x: auto;
}

table {
    min-width: 0;
}

td .status-pill {
    white-space: nowrap;
    max-width: none;
}

.table-actions {
    flex-wrap: nowrap;
    align-items: center;
}

.table-actions .secondary-button,
.table-actions .danger-button,
.table-actions .primary-button {
    white-space: nowrap;
}

input.date-br {
    font-variant-numeric: tabular-nums;
}

/* ======================================================================================
   Loop 3 — polimento premium (Linear/Stripe/Vercel/Fiori → identidade Transdalla)
   1 spacing 4/8/12/16  2 bordas 1px  3 tabular-nums  4 rows densas+hover
   5 focus ring  6 alturas de botão  7 toolbar/header  8 empty + sidebar ativo
   ====================================================================================== */

button:focus-visible,
input:focus-visible,
select:focus-visible,
a:focus-visible,
.modal-close:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

.topbar {
    padding: var(--space-2) var(--space-4);
    min-height: 56px;
}

.topbar h2 {
    font-weight: 650;
    letter-spacing: -0.02em;
}

.content {
    padding: var(--space-4);
    gap: var(--space-3);
}

.panel-header {
    padding: var(--space-3) var(--space-4);
}

.panel-header h3 {
    font-weight: 650;
}

.tab-toolbar {
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    align-items: flex-end;
}

.primary-button,
.secondary-button,
.danger-button {
    height: var(--control-h-form);
    padding: 0 var(--space-3);
}

.tab-toolbar .primary-button,
.tab-toolbar .secondary-button,
.tab-toolbar .icon-button,
.panel-actions .primary-button,
.panel-actions .secondary-button {
    height: var(--control-h);
}

.card-actions .primary-button,
.card-actions .secondary-button,
.card-actions .danger-button,
.table-actions .secondary-button,
.table-actions .danger-button,
.table-actions .primary-button {
    height: var(--control-h-sm);
    padding: 0 var(--space-2);
    font-size: 12.5px;
}

input:not([type="checkbox"]):not([type="radio"]):not([type="color"]):not([type="file"]),
select,
textarea {
    min-height: var(--control-h-form);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    background: var(--surface);
}

input:not([type="checkbox"]):not([type="radio"]):focus,
select:focus,
textarea:focus {
    border-color: color-mix(in srgb, var(--brand) 55%, var(--border-strong));
}

th, td {
    height: var(--row-h);
    font-variant-numeric: tabular-nums;
}

td {
    vertical-align: middle;
}

tbody tr {
    transition: background-color 0.1s linear;
}

tbody tr:hover td {
    background: color-mix(in srgb, var(--brand) 4%, var(--surface-soft));
}

.status-pill,
.metric-count,
.summary-value,
.documents-count,
.num,
[data-money],
.audit-date {
    font-variant-numeric: tabular-nums;
}

.empty-state {
    padding: var(--space-5) var(--space-4);
    color: var(--muted);
    font-size: 13px;
    text-align: center;
    border: 1px dashed var(--border);
    border-radius: var(--radius);
    background: var(--surface-soft);
}

table .empty-state {
    border: 0;
    background: transparent;
    padding: var(--space-5) var(--space-3);
}

.nav-button.active,
.nav-link.active {
    background: color-mix(in srgb, var(--brand) 92%, #000);
    box-shadow: inset 3px 0 0 #fff;
}

.sidebar-section-label {
    margin-top: var(--space-4);
    padding-left: var(--space-3);
}

.login-card {
    padding: var(--space-5) var(--space-5) var(--space-4);
    border: 1px solid var(--border);
}

.login-card .primary-button {
    height: var(--control-h);
}


/* Painel v2 — 16:9 sem rolagem de página: métricas compactas + 60/40 docs|financeiro */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

body:has(#tab-dashboard.active),
html:has(#tab-dashboard.active) {
    height: 100%;
    overflow: hidden;
}

body:has(#tab-dashboard.active) .app-shell {
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
}

.content.is-filled:has(#tab-dashboard.active) {
    overflow: hidden;
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    max-height: none;
    padding-bottom: 10px;
    gap: 8px;
}

.content.is-filled:has(#tab-dashboard.active) .tab-panel.active {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    height: 100%;
    gap: 8px;
    overflow: hidden;
}

.content.is-filled:has(#tab-dashboard.active) .summary-panel {
    margin-bottom: 0;
    flex: 0 0 auto;
}

.content.is-filled:has(#tab-dashboard.active) .summary-panel .panel-header {
    display: none;
}

.content.is-filled:has(#tab-dashboard.active) .census-line {
    padding: 4px 8px;
    gap: 4px;
}

.content.is-filled:has(#tab-dashboard.active) .summary-item {
    padding: 2px 6px;
}

.content.is-filled:has(#tab-dashboard.active) .summary-label {
    font-size: 11px;
}

.content.is-filled:has(#tab-dashboard.active) .summary-value {
    font-size: 13px;
}

.content.is-filled:has(#tab-dashboard.active) .dashboard-metrics {
    flex: 0 0 auto;
    gap: 6px;
    grid-template-columns: repeat(4, minmax(0, 1fr));
}

.content.is-filled:has(#tab-dashboard.active) .metric-card .panel-header {
    padding: 4px 8px 0;
}

.content.is-filled:has(#tab-dashboard.active) .metric-card .panel-header h3 {
    font-size: 12.5px;
}

.content.is-filled:has(#tab-dashboard.active) .metric-total {
    font-size: 10.5px;
    padding: 1px 6px;
}

.content.is-filled:has(#tab-dashboard.active) .metric-card .panel-subtitle {
    display: none;
}

.content.is-filled:has(#tab-dashboard.active) .metric-row {
    padding: 2px 8px;
    min-height: 24px;
    font-size: 11.5px;
}

.content.is-filled:has(#tab-dashboard.active) .metric-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 3px;
    padding: 2px 6px 6px;
}

.content.is-filled:has(#tab-dashboard.active) .metric-action {
    height: 26px;
    padding: 0 4px;
    font-size: 11px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    min-width: 0;
}

.dashboard-docs-v2 {
    display: grid !important;
    grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); /* ~60/40 at wide */
    gap: 8px;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    height: auto;
    align-content: stretch;
}

@media (max-width: 1599px) {
    .dashboard-docs-v2 {
        grid-template-columns: minmax(0, 1.22fr) minmax(0, 1fr); /* ~55/45 */
    }
}

.dashboard-docs-v2 .dashboard-finance-dues {
    grid-column: auto;
}

.dashboard-docs-v2 > .panel {
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 0;
    height: 100%;
    margin-bottom: 0;
}

.dashboard-docs-v2 > .panel.dash-flash {
    box-shadow: 0 0 0 2px var(--brand);
}

.dashboard-docs-v2 .panel-header {
    flex: 0 0 auto;
    padding: 6px 10px;
    gap: 8px;
}

.dashboard-docs-v2 .panel-header h3 {
    font-size: 13.5px;
}

.dashboard-docs-v2 .panel-subtitle {
    display: none;
}

.dashboard-docs-v2 .panel-actions {
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    align-items: center;
}

.dashboard-docs-v2 .table-wrap {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    scrollbar-width: thin;
}

.dashboard-docs-v2 thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--surface-soft);
    box-shadow: inset 0 -1px 0 var(--border);
    font-size: 11.5px;
    padding: 6px 8px;
    white-space: nowrap;
}

.dashboard-docs-v2 table.dash-compact-table {
    width: 100%;
    min-width: 0;
    table-layout: fixed;
    font-size: 12px;
    border-collapse: separate;
    border-spacing: 0;
}

.dashboard-docs-v2 .dash-compact-table tbody tr {
    height: 36px;
    max-height: 36px;
}

.dashboard-docs-v2 .dash-compact-table th,
.dashboard-docs-v2 .dash-compact-table td {
    padding: 0 8px;
    vertical-align: middle;
    height: 36px;
    max-height: 36px;
    box-sizing: border-box;
    line-height: 1.2;
}

.dashboard-docs-v2 .dash-compact-table tbody td {
    overflow: hidden;
}

.dashboard-docs-v2 .dash-owner-cell {
    overflow: hidden;
}

.dashboard-docs-v2 .dash-owner-line {
    display: grid;
    /* placa tabular | pill = "Motorista" + padding | vínculo */
    grid-template-columns: 9.5ch var(--dash-type-track, 4.85rem) minmax(0, 1fr);
    column-gap: 8px;
    align-items: center;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.dashboard-docs-v2 .dash-plate {
    min-width: 0 !important;
    max-width: none !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
    font-family: ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
    font-variant-numeric: tabular-nums;
    font-size: 12px;
    letter-spacing: 0;
    justify-self: start;
}

.dashboard-docs-v2 .dash-owner-line .dash-type-tag {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    justify-self: stretch;
    text-align: center;
    overflow: hidden;
    text-overflow: clip;
    padding-left: 6px;
    padding-right: 6px;
}

.dashboard-docs-v2 .dash-link-inline {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-top: 0 !important;
    display: block !important;
    -webkit-line-clamp: unset !important;
    max-height: none !important;
}

/* Financeiro: descrição em 2 linhas (título + fornecedor) */
.dashboard-docs-v2 .dash-finance-desc {
    overflow: hidden;
    max-width: 100%;
    line-height: 1.2;
}

.dashboard-docs-v2 .dash-finance-title {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    max-width: 100%;
    min-width: 0;
}

.dashboard-docs-v2 .dash-finance-sub {
    display: block !important;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 10.5px;
    margin-top: 1px !important;
    max-width: 100%;
    min-width: 0;
}

.dashboard-docs-v2 .dash-finance-table tbody tr {
    height: 40px;
    max-height: 40px;
}

.dashboard-docs-v2 .dash-finance-table tbody td {
    height: 40px;
    max-height: 40px;
}

.dashboard-docs-v2 .dash-date-cell,
.dashboard-docs-v2 .dash-money-cell {
    white-space: nowrap !important;
    overflow: visible !important;
    text-overflow: clip !important;
    font-variant-numeric: tabular-nums;
}

.dashboard-docs-v2 .dash-finance-row {
    cursor: pointer;
}

.dashboard-docs-v2 .dash-finance-row:hover {
    background: var(--surface-soft);
}

.dashboard-docs-v2 .status-pill {
    display: inline-block;
    max-width: none;
    white-space: nowrap;
    overflow: visible;
    text-overflow: clip;
    font-size: 11px;
    padding: 2px 7px;
}

.dashboard-docs-v2 .table-actions {
    flex-wrap: nowrap;
    gap: 4px;
}

.dashboard-docs-v2 .table-actions .secondary-button,
.dashboard-docs-v2 .table-actions .primary-button {
    height: 26px;
    padding: 0 8px;
    font-size: 11.5px;
    white-space: nowrap;
}

.dashboard-docs-v2 th:nth-child(1),
.dashboard-docs-v2 td:nth-child(1) {
    width: 42%;
}

.dashboard-docs-v2 th:nth-child(2),
.dashboard-docs-v2 td:nth-child(2) {
    width: 14%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-docs-v2 th:nth-child(3),
.dashboard-docs-v2 td:nth-child(3) {
    width: 12%;
    min-width: 52px;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
    overflow: visible;
}

.dashboard-docs-v2 th:nth-child(4),
.dashboard-docs-v2 td:nth-child(4) {
    width: 18%;
    white-space: nowrap;
    overflow: visible;
}

.dashboard-docs-v2 th:nth-child(5),
.dashboard-docs-v2 td:nth-child(5) {
    width: 14%;
    white-space: nowrap;
    overflow: visible;
}

.dashboard-docs-v2 .dashboard-finance-dues th:nth-child(1),
.dashboard-docs-v2 .dashboard-finance-dues td:nth-child(1) {
    width: 38%;
}

.dashboard-docs-v2 .dashboard-finance-dues th:nth-child(2),
.dashboard-docs-v2 .dashboard-finance-dues td:nth-child(2) {
    width: 12%;
    min-width: 48px;
}

.dashboard-docs-v2 .dashboard-finance-dues th:nth-child(3),
.dashboard-docs-v2 .dashboard-finance-dues td:nth-child(3) {
    width: 16%;
    min-width: 72px;
    text-align: right;
}

.dashboard-docs-v2 .dashboard-finance-dues th:nth-child(4),
.dashboard-docs-v2 .dashboard-finance-dues td:nth-child(4) {
    width: 18%;
    min-width: 72px;
}

.dashboard-docs-v2 .dashboard-finance-dues th:nth-child(5),
.dashboard-docs-v2 .dashboard-finance-dues td:nth-child(5) {
    width: 16%;
    min-width: 58px;
}

.dash-type-tag {
    display: inline-block;
    margin-left: 0;
    padding: 0 6px;
    border-radius: 999px;
    border: 1px solid var(--border-strong);
    background: var(--surface-soft);
    color: var(--text-secondary);
    font-size: 10px;
    font-weight: 600;
    line-height: 1.55;
    vertical-align: middle;
    white-space: nowrap;
}

.dash-filter-seg {
    display: inline-flex;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    overflow: hidden;
    margin-right: 4px;
}

.dash-filter {
    height: 26px;
    padding: 0 8px;
    border: 0;
    border-right: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    font-size: 11.5px;
    font-weight: 500;
}

.dash-filter:last-child { border-right: 0; }

.dash-filter.active {
    background: var(--brand);
    color: #fff;
    font-weight: 600;
}

button.summary-item.summary-link {
    background: transparent;
    border: 0;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
}

button.summary-item.summary-link:hover {
    background: var(--surface-soft);
}

button.summary-item.summary-link:focus-visible {
    outline: none;
    box-shadow: var(--focus-ring);
}

@media (max-width: 1400px) {
    .content.is-filled:has(#tab-dashboard.active) .dashboard-metrics {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
}

@media (max-width: 1200px) {
    .dashboard-docs-v2 {
        grid-template-columns: minmax(0, 1.35fr) minmax(0, 1fr);
    }
    .content.is-filled:has(#tab-dashboard.active) .dashboard-metrics {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-height: 800px) {
    .content.is-filled:has(#tab-dashboard.active) .metric-actions {
        grid-template-columns: repeat(4, minmax(0, 1fr));
    }
    .content.is-filled:has(#tab-dashboard.active) .metric-action {
        height: 22px;
        font-size: 10px;
    }
}

@media (max-width: 1500px) {
    .dashboard-attention-panel .dash-filter {
        padding: 0 6px;
        font-size: 11px;
    }
}


/* Force single-line compact cells inside v2 panes */
.dashboard-docs-v2 td:nth-child(1) .muted {
    display: inline !important;
    -webkit-line-clamp: unset !important;
    white-space: nowrap !important;
    max-height: none !important;
    margin-top: 0 !important;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dashboard-docs-v2 td:nth-child(1) strong.dash-plate {
    display: inline !important;
    overflow: visible !important;
    text-overflow: clip !important;
    white-space: nowrap !important;
}

.dashboard-docs-v2 .dash-finance-desc .muted,
.dashboard-docs-v2 .dash-finance-sub {
    display: block !important;
}


/* sidebar shrink below 1500 — more room for painel 16:9 */
@media (max-width: 1499px) {
    body:has(#tab-dashboard.active) .sidebar:not(.sidebar-collapsed) {
        width: 188px;
        flex-basis: 188px;
    }
    body:has(#tab-dashboard.active) .sidebar:not(.sidebar-collapsed) .nav-button,
    body:has(#tab-dashboard.active) .sidebar:not(.sidebar-collapsed) .nav-link {
        padding-left: 10px;
        padding-right: 8px;
        gap: 8px;
    }
    body:has(#tab-dashboard.active) .sidebar:not(.sidebar-collapsed) .nav-label {
        font-size: 12.5px;
    }
}

/* wide finance desc — less truncation at 1920 */
@media (min-width: 1600px) {
    .dashboard-docs-v2 .dashboard-finance-dues th:nth-child(1),
    .dashboard-docs-v2 .dashboard-finance-dues td:nth-child(1) {
        width: 44%;
    }
    .dashboard-docs-v2 .dashboard-finance-dues th:nth-child(5),
    .dashboard-docs-v2 .dashboard-finance-dues td:nth-child(5) {
        width: 12%;
    }
}

@media (max-width: 1599px) {
    .dashboard-docs-v2 .dash-owner-line {
        --dash-type-track: 4.6rem; /* ~Motorista + padding, centered */
        column-gap: 6px;
        grid-template-columns: 8.8ch var(--dash-type-track) minmax(0, 1fr);
    }
}
