body {
    background: linear-gradient(135deg, #f0f4ff 0%, #f8f9fa 100%);
    font-family: 'Segoe UI', sans-serif;
    min-height: 100vh;
}

.hidden { 
  display: none !important; 
}

.toast {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%);
  background: #333; color: white; padding: 10px 20px; border-radius: 4px; z-index: 100;
}

.error { 
  color: #c00; margin-top: 8px; 
}

.hint { 
  color: #666; 
  font-size: 0.9em; 
}

.banner { 
  background: #e8f0fe; 
  padding: 10px; 
  border-radius: 4px; 
  margin-bottom: 12px; 
}

.warning { 
  color: #b45309; 
}

.page-nav { 
  display: flex; 
  align-items: center; 
  gap: 12px; 
  margin-bottom: 16px; 
}

.preview-image { 
  max-width: 100%; 
  border: 1px solid #ccc; 
  margin-bottom: 12px; 
}

.page-html { 
  border: 1px solid #ddd; 
  padding: 12px; 
  margin-bottom: 12px; 
}

button { 
  padding: 8px 16px; 
  margin: 4px 4px 4px 0; 
  cursor: pointer; 
}

button:disabled { 
  cursor: not-allowed; 
  opacity: 0.5; 
}

select { 
  padding: 6px; 
  margin-right: 8px; 
}

.page-header {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    padding: 16px 0;
    margin-bottom: 28px;
    box-shadow: 0 2px 12px rgba(79,70,229,.3);
}
.page-header h5 { 
  font-weight: 700; 
  color: #fff; 
  margin: 0; 
  font-size: 1.1rem; 
}

.card {
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    margin-bottom: 20px;
    overflow: hidden;
}
.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f0f0;
    font-weight: 600;
    color: #1f2937;
    padding: 14px 20px;
    font-size: 0.9rem;
    letter-spacing: .01em;
}

.card-header .section-icon { 
  color: #6366f1; 
  margin-right: 8px; 
}

.card-body { 
  padding: 20px; 
}

.btn-extract {
    background: #fff;
    border: 1.5px solid #6366f1;
    color: #6366f1;
    font-size: 0.82rem;
    border-radius: 8px;
    padding: 6px 16px;
    transition: all .2s;
}
.btn-extract:hover { 
  background: #6366f1; 
  color: #fff; 
}

.btn-extract:disabled { 
  background: #f3f4f6; 
  border-color: #e5e7eb; 
  color: #9ca3af; 
  cursor: not-allowed; 
}

