:root {
  color-scheme: light;
  --bg: #f4f6f8;
  --panel: #ffffff;
  --ink: #172026;
  --muted: #65727c;
  --line: #dce3e8;
  --soft: #eef3f6;
  --brand: #0f766e;
  --brand-dark: #0b5d57;
  --accent: #f3bd2b;
  --danger: #b93f3f;
  --whatsapp: #1b9f52;
  --shadow: 0 12px 32px rgba(24, 35, 43, 0.07);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

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

button,
input,
select,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.app-shell {
  width: min(1560px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

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

.eyebrow,
h1,
h2,
h3,
p {
  margin: 0;
}

.eyebrow {
  margin-bottom: 6px;
  color: var(--brand-dark);
  font-size: 0.75rem;
  font-weight: 850;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

.lead {
  max-width: 760px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.46;
}

.top-actions,
.quick-actions,
.send-grid,
.card-actions {
  display: flex;
  gap: 9px;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 11px;
  margin-bottom: 16px;
}

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

.metric-card {
  padding: 15px;
}

.metric-card span {
  display: block;
  font-size: 1.75rem;
  font-weight: 850;
  line-height: 1;
}

.metric-card small {
  display: block;
  margin-top: 7px;
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: minmax(270px, 0.75fr) minmax(480px, 1.65fr) minmax(330px, 0.9fr);
  gap: 16px;
  align-items: start;
}

.sidebar,
.main-column,
.inspector {
  display: grid;
  gap: 16px;
}

.sidebar,
.inspector {
  position: sticky;
  top: 14px;
}

.panel {
  padding: 16px;
}

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

.panel-title p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.35;
}

label {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  color: #2c3941;
  font-size: 0.9rem;
  font-weight: 750;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
}

.check-row input {
  width: 18px;
  min-height: 18px;
}

input,
select,
textarea {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fbfcfd;
  color: var(--ink);
  outline: 0;
  padding: 9px 11px;
}

textarea {
  resize: vertical;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.form-grid,
.filters {
  display: grid;
  gap: 10px;
}

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

.form-grid.compact {
  gap: 8px;
}

.filters {
  grid-template-columns: minmax(220px, 1fr) 180px 150px 150px;
}

.button {
  display: inline-flex;
  min-height: 40px;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 7px;
  cursor: pointer;
  font-weight: 800;
  line-height: 1;
  padding: 0 13px;
  text-decoration: none;
  white-space: nowrap;
}

.button.full {
  width: 100%;
}

.button.primary {
  background: var(--brand);
  color: #fff;
}

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

.button.secondary,
.button.subtle {
  background: var(--soft);
  color: var(--ink);
}

.button.secondary:hover,
.button.subtle:hover {
  background: #e3ebef;
}

.button.danger {
  background: #f8eaea;
  color: var(--danger);
}

.button.whatsapp {
  background: var(--whatsapp);
  color: #fff;
}

.file-button {
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  cursor: pointer;
  opacity: 0;
}

.hidden {
  display: none !important;
}

.source-list,
.offer-list,
.contact-list,
.config-list {
  display: grid;
  gap: 10px;
}

.source-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.source-card small {
  grid-column: 2 / -1;
  color: var(--muted);
  font-size: 0.78rem;
}

.source-card p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.32;
}

.source-icon {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #dff3ef;
  color: var(--brand-dark);
  font-weight: 900;
}

.source-card.planned .source-icon {
  background: #edf0f2;
  color: #596771;
}

.toolbar-panel {
  padding: 12px;
}

.offer-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.offer-card.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.12);
}

.offer-main {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 13px;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  padding: 0;
  text-align: left;
}

.offer-thumb {
  width: 86px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-weight: 900;
}

.offer-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.offer-content {
  min-width: 0;
}

.offer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.offer-heading h3 {
  font-size: 0.98rem;
  line-height: 1.28;
}

.offer-card p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.34;
  overflow-wrap: anywhere;
}

.offer-meta,
.offer-price {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
}

.offer-price {
  margin-top: 8px;
}

.offer-price strong {
  color: var(--brand-dark);
  font-size: 1.16rem;
}

.offer-price del {
  color: #89949b;
}

.offer-meta {
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 999px;
  background: var(--soft);
  color: #33424a;
  font-size: 0.76rem;
  font-weight: 800;
  padding: 0 9px;
  white-space: nowrap;
}

.tag.hot {
  background: #fff0bd;
  color: #6f5200;
}

.tag.sent {
  background: #e3f5ea;
  color: #17643a;
}

.tag.archived {
  background: #eceff1;
  color: #5d6971;
}

.icon-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
}

.icon-button:hover {
  border-color: var(--brand);
}

.card-actions {
  flex-direction: column;
}

.message-preview {
  min-height: 230px;
  max-height: 390px;
  overflow: auto;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  color: #26343c;
  line-height: 1.52;
  white-space: pre-wrap;
}

.send-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 12px;
}

.quick-actions {
  margin-top: 10px;
}

.quick-actions .button {
  flex: 1;
}

.contact-item,
.config-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
}

.contact-item strong,
.config-row strong {
  display: block;
  font-size: 0.9rem;
}

.contact-item small,
.config-row span {
  color: var(--muted);
  font-size: 0.82rem;
}

.config-row strong {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.automation-status {
  display: grid;
  gap: 8px;
  min-height: 96px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f9fbfc;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.42;
}

.automation-status strong {
  color: var(--ink);
}

.automation-status code {
  padding: 2px 5px;
  border-radius: 5px;
  background: var(--soft);
  color: var(--ink);
  overflow-wrap: anywhere;
}

.empty-state {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.login-screen {
  display: flex;
  min-height: 100vh;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-form {
  width: min(360px, 100%);
  padding: 28px 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.login-form h1 {
  margin: 4px 0 20px;
  font-size: 1.6rem;
}

.login-error {
  margin-top: 12px;
  color: var(--danger);
  font-size: 0.86rem;
}

@media (max-width: 1220px) {
  .workspace {
    grid-template-columns: minmax(250px, 0.85fr) minmax(0, 1.6fr);
  }

  .inspector {
    grid-column: 1 / -1;
    position: static;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    align-items: start;
  }
}

@media (max-width: 880px) {
  .app-shell {
    width: min(100% - 20px, 1560px);
    padding-top: 16px;
  }

  .topbar,
  .workspace,
  .inspector,
  .panel-title {
    display: grid;
    grid-template-columns: 1fr;
  }

  .sidebar,
  .inspector {
    position: static;
  }

  .top-actions,
  .quick-actions,
  .send-grid {
    display: grid;
    grid-template-columns: 1fr;
  }

  .metrics,
  .filters,
  .form-grid.two {
    grid-template-columns: 1fr;
  }

  .offer-card {
    grid-template-columns: 1fr;
  }

  .offer-main {
    grid-template-columns: 72px minmax(0, 1fr);
  }

  .offer-thumb {
    width: 72px;
  }

  .card-actions {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
  }

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