/* =========================================================
   VARIÁVEIS GERAIS
   ========================================================= */
:root {
    /* Cores base */
    --bg-body: #f3f4f6;
    --bg-shell: #f3f4f6;
    --bg-card: #ffffff;
    --bg-card-soft: #f9fafb;

    --text-main: #111827;
    --text-muted: #6b7280;
    --text-contrast: #f9fafb;

    --accent: #ff7a1a;
    --accent-soft: rgba(255, 122, 26, 0.16);
    --accent-hover: #ff8f3d;

    --border-soft: #e5e7eb;
    --input-bg: #f9fafb;
    --input-border: #d1d5db;

    /* Sidebar */
    --sidebar-bg: #111827;
    --sidebar-bg-active: #0b1120;
    --sidebar-border: #020617;
    --sidebar-text: #e5e7eb;
    --sidebar-muted: #9ca3af;

    /* Sombras e raio */
    --shadow-card-soft: 0 4px 14px rgba(15, 23, 42, 0.06);
    --shadow-card-strong: 0 18px 40px rgba(15, 23, 42, 0.12);
    --radius-lg: 18px;
    --radius-xl: 26px;
    --radius-full: 999px;

    /* Transições */
    --transition-fast: 0.16s ease-out;
    --transition-med: 0.22s ease-out;
}

/* =========================================================
   RESET
   ========================================================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    font-family: "Poppins", system-ui, -apple-system, BlinkMacSystemFont,
        "Segoe UI", sans-serif;
    background: var(--bg-body);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
}

/* =========================================================
   LOGIN (index.php)
   ========================================================= */

/* fundo escuro só é usado no login, pois só lá existe .page-bg */
.page-bg {
    position: fixed;
    inset: 0;
    pointer-events: none;
    background:
        radial-gradient(circle at top, rgba(15, 23, 42, 0.9) 0, #020617 55%),
        radial-gradient(circle at bottom right, rgba(15, 23, 42, 0.9) 0, #020617 60%);
    opacity: 0.98;
    z-index: -1;
}

/* wrapper login */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* card login */
.auth-card {
    width: 100%;
    max-width: 520px;
    background: var(--bg-card);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-card-strong);
    padding: 32px 32px 28px;
    position: relative;
}

.auth-card::before {
    content: "";
    position: absolute;
    inset: -2px;
    border-radius: inherit;
    background: radial-gradient(circle at bottom left, rgba(255, 122, 26, 0.14), transparent 60%);
    z-index: -1;
}

/* header login */
.auth-header {
    display: flex;
    align-items: center;
    gap: 18px;
    margin-bottom: 24px;
}

.auth-logo img {
    width: 64px;
    height: auto;
    display: block;
}

.auth-title-group {
    flex: 1;
}

.auth-title {
    margin: 0 0 4px;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    color: #111827;
}

.auth-subtitle {
    margin: 0;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--text-muted);
}

/* ALERTAS DE LOGIN */
.auth-alert {
    margin-bottom: 12px;
    padding: 8px 12px;
    border-radius: 10px;
    font-size: 0.8rem;
    line-height: 1.5;
    border: 1px solid transparent;
}

.auth-alert-erro {
    background: #fef2f2;
    border-color: #fecaca;
    color: #b91c1c;
}

.auth-alert-permissao {
    background: #fefce8;
    border-color: #fef3c7;
    color: #92400e;
}

.auth-alert-timeout {
    background: #eff6ff;
    border-color: #bfdbfe;
    color: #1d4ed8;
}

.auth-alert-sucesso {
    background: #ecfdf3;
    border-color: #bbf7d0;
    color: #047857;
}

/* formulário login */
.auth-form {
    margin-top: 8px;
}

.form-group {
    margin-bottom: 16px;
}

.form-label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #4b5563;
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    border-radius: var(--radius-full);
    border: 1px solid var(--input-border);
    background-color: var(--input-bg);
    padding: 10px 14px;
    font-size: 0.9rem;
    color: var(--text-main);
    outline: none;
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast),
        background-color var(--transition-fast),
        transform 0.04s ease-out;
}

.form-control::placeholder {
    color: #9ca3af;
}

.form-control:focus {
    border-color: var(--accent);
    background-color: #ffffff;
    box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.55),
        0 10px 25px rgba(15, 23, 42, 0.14);
    transform: translateY(-1px);
}

/* senha com botão de olho */
.password-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.btn-eye {
    position: absolute;
    right: 10px;
    width: 26px;
    height: 26px;
    border-radius: 999px;
    border: none;
    background: transparent;
    cursor: pointer;
    padding: 0;
    outline: none;
}

.btn-eye::before,
.btn-eye::after {
    content: "";
    position: absolute;
    inset: 7px 5px;
    border-radius: 999px;
    border: 2px solid #9ca3af;
    opacity: 0.85;
}

.btn-eye::after {
    inset: 11px 9px;
    border-width: 3px;
    border-color: #9ca3af;
    border-radius: 999px;
}

.btn-eye:hover::before,
.btn-eye:hover::after {
    border-color: var(--accent);
}

/* espaçamento entre grids de cards dentro da mesma seção (ex: visão financeira) */
.dashboard-section .cards-grid + .cards-grid {
    margin-top: 16px; /* mesmo valor do gap dos cards */
}


/* linha com botão + link */
.form-footer-row {
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

/* botão padrão */
.btn {
    border: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 11px 26px;
    border-radius: var(--radius-full);
    transition:
        background-color var(--transition-med),
        box-shadow var(--transition-med),
        transform 0.08s ease-out;
}

.btn-primary {
    background: var(--accent);
    color: #111827;
    box-shadow:
        0 10px 30px rgba(255, 122, 26, 0.45),
        0 0 0 6px var(--accent-soft);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow:
        0 16px 45px rgba(255, 122, 26, 0.5),
        0 0 0 7px rgba(255, 122, 26, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
    box-shadow:
        0 6px 18px rgba(255, 122, 26, 0.35),
        0 0 0 5px rgba(255, 122, 26, 0.16);
}

/* link "esqueci minha senha" */
.link-forgot {
    font-size: 0.83rem;
    color: #6b7280;
    text-decoration: none;
    white-space: nowrap;
    transition: color var(--transition-fast), text-decoration-color var(--transition-fast);
}

.link-forgot:hover {
    color: var(--accent);
    text-decoration: underline;
    text-decoration-thickness: 1px;
    text-underline-offset: 3px;
}

/* rodapé login */
.auth-footer {
    margin-top: 20px;
    padding-top: 14px;
    border-top: 1px solid var(--border-soft);
}

.auth-note {
    margin: 0;
    font-size: 0.78rem;
    line-height: 1.6;
    color: var(--text-muted);
}

.auth-note a {
    color: var(--accent);
    font-weight: 600;
    text-decoration: none;
}

.auth-note a:hover {
    text-decoration: underline;
}

/* responsivo login */
@media (max-width: 640px) {
    .auth-card {
        padding: 22px 18px 20px;
        border-radius: 22px;
    }

    .auth-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .auth-logo img {
        width: 56px;
    }

    .auth-title {
        font-size: 1.35rem;
    }

    .form-footer-row {
        flex-direction: column;
        align-items: stretch;
    }

    .btn-primary {
        width: 100%;
        text-align: center;
        justify-content: center;
    }

    .link-forgot {
        text-align: center;
    }
}

/* =========================================================
   LAYOUT DO PAINEL (dashboard, clientes, boletos, etc.)
   ========================================================= */

/* container geral do app – cobre tanto .layout-shell quanto .app-shell */
.layout-shell,
.app-shell {
    min-height: 100vh;
    display: flex;
    background: var(--bg-shell);
}

/* SIDEBAR */
.sidebar,
.app-sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
}

.sidebar-logo-area {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid rgba(15, 23, 42, 0.9);
}

.sidebar-logo-area img {
    width: 36px;
    height: auto;
}

.sidebar-title {
    font-size: 0.95rem;
    font-weight: 600;
    letter-spacing: 0.04em;
}

/* subtítulo sob o nome do painel */
.sidebar-subtitle {
    font-size: 0.72rem;
    color: var(--sidebar-muted);
    margin-top: 2px;
}

.sidebar-section-label {
    margin: 16px 18px 6px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--sidebar-muted);
}

.sidebar-nav {
    padding: 0 10px 16px;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 999px;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    text-decoration: none;
    transition: background-color var(--transition-fast), color var(--transition-fast),
        transform 0.06s ease-out;
}

