:root {
  color-scheme: light;
  --bg: #f4f7f5;
  --surface: #ffffff;
  --surface-soft: #eef4f1;
  --ink: #17211d;
  --muted: #62716b;
  --line: #d7e0dc;
  --accent: #1f7a5a;
  --accent-dark: #145b42;
  --danger: #b83232;
  --shadow: 0 18px 45px rgba(27, 43, 36, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Arial, Helvetica, sans-serif;
  background: linear-gradient(135deg, #edf5f1 0%, #f8faf8 42%, #e9f0f5 100%);
  color: var(--ink);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 20px;
}

.workspace {
  display: grid;
  gap: 16px;
}

.topbar,
.search-panel,
.order-panel,
.message-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.topbar {
  display: grid;
  gap: 16px;
  justify-items: center;
  padding: 20px;
}

.topbar-title {
  display: grid;
  gap: 10px;
  justify-items: center;
  width: 100%;
  min-width: 0;
}

.top-logo {
  display: block;
  width: min(390px, 72vw);
  height: auto;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(24px, 6vw, 40px);
  line-height: 1.05;
}

h2 {
  font-size: 18px;
}

.search-panel,
.order-panel,
.message-panel {
  padding: 18px;
}

label {
  display: block;
  margin-bottom: 8px;
  font-weight: 700;
}

.site-field {
  margin-bottom: 16px;
}

.field-error {
  display: none;
  margin: 7px 0 0;
  color: var(--danger);
  font-size: 13px;
}

.field-error.visible {
  display: block;
}

.field-invalid {
  border-color: var(--danger);
}

.search-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

.reference-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 13px;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  height: 48px;
  padding: 0 13px;
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 90, 0.14);
}

.results {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: 285px;
  overflow: auto;
}

.result-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  min-height: 54px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-soft);
  color: var(--ink);
  cursor: pointer;
  text-align: left;
}

.result-item:hover,
.result-item:focus-visible {
  border-color: var(--accent);
  background: #e3f1eb;
}

.result-name,
.selected-name {
  overflow-wrap: anywhere;
}

.result-text {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.result-category,
.selected-category {
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.result-code,
.selected-code,
#itemCount {
  color: var(--muted);
  font-size: 13px;
  white-space: nowrap;
}

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

.selected-list {
  display: grid;
  gap: 10px;
}

.empty-state {
  margin: 0;
  padding: 16px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fbfcfb;
}

.selected-item {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfb;
}

.selected-item > div:first-child {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.selected-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.selected-quantity {
  width: 76px;
}

.remove-button,
.ghost-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
}

.remove-button {
  width: 40px;
  height: 40px;
  color: var(--danger);
  font-size: 24px;
  line-height: 1;
}

.ghost-button {
  min-height: 40px;
  padding: 0 13px;
  font-weight: 700;
}

.ghost-button:hover,
.remove-button:hover {
  border-color: var(--accent);
}

.ghost-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

textarea {
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  line-height: 1.5;
}

.whatsapp-button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  margin-top: 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
  text-decoration: none;
}

.whatsapp-button:hover {
  background: var(--accent-dark);
}

.whatsapp-button.disabled {
  pointer-events: none;
  opacity: 0.45;
}

@media (min-width: 760px) {
  .workspace {
    grid-template-columns: 1fr 1fr;
  }

  .topbar,
  .search-panel {
    grid-column: 1 / -1;
  }
}

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

  .topbar {
    padding: 14px;
  }

  .top-logo {
    width: min(240px, 68vw);
  }

  h1 {
    font-size: 20px;
  }

  .ghost-button {
    min-height: 36px;
    padding: 0 10px;
  }

  .search-row,
  .selected-item {
    grid-template-columns: 1fr;
  }

  .reference-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .selected-actions {
    justify-content: space-between;
  }

  .selected-quantity {
    flex: 1;
  }
}
