* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

body { background: #f5f5f5; }
#app { max-width: 1200px; margin: 0 auto; background: white; min-height: 100vh; }

.screen { display: none; }
.screen.active { display: block; }

/* Login */
#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.login-container {
    width: 90%;
    max-width: 400px;
    padding: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

.logo { text-align: center; margin-bottom: 30px; }
.logo i { font-size: 60px; color: #667eea; }
.logo h1 { color: #333; margin-top: 10px; }
.login-form h2 { margin-bottom: 20px; color: #555; text-align: center; }

.input-group {
    position: relative;
    margin-bottom: 20px;
}

.input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.input-group input {
    width: 100%;
    padding: 15px 15px 15px 45px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 16px;
}

.input-group input:focus {
    outline: none;
    border-color: #667eea;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 5px;
    font-size: 16px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    transition: 0.3s;
}

.btn-primary:hover { transform: translateY(-2px); }

.login-info {
    margin-top: 20px;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 5px;
    font-size: 14px;
    color: #666;
}

.login-info p { margin: 5px 0; }

/* Header */
.header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.header-title { display: flex; align-items: center; gap: 10px; }
.header-title i { font-size: 24px; }
.header-title h2 { font-size: 20px; }

.user-info { display: flex; align-items: center; gap: 15px; }

.btn-icon {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 18px;
}

.btn-icon:hover { background: rgba(255,255,255,0.3); }

/* Content */
.content { padding: 20px; }

/* GPS Status */
.gps-status {
    background: #f8f9fa;
    border-left: 4px solid #ffc107;
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.gps-status.active { border-left-color: #28a745; }
.gps-status.active i { color: #28a745; }

/* Cards */
.card {
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 20px;
    overflow: hidden;
}

.card-header {
    background: #f8f9fa;
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

.card-header h3 {
    color: #495057;
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-body { padding: 20px; }

/* Forms */
.form-group { margin-bottom: 15px; }

.form-group label {
    display: block;
    margin-bottom: 5px;
    color: #495057;
    font-weight: 500;
    font-size: 14px;
}

.form-group label i { margin-right: 5px; color: #667eea; }

.form-group input {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 16px;
}

.form-group input:focus { outline: none; border-color: #667eea; }
.form-group input[readonly] { background: #e9ecef; }

.form-row { display: flex; gap: 15px; }
.form-group.half { flex: 1; }

.btn-gps {
    background: #28a745;
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 5px;
    font-size: 14px;
    cursor: pointer;
    margin-top: 5px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.btn-gps:hover { background: #218838; }
.btn-block { width: 100%; margin-top: 20px; }

/* Fretes List */
.fretes-list { max-height: 400px; overflow-y: auto; }

.frete-item {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 5px;
    padding: 15px;
    margin-bottom: 10px;
}

.frete-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.frete-motorista { font-weight: bold; color: #495057; }
.frete-data { color: #6c757d; font-size: 12px; }

.frete-detalhes {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
    margin: 10px 0;
}

.frete-detalhes div {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #495057;
    font-size: 14px;
}

.frete-detalhes i { color: #667eea; width: 20px; }

.frete-enderecos {
    font-size: 13px;
    color: #6c757d;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #dee2e6;
}

.frete-enderecos p {
    margin: 5px 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    gap: 15px;
}

.stat-card i { font-size: 40px; opacity: 0.8; }
.stat-info { display: flex; flex-direction: column; }
.stat-value { font-size: 28px; font-weight: bold; }
.stat-label { font-size: 14px; opacity: 0.9; }

/* Filters */
.filter-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-row input {
    flex: 1;
    min-width: 200px;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 14px;
}

.filter-row button {
    width: auto;
    padding: 12px 30px;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    color: #6c757d;
}

.loading i { animation: spin 1s linear infinite; }
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.empty-state i { font-size: 50px; margin-bottom: 20px; opacity: 0.5; }

/* Responsive */
@media (max-width: 768px) {
    .form-row { flex-direction: column; gap: 0; }
    .stats-grid { grid-template-columns: 1fr; }
    .filter-row { flex-direction: column; }
    .filter-row input,
    .filter-row button { width: 100%; }
    .header { flex-direction: column; gap: 10px; text-align: center; }
    .frete-detalhes { grid-template-columns: 1fr; }
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.modal-content {
    background-color: white;
    margin: 50px auto;
    padding: 20px;
    border-radius: 10px;
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid #dee2e6;
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.modal-close:hover {
    color: #333;
}

.modal-footer {
    margin-top: 20px;
    text-align: right;
}

.button-group {
    display: flex;
    gap: 10px;
    margin-top: 5px;
}

#map {
    height: 400px;
    width: 100%;
    border-radius: 5px;
    margin-bottom: 15px;
}

/* Leaflet marker fix */
.leaflet-default-icon-path {
    background-image: url(https://unpkg.com/leaflet@1.9.4/dist/images/marker-icon.png);
}
