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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: #f0f2f5;
  color: #1a1a2e;
  font-size: 14px;
  line-height: 1.6;
}

/* === Topbar === */
.topbar {
  background: #fff;
  display: flex;
  align-items: center;
  padding: 0 24px;
  height: 56px;
  border-bottom: 1px solid #e0e0e0;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: #2563eb;
  margin-right: 40px;
}
.logo-icon { font-size: 22px; }
.tabs { display: flex; gap: 4px; }
.tab {
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  color: #666;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s;
}
.tab:hover { background: #f0f4ff; color: #2563eb; }
.tab.active { background: #2563eb; color: #fff; }

/* === Views === */
.view { display: none; max-width: 1200px; margin: 0 auto; padding: 24px; }
.view.active { display: block; }

/* === Form Card === */
.form-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.form-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 6px;
}
.hint {
  color: #888;
  font-size: 13px;
  margin-bottom: 20px;
}

/* === Form === */
.form-group {
  margin-bottom: 18px;
  flex: 1;
}
.form-group label {
  display: block;
  font-weight: 600;
  margin-bottom: 6px;
  font-size: 13px;
}
.form-group input[type="text"],
.form-group input[type="number"],
.form-group input[type="password"] {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  font-size: 14px;
  transition: border 0.15s;
}
.form-group input:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37,99,235,0.1);
}
.form-group small {
  color: #999;
  font-size: 12px;
}
.form-row {
  display: flex;
  gap: 20px;
}
.req { color: #ef4444; }

/* === Checkboxes === */
.checkbox-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}
.cb {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  transition: all 0.15s;
}
.cb:hover { border-color: #93c5fd; background: #eff6ff; }
.cb input { accent-color: #2563eb; }

/* Multi-column checkbox layout */
.cb-columns {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 6px 12px;
  max-height: 280px;
  overflow-y: auto;
  padding: 8px;
  border: 1px solid #e8eaed;
  border-radius: 10px;
  background: #fcfcfd;
}
.cb-columns .cb {
  padding: 5px 10px;
  font-size: 12.5px;
}
.cb-group-title {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: 700;
  color: #2563eb;
  padding: 4px 0 2px;
  border-bottom: 1px solid #e0e7ff;
  margin-top: 4px;
}
.cb-group-title:first-child { margin-top: 0; }
.btn-link {
  background: none;
  border: none;
  color: #2563eb;
  cursor: pointer;
  font-size: 12px;
  text-decoration: underline;
  padding: 0 0 0 8px;
}
.btn-link:hover { color: #1d4ed8; }

/* === Buttons === */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid #d0d5dd;
  border-radius: 8px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
}
.btn:hover { background: #f8f9fa; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.btn-primary:hover { background: #1d4ed8; }
.btn-lg { padding: 12px 28px; font-size: 15px; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-danger { color: #ef4444; border-color: #fca5a5; }
.btn-danger:hover { background: #fef2f2; }

/* === Progress === */
.progress-card {
  background: #fff;
  border-radius: 12px;
  padding: 28px;
  margin-bottom: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}
.progress-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
}
.step {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: 8px;
  background: #f0f2f5;
  transition: all 0.3s;
}
.step.active {
  background: #dbeafe;
}
.step.done {
  background: #d1fae5;
}
.step.done .step-num { background: #10b981; }
.step.active .step-num { background: #2563eb; }
.step-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #cbd5e1;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
}
.step-text { font-weight: 600; font-size: 13px; }
.step-line {
  flex: 0 0 40px;
  height: 2px;
  background: #e0e0e0;
  margin: 0 4px;
}
.step-line.done { background: #10b981; }
.progress-log {
  max-height: 200px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  line-height: 1.8;
  background: #1a1a2e;
  color: #a5d6ff;
  padding: 16px;
  border-radius: 8px;
}
.progress-log .log-entry {
  padding: 2px 0;
}
.progress-log .log-time {
  color: #666;
  margin-right: 8px;
}

/* === Table === */
.results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.results-header h2 {
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 10px;
}
.results-actions {
  display: flex;
  gap: 8px;
}
.badge {
  display: inline-block;
  padding: 2px 10px;
  background: #dbeafe;
  color: #2563eb;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 600;
}
.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  background: #fff;
}
.data-table th {
  background: #f8f9fa;
  padding: 10px 12px;
  text-align: left;
  font-weight: 600;
  color: #555;
  border-bottom: 2px solid #e5e7eb;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid #f0f0f0;
  white-space: nowrap;
}
.data-table tbody tr:hover {
  background: #f8faff;
}
.data-table input[type="checkbox"] {
  accent-color: #2563eb;
}

/* === Status tags === */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}
.tag-searching { background: #fef3c7; color: #92400e; }
.tag-extracting { background: #ede9fe; color: #5b21b6; }
.tag-composing { background: #dbeafe; color: #1e40af; }
.tag-sending { background: #fce7f3; color: #9d174d; }
.tag-done { background: #d1fae5; color: #065f46; }
.tag-failed { background: #fee2e2; color: #991b1b; }
.tag-sent { background: #e0f2fe; color: #075985; }
.tag-opened { background: #fef3c7; color: #92400e; }
.tag-replied { background: #d1fae5; color: #065f46; }
.tag-new { background: #f1f5f9; color: #475569; }

/* === Stats === */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.stat-card {
  background: #fff;
  border-radius: 12px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.05);
  text-align: center;
}
.stat-card .stat-icon {
  font-size: 28px;
  margin-bottom: 8px;
}
.stat-card .stat-value {
  font-size: 28px;
  font-weight: 700;
  color: #1a1a2e;
}
.stat-card .stat-label {
  font-size: 13px;
  color: #888;
  margin-top: 4px;
}

/* === Misc === */
.hidden { display: none !important; }
.confidence-bar {
  display: inline-block;
  width: 50px;
  height: 6px;
  background: #e5e7eb;
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
}
.confidence-fill {
  height: 100%;
  border-radius: 3px;
}

/* === Responsive === */
@media (max-width: 768px) {
  .form-row { flex-direction: column; gap: 0; }
  .topbar { padding: 0 12px; }
  .tabs { flex-wrap: wrap; }
  .view { padding: 12px; }
}

/* === Guide Box === */
.guide-box {
  background: #f0f7ff;
  border: 1px solid #bfdbfe;
  border-radius: 10px;
  margin-bottom: 20px;
  overflow: hidden;
}
.guide-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  color: #1e40af;
  transition: background 0.15s;
}
.guide-header:hover { background: #e0edff; }
.guide-arrow { font-size: 12px; transition: transform 0.2s; }
.guide-content {
  padding: 8px 18px 18px;
  border-top: 1px solid #bfdbfe;
}
.guide-step {
  display: flex;
  gap: 14px;
  padding: 14px 0;
  border-bottom: 1px dashed #cbd5e1;
}
.guide-step:last-of-type { border-bottom: none; }
.guide-step-num {
  flex-shrink: 0;
  width: 64px;
  font-weight: 700;
  font-size: 13px;
  color: #2563eb;
}
.guide-step-body h4 {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 6px;
  color: #1a1a2e;
}
.guide-step-body p {
  font-size: 13px;
  color: #555;
  margin-bottom: 4px;
  line-height: 1.8;
}
.guide-step-body a {
  color: #2563eb;
  text-decoration: underline;
}
.guide-tip {
  margin-top: 12px;
  padding: 12px 16px;
  background: #fefce8;
  border: 1px solid #fde68a;
  border-radius: 8px;
  font-size: 13px;
  color: #78350f;
}
.guide-tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0;
  flex-wrap: wrap;
}
.guide-tab-btn {
  padding: 6px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  background: #fff;
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s;
}
.guide-tab-btn:hover { border-color: #93c5fd; }
.guide-tab-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}
.guide-tab-content p { margin-bottom: 4px; }

/* === Preset Buttons === */
.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.preset-btn {
  padding: 12px 20px;
  border: 2px solid #d0d5dd;
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s;
  color: #444;
}
.preset-btn:hover {
  border-color: #2563eb;
  background: #eff6ff;
  color: #2563eb;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(37,99,235,0.15);
}
.preset-btn:active {
  transform: translateY(0);
}
.guide-step-body code {
  display: inline-block;
  padding: 1px 6px;
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  color: #c43b3b;
}
.guide-step-body ul {
  margin-left: 8px;
}
.guide-step-body ul li {
  margin-bottom: 4px;
  font-size: 13px;
  color: #555;
}

/* === New Form Layout (v2) === */
.form-header {
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f0f0f0;
}
.form-header h2 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  margin-bottom: 6px;
}
.form-header .hint {
  font-size: 13.5px;
  color: #888;
  margin: 0;
}
.form-section {
  margin-bottom: 4px;
}
.form-section .section-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  color: #1a1a2e;
  margin-bottom: 12px;
}
.section-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  font-size: 13px;
  font-weight: 700;
}
.form-divider {
  height: 1px;
  background: linear-gradient(to right, transparent, #e5e7eb 20%, #e5e7eb 80%, transparent);
  margin: 18px 0;
}
.form-row-2 {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}
.form-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-top: 20px;
}
.form-actions .form-hint {
  font-size: 13px;
  color: #888;
  margin: 0;
}
.btn-xl {
  padding: 14px 48px;
  font-size: 16px;
  font-weight: 700;
  border-radius: 10px;
  box-shadow: 0 4px 12px rgba(37,99,235,0.2);
}
.btn-xl:hover {
  box-shadow: 0 6px 16px rgba(37,99,235,0.3);
  transform: translateY(-1px);
}

/* === Chip Row (horizontal pill-style checkboxes) === */
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 9px 18px;
  background: #f8f9fa;
  border: 1.5px solid #e0e0e0;
  border-radius: 24px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s;
  user-select: none;
}
.chip:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}
.chip input {
  accent-color: #2563eb;
  width: 16px;
  height: 16px;
}
.chip:has(input:checked) {
  background: #dbeafe;
  border-color: #2563eb;
  color: #1e40af;
  font-weight: 600;
}
