:root {
  --ink: #1d2433;
  --muted: #637087;
  --line: #e3e7ee;
  --bg: #f5f7fa;
  --panel: #ffffff;
  --brand: #4c5cff;
  --brand-dark: #3341d6;
  --brand-soft: #eef0ff;
  --nav: #111827;
  --ok: #18a058;
  --warn: #e0a100;
  --bad: #d64545;
  --radius: 8px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: var(--ink); background: var(--bg); }
a { color: var(--brand); text-decoration: none; cursor: pointer; }
a:hover { text-decoration: underline; }
h1 { font-size: 22px; margin: 0; }
h2 { font-size: 16px; margin: 0 0 12px; }
h3 { font-size: 14px; margin: 0 0 8px; }
.boot { display: grid; place-items: center; height: 100vh; color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: 12px; }
.right { text-align: right; }
.hidden { display: none !important; }

/* Botones y campos */
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--ink); border-radius: 6px; padding: 7px 12px; cursor: pointer; }
button:hover { border-color: #c9d0dc; }
button.primary { background: var(--brand); border-color: var(--brand); color: #fff; }
button.primary:hover { background: var(--brand-dark); }
button.danger { color: var(--bad); }
button.link { border: 0; background: none; color: var(--brand); padding: 0; }
button:disabled { opacity: .5; cursor: default; }
input, select, textarea { font: inherit; width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 6px; background: #fff; color: var(--ink); }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-soft); border-color: var(--brand); }
textarea { min-height: 90px; resize: vertical; }
label { display: block; font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Acceso */
.auth { display: grid; place-items: center; min-height: 100vh; padding: 16px; }
.auth-card { width: 100%; max-width: 380px; background: var(--panel); border-radius: 12px; box-shadow: var(--shadow); padding: 28px; }
.auth-card h1 { margin-bottom: 4px; }
.auth-card .brand { font-weight: 700; color: var(--brand); letter-spacing: .3px; margin-bottom: 18px; }
.auth-card button.primary { width: 100%; margin-top: 16px; padding: 10px; }
.qr { display: block; margin: 12px auto; width: 180px; height: 180px; }
.secret { font-family: ui-monospace, Menlo, monospace; font-size: 12px; word-break: break-all; background: var(--bg); padding: 8px; border-radius: 6px; }

/* Estructura */
.shell { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.nav { background: var(--nav); color: #cbd2e0; padding: 16px 10px; display: flex; flex-direction: column; gap: 2px; }
.nav .logo { color: #fff; font-weight: 700; font-size: 16px; padding: 4px 10px 16px; }
.nav .logo span { color: #8f9bff; }
.nav a { color: #cbd2e0; padding: 8px 10px; border-radius: 6px; display: block; }
.nav a:hover { background: #1f2937; text-decoration: none; color: #fff; }
.nav a.active { background: #273246; color: #fff; }
.nav .sep { border-top: 1px solid #263041; margin: 10px 0; }
.nav .who { margin-top: auto; padding: 10px; font-size: 12px; color: #94a0b8; }
.nav .who b { color: #fff; display: block; }
.main { padding: 20px 24px; min-width: 0; }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.toolbar input, .toolbar select { width: auto; min-width: 180px; }

/* Tarjetas y tablas */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.table-wrap { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); overflow: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th { font-size: 12px; color: var(--muted); font-weight: 600; background: #fafbfc; position: sticky; top: 0; }
tr:hover td { background: #fafbff; }
td.wrap { white-space: normal; }
.pager { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; }
.empty { padding: 32px; text-align: center; color: var(--muted); }
.pill { display: inline-block; padding: 2px 8px; border-radius: 999px; background: var(--brand-soft); color: var(--brand-dark); font-size: 12px; }
.pill.won { background: #e6f6ed; color: var(--ok); }
.pill.lost { background: #fdecec; color: var(--bad); }
.pill.late { background: #fff4d6; color: #8a6400; }

/* Ficha de registro (tres columnas, como HubSpot) */
.record { display: grid; grid-template-columns: 300px minmax(0, 1fr) 300px; gap: 16px; align-items: start; }
.record .title { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-dark); display: grid; place-items: center; font-weight: 700; flex: none; }
.side-section { border-top: 1px solid var(--line); padding-top: 12px; margin-top: 12px; }
.side-section:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.assoc-item { display: flex; justify-content: space-between; gap: 8px; padding: 6px 0; border-bottom: 1px dashed var(--line); }
.assoc-item:last-child { border-bottom: 0; }

/* Actividades */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; flex-wrap: wrap; }
.tabs button { border: 0; border-bottom: 2px solid transparent; border-radius: 0; background: none; padding: 8px 10px; color: var(--muted); }
.tabs button.on { color: var(--brand); border-bottom-color: var(--brand); }
.timeline { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.tl-item { border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; background: #fff; }
.tl-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.tl-type { font-weight: 600; color: var(--ink); }
.tl-body { white-space: pre-wrap; word-break: break-word; }
.tl-item.task-done .tl-subject { text-decoration: line-through; color: var(--muted); }

/* Tablero de negocios */
.board { display: grid; grid-auto-flow: column; grid-auto-columns: minmax(220px, 1fr); gap: 12px; overflow-x: auto; padding-bottom: 8px; }
.col { background: #eef1f6; border-radius: var(--radius); padding: 10px; min-height: 300px; }
.col.drop { outline: 2px dashed var(--brand); }
.col-head { display: flex; justify-content: space-between; font-weight: 600; margin-bottom: 8px; font-size: 13px; }
.col-sum { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.deal-card { background: #fff; border: 1px solid var(--line); border-radius: 6px; padding: 8px 10px; margin-bottom: 8px; cursor: grab; box-shadow: var(--shadow); }
.deal-card .amt { font-weight: 600; }

/* Informes */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi .val { font-size: 22px; font-weight: 700; margin-top: 4px; }
.charts { display: grid; grid-template-columns: repeat(auto-fit, minmax(380px, 1fr)); gap: 16px; }
.chart-box { position: relative; height: 280px; }

/* Ventana modal y avisos */
.modal-bg { position: fixed; inset: 0; background: rgba(17, 24, 39, .45); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal { background: #fff; border-radius: 12px; width: 100%; max-width: 560px; max-height: 90vh; overflow: auto; padding: 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
.toast { position: fixed; right: 16px; bottom: 16px; background: var(--nav); color: #fff; padding: 10px 14px; border-radius: 8px; opacity: 0; transform: translateY(8px); transition: .2s; pointer-events: none; max-width: 420px; z-index: 60; }
.toast.show { opacity: 1; transform: none; }
.toast.error { background: var(--bad); }

@media (max-width: 1200px) { .record { grid-template-columns: 280px minmax(0, 1fr); } .record > .rail { grid-column: 1 / -1; } }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .who { margin-top: 0; }
  .record { grid-template-columns: 1fr; }
  .main { padding: 16px; }
  .charts { grid-template-columns: 1fr; }
  .field-row { grid-template-columns: 1fr; }
}
