:root {
  color-scheme: light;
  --ink: #18212f;
  --muted: #667085;
  --line: #d7dee8;
  --panel: #ffffff;
  --page: #eef2f5;
  --soft: #f7f9fc;
  --blue: #175cd3;
  --blue-soft: #edf4ff;
  --green: #167447;
  --green-soft: #ecfdf3;
  --amber: #b54708;
  --amber-soft: #fff7ed;
  --red: #b42318;
  --red-soft: #fff1f0;
  --shadow: 0 14px 30px rgba(20, 33, 54, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-width: 320px;
  background: var(--page);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.app-shell {
  min-height: 100vh;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 1640px;
  margin: 0 auto 14px;
}

.topbar-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.topbar-brand img {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  border: 1px solid rgba(24, 33, 47, 0.12);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 8px 18px rgba(20, 33, 54, 0.12);
}

.topbar h1,
.panel h2,
.form-section h3,
.packet-section h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 28px;
  line-height: 1.1;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

.status-strip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: #344054;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

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

.status-dot.ready {
  background: var(--green);
}

.status-dot.review,
.status-dot.working {
  background: var(--amber);
}

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

.view-tabs {
  display: flex;
  gap: 8px;
  max-width: 1640px;
  margin: 0 auto 14px;
  border-bottom: 1px solid var(--line);
}

.view-tabs button {
  min-height: 40px;
  border: 1px solid transparent;
  border-bottom: 0;
  border-radius: 8px 8px 0 0;
  background: transparent;
  color: #344054;
  padding: 0 14px;
  font-size: 13px;
  font-weight: 800;
}

.view-tabs button[aria-selected="true"] {
  border-color: var(--line);
  background: var(--panel);
  color: var(--blue);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(420px, 1.08fr) minmax(360px, 0.9fr) minmax(440px, 1.08fr);
  gap: 14px;
  max-width: 1640px;
  margin: 0 auto;
  align-items: start;
}

.workspace.importer-workspace {
  grid-template-columns: minmax(360px, 0.9fr) minmax(520px, 1.1fr);
}

.workspace.broker-workspace {
  grid-template-columns: 1fr;
  max-width: 1280px;
}

.document-intake {
  max-width: 980px;
  margin: 64px auto 0;
}

.document-intake.compact {
  max-width: 1640px;
  margin: 0 auto 14px;
}

.document-panel {
  overflow: hidden;
}

.document-intake.compact .upload-dropzone {
  min-height: 128px;
}

.upload-dropzone {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 260px;
  margin: 18px;
  border: 1px dashed #9fb2cc;
  border-radius: 8px;
  background: #f8fbff;
  color: #344054;
  text-align: center;
  cursor: pointer;
}

.upload-dropzone.dragging,
.upload-dropzone:hover {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.upload-dropzone input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.upload-dropzone strong {
  font-size: 18px;
}

.upload-dropzone span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.typed-upload-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0 18px 18px;
}

.typed-upload-grid input {
  min-height: 42px;
  padding: 8px;
}

.document-meta {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 0 18px 18px;
}

.document-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.document-list li {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 6px 9px;
  font-size: 12px;
}

.document-list strong {
  max-width: 240px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.document-list span,
.extraction-status {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.extraction-status {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  padding: 8px 10px;
  white-space: nowrap;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 66px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.panel h2 {
  font-size: 18px;
  line-height: 1.2;
}

.panel-note {
  max-width: 620px;
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.35;
}

.form-section {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.form-section:last-child {
  border-bottom: 0;
}

.form-section h3,
.packet-section h3 {
  margin-bottom: 10px;
  color: #344054;
  font-size: 13px;
}

.section-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.section-row h3 {
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px 12px;
}

label {
  display: grid;
  gap: 6px;
  min-width: 0;
  color: #344054;
  font-size: 12px;
  font-weight: 700;
}

.span-2 {
  grid-column: span 2;
}

input,
textarea,
select {
  width: 100%;
  min-height: 38px;
  border: 1px solid #cbd5df;
  border-radius: 6px;
  background: #fff;
  color: var(--ink);
  padding: 8px 10px;
  outline: none;
  font: inherit;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(23, 92, 211, 0.12);
}

textarea {
  min-height: 54px;
  resize: vertical;
  line-height: 1.4;
}

.ghost-button,
.icon-button,
.primary-button,
.chat-compose button,
.question-row button {
  min-height: 36px;
  border-radius: 6px;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 700;
}

.ghost-button,
.icon-button,
.question-row button {
  border: 1px solid var(--line);
  background: #f8fafc;
  color: #344054;
}

.ghost-button:hover:not(:disabled),
.icon-button:hover:not(:disabled),
.question-row button:hover {
  background: #edf2f7;
}

.primary-button,
.chat-compose button {
  background: var(--blue);
  color: #fff;
}

.primary-button:hover:not(:disabled),
.chat-compose button:hover {
  background: #1249a8;
}

.line-items {
  display: grid;
  gap: 10px;
}

.line-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}

.line-card header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.line-card header strong {
  font-size: 13px;
}

.line-card .form-grid {
  padding: 12px;
}

.chat-panel {
  order: 1;
  min-height: calc(100vh - 120px);
}

.intake-panel {
  order: 2;
}

.packet-panel {
  order: 3;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 10px;
  height: min(520px, calc(100vh - 360px));
  min-height: 380px;
  overflow: auto;
  padding: 16px;
  background: linear-gradient(#fbfcfe, #f5f8fb);
}

.shipment-status-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.shipment-status-grid div {
  min-width: 0;
  padding: 12px;
  border-right: 1px solid var(--line);
}

.shipment-status-grid div:last-child {
  border-right: 0;
}

.shipment-status-grid span,
.shipment-status-grid strong {
  display: block;
}

.shipment-status-grid span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.shipment-status-grid strong {
  margin-top: 4px;
  font-size: 13px;
  overflow-wrap: anywhere;
}

.message {
  max-width: 90%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: #fff;
  line-height: 1.45;
  font-size: 14px;
}

.message.importer {
  align-self: flex-end;
  border-color: #b7c7e8;
  background: var(--blue-soft);
}

.message.system {
  align-self: flex-start;
}

.message strong {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
}

.chat-compose {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px 16px 10px;
  border-top: 1px solid var(--line);
}

.question-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 16px 16px;
}

.question-row .next-button {
  border-color: #b7c7e8;
  background: var(--blue-soft);
  color: #123b7a;
}

.fact-editor-section {
  background: #fff;
}

.facts-editor {
  display: grid;
  gap: 8px;
}

.fact-row {
  display: grid;
  grid-template-columns: minmax(122px, 0.55fr) minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.fact-row strong,
.fact-row span,
.fact-control small {
  display: block;
}

.fact-row strong {
  color: #344054;
  font-size: 13px;
}

.fact-row span,
.fact-control small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.fact-control {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.evidence-section {
  background: #fcfdff;
}

.packet-panel {
  position: sticky;
  top: 18px;
  max-height: calc(100vh - 36px);
  overflow: auto;
}

.broker-workspace .packet-panel {
  position: static;
  max-height: none;
}

.packet-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-bottom: 1px solid var(--line);
}

.metric {
  min-width: 0;
  padding: 14px 12px;
  border-right: 1px solid var(--line);
}

.metric:last-child {
  border-right: 0;
}

.metric span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.metric strong {
  display: block;
  margin-top: 5px;
  font-size: 14px;
  word-break: break-word;
}

.packet-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}

.broker-actions-section {
  background: #fcfdff;
}

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

.broker-button-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.error-box {
  margin: 12px 16px 0;
  border: 1px solid #f2b8b5;
  border-left: 4px solid var(--red);
  border-radius: 6px;
  background: var(--red-soft);
  color: #7a271a;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.45;
}

.packet-section {
  padding: 15px 16px;
  border-bottom: 1px solid var(--line);
}

.packet-section:last-child {
  border-bottom: 0;
}

dl {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 8px 12px;
  margin: 0;
  font-size: 13px;
}

dt {
  color: var(--muted);
  font-weight: 700;
}

dd {
  margin: 0;
  word-break: break-word;
}

.review-list,
.issue-list,
.evidence-list,
.audit-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
}

.review-list li,
.issue-list li,
.evidence-list li,
.audit-list li {
  border-left: 4px solid var(--amber);
  border-radius: 6px;
  background: var(--amber-soft);
  padding: 9px 10px;
}

.review-list li strong,
.issue-list li strong,
.evidence-list li strong,
.audit-list li strong {
  display: block;
  margin-bottom: 3px;
  text-transform: none;
}

.review-list li p {
  margin: 0 0 4px;
}

.review-list li span {
  color: #7a4d00;
  font-size: 12px;
}

.evidence-list li {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.audit-list li {
  border-color: var(--green);
  background: var(--green-soft);
}

.audit-list span,
.audit-list small,
.audit-list p {
  display: block;
  margin: 2px 0 0;
  overflow-wrap: anywhere;
}

.audit-list small {
  color: var(--muted);
  font-weight: 700;
}

.issue-list li.ok {
  border-color: var(--green);
  background: var(--green-soft);
}

.issue-list li.fatal {
  border-color: var(--red);
  background: var(--red-soft);
}

.issue-list li.warning {
  border-color: var(--amber);
  background: var(--amber-soft);
}

.issue-list li.info {
  border-color: var(--blue);
  background: var(--blue-soft);
}

.preview-section {
  padding-bottom: 16px;
}

#packet-frame {
  display: block;
  width: 100%;
  height: 520px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

body.landing-page {
  background: #f4f0e8;
  color: #15201f;
}

.landing-page main {
  min-height: 100dvh;
  background: #f4f0e8;
}

.landing-hero {
  position: relative;
  height: clamp(560px, 92dvh, 920px);
  overflow: hidden;
  background: #15201f;
}

.landing-hero-image {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 66% 54%;
  filter: brightness(0.78) saturate(1.08) contrast(1.05);
  transform: scale(1.12);
  transform-origin: 66% 54%;
}

.landing-hero-overlay {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(8, 18, 21, 0.5), rgba(10, 27, 31, 0.58) 48%, rgba(10, 14, 14, 0.96)),
    linear-gradient(90deg, rgba(93, 47, 21, 0.44), rgba(6, 53, 62, 0.3) 56%, rgba(3, 10, 12, 0.28));
}

.landing-hero-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.landing-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 38px 40px 0;
}

.landing-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: #fff;
  text-decoration: none;
  font-size: 26px;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 14px rgba(0, 0, 0, 0.34);
}

.landing-brand-logo {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 8px;
  object-fit: cover;
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(10px);
}

.landing-copy {
  display: flex;
  flex: 1;
  flex-direction: column;
  justify-content: flex-end;
  width: min(100%, 820px);
  margin: 0 auto;
  padding: 46px 40px 82px;
}

.landing-copy h1 {
  margin: 0;
  color: #fff;
  font-size: 64px;
  font-weight: 500;
  letter-spacing: 0;
  line-height: 1.06;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.38);
}

.landing-copy h1 span:not(.sr-only) {
  display: inline-block;
  color: #ffe0ad;
}

.landing-copy p {
  max-width: 620px;
  margin: 22px 0 0;
  color: rgba(255, 255, 255, 0.9);
  font-size: 19px;
  line-height: 1.6;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.32);
}

