:root {
  --bg: #0e1114;
  --bg-elevated: #161b20;
  --bg-row: #1a2026;
  --border: #2a323a;
  --text: #e6eaee;
  --text-muted: #8b959e;
  --accent: #3d8f8f;
  --accent-hover: #4aa3a3;
  --danger: #c45c5c;
  --ok: #5a9e6f;
  --warn: #b8943f;
  --input-bg: #0c0f12;
  --font: "IBM Plex Sans", "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", "Consolas", monospace;
  --radius: 4px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.45;
}

body {
  background-image:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(61, 143, 143, 0.08), transparent),
    linear-gradient(180deg, #101418 0%, var(--bg) 40%);
}

a {
  color: var(--accent);
}

.app-shell {
  max-width: 920px;
  margin: 0 auto;
  padding: 2.5rem 1.5rem 4rem;
}

.app-shell.wide {
  max-width: 1100px;
}

.app-shell.narrow {
  max-width: 420px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-muted);
  font-size: 0.8rem;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
  background: none;
  text-decoration: underline;
}

/* Upload */
.field-group .dropzone {
  display: flex;
  margin: 0;
  font-size: inherit;
  color: var(--text);
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
  padding: 2rem 1rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  background: var(--input-bg);
  cursor: pointer;
  text-align: center;
  transition: border-color 120ms ease, background 120ms ease;
}

.field-group .dropzone:hover,
.field-group .dropzone.over {
  border-color: var(--accent);
  background: #0f1518;
}

.dropzone-title {
  font-size: 0.95rem;
}

.dropzone-hint {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.file-list {
  list-style: none;
  margin: 0.75rem 0 0;
  padding: 0;
  font-family: var(--mono);
  font-size: 0.8rem;
}

.file-list:empty {
  display: none;
}

.file-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.35rem 0.5rem;
  border-bottom: 1px solid var(--border);
}

.file-list li:last-child {
  border-bottom: none;
}

.file-list .name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-list .size {
  color: var(--text-muted);
  flex-shrink: 0;
}

.footnote {
  margin-top: 1.25rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

a.btn {
  display: inline-block;
  text-decoration: none;
}

a.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #061212;
  font-weight: 550;
}

a.btn.primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.brand {
  font-size: 0.75rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

h1 {
  font-size: 1.65rem;
  font-weight: 500;
  margin: 0 0 0.35rem;
  letter-spacing: -0.02em;
}

.lede {
  color: var(--text-muted);
  margin: 0 0 2rem;
  max-width: 36rem;
}

.panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
}

.field-group {
  margin-bottom: 1.25rem;
}

.field-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.path-row {
  display: flex;
  gap: 0.5rem;
}

.path-row input[type="text"] {
  flex: 1;
}

input[type="text"],
input[type="search"],
textarea {
  width: 100%;
  background: var(--input-bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius);
  padding: 0.55rem 0.7rem;
  font: inherit;
}

input[type="text"]:focus,
textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.checkbox-row {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  margin: 1.5rem 0 1.75rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.checkbox-row input {
  margin-top: 0.2rem;
  accent-color: var(--accent);
}

.actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

button,
.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--bg-row);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.55rem 1rem;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

button:hover:not(:disabled),
.btn:hover:not(:disabled) {
  border-color: #3d4854;
  background: #222a32;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #061212;
  font-weight: 550;
}

button.primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

button:disabled,
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.error-banner {
  display: none;
  margin-bottom: 1rem;
  padding: 0.7rem 0.9rem;
  border: 1px solid var(--danger);
  background: rgba(196, 92, 92, 0.12);
  color: #efc0c0;
  border-radius: var(--radius);
  font-size: 0.9rem;
}

.error-banner.show {
  display: block;
}

/* Progress */
.meta-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
  font-size: 0.85rem;
}

.meta-bar .meta-left {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.75rem 1.25rem;
}

.meta-bar .review-btn {
  flex-shrink: 0;
}

