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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #ffffff;
  color: #1a1a2e;
  min-height: 100vh;
}

.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 240px;
  background: #141f25;
  color: #c5d0dc;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 100;
}

.sidebar-logo {
  padding: 1.2rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
}

.sidebar-logo img {
  height: 32px;
  width: auto;
}

.sidebar-nav {
  list-style: none;
  padding: 0.8rem 0;
  margin: 0;
  flex: 1;
}

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0.7rem 1.2rem;
  color: rgba(255,255,255,0.6);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover {
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
}

.sidebar-nav li a.active {
  background: rgba(255,255,255,0.08);
  color: #fff;
  border-left-color: #fff;
}

.sidebar-nav li a svg {
  flex-shrink: 0;
  opacity: 0.7;
}

.sidebar-nav li a.active svg {
  opacity: 1;
}

.sidebar-nav li.social-media-hidden {
  display: none;
}
body.is-admin .sidebar-nav li.social-media-hidden {
  display: list-item;
}

.main-content {
  flex: 1;
  margin-left: 240px;
  background: #ffffff;
}

.container {
  max-width: 640px;
  margin: 0 auto;
  padding: 40px 20px;
}

@media (max-width: 768px) {
  .sidebar {
    width: 56px;
  }
  .sidebar-logo span,
  .sidebar-nav li a span,
  .sidebar-branding span {
    display: none;
  }
  .sidebar-nav li a {
    justify-content: center;
    padding: 0.7rem;
  }
  .main-content {
    margin-left: 56px;
  }
}

@media (min-width: 1280px) {
  .sidebar { width: 280px; }
  .main-content { margin-left: 280px; }
}

@media (min-width: 1500px) {
  .sidebar { width: 320px; }
  .main-content { margin-left: 320px; }
  .sidebar-nav li a { padding: 0.8rem 1.5rem; font-size: 0.95rem; }
  .sidebar-logo { padding: 1.4rem 1.4rem; }
}

@media (min-width: 1800px) {
  .sidebar { width: 360px; }
  .main-content { margin-left: 360px; }
  .sidebar-nav li a { padding: 0.85rem 1.75rem; font-size: 1rem; }
  .sidebar-logo { padding: 1.6rem 1.6rem; }
}

header {
  text-align: center;
  margin-bottom: 32px;
}

header h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #1a1a2e;
}

.subtitle {
  color: #6b7280;
  margin-top: 6px;
  font-size: 0.95rem;
}

.doc-type-selector {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
}

.doc-type-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 20px 16px;
  background: #fff;
  border: 2px solid #e2e8f0;
  border-radius: 12px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
  font-family: inherit;
  color: #64748b;
}

.doc-type-btn:hover {
  border-color: #93c5fd;
  background: #f8fafc;
}

.doc-type-btn.active {
  border-color: #3b82f6;
  background: #eff6ff;
  color: #1e40af;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.doc-type-btn span {
  font-size: 0.9rem;
  font-weight: 600;
}

.upload-area {
  border: 2px dashed #cbd5e1;
  border-radius: 12px;
  padding: 40px 24px;
  text-align: center;
  background: #fff;
  transition: border-color 0.2s, background 0.2s;
  cursor: pointer;
}

.upload-area.dragover {
  border-color: #3b82f6;
  background: #eff6ff;
}

.upload-area.has-file {
  border-color: #22c55e;
  background: #f0fdf4;
}

.upload-icon {
  color: #94a3b8;
  margin-bottom: 12px;
}

.upload-area.has-file .upload-icon {
  color: #22c55e;
}

.upload-text {
  font-size: 1rem;
  font-weight: 500;
  color: #475569;
}

.upload-hint {
  color: #94a3b8;
  font-size: 0.85rem;
  margin: 8px 0;
}

