:root {
  --bg: #0f1419;
  --surface: #1a2332;
  --text: #e8eef7;
  --muted: #8b9cb3;
  --accent: #5b9cf5;
  --accent-hover: #7eb0ff;
  --border: #2a3a52;
  --radius: 12px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
}

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

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  background: radial-gradient(1200px 600px at 20% -10%, #1e3a5f 0%, transparent 55%),
    radial-gradient(900px 500px at 100% 0%, #2d1f4e 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  line-height: 1.6;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(26, 35, 50, 0.85);
  backdrop-filter: blur(8px);
}

.site-header .inner,
.site-footer .inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 1rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  color: var(--text);
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand:hover {
  color: var(--accent-hover);
}

.meta {
  font-size: 0.85rem;
  color: var(--muted);
}

.site-main {
  max-width: 880px;
  margin: 0 auto;
  padding: 2.5rem 1.25rem 4rem;
}

.site-footer {
  border-top: 1px solid var(--border);
  margin-top: auto;
  color: var(--muted);
}

.site-footer small {
  font-size: 0.8rem;
}

.hero {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2rem 2.25rem;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.35);
}

.hero h1 {
  margin: 0 0 0.75rem;
  font-size: clamp(1.75rem, 4vw, 2.25rem);
  font-weight: 700;
}

.lead {
  margin: 0 0 1rem;
  font-size: 1.05rem;
  color: var(--text);
}

.hint {
  margin: 0 0 1.75rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.progress-panel {
  margin: 0 0 1.25rem;
  padding: 0.85rem 0;
}

.progress-panel[hidden] {
  display: none !important;
}

.progress-label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.45rem;
}

.progress-track {
  position: relative;
  height: 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), var(--accent-hover));
  transition: width 0.2s ease-out;
}

.progress-track.progress-track--indeterminate .progress-fill {
  width: 35% !important;
  border-radius: 999px;
  animation: progress-slide 1.1s ease-in-out infinite;
}

@keyframes progress-slide {
  0% {
    transform: translateX(-100%);
  }
  50% {
    transform: translateX(120%);
  }
  100% {
    transform: translateX(320%);
  }
}

.progress-detail {
  margin: 0.4rem 0 0;
  font-size: 0.85rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.65rem 1.1rem;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--text);
  background: rgba(255, 255, 255, 0.04);
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn:hover {
  border-color: var(--accent);
  color: var(--accent-hover);
  background: rgba(91, 156, 245, 0.12);
}

.btn.primary {
  background: var(--accent);
  border-color: transparent;
  color: #0a0f14;
}

.btn.primary:hover {
  background: var(--accent-hover);
  color: #0a0f14;
}

.btn-disabled,
.btn[aria-disabled="true"] {
  pointer-events: none;
  opacity: 0.45;
  cursor: not-allowed;
}

button.btn {
  cursor: pointer;
  font: inherit;
}

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

.alert {
  border-radius: 10px;
  padding: 1rem 1.15rem;
  margin: 0 0 1.25rem;
  border: 1px solid var(--border);
}

.alert.error {
  background: rgba(220, 80, 80, 0.12);
  border-color: rgba(220, 100, 100, 0.45);
  color: #f3c0c0;
}

.alert.success {
  background: rgba(80, 180, 120, 0.1);
  border-color: rgba(100, 200, 140, 0.35);
}

.alert.info {
  background: rgba(91, 156, 245, 0.08);
  border-color: rgba(91, 156, 245, 0.35);
  font-size: 0.88rem;
}

.ocr-debug {
  font-family: ui-monospace, monospace;
  font-size: 0.82rem;
}

.result-heading {
  margin: 0 0 0.5rem;
  font-size: 1rem;
  color: var(--muted);
  font-weight: 600;
}

.answer-body {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
}

.preview {
  margin: 0 0 1.5rem;
  padding: 0;
}

.preview figcaption {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.preview img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--border);
}

.analyze-form {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.field .label {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--muted);
}

.field input[type="file"] {
  font-size: 0.9rem;
  color: var(--text);
}

.field textarea {
  font: inherit;
  font-size: 0.95rem;
  padding: 0.75rem 0.85rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.25);
  color: var(--text);
  resize: vertical;
  min-height: 6rem;
}

.field textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.form-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
}

.pdf-hint {
  margin: 0.35rem 0 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}

.pdf-status {
  margin: 0;
}

.pdf-status-error {
  color: #f3a8a8;
}

