:root {
  --primary: #936647;
  --primary-dark: #7A5039;
  --secondary: #C09574;
  --accent: #D4B49A;
  --bg-page: #F7F3EB;
  --bg-card: #FFFFFF;
  --border: #E8DDC8;
  --text-main: #2D2419;
  --text-muted: #7A6F60;
  --success: #5D7A4A;
  --error: #A8423C;
  --shadow-sm: 0 1px 3px rgba(147, 102, 71, 0.06);
  --shadow-md: 0 4px 12px rgba(147, 102, 71, 0.10);
  --shadow-lg: 0 10px 30px rgba(147, 102, 71, 0.15);
  --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg-page);
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Login ── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-brand {
  text-align: center;
  margin-bottom: 28px;
}
.login-brand .logo-mark {
  display: inline-block;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  border-radius: 12px;
  color: #fff;
  font-weight: 700;
  font-size: 22px;
  line-height: 48px;
  margin-bottom: 10px;
  letter-spacing: -0.5px;
}
.login-brand h1 {
  font-size: 20px;
  color: var(--primary-dark);
  letter-spacing: 0.5px;
  font-weight: 700;
}
.login-brand p {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ── Header ── */
.header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow-md);
}
.header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 16px;
  letter-spacing: 0.3px;
}
.header .logo-mark {
  display: inline-block;
  width: 36px;
  height: 36px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 8px;
  text-align: center;
  line-height: 36px;
  font-weight: 700;
  font-size: 16px;
}
.header .user-info {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
}
.header .user-info button {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
  border: none;
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  transition: background 0.2s;
}
.header .user-info button:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* ── Layout ── */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}
.card h2 {
  font-size: 16px;
  color: var(--primary-dark);
  margin-bottom: 4px;
  letter-spacing: 0.3px;
}
.card .sub {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 20px;
}

