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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f2f5;
  height: 100vh;
  overflow: hidden;
}

#app {
  display: flex;
  height: 100vh;
}

/* Sidebar */
#sidebar {
  width: 320px;
  background: #fff;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #e0e0e0;
  overflow: hidden;
  flex-shrink: 0;
}

#sidebar-header {
  padding: 16px;
  background: #1a73e8;
  color: white;
}

#sidebar-header h1 {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 4px;
}

#stats {
  font-size: 13px;
  opacity: 0.85;
}

#account-list {
  overflow-y: auto;
  flex: 1;
}

.account-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  cursor: pointer;
  transition: background 0.15s;
}

.account-item:hover { background: #f5f8ff; }

.account-item .account-name {
  font-weight: 600;
  font-size: 14px;
  color: #1a1a1a;
  margin-bottom: 2px;
}

.account-item .account-meta {
  font-size: 12px;
  color: #666;
}

.touch-badge {
  display: inline-block;
  background: #1a73e8;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  margin-left: 6px;
}

/* Map */
#map-container {
  flex: 1;
  position: relative;
}

#map { width: 100%; height: 100%; }

/* Loading */
#loading-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

#loading-box {
  text-align: center;
  color: #444;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e0e0e0;
  border-top-color: #1a73e8;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 0 auto 12px;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Popup */
#popup-overlay, #form-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.hidden { display: none !important; }

#popup {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}

#popup-close, #form-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #666;
  line-height: 1;
  padding: 4px 8px;
}

#popup-close:hover, #form-close:hover { color: #000; }

.popup-account-name {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 4px;
}

.popup-address {
  font-size: 13px;
  color: #666;
  margin-bottom: 16px;
}

.popup-total-touches {
  font-size: 14px;
  color: #1a73e8;
  font-weight: 600;
  margin-bottom: 16px;
}

.log-visit-btn {
  display: block;
  width: 100%;
  padding: 10px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 20px;
}

.log-visit-btn:hover { background: #1558b0; }

.contacts-title {
  font-size: 14px;
  font-weight: 600;
  color: #444;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.contact-card {
  border: 1px solid #e8e8e8;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}

.contact-name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 2px;
}

.contact-title {
  font-size: 12px;
  color: #666;
  margin-bottom: 8px;
}

.contact-detail {
  font-size: 12px;
  color: #444;
  margin-bottom: 3px;
}

.contact-detail a { color: #1a73e8; text-decoration: none; }
.contact-detail a:hover { text-decoration: underline; }

.contact-touches {
  margin-top: 6px;
  font-size: 12px;
  font-weight: 600;
  color: #1a73e8;
}

/* Form */
#form-modal {
  background: white;
  border-radius: 12px;
  width: 100%;
  max-width: 440px;
  padding: 24px;
  position: relative;
}

#form-modal h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 20px;
}

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

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: #444;
  margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
}

.form-group textarea { resize: vertical; min-height: 80px; }

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: #1a73e8;
}

.form-submit-btn {
  width: 100%;
  padding: 11px;
  background: #1a73e8;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
}

.form-submit-btn:hover { background: #1558b0; }
.form-submit-btn:disabled { background: #aaa; cursor: not-allowed; }

.form-success {
  text-align: center;
  padding: 20px 0;
  color: #2e7d32;
  font-weight: 600;
  font-size: 15px;
}

/* Mobile */
@media (max-width: 640px) {
  #sidebar { display: none; }
}
