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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background-color: #f5f7fa;
  color: #333;
  line-height: 1.6;
}

.container {
  max-width: 100%;
  margin: 0;
  padding: 12px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid #e0e0e0;
  margin-bottom: 12px;
}

header h1 {
  font-size: 1.5rem;
  color: #1a73e8;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-info span {
  font-size: 0.9rem;
  color: #666;
}

main {
  flex: 1;
}

.section {
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* Login Card */
.login-card {
  background: white;
  border-radius: 8px;
  padding: 30px;
  text-align: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  margin: 40px auto;
}

.login-card h2 {
  margin-bottom: 10px;
  color: #333;
}

.login-card p {
  color: #666;
  margin-bottom: 30px;
}

#google-signin-btn {
  display: flex;
  justify-content: center;
}

/* Form Card */
.form-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
}

.form-card h2 {
  margin-bottom: 25px;
  color: #333;
  font-size: 1.25rem;
}

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

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: #444;
}

/* Search Container */
.search-container {
  position: relative;
}

.search-container input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-container input:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.search-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid #ddd;
  border-radius: 8px;
  margin-top: 4px;
  max-height: 300px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-result-item {
  padding: 12px 16px;
  cursor: pointer;
  border-bottom: 1px solid #eee;
  transition: background-color 0.15s;
}

.search-result-item:last-child {
  border-bottom: none;
}

.search-result-item:hover {
  background-color: #f5f7fa;
}

.search-result-item .company-name {
  font-weight: 500;
  color: #333;
}

.search-result-item .company-meta {
  font-size: 0.85rem;
  color: #666;
  margin-top: 4px;
}

/* Selected Company */
.selected-company {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #e8f0fe;
  border: 1px solid #1a73e8;
  border-radius: 8px;
  padding: 12px 16px;
  margin-top: 8px;
}

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

.industry-tag {
  font-size: 0.85rem;
  color: #666;
}

.btn-clear {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  padding: 0 8px;
  transition: color 0.2s;
}

.btn-clear:hover {
  color: #333;
}

/* Manual Input */
#manual-company-name {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  margin-top: 8px;
}

/* Input Method Selector */
.input-method-selector {
  display: flex;
  gap: 20px;
  margin-top: 8px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 12px 16px;
  border: 2px solid #ddd;
  border-radius: 8px;
  transition: border-color 0.2s, background-color 0.2s;
}

.radio-label:hover {
  border-color: #1a73e8;
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-label input[type="radio"]:checked + .radio-custom {
  border-color: #1a73e8;
  background-color: #1a73e8;
}

.radio-label input[type="radio"]:checked + .radio-custom::after {
  content: '';
  display: block;
  width: 8px;
  height: 8px;
  background: white;
  border-radius: 50%;
}

.radio-label:has(input[type="radio"]:checked) {
  border-color: #1a73e8;
  background-color: #e8f0fe;
}

.radio-custom {
  width: 20px;
  height: 20px;
  border: 2px solid #ddd;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background-color 0.2s;
}

/* Fieldset */
.fieldset {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.fieldset legend {
  font-weight: 500;
  color: #444;
  padding: 0 8px;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
}

/* Textarea */
textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}

textarea:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* Manual input section inputs */
#manual-input-section input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#manual-input-section input[type="text"]:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

/* Upload Area */
.upload-area {
  border: 2px dashed #ddd;
  border-radius: 12px;
  padding: 30px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
  position: relative;
}

.upload-area:hover,
.upload-area.dragover {
  border-color: #1a73e8;
  background-color: #f8faff;
}

.file-input {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-placeholder {
  color: #666;
}

.upload-placeholder svg {
  margin-bottom: 10px;
  color: #999;
}

.preview-container {
  position: relative;
}

.preview-container img {
  max-width: 100%;
  max-height: 400px;
  border-radius: 8px;
}

.btn-remove {
  position: absolute;
  top: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background-color 0.2s;
}

.btn-remove:hover {
  background: rgba(0, 0, 0, 0.85);
}

/* Multiple Image Previews */
.image-previews {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.image-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 4/3;
  background: #f5f7fa;
}

.image-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-preview-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.5), transparent);
}

.image-number {
  color: white;
  font-size: 0.75rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.4);
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-remove-image {
  background: rgba(0, 0, 0, 0.4);
  border: none;
  border-radius: 4px;
  padding: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: background-color 0.2s;
}

.btn-remove-image:hover {
  background: rgba(220, 53, 69, 0.8);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s, opacity 0.2s;
}

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

.btn-primary {
  background-color: #1a73e8;
  color: white;
  width: 100%;
}

.btn-primary:hover:not(:disabled) {
  background-color: #1557b0;
}

.btn-secondary {
  background-color: #f1f3f4;
  color: #333;
}

.btn-secondary:hover {
  background-color: #e0e0e0;
}

