:root {
  color-scheme: light;
  --cream: #f4f5ef;
  --cream-2: #eaeee4;
  --ink: #07150f;
  --green: #003d25;
  --green-2: #072f20;
  --mint: #5df0a6;
  --gold: #d5b12d;
  --gold-2: #c5a223;
  --line: #cad0c3;
  --muted: #627064;
  --card: #ffffff;
  --shadow: 0 18px 42px rgba(10, 28, 20, 0.13);
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--ink);
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 44px;
  align-items: center;
  min-height: 58px;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(244, 245, 239, 0.96);
  backdrop-filter: blur(14px);
}

.brand-mark {
  color: var(--ink);
  font-size: 29px;
  font-weight: 950;
  letter-spacing: 0;
  text-align: center;
  text-decoration: none;
}

.header-icon {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
}

.header-icon:hover {
  background: #e5eadf;
}

.header-icon span {
  width: 19px;
  height: 2px;
  margin: 2px 0;
  border-radius: 999px;
  background: currentColor;
}

.logout-form {
  margin: 0;
}

.app-shell {
  min-height: calc(100vh - 58px);
  padding: 18px 14px 34px;
}

.workbench {
  width: min(1160px, 100%);
  margin: 0 auto;
}

.hero-panel {
  overflow: hidden;
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(0, 61, 37, 0.98), rgba(4, 39, 27, 0.96)),
    repeating-linear-gradient(135deg, transparent 0 18px, rgba(255, 255, 255, 0.03) 18px 19px);
  color: #f8fff9;
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 22px 18px 12px;
}

.eyebrow,
.section-label {
  margin: 0 0 9px;
  color: var(--gold);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  max-width: 760px;
  font-size: 44px;
  line-height: 0.92;
  letter-spacing: 0;
}

h2 {
  font-size: 32px;
  line-height: 1;
}

h3 {
  font-size: 19px;
}

.settings-panel {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(160px, 240px);
  gap: 10px;
  align-items: end;
  padding: 14px 18px 8px;
}

.settings-heading,
.prompt-field,
.settings-actions {
  grid-column: 1 / -1;
}

.settings-heading {
  display: grid;
  gap: 6px;
}

.settings-heading h2 {
  color: #f8fff9;
  font-size: 30px;
}

.settings-status {
  color: #d8ecdf;
  font-size: 13px;
  line-height: 1.4;
}

.field-block {
  display: grid;
  gap: 7px;
}

.field-block label {
  color: #d8ecdf;
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

input[type="password"],
input[type="text"],
textarea {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: var(--radius);
  outline: none;
  background: rgba(3, 31, 21, 0.88);
  color: #f8fff9;
}

input[type="password"],
input[type="text"] {
  min-height: 47px;
  padding: 0 13px;
}

textarea {
  min-height: 118px;
  resize: vertical;
  padding: 12px 13px;
  font: inherit;
  line-height: 1.45;
}

input[type="password"]:focus,
input[type="text"]:focus,
textarea:focus {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(93, 240, 166, 0.16);
}

.secret-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 64px;
  gap: 8px;
}

.text-toggle,
.secondary,
.primary-action {
  min-height: 45px;
  border-radius: var(--radius);
  font-weight: 900;
}

.text-toggle {
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.08);
  color: #f8fff9;
  font-size: 12px;
}

.field-hint {
  margin: 4px 0 0;
  font-size: 11px;
  line-height: 1.35;
  color: var(--muted);
}

.model-note {
  display: grid;
  gap: 2px;
  min-height: 47px;
  align-content: center;
  padding: 0 12px;
  border: 1px solid rgba(213, 177, 45, 0.4);
  border-radius: var(--radius);
  background: rgba(213, 177, 45, 0.12);
}

