:root {
  --primary: #fc4c02;
  --primary-hover: #f76d32;
  --surface: #f8f5f0;
  --ink: #000000;
  --secondary: #31312f;
  --muted: rgba(49, 49, 47, .68);
  --line: #e5e5e5;
  --card-ring: rgb(236, 220, 211) 0 0 0 1px inset;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: #ffffff;
  color: var(--ink);
  font-family: Poppins, -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.page {
  width: min(1180px, calc(100vw - 48px));
  margin: 0 auto;
}

.workspace {
  min-height: 100vh;
  padding: 36px 0 64px;
  display: grid;
  align-content: center;
}

.hero {
  margin-bottom: 24px;
  padding: 44px 48px;
  border-radius: 8px;
  background: linear-gradient(135deg, #000000 0%, #31312f 100%);
  color: #ffffff;
}

.kicker {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  max-width: 860px;
  font-size: clamp(44px, 5vw, 72px);
  line-height: 1.12;
  font-weight: 600;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(28px, 3vw, 42px);
  line-height: 1.12;
  font-weight: 600;
}

.hero-copy {
  max-width: 780px;
  margin-bottom: 0;
  color: rgba(255, 255, 255, .78);
  font-size: 18px;
  line-height: 1.5;
}

.query-card,
.analysis-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: var(--card-ring);
}

.analysis-card {
  margin-top: 24px;
}

.query-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.query-top p {
  margin-bottom: 0;
  color: var(--muted);
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.field span {
  color: var(--secondary);
  font-size: 14px;
  font-weight: 500;
}

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

.compact-grid {
  align-items: end;
}

input,
select {
  width: 100%;
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #ffffff;
  color: var(--ink);
  outline: none;
}

select[multiple] {
  min-height: 176px;
  border-radius: 14px;
}

input:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(252, 76, 2, .12);
}

.autocomplete-field {
  position: relative;
}

.autocomplete-options {
  position: absolute;
  top: 72px;
  left: 0;
  right: 0;
  z-index: 20;
  max-height: 288px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .14);
}

.autocomplete-option {
  display: block;
  width: 100%;
  padding: 11px 14px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.autocomplete-option:hover {
  background: var(--surface);
}

.selected-pill {
  min-height: 24px;
  color: var(--muted);
  font-size: 13px;
}

.button-primary {
  min-height: 42px;
  padding: 8px 20px;
  border: 0;
  border-radius: 100px;
  background: var(--primary);
  color: #ffffff;
  cursor: pointer;
  transition: background-color .2s ease-in, transform .1s ease-in;
  white-space: nowrap;
}

.button-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.button-primary:disabled {
  opacity: .55;
  cursor: not-allowed;
  transform: none;
}

.query-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.query-meta {
  color: var(--muted);
  font-size: 14px;
}

.status {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 8px;
  background: var(--surface);
  color: var(--secondary);
}

.status.error {
  background: #fff0e7;
  color: #9a2500;
}

.status.success {
  background: #eefaf1;
  color: #176c31;
}

.analysis-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.analysis-meta,
.waybill-panel-head span {
  color: var(--muted);
  font-size: 14px;
}

.count-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 16px;
}

.count-button {
  min-height: 38px;
  padding: 7px 15px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
}

.count-button.active,
.count-button:hover {
  border-color: var(--primary);
  background: #fff0e7;
  color: #9a2500;
}

.waybill-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
}

.waybill-panel-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
}

.waybill-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  max-height: 320px;
  overflow: auto;
  padding: 14px;
}

.waybill-chip {
  padding: 6px 9px;
  border-radius: 6px;
  background: #ffffff;
  box-shadow: var(--card-ring);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.lock-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(255, 255, 255, .42);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  transition: opacity .2s ease-in, backdrop-filter .2s ease-in;
}

.lock-overlay.unlocked {
  opacity: 0;
  pointer-events: none;
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
}

.lock-card {
  width: min(430px, 100%);
  padding: 28px;
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  box-shadow: 0 24px 64px rgba(0, 0, 0, .18), var(--card-ring);
}

.lock-card h2 {
  margin-bottom: 8px;
}

.lock-card p:not(.kicker) {
  color: var(--muted);
}

.lock-error {
  margin: 12px 0 0;
  color: #9a2500 !important;
  font-size: 14px;
}

.copy-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  padding: 10px 14px;
  border-radius: 999px;
  background: #000000;
  color: #ffffff;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity .18s ease-in, transform .18s ease-in;
}

.copy-toast.show {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 760px) {
  .page {
    width: min(100vw - 28px, 1180px);
  }

  .workspace {
    padding: 18px 0 36px;
    align-content: start;
  }

  .hero {
    padding: 30px 24px;
  }

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

  .query-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .analysis-head {
    flex-direction: column;
  }

  .button-primary {
    width: 100%;
  }
}
