:root {
  --bg: #f4f1e8;
  --panel: #fffaf0;
  --ink: #122035;
  --muted: #556070;
  --primary: #0b8a89;
  --accent: #da5b2f;
  --line: #1f2a3a;
  --ok: #1f8f4e;
  --shadow: 10px 10px 0 #1f2a3a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 10% 10%, #f6d8af 0%, transparent 36%),
    radial-gradient(circle at 90% 10%, #b4e4e2 0%, transparent 30%),
    linear-gradient(135deg, #f4f1e8 0%, #f0efe9 100%);
  font-family: "Source Han Serif SC", "Noto Serif SC", "Songti SC", serif;
  overflow-x: hidden;
}

.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.08;
  background-image:
    radial-gradient(#000 0.45px, transparent 0.45px),
    radial-gradient(#000 0.45px, transparent 0.45px);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

.layout {
  position: relative;
  width: min(1160px, calc(100vw - 16px));
  margin: 28px auto 40px;
  display: grid;
  gap: 18px;
}

.panel {
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
  padding: 18px;
}

.hero h1 {
  margin: 6px 0;
  font-size: clamp(34px, 5vw, 60px);
  letter-spacing: 1px;
}

.kicker {
  margin: 0;
  display: inline-block;
  padding: 4px 10px;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  border-radius: 999px;
}

.muted {
  color: var(--muted);
}

.small {
  font-size: 13px;
}

.whoami {
  margin-top: 12px;
  border: 1px dashed var(--line);
  padding: 10px;
  font-size: 14px;
  background: #fff;
  overflow-wrap: anywhere;
  word-break: break-all;
}

h2 {
  margin: 0 0 12px;
  font-size: 24px;
}

h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.grid.two {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.card {
  border: 2px solid var(--line);
  background: #fff;
  padding: 14px;
}

input,
select,
button {
  width: 100%;
  margin-top: 8px;
  border: 2px solid var(--line);
  border-radius: 0;
  padding: 12px 12px;
  font-size: 15px;
  font-family: inherit;
  background: #fff;
  color: var(--ink);
}

button {
  cursor: pointer;
  font-weight: 700;
  background: var(--primary);
  color: #fff;
  transition: transform 120ms ease, filter 120ms ease;
}

button:hover {
  transform: translate(-2px, -2px);
  filter: brightness(1.04);
}

button:active {
  transform: translate(0, 0);
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

.scan {
  display: grid;
  gap: 10px;
}

.scan-actions {
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 10px;
}

.hidden-file-input {
  display: none;
}

.secondary-btn {
  background: #fff;
  color: var(--primary);
}

.toolbar {
  display: grid;
  grid-template-columns: 2fr 1.1fr 1fr 1fr 0.9fr 0.9fr;
  gap: 10px;
  margin-bottom: 12px;
}

.mobile-toolbar-header {
  display: none;
}

.job-summary {
  border: 1px dashed var(--line);
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
  display: grid;
  gap: 8px;
}

.job-summary-title {
  font-size: 13px;
  font-weight: 700;
}

.job-summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.job-chip {
  display: inline-block;
  border: 1px solid var(--line);
  padding: 2px 7px;
  font-size: 12px;
  background: #f8fbfb;
}

.job-summary-meta {
  color: var(--muted);
  font-size: 12px;
  overflow-wrap: anywhere;
}

.table-wrap {
  overflow: auto;
  border: 2px solid var(--line);
  background: #fff;
}

.mobile-list {
  display: none;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 900px;
}

th,
td {
  border-bottom: 1px solid #d8dbe0;
  padding: 10px;
  text-align: left;
  vertical-align: top;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #f2f7f7;
}

.pre {
  max-width: 340px;
  white-space: pre-wrap;
  line-height: 1.45;
}

.ocr-result {
  display: grid;
  gap: 8px;
}

.ocr-engine {
  font-size: 12px;
  color: var(--muted);
}

.ocr-section {
  border: 1px solid #d8dbe0;
  background: #fafcfc;
  padding: 8px;
}

.ocr-title {
  margin-bottom: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #1f2a3a;
}

.ocr-pre {
  max-width: 440px;
}

.ocr-raw summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  user-select: none;
}

.ocr-raw[open] summary {
  margin-bottom: 6px;
}

.link {
  color: var(--accent);
  text-decoration: none;
  font-weight: 700;
}

.status-badge {
  display: inline-block;
  padding: 3px 8px;
  border: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.status-pending {
  background: #fff1c9;
}

.status-processing {
  background: #d7f3ff;
}

.status-completed {
  background: #d7f7e4;
}

.status-failed {
  background: #ffd9d9;
}

.action-btn {
  margin-top: 0;
  padding: 8px 10px;
  font-size: 13px;
  min-width: 78px;
}

.error-text {
  color: #b32020;
}

.mobile-card {
  border: 2px solid var(--line);
  background: #fff;
  box-shadow: 4px 4px 0 #1f2a3a;
  padding: 12px;
  display: grid;
  gap: 8px;
}

.mobile-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 10px;
  font-size: 12px;
  color: var(--muted);
}

.mobile-meta > div {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-row {
  display: grid;
  gap: 4px;
}

.mobile-label {
  font-size: 12px;
  color: var(--muted);
}

.mobile-value {
  font-size: 14px;
  white-space: pre-wrap;
  line-height: 1.45;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mobile-value .ocr-pre {
  max-width: none;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  background: var(--line);
  color: #fff;
  border: 2px solid #fff;
  padding: 10px 12px;
  display: none;
  z-index: 9;
}

.toast.show {
  display: block;
}

@media (max-width: 900px) {
  .grid.two,
  .scan,
  .toolbar {
    grid-template-columns: 1fr;
  }

  .layout {
    width: calc(100vw - 10px);
    margin-top: 14px;
    margin-bottom: 22px;
    gap: 12px;
  }

  .panel {
    padding: 14px;
    box-shadow: 5px 5px 0 #1f2a3a;
  }

  h2 {
    font-size: 21px;
  }

  .hero h1 {
    font-size: clamp(30px, 9vw, 42px);
  }

  input,
  select,
  button {
    min-height: 40px;
    font-size: 14px;
    padding: 9px 10px;
  }

  #btnOpenCamera,
  #btnOpenAlbum {
    min-height: 46px;
    font-size: 16px;
  }

  .scan {
    gap: 8px;
  }

  .scan-actions {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .toolbar {
    gap: 8px;
    margin-bottom: 0;
  }

  .scan-panel {
    order: 2 !important;
  }

  .tasks-panel {
    display: grid;
    gap: 10px;
    order: 3 !important;
  }

  .tasks-panel .job-summary {
    display: none;
  }

  .tasks-panel .mobile-toolbar-header {
    display: none;
  }

  .tasks-panel .toolbar {
    display: none;
    grid-template-columns: 1fr;
  }

  #btnExport {
    display: none;
  }

  .tasks-panel .mobile-list {
    order: 1;
  }

  .table-wrap {
    display: none;
  }

  .mobile-list {
    display: grid;
    gap: 10px;
  }

  .toast {
    left: 10px;
    right: 10px;
    bottom: 10px;
  }
}
