:root {
  --accent: #6d28d9;
  --accent-dark: #5b21b6;
  --ink: #1f2430;
  --muted: #8b91a1;
  --line: #e6e8ef;
  --bg: #f6f7fb;
  --ok: #15803d;
  --bad: #b91c1c;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 15px;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }
code {
  background: #eef0f6; padding: 1px 5px; border-radius: 4px;
  font-size: 13px;
}

/* topbar */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  background: #fff; border-bottom: 1px solid var(--line);
  padding: 12px 24px;
}
.brand { font-weight: 700; font-size: 18px; color: var(--ink); }
.brand span { color: var(--muted); font-weight: 400; }
.topbar nav { display: flex; gap: 16px; align-items: center; }

main { max-width: 960px; margin: 0 auto; padding: 24px; }
h1 { font-size: 22px; margin: 16px 0; }
h2 { font-size: 16px; margin: 26px 0 10px; color: var(--muted);
     text-transform: uppercase; letter-spacing: .04em; }

/* botones */
button, .btn {
  background: var(--accent); color: #fff; border: 0;
  padding: 9px 16px; border-radius: 8px; font-size: 14px;
  cursor: pointer; font-weight: 600;
}
button:hover, .btn:hover { background: var(--accent-dark); text-decoration: none; }
button.secondary { background: #fff; color: var(--ink);
  border: 1px solid var(--line); }
button.secondary:hover { background: #f0f1f6; }

/* tablas */
table { width: 100%; border-collapse: collapse; background: #fff;
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden; }
th, td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--line); }
th { background: #fafbfd; font-size: 12px; text-transform: uppercase;
  letter-spacing: .03em; color: var(--muted); }
tr:last-child td { border-bottom: 0; }
table.clickable tr { cursor: pointer; }
table.clickable tbody tr:hover { background: #faf8ff; }

/* badges */
.badge { display: inline-block; padding: 2px 9px; border-radius: 999px;
  font-size: 12px; font-weight: 600; background: #eef0f6; color: var(--ink); }
.st-open { background: #ddeeff; color: #1d4ed8; }
.st-closed { background: #e6e8ef; color: var(--muted); }
.st-cancelled { background: #fde2e2; color: var(--bad); }
.stx-quoted, .stx-won { background: #dcfce7; color: var(--ok); }
.stx-declined, .stx-no_response, .stx-expired { background: #fde2e2; color: var(--bad); }
.stx-clarifying, .stx-negotiating { background: #fef3c7; color: #b45309; }

/* formularios */
.form { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  padding: 20px; display: flex; flex-direction: column; gap: 16px; max-width: 640px; }
.form label { display: flex; flex-direction: column; gap: 5px; font-weight: 600;
  font-size: 14px; }
.form .row { display: flex; gap: 14px; flex-wrap: wrap; }
.form .row label { flex: 1; min-width: 160px; }
.form label.check { flex-direction: row; align-items: center; gap: 8px;
  font-weight: 400; }
input, textarea {
  font: inherit; padding: 9px 11px; border: 1px solid var(--line);
  border-radius: 8px; background: #fff; width: 100%;
}
input:focus, textarea:focus { outline: 2px solid #d8c9fb; border-color: var(--accent); }
textarea { resize: vertical; }
.form small { font-weight: 400; }

/* detalle de campaña */
.meta { display: flex; gap: 16px; flex-wrap: wrap; align-items: center;
  color: var(--muted); margin-bottom: 8px; }
.products { padding-left: 20px; }
.products li { margin: 4px 0; }
.actions { display: flex; gap: 12px; margin-top: 16px; flex-wrap: wrap; }

/* hilos de conversación */
.thread { background: #fff; border: 1px solid var(--line); border-radius: 10px;
  margin: 8px 0; padding: 6px 14px; }
.thread summary { cursor: pointer; font-weight: 600; padding: 6px 0; }
.msg { margin: 8px 0; padding: 8px 12px; border-radius: 10px; max-width: 80%; }
.msg.out { background: #ede9fe; margin-left: auto; }
.msg.in { background: #f0f1f6; }
.msg p { margin: 4px 0; white-space: pre-wrap; }
.msg-dir { font-size: 12px; font-weight: 700; color: var(--accent); }
.msg-ts { font-size: 11px; }

/* estado de WhatsApp */
.wa-status { padding: 8px 14px; border-radius: 8px; font-size: 13px;
  font-weight: 600; margin-bottom: 8px; }
.wa-status.ok { background: #dcfce7; color: var(--ok); }
.wa-status.bad { background: #fef3c7; color: #b45309; }

/* login */
.login-page { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; }
.login-card { background: #fff; border: 1px solid var(--line);
  border-radius: 14px; padding: 32px; width: 320px; text-align: center;
  display: flex; flex-direction: column; gap: 12px; }
.login-card h1 { margin: 0; color: var(--accent); }
.error { color: var(--bad); font-size: 14px; margin: 0; }

/* filtros */
.filters { display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
  margin-bottom: 14px; }
.filters select, .filters input { width: auto; }

/* selector de proveedores registrados */
.suppliers-pick { border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }
.suppliers-pick legend { font-weight: 600; font-size: 14px; padding: 0 6px; }
#suplist { max-height: 240px; overflow-y: auto; border: 1px solid var(--line);
  border-radius: 8px; margin-top: 6px; }
.suprow { display: flex; gap: 8px; align-items: center; padding: 6px 10px;
  border-bottom: 1px solid var(--line); font-weight: 400; cursor: pointer; }
.suprow:last-child { border-bottom: 0; }
.suprow:hover { background: #faf8ff; }

/* controles de conversación (pausar / tomar el control) */
.conv-controls { margin-top: 12px; padding-top: 12px;
  border-top: 1px solid var(--line); display: flex; flex-direction: column;
  gap: 10px; }
.manual-send { display: flex; flex-direction: column; gap: 6px; }