.model-note span {
  color: #f5df7f;
  font-family: Consolas, Monaco, monospace;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.model-note strong {
  color: #fff7bf;
  font-size: 15px;
}

.settings-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.search-form {
  display: grid;
  gap: 12px;
  padding: 14px 18px 18px;
}

.upload-zone {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  min-height: 156px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: var(--radius);
  background:
    linear-gradient(135deg, rgba(6, 42, 30, 0.62), rgba(10, 71, 45, 0.42)),
    linear-gradient(90deg, rgba(255, 255, 255, 0.08), transparent);
  outline: none;
}

.upload-zone:focus,
.upload-zone.is-dragging {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(93, 240, 166, 0.16);
}

.upload-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary {
  padding: 0 14px;
  border: 1px solid var(--green);
  background: #f7f7f0;
  color: var(--green);
}

.secondary:hover:not(:disabled) {
  background: #e9eee5;
}

.secondary.solid {
  border-color: var(--green);
  background: var(--green);
  color: #f8fff9;
}

.secondary.outline {
  background: transparent;
}

.primary-action {
  width: 100%;
  min-height: 54px;
  border: 1px solid #a88818;
  background: var(--gold);
  color: #09150e;
  box-shadow: inset 0 -2px rgba(0, 0, 0, 0.1);
}

.primary-action:hover:not(:disabled) {
  background: var(--gold-2);
}

.upload-preview {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(138px, 1fr));
  gap: 10px;
}

.upload-item,
.image-item {
  position: relative;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
}

.upload-item img,
.image-item img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: #f6f5ee;
}

.remove-image {
  position: absolute;
  top: 8px;
  right: 8px;
  min-height: 30px;
  padding: 0 9px;
  border-radius: 999px;
  background: rgba(0, 61, 37, 0.94);
  color: #f8fff9;
  font-size: 12px;
  font-weight: 900;
}

.status-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.progress-track {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: #dfe5d9;
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 0.2s ease;
}

.candidate-panel,
.final-panel,
.manifest-tool {
  margin-top: 26px;
}

.manifest-tool {
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
  box-shadow: 0 8px 20px rgba(10, 28, 20, 0.06);
}

.lookup-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 92px 120px;
  gap: 10px;
  margin-bottom: 14px;
}

.lookup-form input[type="text"],
.lookup-form input[type="number"] {
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.quantity-input {
  text-align: center;
}

.lookup-results {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}

@media (max-width: 1100px) {
  .lookup-results { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .lookup-results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .lookup-results { grid-template-columns: 1fr; }
}

.lookup-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-width: 0;
}

.lookup-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 10px;
  background: var(--green);
  color: #ffffff;
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.lookup-column-count {
  background: rgba(255, 255, 255, 0.18);
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 700;
}

.lookup-column-empty {
  padding: 14px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  font-size: 13px;
}

.lookup-card {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
}

.lookup-card:hover,
.lookup-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 61, 37, 0.12);
}

