/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", sans-serif; background: #F2F2F7; color: #1C1C1E; -webkit-font-smoothing: antialiased; }
input, select, button { font-family: inherit; }
.view { display: none; min-height: 100vh; }
.view.active { display: flex; flex-direction: column; }

/* === Login === */
.login-container {
    flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
    padding: 40px 24px; background: linear-gradient(135deg, #007AFF 0%, #5856D6 100%);
}
.login-icon { font-size: 64px; margin-bottom: 16px; }
.login-container h1 { color: #fff; font-size: 24px; font-weight: 600; }
.login-subtitle { color: rgba(255,255,255,0.8); font-size: 14px; margin-top: 4px; }
.login-hint { color: rgba(255,255,255,0.7); font-size: 13px; margin-bottom: 16px; }
.login-container input[type="password"] {
    width: 100%; max-width: 300px; padding: 14px 16px; border: none; border-radius: 12px;
    font-size: 16px; background: rgba(255,255,255,0.2); color: #fff; outline: none;
    margin-bottom: 12px; backdrop-filter: blur(10px);
}
.login-container input::placeholder { color: rgba(255,255,255,0.5); }
.error-msg { color: #FF3B30; font-size: 13px; margin-top: 8px; background: rgba(255,255,255,0.9); padding: 8px 16px; border-radius: 8px; display: none; }

/* === Buttons === */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 14px 28px; border: none; border-radius: 12px; font-size: 16px;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-primary { background: #fff; color: #007AFF; width: 100%; max-width: 300px; }
.btn-primary:active { transform: scale(0.98); opacity: 0.9; }
.btn-outline { background: rgba(255,255,255,0.15); color: #fff; border: 1.5px solid rgba(255,255,255,0.4); }
.btn-outline:active { background: rgba(255,255,255,0.25); }
.btn-icon { background: none; border: none; font-size: 20px; cursor: pointer; padding: 8px; border-radius: 8px; }
.btn-icon:active { background: rgba(0,0,0,0.05); }

/* === Header === */
.app-header {
    position: sticky; top: 0; z-index: 100; background: #F2F2F7;
    padding: env(safe-area-inset-top) 16px 0;
    border-bottom: 0.5px solid rgba(0,0,0,0.1);
}
.header-top { display: flex; align-items: center; justify-content: space-between; padding: 12px 0 8px; }
.header-top h1 { font-size: 28px; font-weight: 700; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.company-count { font-size: 13px; color: #8E8E93; background: #E5E5EA; padding: 4px 10px; border-radius: 12px; }

/* === Search & Filter === */
.search-bar { padding: 8px 0; }
.search-bar input {
    width: 100%; padding: 10px 14px; border: none; border-radius: 10px;
    font-size: 15px; background: #E5E5EA; outline: none;
}
.search-bar input:focus { background: #D1D1D6; }
.filter-bar { display: flex; gap: 8px; padding: 4px 0 12px; align-items: center; }
.filter-bar select {
    flex: 1; padding: 8px 12px; border: none; border-radius: 10px;
    font-size: 14px; background: #E5E5EA; color: #1C1C1E; appearance: none;
    -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%238E8E93'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center;
}
.btn-map-toggle { font-size: 24px; }
.btn-locate { background: #007AFF; color: #fff; border: none; width: 36px; height: 36px; border-radius: 50%; font-size: 18px; cursor: pointer; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,122,255,0.3); }
.btn-locate:active { transform: scale(0.9); }

/* === Map === */
#map-container { height: 50vh; border-bottom: 0.5px solid rgba(0,0,0,0.1); }
#amap { width: 100%; height: 100%; position: relative; }

/* === Company List === */
.list-container { flex: 1; overflow-y: auto; padding: 0 16px 80px; }
.company-list { display: flex; flex-direction: column; gap: 8px; padding: 8px 0; }
.company-card {
    background: #fff; border-radius: 12px; padding: 14px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04); cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s;
    display: flex; align-items: center; gap: 12px;
}
.company-card:active { transform: scale(0.98); box-shadow: 0 0 0 rgba(0,0,0,0); }
.card-badge {
    width: 40px; height: 40px; border-radius: 10px; display: flex;
    align-items: center; justify-content: center; font-size: 14px;
    font-weight: 700; color: #fff; flex-shrink: 0;
}
.card-badge.A { background: #34C759; }
.card-badge.B { background: #007AFF; }
.card-badge.C { background: #FF9500; }
.card-badge.D { background: #FF3B30; }
.card-info { flex: 1; min-width: 0; }
.card-name { font-size: 15px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-meta { font-size: 12px; color: #8E8E93; margin-top: 3px; display: flex; gap: 8px; }
.card-phone { font-size: 20px; color: #34C759; flex-shrink: 0; padding: 4px; }
.badge-joint { display: inline-block; background: #5856D6; color: #fff; font-size: 11px; padding: 2px 8px; border-radius: 6px; font-weight: 600; }
.no-results { text-align: center; padding: 60px 20px; color: #8E8E93; font-size: 15px; }

/* === Detail === */
.detail-header { display: flex; align-items: center; gap: 12px; padding: 12px 0; }
.detail-header h1 { font-size: 17px; font-weight: 600; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.btn-back { background: none; border: none; color: #007AFF; font-size: 16px; cursor: pointer; padding: 4px 0; white-space: nowrap; }
.detail-content { flex: 1; overflow-y: auto; padding: 0 16px 100px; }
.detail-section { background: #fff; border-radius: 12px; margin: 12px 0; overflow: hidden; }
.detail-row {
    display: flex; padding: 14px 16px; border-bottom: 0.5px solid #F2F2F7;
    font-size: 15px; line-height: 1.4;
}
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 80px; color: #8E8E93; flex-shrink: 0; }
.detail-value { flex: 1; word-break: break-all; }
.detail-value a { color: #007AFF; text-decoration: none; }
.detail-actions { display: flex; gap: 12px; padding: 16px; }
.btn-action {
    flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
    padding: 14px; border: none; border-radius: 12px; font-size: 16px;
    font-weight: 600; cursor: pointer; transition: all 0.2s;
}
.btn-call { background: #34C759; color: #fff; }
.btn-call:active { background: #2DB84E; }
.btn-nav { background: #007AFF; color: #fff; }
.btn-nav:active { background: #0066DD; }
.detail-map { height: 200px; border-radius: 12px; overflow: hidden; margin: 0 16px 16px; }

/* === Bottom Nav === */
.bottom-nav {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
    background: rgba(249,249,249,0.94); backdrop-filter: blur(20px);
    border-top: 0.5px solid rgba(0,0,0,0.1);
    display: flex; padding: 6px 0 env(safe-area-inset-bottom);
}
.nav-item {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    gap: 2px; padding: 6px 0; background: none; border: none;
    color: #8E8E93; cursor: pointer; transition: color 0.2s;
}
.nav-item.active { color: #007AFF; }
.nav-icon { font-size: 22px; }
.nav-label { font-size: 10px; font-weight: 500; }

/* === Toast === */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background: rgba(0,0,0,0.8); color: #fff; padding: 10px 20px;
    border-radius: 10px; font-size: 14px; z-index: 999;
    animation: toastIn 0.3s ease, toastOut 0.3s ease 1.7s forwards;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(-50%) translateY(10px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
@keyframes toastOut { to { opacity: 0; transform: translateX(-50%) translateY(10px); } }

/* === Scrollbar === */
::-webkit-scrollbar { display: none; }