.btn-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* Result Card */
.result-card {
  background: white;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.result-card h3 {
  margin-bottom: 20px;
  color: #333;
}

.result-success {
  background: #e6f4ea;
  border: 1px solid #34a853;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 20px;
}

.result-success h4 {
  color: #1e8e3e;
  margin-bottom: 8px;
}

.result-error {
  background: #fce8e6;
  border: 1px solid #ea4335;
  border-radius: 8px;
  padding: 16px;
}

.result-error h4 {
  color: #c5221f;
  margin-bottom: 8px;
}

.result-data {
  margin-top: 20px;
}

.result-data table {
  width: 100%;
  border-collapse: collapse;
}

.result-data th,
.result-data td {
  padding: 10px;
  text-align: left;
  border-bottom: 1px solid #eee;
}

.result-data th {
  font-weight: 500;
  color: #666;
  width: 40%;
}

.result-data td {
  color: #333;
}

.result-data td.markdown-cell p {
  margin: 0 0 4px 0;
}

.result-data td.markdown-cell p:last-child {
  margin-bottom: 0;
}

.result-data td.markdown-cell ul,
.result-data td.markdown-cell ol {
  margin: 0;
  padding-left: 20px;
}

/* Footer */
footer {
  text-align: center;
  padding: 12px 0;
  color: #999;
  font-size: 0.8rem;
  margin-top: 12px;
}

/* Navigation Tabs */
.nav-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  background: #e0e0e0;
  border-radius: 8px;
  padding: 4px;
}

.nav-tab {
  flex: 1;
  padding: 12px 20px;
  border: none;
  background: transparent;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  color: #666;
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}

.nav-tab:hover {
  color: #333;
}

.nav-tab.active {
  background: white;
  color: #1a73e8;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Tab Content */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

/* Filter Card */
.filter-card {
  background: white;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  margin-bottom: 12px;
}

.filter-card h3 {
  margin-bottom: 16px;
  font-size: 1rem;
  color: #333;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

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

.filter-group label {
  font-size: 0.85rem;
  font-weight: 500;
  color: #666;
}

.filter-group input,
.filter-group select {
  padding: 10px 12px;
  border: 1px solid #ddd;
  border-radius: 8px;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: #1a73e8;
  box-shadow: 0 0 0 3px rgba(26, 115, 232, 0.1);
}

.filter-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.9rem;
}

/* History List */
.history-list {
  background: white;
  border-radius: 8px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.history-loading,
.history-empty {
  padding: 40px;
  text-align: center;
  color: #666;
}

.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background-color 0.15s;
}

.history-item:last-child {
  border-bottom: none;
}

.history-item:hover {
  background-color: #f8faff;
}

.history-item-main {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.history-company-name {
  font-weight: 500;
  color: #333;
  font-size: 1rem;
}

.history-meta {
  display: flex;
  gap: 12px;
  font-size: 0.85rem;
  color: #666;
}

.history-meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.history-arrow {
  color: #999;
  font-size: 1.2rem;
}

/* Detail Page */
.detail-page {
  animation: fadeIn 0.3s ease;
  max-width: 100%;
}

.detail-header {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.detail-header .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.detail-header-actions {
  display: flex;
  gap: 8px;
}

.back-arrow {
  font-size: 1.1rem;
}

.detail-page-title {
  background: white;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.detail-page-title h2 {
  font-size: 1.3rem;
  color: #333;
  margin-bottom: 4px;
}

.detail-page-title p {
  font-size: 0.9rem;
  color: #666;
}

.detail-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Detail Card */
.detail-card {
  display: flex;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  overflow: hidden;
}

.detail-label {
  flex-shrink: 0;
  width: 100px;
  padding: 12px;
  background: #4ECDC4;
  color: white;
  font-weight: 500;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  line-height: 1.3;
}

.detail-content {
  flex: 1;
  padding: 12px 16px;
  background: white;
  font-size: 0.9rem;
  line-height: 1.5;
  color: #333;
}

.detail-content p {
  margin: 0 0 8px 0;
}

.detail-content p:last-child {
  margin-bottom: 0;
}

.detail-content ul,
.detail-content ol {
  margin: 0 0 8px 0;
  padding-left: 20px;
}

.detail-content ul:last-child,
.detail-content ol:last-child {
  margin-bottom: 0;
}

.detail-content li {
  margin-bottom: 2px;
}

.detail-content h1, .detail-content h2, .detail-content h3 {
  font-size: 1rem;
  margin: 0 0 8px 0;
}

.detail-content strong {
  font-weight: 600;
}

.detail-subsection {
  margin-bottom: 8px;
}

.detail-subsection:last-child {
  margin-bottom: 0;
}

.detail-subsection-title {
  font-weight: 600;
  color: #555;
  font-size: 0.8rem;
  margin-bottom: 2px;
}

/* Detail Editor */
.detail-editor {
  flex: 1;
  padding: 12px;
  border: none;
  font-size: 0.9rem;
  font-family: monospace;
  line-height: 1.5;
  resize: vertical;
  min-height: 80px;
}

.detail-editor:focus {
  outline: 2px solid #1a73e8;
  outline-offset: -2px;
}

.detail-editor-group {
  flex: 1;
  padding: 12px;
  background: white;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.editor-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-section label {
  font-size: 0.8rem;
  color: #666;
  font-weight: 500;
}

.editor-section input,
.editor-section textarea {
  padding: 8px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.editor-section input:focus,
.editor-section textarea:focus {
  outline: none;
  border-color: #1a73e8;
}

