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

:root {
  --primary: #1B3A5C;
  --primary-light: #2A5580;
  --primary-dark: #0F2640;
  --accent: #E8A838;
  --accent-light: #F0C060;
  --accent-dark: #C08820;
  --bg: #F5F6F8;
  --surface: #FFFFFF;
  --text: #1A1D21;
  --text-secondary: #6B7280;
  --text-tertiary: #9CA3AF;
  --text-on-primary: #FFFFFF;
  --border: #E5E7EB;
  --border-light: #F0F1F3;
  --divider: #EEEFF2;
  --success: #10B981;
  --error: #EF4444;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.08), 0 4px 10px rgba(0,0,0,0.04);
  --radius: 12px;
  --radius-lg: 16px;
  --market-boise: #2563EB;
  --market-salt-lake: #7C3AED;
  --market-phoenix: #DC2626;
  --market-san-antonio: #059669;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.top-nav {
  background: var(--primary);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
}

.nav-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-icon {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-icon .material-icons-outlined {
  color: var(--accent);
  font-size: 24px;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  color: white;
  letter-spacing: -0.3px;
}

.brand-tagline {
  font-size: 11px;
  color: rgba(255,255,255,0.6);
  font-weight: 400;
}

.nav-tabs {
  display: flex;
  gap: 4px;
}

.nav-tab {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.6);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
}

.nav-tab:hover {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
}

.nav-tab.active {
  background: rgba(255,255,255,0.15);
  color: white;
}

.nav-tab .material-icons-outlined {
  font-size: 20px;
}

.main-content {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

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

.page-header {
  margin-bottom: 24px;
}

.page-header h1 {
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.5px;
}

.page-header p {
  font-size: 15px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Market Cards */
.market-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 16px;
}

.market-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.market-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.market-icon {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.market-icon .material-icons-outlined {
  font-size: 28px;
}

.market-card-content {
  flex: 1;
}

.market-card-name {
  font-size: 18px;
  font-weight: 600;
  color: var(--text);
}

.market-card-count {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.market-card-arrow {
  color: var(--text-tertiary);
  font-size: 20px;
}

/* Market Members Section */
.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--primary);
  font-family: inherit;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  padding: 8px 0;
  margin-bottom: 16px;
}

.back-btn:hover {
  opacity: 0.8;
}

.market-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
}

.market-section-header .market-dot {
  width: 12px;
  height: 12px;
  border-radius: 6px;
}

.market-section-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.market-section-header .count {
  margin-left: auto;
  font-size: 14px;
  color: var(--text-secondary);
}

/* Member Grid */
.member-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 12px;
}

.member-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  transition: all 0.15s;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.member-card:hover {
  box-shadow: var(--shadow-md);
  border-color: var(--border);
}

.member-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.member-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.member-avatar-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
}

.member-avatar-placeholder .material-icons-outlined {
  font-size: 24px;
}

.member-card-info {
  flex: 1;
  min-width: 0;
}

.member-card-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-card-business {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.member-card-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
}

.category-badge {
  background: rgba(232, 168, 56, 0.15);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 6px;
}

.market-dot-small {
  width: 7px;
  height: 7px;
  border-radius: 50%;
}

.market-label-small {
  font-size: 11px;
  color: var(--text-secondary);
}

.member-card-arrow {
  color: var(--text-tertiary);
  font-size: 18px;
  flex-shrink: 0;
}

/* Search */
.search-controls {
  margin-bottom: 20px;
}

.search-bar {
  display: flex;
  align-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  gap: 10px;
  transition: border-color 0.2s;
}

.search-bar:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.1);
}

.search-bar .material-icons-outlined {
  color: var(--text-tertiary);
  font-size: 20px;
}

.search-bar input {
  flex: 1;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  padding: 14px 0;
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-tertiary);
}

.search-clear {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-tertiary);
  padding: 4px;
  display: flex;
}

.search-clear:hover {
  color: var(--text-secondary);
}