.landing-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 18px 26px;
  margin-top: 32px;
}

.landing-primary-link {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: #ffe0ad;
  text-decoration: none;
  font-size: 14px;
  font-weight: 800;
  text-transform: uppercase;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.34);
}

.landing-primary-link:hover {
  color: #fff;
}

.landing-primary-link span:first-child {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
}

.landing-actions p {
  margin: 0;
  color: rgba(255, 224, 173, 0.92);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.landing-proof {
  border-top: 1px solid rgba(111, 77, 42, 0.18);
  background: linear-gradient(180deg, #f4f0e8, #e8f0ee);
}

.landing-proof-inner {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 64px 40px 72px;
}

.landing-proof-heading {
  display: grid;
  grid-template-columns: minmax(180px, 0.42fr) minmax(0, 1fr);
  gap: 34px;
  align-items: start;
}

.landing-kicker {
  margin: 7px 0 0;
  color: #94611d;
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.landing-proof h2 {
  margin: 0;
  max-width: 780px;
  color: #15201f;
  font-size: 34px;
  font-weight: 650;
  letter-spacing: 0;
  line-height: 1.14;
}

.landing-proof-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 28px;
  margin-top: 46px;
}

.landing-proof-grid article {
  min-width: 0;
  border-top: 1px solid rgba(21, 32, 31, 0.22);
  padding-top: 18px;
}

.landing-proof-grid span {
  display: block;
  color: #94611d;
  font-size: 13px;
  font-weight: 800;
}

.landing-proof-grid h3 {
  margin: 14px 0 0;
  color: #15201f;
  font-size: 18px;
  line-height: 1.25;
}

.landing-proof-grid p {
  margin: 10px 0 0;
  color: #4f5f5d;
  font-size: 15px;
  line-height: 1.55;
}

.landing-secondary-link {
  display: inline-flex;
  margin-top: 38px;
  color: #0b5f6b;
  font-size: 15px;
  font-weight: 800;
  text-decoration: none;
}

.landing-secondary-link:hover {
  color: #083f47;
}

@media (max-width: 1340px) {
  .workspace {
    grid-template-columns: minmax(360px, 1fr) minmax(360px, 1fr);
  }

  .workspace.broker-workspace {
    grid-template-columns: 1fr;
  }

  .packet-panel {
    position: static;
    grid-column: span 2;
    max-height: none;
  }

  .broker-workspace .packet-panel {
    grid-column: auto;
  }
}

@media (max-width: 920px) {
  .landing-copy h1 {
    font-size: 52px;
  }

  .landing-proof-heading,
  .landing-proof-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 820px) {
  .app-shell {
    padding: 12px;
  }

  .topbar,
  .workspace,
  .form-grid,
  .fact-row,
  .packet-summary,
  .shipment-status-grid,
  .chat-compose {
    grid-template-columns: 1fr;
  }

  .topbar,
  .workspace,
  .chat-compose {
    display: grid;
  }

  .view-tabs {
    overflow-x: auto;
  }

  .view-tabs button {
    flex: 1 0 148px;
  }

  .status-strip {
    justify-content: flex-start;
    white-space: normal;
  }

  .document-intake {
    margin-top: 18px;
  }

  .document-meta {
    grid-template-columns: 1fr;
  }

  .typed-upload-grid {
    grid-template-columns: 1fr;
    padding: 0 12px 12px;
  }

  .broker-actions-grid {
    grid-template-columns: 1fr;
  }

  .upload-dropzone {
    margin: 12px;
  }

  .span-2,
  .packet-panel {
    grid-column: auto;
  }

  .chat-log {
    height: 360px;
  }

  .metric {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .metric:last-child {
    border-bottom: 0;
  }

  .shipment-status-grid div {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .shipment-status-grid div:last-child {
    border-bottom: 0;
  }

  dl {
    grid-template-columns: 1fr;
    gap: 3px;
  }

  dd {
    margin-bottom: 6px;
  }

  .landing-header {
    padding: 26px 22px 0;
  }

  .landing-brand {
    font-size: 23px;
  }

  .landing-copy {
    padding: 34px 22px 58px;
  }

  .landing-copy h1 {
    font-size: 42px;
    line-height: 1.08;
  }

  .landing-copy p {
    font-size: 17px;
  }

  .landing-actions p {
    white-space: normal;
  }

  .landing-proof-inner {
    padding: 48px 22px 58px;
  }

  .landing-proof h2 {
    font-size: 28px;
  }
}

@media (max-height: 640px) {
  .landing-hero {
    height: calc(100dvh - 34px);
  }

  .landing-header {
    padding-top: 22px;
  }

  .landing-copy {
    padding-bottom: 38px;
  }

  .landing-copy h1 {
    font-size: 40px;
  }

  .landing-copy p {
    margin-top: 16px;
    font-size: 16px;
  }
}