/* ── Forms ── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 14px;
}
.form-row.full { grid-template-columns: 1fr; }
.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-page);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  color: var(--text-main);
  font-size: 14px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
}
.form-group textarea { resize: vertical; min-height: 110px; line-height: 1.5; }

/* ── Items table ── */
.items-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-bottom: 10px;
}
.items-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 6px 8px 10px;
  border-bottom: 2px solid var(--border);
}
.items-table th.num { width: 80px; text-align: center; }
.items-table th.val { width: 120px; text-align: right; }
.items-table th.act { width: 40px; }
.items-table td { padding: 6px 4px; }
.items-table input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.items-table input:focus { border-color: var(--primary); }
.items-table input[type=number] { text-align: right; }
.btn-remove {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--error);
  width: 30px;
  height: 30px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
}
.btn-remove:hover { background: var(--error); color: #fff; border-color: var(--error); }

/* ── Buttons ── */
.btn {
  display: inline-block;
  padding: 10px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  text-decoration: none;
}
.btn:hover { background: var(--primary-dark); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn.secondary {
  background: transparent;
  color: var(--primary);
  border: 1.5px solid var(--primary);
}
.btn.secondary:hover { background: var(--primary); color: #fff; }
.btn.big { padding: 14px 32px; font-size: 15px; }
.btn-link-like {
  background: transparent;
  color: var(--primary);
  border: none;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  padding: 4px 8px;
  text-decoration: underline;
}

/* ── Upload dropzone ── */
.dropzone {
  border: 2px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  background: var(--bg-page);
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.dropzone:hover, .dropzone.drag-over {
  border-color: var(--primary);
  background: #faf5ec;
}
.dropzone input { display: none; }
.img-previews { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 12px; }
.img-previews .preview {
  position: relative;
  width: 90px;
  height: 90px;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.img-previews img { width: 100%; height: 100%; object-fit: cover; }
.img-previews .rm {
  position: absolute;
  top: 2px;
  right: 2px;
  background: rgba(0,0,0,0.6);
  color: #fff;
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}

/* ── Proposals list ── */
.proposals-list { list-style: none; }
.proposals-list li {
  padding: 14px 4px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 14px;
}
.proposals-list li:last-child { border-bottom: none; }
.prop-main { flex: 1; min-width: 0; }
.prop-main .ref { font-size: 11px; color: var(--text-muted); font-family: 'SF Mono', Menlo, monospace; }
.prop-main .client { font-weight: 600; color: var(--text-main); }
.prop-main .meta { font-size: 12px; color: var(--text-muted); }
.prop-value { font-weight: 700; color: var(--primary-dark); font-size: 14px; }
.prop-status {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 10px;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.5px;
}
.prop-status.draft { background: #f0e8dc; color: var(--text-muted); }
.prop-status.generated { background: #e8d9c2; color: var(--primary-dark); }
.prop-status.sent { background: #d5e4cb; color: var(--success); }
.prop-status.failed { background: #f4d7d5; color: var(--error); }

/* ── Messages / alerts ── */
.error-msg { color: var(--error); font-size: 13px; margin-top: 8px; }
.success-card {
  background: #f3f7ee;
  border: 1.5px solid var(--success);
  padding: 20px 24px;
  border-radius: 8px;
  margin-bottom: 20px;
}
.success-card h3 { color: var(--success); font-size: 16px; margin-bottom: 6px; }
.success-card .ref { font-family: 'SF Mono', Menlo, monospace; font-size: 13px; color: var(--text-muted); }
.success-card .actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

.avisos {
  background: #fdf4e3;
  border: 1px solid #e9c97b;
  padding: 12px 16px;
  border-radius: 6px;
  margin-top: 14px;
  font-size: 13px;
  color: #7a5200;
}
.avisos strong { display: block; margin-bottom: 4px; }
.avisos ul { margin: 4px 0 0 20px; }

/* ── Loading overlay ── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(45, 36, 25, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.overlay .box {
  background: var(--bg-card);
  padding: 36px 48px;
  border-radius: 12px;
  text-align: center;
  box-shadow: var(--shadow-lg);
  max-width: 400px;
}
.overlay .spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.overlay .box p { font-size: 14px; color: var(--text-main); }
.overlay .box .step { font-size: 12px; color: var(--text-muted); margin-top: 6px; }

/* ── GHL Lead Picker ── */
.ghl-picker {
  background: linear-gradient(180deg, #faf8f5 0%, #f3ede3 100%);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 20px;
}
.ghl-picker-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 10px;
  gap: 12px;
  flex-wrap: wrap;
}
.ghl-picker-title {
  font-weight: 700;
  color: var(--primary-dark);
  font-size: 14px;
}
.ghl-picker-hint {
  font-size: 11px;
  color: var(--text-muted);
  font-style: italic;
}
.ghl-picker-row {
  display: flex;
  gap: 8px;
  align-items: stretch;
}
.ghl-search-wrap {
  flex: 1;
  position: relative;
}
.ghl-search-wrap input {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  font-family: inherit;
  outline: none;
}
.ghl-search-wrap input:focus { border-color: var(--primary); }
.ghl-results {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  z-index: 50;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 6px 6px;
  box-shadow: var(--shadow-md);
  max-height: 320px;
  overflow-y: auto;
  display: none;
}
.ghl-results.open { display: block; }
.ghl-result-item {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  font-size: 13px;
  line-height: 1.4;
  transition: background 0.1s;
}
.ghl-result-item:last-child { border-bottom: none; }
.ghl-result-item:hover,
.ghl-result-item.active { background: #faf5ef; }
.ghl-result-item .name { font-weight: 600; color: var(--text-main); }
.ghl-result-item .meta { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.ghl-result-empty {
  padding: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  font-style: italic;
}

#ghlPullBtn {
  min-width: 140px;
  padding: 10px 16px;
  font-size: 13px;
  white-space: nowrap;
}
#ghlPullBtn:disabled { opacity: 0.5; cursor: not-allowed; }

.ghl-selected {
  margin-top: 10px;
  padding: 10px 14px;
  background: #f3f7ee;
  border: 1px solid #c3d4b4;
  border-radius: 6px;
  font-size: 12px;
  color: var(--success);
  line-height: 1.5;
}
.ghl-selected strong { color: #4a6337; }
.ghl-selected .clear-btn {
  float: right;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 0;
  margin-left: 8px;
}

.form-divider {
  text-align: center;
  position: relative;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.form-divider::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--border);
}
.form-divider span {
  background: var(--bg-card);
  padding: 0 14px;
  position: relative;
}

/* ── Key points badges (após extract GHL) ── */
.key-points {
  margin: 8px 0 4px;
  padding: 10px 14px;
  background: #fdf4e3;
  border: 1px solid #e9c97b;
  border-radius: 6px;
  font-size: 12px;
  color: #7a5200;
  line-height: 1.6;
}
.key-points strong { display: block; margin-bottom: 4px; }
.key-points ul { margin: 0; padding-left: 18px; }

/* ── Responsive ── */
@media (max-width: 640px) {
  .form-row { grid-template-columns: 1fr; }
  .container { padding: 20px 14px 80px; }
  .card { padding: 20px; }
  .header { padding: 14px 16px; }
}