#view-upload {
    display: flex;
    justify-content: center;
}
.upload-card {
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,.08);
    padding: 48px 40px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    margin-top: 40px;
}
.upload-card .icon-wrap {
    font-size: 3.5rem;
    color: #6366f1;
    margin-bottom: 20px;
}
.upload-card h4 {
    font-weight: 700;
    color: #1f2937;
    font-size: 1.4rem;
    margin-bottom: 10px;
}
.upload-card .sub-text {
    color: #6b7280;
    font-size: 0.9rem;
    margin-bottom: 20px;
}
.btn-primary-gradient {
    background: linear-gradient(90deg, #4f46e5, #7c3aed);
    border: none;
    color: #fff;
    font-size: 0.9rem;
    border-radius: 8px;
    padding: 10px 28px;
    font-weight: 600;
    transition: opacity .2s;
}
.btn-primary-gradient:hover { opacity: 0.9; }
.btn-primary-gradient:disabled { background: #d1d5db; cursor: not-allowed; }

.spin-icon i {
    display: inline-block;
    animation: spin 1.5s linear infinite;
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.status-list {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}
.status-list li {
    padding: 10px 14px;
    border-radius: 8px;
    background: #f8f9fc;
    margin-bottom: 8px;
    font-size: 0.88rem;
    color: #374151;
}
#view-processing {
    display: flex;
    justify-content: center;
}

#view-ocr-choice {
    display: flex;
    justify-content: center;
}
.warn-icon { color: #f59e0b; }
.btn-link-muted {
    background: none;
    border: none;
    color: #9ca3af;
    font-size: 0.82rem;
    text-decoration: underline;
    cursor: pointer;
}
.btn-link-muted:hover { color: #6366f1; }

.status-need-ocr { color: #dc2626; font-weight: 700; }
.status-ok { color: #16a34a; font-weight: 600; }
.choice-btn-row {
    display: flex;
    gap: 10px;
    margin-top: 16px;
}
.btn-choice {
    flex: 1;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 0.85rem;
    font-weight: 600;
    color: #fff;
    transition: opacity .2s;
}
.btn-choice:hover { opacity: 0.9; }
.btn-choice-primary { background: linear-gradient(90deg, #4f46e5, #7c3aed); }
.btn-choice-secondary { background: linear-gradient(90deg, #0891b2, #06b6d4); }
#view-result { max-width: 600px; margin: 0 auto; }
.page-nav-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 2px 12px rgba(0,0,0,.06);
    padding: 12px 20px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.page-nav-center { text-align: center; flex: 1; }
.page-indicator-text { font-weight: 600; color: #1f2937; font-size: 0.95rem; }
.btn-nav {
    background: #f3f4f6;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    color: #6366f1;
    font-size: 1rem;
}
.btn-nav:disabled { color: #d1d5db; cursor: not-allowed; }
.source-badge { display: inline-block; margin-top: 4px; font-size: 0.78rem; color: #6b7280; }
.badge-low-quality { color: #b45309; font-weight: 600; }
.preview-image {
    width: 100%;
    border-radius: 8px;
    object-fit: contain;
    background: #f1f5f9;
    min-height: 200px;
}
.page-html {
    background: #fafafa;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    padding: 14px;
    line-height: 1.7;
    font-size: 0.9rem;
}
.warning { color: #b45309; font-size: 0.85rem; margin-top: 12px; }
.extract-controls { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.form-select-sm { border: 1px solid #d1d5db; border-radius: 8px; font-size: 0.82rem; color: #374151; padding: 6px 10px; }
.btn-download {
    background: #fff;
    border: 1.5px solid #d1d5db;
    color: #374151;
    font-size: 0.82rem;
    border-radius: 8px;
    padding: 8px 20px;
    transition: all .2s;
}
.btn-download:hover { border-color: #6366f1; color: #6366f1; background: #f5f3ff; }
.result-actions { display: flex; justify-content: center; gap: 12px; margin-top: 20px; }
.extract-table { width: 100%; border-collapse: collapse; }
.extract-table td { padding: 9px 14px; vertical-align: top; }
.extract-table .section-header { background: #e0e7ff; font-weight: 700; color: #1f2937; padding: 10px 14px; font-size: 0.85rem; }
.extract-table .field-label { color: #6b7280; font-size: 0.76rem; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; white-space: nowrap; width: 160px; }
.extract-table .field-value { font-size: 0.9rem; color: #111827; }
.extract-table tr:not(:last-child) td { border-bottom: 1px solid #f3f4f6; }
.sub-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; }
.sub-table th, .sub-table td { border: 1px solid #e5e7eb; padding: 6px 10px; }
.sub-table th { background: #f3f4f6; }
.extract-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 20px 0;
    color: #6b7280;
    font-size: 0.85rem;
}
.spinner {
    width: 18px;
    height: 18px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}
.text-danger-msg {
    color: #dc2626;
    font-size: 0.85rem;
    text-align: center;
    padding: 12px 0;
}
#view-error {
    display: flex;
    justify-content: center;
}
.error-icon { color: #ef4444; }
.legal-content {
    font-size: 1.05rem;
    line-height: 1.9;
    color: #111827;
}
.legal-content {
    font-size: 1.05rem;
    line-height: 1.5;
    color: #111827;
}
.legal-content h1 {
    font-weight: 800;
    font-size: 1.7rem;
    color: #1f2937;
    margin-top: 0;
    margin-bottom: 0.5rem;
}
.legal-content h2 {
    font-weight: 700;
    font-size: 1.25rem;
    color: #1f2937;
    margin-top: 1.25rem;
    margin-bottom: 0.5rem;
}
.legal-content p, .legal-content li {
    margin-bottom: 0.4rem;
}
.legal-content ul, .legal-content ol {
    padding-left: 1.5rem;
    margin-bottom: 0.4rem;
}
.legal-content em {
    color: #b45309;
}
#upload-sub-text {
    font-size: 0.95rem;
}