.pdf-previews {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
}

.pdf-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
  padding: 0.5rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(0, 0, 0, 0.2);
}

.pdf-thumb {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--muted);
}

.pdf-thumb img {
  width: 72px;
  height: auto;
  border-radius: 6px;
  border: 1px solid var(--border);
  object-fit: contain;
  background: #0a0f14;
}

.checkbox-field {
  flex-direction: row;
  align-items: flex-start;
  gap: 0.6rem;
}

.checkbox-field input {
  margin-top: 0.35rem;
  width: 1rem;
  height: 1rem;
  accent-color: var(--accent);
}

.json-out {
  margin: 0;
  padding: 1rem;
  overflow-x: auto;
  font-family: ui-monospace, "Cascadia Code", "Consolas", monospace;
  font-size: 0.82rem;
  line-height: 1.45;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 10px;
  border: 1px solid var(--border);
  color: #c8e0ff;
  white-space: pre;
}

.json-block .result-heading {
  margin-bottom: 0.75rem;
}

.json-raw-fallback {
  margin-bottom: 1rem;
  max-height: 320px;
  white-space: pre-wrap;
  word-break: break-word;
}

.extract-view {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-bottom: 1rem;
}

.extract-pages {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.page-card {
  border-left: 4px solid var(--accent);
  background: rgba(91, 156, 245, 0.06);
}

.page-card-title {
  margin: 0 0 0.75rem;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--accent-hover);
}

.page-subheading {
  margin: 1rem 0 0.5rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.page-subheading:first-of-type {
  margin-top: 0;
}

.page-summary {
  margin-bottom: 0.75rem;
}

.page-summary .summary-text {
  font-size: 0.92rem;
  color: var(--text);
}

.section-list .section-block:first-child .section-heading {
  margin-top: 0;
}

.extract-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
}

.extract-card-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}

.section-block + .section-block,
.table-block + .table-block {
  margin-top: 1.1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.section-heading,
.table-block-title {
  margin: 0 0 0.6rem;
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--muted);
}

.section-id,
.table-meta {
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
  margin-left: 0.35rem;
}

.summary-text {
  margin: 0;
  font-size: 0.95rem;
  line-height: 1.65;
  color: var(--text);
}

.table-wrap {
  overflow-x: auto;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.data-table th,
.data-table td {
  padding: 0.5rem 0.65rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

.data-table thead th {
  background: rgba(91, 156, 245, 0.12);
  color: var(--text);
  font-weight: 600;
  white-space: nowrap;
}

.data-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.03);
}

.table-wrap--sheet {
  background: rgba(10, 15, 20, 0.5);
  border-radius: 8px;
}

.data-table--sheet {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}

.data-table--sheet caption.sheet-caption {
  caption-side: top;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--muted);
  padding: 0.35rem 0.25rem 0.5rem;
}

.data-table--sheet th,
.data-table--sheet td {
  border: 1px solid rgba(139, 156, 179, 0.45);
  padding: 0.45rem 0.5rem;
  word-wrap: break-word;
  overflow-wrap: break-word;
  vertical-align: middle;
}

.data-table--sheet thead th {
  background: rgba(91, 156, 245, 0.18);
  color: var(--text);
  font-weight: 700;
  white-space: normal;
  line-height: 1.35;
}

.data-table--sheet tbody td {
  background: rgba(0, 0, 0, 0.15);
}

.data-table--sheet tbody tr:nth-child(even) td {
  background: rgba(255, 255, 255, 0.02);
}

.table-truncated-note {
  margin: 0 0 0.5rem;
  font-size: 0.85rem;
}

.table-block--sheet + .table-block--sheet {
  margin-top: 1.25rem;
}

.meta-table th[scope="row"] {
  width: 8.5rem;
  background: rgba(91, 156, 245, 0.08);
  color: var(--muted);
  font-weight: 600;
  white-space: nowrap;
}

.json-source-details {
  margin-top: 0.5rem;
}

.json-source-details summary {
  cursor: pointer;
  color: var(--accent-hover);
  font-size: 0.9rem;
  font-weight: 600;
  padding: 0.35rem 0;
}

.json-source-details summary:hover {
  text-decoration: underline;
}

.json-source-details .json-out {
  margin-top: 0.5rem;
  max-height: 280px;
  white-space: pre;
}

.json-out.small {
  font-size: 0.75rem;
  max-height: 200px;
}
