:root {
  --bg: #f5f7fa;
  --surface: #ffffff;
  --ink: #1a2233;
  --ink-soft: #5b6675;
  --line: #e6eaf0;
  --brand: #0a4d8c;
  --brand-2: #06b6d4;
  --brand-tint: #eaf3fb;
  --ok: #16a34a;
  --warn: #d97706;
  --bad: #dc2626;
  --mql: #7c3aed;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16,24,40,.06), 0 1px 2px rgba(16,24,40,.04);
  --sidebar-w: 236px;
  --topbar-h: 56px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg); color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

/* ─── Barra superior ─── */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h); z-index: 40;
  background: var(--surface); border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 24px; padding: 0 20px;
}
.tb-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; letter-spacing: -.02em; }
.tb-brand .dot { width: 24px; height: 24px; border-radius: 7px; background: linear-gradient(135deg, var(--brand), var(--brand-2)); }
.tb-tabs { display: flex; gap: 4px; }
.tb-tabs button {
  border: none; background: transparent; font-family: inherit; font-size: 14px; font-weight: 600;
  color: var(--ink-soft); padding: 8px 18px; border-radius: 10px; cursor: pointer; transition: .15s;
}
.tb-tabs button:hover { background: var(--bg); color: var(--ink); }
.tb-tabs button.active { background: var(--brand); color: #fff; }
.tb-right { margin-left: auto; display: flex; align-items: center; gap: 16px; }
.tb-right .user { display: flex; align-items: center; gap: 8px; font-size: 13px; }
.tb-right .user img, .tb-right .user .avatar-fallback {
  width: 30px; height: 30px; border-radius: 50%; object-fit: cover;
  background: var(--brand-tint); color: var(--brand);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 12px;
}
.tb-right .user .rol { font-size: 11px; color: var(--ink-soft); }
.tb-logout { border: 1px solid var(--line); background: var(--surface); color: var(--ink-soft); font-family: inherit; font-size: 13px; padding: 7px 14px; border-radius: 9px; cursor: pointer; }
.tb-logout:hover { background: var(--bg); }
.lang-toggle { display: flex; gap: 4px; }
.lang-toggle button { padding: 6px 10px; border: 1px solid var(--line); background: var(--surface); border-radius: 8px; font-size: 12px; cursor: pointer; color: var(--ink-soft); font-family: inherit; }
.lang-toggle button.active { background: var(--brand); color: #fff; border-color: var(--brand); }

/* ─── Layout ─── */
.layout { display: flex; min-height: 100vh; padding-top: var(--topbar-h); }
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--line);
  position: fixed; top: var(--topbar-h); bottom: 0; left: 0; overflow-y: auto;
}
.nav { padding: 12px 8px; }
.nav a {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin: 2px 0; border-radius: 10px;
  color: var(--ink-soft); text-decoration: none; font-size: 14px; font-weight: 500;
  cursor: pointer; transition: background .15s, color .15s;
}
.nav a:hover { background: var(--bg); color: var(--ink); }
.nav a.active { background: var(--brand-tint); color: var(--brand); }
.nav a.soon { opacity: .55; }
.nav a .soon-tag { margin-left: auto; font-size: 10px; text-transform: uppercase; letter-spacing: .05em; color: var(--warn); border: 1px solid #f3ddb8; background: #fdf6ec; padding: 1px 6px; border-radius: 6px; }
.nav .group-label { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--ink-soft); padding: 14px 12px 4px; opacity: .7; }

/* ─── Contenido ─── */
.main { margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; max-width: 1200px; }
.page-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.page-head h1 { font-size: 22px; font-weight: 700; letter-spacing: -.02em; margin: 0; }
.page-head .sub { font-size: 13px; color: var(--ink-soft); margin-top: 4px; }

/* ─── Métricas ─── */
.metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.metric { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.metric .label { font-size: 12px; color: var(--ink-soft); font-weight: 500; }
.metric .value { font-size: 28px; font-weight: 700; letter-spacing: -.03em; margin-top: 6px; }

/* ─── Tabla ─── */
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th { text-align: left; padding: 12px 16px; font-weight: 600; color: var(--ink-soft); background: var(--bg); font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td { padding: 12px 16px; border-top: 1px solid var(--line); }
tr:hover td { background: #fafbfc; }

/* ─── Chips ─── */
.chip { display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.chip.nuevo { background: #eef2f7; color: #64748b; }
.chip.contactado { background: #e0f2fe; color: #0369a1; }
.chip.mql { background: #f3e8ff; color: var(--mql); }
.chip.descartado { background: #f1f5f9; color: #94a3b8; }
.chip.ganado { background: #dcfce7; color: var(--ok); }
.chip.perdido { background: #fee2e2; color: var(--bad); }
.chip.recibido, .chip.sql, .chip.negociacion { background: var(--brand-tint); color: var(--brand); }

/* ─── Botones ─── */
.btn { display: inline-flex; align-items: center; gap: 6px; padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 13px; font-weight: 600; cursor: pointer; transition: .15s; font-family: inherit; }
.btn:hover { background: var(--bg); }
.btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.mql { background: var(--mql); color: #fff; border-color: var(--mql); }
.btn.sm { padding: 5px 10px; font-size: 12px; border-radius: 8px; }

/* ─── Modal ─── */
.overlay { position: fixed; inset: 0; background: rgba(16,24,40,.4); display: none; align-items: center; justify-content: center; z-index: 50; }
.overlay.open { display: flex; }
.modal { background: var(--surface); border-radius: 16px; width: 460px; max-width: 92vw; padding: 24px; box-shadow: 0 20px 60px rgba(16,24,40,.2); max-height: 90vh; overflow-y: auto; }
.modal h2 { margin: 0 0 18px; font-size: 18px; }
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 600; color: var(--ink-soft); margin-bottom: 6px; }
.field input, .field select, .field textarea { width: 100%; padding: 9px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit; }
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--brand-2); box-shadow: 0 0 0 3px rgba(6,182,212,.15); }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }

.empty { padding: 48px 16px; text-align: center; color: var(--ink-soft); font-size: 14px; }
.toolbar { display: flex; gap: 8px; align-items: center; margin-bottom: 16px; }
.toolbar select { padding: 8px 12px; border: 1px solid var(--line); border-radius: 10px; font-size: 13px; background: var(--surface); }

/* ─── Placeholder de módulo en preparación ─── */
.soon-panel { background: var(--surface); border: 1px dashed var(--line); border-radius: var(--radius); padding: 56px 24px; text-align: center; }
.soon-panel .ic { font-size: 34px; margin-bottom: 12px; }
.soon-panel h2 { margin: 0 0 8px; font-size: 18px; }
.soon-panel p { margin: 0 auto; max-width: 460px; color: var(--ink-soft); font-size: 14px; line-height: 1.5; }
.soon-panel .fields { margin-top: 18px; font-size: 12px; color: var(--ink-soft); }

@media (max-width: 860px) {
  .tb-brand span:last-child { display: none; }
  .tb-right .user > div { display: none; }
  .sidebar { transform: translateX(-100%); transition: transform .2s; z-index: 45; }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; padding: 20px; }
  .metrics { grid-template-columns: repeat(2, 1fr); }
}
