:root {
  --bg: #f4f5f7;
  --card: #ffffff;
  --border: #e2e4e8;
  --text: #1f2430;
  --muted: #6b7280;
  --accent: #714B67;
  --accent-dark: #5a3b52;
  --group-bg: #ede7ec;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  background: var(--accent);
  color: white;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  gap: 24px;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }
.topbar h1 a { color: white; text-decoration: none; }
.topnav { display: flex; gap: 16px; flex: 1; }
.topnav a { color: rgba(255,255,255,0.85); text-decoration: none; font-size: 13.5px; }
.topnav a:hover { color: white; text-decoration: underline; }
.topbar-user { display: flex; align-items: center; gap: 10px; font-size: 13px; }

.content { padding: 20px 24px 60px; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  background: var(--card);
  padding: 14px 16px;
  border-radius: 8px;
  margin-bottom: 14px;
  border: 1px solid var(--border);
}
.toolbar input[type="text"] { width: 240px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.toolbar label { font-size: 12px; color: var(--muted); display: flex; align-items: center; gap: 4px; }
.toolbar select { padding: 7px 8px; border: 1px solid var(--border); border-radius: 6px; font-size: 13px; }
.spacer { flex: 1; }

.btn {
  display: inline-block;
  padding: 8px 14px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 500;
}
.btn:hover { background: var(--accent-dark); }
.btn:disabled { opacity: 0.6; cursor: default; }
.btn-secondary { background: white; color: var(--accent); border: 1px solid var(--accent); }
.btn-secondary:hover { background: #f1eaf0; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-block { width: 100%; }

.stats { font-size: 13px; color: var(--muted); margin-bottom: 10px; }
.muted { color: var(--muted); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--card);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}
.data-table th {
  background: #faf9fb;
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.data-table td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 13.5px;
  vertical-align: top;
  max-width: 280px;
}
.data-table tr:hover { background: #fbfaf9; }
[contenteditable="true"] { cursor: text; border-radius: 4px; }
[contenteditable="true"]:focus { outline: 2px solid var(--accent); background: #fdf9fc; }
.data-table td.num { color: var(--muted); width: 40px; }
.data-table td.desc { max-width: 380px; }
.data-table td.links a { color: var(--accent); text-decoration: none; font-size: 12px; margin-right: 8px; white-space: nowrap; }
.data-table td.links a:hover { text-decoration: underline; }

tr.group-header td {
  background: var(--group-bg);
  font-weight: 600;
  font-size: 13px;
  padding: 8px 12px;
  color: var(--accent-dark);
}

.del-btn { background: transparent; color: #b3261e; border: none; font-size: 15px; cursor: pointer; }
.del-btn:hover { background: #fbe9e8; border-radius: 4px; }

.empty-msg { text-align: center; padding: 40px; color: var(--muted); }

.pagination { display: flex; align-items: center; gap: 12px; justify-content: center; margin-top: 16px; font-size: 13px; color: var(--muted); }

.form-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 640px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.form-card label { font-size: 13px; color: var(--muted); display: flex; flex-direction: column; gap: 4px; }
.form-card input, .form-card textarea {
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.form-actions { display: flex; gap: 10px; margin-top: 6px; }

.alert-error {
  background: #fbe9e8;
  color: #8f1d17;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 13px;
  margin-bottom: 12px;
}

.scraper-box {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  max-width: 640px;
  margin-top: 16px;
}
.progress-bar-outer {
  background: #eee;
  border-radius: 6px;
  height: 14px;
  overflow: hidden;
  margin-bottom: 10px;
}
.progress-bar-inner {
  background: var(--accent);
  height: 100%;
  width: 0%;
  transition: width 0.2s ease;
}
.log-area {
  background: #1f2430;
  color: #d9dbe0;
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
  padding: 12px;
  border-radius: 6px;
  height: 220px;
  overflow-y: auto;
  margin-top: 10px;
}
.log-line { padding: 1px 0; white-space: pre-wrap; }
.log-line.log-ok { color: #8bd48b; }
.log-line.log-warn { color: #e0c060; }
.log-line.log-error { color: #e08a8a; }

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  align-items: center;
  justify-content: center;
  z-index: 500;
}
.modal-box {
  background: white;
  border-radius: 10px;
  padding: 24px 28px;
  max-width: 560px;
  width: 90%;
  max-height: 70vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
}
.modal-box h3 { margin: 0 0 12px; padding-right: 30px; font-size: 16px; }
.modal-box p { margin: 0; line-height: 1.5; font-size: 14px; white-space: pre-wrap; }
.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: transparent;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--muted);
}
.modal-close:hover { color: var(--text); }
.desc-cell { text-align: left; }

.sort-link { color: var(--muted); text-decoration: none; }
.sort-link:hover { color: var(--text); text-decoration: underline; }

.lead-link { color: var(--text); text-decoration: none; font-weight: 500; }
.lead-link:hover { color: var(--accent); text-decoration: underline; }

.badge-tag {
  display: inline-block;
  background: #eef0f3;
  color: var(--text);
  border-radius: 10px;
  padding: 2px 10px;
  font-size: 11.5px;
}
.badge-origen-odoo { background: #e6ddfb; color: #5a3ba0; }
.badge-origen-maps { background: #d9f0e3; color: #1e7d46; }
.badge-origen-manual { background: #f0e6d9; color: #8a5a1e; }

.detail-topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}
.detail-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 24px;
  max-width: 900px;
}
.detail-header {
  display: flex;
  gap: 18px;
  align-items: center;
  margin-bottom: 20px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.detail-header h2 { margin: 0 0 8px; font-size: 20px; }
.detail-badges { display: flex; gap: 6px; flex-wrap: wrap; }
.detail-foto {
  width: 84px;
  height: 84px;
  border-radius: 10px;
  object-fit: cover;
  border: 1px solid var(--border);
}
.detail-foto-vacia {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  background: #f4f5f7;
}
.detail-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 18px;
  margin-bottom: 20px;
}
.detail-field label {
  display: block;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--muted);
  margin-bottom: 4px;
}
.detail-field { font-size: 14px; }
.detail-field-full {
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.detail-field-full p { margin: 0; line-height: 1.5; }

.btn-danger { background: #b3261e; }
.btn-danger:hover { background: #8f1d17; }

.foto-thumb {
  width: 36px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border);
  display: block;
}
.foto-cell { width: 44px; text-align: center; }

.opciones-grupo {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  margin-top: 4px;
}
.opciones-grupo strong { font-size: 13px; display: block; margin-bottom: 8px; }
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 14px;
}
.chk {
  flex-direction: row !important;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text) !important;
}
.chk input { width: auto !important; }

.login-body {
  height: 100vh;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #3d2938, var(--accent));
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
}
.login-card {
  background: white;
  padding: 32px 36px;
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.25);
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.login-card h2 { margin: 0; font-size: 18px; }
.login-card .muted { margin: 0 0 8px; font-size: 12.5px; color: var(--muted); }
.login-card input { padding: 10px 12px; border: 1px solid var(--border); border-radius: 6px; font-size: 14px; }
.login-error { color: #b3261e; font-size: 12.5px; }
.login-ok { color: #1e7d32; font-size: 12.5px; background: #eaf7ea; padding: 6px 8px; border-radius: 6px; }
