:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #15181d;
  --muted: #667085;
  --line: #d8dee8;
  --field: #fbfcfe;
  --blue: #1d5fd1;
  --green: #0c8f62;
  --red: #c2362b;
  --gold: #a66b00;
  --shadow: 0 18px 45px rgba(23, 32, 51, 0.08);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(180deg, #ffffff 0, var(--bg) 42%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

.shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 40px 0;
}

.lookup-panel,
.result-card,
.empty-state {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.lookup-panel {
  padding: 24px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 3.4rem);
  line-height: 1;
  letter-spacing: 0;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

.status-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--green);
}

.status-pill.loading .status-dot {
  background: var(--gold);
}

.status-pill.error .status-dot {
  background: var(--red);
}

.lookup-form {
  display: grid;
  gap: 20px;
}

.company-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 0;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #eef2f7;
}

.company-control legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.company-control label {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: 6px;
  color: #384150;
  font-weight: 700;
  cursor: pointer;
}

.company-control input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.company-control input:checked + span {
  color: var(--ink);
}

.company-control label:has(input:checked) {
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(18, 31, 53, 0.1);
}

.form-grid {
  display: grid;
  grid-template-columns: 230px minmax(0, 1fr) 170px 136px;
  gap: 12px;
  align-items: end;
}

.company-select {
  min-width: 0;
}

.input-group {
  display: grid;
  gap: 7px;
}

.input-group span {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--field);
  color: var(--ink);
  padding: 0 13px;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(29, 95, 209, 0.14);
}

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  border: 0;
  border-radius: 6px;
  background: var(--ink);
  color: #ffffff;
  font-weight: 800;
  cursor: pointer;
}

.submit-button svg {
  width: 19px;
  height: 19px;
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
}

.results-area {
  margin-top: 18px;
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 260px;
  padding: 32px;
  color: var(--muted);
  text-align: center;
}

.empty-state svg {
  width: 42px;
  height: 42px;
  color: var(--blue);
}

.result-card {
  padding: 22px;
}

.hidden {
  display: none;
}

.result-topline {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.result-title {
  margin: 0;
  font-size: 1.35rem;
  line-height: 1.2;
  letter-spacing: 0;
}

.result-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.badge.found {
  background: #e7f6ee;
  color: var(--green);
}

.badge.manual {
  background: #fff4df;
  color: var(--gold);
}

.badge.not_found,
.badge.error {
  background: #fdeceb;
  color: var(--red);
}

.message {
  margin: 0 0 18px;
  color: #344054;
}

.field-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 0;
}

.field {
  min-height: 70px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fbfcfe;
}

.field dt {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

.field dd {
  margin: 0;
  overflow-wrap: anywhere;
  color: var(--ink);
  font-weight: 650;
}

.image-field {
  grid-row: span 2;
}

.image-field dd {
  font-weight: 400;
}

.image-link {
  display: block;
  width: fit-content;
  max-width: 100%;
}

.image-preview {
  display: block;
  width: min(100%, 260px);
  max-height: 340px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #ffffff;
}

.source-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.source-row a {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--blue);
  font-weight: 800;
  text-decoration: none;
}

.source-row a:hover {
  text-decoration: underline;
}

.timestamp {
  color: var(--muted);
  font-size: 0.82rem;
}

@media (max-width: 760px) {
  .shell {
    width: min(100% - 20px, 1120px);
    padding: 16px 0;
  }

  .lookup-panel,
  .result-card {
    padding: 16px;
  }

  .panel-heading,
  .result-topline,
  .source-row {
    flex-direction: column;
    align-items: stretch;
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .company-control {
    grid-template-columns: 1fr;
  }

  .field-list {
    grid-template-columns: 1fr;
  }
}
