:root {
  --app-bg: #f4f7fb;
  --app-border: #e5eaf0;
  --app-muted: #667085;
  --app-navy: #0b1f3a;
}

* { box-sizing: border-box; }

body {
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(13,110,253,.08), transparent 30rem),
    var(--app-bg);
  color: #172033;
}

.min-w-0 { min-width: 0; }

.app-header {
  background: linear-gradient(135deg, #0b1f3a, #0d6efd);
  color: #fff;
  box-shadow: 0 6px 24px rgba(11,31,58,.18);
}

.brand-logo {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255,255,255,.14);
  border: 1px solid rgba(255,255,255,.18);
  font-size: 1.4rem;
  flex: 0 0 auto;
}

.header-meta { white-space: nowrap; }

.app-card {
  border: 1px solid var(--app-border);
  border-radius: 18px;
  box-shadow: 0 10px 30px rgba(16,24,40,.06);
  overflow: hidden;
}

.eyebrow {
  display: block;
  color: #0d6efd;
  font-weight: 800;
  font-size: .7rem;
  letter-spacing: .12em;
  margin-bottom: .25rem;
}

.upload-panel {
  border: 2px dashed #b8c9e6;
  border-radius: 18px;
  padding: 2rem 1rem;
  background: linear-gradient(180deg, rgba(13,110,253,.035), rgba(255,255,255,.7));
}

.upload-panel.dragover {
  border-color: #0d6efd;
  background: rgba(13,110,253,.08);
}

.upload-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 22px;
  background: #eaf2ff;
  color: #0d6efd;
  font-size: 2rem;
}

.upload-help { max-width: 520px; }

.action-btn {
  min-height: 52px;
  font-weight: 700;
  border-radius: 12px;
}

.processing-panel {
  border-radius: 14px;
  border: 1px solid #dbe6f5;
  background: #f8fbff;
  padding: 1rem;
}

.progress { height: 10px; border-radius: 999px; }

.preview-card {
  border: 1px solid var(--app-border);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
}

.preview-toolbar {
  padding: .85rem 1rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--app-border);
}

.preview-frame {
  aspect-ratio: 4 / 3;
  background:
    linear-gradient(45deg, #f4f4f4 25%, transparent 25%),
    linear-gradient(-45deg, #f4f4f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #f4f4f4 75%),
    linear-gradient(-45deg, transparent 75%, #f4f4f4 75%);
  background-size: 22px 22px;
  background-position: 0 0, 0 11px, 11px -11px, -11px 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.preview-frame img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.form-control, .btn { border-radius: 11px; }

.form-control-lg { min-height: 50px; font-size: 1rem; }

.confidence-badge {
  font-size: .76rem;
  font-weight: 700;
  padding: .3rem .55rem;
  border-radius: 999px;
}

.confidence-high { color: #087443; background: #dff7ea; }
.confidence-medium { color: #8a5c00; background: #fff2c7; }
.confidence-low { color: #b42318; background: #fee4e2; }

.field-low .form-control {
  border-color: #dc3545;
  box-shadow: 0 0 0 .2rem rgba(220,53,69,.08);
}

.ocr-raw pre {
  max-height: 190px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  background: #111827;
  color: #d1e7ff;
  border-radius: 10px;
  padding: .8rem;
  font-size: .78rem;
}

.search-box {
  position: relative;
  width: min(100%, 370px);
}
.search-box i {
  position: absolute;
  left: .9rem;
  top: 50%;
  transform: translateY(-50%);
  color: #98a2b3;
  pointer-events: none;
}
.search-box .form-control { padding-left: 2.55rem; }

.table thead th {
  color: #667085;
  font-size: .76rem;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom-width: 1px;
}

.history-mobile-card {
  border: 1px solid var(--app-border);
  border-radius: 14px;
  padding: 1rem;
  margin-bottom: .75rem;
  background: #fff;
}

.history-mobile-card .label {
  color: var(--app-muted);
  font-size: .75rem;
}

.empty-state { color: #667085; }

.summary-list {
  display: grid;
  gap: .65rem;
}
.summary-list > div {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding-bottom: .65rem;
  border-bottom: 1px solid var(--app-border);
}
.summary-list > div:last-child { border-bottom: 0; padding-bottom: 0; }
.summary-list span { color: #667085; }
.summary-list strong { text-align: right; overflow-wrap: anywhere; }

.success-icon {
  width: 76px;
  height: 76px;
  margin: 0 auto;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #dff7ea;
  color: #198754;
  font-size: 2.3rem;
}

.image-stage {
  overflow: hidden;
  padding: 0;
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.image-stage:active { cursor: grabbing; }

.image-stage img {
  max-width: 92vw;
  max-height: calc(100vh - 140px);
  transform-origin: center;
  will-change: transform;
  user-select: none;
  pointer-events: none;
}

@media (max-width: 575.98px) {
  .header-meta { display: none; }
  main.container { padding-left: .75rem; padding-right: .75rem; }
  .app-card { border-radius: 14px; }
  .upload-panel { padding: 1.5rem .85rem; }
  .upload-icon { width: 62px; height: 62px; border-radius: 18px; }
  .preview-frame { aspect-ratio: 1 / 1; }
  .btn-lg { font-size: 1rem; }
}

@media (min-width: 992px) {
  .app-card .card-body { padding: 1.75rem !important; }
}
