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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans TC", sans-serif;
  background: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

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

/* Header */
header {
  text-align: center;
  padding: 30px 0 20px;
}

header h1 {
  font-size: 28px;
  color: #1a1a2e;
  margin-bottom: 6px;
}

.subtitle {
  color: #666;
  font-size: 14px;
}

/* Search Form */
.search-form {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
}

.form-row {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  align-items: flex-end;
}

.form-row:last-child {
  margin-bottom: 0;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: #555;
}

.required { color: #e74c3c; }
.flex-1 { flex: 1; }
.flex-2 { flex: 2; }

input[type="text"],
input[type="number"],
select {
  padding: 10px 14px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
  background: #fff;
  width: 100%;
}

input:focus, select:focus {
  outline: none;
  border-color: #4a90d9;
  box-shadow: 0 0 0 3px rgba(74, 144, 217, 0.1);
}

.hint {
  font-size: 11px;
  color: #999;
}

/* Form bottom row */
.form-bottom {
  align-items: center;
  justify-content: space-between;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #4a90d9;
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

/* ──── Area Selector ──── */

.area-selector {
  position: relative;
}

.area-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 42px;
  padding: 6px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  transition: border-color 0.2s;
}

.area-trigger:hover {
  border-color: #4a90d9;
}

.selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex: 1;
}

.selected-tags .placeholder {
  color: #aaa;
  font-size: 14px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #e8f0fe;
  color: #1a73e8;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 500;
}

.tag button {
  border: none;
  background: none;
  color: #1a73e8;
  cursor: pointer;
  font-size: 12px;
  padding: 0 2px;
  line-height: 1;
}

.tag button:hover {
  color: #c00;
}

.dropdown-arrow {
  color: #999;
  font-size: 14px;
  margin-left: 8px;
}

/* Dropdown panel */
.area-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 100;
  max-height: 380px;
  overflow: hidden;
}

.area-dropdown.open {
  display: block;
}

.area-search-box {
  padding: 10px 12px;
  border-bottom: 1px solid #eee;
}

.area-search-box input {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
}

.area-columns {
  display: flex;
  height: 300px;
}

.area-cities {
  width: 45%;
  overflow-y: auto;
  border-right: 1px solid #eee;
}

.area-districts {
  width: 55%;
  overflow-y: auto;
  padding: 8px 0;
}

.city-item {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  transition: background 0.15s;
  gap: 6px;
}

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

.city-item.active {
  background: #e8f0fe;
}

.city-check input {
  width: 14px;
  height: 14px;
  accent-color: #4a90d9;
}

.city-name {
  flex: 1;
  font-size: 14px;
}

.city-arrow {
  color: #aaa;
  font-size: 16px;
}

.district-hint {
  padding: 40px 20px;
  text-align: center;
  color: #aaa;
  font-size: 14px;
}

.district-header {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #555;
  border-bottom: 1px solid #eee;
  margin-bottom: 4px;
}

.district-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.1s;
}

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

.district-item input {
  width: 14px;
  height: 14px;
  accent-color: #4a90d9;
}

/* Buttons */
.btn {
  padding: 10px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
  text-decoration: none;
  display: inline-block;
  text-align: center;
}

.btn-primary {
  background: #4a90d9;
  color: #fff;
}

.btn-primary:hover {
  background: #357abd;
}

.btn-primary:disabled {
  background: #a0c4e8;
  cursor: not-allowed;
}

.btn-secondary {
  background: #fff;
  color: #4a90d9;
  border: 1px solid #4a90d9;
}

.btn-secondary:hover:not(:disabled) {
  background: #f0f7ff;
}

.btn-secondary:disabled {
  color: #aaa;
  border-color: #ddd;
  cursor: not-allowed;
}

.btn-detail {
  padding: 4px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  cursor: pointer;
  color: #4a90d9;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn-detail:hover {
  background: #e8f0fe;
  border-color: #4a90d9;
}

/* Status */
.status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: #666;
  font-size: 14px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid #e0e0e0;
  border-top-color: #4a90d9;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Result Info */