.review-btn.ready:not(:disabled) {
  box-shadow: 0 0 0 1px rgba(61, 143, 143, 0.55), 0 0 18px rgba(61, 143, 143, 0.28);
}

.progress-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-elevated);
}

.progress-list li {
  display: grid;
  grid-template-columns: 2.5rem 1fr auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.65rem 0.9rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg-row);
  opacity: 0.55;
  transition: opacity 160ms ease, background 160ms ease;
}

.progress-list li:last-child {
  border-bottom: none;
}

.progress-list li.active {
  opacity: 1;
  background: #1e262e;
}

.progress-list li.done {
  opacity: 1;
}

.progress-list li.error {
  opacity: 1;
}

.progress-list .idx {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  font-size: 0.8rem;
}

.progress-list .name {
  font-family: var(--mono);
  font-size: 0.82rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-list .status {
  font-size: 0.75rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.progress-list li.done .status {
  color: var(--ok);
}

.progress-list li.active .status {
  color: var(--accent);
}

.progress-list li.error .status {
  color: var(--danger);
}

.progress-list li.error .status-btn {
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  border-radius: 2px;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.25rem;
}

.progress-list li.error .status-btn:hover,
.progress-list li.error .status-btn:focus-visible {
  color: #efc0c0;
  outline: none;
  background: rgba(196, 92, 92, 0.16);
}

body.modal-open {
  overflow: hidden;
}

.error-modal[hidden] {
  display: none;
}

.error-modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
}

.error-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(6, 8, 10, 0.72);
}

.error-modal-panel {
  position: relative;
  width: min(36rem, 100%);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.35rem 1.4rem 1.2rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45);
}

.error-modal-panel h2 {
  font-size: 1.2rem;
  font-weight: 500;
  margin: 0 0 0.65rem;
}

.error-modal-file {
  margin: 0 0 0.75rem;
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--text-muted);
  word-break: break-all;
}

.error-modal-msg {
  margin: 0;
  max-height: 40vh;
  overflow: auto;
  padding: 0.75rem 0.85rem;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: #efc0c0;
  font-family: var(--mono);
  font-size: 0.8rem;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}

.error-modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 1rem;
}

.footer-bar {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
  margin-top: 1.25rem;
}

/* Verify */
.verify-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 1rem;
  margin-bottom: 1rem;
}

.verify-header .file-label {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.full-check {
  width: 100%;
  max-height: 220px;
  object-fit: contain;
  background: #090b0d;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 1rem;
}

.verify-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.verify-table th {
  text-align: left;
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
  background: #12171c;
}

.verify-table td {
  padding: 0.55rem 0.85rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.verify-table tr:last-child td {
  border-bottom: none;
}

.verify-table .field-label {
  width: 11rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.verify-table .crop-cell {
  width: 26rem;
  min-width: 16rem;
}

.verify-table .crop-cell img {
  display: block;
  width: auto;
  max-width: 100%;
  height: auto;
  max-height: 120px;
  min-height: 72px;
  object-fit: contain;
  object-position: left center;
  background: #fff;
  border: 1px solid var(--border);
  image-rendering: auto;
}

.verify-table .crop-cell .no-crop {
  display: inline-block;
  color: var(--text-muted);
  font-size: 0.78rem;
  font-style: italic;
}

.verify-table input {
  font-family: var(--mono);
  font-size: 0.85rem;
}

.verify-footer {
  position: sticky;
  bottom: 0;
  margin-top: 1.25rem;
  padding: 0.9rem 0;
  background: linear-gradient(180deg, transparent, var(--bg) 30%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
}

.done-panel {
  display: none;
  margin-top: 1.5rem;
}

.done-panel.show {
  display: block;
}

.done-panel code {
  font-family: var(--mono);
  font-size: 0.82rem;
  color: var(--accent);
  word-break: break-all;
}

.done-panel p {
  margin: 0.4rem 0;
  color: var(--text-muted);
}
