/* ============================================================
   GESTÃO DE ROTAS — DESIGN SYSTEM v2
   Paleta: azul-atlântico + laranja pôr-do-sol (Bahia)
   Tipografia: Space Grotesk (display/números) + Inter (UI)
   ============================================================ */

:root {
    /* ----- Cores base ----- */
    --navy-950: #070E24;
    --navy-900: #0A1330;
    --navy-800: #0E1D46;
    --navy-700: #16346F;
    --navy-600: #1E4293;
    --blue-600: #2E5BD7;
    --blue-500: #3B82F6;
    --cyan-400: #38BDF8;
    --cyan-500: #0EA5E9;

    --laranja-500: #FF8A1E;
    --laranja-600: #F97316;
    --laranja-soft: #FFF1E2;

    --green-500: #10B981;
    --green-600: #059669;
    --green-soft: #E5F8F1;

    --red-500: #F43F5E;
    --red-600: #E11D48;
    --red-soft: #FEEBEF;

    --amber-500: #F59E0B;
    --amber-soft: #FEF3DC;

    --violet-500: #8B5CF6;
    --violet-soft: #F1EBFE;

    /* ----- Superfícies ----- */
    --bg-app: #F2F4FB;
    --surface: #FFFFFF;
    --surface-muted: #F7F9FE;
    --border: #E4E9F4;
    --border-strong: #D3DAEB;

    --text-strong: #101731;
    --text-body: #33405E;
    --text-muted: #5A6684;
    --text-faint: #8B95AF;

    /* ----- Gradientes ----- */
    --grad-navy: linear-gradient(150deg, #0A1330 0%, #0E1D46 45%, #1B3E8F 100%);
    --grad-blue: linear-gradient(135deg, #2E5BD7 0%, #38BDF8 100%);
    --grad-laranja: linear-gradient(135deg, #F97316 0%, #FFB01F 100%);
    --grad-green: linear-gradient(135deg, #059669 0%, #34D399 100%);
    --grad-red: linear-gradient(135deg, #E11D48 0%, #FB7185 100%);

    /* ----- Elevação ----- */
    --shadow-xs: 0 1px 2px rgba(16, 23, 49, .05);
    --shadow-sm: 0 2px 8px rgba(16, 23, 49, .06), 0 1px 2px rgba(16, 23, 49, .04);
    --shadow-md: 0 8px 24px rgba(16, 23, 49, .09);
    --shadow-lg: 0 18px 44px rgba(14, 29, 70, .16);
    --shadow-orange: 0 8px 22px rgba(249, 115, 22, .32);
    --shadow-blue: 0 8px 22px rgba(46, 91, 215, .30);

    /* ----- Forma / densidade (dashboard: escala compacta) ----- */
    --r-sm: 10px;
    --r-md: 14px;
    --r-lg: 18px;
    --r-xl: 24px;
    --sp-1: 4px; --sp-2: 8px; --sp-3: 12px; --sp-4: 16px;
    --sp-5: 20px; --sp-6: 24px; --sp-8: 32px;

    --sidebar-w: 264px;
    --sidebar-w-min: 78px;
    --topbar-h: 64px;

    --font-display: 'Space Grotesk', 'Inter', sans-serif;
    --font-ui: 'Inter', 'Segoe UI', system-ui, sans-serif;

    --t-fast: .16s ease;
    --t-med: .28s cubic-bezier(.4, 0, .2, 1);

    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================================
   BASE
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-ui);
    background: var(--bg-app);
    color: var(--text-strong);
    font-size: 15px;
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    padding-top: var(--safe-top);
}

::selection { background: var(--laranja-500); color: #fff; }

:focus-visible {
    outline: 2px solid var(--blue-500);
    outline-offset: 2px;
    border-radius: 4px;
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #C7D0E4; border-radius: 8px; border: 2px solid var(--bg-app); }
::-webkit-scrollbar-thumb:hover { background: #A9B6D4; }

h1, h2, h3, h4, h5, h6 { font-family: var(--font-display); letter-spacing: -.01em; }

.num, .kpi-value, .clock, .route-timer, .days-counter, .saldo-val {
    font-family: var(--font-display);
    font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
    }
}

/* ============================================================
   BANNER OFFLINE
   ============================================================ */
.offline-banner {
    display: none;
    background: var(--grad-red);
    color: #fff;
    padding: 8px 16px;
    text-align: center;
    font-weight: 600;
    font-size: .82rem;
    position: sticky;
    top: 0;
    z-index: 1200;
}
.offline-banner.show { display: block; }

.offline-badge {
    display: none;
    align-items: center;
    gap: 5px;
    background: rgba(244, 63, 94, .14);
    color: var(--red-500);
    border: 1px solid rgba(244, 63, 94, .35);
    font-size: .68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.offline-badge.show { display: inline-flex; }

/* ============================================================
   LOGIN
   ============================================================ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--sp-5);
    background: var(--grad-navy);
    position: relative;
    overflow: hidden;
}
.login-page::before {
    content: '';
    position: absolute;
    inset: 0;
    background:
        radial-gradient(ellipse 60% 45% at 85% 10%, rgba(56, 189, 248, .18), transparent 60%),
        radial-gradient(ellipse 55% 40% at 8% 92%, rgba(249, 115, 22, .16), transparent 60%);
    pointer-events: none;
}

.login-card {
    position: relative;
    width: 100%;
    max-width: 880px;
    display: grid;
    grid-template-columns: 1.05fr 1fr;
    background: var(--surface);
    border-radius: var(--r-xl);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: loginIn .5s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes loginIn {
    from { opacity: 0; transform: translateY(18px) scale(.98); }
    to { opacity: 1; transform: none; }
}

.login-brand {
    background: var(--grad-navy);
    color: #fff;
    padding: 44px 40px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}
.login-brand .route-svg {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: .5;
    pointer-events: none;
}
.login-brand-logo {
    position: relative;
    display: flex;
    align-items: center;
    gap: 12px;
}
.login-brand-logo .mark {
    width: 46px; height: 46px;
    border-radius: 14px;
    background: var(--grad-laranja);
    display: grid;
    place-items: center;
    font-size: 20px;
    color: #fff;
    box-shadow: var(--shadow-orange);
}
.login-brand-logo h1 {
    font-size: 1.3rem;
    font-weight: 700;
    margin: 0;
}
.login-brand-logo small { color: rgba(255,255,255,.55); font-size: .74rem; letter-spacing: .12em; text-transform: uppercase; }

.login-brand-feats { position: relative; display: grid; gap: 14px; margin-top: 40px; }
.login-feat { display: flex; gap: 12px; align-items: flex-start; }
.login-feat i {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 10px;
    display: grid; place-items: center;
    background: rgba(255,255,255,.08);
    border: 1px solid rgba(255,255,255,.12);
    color: var(--cyan-400);
    font-size: .85rem;
}
.login-feat strong { display: block; font-size: .88rem; font-weight: 600; }
.login-feat span { font-size: .76rem; color: rgba(255,255,255,.55); }

.login-form-side { padding: 44px 40px; display: flex; flex-direction: column; justify-content: center; }
.login-form-side h2 { font-size: 1.45rem; margin-bottom: 4px; }
.login-form-side .sub { color: var(--text-muted); font-size: .86rem; margin-bottom: 26px; }

.login-form-side .form-label { font-weight: 600; font-size: .82rem; color: var(--text-body); }
.login-demo {
    margin-top: 18px;
    background: var(--surface-muted);
    border: 1px dashed var(--border-strong);
    border-radius: var(--r-md);
    padding: 10px 14px;
    font-size: .78rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}
.login-demo code {
    background: #fff;
    border: 1px solid var(--border);
    padding: 2px 8px;
    border-radius: 6px;
    color: var(--navy-700);
    font-weight: 600;
}

.login-tabs {
    display: flex;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 4px;
    gap: 4px;
    margin-bottom: 18px;
}
.lt-btn {
    flex: 1;
    border: none;
    background: transparent;
    border-radius: 10px;
    padding: 9px 10px;
    font-size: .84rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    transition: var(--t-fast);
}
.lt-btn:hover { color: var(--text-strong); }
.lt-btn.active { background: var(--navy-800); color: #fff; box-shadow: var(--shadow-sm); }

.sv-aviso {
    display: flex;
    align-items: flex-start;
    gap: 9px;
    background: var(--amber-soft);
    border: 1px solid #F5D9A8;
    color: #7A4E08;
    border-radius: var(--r-md);
    padding: 9px 12px;
    font-size: .72rem;
    margin-bottom: 14px;
    line-height: 1.45;
}
.sv-aviso i { margin-top: 2px; }
.sv-aviso code { background: #fff; border: 1px solid #F5D9A8; border-radius: 5px; padding: 1px 5px; font-size: .68rem; }

.user-chip {
    background: var(--navy-800) !important;
    color: #fff !important;
    border-color: var(--navy-800) !important;
    font-weight: 700;
}
.user-chip i { color: var(--laranja-500); }

@media (max-width: 820px) {
    .login-card { grid-template-columns: 1fr; max-width: 460px; }
    .login-brand { padding: 28px; }
    .login-brand-feats { display: none; }
    .login-form-side { padding: 30px 26px; }
}

/* ============================================================
   SIDEBAR
   ============================================================ */
.sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--grad-navy);
    color: #E7ECF8;
    z-index: 1100;
    display: flex;
    flex-direction: column;
    transition: width var(--t-med), transform var(--t-med);
    padding-top: var(--safe-top);
}
.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 1px;
    background: linear-gradient(180deg, transparent, rgba(56,189,248,.25), transparent);
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 18px 18px 14px;
}
.sidebar .brand .mark {
    width: 40px; height: 40px; flex: 0 0 40px;
    border-radius: 12px;
    background: var(--grad-laranja);
    display: grid; place-items: center;
    color: #fff;
    font-size: 17px;
    box-shadow: var(--shadow-orange);
}
.sidebar .brand-txt { min-width: 0; }
.sidebar .brand-txt h3 {
    font-size: 1.02rem;
    font-weight: 700;
    margin: 0;
    color: #fff;
    white-space: nowrap;
}
.sidebar .brand-txt small {
    display: block;
    font-size: .66rem;
    letter-spacing: .14em;
    text-transform: uppercase;
    color: rgba(231, 236, 248, .45);
    white-space: nowrap;
}

.sidebar .toggle-btn {
    position: absolute;
    top: 24px;
    right: -13px;
    width: 26px; height: 26px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--navy-700);
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: .68rem;
    box-shadow: var(--shadow-sm);
    z-index: 5;
    transition: var(--t-fast);
}
.sidebar .toggle-btn:hover { background: var(--laranja-500); color: #fff; border-color: var(--laranja-500); }

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 4px 12px 18px;
    list-style: none;
    margin: 0;
}
.sidebar-nav::-webkit-scrollbar { width: 5px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.14); border: none; }

.nav-sec {
    font-size: .62rem;
    font-weight: 700;
    letter-spacing: .16em;
    text-transform: uppercase;
    color: rgba(231,236,248,.38);
    padding: 16px 10px 6px;
    white-space: nowrap;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 10px;
    margin: 2px 0;
    border-radius: var(--r-md);
    color: rgba(231,236,248,.78);
    font-size: .88rem;
    font-weight: 500;
    text-decoration: none;
    position: relative;
    transition: background var(--t-fast), color var(--t-fast);
    white-space: nowrap;
}
.sidebar .nav-link i {
    width: 30px; height: 30px; flex: 0 0 30px;
    display: grid; place-items: center;
    border-radius: 9px;
    background: rgba(255,255,255,.06);
    font-size: .8rem;
    transition: var(--t-fast);
}
.sidebar .nav-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar .nav-link:hover i { background: rgba(56,189,248,.18); color: var(--cyan-400); }

.sidebar .nav-link.active {
    background: linear-gradient(90deg, rgba(249,115,22,.18), rgba(46,91,215,.22));
    color: #fff;
}
.sidebar .nav-link.active::before {
    content: '';
    position: absolute;
    left: -12px; top: 20%;
    height: 60%; width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--grad-laranja);
    box-shadow: 0 0 12px rgba(249,115,22,.7);
}
.sidebar .nav-link.active i { background: var(--grad-laranja); color: #fff; }

.sidebar .nav-link .badge {
    margin-left: auto;
    font-size: .64rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 999px;
}
.sidebar .nav-link.danger { color: #FDA4AF; }
.sidebar .nav-link.danger:hover { background: rgba(244,63,94,.14); color: #FECDD3; }
.sidebar .nav-link.danger i { background: rgba(244,63,94,.14); }

.sidebar-foot {
    padding: 12px 16px calc(14px + var(--safe-bottom));
    border-top: 1px solid rgba(255,255,255,.07);
    font-size: .7rem;
    color: rgba(231,236,248,.4);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

/* --- Sidebar recolhida --- */
.sidebar.collapsed { width: var(--sidebar-w-min); }
.sidebar.collapsed .brand-txt,
.sidebar.collapsed .nav-sec,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .nav-link .badge,
.sidebar.collapsed .sidebar-foot span { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 9px 6px; }
.sidebar.collapsed .brand { justify-content: center; padding-left: 8px; padding-right: 8px; }
.sidebar.collapsed .sidebar-foot { justify-content: center; }

/* --- Overlay / mobile --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(7, 14, 36, .55);
    backdrop-filter: blur(3px);
    z-index: 1050;
    opacity: 0;
    transition: opacity var(--t-med);
}
.sidebar-overlay.active { display: block; opacity: 1; }

.mobile-menu-btn {
    display: none;
    width: 42px; height: 42px;
    border-radius: var(--r-md);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--navy-800);
    font-size: 1rem;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
    flex: 0 0 42px;
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .sidebar { transform: translateX(-105%); width: var(--sidebar-w); }
    .sidebar.mobile-open { transform: none; box-shadow: var(--shadow-lg); }
    .sidebar .toggle-btn { display: none; }
    .mobile-menu-btn { display: inline-flex; }
}

/* ============================================================
   ÁREA PRINCIPAL / TOPBAR
   ============================================================ */
.main-content {
    margin-left: var(--sidebar-w);
    min-height: 100vh;
    transition: margin-left var(--t-med);
    padding: 0 clamp(14px, 2.6vw, 30px) 90px;
}
.main-content.expanded { margin-left: var(--sidebar-w-min); }
@media (max-width: 768px) {
    .main-content, .main-content.expanded { margin-left: 0; }
}

.topbar {
    position: sticky;
    top: 0;
    z-index: 900;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    padding: 12px 0;
    margin: 0 0 var(--sp-5);
    background: linear-gradient(var(--bg-app) 82%, rgba(242,244,251,0));
}

.topbar-title { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title h2 {
    font-size: 1.22rem;
    font-weight: 700;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.topbar-title .crumb {
    font-size: .7rem;
    color: var(--text-faint);
    letter-spacing: .1em;
    text-transform: uppercase;
    display: block;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.clock-chip {
    background: var(--navy-800);
    color: #fff;
    border-radius: var(--r-md);
    padding: 6px 14px;
    text-align: right;
    line-height: 1.15;
    box-shadow: var(--shadow-sm);
}
.clock-chip .clock { font-size: 1.02rem; font-weight: 700; letter-spacing: .02em; }
.clock-chip .date { font-size: .62rem; color: rgba(255,255,255,.6); display: block; }
.clock-chip .uptime-line { font-size: .58rem; color: rgba(255,255,255,.45); display: block; }

.status-strip {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .7rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    white-space: nowrap;
}
.chip i { font-size: .68rem; }
.chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--text-faint); }

.connection-status { composes: none; }
.connection-status,
.bot-status,
.ws-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: .7rem;
    font-weight: 600;
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    white-space: nowrap;
}
.connection-status .dot, .ws-status .dot { width: 7px; height: 7px; border-radius: 50%; }
.connection-status.online { color: var(--green-600); border-color: rgba(16,185,129,.35); background: var(--green-soft); }
.connection-status.online .dot { background: var(--green-500); box-shadow: 0 0 0 3px rgba(16,185,129,.18); animation: pulseDot 2s infinite; }
.connection-status.offline { color: var(--red-600); border-color: rgba(244,63,94,.35); background: var(--red-soft); }
.connection-status.offline .dot { background: var(--red-500); }
.bot-status.online { color: var(--cyan-500); border-color: rgba(14,165,233,.3); background: #EAF7FE; }
.bot-status.offline { color: var(--red-600); background: var(--red-soft); }
.ws-status.connected { color: var(--green-600); }
.ws-status.connected .dot { background: var(--green-500); }

@keyframes pulseDot {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,.35); }
    50% { box-shadow: 0 0 0 5px rgba(16,185,129,0); }
}

.icon-btn {
    width: 36px; height: 36px;
    display: inline-grid;
    place-items: center;
    border-radius: var(--r-sm);
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-muted);
    cursor: pointer;
    font-size: .8rem;
    transition: var(--t-fast);
}
.icon-btn:hover { color: var(--blue-600); border-color: var(--blue-500); background: #EFF5FF; transform: translateY(-1px); }
.icon-btn.telegram:hover { color: #229ED9; border-color: #229ED9; background: #E8F6FC; }
.icon-btn.warn:hover { color: var(--laranja-600); border-color: var(--laranja-500); background: var(--laranja-soft); }

/* ============================================================
   PÁGINAS / CABEÇALHOS DE SEÇÃO
   ============================================================ */
.page-content { animation: none; }
.fade-in { animation: pageIn .35s cubic-bezier(.22, 1, .36, 1) both; }
@keyframes pageIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: none; }
}

.page-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: var(--sp-4);
}
.page-head h2 {
    font-size: 1.14rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}
.page-head h2 .ph-ico {
    width: 36px; height: 36px;
    border-radius: 11px;
    display: inline-grid;
    place-items: center;
    font-size: .88rem;
    color: #fff;
    background: var(--grad-blue);
    box-shadow: var(--shadow-blue);
}
.page-head h2 .ph-ico.orange { background: var(--grad-laranja); box-shadow: var(--shadow-orange); }
.page-head h2 .ph-ico.green { background: var(--grad-green); box-shadow: 0 8px 22px rgba(5,150,105,.3); }
.page-head .actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

.count-chip {
    font-family: var(--font-display);
    font-size: .78rem;
    font-weight: 700;
    color: var(--navy-700);
    background: #E8EEFC;
    border: 1px solid #D3DFF8;
    padding: 4px 12px;
    border-radius: 999px;
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--t-fast);
}
.card:hover { box-shadow: var(--shadow-sm); }
.card .card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 13px 18px;
    border-radius: var(--r-lg) var(--r-lg) 0 0 !important;
}
.card .card-header h5, .card .card-header h6 {
    font-size: .92rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}