.result-info {
  padding: 12px 16px;
  font-size: 14px;
  color: #555;
}

.total-hint {
  color: #999;
  font-size: 13px;
}

/* Table */
.table-wrapper {
  overflow-x: auto;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  font-size: 13px;
}

thead {
  background: #f8f9fb;
  position: sticky;
  top: 0;
}

th {
  padding: 12px 14px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e8e8e8;
  white-space: nowrap;
}

td {
  padding: 10px 14px;
  border-bottom: 1px solid #f0f0f0;
  vertical-align: top;
}

tr:hover {
  background: #f8fbff;
}

.col-num { width: 40px; text-align: center; }
.col-title { min-width: 160px; }
.col-company { min-width: 120px; }
.col-industry { min-width: 80px; }
.col-area { min-width: 80px; }
.col-edu { min-width: 50px; }
.col-exp { min-width: 50px; }
.col-salary { min-width: 110px; white-space: nowrap; }
.col-desc { min-width: 180px; max-width: 300px; }

td.col-desc {
  font-size: 12px;
  color: #666;
  line-height: 1.5;
}

td a {
  color: #4a90d9;
  text-decoration: none;
  font-weight: 500;
}

td a:hover {
  text-decoration: underline;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: #999;
  font-size: 15px;
}

/* ──── Modal ──── */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 200;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: #fff;
  border-radius: 16px;
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 32px;
  position: relative;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.2);
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  border: none;
  background: #f0f0f0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.modal-close:hover {
  background: #ddd;
}

.modal-body h2 {
  font-size: 20px;
  margin-bottom: 4px;
  color: #1a1a2e;
}

.modal-company {
  color: #666;
  font-size: 14px;
  margin-bottom: 12px;
}

.modal-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 20px;
}

.modal-tag {
  padding: 4px 10px;
  background: #f0f4f8;
  border-radius: 6px;
  font-size: 13px;
  color: #555;
}

.modal-section {
  margin-bottom: 20px;
}

.modal-section h3 {
  font-size: 15px;
  color: #333;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

.detail-table {
  width: 100%;
  font-size: 13px;
  box-shadow: none;
}

.detail-table td {
  padding: 6px 10px;
  border-bottom: 1px solid #f5f5f5;
}

.detail-label {
  width: 100px;
  font-weight: 600;
  color: #555;
  white-space: nowrap;
}

.detail-desc {
  font-size: 14px;
  line-height: 1.8;
  color: #444;
  white-space: pre-line;
}

.modal-footer {
  margin-top: 24px;
  text-align: center;
}

/* ──── Sheets Options ──── */

.form-options-row {
  display: flex;
  gap: 24px;
  align-items: center;
  flex-wrap: wrap;
}

.sheets-status {
  font-size: 11px;
  margin-left: 4px;
}

.sheets-status.connected { color: #2e7d32; }
.sheets-status.disconnected { color: #e65100; }

.sheets-badge {
  display: inline-block;
  margin-left: 16px;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 13px;
}

.sheets-badge.success {
  background: #e8f5e9;
  color: #2e7d32;
}

.sheets-badge.success a {
  color: #1b5e20;
  font-weight: 600;
  text-decoration: underline;
}

.sheets-badge.error {
  background: #fce4ec;
  color: #c62828;
}

/* Responsive */
@media (max-width: 768px) {
  .container { padding: 12px; }
  header { padding: 20px 0 16px; }
  header h1 { font-size: 22px; }
  .search-form { padding: 16px; }

  .form-row {
    flex-direction: column;
    gap: 12px;
  }

  .form-bottom {
    align-items: flex-start;
  }

  .form-actions {
    width: 100%;
  }

  .form-actions .btn {
    flex: 1;
  }

  .flex-1, .flex-2 {
    flex: unset;
  }

  .area-columns {
    flex-direction: column;
    height: 320px;
  }

  .area-cities {
    width: 100%;
    max-height: 140px;
    border-right: none;
    border-bottom: 1px solid #eee;
  }

  .area-districts {
    width: 100%;
  }

  .modal-box {
    padding: 20px;
    max-height: 90vh;
  }
}