.lookup-thumb {
  display: inline-grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 6px;
  background: #eeeee6;
  overflow: hidden;
  color: var(--green);
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.lookup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.lookup-thumb.placeholder {
  background: linear-gradient(135deg, #eef3ec 0%, #d6e4d8 100%);
  border: 1px dashed rgba(0, 61, 37, 0.18);
}

.lookup-content {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.lookup-content strong {
  font-size: 13px;
  line-height: 1.25;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.lookup-content p {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.manifest-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.manifest-table-wrap {
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
}

.manifest-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 13px;
}

.manifest-table th,
.manifest-table td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.manifest-table th {
  position: sticky;
  top: 0;
  background: var(--green);
  color: #ffffff;
  font-size: 12px;
}

.manifest-table td:first-child,
.manifest-table td:nth-child(4) {
  text-align: center;
}

.manifest-thumb {
  display: inline-grid;
  place-items: center;
  width: 58px;
  height: 58px;
  overflow: hidden;
  border-radius: 6px;
  background: #f1f1ea;
}

.manifest-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.row-delete {
  min-height: 30px;
  padding: 0 9px;
  border-radius: var(--radius);
  background: #f1e7e5;
  color: #8f1c22;
  font-weight: 900;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.section-heading h2 {
  color: var(--ink);
}

.count-pill {
  min-width: 36px;
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--green);
  color: #f8fff9;
  text-align: center;
  font-weight: 950;
}

.filter-row {
  display: flex;
  gap: 9px;
  margin-bottom: 16px;
  overflow-x: auto;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 17px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fbfcf8;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.filter-chip.active {
  border-color: var(--green);
  background: var(--green);
  color: #f8fff9;
}

.candidate-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.candidate-card {
  display: grid;
  gap: 12px;
  width: 100%;
  min-width: 0;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
  color: var(--ink);
  text-align: left;
  box-shadow: 0 7px 18px rgba(10, 28, 20, 0.07);
}

.candidate-card:hover,
.candidate-card.selected {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 61, 37, 0.12);
}

.candidate-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  border-radius: 6px;
  background: #eeeee6;
}

.candidate-card strong {
  min-height: 48px;
  font-size: 17px;
  line-height: 1.28;
  overflow-wrap: anywhere;
}

.product-head {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
}

.product-head span {
  color: var(--muted);
  font-family: Consolas, Monaco, monospace;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.product-head strong {
  color: var(--green);
  font-size: 30px;
  line-height: 1.02;
  overflow-wrap: anywhere;
}

.final-layout {
  display: grid;
  grid-template-columns: minmax(250px, 360px) minmax(0, 1fr);
  gap: 16px;
}

.media-panel,
.description-panel {
  min-width: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
  box-shadow: 0 8px 20px rgba(10, 28, 20, 0.06);
}

.media-panel h3,
.description-panel h3 {
  margin-bottom: 12px;
}

.image-grid {
  display: grid;
  gap: 10px;
  max-height: 720px;
  overflow: auto;
  padding-right: 2px;
}

.description-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.output-text {
  width: 100%;
  min-height: 460px;
  max-height: 720px;
  margin: 0;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #ffffff;
  color: #18241c;
  white-space: pre-wrap;
  padding: 18px;
  font-family: Inter, Segoe UI, Roboto, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.68;
}

.final-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.empty-state {
  display: grid;
  min-height: 130px;
  place-items: center;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  color: var(--muted);
  text-align: center;
}

.is-error {
  color: #a52336;
}

.login-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.login-panel {
  width: min(460px, 100%);
  padding: 30px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #fbfcf8;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin-bottom: 10px;
  color: var(--green);
}

.login-copy {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
}

.login-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid rgba(165, 35, 54, 0.36);
  border-radius: var(--radius);
  background: rgba(165, 35, 54, 0.08);
  color: #8c1d2e;
  font-weight: 800;
}

.login-form {
  display: grid;
  gap: 10px;
}

.login-form label {
  color: var(--ink);
  font-size: 14px;
  font-weight: 850;
}

.login-form input {
  margin-bottom: 8px;
  border-color: var(--line);
  background: #ffffff;
  color: var(--ink);
}

.login-button {
  min-height: 52px;
  margin-top: 4px;
  border-radius: var(--radius);
  background: var(--gold);
  color: var(--ink);
  font-weight: 900;
}

.login-button:hover {
  background: var(--gold-2);
}

@media (min-width: 860px) {
  .app-shell {
    padding-top: 28px;
  }

  .hero-panel {
    display: grid;
    grid-template-columns: minmax(280px, 0.85fr) minmax(420px, 1.15fr);
    align-items: stretch;
  }

  .hero-copy {
    display: grid;
    align-content: end;
    min-height: 420px;
    padding: 34px;
  }

  h1 {
    font-size: 72px;
  }

  h2 {
    font-size: 44px;
  }

  .product-head strong {
    font-size: 40px;
  }

  .settings-panel,
  .search-form {
    grid-column: 2;
  }

  .settings-panel {
    padding-top: 24px;
  }

  .search-form {
    padding-bottom: 24px;
  }
}

@media (max-width: 760px) {
  .settings-panel,
  .settings-actions,
  .final-layout,
  .final-actions,
  .lookup-form,
  .manifest-actions {
    grid-template-columns: 1fr;
  }

  .settings-panel {
    padding-top: 8px;
  }

  .upload-zone {
    display: grid;
    min-height: 180px;
  }

  .upload-actions {
    justify-content: stretch;
  }

  .upload-actions button {
    width: 100%;
  }

  .candidate-list {
    grid-template-columns: 1fr;
  }

  .lookup-results {
    grid-template-columns: 1fr;
  }

  .candidate-card {
    grid-template-columns: 128px minmax(0, 1fr);
    align-items: center;
  }

  .candidate-card strong {
    min-height: auto;
  }

  .output-text {
    min-height: 360px;
  }
}

@media (max-width: 520px) {
  .app-shell {
    padding: 12px 8px 34px;
  }

  .hero-copy {
    padding: 20px 14px 10px;
  }

  .settings-panel,
  .search-form {
    padding-left: 14px;
    padding-right: 14px;
  }

  .upload-preview {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .candidate-card {
    grid-template-columns: 112px minmax(0, 1fr);
    padding: 8px;
  }

  .candidate-card strong {
    font-size: 15px;
  }

  .brand-mark {
    font-size: 22px;
  }

  h1 {
    font-size: 38px;
  }

  h2 {
    font-size: 28px;
  }

  .product-head strong {
    font-size: 24px;
  }
}
