:root {
  --font-main: 'Inter', system-ui, -apple-system, sans-serif;
  --font-heading: 'Outfit', 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --color-primary: #2563eb;
  --color-primary-hover: #1d4ed8;
  --color-success: #10b981;
  --color-success-hover: #059669;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
}

body {
  font-family: var(--font-main);
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-main, #0f172a);
  color: var(--text-main, #f8fafc);
  margin: 0;
  padding: 0;
}

h1, h2, h3, h4, h5, h6,
.brand-title,
.section-title,
.hero-title,
.faq-section-title {
  font-family: var(--font-heading);
}

.mono,
code {
  font-family: var(--font-mono);
}

/* Tool Layout */
.tool-layout {
  max-width: 1380px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  box-sizing: border-box;
  flex: 1 0 auto;
  width: 100%;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
  width: 100%;
}

.tool-main-content {
  flex: 1 1 0%;
  min-width: 0;
  width: 100%;
}

/* Hero Section */
.tool-hero {
  margin-bottom: 2rem;
}

.tool-hero-text h1 {
  font-size: 2.1rem;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 0.5rem 0;
  color: var(--text-title, #f8fafc);
}

.tool-hero-text p {
  font-size: 1.05rem;
  line-height: 1.6;
  color: var(--text-muted, #94a3b8);
  margin: 0 0 1rem 0;
  max-width: 860px;
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--bg-card-secondary, #1e293b);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-main, #e2e8f0);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
}

.chip-success {
  background: rgba(16, 185, 129, 0.12);
  border-color: rgba(16, 185, 129, 0.35);
  color: #34d399;
}

/* Upload Dropzone */
.upload-container {
  background: var(--bg-card, #1e293b);
  border: 2px dashed var(--border-color, #334155);
  border-radius: 1rem;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  position: relative;
  margin-bottom: 2rem;
}

.upload-container:hover,
.upload-container.drag-over {
  border-color: var(--color-primary);
  background: rgba(37, 99, 235, 0.05);
}

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

.upload-icon-box {
  width: 68px;
  height: 68px;
  margin: 0 auto 1.25rem;
  background: rgba(37, 99, 235, 0.12);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #60a5fa;
}

.upload-text h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.5rem 0;
  color: var(--text-title, #f8fafc);
}

.upload-link {
  color: #60a5fa;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.upload-text p {
  color: var(--text-muted, #94a3b8);
  font-size: 0.95rem;
  margin: 0 0 1.25rem 0;
}

.upload-tags {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-tag {
  background: var(--bg-subtle, #0f172a);
  border: 1px solid var(--border-color, #334155);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
  padding: 0.25rem 0.6rem;
  border-radius: 6px;
}

.demo-btn-wrap {
  margin-top: 1.25rem;
  position: relative;
  z-index: 10;
}

.btn-secondary-subtle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-main, #e2e8f0);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-secondary-subtle:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: #64748b;
}

/* Workspace Layout */
.workspace-container {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* Top toolbar */
.doc-header-card {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.doc-info {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-icon {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  background: rgba(37, 99, 235, 0.15);
  color: #60a5fa;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-meta h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  color: var(--text-title, #f8fafc);
}

.doc-meta span {
  font-size: 0.82rem;
  color: var(--text-muted, #94a3b8);
}

.doc-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Split Viewer & Extractor Panel */
.extractor-grid {
  display: grid;
  grid-template-columns: minmax(360px, 460px) 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .extractor-grid {
    grid-template-columns: 1fr;
  }
}

/* PDF Preview Panel */
.preview-panel {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 0.75rem;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.panel-header {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.panel-title {
  font-size: 0.92rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.page-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-icon-sm {
  width: 30px;
  height: 30px;
  border-radius: 6px;
  background: var(--bg-subtle, #0f172a);
  border: 1px solid var(--border-color, #334155);
  color: var(--text-main, #f8fafc);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-icon-sm:hover:not(:disabled) {
  background: #334155;
}

.btn-icon-sm:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.page-counter {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted, #94a3b8);
}

.canvas-viewport-wrap {
  position: relative;
  background: #090d16;
  padding: 1rem;
  overflow: auto;
  max-height: 580px;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  user-select: none;
}

.canvas-container {
  position: relative;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border-radius: 4px;
  overflow: hidden;
  display: inline-block;
  cursor: crosshair;
}

#pdf-canvas {
  display: block;
  max-width: 100%;
  height: auto;
}

/* Selection Box */
.selection-box {
  position: absolute;
  border: 2px dashed #2563eb;
  background: rgba(37, 99, 235, 0.18);
  pointer-events: none;
  display: none;
  z-index: 10;
}

.selection-info-bar {
  padding: 0.6rem 1rem;
  background: var(--bg-subtle, #0f172a);
  border-top: 1px solid var(--border-color, #334155);
  font-size: 0.8rem;
  color: var(--text-muted, #94a3b8);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

/* Table Editor / Data Grid Panel */
.data-panel {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 0.75rem;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.data-panel-header {
  padding: 0.75rem 1rem;
  background: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.data-actions-left {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.data-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-primary);
  color: #fff;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-primary:hover {
  background: var(--color-primary-hover);
}

.btn-success {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--color-success);
  color: #fff;
  border: none;
  padding: 0.45rem 0.9rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease;
}

.btn-success:hover {
  background: var(--color-success-hover);
}

.btn-outline {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: transparent;
  color: var(--text-main, #f8fafc);
  border: 1px solid var(--border-color, #334155);
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: #64748b;
}

/* Settings Bar */
.editor-settings-bar {
  padding: 0.6rem 1rem;
  background: var(--bg-subtle, #0f172a);
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.85rem;
}

.toggle-label {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  cursor: pointer;
  font-size: 0.82rem;
  color: var(--text-main, #e2e8f0);
}

/* Spreadsheet Grid View */
.table-scroll-container {
  overflow: auto;
  max-height: 520px;
  background: var(--bg-main, #0f172a);
}

.spreadsheet-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  text-align: left;
}

.spreadsheet-table th,
.spreadsheet-table td {
  border: 1px solid var(--border-color, #334155);
  padding: 0.45rem 0.65rem;
  min-width: 90px;
  max-width: 260px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.spreadsheet-table th {
  background: var(--bg-card-secondary, #1e293b);
  color: var(--text-title, #f8fafc);
  font-family: var(--font-heading);
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 2;
}

.spreadsheet-table .col-header-row th {
  background: #111827;
  color: #94a3b8;
  font-size: 0.75rem;
  text-align: center;
  font-family: var(--font-mono);
  padding: 0.25rem 0.4rem;
}

.spreadsheet-table .row-index {
  background: #111827;
  color: #94a3b8;
  font-size: 0.75rem;
  text-align: center;
  font-family: var(--font-mono);
  width: 36px;
  min-width: 36px;
  user-select: none;
}

.spreadsheet-table td[contenteditable="true"] {
  outline: none;
  background: var(--bg-card, #1e293b);
  color: var(--text-main, #f8fafc);
}

.spreadsheet-table td[contenteditable="true"]:focus {
  background: rgba(37, 99, 235, 0.15);
  box-shadow: inset 0 0 0 2px var(--color-primary);
}

/* Table empty state */
.table-empty-state {
  padding: 3rem 1.5rem;
  text-align: center;
  color: var(--text-muted, #94a3b8);
}

.table-empty-state svg {
  margin-bottom: 0.75rem;
  opacity: 0.4;
}

.table-empty-state p {
  font-size: 0.95rem;
  margin: 0;
}

/* Extraction Options Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  backdrop-filter: blur(4px);
  padding: 1rem;
  box-sizing: border-box;
}

.modal-card {
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 1rem;
  max-width: 520px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}

.modal-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--border-color, #334155);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.15rem;
  margin: 0;
  color: var(--text-title, #f8fafc);
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted, #94a3b8);
  cursor: pointer;
  padding: 0.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
}

.btn-close-modal:hover {
  color: var(--text-main, #f8fafc);
  background: rgba(255, 255, 255, 0.08);
}

.modal-body {
  padding: 1.25rem;
  font-size: 0.92rem;
  color: var(--text-main, #e2e8f0);
}

.modal-footer {
  padding: 1rem 1.25rem;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid var(--border-color, #334155);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Toast Notification */
.toast-notice {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #10b981;
  color: #fff;
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  transform: translateY(100px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-notice.show {
  transform: translateY(0);
  opacity: 1;
}

/* FAQ / SEO Section */
.faq-section {
  margin-top: 3.5rem;
  background: var(--bg-card, #1e293b);
  border: 1px solid var(--border-color, #334155);
  border-radius: 1rem;
  padding: 2rem;
}

.faq-title {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 0 0 1.5rem 0;
  color: var(--text-title, #f8fafc);
}

.faq-accordion {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.faq-item {
  border: 1px solid var(--border-color, #334155);
  border-radius: 0.5rem;
  overflow: hidden;
  background: var(--bg-subtle, #0f172a);
}

.faq-item summary {
  padding: 1rem 1.25rem;
  font-weight: 600;
  font-size: 0.98rem;
  cursor: pointer;
  user-select: none;
  color: var(--text-title, #f8fafc);
  list-style: none;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.faq-item summary::-webkit-details-marker {
  display: none;
}

.faq-item summary::after {
  content: '+';
  font-size: 1.25rem;
  font-weight: 400;
  color: #60a5fa;
  transition: transform 0.2s ease;
}

.faq-item[open] summary::after {
  content: '−';
}

.faq-content {
  padding: 0 1.25rem 1.25rem;
  font-size: 0.92rem;
  line-height: 1.6;
  color: var(--text-muted, #94a3b8);
}

@media (max-width: 768px) {
  .tool-hero-text h1 {
    font-size: 1.6rem;
  }
  .doc-header-card {
    flex-direction: column;
    align-items: stretch;
  }
  .data-panel-header {
    flex-direction: column;
    align-items: stretch;
  }
  .data-actions-left,
  .data-actions-right {
    justify-content: stretch;
  }
  .data-actions-left button,
  .data-actions-right button {
    flex: 1 1 auto;
    justify-content: center;
  }
}