.browse-btn {
  display: inline-block;
  padding: 8px 20px;
  background: #3b82f6;
  color: #fff;
  border-radius: 8px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.browse-btn:hover {
  background: #2563eb;
}

.file-name {
  margin-top: 12px;
  font-size: 0.9rem;
  color: #22c55e;
  font-weight: 500;
  word-break: break-all;
}

.extract-btn {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 14px;
  background: #3b82f6;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}

.extract-btn:hover:not(:disabled) {
  background: #2563eb;
}

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

.loading {
  display: none;
  text-align: center;
  margin-top: 24px;
}

.loading.active {
  display: block;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  margin: 0 auto 12px;
  animation: spin 0.8s linear infinite;
}

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

.loading p {
  color: #6b7280;
  font-size: 0.9rem;
}

.error-msg {
  display: none;
  margin-top: 16px;
  padding: 12px 16px;
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  color: #dc2626;
  font-size: 0.9rem;
}

.error-msg.active {
  display: block;
}

.results {
  display: none;
  margin-top: 24px;
}

.results.active {
  display: block;
}

.results h2 {
  font-size: 1.25rem;
  margin-bottom: 16px;
  color: #1a1a2e;
}

.result-card {
  background: #fff;
  border-radius: 10px;
  padding: 20px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.result-card h3 {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #6b7280;
  margin-bottom: 12px;
}

.field {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding: 8px 0;
  border-bottom: 1px solid #f1f5f9;
}

.field:last-child {
  border-bottom: none;
}

.field .label {
  font-size: 0.9rem;
  color: #64748b;
  flex-shrink: 0;
  margin-right: 16px;
}

.field .value {
  font-size: 0.9rem;
  font-weight: 500;
  color: #1e293b;
  text-align: right;
  word-break: break-word;
}

.employment-block {
  padding: 12px 0;
  border-bottom: 1px solid #f1f5f9;
}

.employment-block:last-child {
  border-bottom: none;
}

.employment-block .emp-name {
  font-weight: 600;
  font-size: 0.95rem;
  margin-bottom: 6px;
  color: #1e293b;
}

.employment-block .emp-detail {
  font-size: 0.85rem;
  color: #64748b;
  margin-top: 3px;
}

.confidence-bar {
  display: inline-block;
  width: 80px;
  height: 6px;
  background: #e2e8f0;
  border-radius: 3px;
  overflow: hidden;
  vertical-align: middle;
  margin-right: 8px;
}

.confidence-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
}

.meta-card .field .value {
  font-size: 0.85rem;
}

.total-field {
  border-top: 2px solid #e2e8f0;
  padding-top: 10px;
  margin-top: 4px;
}

.total-field .label,
.total-field .value {
  font-weight: 700;
  font-size: 1rem;
  color: #1a1a2e;
}

.no-items-msg {
  font-size: 0.9rem;
  color: #94a3b8;
  font-style: italic;
  padding: 8px 0;
}

.reset-btn {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 12px;
  background: #fff;
  color: #3b82f6;
  border: 2px solid #3b82f6;
  border-radius: 10px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.reset-btn:hover {
  background: #eff6ff;
}

.appraisal-image-wrap {
  text-align: center;
  margin-top: 8px;
}

.appraisal-image-wrap img {
  max-width: 100%;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

#appraisalMap {
  z-index: 1;
}

.editable-na {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #94a3b8;
  border-bottom: 1px dashed #cbd5e1;
  padding-bottom: 1px;
  transition: color 0.15s, border-color 0.15s;
}

.editable-na:hover {
  color: #3b82f6;
  border-bottom-color: #3b82f6;
}

.editable-na .edit-icon {
  opacity: 0.5;
  transition: opacity 0.15s;
}

.editable-na:hover .edit-icon {
  opacity: 1;
}

.editable-field {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding-bottom: 1px;
  transition: color 0.15s;
}

.editable-field .edit-icon {
  opacity: 0;
  transition: opacity 0.15s;
}

.editable-field:hover .edit-icon {
  opacity: 0.5;
}

.inline-edit-input {
  font-size: 0.9rem;
  padding: 4px 8px;
  border: 1px solid #3b82f6;
  border-radius: 4px;
  outline: none;
  width: 100%;
  max-width: 200px;
  background: #fff;
  color: #1a1a2e;
  box-shadow: 0 0 0 2px rgba(59,130,246,0.15);
}

#saveBar {
  position: fixed;
  top: 0;
  left: 240px;
  right: 0;
  background: #dc2626;
  color: #fff;
  padding: 14px 24px;
  display: none;
  align-items: center;
  justify-content: space-between;
  z-index: 1100;
  box-shadow: 0 2px 12px rgba(0,0,0,0.3);
  font-size: 0.95rem;
  font-weight: 600;
}

@media (max-width: 768px) {
  #saveBar {
    left: 56px;
  }
}

.save-bar-btn {
  padding: 8px 18px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  margin-left: 8px;
}

.save-bar-btn.cancel {
  background: rgba(255,255,255,0.2);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.4);
}

.save-bar-btn.cancel:hover {
  background: rgba(255,255,255,0.3);
}

.save-bar-btn.save {
  background: #fff;
  color: #dc2626;
}

.save-bar-btn.save:hover {
  background: #fee2e2;
}

.encrypted-toggle,
.dark-mode-toggle {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}
.encrypted-toggle {
  margin-top: auto;
}
.toggle-track {
  width: 38px;
  height: 20px;
  background: rgba(255,255,255,0.15);
  border-radius: 10px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.encrypted-toggle.active .toggle-track,
.dark-mode-toggle.active .toggle-track {
  background: #4a6cf7;
}
.toggle-dot {
  width: 16px;
  height: 16px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}
.toggle-label {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  font-weight: 500;
  white-space: nowrap;
}
.encrypted-badge {
  display: inline-block;
  background: #4a6cf7;
  color: #fff;
  font-size: 0.55rem;
  padding: 1px 5px;
  border-radius: 3px;
  margin-left: 4px;
  vertical-align: middle;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.sidebar-branding {
  padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.sidebar-branding span {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.25);
  font-weight: 500;
  letter-spacing: 0.3px;
}