.filter-chips {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--surface);
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-chip:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.filter-chip.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
}

.empty-icon {
  font-size: 56px;
  color: var(--text-tertiary);
}

.empty-state h3 {
  font-size: 18px;
  font-weight: 600;
  margin-top: 12px;
  color: var(--text);
}

.empty-state p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Manage */
.add-member-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  width: 100%;
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  color: var(--primary);
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 20px;
}

.add-member-btn:hover {
  border-color: var(--primary);
  background: rgba(27, 58, 92, 0.03);
}

.add-member-btn .material-icons-outlined {
  font-size: 24px;
  color: var(--primary);
}

.manage-member-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.manage-member-row {
  display: flex;
  align-items: center;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 16px;
  gap: 14px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
}

.manage-member-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
}

.manage-actions {
  display: flex;
  gap: 4px;
}

.action-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.action-btn:hover {
  background: var(--bg);
}

.action-btn.edit .material-icons-outlined {
  color: var(--primary);
  font-size: 20px;
}

.action-btn.delete .material-icons-outlined {
  color: var(--error);
  font-size: 20px;
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 40px 20px;
  overflow-y: auto;
  backdrop-filter: blur(4px);
}

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 600px;
  box-shadow: var(--shadow-lg);
  position: relative;
  animation: modalIn 0.25s ease-out;
}

@keyframes modalIn {
  from { opacity: 0; transform: translateY(20px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 36px;
  height: 36px;
  border: none;
  background: rgba(0,0,0,0.06);
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: background 0.15s;
}

.modal-close:hover {
  background: rgba(0,0,0,0.1);
}

/* Profile Modal */
.profile-hero {
  background: var(--primary);
  padding: 48px 32px 32px;
  text-align: center;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.profile-hero .modal-close {
  background: rgba(255,255,255,0.15);
}

.profile-hero .modal-close .material-icons-outlined {
  color: white;
}

.profile-avatar {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  overflow: hidden;
  margin: 0 auto 16px;
  border: 3px solid rgba(255,255,255,0.3);
}

.profile-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-avatar-placeholder {
  width: 100%;
  height: 100%;
  background: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

.profile-avatar-placeholder .material-icons-outlined {
  font-size: 44px;
  color: var(--primary);
}

.profile-name {
  font-size: 24px;
  font-weight: 700;
  color: white;
}

.profile-business {
  font-size: 15px;
  color: rgba(255,255,255,0.8);
  margin-top: 4px;
}

.profile-market-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(255,255,255,0.15);
  padding: 5px 14px;
  border-radius: 20px;
  margin-top: 12px;
}

.profile-market-badge .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.profile-market-badge span {
  font-size: 13px;
  font-weight: 500;
  color: white;
}

.profile-quick-actions {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 20px 24px;
  margin: -20px 24px 0;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  position: relative;
  z-index: 5;
}

.quick-action {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  padding: 4px;
}

.quick-action:hover .quick-action-icon {
  transform: scale(1.05);
}

.quick-action-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s;
}

.quick-action-icon .material-icons-outlined {
  font-size: 22px;
}

.quick-action-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
}

.profile-section {
  padding: 0 24px;
  margin-top: 24px;
}

.profile-section:last-child {
  padding-bottom: 24px;
}

.profile-section-title {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.profile-info-card {
  background: var(--bg);
  border-radius: var(--radius);
  overflow: hidden;
}

.profile-info-row {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  gap: 12px;
  cursor: default;
}

.profile-info-row.clickable {
  cursor: pointer;
  transition: background 0.15s;
}

.profile-info-row.clickable:hover {
  background: rgba(0,0,0,0.02);
}

.profile-info-icon {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: rgba(27, 58, 92, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.profile-info-icon .material-icons-outlined {
  font-size: 20px;
  color: var(--primary);
}

.profile-info-content {
  flex: 1;
  min-width: 0;
}

.profile-info-label {
  font-size: 12px;
  color: var(--text-tertiary);
}

.profile-info-value {
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.profile-info-value.link {
  color: var(--primary);
}

.profile-info-divider {
  height: 1px;
  background: var(--divider);
  margin-left: 64px;
}

.profile-logo-container {
  background: var(--bg);
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
}

.profile-logo {
  max-width: 180px;
  max-height: 90px;
  object-fit: contain;
}

.profile-services {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.service-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 8px 14px;
  border-radius: 10px;
  font-size: 14px;
  color: var(--text);
}

.service-chip .material-icons-outlined {
  font-size: 16px;
  color: var(--success);
}

/* Form Modal */
.form-modal {
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.form-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-light);
}

.form-modal-header .modal-close {
  position: static;
  background: transparent;
}

.form-modal-header h2 {
  font-size: 17px;
  font-weight: 600;
}

.form-body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}

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

.form-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-family: inherit;
  font-size: 15px;
  color: var(--text);
  outline: none;
  transition: border-color 0.2s;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(27, 58, 92, 0.08);
}

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

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%239CA3AF' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 40px;
}

.image-upload-section {
  display: flex;
  gap: 20px;
  justify-content: center;
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-light);
  position: relative;
  z-index: 1;
}

