:root {
  --bg: #0b1220;
  --panel: #131b2e;
  --border: #232d44;
  --text: #e7ecf5;
  --muted: #8b95ab;
  --accent: #2f5d9f;
  --accent-2: #4d7fc9;
  --ok: #34d399;
  --bad: #f87171;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  min-height: 100dvh;
  line-height: 1.4;
  padding-bottom: env(safe-area-inset-bottom);
}

header {
  width: min(100%, 680px);
  margin: 0 auto;
  padding: 28px 20px 14px;
  text-align: center;
}

header .logo {
  display: block;
  height: 34px;
  max-width: min(300px, 82vw);
  width: auto;
  margin: 0 auto 14px;
}

header h1 {
  font-size: 24px;
  line-height: 1.15;
  margin: 0 0 6px;
}

header p {
  margin: 0 auto;
  max-width: 420px;
  color: var(--muted);
  font-size: 14px;
}

main {
  width: min(100%, 680px);
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: 14px 20px 36px;
  gap: 18px;
}

.details-form {
  width: 100%;
  max-width: 520px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: left;
}

.field label {
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
}

.field textarea {
  resize: vertical;
  min-height: 90px;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  outline: none;
  border-color: var(--accent-2);
}

.capture-btn {
  width: 100%;
  min-height: 58px;
  padding: 16px 20px;
  border-radius: 8px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  font-size: 17px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(47, 93, 159, 0.35);
}

.capture-btn:active {
  transform: scale(0.98);
}

.capture-btn svg {
  width: 24px;
  height: 24px;
}

.status {
  min-height: 22px;
  font-size: 13.5px;
  color: var(--muted);
  text-align: center;
  overflow-wrap: anywhere;
}

.status.ok { color: var(--ok); }
.status.bad { color: var(--bad); }

.grid {
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 10px;
}

.item {
  position: relative;
  aspect-ratio: 1;
  border-radius: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border);
}

.item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.item .badge {
  position: absolute;
  right: 6px;
  bottom: 6px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  background: var(--muted);
}

.item.pending .badge {
  background: var(--accent-2);
}

.item.done .badge { background: var(--ok); }
.item.error .badge { background: var(--bad); }

.item .badge.spin {
  border: 2px solid rgba(255, 255, 255, 0.4);
  border-top-color: #fff;
  background: transparent;
  animation: spin 0.8s linear infinite;
}

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

.empty {
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  margin-top: 8px;
}

input[type="file"] { display: none; }

@media (max-width: 420px) {
  header {
    padding: 18px 16px 10px;
  }

  header .logo {
    height: 28px;
    margin-bottom: 10px;
  }

  header h1 {
    font-size: 20px;
  }

  main {
    padding: 10px 16px 28px;
    gap: 14px;
  }

  .details-form {
    gap: 12px;
  }

  .grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
  }
}
