:root {
  --bg: #110d12;
  --card: #18141c;
  --line: #3a2934;
  --text: #f3f1f3;
  --muted: #c6bbc4;
  --brand: #ff7b1c;
  --brand-dark: #cf5f0f;
  --danger: #ff665f;
  --ok: #44d18c;
  --panel-strong: #231a24;
  --radius: 10px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 15% 10%, #371925 0%, transparent 42%),
    radial-gradient(circle at 85% 20%, #41222e 0%, transparent 44%),
    linear-gradient(180deg, #0f0b11 0%, #160f16 100%);
}

.app-shell {
  width: min(1120px, 96vw);
  margin: 14px auto 24px;
  padding: 14px;
}

.promo-banner {
  position: relative;
  border: 1px solid #704251;
  border-radius: 14px;
  overflow: hidden;
  min-height: 210px;
  margin-bottom: 12px;
  background: #1b1117;
}

.promo-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 38%;
  filter: saturate(1.1) contrast(1.04);
}

.promo-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(19, 9, 13, 0.86) 0%, rgba(19, 9, 13, 0.45) 46%, rgba(19, 9, 13, 0.6) 100%);
}

.promo-content {
  position: relative;
  z-index: 1;
  padding: 20px 22px;
  max-width: 760px;
}

.promo-kicker {
  margin: 0 0 8px;
  color: #ffbc87;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.promo-content h1 {
  margin: 0 0 8px;
  font-size: clamp(1.25rem, 2.8vw, 2rem);
  line-height: 1.12;
}

.promo-content p {
  margin: 0;
  color: #f2dce4;
  font-size: 0.98rem;
  max-width: 62ch;
}

.app-header {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 14px;
  margin-bottom: 10px;
}

.app-header h2 {
  margin: 0 0 4px;
  font-size: 1.25rem;
}

.app-header p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.tab-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 10px;
}

.tab-btn {
  border: 1px solid var(--line);
  background: #241927;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}

.tab-btn.active {
  background: var(--brand);
  color: #fff;
  border-color: var(--brand);
}

.status-box {
  min-height: 0;
  margin-bottom: 10px;
}

.status-box .msg {
  border-radius: var(--radius);
  border: 1px solid var(--line);
  padding: 10px 12px;
  font-size: 0.92rem;
  background: #211722;
}

.status-box .msg.ok {
  color: var(--ok);
  border-color: #3a5c4c;
  background: #19251f;
}

.status-box .msg.error {
  color: var(--danger);
  border-color: #7b3d44;
  background: #2a1518;
}

.cad-form {
  display: none;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px;
}

.cad-form.active {
  display: block;
}

.cad-form h2 {
  margin: 0 0 10px;
  font-size: 1.12rem;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin: 0 0 10px;
  padding: 10px;
}

legend {
  padding: 0 6px;
  color: var(--muted);
  font-weight: 700;
  font-size: 0.84rem;
}

.grid {
  display: grid;
  gap: 8px;
}

.grid.cols-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.grid.cols-3 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.84rem;
  color: #e3d5dd;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 9px;
  font-size: 0.92rem;
  color: var(--text);
  background: #261c28;
}

input:focus {
  outline: 2px solid #ffc08d;
  border-color: #ff9f52;
}

.cnpj-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.cep-search-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.btn-secondary {
  border: 1px solid #7a4c28;
  border-radius: 7px;
  padding: 8px 10px;
  background: #2e1b11;
  color: #ffd6b3;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.btn-secondary:hover {
  background: #3a2215;
}

.btn-secondary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.form-actions button {
  border: none;
  border-radius: 8px;
  padding: 9px 14px;
  background: var(--brand);
  color: #fff;
  font-weight: 700;
  cursor: pointer;
}

.form-actions button:hover {
  background: var(--brand-dark);
}

.app-footer {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #18111b;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
}

.footer-preview {
  width: min(320px, 100%);
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #51404b;
  background: #161018;
}

.footer-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.product-logo {
  width: min(420px, 100%);
  height: 88px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #51404b;
  background: #ebeef3;
}

.product-logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  transform: none;
}

.footer-contact {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.footer-contact a {
  color: #ffc48f;
  text-decoration: none;
  font-weight: 700;
}

.footer-contact a:hover {
  text-decoration: underline;
}

.toast-root {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 2000;
  display: grid;
  gap: 8px;
  width: min(360px, calc(100vw - 20px));
}

.toast {
  border: 1px solid #5b4854;
  border-radius: 10px;
  padding: 10px 12px;
  color: #fff;
  background: #2a212f;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.35);
  animation: toast-in 160ms ease-out;
}

.toast.ok {
  border-color: #2f7a5a;
  background: #1f3a30;
}

.toast.error {
  border-color: #8e3b3b;
  background: #422222;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: 100%;
    margin: 0;
    padding: 10px;
  }

  .tab-actions {
    flex-wrap: wrap;
  }

  .promo-banner {
    min-height: 190px;
  }

  .promo-content {
    padding: 16px;
  }

  .grid.cols-3,
  .grid.cols-2 {
    grid-template-columns: 1fr;
  }

  .cnpj-search-row {
    grid-template-columns: 1fr;
  }

  .cep-search-row {
    grid-template-columns: 1fr;
  }

  .form-actions {
    justify-content: stretch;
  }

  .form-actions button {
    width: 100%;
  }

  .app-footer {
    align-items: stretch;
  }
}