.image-upload-item {
  text-align: center;
  flex-shrink: 0;
}

.image-upload-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.image-upload-btn {
  position: relative;
  cursor: pointer;
  overflow: hidden;
  border: 2px dashed var(--border);
  background: var(--bg);
  transition: border-color 0.2s;
  display: block;
  flex-shrink: 0;
}

.image-upload-btn:hover {
  border-color: var(--primary);
}

.image-upload-btn.headshot {
  width: 100px;
  height: 100px;
  min-width: 100px;
  min-height: 100px;
  border-radius: 50%;
}

.image-upload-btn.logo {
  width: 140px;
  height: 80px;
  min-width: 140px;
  min-height: 80px;
  border-radius: 12px;
}

.image-upload-btn img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-upload-btn.logo img {
  object-fit: contain;
}

.image-upload-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-placeholder .material-icons-outlined {
  font-size: 28px;
  color: var(--text-tertiary);
}

.image-upload-badge {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-upload-badge .material-icons-outlined {
  font-size: 14px;
  color: white;
}

.image-upload-btn input[type="file"] {
  display: none;
}

.form-submit-btn {
  width: 100%;
  padding: 14px;
  background: var(--primary);
  color: white;
  border: none;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  margin-top: 8px;
}

.form-submit-btn:hover {
  background: var(--primary-light);
}

.form-submit-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Loading */
.loading-spinner {
  text-align: center;
  padding: 60px 20px;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  margin: 0 auto;
}

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

/* Responsive */
@media (max-width: 768px) {
  .nav-inner {
    flex-direction: column;
    height: auto;
    padding: 12px 16px;
    gap: 8px;
  }

  .nav-tabs {
    width: 100%;
    justify-content: center;
  }

  .main-content {
    padding: 16px;
  }

  .page-header h1 {
    font-size: 24px;
  }

  .market-grid {
    grid-template-columns: 1fr;
  }

  .member-grid {
    grid-template-columns: 1fr;
  }

  .modal-overlay {
    padding: 20px 12px;
  }

  .profile-quick-actions {
    gap: 12px;
    margin: -20px 16px 0;
  }

  .profile-section {
    padding: 0 16px;
  }

  .image-upload-section {
    flex-direction: row;
    align-items: center;
    gap: 16px;
  }
}

.admin-pin-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.admin-pin-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}

.admin-pin-icon .material-icons-outlined {
  font-size: 36px;
  color: var(--text-on-primary);
}

.admin-pin-screen h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.admin-pin-screen p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.admin-pin-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 280px;
}

.admin-pin-form .form-input {
  text-align: center;
  font-size: 20px;
  letter-spacing: 6px;
  padding: 14px;
}

.admin-pin-error {
  margin-top: 12px;
  color: var(--error);
  font-size: 13px;
  font-weight: 500;
}
