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

:root {
  --bg: #f9f9f9;
  --surface: #ffffff;
  --border: #e0e0e0;
  --text-primary: #1a1a1a;
  --text-secondary: #555555;
  --text-muted: #999999;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --tag-bg: #f0f0f0;
  --na-color: #bbb;
  --header-bg: #ffffff;
  --row-hover: #f5f5f5;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.5;
}

header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  padding: 28px 0 20px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.container {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px;
}

header .container {
  max-width: 100%;
  display: flex;
  align-items: center;
  gap: 24px;
  flex-wrap: wrap;
}

.header-title {
  flex: 1;
}

header h1 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

header p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

.search-wrap {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.request-btn {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  text-decoration: none;
  transition: background-color 0.15s;
}

.request-btn:hover {
  background: var(--accent-hover);
}

/* Request Company Popup */
.request-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.request-overlay.active {
  display: flex;
}

.request-popup {
  background: var(--surface);
  border-radius: 10px;
  padding: 32px 28px 28px;
  width: 100%;
  max-width: 460px;
  position: relative;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}

.request-popup h2 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 6px;
}

.request-popup-sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
  line-height: 1.5;
}

.request-popup-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0 4px;
}

.request-popup-close:hover {
  color: var(--text-primary);
}

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

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.form-group .required {
  color: #e53e3e;
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="email"],
.form-group textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 13px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
  font-family: inherit;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--accent);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.request-popup input[type="submit"] {
  width: 100%;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 6px;
  transition: background-color 0.15s;
}

.request-popup input[type="submit"]:hover:not(:disabled) {
  background: var(--accent-hover);
}

.request-popup input[type="submit"]:disabled {
  background: #86a8f0;
  cursor: default;
}

#search {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 14px;
  font-size: 13px;
  width: 220px;
  background: var(--bg);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.15s;
}

#search:focus {
  border-color: var(--accent);
}

#search::placeholder {
  color: var(--text-muted);
}

main {
  padding: 24px 0 60px;
}

.count-bar {
  margin-bottom: 14px;
  font-size: 12px;
  color: var(--text-muted);
}

.company-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.alpha-divider {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 6px 4px 4px;
  margin-top: 12px;
  border-bottom: 2px solid var(--border);
  user-select: none;
}

.alpha-divider:first-child {
  margin-top: 0;
}

.company-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  transition: box-shadow 0.15s;
}

.company-item:hover {
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.company-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  user-select: none;
  gap: 12px;
}

.company-header:hover {
  background: var(--row-hover);
}

.company-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  flex: 1;
}

.company-location-inline {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.chevron {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: transform 0.2s ease;
  will-change: transform;
}

.company-item.open .chevron {
  transform: rotate(180deg);
}

.company-item.viewed .company-header {
  background: #f0fdf4;
}

.company-item.viewed .company-header:hover {
  background: #dcfce7;
}

.company-item.viewed .company-name {
  color: #16a34a;
}

.company-item.viewed {
  border-color: #bbf7d0;
}

.company-body {
  display: none;
  border-top: 1px solid var(--border);
  padding: 18px 18px 20px;
}

.company-item.open .company-body {
  display: block;
}

.info-grid {
  display: grid;
  grid-template-columns: 140px 1fr;
  gap: 10px 16px;
}

.info-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  padding-top: 1px;
}

.info-value {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
}

.info-value .na {
  color: var(--na-color);
  font-style: italic;
}

.info-value a {
  color: var(--accent);
  text-decoration: none;
}

.info-value a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

.info-divider {
  grid-column: 1 / -1;
  border: none;
  border-top: 1px solid var(--border);
  margin: 4px 0;
}

.no-results {
  text-align: center;
  color: var(--text-muted);
  padding: 60px 20px;
  font-size: 14px;
}

.bottom-bar {
  text-align: center;
  padding: 20px 0 28px;
  font-size: 12px;
  color: var(--text-muted);
}

.export-inline-link {
  color: var(--text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  font-size: 12px;
}

.export-inline-link:hover {
  color: var(--text-secondary);
}

@media (max-width: 600px) {
  header .container { flex-direction: column; align-items: stretch; gap: 12px; }
  .search-wrap { flex-direction: column; }
  #search { width: 100%; }
  .request-btn { width: 100%; text-align: center; }
  .company-location-inline { display: none; }
  .info-grid { grid-template-columns: 1fr; gap: 8px 0; }
  .info-label { border-top: 1px solid var(--border); padding-top: 8px; margin-top: 4px; }
  .info-label:first-child { border: none; padding-top: 0; margin-top: 0; }
  .info-divider { display: none; }

}