.card .card-body { padding: 16px 18px; }

/* ============================================================
   BOTÕES (override Bootstrap)
   ============================================================ */
.btn {
    border-radius: var(--r-sm);
    font-weight: 600;
    font-size: .82rem;
    padding: 7px 14px;
    border: 1px solid transparent;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast), filter var(--t-fast);
}
.btn:active { transform: scale(.97); }
.btn:focus { box-shadow: 0 0 0 3px rgba(46,91,215,.25); }
.btn-sm { font-size: .76rem; padding: 5px 11px; }

.btn-primary { background: var(--grad-blue); border: none; box-shadow: var(--shadow-blue); }
.btn-primary:hover { background: var(--grad-blue); filter: brightness(1.08); transform: translateY(-1px); }
.btn-accent { background: var(--grad-laranja); border: none; color: #fff; box-shadow: var(--shadow-orange); }
.btn-accent:hover { color: #fff; filter: brightness(1.06); transform: translateY(-1px); }
.btn-success { background: var(--grad-green); border: none; }
.btn-success:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-danger { background: var(--grad-red); border: none; }
.btn-danger:hover { filter: brightness(1.06); }
.btn-warning { background: linear-gradient(135deg, #F59E0B, #FBBF24); border: none; color: #3D2800; }
.btn-warning:hover { color: #3D2800; filter: brightness(1.05); }
.btn-info { background: linear-gradient(135deg, #0EA5E9, #38BDF8); border: none; color: #fff; }
.btn-info:hover { color: #fff; filter: brightness(1.07); }
.btn-secondary { background: #E8ECF6; border: none; color: var(--text-body); }
.btn-secondary:hover { background: #DDE3F2; color: var(--text-strong); }
.btn-outline-primary { border-color: var(--blue-500); color: var(--blue-600); }
.btn-outline-primary:hover { background: var(--blue-600); border-color: var(--blue-600); }
.btn-outline-secondary { border-color: var(--border-strong); color: var(--text-muted); }
.btn-outline-secondary:hover { background: #EDF1FA; color: var(--text-strong); border-color: var(--border-strong); }

.btn-whatsapp {
    background: linear-gradient(135deg, #1FAF55, #33D673);
    color: #fff; border: none;
}
.btn-whatsapp:hover { color: #fff; filter: brightness(1.06); }
.btn-whatsapp-sm { font-size: .74rem; padding: 4px 10px; border-radius: 8px; }

.btn-action {
    width: 30px; height: 30px;
    padding: 0;
    display: inline-grid;
    place-items: center;
    border-radius: 9px;
    font-size: .72rem;
}

/* ============================================================
   DASHBOARD — HERO
   ============================================================ */
.dash-hero {
    position: relative;
    border-radius: var(--r-xl);
    background: var(--grad-navy);
    color: #fff;
    padding: clamp(20px, 3vw, 30px) clamp(20px, 3.4vw, 34px);
    margin-bottom: var(--sp-5);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}
.dash-hero .route-svg {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    opacity: .55;
}
.dash-hero::after {
    content: '';
    position: absolute;
    right: -80px; top: -110px;
    width: 320px; height: 320px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(56,189,248,.25), transparent 65%);
    pointer-events: none;
}
.hero-left { position: relative; min-width: 240px; }
.hero-eyebrow {
    font-size: .64rem;
    font-weight: 700;
    letter-spacing: .2em;
    text-transform: uppercase;
    color: var(--laranja-500);
    display: flex;
    align-items: center;
    gap: 8px;
}
.hero-eyebrow::before {
    content: '';
    width: 22px; height: 2px;
    background: var(--grad-laranja);
    border-radius: 2px;
}
.hero-left h1 {
    font-size: clamp(1.4rem, 2.6vw, 1.9rem);
    font-weight: 700;
    margin: 6px 0 2px;
}
.hero-left .hero-sub { color: rgba(255,255,255,.62); font-size: .84rem; }

.hero-right {
    position: relative;
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}
.hero-pill {
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.14);
    backdrop-filter: blur(6px);
    border-radius: var(--r-md);
    padding: 10px 16px;
    min-width: 128px;
}
.hero-pill .hp-label { font-size: .64rem; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .08em; }
.hero-pill .hp-value { font-family: var(--font-display); font-size: 1.18rem; font-weight: 700; line-height: 1.25; }
.hero-pill .hp-value.orange { color: #FFB86B; }
.hero-pill .hp-value.green { color: #5EEAB4; }

.hero-actions { position: relative; display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }

/* ============================================================
   KPI CARDS
   ============================================================ */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(158px, 1fr));
    gap: 12px;
    margin-bottom: var(--sp-5);
}
.kpi-card {
    position: relative;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 14px 16px 18px;
    overflow: hidden;
    transition: transform var(--t-fast), box-shadow var(--t-fast);
    cursor: default;
}
.kpi-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.kpi-top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.kpi-label { font-size: .7rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; }
.kpi-value { font-size: 1.62rem; font-weight: 700; line-height: 1.1; margin-top: 2px; color: var(--text-strong); }
.kpi-value small { font-size: .85rem; font-weight: 600; color: var(--text-faint); }
.kpi-ico {
    width: 38px; height: 38px; flex: 0 0 38px;
    border-radius: 12px;
    display: grid; place-items: center;
    color: #fff;
    font-size: .86rem;
}
.kpi-sub { font-size: .68rem; color: var(--text-faint); margin-top: 4px; }

/* trilho de rota na base do cartão (assinatura visual) */
.kpi-card::after {
    content: '';
    position: absolute;
    left: 16px; right: 16px; bottom: 9px;
    height: 3px;
    border-radius: 3px;
    background-image: linear-gradient(90deg, var(--kpi-c, var(--blue-500)) 55%, transparent 45%);
    background-size: 12px 3px;
    opacity: .5;
    transition: opacity var(--t-fast);
}
.kpi-card:hover::after { opacity: .95; }
.kpi-card.c-blue { --kpi-c: var(--blue-500); }
.kpi-card.c-green { --kpi-c: var(--green-500); }
.kpi-card.c-red { --kpi-c: var(--red-500); }
.kpi-card.c-orange { --kpi-c: var(--laranja-500); }
.kpi-card.c-cyan { --kpi-c: var(--cyan-500); }
.kpi-card.c-violet { --kpi-c: var(--violet-500); }
.kpi-card.c-blue .kpi-ico { background: var(--grad-blue); }
.kpi-card.c-green .kpi-ico { background: var(--grad-green); }
.kpi-card.c-red .kpi-ico { background: var(--grad-red); }
.kpi-card.c-orange .kpi-ico { background: var(--grad-laranja); }
.kpi-card.c-cyan .kpi-ico { background: linear-gradient(135deg, #0EA5E9, #67E8F9); }
.kpi-card.c-violet .kpi-ico { background: linear-gradient(135deg, #7C3AED, #A78BFA); }

/* ============================================================
   GRÁFICOS / LISTAS DO DASHBOARD
   ============================================================ */
.chart-card .card-body { min-height: 220px; }
.chart-wrap { position: relative; height: 250px; }
.chart-wrap.sm { height: 210px; }

.mini-list { list-style: none; margin: 0; padding: 0; }
.mini-list li {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 18px;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
}
.mini-list li:last-child { border-bottom: none; }
.mini-list li:hover { background: var(--surface-muted); }
.mini-list .ml-txt { min-width: 0; flex: 1; }
.mini-list .ml-title { font-size: .84rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-list .ml-sub { font-size: .7rem; color: var(--text-faint); }
.mini-list .ml-end { font-size: .7rem; color: var(--text-muted); text-align: right; white-space: nowrap; }

.avatar-ini {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 11px;
    display: inline-grid;
    place-items: center;
    font-family: var(--font-display);
    font-size: .78rem;
    font-weight: 700;
    color: #fff;
    background: var(--grad-blue);
}
.avatar-ini.inativo { background: linear-gradient(135deg, #64748B, #94A3B8); }
.avatar-ini.alerta { background: var(--grad-laranja); }

.event-log {
    max-height: 260px;
    overflow-y: auto;
    padding: 6px 0;
}
.log-entry {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 8px 18px;
    font-size: .78rem;
    color: var(--text-body);
    border-left: 3px solid transparent;
}
.log-entry .le-time { font-family: var(--font-display); font-size: .68rem; color: var(--text-faint); white-space: nowrap; padding-top: 1px; }
.log-entry.success { border-left-color: var(--green-500); }
.log-entry.info { border-left-color: var(--cyan-500); }
.log-entry.warning { border-left-color: var(--amber-500); }
.log-entry.danger { border-left-color: var(--red-500); }

/* ============================================================
   TABELAS
   ============================================================ */
.table-responsive { border-radius: var(--r-md); }
.table { --bs-table-hover-bg: #F4F7FE; margin-bottom: 0; min-width: 820px; }
.table tbody td .d-flex.justify-content-end { flex-wrap: nowrap !important; }
.table thead th {
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--text-faint);
    background: var(--surface-muted);
    border-bottom: 1px solid var(--border) !important;
    padding: 10px 12px;
    white-space: nowrap;
}
.table tbody td {
    padding: 10px 12px;
    vertical-align: middle;
    font-size: .84rem;
    border-color: var(--border);
}
.table tbody tr { transition: background var(--t-fast); }

.cell-client { display: flex; align-items: center; gap: 10px; min-width: 170px; }
.cell-client .cc-name { font-weight: 600; font-size: .85rem; line-height: 1.2; }
.cell-client .cc-sub { font-size: .68rem; color: var(--text-faint); }

/* ----- pills e badges de status ----- */
.status-badge, .pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .7rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    white-space: nowrap;
}
.status-badge.status-Ativo, .pill.green { background: var(--green-soft); color: var(--green-600); }
.status-badge.status-Inativo, .pill.red { background: var(--red-soft); color: var(--red-600); }
.pill.orange { background: var(--laranja-soft); color: var(--laranja-600); }
.pill.blue { background: #E8EEFC; color: var(--blue-600); }
.pill.gray { background: #EEF1F8; color: var(--text-muted); }
.pill.amber { background: var(--amber-soft); color: #B45309; }
.pill .pdot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

.days-counter {
    display: inline-block;
    font-size: .74rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 8px;
}
.days-counter.safe { background: var(--green-soft); color: var(--green-600); }
.days-counter.warn { background: var(--amber-soft); color: #B45309; }
.days-counter.urgent { background: var(--red-soft); color: var(--red-600); }

.fantasia-badge {
    background: var(--violet-soft);
    color: var(--violet-500);
    font-size: .7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 7px;
}
.rota-auto-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: #E8EEFC;
    color: var(--blue-600);
    font-size: .7rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
}
.sem-rota-alert {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: var(--amber-soft);
    color: #B45309;
    font-size: .7rem;
    font-weight: 600;
    padding: 3px 9px;
    border-radius: 999px;
}
.coord-badge { font-size: .62rem; font-weight: 700; padding: 1px 7px; border-radius: 6px; }
.coord-badge.especifica { background: var(--green-soft); color: var(--green-600); }
.coord-badge.cidade { background: #E8EEFC; color: var(--blue-600); }

.saldo-val { font-weight: 700; font-size: .86rem; }
.saldo-val.pos { color: var(--red-600); }
.saldo-val.zero { color: var(--green-600); }
.saldo-val.neg { color: var(--cyan-500); }

/* ============================================================
   TOOLBAR DE FILTROS (clientes / financeiro / cidades)
   ============================================================ */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    padding: 10px 12px;
    margin-bottom: var(--sp-4);
    box-shadow: var(--shadow-xs);
}
.search-field {
    position: relative;
    flex: 1 1 220px;
    min-width: 180px;
}
.search-field i {
    position: absolute;
    left: 12px; top: 50%;
    transform: translateY(-50%);
    color: var(--text-faint);
    font-size: .78rem;
    pointer-events: none;
}
.search-field input {
    width: 100%;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--r-sm);
    padding: 8px 12px 8px 34px;
    font-size: .84rem;
    transition: var(--t-fast);
}
.search-field input:focus { outline: none; border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 3px rgba(46,91,215,.12); }

.filter-bar select.form-select {
    flex: 0 1 200px;
    min-width: 150px;
    font-size: .82rem;
    border-radius: var(--r-sm);
    border-color: var(--border);
    background-color: var(--surface-muted);
    padding-top: 8px;
    padding-bottom: 8px;
}
.filter-bar select.form-select:focus { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(46,91,215,.12); }

.seg-filter {
    display: inline-flex;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: 999px;
    padding: 3px;
    gap: 2px;
}
.seg-btn {
    border: none;
    background: transparent;
    font-size: .74rem;
    font-weight: 600;
    color: var(--text-muted);
    padding: 5px 13px;
    border-radius: 999px;
    cursor: pointer;
    transition: var(--t-fast);
    white-space: nowrap;
}
.seg-btn:hover { color: var(--text-strong); }
.seg-btn.active { background: var(--navy-800); color: #fff; box-shadow: var(--shadow-sm); }
.seg-btn.active.seg-green { background: var(--green-600); }
.seg-btn.active.seg-red { background: var(--red-600); }
.seg-btn.active.seg-amber { background: var(--laranja-600); }

.resumo-chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: var(--sp-4); }

/* ============================================================
   ROTAS — PASTAS
   ============================================================ */
.route-status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    font-size: .78rem;
    font-weight: 700;
    color: var(--laranja-600);
}
.route-status-indicator .dot {
    width: 9px; height: 9px;
    border-radius: 50%;
    background: var(--laranja-500);
    animation: pulseDot 1.6s infinite;
}
.route-timer {
    background: var(--navy-800);
    color: #FFB86B;
    font-size: .8rem;
    font-weight: 700;
    padding: 3px 11px;
    border-radius: 8px;
    letter-spacing: .04em;
}
.route-live-card {
    border: 1px solid rgba(249,115,22,.4) !important;
    background: linear-gradient(90deg, var(--laranja-soft), #fff 55%) !important;
}

.rota-pasta-container {
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 5px solid var(--navy-800);
    border-radius: var(--r-lg);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
    transition: box-shadow var(--t-fast), transform var(--t-fast);
}
.rota-pasta-container:hover { box-shadow: var(--shadow-md); }
.rota-pasta-container.active-route {
    border-color: rgba(249,115,22,.45);
    box-shadow: 0 0 0 3px rgba(249,115,22,.14), var(--shadow-md);
}

.rota-pasta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 13px 16px;
    cursor: pointer;
    background: linear-gradient(180deg, var(--surface-muted), var(--surface));
    transition: background var(--t-fast);
    flex-wrap: wrap;
}
.rota-pasta-header:hover { background: #EFF3FC; }
.rota-info { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; min-width: 0; }
.rota-icon { font-size: 1.05rem; }
.rota-nome { font-family: var(--font-display); font-weight: 700; font-size: .96rem; }
.rota-badge {
    font-size: .68rem;
    font-weight: 700;
    padding: 3px 9px;
    border-radius: 999px;
}
.rota-badge.cidades { background: #E8EEFC; color: var(--blue-600); }
.rota-badge.clientes { background: var(--green-soft); color: var(--green-600); }

.rota-actions { display: flex; gap: 5px; align-items: center; }
.btn-play-action, .btn-edit-action, .btn-delete-action, .btn-route-action {
    width: 30px; height: 30px;
    border: none;
    border-radius: 9px;
    display: inline-grid;
    place-items: center;
    font-size: .72rem;
    cursor: pointer;
    color: #fff;
    transition: var(--t-fast);
}
.btn-play-action { background: var(--grad-green); }
.btn-edit-action { background: linear-gradient(135deg, #F59E0B, #FBBF24); color: #3D2800; }
.btn-delete-action { background: var(--grad-red); }
.btn-route-action { background: var(--grad-blue); }
.btn-play-action:hover, .btn-edit-action:hover, .btn-delete-action:hover, .btn-route-action:hover { filter: brightness(1.1); transform: translateY(-1px); }

.rota-toggle, .cidade-toggle {
    width: 28px; height: 28px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    color: var(--text-muted);
    display: inline-grid;
    place-items: center;
    cursor: pointer;
    font-size: .66rem;
    transition: var(--t-fast);
}
.rota-toggle:hover, .cidade-toggle:hover { color: var(--blue-600); border-color: var(--blue-500); }

.rota-pasta-body { display: none; padding: 8px 14px 14px; }
.rota-pasta-body.open { display: block; animation: pageIn .25s ease both; }

.rota-vazia, .cidade-vazia {
    text-align: center;
    color: var(--text-faint);
    font-size: .8rem;
    padding: 18px 10px;
}
.rota-vazia .emoji { font-size: 1.6rem; display: block; margin-bottom: 4px; }

.cidade-pasta {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-top: 8px;
    overflow: hidden;
    background: var(--surface);
}
.cidade-pasta-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    background: var(--surface-muted);
    cursor: pointer;
    flex-wrap: wrap;
    transition: background var(--t-fast);
}
.cidade-pasta-header:hover { background: #EFF3FC; }
.cidade-info { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.cidade-nome { font-weight: 700; font-size: .84rem; }
.ibge-badge {
    font-size: .6rem;
    font-weight: 700;
    background: var(--green-soft);
    color: var(--green-600);
    padding: 2px 7px;
    border-radius: 6px;
}
.cidade-cliente-count {
    font-size: .66rem;
    font-weight: 700;
    background: #E8EEFC;
    color: var(--blue-600);
    padding: 2px 8px;
    border-radius: 999px;
}
.cidade-cliente-count.inativos { background: var(--red-soft); color: var(--red-600); }
.cidade-pasta-body { display: none; padding: 4px 10px 10px; }
.cidade-pasta-body.open { display: block; }

.cliente-pasta-item {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    margin-top: 7px;
    background: var(--surface);
    transition: var(--t-fast);
}
.cliente-pasta-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.cliente-pasta-item.editing { border-color: var(--blue-500); box-shadow: 0 0 0 3px rgba(46,91,215,.12); }
.cliente-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 12px;
    flex-wrap: wrap;
}
.cliente-info {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    cursor: pointer;
    min-width: 0;
    flex: 1;
}
.cliente-nome { font-weight: 600; font-size: .84rem; }
.cliente-fantasia {
    background: var(--violet-soft);
    color: var(--violet-500);
    font-size: .66rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 6px;
}
.cliente-telefone { font-size: .72rem; color: #1FAF55; font-weight: 600; }
.cliente-status { font-size: .66rem; font-weight: 700; padding: 2px 8px; border-radius: 999px; }
.cliente-status.ativo { background: var(--green-soft); color: var(--green-600); }
.cliente-status.inativo { background: var(--red-soft); color: var(--red-600); }
.cliente-dias {
    font-size: .66rem;
    font-weight: 700;
    background: var(--amber-soft);
    color: #B45309;
    padding: 2px 8px;
    border-radius: 999px;
}
.cliente-ultima-ligacao {
    font-size: .66rem;
    background: #E8EEFC;
    color: var(--blue-600);
    padding: 2px 8px;
    border-radius: 999px;
    font-weight: 600;
}
.cliente-endereco-resumo, .cliente-coords-resumo {
    font-size: .66rem;
    color: var(--text-faint);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.cliente-actions { display: flex; gap: 5px; }
.compra-btn, .whats-btn, .gps-btn, .edit-btn {
    width: 28px; height: 28px;
    border: none;
    border-radius: 8px;
    display: inline-grid;
    place-items: center;
    font-size: .68rem;
    color: #fff;
    cursor: pointer;
    transition: var(--t-fast);
}
.compra-btn { background: var(--grad-laranja); }
.whats-btn { background: linear-gradient(135deg, #1FAF55, #33D673); }
.gps-btn { background: var(--grad-blue); }
.edit-btn { background: linear-gradient(135deg, #64748B, #94A3B8); }
.compra-btn:hover, .whats-btn:hover, .gps-btn:hover, .edit-btn:hover { filter: brightness(1.1); transform: translateY(-1px); }

.cliente-edit-form {
    display: none;
    border-top: 1px dashed var(--border-strong);
    background: var(--surface-muted);
    padding: 10px 12px;
    border-radius: 0 0 var(--r-md) var(--r-md);
}
.cliente-edit-form.show { display: block; }
.cliente-edit-form .form-row { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.cliente-edit-form input, .cliente-edit-form select {
    flex: 1;
    min-width: 110px;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 9px;
    font-size: .76rem;
    background: #fff;
}
.cliente-edit-form input:focus, .cliente-edit-form select:focus { outline: none; border-color: var(--blue-500); }
.btn-save-edit, .btn-cancel-edit {
    border: none;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: .74rem;
    font-weight: 700;
    cursor: pointer;
    color: #fff;
}
.btn-save-edit { background: var(--grad-green); }
.btn-cancel-edit { background: #94A3B8; }

/* ============================================================
   MAPAS
   ============================================================ */
#mapaRotas, #mapaGPS { height: 440px; border-radius: var(--r-md); z-index: 1; }
#mapaGeral { height: 520px !important; border-radius: var(--r-md) !important; z-index: 1; }
.leaflet-container { font-family: var(--font-ui); }
.custom-div-icon { background: transparent; border: none; }
.leaflet-popup-content-wrapper { border-radius: 12px; box-shadow: var(--shadow-md); }

/* ============================================================
   GPS
   ============================================================ */
.gps-search-box { position: relative; display: flex; gap: 6px; flex-wrap: wrap; }
.gps-search-box input[type="text"] {
    flex: 1;
    min-width: 150px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--r-sm);
    padding: 8px 34px 8px 12px;
    font-size: .84rem;
}
.gps-search-box input[type="text"]:focus { outline: none; border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 3px rgba(46,91,215,.12); }
.gps-search-box .clear-btn {
    position: absolute;
    right: calc(96px + 12px);
    top: 8px;
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    font-size: .8rem;
}
.gps-search-box .search-btn {
    border: none;
    border-radius: var(--r-sm);
    background: var(--grad-blue);
    color: #fff;
    font-size: .78rem;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
}
.search-suggestions {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    z-index: 999;
    max-height: 240px;
    overflow-y: auto;
}
.search-suggestions.show { display: block; }
.suggestion-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 9px 13px;
    cursor: pointer;
    font-size: .8rem;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
}
.suggestion-item:last-child { border-bottom: none; }
.suggestion-item:hover { background: var(--surface-muted); }
.suggestion-item .client-name { font-weight: 600; }
.suggestion-item .client-detail { color: var(--text-faint); font-size: .72rem; }
.badge-gps {
    background: #E8EEFC;
    color: var(--blue-600);
    font-size: .64rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    white-space: nowrap;
}
.no-results { padding: 12px; text-align: center; color: var(--text-faint); font-size: .8rem; }

.gps-rotas-lista { max-height: 250px; overflow-y: auto; }
.rota-mini-card {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 10px 14px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background var(--t-fast);
}
.rota-mini-card:hover { background: var(--surface-muted); }
.rota-mini-card .rota-nome { font-size: .84rem; font-weight: 700; font-family: var(--font-display); }
.rota-mini-card .rota-info { font-size: .7rem; color: var(--text-faint); }
.btn-ver-rota {
    border: none;
    background: var(--grad-blue);
    color: #fff;
    font-size: .72rem;
    font-weight: 700;
    border-radius: 8px;
    padding: 5px 12px;
    cursor: pointer;
}
.btn-ver-rota:hover { filter: brightness(1.08); }

.mapbox-search-container { position: relative; }
#gpsEnderecoSugestoes {
    border-radius: var(--r-md) !important;
    box-shadow: var(--shadow-md) !important;
    border: 1px solid var(--border);
    overflow: hidden;
}
#gpsEnderecoSugestoes .list-group-item { font-size: .8rem; cursor: pointer; border-color: var(--border); }
#gpsEnderecoSugestoes .list-group-item:hover { background: var(--surface-muted); }

#gpsDetalhes p { margin-bottom: 6px; font-size: .8rem; color: var(--text-body); }
#gpsDetalhes strong { color: var(--text-strong); }

/* ============================================================
   OCR / IMPORTAÇÃO
   ============================================================ */
.upload-area {
    border: 2px dashed var(--border-strong);
    border-radius: var(--r-lg);
    background: var(--surface-muted);
    text-align: center;
    padding: 30px 18px;
    cursor: pointer;
    transition: var(--t-fast);
}
.upload-area:hover { border-color: var(--blue-500); background: #EFF5FF; }
.upload-area i { font-size: 1.9rem; color: var(--blue-500); margin-bottom: 8px; }
.upload-area h5 { font-size: .95rem; margin: 4px 0; }

.progress-ocr, .progress-import { height: 10px; border-radius: 999px; background: var(--border); }
.progress-ocr .progress-bar, .progress-import .progress-bar {
    background: var(--grad-blue);
    border-radius: 999px;
    font-size: .58rem;
    line-height: 10px;
}

.ocr-result h6 { font-size: .84rem; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.text-detected {
    background: var(--navy-900);
    color: #A5F3FC;
    font-family: 'Consolas', monospace;
    font-size: .74rem;
    border-radius: var(--r-md);
    padding: 12px 14px;
    max-height: 170px;
    overflow-y: auto;
    white-space: pre-wrap;
}
.extracted-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 8px;
}
.extracted-fields .field {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 8px 11px;
}
.extracted-fields .field label {
    font-size: .6rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--text-faint);
    display: block;
}
.extracted-fields .field .value { font-size: .82rem; font-weight: 600; word-break: break-word; }
.ocr-engine-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .68rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--violet-soft);
    color: var(--violet-500);
}

/* ============================================================
   NOTIFICAÇÕES
   ============================================================ */
.notif-item {
    display: flex;
    gap: 12px;
    align-items: flex-start;
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 12px 14px;
    margin-bottom: 8px;
    background: var(--surface);
    transition: var(--t-fast);
}
.notif-item:hover { border-color: var(--border-strong); box-shadow: var(--shadow-xs); }
.notif-item .nt-ico {
    width: 36px; height: 36px; flex: 0 0 36px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    font-size: .8rem;
    color: #fff;
}
.notif-item .nt-ico.auto { background: var(--grad-laranja); }
.notif-item .nt-ico.manual { background: var(--grad-blue); }
.notif-item .nt-body { flex: 1; min-width: 0; }
.notif-item .nt-title { font-weight: 700; font-size: .86rem; }
.notif-item .nt-msg { font-size: .76rem; color: var(--text-muted); white-space: pre-wrap; margin: 3px 0; }
.notif-item .nt-meta { font-size: .66rem; color: var(--text-faint); }
.notif-item .nt-actions { display: flex; gap: 5px; }

/* ============================================================
   FINANCEIRO
   ============================================================ */
.fin-toolbar-btns { display: flex; gap: 6px; flex-wrap: wrap; }

.tipo-icon {
    width: 34px; height: 34px; flex: 0 0 34px;
    border-radius: 10px;
    display: inline-grid;
    place-items: center;
    color: #fff;
    font-size: .76rem;
}
.tipo-icon.venda { background: var(--grad-laranja); }
.tipo-icon.recebimento { background: var(--grad-green); }

.extrato-lista { max-height: 380px; overflow-y: auto; padding-right: 4px; }
.extrato-item {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 10px 4px;
    border-bottom: 1px solid var(--border);
}
.extrato-item:last-child { border-bottom: none; }
.extrato-item .ex-txt { flex: 1; min-width: 0; }
.extrato-item .ex-title { font-size: .82rem; font-weight: 600; }
.extrato-item .ex-sub { font-size: .68rem; color: var(--text-faint); }
.extrato-item .ex-val { font-family: var(--font-display); font-weight: 700; font-size: .9rem; white-space: nowrap; }
.extrato-item .ex-val.venda { color: var(--laranja-600); }
.extrato-item .ex-val.recebimento { color: var(--green-600); }
.extrato-item .ex-del {
    border: none;
    background: transparent;
    color: var(--text-faint);
    cursor: pointer;
    width: 28px; height: 28px;
    border-radius: 8px;
    font-size: .7rem;
}
.extrato-item .ex-del:hover { background: var(--red-soft); color: var(--red-600); }

.extrato-resumo {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 12px;
}
.extrato-resumo .er-box {
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    padding: 9px 12px;
    text-align: center;
}
.extrato-resumo .er-box .er-l { font-size: .62rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.extrato-resumo .er-box .er-v { font-family: var(--font-display); font-weight: 700; font-size: 1rem; }
.extrato-resumo .er-box.venda .er-v { color: var(--laranja-600); }
.extrato-resumo .er-box.receb .er-v { color: var(--green-600); }
.extrato-resumo .er-box.saldo .er-v { color: var(--red-600); }
.extrato-resumo .er-box.saldo.quitado .er-v { color: var(--green-600); }

.tipo-toggle { display: flex; gap: 8px; }
.tipo-toggle .tt-btn {
    flex: 1;
    border: 1.5px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--r-md);
    padding: 11px 10px;
    font-size: .84rem;
    font-weight: 700;
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--t-fast);
}
.tipo-toggle .tt-btn.venda.active { border-color: var(--laranja-500); background: var(--laranja-soft); color: var(--laranja-600); }
.tipo-toggle .tt-btn.recebimento.active { border-color: var(--green-500); background: var(--green-soft); color: var(--green-600); }

.cliente-select-wrap { position: relative; }
.cliente-select-list {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    max-height: 210px;
    overflow-y: auto;
    z-index: 1300;
}
.cliente-select-list.show { display: block; }
.cliente-select-list .cs-item {
    padding: 8px 13px;
    font-size: .8rem;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
    border-bottom: 1px solid var(--border);
}
.cliente-select-list .cs-item:last-child { border-bottom: none; }
.cliente-select-list .cs-item:hover, .cliente-select-list .cs-item.selected { background: var(--surface-muted); }
.cliente-select-list .cs-item small { color: var(--text-faint); }

/* ============================================================
   MODAIS (override Bootstrap)
   ============================================================ */
.modal-content {
    border: none;
    border-radius: var(--r-xl);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}
.modal-header {
    background: var(--grad-navy);
    color: #fff;
    border-bottom: none;
    padding: 15px 22px;
}
.modal-header .modal-title { font-size: 1rem; display: flex; align-items: center; gap: 9px; font-family: var(--font-display); }
.modal-header .btn-close { filter: invert(1) brightness(2); opacity: .7; }
.modal-body { padding: 20px 22px; }
.modal-footer { border-top: 1px solid var(--border); padding: 13px 22px; }

.form-label { font-weight: 600; font-size: .78rem; color: var(--text-body); margin-bottom: 4px; }
.form-control, .form-select {
    border-radius: var(--r-sm);
    border-color: var(--border);
    font-size: .86rem;
    padding: 8px 12px;
}
.form-control:focus, .form-select:focus {
    border-color: var(--blue-500);
    box-shadow: 0 0 0 3px rgba(46,91,215,.12);
}
.form-control-color { padding: 4px; height: 40px; }

/* pesquisa de cidade no modal cliente */
.search-city-modal { position: relative; }
.search-city-modal .search-icon {
    position: absolute;
    left: 12px; top: 12px;
    color: var(--text-faint);
    font-size: .78rem;
    z-index: 2;
}
.search-city-modal input.form-control { padding-left: 33px; }
.city-list-modal {
    display: none;
    position: absolute;
    top: calc(100% + 4px);
    left: 0; right: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    max-height: 200px;
    overflow-y: auto;
    z-index: 1300;
}
.city-list-modal.show { display: block; }
.city-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 13px;
    font-size: .8rem;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
    transition: background var(--t-fast);
}
.city-item:last-child { border-bottom: none; }
.city-item:hover { background: var(--surface-muted); }
.city-item.selected { background: #E8EEFC; }
.city-item .city-name { font-weight: 600; }
.city-badge {
    font-size: .6rem;
    font-weight: 700;
    background: var(--green-soft);
    color: var(--green-600);
    padding: 2px 7px;
    border-radius: 6px;
}
.city-badge.warning { background: var(--amber-soft); color: #B45309; }

/* lista de cidades no modal rota */
.search-city-input {
    flex: 1;
    min-width: 160px;
    border: 1px solid var(--border);
    background: var(--surface-muted);
    border-radius: var(--r-sm);
    padding: 8px 12px;
    font-size: .84rem;
}
.search-city-input:focus { outline: none; border-color: var(--blue-500); background: #fff; box-shadow: 0 0 0 3px rgba(46,91,215,.12); }
.city-count-badge {
    font-size: .7rem;
    font-weight: 700;
    background: #E8EEFC;
    color: var(--blue-600);
    padding: 4px 11px;
    border-radius: 999px;
    white-space: nowrap;
}
.city-list-container {
    border: 1px solid var(--border);
    border-radius: var(--r-md);
    background: var(--surface-muted);
    max-height: 230px;
    overflow-y: auto;
    padding: 8px 12px;
}
.city-list-container .form-check { padding: 5px 0 5px 26px; border-bottom: 1px dashed var(--border); }
.city-list-container .form-check:last-child { border-bottom: none; }
.city-list-container .form-check-label { font-size: .8rem; display: inline-flex; gap: 7px; align-items: center; cursor: pointer; }
.city-list-container .form-check-input { cursor: pointer; }
.city-list-container .form-check-input:checked { background-color: var(--blue-600); border-color: var(--blue-600); }

/* ============================================================
   TOASTS
   ============================================================ */
.toast-container {
    position: fixed;
    top: calc(14px + var(--safe-top));
    right: 14px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: min(360px, calc(100vw - 28px));
}
.toast-custom {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-left: 4px solid var(--cyan-500);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    padding: 11px 13px;
    font-size: .82rem;
    font-weight: 500;
    animation: toastIn .3s cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes toastIn {
    from { opacity: 0; transform: translateX(30px); }
    to { opacity: 1; transform: none; }
}
.toast-custom.success { border-left-color: var(--green-500); }
.toast-custom.error { border-left-color: var(--red-500); }
.toast-custom.warning { border-left-color: var(--amber-500); }
.toast-custom .toast-msg { flex: 1; min-width: 0; }
.toast-custom .toast-close {
    border: none;
    background: transparent;
    color: var(--text-faint);
    font-size: 1rem;
    cursor: pointer;
    line-height: 1;
    padding: 2px 5px;
    border-radius: 6px;
}
.toast-custom .toast-close:hover { background: var(--surface-muted); color: var(--text-strong); }

/* ============================================================
   FLUTUANTES
   ============================================================ */
.whatsapp-float {
    position: fixed;
    right: 18px;
    bottom: calc(18px + var(--safe-bottom));
    width: 52px; height: 52px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1FAF55, #33D673);
    color: #fff;
    display: grid;
    place-items: center;
    font-size: 1.4rem;
    z-index: 1500;
    box-shadow: 0 10px 26px rgba(31, 175, 85, .45);
    transition: var(--t-fast);
}
.whatsapp-float:hover { color: #fff; transform: translateY(-3px) scale(1.05); }

.install-btn-fixed {
    display: none;
    position: fixed;
    bottom: calc(18px + var(--safe-bottom));
    left: 50%;
    transform: translateX(-50%);
    z-index: 1500;
    border: none;
    border-radius: 999px;
    background: var(--grad-laranja);
    color: #fff;
    font-weight: 700;
    font-size: .86rem;
    padding: 11px 22px;
    gap: 8px;
    align-items: center;
    box-shadow: var(--shadow-orange);
    cursor: pointer;
    animation: installPulse 2.4s ease-in-out infinite;
}
.install-btn-fixed.show { display: inline-flex; }
@keyframes installPulse {
    0%, 100% { box-shadow: 0 8px 22px rgba(249,115,22,.32); }
    50% { box-shadow: 0 8px 30px rgba(249,115,22,.6); }
}
.install-btn-main.hidden { display: none !important; }

/* ============================================================
   RESPONSIVO FINO
   ============================================================ */
@media (max-width: 992px) {
    .chart-wrap { height: 220px; }
}
@media (max-width: 768px) {
    body { font-size: 14px; }
    .topbar { padding-top: 10px; }
    .topbar-right { width: 100%; justify-content: flex-start; }
    .clock-chip { order: -1; }
    .status-strip { overflow-x: auto; flex-wrap: nowrap; width: 100%; padding-bottom: 4px; scrollbar-width: none; }
    .status-strip::-webkit-scrollbar { display: none; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); gap: 9px; }
    .kpi-value { font-size: 1.35rem; }
    .dash-hero { padding: 18px; }
    .hero-right { width: 100%; }
    .hero-pill { flex: 1; min-width: 110px; }
    .page-head .actions { width: 100%; }
    #mapaRotas, #mapaGPS { height: 320px; }
    #mapaGeral { height: 380px !important; }
    .extrato-resumo { grid-template-columns: 1fr; }
    .main-content { padding-bottom: 110px; }
}
@media (max-width: 420px) {
    .kpi-grid { grid-template-columns: 1fr 1fr; }
    .btn { font-size: .78rem; }
}
