:root {
    --primary-color: #004d40;
    --primary-light: #00796b;
    --accent-color: #ffca28;
    --bg-color: #f0f2f5;
    --card-bg: #ffffff;
    --text-main: #2d3748;
    --text-muted: #718096;
    
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    
    --top-height: 115px;
    --nav-height: 65px;
    
    --total-top: calc(var(--top-height) + var(--safe-top));
    --total-bottom: calc(var(--nav-height) + var(--safe-bottom));
}

body, html { margin: 0; padding: 0; height: 100%; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background-color: var(--bg-color); overflow: hidden; color: var(--text-main); }
body { display: flex; flex-direction: column; height: 100dvh; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; outline: none; }

@media all and (display-mode: standalone) { #footer-global-install { display: none !important; } }

#login-overlay { position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: var(--primary-color); display: flex; align-items: center; justify-content: center; z-index: 99999; }
.login-box { background: var(--card-bg); padding: 35px 25px; border-radius: 16px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); text-align: center; width: 90%; max-width: 350px; }
.login-box h2 { color: var(--primary-color); margin-top: 0; margin-bottom: 25px; font-weight: 800; }
.login-box input { width: 100%; padding: 14px; margin: 8px 0; border: 1px solid #e2e8f0; border-radius: 10px; background: #f8fafc; font-size: 15px; transition: 0.2s; }
.login-box input:focus { border-color: var(--primary-light); background: #fff; }
.login-box button { width: 100%; padding: 14px; background: var(--accent-color); border: none; font-weight: 800; color: var(--primary-color); border-radius: 10px; cursor: pointer; font-size: 16px; margin-top: 15px; box-shadow: 0 4px 6px rgba(255, 202, 40, 0.3); transition: 0.2s;}
.login-box button:disabled { opacity: 0.7; cursor: not-allowed; }

#top-app-bar { position: fixed; top: 0; left: 0; width: 100%; height: var(--total-top); padding-top: var(--safe-top); background: var(--primary-color); color: white; display: flex; justify-content: space-between; align-items: center; padding-left: 15px; padding-right: 15px; z-index: 10003; box-shadow: 0 2px 10px rgba(0,0,0,0.15); }
.app-title { font-size: 18px; font-weight: 800; letter-spacing: 0.5px; display: flex; align-items: center; gap: 8px;}
.btn-top-action { background: rgba(255,255,255,0.15); border: none; color: white; padding: 8px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; cursor: pointer; display: flex; align-items: center; gap: 5px; transition: 0.2s; }
.btn-top-action:active { background: rgba(255,255,255,0.25); }

#header-filtros { position: fixed; top: var(--total-top); left: 0; width: 100%; background: var(--card-bg); z-index: 10002; display: flex; flex-direction: column; transform: translateY(-110%); transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); border-bottom-left-radius: 20px; border-bottom-right-radius: 20px; padding-bottom: 10px; max-height: calc(100vh - var(--total-top) - 80px); overflow-y: auto;}
#header-filtros.visible { transform: translateY(0); }
.filtros-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 15px; }
.grupo-filtro { display: flex; flex-direction: column; }
.grupo-filtro strong { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; text-transform: uppercase; }
.filtro-select { padding: 10px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; font-size: 13px; color: var(--text-main); width: 100%; font-family: inherit; }

.custom-multiselect-container { position: relative; }
.multiselect-header { padding: 10px; border-radius: 8px; border: 1px solid #e2e8f0; background: #f8fafc; font-size: 13px; color: var(--text-main); display: flex; justify-content: space-between; align-items: center; cursor: pointer; user-select: none; }
.multiselect-dropdown { display: none; position: absolute; top: 100%; left: 0; right: 0; background: white; border: 1px solid #e2e8f0; border-radius: 8px; max-height: 200px; overflow-y: auto; z-index: 10005; box-shadow: 0 4px 15px rgba(0,0,0,0.1); margin-top: 4px; padding: 5px; }
.multiselect-dropdown.show { display: block; }
.multiselect-option { display: flex; align-items: center; gap: 8px; padding: 8px; cursor: pointer; border-radius: 4px; transition: background 0.2s; font-size: 13px; color: var(--text-main); }
.multiselect-option:hover { background: #f0fdf4; }
.multiselect-option input[type="checkbox"] { margin: 0; width: 16px; height: 16px; cursor: pointer; accent-color: var(--primary-light); }

.header-actions-row { display: flex; gap: 10px; padding: 0 15px 15px 15px; }
.btn-modern { flex: 1; padding: 12px; border: none; border-radius: 10px; font-weight: 700; font-size: 13px; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 5px; transition: transform 0.1s; color: white; box-shadow: 0 2px 5px rgba(0,0,0,0.1); }
.btn-modern:active { transform: scale(0.97); }
.btn-modern-blue { background: #1976D2; }
.btn-modern-red { background: #dc3545; }

.bottom-nav { height: var(--total-bottom); padding-bottom: var(--safe-bottom); background: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); display: flex; position: fixed; bottom: 0; left: 0; width: 100vw; z-index: 10000; box-shadow: 0 -4px 20px rgba(0,0,0,0.08); border-top-left-radius: 20px; border-top-right-radius: 20px; padding-left: 5px; padding-right: 5px; }
.nav-item { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 10px; color: #a0aec0; cursor: pointer; transition: 0.3s ease; position: relative; }
.nav-item.active { color: var(--primary-color); font-weight: 800; }
.nav-item i { font-size: 22px; margin-bottom: 3px; font-style: normal; transition: transform 0.2s; }
.nav-item.active i { transform: translateY(-2px); }
.nav-indicator { position: absolute; top: 0; width: 40px; height: 3px; background: var(--accent-color); border-radius: 0 0 4px 4px; opacity: 0; transition: 0.3s; }
.nav-item.active .nav-indicator { opacity: 1; }
#tab-admin { display: none; }

#footer-rota-global { display: none; position: fixed; bottom: calc(var(--total-bottom) + 15px); left: 50%; transform: translateX(-50%); width: 90%; max-width: 350px; background: linear-gradient(135deg, #10b981, #059669); color: white; padding: 14px 20px; font-size: 15px; font-weight: 800; border-radius: 30px; box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4); z-index: 9999; cursor: pointer; align-items: center; justify-content: center; gap: 8px; transition: transform 0.2s, box-shadow 0.2s; letter-spacing: 0.5px; }
#footer-rota-global:active { transform: translateX(-50%) scale(0.96); box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3); }

.tab-content { display: none; flex: 1; position: relative; width: 100%; overflow-y: auto; margin-top: var(--total-top); height: calc(100dvh - var(--total-top) - var(--total-bottom)); padding-bottom: 80px; } 
.tab-content.active { display: flex; flex-direction: column; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }
.map-container { flex-grow: 1; width: 100%; height: 100%; z-index: 1;}

.roteiro-panel, .tabela-container, .admin-section { padding: 20px; background: var(--card-bg); margin: 15px; border-radius: 16px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.05); }
.admin-section h3 { margin-top:0; border-bottom: 2px solid #f0f2f5; padding-bottom: 10px; color:var(--primary-color); font-size: 16px; }
.btn-gerar-rota-massa { width: 100%; padding: 14px; background: #10b981; color: white; border: none; border-radius: 10px; font-size: 15px; font-weight: bold; cursor: pointer; margin-top: 15px; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.2); }

#banner-offline { display: none; position: fixed; top: var(--total-top); left: 0; width: 100%; background-color: #f59e0b; color: white; text-align: center; padding: 10px; font-weight: bold; cursor: pointer; z-index: 10001; box-sizing: border-box; font-size: 13px;}
#erro-global { top: var(--total-top); }

.user-location-icon { background-color: #3b82f6; border: 3px solid white; border-radius: 50%; box-shadow: 0 4px 10px rgba(59, 130, 246, 0.5); display: flex; align-items: center; justify-content: center; font-size: 14px;}
.base-location-icon { background-color: #8b5cf6; border: 3px solid white; border-radius: 50%; box-shadow: 0 4px 10px rgba(139, 92, 246, 0.5); display: flex; align-items: center; justify-content: center; font-size: 16px; color: white; font-weight: bold;}

.btn-localizar { position: absolute; top: 15px; left: 15px; z-index: 1000; background: white; color: var(--primary-color); border: none; border-radius: 12px; padding: 12px; cursor: pointer; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 5px;}
.btn-selecao { position: absolute; top: 15px; left: 105px; z-index: 1000; background: white; color: var(--primary-color); border: none; border-radius: 12px; padding: 12px; cursor: pointer; font-weight: 700; box-shadow: 0 4px 12px rgba(0,0,0,0.15); display: flex; align-items: center; gap: 5px; transition: 0.2s; }
.btn-selecao.ativo { background: var(--accent-color); color: var(--primary-color); border: 2px solid var(--primary-color); padding: 10px; }
.popup-selecao-btn { width: 100%; padding: 10px; margin: 4px 0; border: none; border-radius: 6px; font-weight: 800; cursor: pointer; transition: 0.2s; font-size: 13px;}
.popup-selecao-btn:active { transform: scale(0.97); }
.popup-selecao-add { background: #3b82f6; color: white; }
.popup-selecao-rem { background: #ef4444; color: white; }

#toast-instrucao { display: none; position: absolute; top: 75px; left: 50%; transform: translateX(-50%); background: #1e293b; color: white; padding: 10px 20px; border-radius: 20px; font-weight: bold; font-size: 13px; z-index: 10006; box-shadow: 0 4px 10px rgba(0,0,0,0.3); text-align: center; pointer-events: none; }

#pf-backdrop, #md-backdrop { display: none; position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); z-index: 10004; }
#painel-flutuante { position: fixed; bottom: 0; left: 0; width: 100vw; background: white; z-index: 10005; box-shadow: 0 -10px 25px rgba(0,0,0,0.15); padding: 20px; border-radius: 24px 24px 0 0; transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1); transform: translateY(110%); display: flex; flex-direction: column; max-height: 85vh; overflow-y: auto; box-sizing: border-box; padding-bottom: calc(20px + var(--total-bottom)); }
#painel-flutuante.ativo { transform: translateY(0); }
.drag-handle { width: 40px; height: 5px; background: #cbd5e1; border-radius: 5px; margin: 0 auto 15px auto; }

#modal-detalhes, #modal-instalar-app { display: none; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); width: 90%; max-width: 400px; background: white; z-index: 10007; border-radius: 16px; box-shadow: 0 10px 30px rgba(0,0,0,0.2); padding: 25px; }

.popup-titulo { color: var(--primary-color); font-size: 18px; font-weight: 800; margin-bottom: 4px; display: block; line-height: 1.2; }
.popup-subtitulo { color: var(--text-muted); font-size: 13px; font-weight: 600; margin-bottom: 15px; display: block; padding-bottom: 10px; border-bottom: 1px solid #f0f2f5;}
.popup-status-box { background: #f8fafc; border: 1px solid #e2e8f0; padding: 12px; border-radius: 10px; margin-bottom: 15px; display: flex; flex-direction: column; gap: 5px;}

.btn-checkin { padding: 12px 10px; border: none; border-radius: 10px; color: white; font-weight: 700; cursor: pointer; width: 100%; margin-top: 5px; font-size: 13px; transition: 0.2s; display: flex; align-items: center; justify-content: center; gap: 5px;}
.btn-checkin:active { transform: scale(0.97); }
.btn-checkin:disabled { background: #e2e8f0 !important; color: #94a3b8 !important; cursor: not-allowed; transform: none; }
.btn-checkin.normal { background-color: #10b981; }
.btn-checkin.detalhada { background-color: #8b5cf6; }
.btn-checkin.add-rota { background-color: #3b82f6; }
.btn-checkin.remove-rota { background-color: #ef4444; }
.btn-checkin.ir-direto { background-color: #0ea5e9; }
.btn-checkin.info-btn { background-color: #f59e0b; }
.btn-checkin.primeira-parada { background-color: #f59e0b; color: #fff; }

.input-print { width: 100%; padding: 10px; border: 2px dashed #cbd5e1; border-radius: 10px; background: #f8fafc; font-size: 12px; cursor: pointer; color: var(--text-muted); }

.tabela-escolas { width: 100%; border-collapse: collapse; }
.tabela-escolas th { background-color: #f8fafc; color: var(--text-muted); text-transform: uppercase; font-size: 11px; padding: 12px; text-align: left; border-bottom: 2px solid #e2e8f0; }
.tabela-escolas td { padding: 12px; border-bottom: 1px solid #f0f2f5; font-size: 13px; vertical-align: middle; }

@media (max-width: 768px) {
    .tabela-escolas thead { display: none; }
    .tabela-escolas tbody tr { display: block; background: white; margin-bottom: 15px; border-radius: 12px; padding: 15px; box-shadow: 0 2px 8px rgba(0,0,0,0.06); border: 1px solid #f0f2f5; }
    .tabela-escolas tbody td { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #f8fafc; padding: 8px 0; text-align: right; gap: 10px;}
    .tabela-escolas tbody td:last-child { border-bottom: none; padding-bottom: 0; }
    .tabela-escolas tbody td::before { content: attr(data-label); font-weight: 700; color: var(--text-muted); font-size: 11px; text-transform: uppercase; text-align: left;}
    .tabela-escolas tbody td button { width: auto; min-width: 100px; }
}

.admin-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 20px; }
.admin-form input, .admin-form select { padding: 12px; border: 1px solid #e2e8f0; border-radius: 8px; flex-grow: 1; font-family: inherit; }
.btn-acao { padding: 12px 16px; background: #3b82f6; color: white; border: none; border-radius: 8px; font-weight: 700; cursor: pointer; transition: 0.2s;}
.btn-acao:active { transform: scale(0.97); }
.btn-upload { background-color: var(--accent-color); color: var(--primary-color); padding: 12px 16px; border-radius: 8px; font-weight: 800; cursor: pointer; display: inline-block; text-align: center; box-shadow: 0 4px 6px rgba(255, 202, 40, 0.2);}

.dash-card { background: white; border-radius: 12px; padding: 15px; text-align: center; border: 1px solid #f0f2f5; flex: 1; min-width: 100px; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.dash-card.green { border-bottom: 4px solid #10b981; }
.dash-card.red { border-bottom: 4px solid #ef4444; }
.dash-card h4 { margin: 0; color: var(--text-muted); font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px;}
.dash-card span { font-size: 26px; font-weight: 800; color: var(--text-main); display: block; margin-top: 5px; }
.progress-bar-bg { width: 100%; background-color: #e2e8f0; border-radius: 15px; margin-top: 15px; overflow: hidden; height: 18px; }
.progress-bar-fill { background-color: #10b981; height: 100%; color: white; text-align: center; line-height: 18px; font-size: 10px; font-weight: 800; transition: width 0.5s ease; }

#footer-global-install { display: none; position: fixed; top: calc(var(--total-top) + 10px); left: 50%; transform: translateX(-50%); width: 90%; max-width: 350px; background: #fff; padding: 12px; text-align: center; border-radius: 12px; z-index: 10000; box-shadow: 0 4px 15px rgba(0,0,0,0.15); border: 1px solid #e2e8f0; }
#btn-instalar-app { background: var(--primary-color); color: var(--accent-color); border: none; padding: 10px 20px; border-radius: 8px; font-weight: 800; cursor: pointer; font-size: 13px; width: 100%; }
.item-roteiro { background: #f8fafc; padding: 12px; border-radius: 10px; margin-bottom: 8px; display: flex; justify-content: space-between; align-items: center; border-left: 4px solid #3b82f6;}

/* --- ESTILOS DOS PINOS EM LOSANGO (TEMPO INTEGRAL) --- */
.icone-losango { display: flex; justify-content: center; align-items: center; background: transparent !important; border: none !important; box-shadow: none !important; }
.diamond-shape { width: 24px; height: 48px; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); border: none; box-shadow: none; position: relative; }
.diamond-shape::after { content: ''; position: absolute; top: 2px; left: 2px; right: 2px; bottom: 2px; background: inherit; clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%); filter: brightness(1.1); }
.diamond-verde .diamond-shape { background-color: #10b981; }
.diamond-amarelo .diamond-shape { background-color: #f59e0b; }
.diamond-roxo .diamond-shape { background-color: #8b5cf6; }
.diamond-vermelho .diamond-shape { background-color: #ef4444; }
.diamond-azul .diamond-shape { background-color: #3b82f6; }
.diamond-cinza .diamond-shape { background-color: #9ca3af; }

/* Workspace Matrix Switcher Utility */
.matrix-container { background: #f8fafc; border: 2px solid #3b82f6; padding: 12px; border-radius: 12px; margin-bottom: 15px; }
.matrix-title { font-size: 12px; font-weight: 800; color: #1e293b; margin-bottom: 8px; text-transform: uppercase; text-align: center; }
.matrix-grid-teams { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
.btn-matrix-team { padding: 10px; border: 2px solid #cbd5e1; background: white; font-weight: bold; font-size: 12px; border-radius: 8px; cursor: pointer; transition: 0.2s; color: var(--text-main); }
.btn-matrix-team.active[data-team="EQUIPA A"] { background: #2563eb; color: white; border-color: #2563eb; }
.btn-matrix-team.active[data-team="EQUIPA B"] { background: #7c3aed; color: white; border-color: #7c3aed; }