.sidebar-link .icon,
.sidebar-link span.icon {
    display: inline-flex;
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
}
.sidebar-link .icon .svg-icon,
.sidebar-link .svg-icon {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.sidebar-link:hover {
    background: rgba(31, 41, 55, 0.85);
    transform: translateX(1px);
}

.sidebar-link.active {
    background: linear-gradient(90deg, var(--accent), #ffb062);
    color: #111827;
    font-weight: 600;
}

.sidebar-link--sandbox {
    border: 1px dashed rgba(251,191,36,.4);
    color: #fbbf24 !important;
}
.sidebar-link--sandbox:hover { background: rgba(251,191,36,.12); }
.sidebar-link--sandbox.active { background: rgba(251,191,36,.25); color:#fbbf24 !important; }

/* rodapé da sidebar com usuário */
.sidebar-footer {
    margin-top: auto;
    padding: 12px 16px 18px;
    border-top: 1px solid rgba(15, 23, 42, 0.9);
    font-size: 0.8rem;
    color: var(--sidebar-muted);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.sidebar-user-avatar {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #f97316;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
}

.sidebar-user-info strong {
    display: block;
    color: var(--sidebar-text);
}

.sidebar-logout {
    display: inline-flex;
    margin-top: 4px;
    color: #fca5a5;
    text-decoration: none;
}

.sidebar-logout:hover {
    text-decoration: underline;
}

/* ÁREA PRINCIPAL */
.layout-main,
.app-main {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
}

.main-header,
.app-topbar {
    background: #ffffff;
    padding: 16px 28px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.main-header-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
}

.main-header-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* layout interno da topbar */
.topbar-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

/* Widget Traccar — inline no topbar (desktop), sub-barra no mobile */
.topbar-center {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* botão hamburguer (fica escondido no desktop, aparece no mobile) */
.btn-menu-toggle {
    display: none;
    width: 34px;
    height: 34px;
    border-radius: 999px;
    border: 1px solid var(--border-soft);
    background: #ffffff;
    padding: 0 9px;
    cursor: pointer;
    outline: none;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
}

.btn-menu-toggle span {
    display: block;
    height: 2px;
    border-radius: 999px;
    background: #111827;
}

/* chip de usuário e botão sair */
.topbar-user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px;
    border-radius: 999px;
    background: #f3f4f6;
}

.avatar-circle {
    width: 26px;
    height: 26px;
    border-radius: 999px;
    background: #f97316;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 600;
}

.user-text {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.user-name {
    font-size: 0.82rem;
    font-weight: 600;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

.btn-logout {
    border-radius: 999px;
    border: 1px solid #fecaca;
    background: #fef2f2;
    color: #b91c1c;
    font-size: 0.78rem;
    padding: 6px 14px;
    text-decoration: none;
    font-weight: 500;
}

.btn-logout:hover {
    background: #fee2e2;
}

/* backdrop do menu mobile (off por padrão) */
.sidebar-backdrop {
    display: none;
}


.main-header-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #111827;
}

.main-header-subtitle {
    font-size: 0.82rem;
    color: var(--text-muted);
}

/* Usuário + logout na topbar */
.app-topbar {
    background: #ffffff;
    padding: 14px 28px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.main-header-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.topbar-user {
    display: flex;
    align-items: center;
    gap: 8px;
}

.topbar-user-avatar {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    background: #f97316;
    color: #111827;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.topbar-user-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.topbar-user-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #111827;
}

.topbar-user-role {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.topbar-logout-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 7px 14px;
    border-radius: var(--radius-full);
    border: 1px solid #fecaca;
    background: #fef2f2;
    font-size: 0.8rem;
    font-weight: 500;
    color: #b91c1c;
    text-decoration: none;
    transition:
        background-color var(--transition-fast),
        border-color var(--transition-fast),
        color var(--transition-fast),
        transform 0.04s ease-out;
}

.topbar-logout-btn:hover {
    background: #fee2e2;
    border-color: #fca5a5;
    transform: translateY(-1px);
}

.topbar-logout-btn:active {
    transform: translateY(0);
}


/* conteúdo */
.page-content,
.app-content {
    flex: 1;
    min-width: 0;
    overflow-x: hidden;
    padding: 20px 28px 22px;
}

/* fundo claro por trás do conteúdo */
.page-content-inner {
    min-height: calc(100vh - 120px);
}

/* GRID DE CARDS */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}

/* card estatística */
.stat-card {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card-soft);
    padding: 16px 18px 14px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}

.stat-card--highlight {
    border-color: var(--accent);
    box-shadow: 0 0 0 1px rgba(255, 122, 26, 0.45),
        0 16px 40px rgba(15, 23, 42, 0.12);
}

.stat-card-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
    margin-bottom: 4px;
}

.stat-card-value {
    font-size: 1.55rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 4px;
}

.stat-card-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Linha simples para cards auxiliares da visão financeira */
.dashboard-row--financial {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    margin-top: 1.5rem;
}

/* Card financeiro mais estreito (ex.: inadimplência) */
.stat-card--narrow {
    flex: 1 1 320px;
    max-width: 420px;
}


/* =========================================================
   DASHBOARD – SEÇÕES E LISTAS
   ========================================================= */

.dashboard-section {
    margin-bottom: 28px;
}

.dashboard-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.dashboard-section-title {
    margin: 0;
    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #6b7280;
}

.dashboard-section-subtitle {
    margin: 4px 0 0;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.cards-grid--secondary {
    margin-top: 12px;
}

.cards-grid--two-columns {
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
}

/* submétricas dentro dos cards */
.stat-card-metrics {
    margin-top: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.stat-card-metrics--row {
    flex-wrap: nowrap;
}

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

.stat-metric-label {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.stat-metric-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}

.stat-metric-value--positive {
    color: #16a34a;
}

.stat-metric-value--negative {
    color: #b91c1c;
}

/* links discretos em microtexto */
.link-inline {
    font-size: 0.78rem;
    color: var(--accent);
    text-decoration: none;
}

.link-inline:hover {
    text-decoration: underline;
}

/* cards de lista / pendências */
.card-list {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-soft);
    box-shadow: var(--shadow-card-soft);
    padding: 14px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.card-list--wide {
    margin-top: 6px;
}

.card-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-list-title {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 600;
    color: #111827;
}

.card-list-group {
    margin-top: 4px;
    padding-top: 6px;
    border-top: 1px dashed var(--border-soft);
}

.card-list-group-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 2px;
}

.card-list-empty {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* item de pendência (vamos usar depois quando ligar no banco) */
.card-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    padding-top: 4px;
}

.card-list-item-main {
    display: flex;
    flex-direction: column;
}

.card-list-item-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* badge simples para futuros status */
.badge-pill {
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 500;
    border: 1px solid var(--border-soft);
    background: #f9fafb;
    color: #4b5563;
}

.badge-pill--danger {
    border-color: #fecaca;
    background: #fef2f2;
    color: #b91c1c;
}

.badge-pill--warning {
    border-color: #fed7aa;
    background: #fff7ed;
    color: #c2410c;
}

/* rodapé geral inferior */
.app-footer {
    border-top: 1px solid var(--border-soft);
    padding: 10px 28px 12px;
    font-size: 0.75rem;
    color: #9ca3af;
    display: flex;
    justify-content: space-between;
    background: #ffffff;
}

/* Filtros boletos */
.boletos-toolbar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 16px;
}

.boletos-filtros .filtros-linha {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.boletos-filtros .campo {
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.boletos-filtros .campo-expand {
    flex: 1;
}

.boletos-filtros label {
    font-size: 11px;
    font-weight: 600;
    color: #6b7280;
    margin-bottom: 2px;
}

.boletos-acoes {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.card-tabela-boletos {
    margin-top: 8px;
}

.tabela-scroll {
    overflow-x: auto;
}

.tabela-boletos {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tabela-boletos th,
.tabela-boletos td {
    padding: 8px 10px;
    border-bottom: 1px solid #e5e7eb;
    text-align: left;
}

.tabela-boletos th {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: #6b7280;
}

.tabela-boletos .sem-registros {
    text-align: center;
    padding: 24px 10px;
    color: #6b7280;
}

/* Badges de status */
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 999px;
    font-size: 11px;
    line-height: 1.4;
}

.badge-status-pago {
    background: #dcfce7;
    color: #166534;
}

.badge-status-em-aberto {
    background: #eff6ff;
    color: #1d4ed8;
}

.badge-status-vencido {
    background: #fee2e2;
    color: #b91c1c;
}

.badge-status-cancelado {
    background: #e5e7eb;
    color: #374151;
}

.badge-nf-autorizada {
    background: #ecfdf5;
    color: #047857;
}

.badge-nf-pendente {
    background: #fef9c3;
    color: #854d0e;
}

.badge-nf-não-emitida,
.badge-nf-nao-emitida {
    background: #f3f4f6;
    color: #4b5563;
}

.badge-nf-erro {
    background: #fee2e2;
    color: #b91c1c;
}

.paginacao-boletos {
    display: flex;
    justify-content: flex-end;
    gap: 4px;
    padding-top: 8px;
}

.page-link {
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 12px;
    text-decoration: none;
    color: #4b5563;
    background: #f3f4f6;
}

.page-link.ativo {
    background: #2563eb;
    color: #fff;
}

/* Resumo da administração de boletos */
.card-resumo-boletos-mes {
    margin-bottom: 1.5rem;
}

.boletos-resumo-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 24px;
}

.boletos-resumo-grid .resumo-bloco {
    min-width: 220px;
}

.boletos-resumo-grid .resumo-label {
    display: block;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #6b7280;
    margin-bottom: 4px;
}

.boletos-resumo-grid strong {
    font-size: 18px;
    display: block;
    margin-bottom: 4px;
}

.boletos-resumo-grid small {
    font-size: 12px;
    color: #4b5563;
}

/* Resumo no cabeçalho da tabela de boletos */
.card-tabela-boletos .card-header.boletos-header-flex {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.boletos-header-esq small {
    display: block;
    margin-top: 2px;
    color: #64748b;
    font-size: 12px;
}

.boletos-header-dir {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 12px;
}

.boletos-header-dir .resumo-chip {
    background: #f1f5f9;
    border-radius: 999px;
    padding: 6px 12px;
    display: flex;
    flex-direction: column;
    min-width: 120px;
}

.boletos-header-dir .resumo-chip span {
    text-transform: uppercase;
    font-size: 10px;
    color: #64748b;
    margin-bottom: 2px;
}

.boletos-header-dir .resumo-chip strong {
    font-size: 13px;
}

.boletos-header-dir .resumo-chip small {
    font-size: 11px;
    color: #0f172a;
}





/* =========================================================
   RESPONSIVO PAINEL
   ========================================================= */

@media (max-width: 1024px) {
    .sidebar,
    .app-sidebar {
        width: 220px;
    }
}

@media (max-width: 768px) {

    .app-shell {
        position: relative;
    }

    /* sidebar vira off-canvas à esquerda */
    .sidebar,
    .app-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px;
        max-width: 80%;
        flex-direction: column;
        overflow-y: auto;
        box-shadow: 0 0 40px rgba(15, 23, 42, 0.55);
        transform: translateX(-100%);
        transition: transform 0.25s ease-out;
        z-index: 40;
    }

    /* quando body tiver .sidebar-open, o menu aparece */
    body.sidebar-open .app-sidebar {
        transform: translateX(0);
    }

    /* backdrop escuro atrás do menu */
    .sidebar-backdrop {
        position: fixed;
        inset: 0;
        background: rgba(15, 23, 42, 0.55);
        z-index: 30;
        display: none;
    }

    body.sidebar-open .sidebar-backdrop {
        display: block;
    }

    /* escondemos o rodapé da sidebar no mobile */
    .sidebar-footer {
        display: none;
    }

    /* topbar mais compacta e com botão de menu */
    .app-topbar {
        padding: 10px 16px;
    }

    .btn-menu-toggle {
        display: flex;
    }

    .page-content,
    .app-content {
        padding: 16px 14px 18px;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    /* chip de usuário mais enxuto */
    .topbar-user-chip {
        background: transparent;
        padding: 0;
    }

    .topbar-right {
        gap: 8px;
    }
}

/* =========================================================
   MODAL - INADIMPLENTES
   ========================================================= */

.dashboard-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(15, 23, 42, 0.72);

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;
}

.dashboard-modal-content {
    width: 100%;
    max-width: 1100px;
    max-height: 85vh;

    overflow: auto;

    background: #fff;
    border-radius: 18px;
    padding: 24px;

    box-shadow: 0 30px 80px rgba(0,0,0,0.25);
}

.dashboard-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 18px;
}

.dashboard-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.dashboard-modal-header button {
    border: 0;
    background: transparent;
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
}

/* =========================================================================
   CONFIGURAÇÕES — config-page
   ========================================================================= */

.config-page {
    max-width: 900px;
}

.config-sandbox-banner {
    background: #fffbeb;
    border: 1.5px solid #f59e0b;
    border-radius: 10px;
    padding: 12px 18px;
    color: #92400e;
    margin-bottom: 22px;
    font-size: 0.9rem;
}

.alert-warning { /* alias */
    background: #fffbeb;
    border: 1.5px solid #f59e0b;
    color: #92400e;
}

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

.page-title {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0 0 4px;
    color: #0b1120;
}

.page-subtitle {
    font-size: 0.88rem;
    color: #64748b;
    margin: 0;
}

/* Feedback (success/error) */
.config-feedback {
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    font-size: 0.9rem;
    font-weight: 500;
}

.feedback-ok {
    background: #f0fdf4;
    border: 1px solid #86efac;
    color: #166534;
}

.feedback-err {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #991b1b;
}

/* Card de seção */
.config-card {
    background: #fff;
    border-radius: 14px;
    border: 1px solid #e2e8f0;
    padding: 24px 28px;
    margin-bottom: 20px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.config-card-header {
    margin-bottom: 20px;
}

.config-card-title {
    font-size: 1rem;
    font-weight: 700;
    color: #0b1120;
    margin: 0 0 4px;
}

.config-card-desc {
    font-size: 0.83rem;
    color: #64748b;
    margin: 0;
}

/* Grid de campos */
.config-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 18px 24px;
}

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

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

.config-label {
    font-size: 0.83rem;
    font-weight: 600;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-input {
    width: 100%;
    padding: 9px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    background: #f8fafc;
    color: #0b1120;
    transition: border-color .15s;
    box-sizing: border-box;
}

.config-input:focus {
    outline: none;
    border-color: #4f8ef7;
    background: #fff;
}

.config-hint {
    font-size: 0.78rem;
    color: #94a3b8;
    line-height: 1.4;
}

.config-hint code {
    background: #f1f5f9;
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 0.78rem;
    color: #475569;
}

/* Badges prod/sandbox */
.config-badge {
    font-size: 0.7rem;
    font-weight: 600;
    border-radius: 999px;
    padding: 1px 8px;
}

.config-badge.prod {
    background: #dcfce7;
    color: #166534;
}

.config-badge.sandbox {
    background: #fef9c3;
    color: #854d0e;
}

/* Campo com botão de toggle de visibilidade */
.token-input-wrap {
    position: relative;
    display: flex;
    align-items: center;
}

.token-input-wrap .config-input {
    flex: 1;
    padding-right: 40px;
}

.btn-token-toggle {
    position: absolute;
    right: 8px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    padding: 4px;
    line-height: 1;
    color: #64748b;
}

/* Toggle de ambiente (prod / sandbox) */
.config-field-row {
    display: flex;
    align-items: center;
    gap: 16px;
}

.toggle-group {
    display: flex;
    gap: 10px;
}

.toggle-option {
    cursor: pointer;
    border-radius: 8px;
    padding: 2px;
}

.toggle-option input[type=radio] {
    display: none;
}

.toggle-badge {
    display: block;
    padding: 8px 20px;
    border-radius: 8px;
    font-size: 0.88rem;
    font-weight: 600;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
    transition: all .15s;
}

.toggle-option.active .toggle-badge.prod {
    border-color: #22c55e;
    background: #dcfce7;
    color: #166534;
}

.toggle-option.active .toggle-badge.sandbox {
    border-color: #f59e0b;
    background: #fffbeb;
    color: #92400e;
}

/* Agenda de dias de envio WA */
.wa-dias-semana {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.wa-dia-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 40px;
    border-radius: 8px;
    border: 2px solid #e2e8f0;
    background: #f8fafc;
    color: #94a3b8;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
}

.wa-dia-btn input[type=checkbox] {
    display: none;
}

.wa-dia-btn.ativo {
    background: #22c55e;
    border-color: #16a34a;
    color: #fff;
}

.wa-dia-btn:hover {
    border-color: #22c55e;
}

/* Botão inferior */
.config-actions-bottom {
    display: flex;
    justify-content: flex-end;
    padding: 8px 0 4px;
}

@media (max-width: 640px) {
    .config-grid {
        grid-template-columns: 1fr;
    }

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

    .page-header-row {
        flex-direction: column;
    }
}

/* =========================================================================
   CLIENTES — clientes-page
   ========================================================================= */

.clientes-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Cards de resumo (reutilizados em outros módulos) */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.summary-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 14px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.summary-card--highlight {
    background: linear-gradient(135deg, #0b1120 0%, #1e293b 100%);
    border-color: transparent;
    color: #fff;
}

.summary-card--highlight .summary-card-label {
    color: #94a3b8;
}

.summary-card-icon {
    font-size: 1.8rem;
    flex-shrink: 0;
}

.summary-card-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.summary-card-label {
    font-size: 0.8rem;
    color: #64748b;
    margin-top: 4px;
}

/* Barra de ferramentas */
.table-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

/* Filtros crescem para preencher espaço disponível */
.table-toolbar > .filtros-linha,
.table-toolbar > form.filtros-linha {
    flex: 1;
    min-width: 0;
}

/* Desktop/notebook: os filtros precisam de uma largura mínima na linha.
   Sem isso, quando o grupo ao lado é largo (busca + vários botões, como em
   dispositivos.php), o form encolhia até a largura de um filtro e cada
   seletor caía numa linha. Agora é o grupo vizinho que desce para baixo.
   (No mobile a toolbar já é em coluna — ver media query ≤768px.) */
@media (min-width: 769px) {
    .table-toolbar > .filtros-linha,
    .table-toolbar > form.filtros-linha {
        flex: 1 1 560px;
    }
}
/* O grupo busca + botões quebra a própria linha em vez de passar da tela.
   Vale também no celular: sem a quebra, a busca (100% da largura) espremia
   os botões até largura zero e o texto deles empilhava na vertical, abrindo
   um espaço vazio enorme acima da "Busca rápida" (dispositivos.php). */
.table-toolbar > .filtros-busca-group {
    max-width: 100%;
    min-width: 0;
    flex-wrap: wrap;
}
.filtros-busca-group > .btn {
    flex-shrink: 0;
    white-space: nowrap;
}

/* Botões de ação na toolbar */
.toolbar-acoes {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
    align-items: flex-end;
}

/* Grupo busca + ação (ex: busca live + botão novo) */
.filtros-busca-group {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.search-form {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    max-width: 480px;
}

.search-input {
    flex: 1;
    padding: 8px 12px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.88rem;
    font-family: inherit;
    background: #f8fafc;
    transition: border-color .15s;
}

.search-input:focus {
    outline: none;
    border-color: #4f8ef7;
    background: #fff;
}

.pagination-info {
    font-size: 0.83rem;
    color: #64748b;
}

/* Tabela de dados */
.table-wrapper {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
    /* Rola de lado quando a tabela não cabe (antes: hidden = colunas da
       direita, como Ações, simplesmente sumiam em notebook) */
    overflow-x: auto;
    overflow-y: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.04);
}

.table-empty {
    padding: 40px;
    text-align: center;
    color: #94a3b8;
    font-size: 0.9rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;
}

.data-table thead tr {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #64748b;
    white-space: nowrap;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #f1f5f9;
    color: #0b1120;
    vertical-align: middle;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

.data-table tbody tr:hover {
    background: #f8fafc;
}

.data-table tbody tr.row-muted td {
    color: #94a3b8;
}

.text-center { text-align: center; }
.text-right  { text-align: right; }
.text-muted  { color: #94a3b8; }
.font-mono   { font-family: 'Courier New', monospace; }

/* Célula de nome do cliente */
.client-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.client-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4f8ef7, #7c5cbf);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 700;
    flex-shrink: 0;
}

.client-name {
    font-weight: 600;
    color: #0b1120;
}

.client-id {
    font-size: 0.75rem;
    color: #94a3b8;
}

.client-contact {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.client-phone {
    font-size: 0.8rem;
    color: #64748b;
}

/* Contagem de devices */
.device-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    font-weight: 700;
}

.device-count--ativo {
    background: #dcfce7;
    color: #166534;
}

.device-count--zero {
    background: #f1f5f9;
    color: #94a3b8;
}

/* Badges de status */
.badge {
    display: inline-block;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 0.74rem;
    font-weight: 600;
    white-space: nowrap;
}

.badge-success   { background: #dcfce7; color: #166534; }
.badge-warning   { background: #fef9c3; color: #854d0e; }
.badge-danger    { background: #fee2e2; color: #991b1b; }
.badge-secondary { background: #f1f5f9; color: #64748b; }

/* Ações por linha */
.actions-cell {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

/* SVG icon global — herda currentColor do elemento pai */
.svg-icon {
    display: inline-block;
    width: 14px;
    height: 14px;
    flex-shrink: 0;
    vertical-align: -0.12em;
    pointer-events: none;
}
.btn .svg-icon  { width: 14px; height: 14px; }
.btn-sm .svg-icon { width: 13px; height: 13px; }
.btn-xs .svg-icon { width: 11px; height: 11px; }
.btn-icon .svg-icon { width: 15px; height: 15px; vertical-align: middle; }

.btn-icon {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border: 1px solid transparent;
    background: #f1f5f9;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.88rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: background .15s, box-shadow .15s, transform .12s, border-color .15s;
    color: #374151;
    line-height: 1;
}
.btn-icon:hover      { background: #e2e8f0; border-color: #cbd5e1; box-shadow: 0 2px 5px rgba(0,0,0,.08); transform: translateY(-1px); }
.btn-icon:active     { transform: scale(0.92); box-shadow: none; }

.btn-icon--edit      { color: #2563eb; }
.btn-icon--edit:hover      { background: #dbeafe; border-color: #bfdbfe; box-shadow: 0 2px 5px rgba(37,99,235,.15); }

.btn-icon--view      { color: #059669; }
.btn-icon--view:hover      { background: #d1fae5; border-color: #a7f3d0; box-shadow: 0 2px 5px rgba(5,150,105,.15); }

.btn-icon--add       { color: #7c3aed; }
.btn-icon--add:hover       { background: #ede9fe; border-color: #ddd6fe; box-shadow: 0 2px 5px rgba(124,58,237,.15); }

.btn-icon--info      { color: #0891b2; }
.btn-icon--info:hover      { background: #cffafe; border-color: #a5f3fc; box-shadow: 0 2px 5px rgba(8,145,178,.15); }

.btn-icon--warning   { color: #d97706; }
.btn-icon--warning:hover   { background: #fef3c7; border-color: #fde68a; box-shadow: 0 2px 5px rgba(217,119,6,.15); }

.btn-icon--danger    { color: #dc2626; }
.btn-icon--danger:hover    { background: #fee2e2; border-color: #fecaca; box-shadow: 0 2px 5px rgba(220,38,38,.15); }

@media (max-width: 640px) {
    .btn-icon {
        width: 38px;
        height: 38px;
        min-width: 38px;
        border-radius: 10px;
        font-size: 1rem;
    }
    .actions-cell { gap: 6px; }
}

/* Paginação */
.pagination-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    flex-wrap: wrap;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 0.85rem;
    text-decoration: none;
    color: #374151;
    background: #fff;
    border: 1px solid #e2e8f0;
    transition: all .15s;
}

.pagination-btn:hover {
    background: #f1f5f9;
}

.pagination-btn.active {
    background: #0b1120;
    color: #fff;
    border-color: #0b1120;
}

.pagination-btn-disabled,
.pagination-ellipsis {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    font-size: 0.85rem;
    color: #cbd5e1;
    user-select: none;
}

.pagination-btn-disabled { cursor: not-allowed; }

.pagination-btn[disabled] {
    opacity: .45;
    cursor: not-allowed;
    pointer-events: none;
}

/* =========================================================================
   DRAWER — modal lateral de detalhe
   ========================================================================= */

.drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s;
}

.drawer-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

.drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 440px;
    max-width: 100vw;
    height: 100vh;
    background: #fff;
    z-index: 201;
    display: flex;
    flex-direction: column;
    box-shadow: -8px 0 40px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform .25s ease;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.drawer-title {
    font-size: 1rem;
    font-weight: 700;
    margin: 0;
    color: #0b1120;
}

.drawer-close {
    border: none;
    background: #f1f5f9;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drawer-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.drawer-loading,
.drawer-error {
    padding: 40px 0;
    text-align: center;
    color: #94a3b8;
    font-size: 0.9rem;
}

.drawer-error {
    color: #991b1b;
}

.drawer-section {
    margin-bottom: 24px;
}

.drawer-section-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: #374151;
    margin: 0 0 12px;
}

.drawer-info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px 20px;
}

.info-label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 2px;
}

.info-val {
    font-size: 0.88rem;
    color: #0b1120;
}

.device-row {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 6px;
}

.device-row-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: #0b1120;
}

.device-row-info {
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 2px;
}

.drawer-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
}

.drawer-table th {
    text-align: left;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    color: #94a3b8;
    padding: 6px 8px;
    border-bottom: 1px solid #e2e8f0;
}

.drawer-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #f1f5f9;
}

@media (max-width: 768px) {
    .summary-cards {
        grid-template-columns: 1fr 1fr;
    }

    .drawer {
        width: 100vw;
    }
}

/* =========================================================================
   BOLETOS — boletos-page
   ========================================================================= */

.boletos-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

/* Alerta de drafts pendentes */
.alert-drafts {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: #fffbeb;
    border: 1.5px solid #f59e0b;
    border-radius: 10px;
    padding: 12px 18px;
    color: #92400e;
    font-size: 0.9rem;
}

/* Toolbar de filtros */
.boletos-toolbar {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.boletos-filtros {
    flex: 1;
}

.filtros-linha {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-wrap: wrap;
}

.filtro-campo {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.filtro-campo--expand {
    flex: 1;
    min-width: 200px;
}

.filtro-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.filtro-select,
.filtro-input {
    padding: 8px 10px;
    border: 1.5px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.87rem;
    font-family: inherit;
    background: #f8fafc;
    color: #0b1120;
    transition: border-color .15s;
}

.filtro-input--sm {
    width: 90px;
}

.filtro-select:focus,
.filtro-input:focus {
    outline: none;
    border-color: #4f8ef7;
    background: #fff;
}

.boletos-acoes {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* Chips de resumo */
.boletos-resumo-chips {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
}

.resumo-chip {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.resumo-chip--pago   { border-left: 3px solid #22c55e; }
.resumo-chip--inad   { border-left: 3px solid #ef4444; }
.resumo-chip--neutro { border-left: 3px solid #64748b; }

.chip-label {
    display: block;
    font-size: 0.74rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #94a3b8;
    margin-bottom: 4px;
}

.chip-valor {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #0b1120;
    line-height: 1;
}

.chip-detalhe {
    display: block;
    font-size: 0.78rem;
    color: #64748b;
    margin-top: 4px;
}

/* Tabela específica de boletos */
.boletos-table .row-inadip {
    background: #fff5f5;
}

.boletos-table .row-inadip:hover {
    background: #fee2e2;
}

.col-id {
    width: 80px;
}

.boleto-id {
    display: block;
    font-weight: 700;
    font-size: 0.82rem;
}

.boleto-num {
    display: block;
    font-size: 0.72rem;
    color: #94a3b8;
}

.boleto-cliente-nome {
    font-weight: 600;
    font-size: 0.87rem;
}

.boleto-cliente-email {
    font-size: 0.76rem;
    color: #64748b;
}

.link-nf {
    margin-left: 4px;
    font-size: 0.9rem;
    text-decoration: none;
}

/* Botões gerais */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 10px;
    font-size: 0.88rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    border: 1.5px solid transparent;
    text-decoration: none;
    letter-spacing: 0.01em;
    transition: background .15s, box-shadow .15s, transform .12s, border-color .15s;
}
.btn:active { transform: scale(0.97); }

.btn-sm {
    padding: 7px 12px;
    font-size: 0.82rem;
    border-radius: 8px;
}

.btn-primary {
    background: #1e293b;
    color: #fff;
    border-color: #1e293b;
    box-shadow: 0 1px 3px rgba(15,23,42,.25), 0 1px 2px rgba(15,23,42,.12);
}
.btn-primary:hover {
    background: #0f172a;
    border-color: #0f172a;
    box-shadow: 0 4px 12px rgba(15,23,42,.3), 0 2px 4px rgba(15,23,42,.15);
    transform: translateY(-1px);
}
.btn-primary:active { transform: scale(0.97); box-shadow: 0 1px 3px rgba(15,23,42,.2); }

.btn-secondary {
    background: #f8fafc;
    color: #374151;
    border-color: #dde3ec;
    box-shadow: 0 1px 2px rgba(0,0,0,.06);
}
.btn-secondary:hover {
    background: #eef2f7;
    border-color: #c8d0dc;
    box-shadow: 0 2px 6px rgba(0,0,0,.09);
    transform: translateY(-1px);
}
.btn-secondary:active { transform: scale(0.97); box-shadow: none; }

.btn-outline {
    background: transparent;
    color: #374151;
    border-color: #cbd5e1;
}
.btn-outline:hover {
    background: #f8fafc;
    border-color: #94a3b8;
    transform: translateY(-1px);
}
.btn-outline:active { transform: scale(0.97); }

.btn-warning {
    background: #f59e0b;
    color: #fff;
    border-color: #f59e0b;
    box-shadow: 0 1px 3px rgba(245,158,11,.3);
}
.btn-warning:hover {
    background: #d97706;
    border-color: #d97706;
    box-shadow: 0 4px 10px rgba(245,158,11,.35);
    transform: translateY(-1px);
}
.btn-warning:active { transform: scale(0.97); box-shadow: none; }

@media (max-width: 768px) {
    .boletos-resumo-chips {
        grid-template-columns: 1fr 1fr;
    }
}

/* =========================================================================
   DISPOSITIVOS
   ========================================================================= */

.dispositivos-page {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.device-name {
    font-weight: 600;
    font-size: 0.87rem;
}

.device-uid {
    font-size: 0.74rem;
    color: #94a3b8;
    font-family: 'Courier New', monospace;
}

.device-status {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-online  { background: #dcfce7; color: #166534; }
.status-offline { background: #fee2e2; color: #991b1b; }
.status-unknown { background: #f1f5f9; color: #94a3b8; }

.link-cliente {
    color: #4f8ef7;
    text-decoration: none;
    font-size: 0.85rem;
}

.link-cliente:hover {
    text-decoration: underline;
}

/* =========================================================
   PRÉ-BOLETOS
   ========================================================= */
.pre-boletos-page .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.5rem;
    gap: 1rem;
}
.pre-boletos-page .page-header__left h1 { margin: 0 0 0.25rem; }
.pre-boletos-page .page-header__left .page-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.drafts-summary {
    background: var(--accent-soft);
    border: 1px solid var(--accent);
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
    color: var(--accent);
    font-weight: 500;
}
.drafts-count {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent);
    margin-right: 0.35rem;
}

.draft-cliente {
    display: flex;
    flex-direction: column;
    gap: 2px;
}
.draft-cliente strong { font-size: 0.9rem; }
.draft-cliente small  { color: var(--text-muted); font-size: 0.78rem; }

.col-valor-final { font-weight: 600; }
.valor-final { color: var(--text-main); font-size: 0.95rem; }

.text-green { color: #16a34a; }

.feedback-bar {
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
    font-weight: 500;
}
.feedback-bar--success { background: #dcfce7; color: #166534; border: 1px solid #bbf7d0; }
.feedback-bar--error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.feedback-bar--warning { background: #fef9c3; color: #854d0e; border: 1px solid #fde68a; }
.feedback-bar--info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* Modal genérico */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.modal-box {
    background: var(--bg-card);
    border-radius: var(--radius-lg, 12px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.18);
    width: 92%;
    max-width: 640px;
    max-height: 90vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}
.modal-box--sm { max-width: 480px; }
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}
.modal-title   { margin: 0; font-size: 1.05rem; }
.modal-close {
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    padding: 0 0.25rem;
}
.modal-close:hover { color: var(--text-main); }
.modal-body  { padding: 1rem 1.25rem; flex: 1; }
.modal-desc  { color: var(--text-muted); font-size: 0.9rem; margin: 0 0 0.75rem; }
.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border-soft);
}

.data-table--compact th,
.data-table--compact td { padding: 0.45rem 0.7rem; font-size: 0.85rem; }

/* =========================================================
   ALERTAS
   ========================================================= */
.alertas-page .page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 1.25rem;
    gap: 1rem;
}
.alertas-page .page-header__left h1 { margin: 0 0 0.2rem; }
.alertas-page .page-header__left .page-subtitle { color: var(--text-muted); font-size: 0.9rem; margin: 0; }

.alertas-resumo {
    margin-bottom: 1.5rem;
}
.alertas-ok {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: #dcfce7;
    border: 1px solid #bbf7d0;
    border-radius: var(--radius);
    padding: 0.85rem 1.25rem;
    color: #166534;
    font-weight: 500;
}
.alertas-ok__icon {
    font-size: 1.2rem;
    font-weight: 700;
}
.alertas-count {
    background: #fee2e2;
    border: 1px solid #fecaca;
    border-radius: var(--radius);
    padding: 0.75rem 1.25rem;
    color: #991b1b;
    font-size: 0.95rem;
}
.alertas-count strong { font-size: 1.3rem; }

.alerta-card {
    background: var(--bg-card);
    border-radius: var(--radius);
    border-left: 4px solid transparent;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.25rem;
    overflow: hidden;
}
.alerta-card--warning { border-left-color: #f59e0b; }
.alerta-card--danger  { border-left-color: #ef4444; }
.alerta-card--info    { border-left-color: #3b82f6; }

.alerta-card__header {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-soft);
}
.alerta-card__icon    { font-size: 1.1rem; }
.alerta-card__title   { margin: 0; font-size: 1rem; flex: 1; }
.alerta-card__action  { margin-left: auto; white-space: nowrap; }
.alerta-card__desc    { padding: 0.6rem 1.25rem 0; color: var(--text-muted); font-size: 0.88rem; margin: 0; }
.alerta-card .data-table-wrap { padding: 0; }
.alerta-card .data-table { border-radius: 0; box-shadow: none; }

/* ── Botão danger ──────────────────────────────────────────────────────────── */
.btn-danger {
    background: #ef4444;
    color: #fff;
    border: 1.5px solid #ef4444;
    padding: 0.45rem 1rem;
    border-radius: 10px;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    letter-spacing: 0.01em;
    box-shadow: 0 1px 3px rgba(239,68,68,.3);
    transition: background .15s, box-shadow .15s, transform .12s;
}
.btn-danger:hover {
    background: #dc2626;
    border-color: #dc2626;
    box-shadow: 0 4px 10px rgba(239,68,68,.35);
    transform: translateY(-1px);
    color: #fff;
}
.btn-danger:active { transform: scale(0.97); box-shadow: none; }
.btn-sm.btn-danger { padding: 0.3rem 0.7rem; font-size: 0.8rem; border-radius: 8px; }

/* ── Page header flexbox (alertas / pré-boletos) ───────────────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
}
.page-header__left  { flex: 1; min-width: 0; }
.page-header__right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* ── Empty state ───────────────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-muted);
}
.empty-state__icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
    color: #10b981;
}
.empty-state h3 { margin: 0 0 0.5rem; font-size: 1.1rem; color: var(--text-main); }
.empty-state p  { margin: 0; font-size: 0.9rem; }


/* ── Btn-success ───────────────────────────────────────────────────────────── */
.btn-success {
    background: #10b981;
    color: #fff;
    border: 1.5px solid #10b981;
    box-shadow: 0 1px 3px rgba(16,185,129,.3);
    transition: background .15s, box-shadow .15s, transform .12s;
}
.btn-success:hover {
    background: #059669;
    border-color: #059669;
    box-shadow: 0 4px 10px rgba(16,185,129,.35);
    transform: translateY(-1px);
    color: #fff;
}
.btn-success:active { transform: scale(0.97); box-shadow: none; }

/* ── Boleto toast notifications ────────────────────────────────────────────── */
.boleto-toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
    animation: toastIn .2s ease;
}
.boleto-toast--ok  { background: #10b981; color: #fff; }
.boleto-toast--err { background: #ef4444; color: #fff; }
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } to { opacity:1; transform: translateY(0); } }

/* ── Form input (modal fields) ─────────────────────────────────────────────── */
/* --border e --surface não existem no :root — sem o fallback a borda sumia (04/12/2026) */
.form-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border, #d1d5db);
    border-radius: 8px;
    font-size: 0.9rem;
    background: var(--surface, #fff);
    color: var(--text-main, #111827);
    box-sizing: border-box;
    min-height: 40px;
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus { outline: none; border-color: var(--primary, #6366f1); box-shadow: 0 0 0 3px rgba(99, 102, 241, .15); }

/* ==========================================================================
   Clientes — Abas de navegação
   ========================================================================== */
.tab-bar {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}
.tab-item {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-muted);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s, border-color 0.15s;
}
.tab-item:hover { color: var(--primary); }
.tab-item.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.4rem;
    height: 1.4rem;
    padding: 0 0.35rem;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 600;
    background: var(--border);
    color: var(--text-muted);
}
.tab-count--warn   { background: #fef9c3; color: #92400e; }
.tab-count--danger { background: #fee2e2; color: #991b1b; }

/* ==========================================================================
   Clientes — Badges e botões extra
   ========================================================================== */
.badge-xs { font-size: 0.68rem; padding: 0.15rem 0.45rem; }
.btn-xs { padding: 0.2rem 0.5rem; font-size: 0.75rem; border-radius: 6px; }
.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0.2rem 0.55rem;
    line-height: 1.4;
    transition: background .15s, color .15s, box-shadow .15s, transform .12s;
}
.btn-outline-primary:hover {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,.15);
    transform: translateY(-1px);
}
.btn-outline-primary:active { transform: scale(0.97); }

/* ==========================================================================
   Clientes — Seção informativa
   ========================================================================== */
.section-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    font-size: 0.88rem;
    color: #0c4a6e;
}
.section-info p { margin: 0; }
.section-info--warn {
    background: #fffbeb;
    border-color: #fcd34d;
    color: #78350f;
}

/* ==========================================================================
   Global Sandbox Banner
   ========================================================================== */
.global-sandbox-banner {
    background: #fef3c7;
    border-bottom: 2px solid #f59e0b;
    color: #78350f;
    font-size: 0.85rem;
    font-weight: 500;
    padding: 0.55rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0;
}
.global-sandbox-banner strong { font-weight: 700; }
.global-sandbox-link {
    margin-left: auto;
    font-size: 0.8rem;
    color: #92400e;
    text-decoration: underline;
}
.global-sandbox-link:hover { color: #78350f; }

/* ==========================================================================
   Configurações — Cobrança/Notificação flow
   ========================================================================== */
.cobranca-fluxo {
    display: flex;
    flex-direction: column;
    gap: 0;
}
.fluxo-step {
    display: flex;
    align-items: flex-start;
    gap: 0.85rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 0.85rem 1rem;
}
.fluxo-step--notif {
    border-color: #a5f3fc;
    background: #f0fdff;
}
.fluxo-icon {
    font-size: 1.4rem;
    line-height: 1;
    flex-shrink: 0;
    margin-top: 0.1rem;
}
.fluxo-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.fluxo-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text);
}
.fluxo-desc {
    font-size: 0.8rem;
    color: var(--text-muted);
}
.fluxo-input {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.4rem;
}
.fluxo-unit {
    font-size: 0.82rem;
    color: var(--text-muted);
    white-space: nowrap;
}
.fluxo-arrow {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-muted);
    padding: 0.15rem 0;
}
.config-input--sm {
    width: 4.5rem;
    text-align: center;
    padding: 0.3rem 0.5rem;
}

/* ==========================================================================
   GRIDS RESPONSIVOS — FORMULÁRIOS E MODAIS
   ========================================================================== */
.form-grid-2 { display:grid; grid-template-columns:1fr 1fr; gap:14px; }
.form-grid-3 { display:grid; grid-template-columns:1fr 1fr 1fr; gap:14px; }
.form-grid-full { grid-column:1 / -1; }

@media (max-width: 600px) {
    .form-grid-2,
    .form-grid-3 { grid-template-columns:1fr; }
    .form-grid-full { grid-column:1; }
}

/* ==========================================================================
   RESPONSIVIDADE GLOBAL — MOBILE
   ========================================================================== */

/* Tabelas com scroll horizontal em telas pequenas */
@media (max-width: 768px) {
    .table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* Toolbar empilha em coluna */
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .table-toolbar .filtros-linha {
        flex-wrap: wrap;
    }

    /* Cards de resumo: 2 colunas no mobile */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Modais: full-width na borda inferior */
    .modal-overlay {
        padding: 8px;
        align-items: flex-end;
    }
    .modal-box {
        border-radius: 20px 20px 14px 14px;
        width: 100% !important;
        max-width: 100% !important;
        max-height: 92vh;
    }

    /* Formulários dentro de modais: forçar coluna única */
    .modal-box [style*="grid-template-columns:1fr 1fr"],
    .modal-box [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    /* Botões do footer de modal: full-width */
    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px;
    }
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }

    /* Stat cards responsivos */
    .stat-card-grid {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 480px) {
    .summary-cards {
        grid-template-columns: 1fr !important;
    }
    .filtro-campo { min-width: 100%; }
    .dashboard-section { padding: 12px; }
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE — CORREÇÕES ABRANGENTES
   ========================================================================== */

/* Previne overflow horizontal — apenas no wrapper interno, nunca em html/body
   (overflow-x:hidden no body cria scroll container no iOS Safari, quebrando
   position:fixed e interceptando eventos de toque nos elementos da página) */
.app-shell {
    overflow-x: hidden;
    max-width: 100%;
}

/* Força min-width:0 em toda a cadeia flex para evitar transbordamento */
.app-shell > * { min-width: 0; }

/* Conteúdo da página não ultrapassa a viewport */
.page-content-inner,
.clientes-page,
.boletos-page,
.dispositivos-page,
.notas-page {
    max-width: 100%;
    overflow-x: hidden;
}

/* Grids de cards — tornar responsivos em TODOS os casos */
.summary-cards {
    grid-template-columns: repeat(4, 1fr);
}

/* Stats-grid baseados em flex também devem quebrar corretamente */
.stats-grid,
.stat-card-row {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}
.stats-grid > *,
.stat-card-row > * {
    flex: 1;
    min-width: 140px;
}

@media (max-width: 900px) {
    .summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    .page-content,
    .app-content {
        padding: 16px 16px 20px;
    }
}

@media (max-width: 768px) {
    /* Topbar: esconde o chip de token de debug em telas menores */
    .app-topbar > .topbar-right > div[style*="background:#0b1120"],
    .app-topbar > .topbar-right > div[style*="background: #0b1120"] {
        display: none;
    }
    .topbar-right {
        gap: 6px;
    }
    /* Oculta texto do user na topbar em mobile */
    .user-text {
        display: none;
    }
    /* Resumo cards: 2 colunas */
    .summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px;
    }
    /* Content padding reduzido */
    .page-content,
    .app-content {
        padding: 12px 12px 18px;
    }
    /* Tabelas com scroll horizontal */
    .table-wrapper,
    [style*="overflow-x:auto"],
    .aud-page > div[style*="overflow-x"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    /* Toolbars empilham em coluna */
    .boletos-toolbar,
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .boletos-filtros .filtros-linha {
        flex-wrap: wrap;
    }
    /* Drawer full-width */
    .drawer {
        width: 100vw !important;
        max-width: 100vw !important;
    }
    /* Action bars e botões */
    .action-bar {
        flex-wrap: wrap;
    }
    /* Cards do dashboard: métricas em linha (nowrap) transbordam a tela em
       telas estreitas — libera a quebra e deixa 2 por linha em vez de 3 */
    .stat-card-metrics--row {
        flex-wrap: wrap;
    }
    .stat-card-metrics--row .stat-metric {
        flex: 1 1 40%;
        min-width: 110px;
    }
}

@media (max-width: 540px) {
    /* Cards 1 coluna em telas muito pequenas */
    .summary-cards {
        grid-template-columns: 1fr !important;
    }
    .stats-grid > *,
    .stat-card-row > * {
        min-width: calc(50% - 6px);
        flex: 1 1 calc(50% - 6px);
    }
    /* Page header mais compacto */
    .main-header-title {
        font-size: 0.95rem;
    }
    .main-header-subtitle {
        display: none;
    }
    .page-content,
    .app-content {
        padding: 10px 10px 16px;
    }
    /* Logout esconde texto */
    .btn-logout {
        font-size: 0;
        padding: 6px 10px;
    }
    .btn-logout::before {
        content: "→";
        font-size: 0.85rem;
    }
}

/* ==========================================================================
   RESPONSIVIDADE MOBILE — TABELAS E TOOLBARS
   ========================================================================== */

/* ---- Tabela: reduz padding e libera quebra de linha nos cabeçalhos ---- */
@media (max-width: 768px) {
    .data-table th {
        white-space: normal;
        padding: 8px 8px;
        font-size: 0.7rem;
    }
    .data-table td {
        padding: 8px 8px;
        font-size: 0.83rem;
    }

    /* Boletos: colunas tratadas em assets/css/boletos-ui.css (04/12/2026) */

    /* Clientes: colunas tratadas em clientes.php (classes col-*) */

    /* Dispositivos: colunas tratadas em dispositivos.php (classes col-*, container query) */

    /* Toolbar de clientes: search ocupa toda a largura */
    .search-form {
        max-width: 100%;
        width: 100%;
    }

    /* Toolbar de dispositivos: busca rápida full-width */
    #busca-live {
        width: 100% !important;
        min-width: 0;
    }

    /* Filtros: selects full-width dentro do form */
    .filtros-linha {
        width: 100%;
    }
    .filtros-linha .filtro-campo {
        flex: 1;
        min-width: 110px;
    }
    .filtros-linha .filtro-select {
        width: 100%;
    }

    /* Dispositivos: div da busca rápida estende full-width */
    .busca-rapida-group {
        width: 100%;
    }
    .busca-rapida-field {
        flex: 1;
        min-width: 0;
    }

    /* Avatar: ligeiramente menor para economizar espaço */
    .client-avatar {
        width: 28px;
        height: 28px;
        min-width: 28px;
        font-size: 0.75rem;
    }

    /* Célula de nome: sem gap excessivo */
    .client-name-cell {
        gap: 6px;
    }

    /* Células: permite quebra de conteúdo longo (ex.: IMEI, números) */
    .data-table td {
        overflow-wrap: anywhere;
    }

    /* IMEI e texto mono: permite quebra */
    .font-mono,
    .device-uid {
        word-break: break-all;
        white-space: normal;
    }

    /* Dashboard — tabelas de Projeção e Faturamento anual: remove o piso de
       largura (o overflow-x:auto do wrapper já resolve o resto se precisar)
       e empilha o delta abaixo do valor principal, encurtando cada coluna */
    #tabela-projecao,
    #tabela-faturamento-anual {
        min-width: 0 !important;
    }
    #tabela-projecao th,
    #tabela-faturamento-anual th {
        padding: 4px 5px !important;
        font-size: 0.68rem !important;
    }
    #tabela-projecao td,
    #tabela-faturamento-anual td {
        padding: 5px !important;
        font-size: 0.72rem !important;
    }
    .dash-proj-delta {
        display: block;
        margin-top: 2px;
    }
}

/* ---- Telas muito pequenas (≤ 540px) ---- */
@media (max-width: 540px) {


    /* Avatar: some para ganhar espaço no nome */
    .client-avatar {
        display: none;
    }

    /* Ações: compacta gap para caber mais botões */
    .actions-cell {
        gap: 3px;
        justify-content: center;
    }

    /* Paginação: botões menores */
    .pagination-btn {
        min-width: 28px;
        height: 28px;
        font-size: 0.78rem;
    }

    /* Valor formatado: sem espaço extra */
    .data-table td.text-right {
        padding-left: 4px;
        padding-right: 4px;
    }

    /* Abas: scroll horizontal para não quebrar layout */
    .tab-bar {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    .tab-bar::-webkit-scrollbar { display: none; }
    .tab-item {
        white-space: nowrap;
        padding: 0.5rem 0.75rem;
        font-size: 0.82rem;
    }
}

/* ============================================================================
   Loading overlay global
   ============================================================================ */
#global-loading {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, .48);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 16px;
}
#global-loading.active {
    display: flex;
}
#global-loading .gl-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255,255,255,.25);
    border-top-color: #fff;
    border-radius: 50%;
    animation: gl-spin .75s linear infinite;
}
#global-loading .gl-label {
    color: #fff;
    font-size: .92rem;
    font-weight: 500;
    letter-spacing: .02em;
    text-shadow: 0 1px 4px rgba(0,0,0,.4);
}
@keyframes gl-spin {
    to { transform: rotate(360deg); }
}

.form-input::placeholder,
.input-moeda::placeholder {
    color: #c4c9d4;
    opacity: 1;
}

/* ── Pagamento parcial: destino do saldo ──────────────────────────────────── */
.destino-opcoes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}
.destino-opt {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1.5px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color .15s, background .15s;
}
.destino-opt:has(input:checked) {
    border-color: #3b82f6;
    background: #eff6ff;
}
.destino-opt input[type=radio] {
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: #3b82f6;
}
.destino-titulo {
    display: block;
    font-size: .88rem;
    font-weight: 600;
    color: #1e293b;
}
.destino-desc {
    display: block;
    font-size: .78rem;
    color: #64748b;
    margin-top: 2px;
}
.parcial-saldo-preview {
    padding: 8px 12px;
    background: #f8fafc;
    border-left: 3px solid #3b82f6;
    border-radius: 4px;
    font-size: .87rem;
    color: #475569;
}

/* =========================================================
   SIDEBAR — BADGES E FERRAMENTAS COLAPSÁVEIS
   ========================================================= */

.sidebar-badge {
    margin-left: auto;
    padding: 1px 7px;
    border-radius: 999px;
    font-size: 0.68rem;
    font-weight: 700;
    background: #dc2626;
    color: #fff;
    min-width: 18px;
    text-align: center;
    line-height: 1.6;
}

.sidebar-badge--warning {
    background: #d97706;
}

.sidebar-link.active .sidebar-badge {
    background: rgba(0,0,0,.25);
    color: #fff;
}

/* Botão de toggle do grupo Ferramentas */
.sidebar-tools-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: 999px;
    border: none;
    background: transparent;
    color: var(--sidebar-text);
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    text-align: left;
    transition: background-color var(--transition-fast);
}

.sidebar-tools-toggle:hover {
    background: rgba(31, 41, 55, 0.85);
}

.sidebar-tools-toggle.open {
    background: rgba(31, 41, 55, 0.5);
    color: #e5e7eb;
}

.sidebar-tools-arrow {
    margin-left: auto;
    font-size: 0.6rem;
    opacity: 0.6;
    transition: transform 0.2s ease;
}

.sidebar-tools-toggle.open .sidebar-tools-arrow {
    transform: rotate(180deg);
}

/* Grupo colapsável */
.sidebar-tools-group {
    display: none;
    overflow: hidden;
}

.sidebar-tools-group.open {
    display: block;
}

/* Sub-links levemente indentados */
.sidebar-link--sub {
    padding-left: 22px;
    font-size: 0.82rem;
}

/* =========================================================
   DASHBOARD — CLASSES UTILITÁRIAS (extraídas de inline styles)
   ========================================================= */

/* Linha de filtro de período */
.dash-periodo-btns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 18px;
}

.dash-periodo-btn {
    padding: 6px 12px;
    border-radius: 999px;
    text-decoration: none;
    font-size: 0.82rem;
    font-weight: 600;
    transition: 0.2s;
    background: #eef2ff;
    color: #1d4ed8;
}

.dash-periodo-btn.active {
    background: #1d4ed8;
    color: #fff;
}

/* Pill de valor (recebimento/caixa) */
.dash-pill {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

.dash-pill--blue {
    background: rgba(59, 130, 246, 0.09);
    color: #1d4ed8;
}

.dash-pill--green {
    background: rgba(16, 185, 129, 0.12);
    color: #047857;
    font-size: 0.9rem;
    font-weight: 700;
}

.dash-pill--receipt {
    display: inline-block;
    margin-top: 6px;
    padding: 6px 14px;
    border-radius: 999px;
    background: #e5edff;
    font-size: 0.80rem;
    font-weight: 600;
    color: #1d4ed8;
}

/* Textos auxiliares do dashboard */
.dash-sub-label {
    font-size: 0.8rem;
    color: #6b7280;
}

.dash-sub-value {
    margin-top: 2px;
}

.dash-note {
    font-size: 0.78rem;
    color: #9ca3af;
}

.dash-note strong {
    color: #374151;
}

.dash-note-block {
    font-size: 0.80rem;
    color: #4b5563;
    margin-bottom: 4px;
}

/* Seta de comparação mensal */
.dash-trend-up   { font-size: 0.85rem; margin-left: 6px; color: #16a34a; }
.dash-trend-down { font-size: 0.85rem; margin-left: 6px; color: #dc2626; }

/* Tabela histórica dentro de card */
.dash-hist-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.76rem;
    color: #374151;
    margin-top: 10px;
    overflow-x: auto;
    display: block;
}

.dash-hist-table th {
    text-align: left;
    padding: 4px 6px;
    color: #9ca3af;
    font-weight: 600;
    border-bottom: 1px solid #e5e7eb;
}

.dash-hist-table th.right,
.dash-hist-table td.right { text-align: right; }

.dash-hist-table th.accent { color: #6366f1; }

.dash-hist-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #f3f4f6;
}

.dash-hist-table td.bold { font-weight: 600; }
.dash-hist-table td.accent { color: #6366f1; font-weight: 600; }

/* Items de lista de pendências */
.pend-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 5px 0;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.78rem;
}

.pend-nome {
    font-weight: 600;
    color: #111827;
}

.pend-meta {
    color: #9ca3af;
}

.pend-valor {
    text-align: right;
}

.pend-valor--warn  { font-weight: 700; color: #d97706; }
.pend-valor--danger { font-weight: 700; color: #dc2626; }

/* Tabela de clientes em risco */
.risk-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;
    color: #374151;
}

.risk-table th {
    text-align: left;
    padding: 6px 8px;
    color: #6b7280;
    font-weight: 600;
    border-bottom: 2px solid #e5e7eb;
}

.risk-table th.right,
.risk-table td.right { text-align: right; }
.risk-table th.center,
.risk-table td.center { text-align: center; }

.risk-table td {
    padding: 7px 8px;
    border-bottom: 1px solid #f3f4f6;
}

.risk-table .risk-nome { font-weight: 600; color: #111827; }
.risk-table .risk-email { font-size: 0.75rem; color: #9ca3af; }
.risk-table .risk-valor { font-weight: 700; color: #dc2626; }

/* Badges de status (NF, etc.) */
.status-pill {
    border-radius: 999px;
    padding: 2px 8px;
    font-size: 0.70rem;
    font-weight: 600;
    display: inline-block;
}

.status-pill--error   { background: #fee2e2; color: #dc2626; }
.status-pill--warning { background: #fef3c7; color: #d97706; }
.status-pill--success { background: #ecfdf5; color: #047857; }
.status-pill--info    { background: #eff6ff; color: #1d4ed8; }

/* ── Traccar live stats bar (dashboard header) ────────────────────────── */
.traccar-live-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 8px 14px;
}
.traccar-live-pulse {
    width: 8px;
    height: 8px;
    min-width: 8px;
    border-radius: 50%;
    background: #22c55e;
    animation: traccar-pulse 2.2s ease-in-out infinite;
}
@keyframes traccar-pulse {
    0%, 100% { opacity: 1;   transform: scale(1);    box-shadow: 0 0 0 0 rgba(34,197,94,.5); }
    50%       { opacity: .55; transform: scale(.85);  box-shadow: 0 0 0 4px rgba(34,197,94,0); }
}
.traccar-live-items {
    display: flex;
    align-items: center;
    gap: 14px;
}
.traccar-stat {
    display: flex;
    align-items: center;
    gap: 5px;
    cursor: default;
}
.traccar-stat-dot {
    font-size: 0.6rem;
    line-height: 1;
}
.traccar-stat-inner {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}
.traccar-stat-num {
    font-size: 0.82rem;
    font-weight: 700;
    color: #1e293b;
    transition: color .3s;
}
.traccar-stat-lbl {
    font-size: 0.62rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.traccar-stat--total   .traccar-stat-dot { color: #9ca3af; }
.traccar-stat--online  .traccar-stat-dot { color: #22c55e; }
.traccar-stat--offline .traccar-stat-dot { color: #ef4444; }
.traccar-stat--unknown .traccar-stat-dot { color: #f59e0b; }
.traccar-stat--moving  .traccar-stat-dot { color: #1e293b; }
.traccar-stat--online  .traccar-stat-num { color: #15803d; }
.traccar-stat--offline .traccar-stat-num { color: #dc2626; }
.traccar-stat--unknown .traccar-stat-num { color: #b45309; }
.traccar-stat--moving  .traccar-stat-num { color: #1e293b; }
.traccar-live-age {
    font-size: 0.68rem;
    color: #cbd5e1;
    white-space: nowrap;
    padding-left: 4px;
    border-left: 1px solid #e2e8f0;
}
/* Atenção: online < 60% do total */
.traccar-live-bar--atencao {
    border-color: #f59e0b;
    background: #fffbeb;
}
.traccar-live-bar--atencao .traccar-live-pulse {
    background: #f59e0b;
}
.traccar-live-bar--atencao .traccar-stat--online .traccar-stat-num {
    animation: traccar-num-pulse 1.6s ease-in-out infinite;
}
/* Crítico: online < 45% do total */
.traccar-live-bar--critico {
    border-color: #ef4444;
    background: #fef2f2;
}
.traccar-live-bar--critico .traccar-live-pulse {
    background: #ef4444;
}
.traccar-live-bar--critico .traccar-stat--online .traccar-stat-num {
    animation: traccar-num-pulse 1s ease-in-out infinite;
    color: #dc2626 !important;
}
@keyframes traccar-num-pulse {
    0%, 100% { opacity: 1; }
    50%       { opacity: .35; }
}
/* Erro de conexão */
.traccar-live-bar--error .traccar-live-pulse { background: #ef4444; animation: none; }
.traccar-live-bar--error .traccar-stat-num   { color: #9ca3af; }
/* Responsivo tablet: compacta gaps e esconde labels de texto */
@media (max-width: 860px) {
    .topbar-center .traccar-live-bar { padding: 6px 10px; gap: 8px; }
    .topbar-center .traccar-live-items { gap: 10px; }
    .topbar-center .traccar-stat-lbl { display: none; }
}
/* Responsivo mobile: widget quebra para segunda linha abaixo do topbar */
@media (max-width: 640px) {
    .app-topbar {
        flex-wrap: wrap;
        padding-bottom: 0;
    }
    .topbar-center {
        order: 3;
        flex-basis: calc(100% + 32px);
        margin: 0 -16px;
        justify-content: flex-start;
        padding: 4px 16px 6px 52px;
        border-bottom: 1px solid var(--border-soft);
    }
    .topbar-center .traccar-live-bar {
        padding: 0;
        gap: 8px;
        background: transparent;
        border: none;
        border-radius: 0;
        box-shadow: none;
    }
    .topbar-center .traccar-live-items { gap: 12px; }
    .topbar-center .traccar-stat--moving { display: none; }
    .topbar-center .traccar-live-age { display: none; }
}

/* ── Card Contratos ativos: coluna de faturamento anual ─────────────────── */
.contratos-layout {
    display: flex;
    flex-wrap: wrap;
    gap: 14px 28px;
    height: 100%;
}
.contratos-col {
    flex: 0 1 220px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-width: 0;
}
.fat-anual {
    flex: 1 1 300px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding-left: 22px;
    border-left: 1px solid var(--border-soft, #e5e7eb);
}
.fat-anual-hdr { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 2px; }
.fat-anual-hint { font-size: 0.72rem; color: #9ca3af; cursor: help; }
.fat-anual-row {
    display: grid;
    grid-template-columns: 62px minmax(40px, 1fr) auto 64px;
    align-items: center;
    gap: 10px;
    font-size: 0.82rem;
}
.fat-anual-ano { font-weight: 700; color: #374151; line-height: 1.1; }
.fat-anual-ano small { display: block; font-size: 0.66rem; font-weight: 500; color: #9ca3af; }
.fat-anual-bar { height: 8px; background: #f1f5f9; border-radius: 999px; overflow: hidden; }
.fat-anual-bar span { display: block; height: 100%; background: #93c5fd; border-radius: 999px; }
.fat-anual-row--atual .fat-anual-bar span { background: #10b981; }
.fat-anual-val { font-weight: 700; color: #111827; white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.fat-anual-var { font-size: 0.74rem; font-weight: 600; color: #9ca3af; text-align: right; white-space: nowrap; cursor: help; }
.fat-anual-var.up   { color: #047857; }
.fat-anual-var.down { color: #b91c1c; }
.fat-anual-mais {
    align-self: flex-start;
    margin-top: 2px;
    padding: 3px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    color: #1d4ed8;
    background: rgba(59, 130, 246, 0.09);
    border: 0;
    border-radius: 999px;
    cursor: pointer;
}
.fat-anual-mais:hover:not(:disabled) { background: rgba(59, 130, 246, 0.18); }
.fat-anual-mais:disabled { color: #9ca3af; background: #f3f4f6; cursor: not-allowed; }
@media (max-width: 640px) {
    .fat-anual { padding-left: 0; border-left: 0; border-top: 1px solid var(--border-soft, #e5e7eb); padding-top: 12px; }
    .fat-anual-row { grid-template-columns: 52px minmax(30px, 1fr) auto 56px; gap: 8px; }
}

/* Badge da fila WA (menu Notificações) — atualizado via polling em sidebar.php */
.sidebar-badge--info { background: #2563eb; }
.sidebar-badge--pausada { background: #64748b; }
.sidebar-badge--enviando { animation: sidebarBadgePulse 1.6s ease-in-out infinite; }
@keyframes sidebarBadgePulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(37, 99, 235, .55); }
    50%      { box-shadow: 0 0 0 5px rgba(37, 99, 235, 0); }
}
@media (prefers-reduced-motion: reduce) {
    .sidebar-badge--enviando { animation: none; }
}
