:root {
  --bg: #f5f4f1;
  --card: #ffffff;
  --line: #e3e0da;
  --text: #2a2622;
  --muted: #7a746b;
  --accent: #b5651d;
  --accentd: #8f4f16;
  --green: #93c47d;
  --orange: #fce5cd;
  --radius: 12px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* --- Login --- */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 40px; width: 360px; max-width: 90vw; text-align: center;
}
.login-card h1 { margin: 0 0 4px; }
.muted { color: var(--muted); margin-top: 0; }
.btn-google {
  display: block; padding: 12px; border-radius: 8px; background: var(--text); color: #fff;
  text-decoration: none; font-weight: 600; margin-top: 20px;
}
.divider { display: flex; align-items: center; color: var(--muted); margin: 20px 0; font-size: 13px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.divider span { padding: 0 10px; }
.login-card form { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.login-card label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 6px; }
.login-card input {
  padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 15px;
}
.login-card button {
  padding: 12px; border: none; border-radius: 8px; background: var(--accent); color: #fff;
  font-weight: 600; cursor: pointer;
}
.login-card button:hover { background: var(--accentd); }
.error { color: #b3261e; font-size: 14px; margin-top: 14px; }

/* --- App --- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; background: var(--card); border-bottom: 1px solid var(--line);
}
.topbar h1 { margin: 0; font-size: 20px; }
.btn-ghost { color: var(--muted); text-decoration: none; font-size: 14px; }
.topbar-right { display: flex; align-items: center; gap: 16px; }
.city-picker { position: relative; }
.city-button {
  padding: 8px 16px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px;
  background: var(--card); cursor: pointer; font-family: inherit;
}
.city-button:hover { border-color: var(--accent); }
.city-dropdown {
  position: absolute; top: calc(100% + 4px); left: 0; min-width: 220px; background: var(--card);
  border: 1px solid var(--line); border-radius: 8px; box-shadow: 0 6px 20px rgba(0,0,0,.12);
  max-height: 320px; overflow-y: auto; z-index: 20;
}
.city-option {
  display: flex; justify-content: space-between; align-items: center; padding: 9px 14px; font-size: 14px; cursor: pointer;
}
.city-option:hover { background: var(--bg); }
.city-option span {
  display: inline-block; min-width: 20px; text-align: center; padding: 2px 7px;
  border-radius: 999px; background: var(--bg); color: var(--text); font-size: 12px; font-weight: 600;
}
.city-option-all { border-bottom: 1px solid var(--line); font-weight: 600; }
.city-option-empty { padding: 10px 14px; font-size: 13px; color: var(--muted); }
.city-banner {
  margin: 16px 20px 0; padding: 10px 14px; background: #fff3e0; border: 1px solid var(--orange);
  border-radius: 8px; font-size: 14px;
}
.city-banner a { color: var(--accentd); font-weight: 600; }

.board {
  display: grid; grid-template-columns: repeat(6, minmax(220px, 1fr));
  gap: 14px; padding: 20px; overflow-x: auto;
}
.column { background: #ece9e3; border-radius: var(--radius); padding: 10px; min-height: 200px; }
.column h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); margin: 4px 8px 10px; }
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px;
  margin-bottom: 8px; cursor: pointer; font-size: 14px;
}
.card:hover { border-color: var(--accent); }
.card .empresa { font-weight: 600; margin-bottom: 2px; }
.card .meta { color: var(--muted); font-size: 12px; }
.card.stage-proposta_enviada { background: var(--orange); }
.card.stage-contactado { background: var(--green); color: #1e3a12; }
.card-sent {
  display: flex; align-items: center; gap: 6px; margin-top: 8px; padding-top: 8px;
  border-top: 1px solid rgba(0,0,0,.12); font-size: 12px; font-weight: 600; cursor: pointer;
}
.card-sent input { cursor: pointer; }
.card-quick-select {
  display: block; width: 100%; margin-top: 8px; padding: 6px; font-size: 12px; font-weight: 600;
  border: 1px solid rgba(0,0,0,.2); border-radius: 6px; background: #fff; cursor: pointer;
}

.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex;
  align-items: center; justify-content: center; padding: 20px; z-index: 10;
}
.modal-backdrop[hidden] { display: none; }
.modal { background: var(--card); border-radius: var(--radius); padding: 28px; width: 560px; max-width: 100%; max-height: 90vh; overflow-y: auto; position: relative; }
.modal-close { position: absolute; top: 12px; right: 16px; border: none; background: none; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal h2 { margin-top: 0; }
.field-row { display: grid; grid-template-columns: 140px 1fr; gap: 8px; padding: 6px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.field-row span.label { color: var(--muted); }
.field-row select, .field-row input { font-size: 14px; padding: 4px; border: 1px solid var(--line); border-radius: 6px; }
.msg-list { margin-top: 16px; }
.msg { border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin-bottom: 8px; font-size: 13px; white-space: pre-wrap; }
.msg-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; white-space: normal; }
.msg .sent { color: #2e7d32; font-weight: 600; }
.copy-msg {
  font-size: 11px; padding: 3px 10px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg); cursor: pointer; white-space: nowrap;
}
.copy-msg:hover { border-color: var(--accent); }
.msg textarea { width: 100%; min-height: 80px; font: inherit; padding: 8px; border-radius: 6px; border: 1px solid var(--line); }

@media (max-width: 900px) {
  .board { grid-template-columns: 1fr; }
}
